KStocky / ShaderTestFramework

An automation testing framework for testing shader code
MIT License
20 stars 1 forks source link

Static Assert macro #26

Closed KStocky closed 5 months ago

KStocky commented 5 months ago

Is your feature request related to a problem? Please describe. We have a lot of template meta programming going on so we probably don't need to RUN tests to test them. The compilation result would be enough. It would be better if we just had a nice way of failing on a compile time known condition. So static assert. But static asserts don't exist in HLSL

Describe the solution you'd like There are a number of ways to emulate static asserts e.g. a static array and the size of the array is given by the condition false = 0 -> cant have an array of size 0 true = 1 -> compiles and is perfectly fine

Another way is via a struct definition. It inherits from a class template that takes a bool parameter, and only the true specialization is valid.