yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
b61371d06
master
Binding Generation Tests
These tests ensure that the compiler can correctly add explicit binding information (e.g., HLSL register semantics) to code that does not originally have them.
Example
Given code like:
Texture2D ta;
Texture2D tb;
We expect to produce output like:
Texture2D ta : register(t0);
Texture2D tb : register(t1);
The resulting code guarantees that tb will always be assigned to the same location, regardless of how these values are (or are not) used in later shader code.
Methodology
These tests currently rely on the ability to run the same HLSL code through the Slang compiler driver and execute either Slang, or HLSL. We write an example like the above by wrapping explicit register semantics in a macro:
Texture2D ta R(: register(t0));
Texture2D tb R(: register(t1));
In the HLSL case, these annotations will manually place things where we want them, while in the Slang case, we define the macro to have an empty expansion, so that the annotations express our expectation for what the compiler will auto-generate.
1Binding Generation Tests 2======================== 3 4These tests ensure that the compiler can correctly add explicit binding information (e.g., HLSL `register` semantics) to code that does not originally have them. 5 6Example 7------- 8 9Given code like: 10 11Texture2D ta; 12Texture2D tb; 13 14We expect to produce output like: 15 16Texture2D ta : register(t0); 17Texture2D tb : register(t1); 18 19The resulting code guarantees that `tb` will always be assigned to the same location, regardless of how these values are (or are not) used in later shader code. 20 21Methodology 22----------- 23 24These tests currently rely on the ability to run the same HLSL code through the Slang compiler driver and execute either Slang, or HLSL. We write an example like the above by wrapping explicit `register` semantics in a macro: 25 26Texture2D ta R(: register(t0)); 27Texture2D tb R(: register(t1)); 28 29In the HLSL case, these annotations will manually place things where we want them, while in the Slang case, we define the macro to have an empty expansion, so that the annotations express our expectation for what the compiler will auto-generate.