Open thargy opened 6 years ago
Note, this will also make it easier to test, as an automatic test can easily be added to ensure all ShaderBuiltins
members throw a ShaderBuiltinException
on invocation. Further, an automated test can be added to test consistency between Builtins
members on CPU & GPU.
Further to the conversations in #65, #67 and GH-77, we should consider reserving
ShaderBuiltins
for members that will throw aShaderBuiltinException
as they cannot reasonably be implemented on the CPU - therefore code that uses them cannot be run on the CPU.Methods that can have CPU equivalents should be in a seperate class (
Builtins
) to indicate that they can run on the GPU & CPU. This makes it easy to see if a file is using GPU only functionality (as it will referenceShaderBuiltins
. By only includingBuiltins
you can be sure the members used will be available when running the same code directly on the CPU.Note, before GH-77 all members of
ShaderBuiltins
throw aShaderBuiltinException
anyway when executed on the CPU, even when they could be implemented to run on the CPU, so this wasn't as big an issue. However, going forward, the ability to share code between GPU & CPU is a USP of the library, and so consideration should be given to creating CPU implementations of members whenever feasible, so the distinction becomes more important.