Skip to content

Pass constants into #[spirv(compute(threads(...)))] ? #697

Closed as not planned
@hrydgard

Description

@hrydgard

Quite often, an algorithm will have a working data size configurable by a constant, and this size is correlated with the thread group size. Here's what I would like to do, but doesn't work:

const BUF_SIZE: u32 = 64;

// use BUF_SIZE to declare arrays and what not

#[spirv(compute(threads(BUF_SIZE, 1, 1)))]
pub fn main_cs(...) { ... }

Instead I have to fall back to:

#[spirv(compute(threads(64, 1, 1)))]  // 64 == BUF_SIZE

I guess the way attributes work might make this impossible? Or is there a way?

In GLSL/HLSL, this is trivial but that's because there's a preprocessor which just injects a #define-d value through text replacement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    t: enhancementA new feature or improvement to an existing one.t: ergonomicsLanguage ergonomics discussions and experimentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions