diff options
Diffstat (limited to 'tests')
11 files changed, 371 insertions, 8 deletions
diff --git a/tests/glsl-intrinsic/compute-derivative/derivative-mode-many-entry-points1.slang b/tests/glsl-intrinsic/compute-derivative/derivative-mode-many-entry-points1.slang new file mode 100644 index 000000000..498542a39 --- /dev/null +++ b/tests/glsl-intrinsic/compute-derivative/derivative-mode-many-entry-points1.slang @@ -0,0 +1,30 @@ +//TEST:SIMPLE(filecheck=CHECK_SPV_SYNTAX): -allow-glsl -fvk-use-entrypoint-name -target spirv +// CHECK_SPV_SYNTAX: DerivativeGroupQuadsNV +// CHECK_SPV_SYNTAX: DerivativeGroupLinearNV + +//TEST:SIMPLE(filecheck=CHECK_GLSL_SYNTAX): -allow-glsl -fvk-use-entrypoint-name -target spirv -DGLSL_SYNTAX +// CHECK_GLSL_SYNTAX: DerivativeGroupQuadsNV +// CHECK_GLSL_SYNTAX: DerivativeGroupQuadsNV +#ifdef GLSL_SYNTAX +layout(derivative_group_quadsNV) in; +#endif + +buffer MyBlockName +{ + int result; +} outputBuffer; + +[DerivativeGroupQuad] +[shader("compute")] +[numthreads(2,2,1)] +void main1(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + outputBuffer.result = asint(ddx(1)); +} + +[DerivativeGroupLinear] +[shader("compute")] +void main2(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + outputBuffer.result = asint(ddx(1)); +} diff --git a/tests/glsl-intrinsic/compute-derivative/derivative-mode-many-entry-points2.slang b/tests/glsl-intrinsic/compute-derivative/derivative-mode-many-entry-points2.slang new file mode 100644 index 000000000..0dbaac640 --- /dev/null +++ b/tests/glsl-intrinsic/compute-derivative/derivative-mode-many-entry-points2.slang @@ -0,0 +1,27 @@ +//TEST:SIMPLE(filecheck=CHECK_SPV_SYNTAX): -allow-glsl -fvk-use-entrypoint-name -target spirv +// CHECK_SPV_SYNTAX: DerivativeGroupQuadsNV +// CHECK_SPV_SYNTAX: DerivativeGroupLinearNV + +#ifdef GLSL_SYNTAX +layout(derivative_group_quadsNV) in; +#endif + +buffer MyBlockName +{ + int result; +} outputBuffer; + +[DerivativeGroupQuad] +[shader("compute")] +[numthreads(2,2,1)] +void main1(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + outputBuffer.result = asint(ddx(1)) + asint(ddx(1)) ; +} + +[DerivativeGroupLinear] +[shader("compute")] +void main2(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + outputBuffer.result = asint(ddy(1)) + asint(ddy(1)); +} diff --git a/tests/glsl-intrinsic/compute-derivative/derivative-mode-many-entry-points3.slang b/tests/glsl-intrinsic/compute-derivative/derivative-mode-many-entry-points3.slang new file mode 100644 index 000000000..327f41f36 --- /dev/null +++ b/tests/glsl-intrinsic/compute-derivative/derivative-mode-many-entry-points3.slang @@ -0,0 +1,24 @@ +//TEST:SIMPLE(filecheck=CHECK_SPV_SYNTAX): -allow-glsl -fvk-use-entrypoint-name -target spirv +// CHECK_SPV_SYNTAX: DerivativeGroupQuadsNV + +#ifdef GLSL_SYNTAX +layout(derivative_group_quadsNV) in; +#endif + +buffer MyBlockName +{ + int result; +} outputBuffer; + +[shader("compute")] +[numthreads(2,2,1)] +void main1(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + outputBuffer.result = asint(ddx(1)) + asint(ddx(1)) ; +} + +[shader("compute")] +void main2(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + outputBuffer.result = 1; +} diff --git a/tests/glsl-intrinsic/compute-derivative/derivative-mode-specifying-two-modes.slang b/tests/glsl-intrinsic/compute-derivative/derivative-mode-specifying-two-modes.slang new file mode 100644 index 000000000..c190f5710 --- /dev/null +++ b/tests/glsl-intrinsic/compute-derivative/derivative-mode-specifying-two-modes.slang @@ -0,0 +1,25 @@ +//TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target glsl -DSLANG +//TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target spirv -DSLANG + +//TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target glsl -DGLSL +//TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target spirv -DGLSL +// CHECK: error 31212 + +buffer MyBlockName +{ + int result; +} outputBuffer; + +#ifdef SLANG +[DerivativeGroupQuad] +[DerivativeGroupLinear] +#endif +#ifdef GLSL +layout(derivative_group_quadsNV) in; +layout(derivative_group_linearNV) in; +#endif +[numthreads(2, 2, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + outputBuffer.result = asint(ddx(1)); +} diff --git a/tests/glsl-intrinsic/compute-derivative/derivative-mode-undefined-mode.slang b/tests/glsl-intrinsic/compute-derivative/derivative-mode-undefined-mode.slang new file mode 100644 index 000000000..610045b78 --- /dev/null +++ b/tests/glsl-intrinsic/compute-derivative/derivative-mode-undefined-mode.slang @@ -0,0 +1,25 @@ +//TEST:SIMPLE(filecheck=CHECK_SPV_SYNTAX): -allow-glsl -fvk-use-entrypoint-name -target spirv +// CHECK_SPV_SYNTAX: DerivativeGroupQuadsNV +// CHECK_SPV_SYNTAX: DerivativeGroupQuadsNV + +//TEST:SIMPLE(filecheck=CHECK_GLSL_SYNTAX): -allow-glsl -stage compute -entry main2 -target glsl +// CHECK_GLSL_SYNTAX: derivative_group_quadsNV + +buffer MyBlockName +{ + int result; +} outputBuffer; + +[shader("compute")] +[numthreads(2, 2, 1)] +void main1(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + outputBuffer.result = asint(ddx(1)); +} + +[shader("compute")] +[numthreads(2, 2, 1)] +void main2(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + outputBuffer.result = asint(ddx(1)); +}
\ No newline at end of file diff --git a/tests/glsl-intrinsic/compute-derivative/derivative-mode-undefined-mode2.slang b/tests/glsl-intrinsic/compute-derivative/derivative-mode-undefined-mode2.slang new file mode 100644 index 000000000..e02f0dbe7 --- /dev/null +++ b/tests/glsl-intrinsic/compute-derivative/derivative-mode-undefined-mode2.slang @@ -0,0 +1,21 @@ +//TEST:SIMPLE(filecheck=CHECK_SPV_SYNTAX): -allow-glsl -stage compute -entry main -target spirv +// CHECK_SPV_SYNTAX: DerivativeGroupQuadsNV + +//TEST:SIMPLE(filecheck=CHECK_GLSL_SYNTAX): -allow-glsl -stage compute -entry main -target glsl +// CHECK_GLSL_SYNTAX: derivative_group_quadsNV + +buffer MyBlockName +{ + int result; +} outputBuffer; + +int someFunc() +{ + return asint(ddx(1)); +} + +[numthreads(2, 2, 1)] +void main(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + outputBuffer.result = someFunc(); +}
\ No newline at end of file diff --git a/tests/glsl-intrinsic/compute-derivative/derivative-mode-undefined-mode3.slang b/tests/glsl-intrinsic/compute-derivative/derivative-mode-undefined-mode3.slang new file mode 100644 index 000000000..6dde2fc09 --- /dev/null +++ b/tests/glsl-intrinsic/compute-derivative/derivative-mode-undefined-mode3.slang @@ -0,0 +1,20 @@ +//TEST:SIMPLE(filecheck=CHECK_SPV_SYNTAX): -allow-glsl -stage compute -entry main -target spirv +// CHECK_SPV_SYNTAX: DerivativeGroupQuadsNV + +//TEST:SIMPLE(filecheck=CHECK_GLSL_SYNTAX): -allow-glsl -stage compute -entry main -target glsl +// CHECK_GLSL_SYNTAX: derivative_group_quadsNV + +buffer MyBlockName +{ + int result; +} outputBuffer; + +int someFunc() +{ + return asint(ddx(1)); +} + +void main(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + outputBuffer.result = someFunc(); +}
\ No newline at end of file diff --git a/tests/glsl-intrinsic/compute-derivative/derivative-mode-wrong-multiple-linear.slang b/tests/glsl-intrinsic/compute-derivative/derivative-mode-wrong-multiple-linear.slang new file mode 100644 index 000000000..b2ac3e0ac --- /dev/null +++ b/tests/glsl-intrinsic/compute-derivative/derivative-mode-wrong-multiple-linear.slang @@ -0,0 +1,26 @@ +//TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target glsl -DLINEAR_SLANG +//TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target spirv -DLINEAR_SLANG + +//TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target glsl -DLINEAR_GLSL +//TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target spirv -DLINEAR_GLSL +// CHECK: error 31211 + +buffer MyBlockName +{ + int result; +} outputBuffer; + +#ifdef LINEAR_SLANG +[DerivativeGroupLinear] +[numthreads(1, 3, 1)] +#endif + +#ifdef LINEAR_GLSL +layout(derivative_group_linearNV) in; +[numthreads(1, 3, 1)] +#endif + +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + outputBuffer.result = asint(ddx(1)); +} diff --git a/tests/glsl-intrinsic/compute-derivative/derivative-mode-wrong-multiple-quad.slang b/tests/glsl-intrinsic/compute-derivative/derivative-mode-wrong-multiple-quad.slang new file mode 100644 index 000000000..0dca8dca9 --- /dev/null +++ b/tests/glsl-intrinsic/compute-derivative/derivative-mode-wrong-multiple-quad.slang @@ -0,0 +1,24 @@ +//TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target glsl -DQUAD_SLANG +//TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target spirv -DQUAD_SLANG + +//TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target glsl -DQUAD_GLSL +//TEST:SIMPLE(filecheck=CHECK): -allow-glsl -stage compute -entry computeMain -target spirv -DQUAD_GLSL +// CHECK: error 31210 + +buffer MyBlockName +{ + int result; +} outputBuffer; + +#ifdef QUAD_SLANG +[DerivativeGroupQuad] +[numthreads(3, 3, 1)] +#endif +#ifdef QUAD_GLSL +layout(derivative_group_quadsNV) in; +[numthreads(3, 3, 1)] +#endif +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + outputBuffer.result = asint(ddx(1)); +} diff --git a/tests/glsl-intrinsic/compute-derivative/intrinsic-derivative-function-in-compute.slang b/tests/glsl-intrinsic/compute-derivative/intrinsic-derivative-function-in-compute.slang new file mode 100644 index 000000000..11b5986b7 --- /dev/null +++ b/tests/glsl-intrinsic/compute-derivative/intrinsic-derivative-function-in-compute.slang @@ -0,0 +1,130 @@ +#version 450 core +#extension GL_EXT_texture_shadow_lod : enable + +//TEST:SIMPLE(filecheck=CHECK_GLSL_QUAD_C): -allow-glsl -stage compute -entry computeMain -target glsl -DCOMPUTE -DQUAD +// CHECK_GLSL_QUAD_C: GL_NV_compute_shader_derivatives +// CHECK_GLSL_QUAD_C: layout(derivative_group_quadsNV) + +//TEST:SIMPLE(filecheck=CHECK_GLSL_LINEAR_C): -allow-glsl -stage compute -entry computeMain -target glsl -DCOMPUTE -DLINEAR +// CHECK_GLSL_LINEAR_C: GL_NV_compute_shader_derivatives +// CHECK_GLSL_LINEAR_C: layout(derivative_group_linearNV) + +//TEST:SIMPLE(filecheck=CHECK_SPV_QUAD_C): -allow-glsl -stage compute -entry computeMain -target spirv -DQUAD -DCOMPUTE +// CHECK_SPV_QUAD_C: DerivativeGroupQuadsNV +// CHECK_SPV_QUAD_C: "SPV_NV_compute_shader_derivatives" + +//TEST:SIMPLE(filecheck=CHECK_SPV_LINEAR_C): -allow-glsl -stage compute -entry computeMain -target spirv -DLINEAR -DCOMPUTE +// CHECK_SPV_LINEAR_C: DerivativeGroupLinearNV +// CHECK_SPV_LINEAR_C: "SPV_NV_compute_shader_derivatives" + +//TEST:SIMPLE(filecheck=CHECK_HLSL_C): -allow-glsl -stage compute -entry computeMain -target hlsl -DCOMPUTE +// CHECK_HLSL_C: computeMain( + +//TEST:SIMPLE(filecheck=CHECK_GLSL_F): -allow-glsl -stage fragment -entry computeMain -target glsl +// CHECK_GLSL_F-NOT: GL_NV_compute_shader_derivatives + +//TEST:SIMPLE(filecheck=CHECK_SPV_QUAD_F): -allow-glsl -stage fragment -entry computeMain -target spirv -DQUAD +// CHECK_SPV_QUAD_F-NOT: DerivativeGroupQuadsNV +// CHECK_SPV_QUAD_F-NOT: "SPV_NV_compute_shader_derivatives" + +//TEST:SIMPLE(filecheck=CHECK_SPV_LINEAR_F): -allow-glsl -stage fragment -entry computeMain -target spirv -DLINEAR +// CHECK_SPV_LINEAR_F-NOT: DerivativeGroupLinearNV +// CHECK_SPV_LINEAR_F-NOT: "SPV_NV_compute_shader_derivatives" + +//TEST:SIMPLE(filecheck=CHECK_GLSL_QUAD_F): -allow-glsl -stage fragment -entry computeMain -target glsl +// CHECK_GLSL_QUAD_F-NOT: GL_NV_compute_shader_derivatives +// CHECK_GLSL_QUAD_F-NOT: layout(derivative_group_quadsNV) + +//TEST:SIMPLE(filecheck=CHECK_HLSL_F): -allow-glsl -stage fragment -entry computeMain -target hlsl +// CHECK_HLSL_F: computeMain( + +buffer MyBlockName +{ + int result; +} outputBuffer; + +uniform sampler1D uniform_sampler1D; + +__generic<T : __BuiltinFloatingPointType, let N : int> +bool textureFuncs(Sampler1D<vector<T,N>> gsampler1D) +{ + typealias gvec4 = vector<T,4>; + + constexpr ivec2 ivec2_0 = ivec2(0); + + return true + // 8.9.1. Texture Query Functions + && int(0) == textureSize(gsampler1D, int(0)) + && vec2(0) == textureQueryLod(gsampler1D, float(0)) + && int(0) == textureQueryLevels(gsampler1D) + && gvec4(T(0)) == texture(gsampler1D, float(0)) + && gvec4(T(0)) == texture(gsampler1D, float(0), float(0)) + && gvec4(T(0)) == textureProj(gsampler1D, vec2(0)) + && gvec4(T(0)) == textureProj(gsampler1D, vec2(0), float(0)) + && gvec4(T(0)) == textureProj(gsampler1D, vec4(0)) + && gvec4(T(0)) == textureProj(gsampler1D, vec4(0), float(0)) + && gvec4(T(0)) == textureLod(gsampler1D, float(0), float(0)) + && gvec4(T(0)) == textureOffset(gsampler1D, float(0), __LINE__) + && gvec4(T(0)) == textureOffset(gsampler1D, float(0), __LINE__, float(0)) + && gvec4(T(0)) == texelFetch(gsampler1D, int(0), int(0)) + && gvec4(T(0)) == texelFetchOffset(gsampler1D, int(0), int(0), __LINE__) + && gvec4(T(0)) == textureProjOffset(gsampler1D, vec2(0), __LINE__) + && gvec4(T(0)) == textureProjOffset(gsampler1D, vec2(0), __LINE__, float(0)) + && gvec4(T(0)) == textureProjOffset(gsampler1D, vec4(0), __LINE__) + && gvec4(T(0)) == textureProjOffset(gsampler1D, vec4(0), __LINE__,float(0)) + && gvec4(T(0)) == textureLodOffset(gsampler1D, float(0), float(0), __LINE__) + && gvec4(T(0)) == textureProjLod(gsampler1D, vec2(0), float(0)) + && gvec4(T(0)) == textureProjLod(gsampler1D, vec4(0), float(0)) + && gvec4(T(0)) == textureProjLodOffset(gsampler1D, vec2(0), float(0), __LINE__) + && gvec4(T(0)) == textureProjLodOffset(gsampler1D, vec4(0), float(0), __LINE__) + && gvec4(T(0)) == textureGrad(gsampler1D, float(0), float(0), float(0)) + && gvec4(T(0)) == textureGradOffset(gsampler1D, float(0), float(0), float(0), __LINE__) + && gvec4(T(0)) == textureProjGrad(gsampler1D, vec2(0), float(0), float(0)) + && gvec4(T(0)) == textureProjGrad(gsampler1D, vec4(0), float(0), float(0)) + && gvec4(T(0)) == textureProjGradOffset(gsampler1D, vec2(0), float(0), float(0), __LINE__) + && gvec4(T(0)) == textureProjGradOffset(gsampler1D, vec4(0), float(0), float(0), __LINE__) + && vec4(0) == texture1D(uniform_sampler1D, float(0)) + && vec4(0) == texture1D(uniform_sampler1D, float(0), float(0)) + && vec4(0) == texture1DProj(uniform_sampler1D, vec2(0)) + && vec4(0) == texture1DProj(uniform_sampler1D, vec2(0), float(0)) + && vec4(0) == texture1DProj(uniform_sampler1D, vec4(0)) + && vec4(0) == texture1DProj(uniform_sampler1D, vec4(0), float(0)) + && vec4(0) == texture1DLod(uniform_sampler1D, float(0), float(0)) + && vec4(0) == texture1DProjLod(uniform_sampler1D, vec2(0), float(0)) + && vec4(0) == texture1DProjLod(uniform_sampler1D, vec4(0), float(0)) + ; +} + +bool derivativeFunc() +{ + 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 + ; +} + + +#ifdef QUAD +[DerivativeGroupQuad] +#endif +#ifdef LINEAR +[DerivativeGroupLinear] +#endif +#ifdef COMPUTE +[numthreads(2, 2, 1)] +#endif +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + // CHECK_SPV: OpEntryPoint + outputBuffer.result = true + && textureFuncs(uniform_sampler1D) + && derivativeFunc() + ; +} diff --git a/tests/glsl-intrinsic/intrinsic-texture.slang b/tests/glsl-intrinsic/intrinsic-texture.slang index 4f3ba22c9..dfed77912 100644 --- a/tests/glsl-intrinsic/intrinsic-texture.slang +++ b/tests/glsl-intrinsic/intrinsic-texture.slang @@ -1,14 +1,17 @@ #version 450 core #extension GL_EXT_texture_shadow_lod : enable -//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -stage compute -entry computeMain -target glsl -// TODO: test direct to spirv backend. -//TEST:SIMPLE(filecheck=CHECK_SPV): -allow-glsl -emit-spirv-via-glsl -stage compute -entry computeMain -target spirv -//TEST:SIMPLE(filecheck=CHECK_CUDA): -allow-glsl -stage compute -entry computeMain -target cuda +//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -stage compute -entry computeMain -target glsl -DCOMPUTE +//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -stage fragment -entry computeMain -target glsl +//TEST:SIMPLE(filecheck=CHECK_SPV): -allow-glsl -stage fragment -entry computeMain -target spirv -emit-spirv-via-glsl +//TEST:SIMPLE(filecheck=CHECK_SPV_DIRECT): -allow-glsl -stage compute -entry computeMain -target spirv -DCOMPUTE +//TEST:SIMPLE(filecheck=CHECK_SPV_DIRECT): -allow-glsl -stage fragment -entry computeMain -target spirv +//TEST:SIMPLE(filecheck=CHECK_CUDA): -allow-glsl -stage compute -entry computeMain -target cuda -DCOMPUTE +//TEST:SIMPLE(filecheck=CHECK_CUDA): -allow-glsl -stage fragment -entry computeMain -target cuda // Disabling following targets because they are currently causing compile errors. -//DISABLE_TEST:SIMPLE(filecheck=CHECK_HLSL): -allow-glsl -stage compute -entry computeMain -target hlsl -//DISABLE_TEST:SIMPLE(filecheck=CHECK_CPP): -allow-glsl -stage compute -entry computeMain -target cpp +//DISABLE_TEST:SIMPLE(filecheck=CHECK_HLSL): -allow-glsl -stage compute -entry computeMain -target hlsl -DCOMPUTE +//DISABLE_TEST:SIMPLE(filecheck=CHECK_CPP): -allow-glsl -stage compute -entry computeMain -target cpp -DCOMPUTE // "Offset" family of texture functions in GLSL requires offset parameter to be a constant value. // It appears that slangc removes the constant-ness of constant values. @@ -22,6 +25,11 @@ //RWStructuredBuffer<float> outputBuffer; //layout(location = 0) out vec4 o_color; +buffer MyBlockName +{ + int result; +} outputBuffer; + uniform sampler1DShadow uniform_sampler1DShadow; uniform sampler2DShadow uniform_sampler2DShadow; uniform samplerCubeShadow uniform_samplerCubeShadow; @@ -499,16 +507,19 @@ bool itextureFuncs(Sampler1D<vector<T, N>> gsampler1D ; } -[numthreads(4, 1, 1)] +#ifdef COMPUTE +[numthreads(2, 2, 1)] +#endif void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) { // CHECK_GLSL: void main( // CHECK_SPV: OpEntryPoint + // CHECK_SPV_DIRECT: OpEntryPoint // CHECK_HLSL: void computeMain( // CHECK_CUDA: void computeMain( // CHECK_CPP: void _computeMain( - bool r = true + outputBuffer.result = true && textureFuncs( uniform_sampler1D , uniform_sampler2D |
