diff options
| author | Yong He <yonghe@outlook.com> | 2022-02-25 20:49:31 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-25 20:49:31 -0800 |
| commit | c31577953d5041c82375c22d847c2eba06106c58 (patch) | |
| tree | bc685a8b63fc13cb85d160ae13df950056ca6e91 /tests | |
| parent | 8990d270e3a0c01b1f7abbf4f79556c5ef82a096 (diff) | |
Improved SCCP, inlining and resource specialization passes, legalize `ImageSubscript` for GLSL (#2146)
Diffstat (limited to 'tests')
10 files changed, 149 insertions, 24 deletions
diff --git a/tests/bugs/sccp-switch-case-removal.slang b/tests/bugs/sccp-switch-case-removal.slang new file mode 100644 index 000000000..cf8d36ef7 --- /dev/null +++ b/tests/bugs/sccp-switch-case-removal.slang @@ -0,0 +1,25 @@ +//TEST(compute,vulkan):COMPARE_COMPUTE_EX:-vk -slang -compute -shaderobj + +//TEST_INPUT:ubuffer(data=[9 9 9 9], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +static const uint kConstant = 5; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + float x = 1.0; + switch(kConstant) + { + case 5: + int tid = int(dispatchThreadID.x); + outputBuffer[tid] = 0; + break; + case 1: + ddx(x); // this should trigger glslang error if it doesn't get eliminated by sccp. + break; + default: + ddy(x); // this should trigger glslang error if it doesn't get eliminated by sccp. + break; + } +}
\ No newline at end of file diff --git a/tests/bugs/sccp-switch-case-removal.slang.expected.txt b/tests/bugs/sccp-switch-case-removal.slang.expected.txt new file mode 100644 index 000000000..ae25f7400 --- /dev/null +++ b/tests/bugs/sccp-switch-case-removal.slang.expected.txt @@ -0,0 +1,4 @@ +0 +0 +0 +0
\ No newline at end of file diff --git a/tests/bugs/vk-image-write.slang b/tests/bugs/vk-image-write.slang new file mode 100644 index 000000000..10141384c --- /dev/null +++ b/tests/bugs/vk-image-write.slang @@ -0,0 +1,16 @@ +//TEST:CROSS_COMPILE: -profile ps_5_0 -entry main -target spirv-assembly + +// Ensure that we can lower to `imageStore` correctly. + +RWTexture2D<float4> t; + +void writeColor(float3 v) +{ + t[uint2(0,0)].xyz += v; +} + +float4 main() : SV_Target +{ + writeColor(float3(1.0)); + return float4(0); +} diff --git a/tests/bugs/vk-image-write.slang.glsl b/tests/bugs/vk-image-write.slang.glsl new file mode 100644 index 000000000..7b9bcebf9 --- /dev/null +++ b/tests/bugs/vk-image-write.slang.glsl @@ -0,0 +1,40 @@ +//TEST_IGNORE_FILE: + +#version 450 +layout(row_major) uniform; +layout(row_major) buffer; + +layout(rgba32f) +layout(binding = 0) +uniform image2D t_0; + +void writeColor_0(vec3 v_0) +{ + const uvec2 _S1 = uvec2(0U, 0U); + + vec4 _S2 = (imageLoad((t_0), ivec2((_S1)))); + + vec3 _S3 = _S2.xyz + v_0; + + ivec2 _S4 = ivec2(_S1); + + vec4 _S5 = imageLoad(t_0,_S4); + + vec4 _S6 = _S5; + _S6.xyz = _S3; + + imageStore(t_0,_S4,_S6); + return; +} + + +layout(location = 0) +out vec4 _S7; + +void main() +{ + writeColor_0(vec3(1.00000000000000000000)); + _S7 = vec4(0); + return; +} + diff --git a/tests/bugs/vk-structured-buffer-load.hlsl.glsl b/tests/bugs/vk-structured-buffer-load.hlsl.glsl index 1c7ec8043..05c8de193 100644 --- a/tests/bugs/vk-structured-buffer-load.hlsl.glsl +++ b/tests/bugs/vk-structured-buffer-load.hlsl.glsl @@ -43,13 +43,12 @@ void main() float HitT_0 = (gl_RayTmaxNV); RayData.PackedHitInfoA_0.x = HitT_0; - const uint use_rcp_0 = uint(0); - float offsfloat_0 = ((gParamBlock_sbuf_0)._data[(int(uint(0)))]); + float offsfloat_0 = ((gParamBlock_sbuf_0)._data[(0)]); - uint use_rcp_1 = use_rcp_0|uint(HitT_0 > 0.00000000000000000000); + uint use_rcp_0 = 0U | uint(HitT_0 > 0.00000000000000000000); - if(bool(use_rcp_1)) + if(bool(use_rcp_0)) { float tmpA = rcp_0(offsfloat_0); @@ -60,7 +59,7 @@ void main() else { - if(use_rcp_1 > uint(0)&&offsfloat_0 == 0.00000000000000000000) + if(use_rcp_0 > 0U&&offsfloat_0 == 0.00000000000000000000) { float tmpB = (inversesqrt((offsfloat_0 + 1.00000000000000000000))); diff --git a/tests/optimization/func-resource-result/func-resource-result-complex.slang b/tests/optimization/func-resource-result/func-resource-result-complex.slang new file mode 100644 index 000000000..a5585ff4c --- /dev/null +++ b/tests/optimization/func-resource-result/func-resource-result-complex.slang @@ -0,0 +1,45 @@ +// func-resource-result-simple.slang + +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj + +// Test that a function that returns a resource type can be +// compiled for targets that don't natively support resource +// return values. + +//TEST_INPUT:set textures=[Texture2D(size=4, content = zero), Texture2D(size=4, content = one)] +Texture2D textures[2]; + +//TEST_INPUT:set sampler=Sampler +SamplerState sampler; + +Texture2D getTex(int index) +{ + Texture2D result; + // Note: `index` here will need to be a compile time constant in order to generate + // valid GLSL. If constant folding and function inlining are all done correctly + // we should be able to compile this. + if (index == 0) + result = textures[1]; + else + result = textures[0]; + return result; +} + +int test(int val) +{ + // Make sure index is a compile-time constant. + return getTex(int(0.0) + 1*2 < 5 ? 0 : 1).SampleLevel(sampler, float2(0,0), 0).x == 0.0 ? 0 : 1; +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + int inVal = tid; + int outVal = test(inVal); + outputBuffer[tid] = outVal; +} diff --git a/tests/optimization/func-resource-result/func-resource-result-complex.slang.expected.txt b/tests/optimization/func-resource-result/func-resource-result-complex.slang.expected.txt new file mode 100644 index 000000000..ef529012e --- /dev/null +++ b/tests/optimization/func-resource-result/func-resource-result-complex.slang.expected.txt @@ -0,0 +1,4 @@ +1 +1 +1 +1
\ No newline at end of file diff --git a/tests/pipeline/rasterization/conservative-rasterization/inner-coverage.slang.glsl b/tests/pipeline/rasterization/conservative-rasterization/inner-coverage.slang.glsl index 1454d493f..59fecd544 100644 --- a/tests/pipeline/rasterization/conservative-rasterization/inner-coverage.slang.glsl +++ b/tests/pipeline/rasterization/conservative-rasterization/inner-coverage.slang.glsl @@ -1,14 +1,14 @@ +//TEST_IGNORE_FILE: #version 450 - #extension GL_NV_conservative_raster_underestimation : require +layout(row_major) uniform; +layout(row_major) buffer; layout(location = 0) out vec4 _S1; void main() { - vec4 _S2; - _S2 = vec4(uint(gl_FragFullyCoveredNV)); - _S1 = _S2; + _S1 = vec4(uint(gl_FragFullyCoveredNV)); return; } diff --git a/tests/pipeline/rasterization/fragment-shader-interlock.slang.glsl b/tests/pipeline/rasterization/fragment-shader-interlock.slang.glsl index a12b9827b..1818b7789 100644 --- a/tests/pipeline/rasterization/fragment-shader-interlock.slang.glsl +++ b/tests/pipeline/rasterization/fragment-shader-interlock.slang.glsl @@ -2,6 +2,8 @@ #version 450 #extension GL_ARB_fragment_shader_interlock : require +layout(row_major) uniform; +layout(row_major) buffer; layout(rgba32f) layout(binding = 0) @@ -15,13 +17,9 @@ out vec4 _S2; void main() { - vec4 _S3; - beginInvocationInterlockARB(); - vec4 _S4 = (imageLoad((entryPointParams_texture_0), ivec2((uvec2(_S1.xy))))); - - _S3 = _S4; + vec4 _S3 = (imageLoad((entryPointParams_texture_0), ivec2((uvec2(_S1.xy))))); imageStore((entryPointParams_texture_0), ivec2((uvec2(_S1.xy))), _S3 + _S1); endInvocationInterlockARB(); diff --git a/tests/pipeline/rasterization/get-attribute-at-vertex.slang.glsl b/tests/pipeline/rasterization/get-attribute-at-vertex.slang.glsl index c07e9b61c..1da5f4f8a 100644 --- a/tests/pipeline/rasterization/get-attribute-at-vertex.slang.glsl +++ b/tests/pipeline/rasterization/get-attribute-at-vertex.slang.glsl @@ -2,24 +2,18 @@ //TEST_IGNORE_FILE: #version 450 - #extension GL_NV_fragment_shader_barycentric : require +layout(row_major) uniform; +layout(row_major) buffer; pervertexNV layout(location = 0) -in vec4 _S1[3]; +in vec4 _S1[3]; layout(location = 0) out vec4 _S2; void main() { - vec4 _S3; - - _S3 = gl_BaryCoordNV.x * _S1[0] - + gl_BaryCoordNV.y * _S1[1] - + gl_BaryCoordNV.z * _S1[2]; - - _S2 = _S3; - + _S2 = gl_BaryCoordNV.x * ((_S1)[(0U)]) + gl_BaryCoordNV.y * ((_S1)[(1U)]) + gl_BaryCoordNV.z * ((_S1)[(2U)]); return; } |
