Closed Korijn closed 3 years ago
That should certainly be possible. Can be done for either bytecode or SpirV.
Example:
from pyshader import python2shader, i32, f32, ivec3, Array
@python2shader
def compute_shader_copy(
index: ("input", "GlobalInvocationId", ivec3),
data1: ("buffer", 0, Array(i32)),
data2: ("buffer", 1, Array(i32)),
):
i = index.x
data2[i] = data1[i]
with open("copy.comp.spv", "wb") as fh:
fh.write(compute_shader_copy.to_spirv())
Is it possible to precompile shaders to files with the current pyshader API? Or would that still need to happen at runtime because it depends on drivers & hardware?