Closed almarklein closed 4 years ago
I'm not sure, implicit conversion in shaders smells like trouble... What's the use case for it? You have to be explicit about input and output types anyway right?
The use case is being able to write e.g. n / 3
instead of f32(n) / 3.0
inside a shader.
I see. Maybe I'm overthinking this :) I was mostly wondering how much control you would want to have over the generated spirv code in optimization scenarios, but maybe it's just not a very big deal
Closing. I think the answer is no. SpirV is much more strictly typed than Python, and it's ok to "feel" that when writing a shader.
Plus it helps to argue about the types of your code if scalar literals comply with the types of other values in an operation:
...
b = a + 1 # I now know that b is an integer type,
# otherwise the compiler would have complained
Pyhon implicitly converts ints to floats when one of the operands is a float, or when the op is division. Should we follow this approach or enforce strict types?
I think the former because it makes the code feel more Pythonic, and I don't think it will cause much confusion as long as we stick to only doing it with int/float.