diff options
Diffstat (limited to 'tests/render')
| -rw-r--r-- | tests/render/cross-compile0.hlsl | 8 | ||||
| -rw-r--r-- | tests/render/cross-compile0.slang | 21 |
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/render/cross-compile0.hlsl b/tests/render/cross-compile0.hlsl index e41de7ef1..b482035d1 100644 --- a/tests/render/cross-compile0.hlsl +++ b/tests/render/cross-compile0.hlsl @@ -6,6 +6,10 @@ // but the two will share a dependency on a file of // pure Spire code that provides the actual shading logic. + +// Pull in Spire code depdendency using extended syntax: +__import cross_compile0; + #if defined(__HLSL__) cbuffer Uniforms @@ -74,6 +78,8 @@ FragmentStageOutput fragmentMain(FragmentStageInput input) float3 color = input.coarseVertex.color; + color = transformColor(color); + output.fragment.color = float4(color, 1.0); return output; @@ -130,6 +136,8 @@ void main() { vec3 color = coarse_color; + color = transformColor(color); + fragment_color = vec4(color, 1.0); } diff --git a/tests/render/cross-compile0.slang b/tests/render/cross-compile0.slang new file mode 100644 index 000000000..d53005688 --- /dev/null +++ b/tests/render/cross-compile0.slang @@ -0,0 +1,21 @@ +//TEST_IGNORE_FILE: + +// This file implements the "library" code +// that both the HLSL and GLSL shaders share. +// +// This code is written in Slang (more or less +// just HLSL), and will be translated as needed +// for each of the targets. + +float3 transformColor(float3 color) +{ + float3 result; + + result.x = sin(20.0 * (color.x + color.y)); + result.y = saturate(cos(color.z * 30.0)); + result.z = sin(color.x * color.y * color.z * 100.0); + + result = 0.5 * (result + 1); + + return result; +}
\ No newline at end of file |
