pygfx / pyshader

Write modern GPU shaders in Python!
BSD 2-Clause "Simplified" License
72 stars 1 forks source link

Add support for runtime constants (specialization)? #25

Open almarklein opened 4 years ago

almarklein commented 4 years ago

SpirV supports specialization: setting constants at runtime, can be useful?

axsaucedo commented 3 years ago

+1 on this, it would be great if it could be defined similar to the parameters, as:

@python2shader
def compute_shader_multiply(
        index: ("input", "GlobalInvocationId", ivec3),
        data1: ("buffer", 0, Array(f32)),
        data2: ("buffer", 1, Array(f32)),
        data3: ("buffer", 2, Array(f32)),
        constants=[Constant("LEN_VAR", 0, )]):
    i = index.x
    data3[i] = data1[i] * data2[i]