diff options
| author | ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> | 2024-04-03 09:30:46 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-03 09:30:46 -0400 |
| commit | a697b2c6707ee699cb734a03fa529dd214ac66cc (patch) | |
| tree | 1b68f4267159828092b512361faff4729510ea39 /tests | |
| parent | c0482ec12d683e53aca56543b620a4ec02082e29 (diff) | |
Implement 8.14-8.19 of OpenGL-GLSL specification
The following PR implements 8.14-8.19 of the [OpenGL-GLSL specification](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.pdf).
Fully implements all functions and built-in type's, resolves https://github.com/shader-slang/slang/issues/3692 for GLSL & SPRI-V targets.
_Notes:_
Testing Tools:
* Fragment shaders cannot test computational results. Only OpCodes are checked for proper emitting.
Implementation Notes:
* SubpassInput requires an unknown image format.
* SubpassInput is disjoint from TextureType: __SubpassImpl (.slang) & SubpassInputType (Compiler) to reduce code generation required.
* SubpassInput required an additional input layout modifier, input_attachment_index, this was added as a new parameter binding attribute. Since the following qualifiers can overlap with different resources (`layout(input_attachment_index = 0, binding = 0, set = 0)`) input_attachment_index is checked for overlapping resource bindings separately from other qualifiers with `LayoutResourceKind::InputAttachmentIndex`.
* `GLSLInputAttachmentIndexLayoutModifier` was added to enforce function parameters only accepting `in` decorated variables.
* `in` decorated variables needed to have emitting modified to allow directly emitting the variable into function calls if used as a parameter, normally Slang has a "global variable" shadow as a "global parameter" through a copy. This does not work and is solved using `GlobalVariableShadowingGlobalParameterDecoration` to build a relationship of "global variable" to "global parameter", we then resolve this relationship and replace "global variable" uses later in compile.
* `AtomicCounterMemory` memory-constraint requires `OpCapability AtomicStorage`, `AtomicStorage` is invalid for Vulkan targets. glslang outputs for `barrier`, `memoryBarrier`, and `groupMemoryBarrier` `AtomicCounterMemory` as a memory constraint. This compiles as valid SPIR-V for Vulkan since `OpCapability AtomicStorage` is not declared. This behavior of glslang is undefined as per [3.31.Capability of the SPIR-V specification](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_capability). We will omit `AtomicCounterMemory` from our barrier calls.
Diffstat (limited to 'tests')
13 files changed, 656 insertions, 0 deletions
diff --git a/tests/glsl-intrinsic/fragment-processing/fragment-processing-interpolate-simple.slang b/tests/glsl-intrinsic/fragment-processing/fragment-processing-interpolate-simple.slang new file mode 100644 index 000000000..fb1c72ed7 --- /dev/null +++ b/tests/glsl-intrinsic/fragment-processing/fragment-processing-interpolate-simple.slang @@ -0,0 +1,28 @@ +//TEST:SIMPLE(filecheck=CHECK_GLSL): -target glsl -stage fragment -entry main -allow-glsl +//TEST:SIMPLE(filecheck=CHECK_SPV): -target spirv -emit-spirv-directly -stage fragment -entry main -allow-glsl +#version 450 +// CHECK_SPV-DAG: OpEntryPoint +// CHECK_GLSL-DAG: void main( + +layout(location = 0) out ivec4 outColorActual; + +layout (location = 0) in float inDataV1; + +bool isOk(float a, float b) { return (a == b); } + +bool testFragmentProcessingInterpolateFunctions() +{ + float tmpStore = inDataV1; + return true + && interpolateAtCentroid(inDataV1) != -1.0f + && (tmpStore + inDataV1) != -0.1f + && isOk(inDataV1, tmpStore) + && inDataV1 != -1.0f + ; +} + +void main() { + outColorActual = ivec4(true + && testFragmentProcessingInterpolateFunctions() + ); +}
\ No newline at end of file diff --git a/tests/glsl-intrinsic/fragment-processing/fragment-processing-non-input-param-error.slang b/tests/glsl-intrinsic/fragment-processing/fragment-processing-non-input-param-error.slang new file mode 100644 index 000000000..638dd0ea7 --- /dev/null +++ b/tests/glsl-intrinsic/fragment-processing/fragment-processing-non-input-param-error.slang @@ -0,0 +1,20 @@ +//TEST:SIMPLE(filecheck=CHECK_GLSL): -target glsl -stage fragment -entry main -allow-glsl +//TEST:SIMPLE(filecheck=CHECK_SPV): -target spirv -emit-spirv-directly -stage fragment -entry main -allow-glsl +#version 450 +// CHECK_SPV-DAG: error 31208 +// CHECK_GLSL-DAG: error 31208 + +layout(location = 0) out ivec4 outColorActual; + +layout (location = 0) in float inDataV1; +bool testFragmentProcessingInterpolateFunctions() +{ + float v = 1.0f; + return interpolateAtCentroid(v) != -1.0f; +} + +void main() { + outColorActual = ivec4(true + && testFragmentProcessingInterpolateFunctions() + ); +}
\ No newline at end of file diff --git a/tests/glsl-intrinsic/fragment-processing/fragment-processing.slang b/tests/glsl-intrinsic/fragment-processing/fragment-processing.slang new file mode 100644 index 000000000..909679bbe --- /dev/null +++ b/tests/glsl-intrinsic/fragment-processing/fragment-processing.slang @@ -0,0 +1,137 @@ +//TEST:SIMPLE(filecheck=CHECK_GLSL): -target glsl -stage fragment -entry main -allow-glsl +//TEST:SIMPLE(filecheck=CHECK_SPV): -target spirv -emit-spirv-directly -stage fragment -entry main -allow-glsl +#version 450 + +layout(location = 0) out ivec4 outColorActual; + +layout (location = 0) in float inDataV1; +layout (location = 1) in vec2 inDataV2; +layout (location = 2) in vec3 inDataV3; +layout (location = 3) in vec4 inDataV4; + +bool testFragmentProcessingDerivativeFunctionsScalar() +{ +// CHECK_SPV: OpDPdx +// CHECK_GLSL: dFdx +// CHECK_SPV: OpDPdy +// CHECK_GLSL: dFdy +// CHECK_SPV: OpDPdxFine +// CHECK_GLSL: dFdxFine +// CHECK_SPV: OpDPdyFine +// CHECK_GLSL: dFdyFine +// CHECK_SPV: OpDPdxCoarse +// CHECK_GLSL: dFdxCoarse +// CHECK_SPV: OpDPdyCoarse +// CHECK_GLSL: dFdyCoarse +// CHECK_SPV: OpFwidth +// CHECK_GLSL: fwidth +// CHECK_SPV: OpFwidthFine +// CHECK_GLSL: fwidthFine +// CHECK_SPV: OpFwidthCoarse +// CHECK_GLSL: fwidthCoarse + return true + && dFdx(1.0f) != -1.0f + && dFdy(1.0f) != -1.0f + && dFdxFine(1.0f) != -1.0f + && dFdyFine(1.0f) != -1.0f + && dFdxCoarse(1.0f) != -1.0f + && dFdyCoarse(1.0f) != -1.0f + && fwidth(1.0f) != -1.0f + && fwidthFine(1.0f) != -1.0f + && fwidthCoarse(1.0f) != -1.0f + ; +} +__generic<let N:int> +bool testFragmentProcessingDerivativeFunctionsVector() +{ +// CHECK_SPV: OpDPdx +// CHECK_GLSL: dFdx +// CHECK_SPV: OpDPdy +// CHECK_GLSL: dFdy +// CHECK_SPV: OpDPdxFine +// CHECK_GLSL: dFdxFine +// CHECK_SPV: OpDPdyFine +// CHECK_GLSL: dFdyFine +// CHECK_SPV: OpDPdxCoarse +// CHECK_GLSL: dFdxCoarse +// CHECK_SPV: OpDPdyCoarse +// CHECK_GLSL: dFdyCoarse +// CHECK_SPV: OpFwidth +// CHECK_GLSL: fwidth +// CHECK_SPV: OpFwidthFine +// CHECK_GLSL: fwidthFine +// CHECK_SPV: OpFwidthCoarse +// CHECK_GLSL: fwidthCoarse + return true + && dFdx(vector<float,N>(1.0f)) != vector<float,N>(-1.0f) + && dFdy(vector<float,N>(1.0f)) != vector<float,N>(-1.0f) + && dFdxFine(vector<float,N>(1.0f)) != vector<float,N>(-1.0f) + && dFdyFine(vector<float,N>(1.0f)) != vector<float,N>(-1.0f) + && dFdxCoarse(vector<float,N>(1.0f)) != vector<float,N>(-1.0f) + && dFdyCoarse(vector<float,N>(1.0f)) != vector<float,N>(-1.0f) + && fwidth(vector<float,N>(1.0f)) != vector<float,N>(-1.0f) + && fwidthFine(vector<float,N>(1.0f)) != vector<float,N>(-1.0f) + && fwidthCoarse(vector<float,N>(1.0f)) != vector<float,N>(-1.0f) + ; +} +bool testFragmentProcessingInterpolateFunctions() +{ +// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtCentroid %inDataV1 +// CHECK_GLSL: interpolateAtCentroid{{.*}}inDataV1 +// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtSample %inDataV1 {{.*}} +// CHECK_GLSL: interpolateAtSample{{.*}}inDataV1 +// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtOffset %inDataV1 {{.*}} +// CHECK_GLSL: interpolateAtOffset{{.*}}inDataV1 + +// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtCentroid %inDataV2 +// CHECK_GLSL: interpolateAtCentroid{{.*}}inDataV2 +// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtSample %inDataV2 {{.*}} +// CHECK_GLSL: interpolateAtSample{{.*}}inDataV2 +// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtOffset %inDataV2 {{.*}} +// CHECK_GLSL: interpolateAtOffset{{.*}}inDataV2 + +// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtCentroid %inDataV3 +// CHECK_GLSL: interpolateAtCentroid{{.*}}inDataV3 +// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtSample %inDataV3 {{.*}} +// CHECK_GLSL: interpolateAtSample{{.*}}inDataV3 +// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtOffset %inDataV3 {{.*}} +// CHECK_GLSL: interpolateAtOffset{{.*}}inDataV3 + +// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtCentroid %inDataV4 +// CHECK_GLSL: interpolateAtCentroid{{.*}}inDataV4 +// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtSample %inDataV4 {{.*}} +// CHECK_GLSL: interpolateAtSample{{.*}}inDataV4 +// CHECK_SPV: {{.*}} = OpExtInst {{.*}} {{.*}} InterpolateAtOffset %inDataV4 {{.*}} +// CHECK_GLSL: interpolateAtOffset{{.*}}inDataV4 + return true + && interpolateAtCentroid(inDataV1) != -1.0f + && interpolateAtSample(inDataV1, 0) != -1.0f + && interpolateAtOffset(inDataV1, vec2(0.0f)) != -1.0f + && interpolateAtCentroid(inDataV2) != vector<float,2>(-1.0f) + && interpolateAtSample(inDataV2, 0) != vector<float,2>(-1.0f) + && interpolateAtOffset(inDataV2, vec2(0.0f)) != vector<float,2>(-1.0f) + && interpolateAtCentroid(inDataV3) != vector<float,3>(-1.0f) + && interpolateAtSample(inDataV3, 0) != vector<float,3>(-1.0f) + && interpolateAtOffset(inDataV3, vec2(0.0f)) != vector<float,3>(-1.0f) + && interpolateAtCentroid(inDataV4) != vector<float,4>(-1.0f) + && interpolateAtSample(inDataV4, 0) != vector<float,4>(-1.0f) + && interpolateAtOffset(inDataV4, vec2(0.0f)) != vector<float,4>(-1.0f) + ; +} +bool testFragmentProcessingFunctions() +{ + return true + && testFragmentProcessingDerivativeFunctionsScalar() + && testFragmentProcessingDerivativeFunctionsVector<2>() + && testFragmentProcessingDerivativeFunctionsVector<3>() + && testFragmentProcessingDerivativeFunctionsVector<4>() + && testFragmentProcessingInterpolateFunctions() + ; + ; +} + +void main() { + outColorActual = ivec4(true + && testFragmentProcessingFunctions() + ); +}
\ No newline at end of file diff --git a/tests/glsl-intrinsic/noise-functions/noise-functions.slang b/tests/glsl-intrinsic/noise-functions/noise-functions.slang new file mode 100644 index 000000000..f7d04b987 --- /dev/null +++ b/tests/glsl-intrinsic/noise-functions/noise-functions.slang @@ -0,0 +1,50 @@ +//TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target glsl +//TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly +#version 460 +// CHECK: warning 31200 + +buffer MyBlockName2 +{ + uint data[]; +} outputBuffer; + +layout(local_size_x = 4) in; + +bool testNoiseScalar() +{ + return true + && noise1(1.0f) == 0.0f + && noise2(1.0f) == vec2(0.0f) + && noise3(1.0f) == vec3(0.0f) + && noise4(1.0f) == vec4(0.0f) + ; +} + +__generic<let N:int> +bool testNoiseVector() +{ + return true + && noise1(vector<float, N>(1.0f)) == 0.0f + && noise2(vector<float, N>(1.0f)) == vec2(0.0f) + && noise3(vector<float, N>(1.0f)) == vec3(0.0f) + && noise4(vector<float, N>(1.0f)) == vec4(0.0f) + ; +} + +bool testNoiseFunctions() +{ + return true + && testNoiseScalar() + && testNoiseVector<2>() + && testNoiseVector<3>() + && testNoiseVector<4>() + ; +} + +void computeMain() +{ + outputBuffer.data[0] = true + && testNoiseFunctions() + ; + // BUF: 1 +}
\ No newline at end of file diff --git a/tests/glsl-intrinsic/shader-invocation-control/shader-invocation-control.slang b/tests/glsl-intrinsic/shader-invocation-control/shader-invocation-control.slang new file mode 100644 index 000000000..4edb249f8 --- /dev/null +++ b/tests/glsl-intrinsic/shader-invocation-control/shader-invocation-control.slang @@ -0,0 +1,40 @@ +//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -stage compute -entry computeMain -target glsl +//TEST:SIMPLE(filecheck=CHECK_SPV): -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly +//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl +//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -emit-spirv-directly + +#version 460 + +groupshared uint raceConditionShared; + +//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer +buffer MyBlockName2 +{ + uint data[]; +} outputBuffer; + +layout(local_size_x = 4) in; +bool testBarrier() +{ + for (int i = 0; i < 4; i++) + { + raceConditionShared = 3; + barrier(); + raceConditionShared = 1; + if (raceConditionShared != 1) + return false; + } + return true + && raceConditionShared == 1 + ; +} + +void computeMain() +{ + outputBuffer.data[0] = true + && testBarrier() + ; + // CHECK_GLSL: void main( + // CHECK_SPV: OpEntryPoint + // BUF: 1 +}
\ No newline at end of file diff --git a/tests/glsl-intrinsic/shader-invocation-group/shader-invocation-group.slang b/tests/glsl-intrinsic/shader-invocation-group/shader-invocation-group.slang new file mode 100644 index 000000000..201f33ea2 --- /dev/null +++ b/tests/glsl-intrinsic/shader-invocation-group/shader-invocation-group.slang @@ -0,0 +1,47 @@ +//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -stage compute -entry computeMain -target glsl +//TEST:SIMPLE(filecheck=CHECK_SPV): -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly +//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl +//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -emit-spirv-directly + +#version 460 + +//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer +buffer MyBlockName2 +{ + uint data[]; +} outputBuffer; + +layout(local_size_x = 4) in; + +bool testAnyInvocation() +{ + return true + && anyInvocation(gl_GlobalInvocationID.x == 0) + && anyInvocation(gl_GlobalInvocationID.x == 8) == false + ; +} +bool testAllInvocations() +{ + return true + && allInvocations(true) + && allInvocations(gl_GlobalInvocationID.x == 0) == false + ; +} +bool testAllInvocationsEqual() +{ + return true + && allInvocationsEqual(false) + && allInvocationsEqual(gl_GlobalInvocationID.x == 0) == false + ; +} +void computeMain() +{ + outputBuffer.data[0] = true + && testAnyInvocation() + && testAllInvocations() + && testAllInvocationsEqual() + ; + // CHECK_GLSL: void main( + // CHECK_SPV: OpEntryPoint + // BUF: 1 +}
\ No newline at end of file diff --git a/tests/glsl-intrinsic/shader-memory-control/shader-memory-control.slang b/tests/glsl-intrinsic/shader-memory-control/shader-memory-control.slang new file mode 100644 index 000000000..e6d9b7984 --- /dev/null +++ b/tests/glsl-intrinsic/shader-memory-control/shader-memory-control.slang @@ -0,0 +1,137 @@ +//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -stage compute -entry computeMain -target glsl +//TEST:SIMPLE(filecheck=CHECK_SPV): -allow-glsl -stage compute -entry computeMain -target spirv -emit-spirv-directly +//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl +//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=BUF):-vk -compute -entry computeMain -allow-glsl -emit-spirv-directly +#version 460 + +// CHECK_GLSL: void main( +// CHECK_SPV: OpEntryPoint + +//TEST_INPUT:ubuffer(data=[2 2 2 2], stride=4):out,name=raceCondition +buffer MyBlockName1 +{ + uint data[]; +} raceCondition; + +groupshared uint raceConditionShared; + +//TEST_INPUT: set raceConditionImage = RWTexture1D(format=R32_SINT, size=4, content=one, mipMaps = 1) +uniform layout(binding=0,r32i) iimage1D raceConditionImage; + +//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer +buffer MyBlockName2 +{ + uint data[]; +} outputBuffer; + +layout(local_size_x = 32) in; + +bool testMemoryBarrier() +{ + for (int i = 0; i < 4; i++) + { + raceCondition.data[0] = gl_GlobalInvocationID.x; + memoryBarrier(); + raceCondition.data[0] = 1; + memoryBarrier(); + if (raceCondition.data[0] != 1) + return false; + } + return true + && raceCondition.data[0] == 1 + ; +} +bool testMemoryBarrierAtomicCounter() +{ + for (int i = 0; i < 4; i++) + { + atomicExchange(raceCondition.data[1], 2); + memoryBarrierAtomicCounter(); + atomicExchange(raceCondition.data[1], 1); + memoryBarrierAtomicCounter(); + if (raceCondition.data[1] != 1) + return false; + } + return true + && raceCondition.data[1] == 1 + ; +} +bool testMemoryBarrierBuffer() +{ + for (int i = 0; i < 4; i++) + { + raceCondition.data[2] = gl_GlobalInvocationID.x; + memoryBarrierBuffer(); + raceCondition.data[2] = 1; + memoryBarrierBuffer(); + if (raceCondition.data[2] != 1) + return false; + } + return true + && raceCondition.data[2] == 1 + ; +} +bool testMemoryBarrierShared() +{ + for (int i = 0; i < 4; i++) + { + raceConditionShared = 2; + memoryBarrierShared(); + raceConditionShared = 1; + memoryBarrierShared(); + if (raceConditionShared != 1) + return false; + } + return true + && raceConditionShared == 1 + ; +} +bool testMemoryBarrierImage() +{ + for (int i = 0; i < 4; i++) + { + imageStore(raceConditionImage, 0, 2); + memoryBarrierShared(); + imageStore(raceConditionImage, 0, 1); + memoryBarrierShared(); + if (imageLoad(raceConditionImage, 0).x != 1) + return false; + } + return true + && imageLoad(raceConditionImage, 0).x == 1 + ; +} +bool testGroupMemoryBarrier() +{ + for (int i = 0; i < 4; i++) + { + raceCondition.data[3] = gl_GlobalInvocationID.x; + groupMemoryBarrier(); + raceCondition.data[3] = 1; + groupMemoryBarrier(); + if (raceCondition.data[3] != 1) + return false; + } + return true + && raceCondition.data[3] == 1 + ; +} +bool testMemoryBarriers() +{ + return true + && testMemoryBarrier() + && testMemoryBarrierAtomicCounter() + && testMemoryBarrierBuffer() + && testMemoryBarrierShared() + && testMemoryBarrierImage() + && testGroupMemoryBarrier() + ; +} + +void computeMain() +{ + outputBuffer.data[0] = true + && testMemoryBarriers() + ; + // BUF: 1 +} diff --git a/tests/glsl-intrinsic/subpass-input/input-attachment-index-overlapping-error1.slang b/tests/glsl-intrinsic/subpass-input/input-attachment-index-overlapping-error1.slang new file mode 100644 index 000000000..82b56f872 --- /dev/null +++ b/tests/glsl-intrinsic/subpass-input/input-attachment-index-overlapping-error1.slang @@ -0,0 +1,23 @@ +//TEST:SIMPLE(filecheck=CHECK): -target glsl -stage fragment -entry main -allow-glsl +//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly -stage fragment -entry main -allow-glsl +#version 450 +// CHECK: warning 39001 +buffer MyBlockName +{ + uvec4 idata[2]; +} keepAliveBuffer; + +layout(location = 0) in highp vec4 a_position; +layout(location = 0) in highp vec4 b_position; + +layout (input_attachment_index = 2, set = 0, binding = 0) uniform isubpassInput isubpass; +layout (input_attachment_index = 2, set = 0, binding = 1) uniform isubpassInputMS isubpassMS; + +layout (location = 0) out vec4 outColor; + +void main() { + keepAliveBuffer.idata[0] = subpassLoad(isubpass); + keepAliveBuffer.idata[1] = subpassLoad(isubpassMS, 0); + + outColor = vec4(0); +}
\ No newline at end of file diff --git a/tests/glsl-intrinsic/subpass-input/input-attachment-index-overlapping-error2.slang b/tests/glsl-intrinsic/subpass-input/input-attachment-index-overlapping-error2.slang new file mode 100644 index 000000000..d70377660 --- /dev/null +++ b/tests/glsl-intrinsic/subpass-input/input-attachment-index-overlapping-error2.slang @@ -0,0 +1,20 @@ +//TEST:SIMPLE(filecheck=CHECK): -target glsl -stage fragment -entry main -allow-glsl +//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly -stage fragment -entry main -allow-glsl +#version 450 +// CHECK: warning 39001 +buffer MyBlockName +{ + uvec4 idata[2]; +} keepAliveBuffer; + +layout (input_attachment_index = 0, set = 0, binding = 1) uniform isubpassInput isubpass; +layout (input_attachment_index = 1, set = 0, binding = 1) uniform isubpassInputMS isubpassMS; + +layout (location = 0) out vec4 outColor; + +void main() { + keepAliveBuffer.idata[0] = subpassLoad(isubpass); + keepAliveBuffer.idata[1] = subpassLoad(isubpassMS, 0); + + outColor = vec4(0); +}
\ No newline at end of file diff --git a/tests/glsl-intrinsic/subpass-input/input-attachment-index-overlapping-error3.slang b/tests/glsl-intrinsic/subpass-input/input-attachment-index-overlapping-error3.slang new file mode 100644 index 000000000..c2396dbfe --- /dev/null +++ b/tests/glsl-intrinsic/subpass-input/input-attachment-index-overlapping-error3.slang @@ -0,0 +1,20 @@ +//TEST:SIMPLE(filecheck=CHECK): -target glsl -stage fragment -entry main -allow-glsl +//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly -stage fragment -entry main -allow-glsl +#version 450 +// CHECK: warning 39001 +buffer MyBlockName +{ + uvec4 idata[2]; +} keepAliveBuffer; + +layout (input_attachment_index = 0, binding = 1) uniform isubpassInput isubpass; +layout (input_attachment_index = 1, binding = 1) uniform isubpassInputMS isubpassMS; + +layout (location = 0) out vec4 outColor; + +void main() { + keepAliveBuffer.idata[0] = subpassLoad(isubpass); + keepAliveBuffer.idata[1] = subpassLoad(isubpassMS, 0); + + outColor = vec4(0); +}
\ No newline at end of file diff --git a/tests/glsl-intrinsic/subpass-input/input-attachment-index-use-error.slang b/tests/glsl-intrinsic/subpass-input/input-attachment-index-use-error.slang new file mode 100644 index 000000000..889a4e205 --- /dev/null +++ b/tests/glsl-intrinsic/subpass-input/input-attachment-index-use-error.slang @@ -0,0 +1,11 @@ +//TEST:SIMPLE(filecheck=CHECK): -target glsl -stage fragment -entry main -allow-glsl +#version 450 + +// CHECK: error 31207 +layout (input_attachment_index = 1, set = 0, binding = 1) uniform vec3 image; + +layout (location = 0) out vec4 outColor; + +void main() { + outColor = vec4(0); +}
\ No newline at end of file diff --git a/tests/glsl-intrinsic/subpass-input/subpass-input-as-parameter.slang b/tests/glsl-intrinsic/subpass-input/subpass-input-as-parameter.slang new file mode 100644 index 000000000..a415fcf81 --- /dev/null +++ b/tests/glsl-intrinsic/subpass-input/subpass-input-as-parameter.slang @@ -0,0 +1,35 @@ +//TEST:SIMPLE(filecheck=CHECK_GLSL): -target glsl -stage fragment -entry main -allow-glsl +//TEST:SIMPLE(filecheck=CHECK_SPV): -target spirv -emit-spirv-directly -stage fragment -entry main -allow-glsl + +#version 450 + +// CHECK_SPV-DAG: InputAttachmentIndex 0 +// CHECK_SPV-DAG: OpTypeImage %float SubpassData 2 0 0 2 Unknown +// CHECK_GLSL: subpassInput + +layout (input_attachment_index = 0, set = 0, binding = 0) uniform subpassInput subpass; + +// CHECK_SPV-DAG: InputAttachmentIndex 1 +// CHECK_SPV-DAG: OpTypeImage %float SubpassData 2 0 1 2 Unknown +// CHECK_GLSL: subpassInputMS +layout (input_attachment_index = 1, set = 0, binding = 1) uniform subpassInputMS subpassMS; + +layout (location = 0) out vec4 outColor; + +void someSideEffect(subpassInput subpassTmp) +{ + outColor.xy = subpassLoad(subpassTmp).xy; +} + +void someSideEffectMS(subpassInputMS subpassTmp) +{ + outColor.zw = subpassLoad(subpassTmp, 0).zw; +} + +// CHECK_GLSL-DAG: void main( +// CHECK_SPV-DAG: OpEntryPoint + +void main() { + someSideEffect(subpass); + someSideEffectMS(subpassMS); +}
\ No newline at end of file diff --git a/tests/glsl-intrinsic/subpass-input/subpass-input.slang b/tests/glsl-intrinsic/subpass-input/subpass-input.slang new file mode 100644 index 000000000..0597cc06c --- /dev/null +++ b/tests/glsl-intrinsic/subpass-input/subpass-input.slang @@ -0,0 +1,88 @@ +//TEST:SIMPLE(filecheck=CHECK_GLSL): -target glsl -stage fragment -entry main -allow-glsl +//TEST:SIMPLE(filecheck=CHECK_SPV): -target spirv -emit-spirv-directly -stage fragment -entry main -allow-glsl +//TEST:SIMPLE(filecheck=CHECK_HLSL): -target hlsl -stage fragment -entry main -allow-glsl + +#version 450 +// CHECK_SPV-DAG: OpEntryPoint + +// CHECK_SPV-DAG: InputAttachmentIndex 0 +// CHECK_SPV-DAG: InputAttachmentIndex 1 +// CHECK_SPV-DAG: InputAttachmentIndex 2 +// CHECK_SPV-DAG: InputAttachmentIndex 3 +// CHECK_SPV-DAG: InputAttachmentIndex 4 +// CHECK_SPV-DAG: InputAttachmentIndex 5 + +// CHECK_SPV-DAG: OpTypeImage %float SubpassData 2 0 0 2 Unknown +// CHECK_GLSL-DAG: input_attachment_index = 0 +// CHECK_GLSL-DAG: subpassInput +// CHECK_HLSL-DAG: vk::input_attachment_index(0) +// CHECK_HLSL-DAG: SubpassInput<float4> +layout (input_attachment_index = 0, set = 0, binding = 0) uniform subpassInput subpass; + +// CHECK_SPV-DAG: OpTypeImage %float SubpassData 2 0 1 2 Unknown +// CHECK_GLSL-DAG: input_attachment_index = 1 +// CHECK_GLSL-DAG: subpassInputMS +// CHECK_HLSL-DAG: vk::input_attachment_index(1) +// CHECK_HLSL-DAG: SubpassInputMS<float4> +layout (input_attachment_index = 1, set = 0, binding = 1) uniform subpassInputMS subpassMS; + +// CHECK_SPV-DAG: OpTypeImage %uint SubpassData 2 0 0 2 Unknown +// CHECK_GLSL-DAG: input_attachment_index = 2 +// CHECK_GLSL-DAG: usubpassInput +// CHECK_HLSL-DAG: vk::input_attachment_index(2) +// CHECK_HLSL-DAG: SubpassInput<uint4> +layout (input_attachment_index = 2, set = 0, binding = 2) uniform usubpassInput usubpass; + +// CHECK_SPV-DAG: OpTypeImage %uint SubpassData 2 0 1 2 Unknown +// CHECK_GLSL-DAG: input_attachment_index = 3 +// CHECK_GLSL-DAG: usubpassInputMS +// CHECK_HLSL-DAG: vk::input_attachment_index(3) +// CHECK_HLSL-DAG: SubpassInputMS<uint4> +layout (input_attachment_index = 3, set = 0, binding = 3) uniform usubpassInputMS usubpassMS; + +// CHECK_SPV-DAG: OpTypeImage %int SubpassData 2 0 0 2 Unknown +// CHECK_GLSL-DAG: input_attachment_index = 4 +// CHECK_GLSL-DAG: isubpassInput +// CHECK_HLSL-DAG: vk::input_attachment_index(4) +// CHECK_HLSL-DAG: SubpassInput<int4> +layout (input_attachment_index = 4, set = 0, binding = 4) uniform isubpassInput isubpass; + +// CHECK_SPV-DAG: OpTypeImage %int SubpassData 2 0 1 2 Unknown +// CHECK_GLSL-DAG: input_attachment_index = 5 +// CHECK_GLSL-DAG: isubpassInputMS +// CHECK_HLSL-DAG: vk::input_attachment_index(5) +// CHECK_HLSL-DAG: SubpassInputMS<int4> +layout (input_attachment_index = 5, set = 0, binding = 5) uniform isubpassInputMS isubpassMS; + +layout (location = 0) out vec4 outColor; + +// CHECK_GLSL-DAG: void main() +// CHECK_HLSL-DAG: main() +void main() { +// CHECK_SPV: OpImageRead +// CHECK_GLSL: subpassLoad +// CHECK_HLSL: SubpassLoad +// CHECK_SPV: OpImageRead +// CHECK_GLSL: subpassLoad +// CHECK_HLSL: SubpassLoad +// CHECK_SPV: OpImageRead +// CHECK_GLSL: subpassLoad +// CHECK_HLSL: SubpassLoad +// CHECK_SPV: OpImageRead +// CHECK_GLSL: subpassLoad +// CHECK_HLSL: SubpassLoad +// CHECK_SPV: OpImageRead +// CHECK_GLSL: subpassLoad +// CHECK_HLSL: SubpassLoad +// CHECK_SPV: OpImageRead +// CHECK_GLSL: subpassLoad +// CHECK_HLSL: SubpassLoad + outColor = vec4(true + && subpassLoad(subpass) == vec4(1) + && subpassLoad(subpassMS, 0) == vec4(1) + && subpassLoad(isubpass) == ivec4(1) + && subpassLoad(isubpassMS, 0) == ivec4(1) + && subpassLoad(usubpass) == uvec4(1) + && subpassLoad(usubpassMS, 0) == uvec4(1) + ); +}
\ No newline at end of file |
