diff options
| author | Yong He <yonghe@outlook.com> | 2024-02-02 22:28:02 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-02 22:28:02 -0800 |
| commit | 14764896c34b230a5563f48d8b8e565de2f3aa10 (patch) | |
| tree | 2f105d3f6222103f458054f1cd38e280b6fb52b4 /tests | |
| parent | c15e7ade4e27e1649d5b98f5854e9e52bb9e60ae (diff) | |
Capability type checking. (#3530)
* Capability type checking.
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bugs/vk-structured-buffer-load.hlsl.glsl | 12 | ||||
| -rw-r--r-- | tests/cross-compile/barycentrics-nv.slang | 7 | ||||
| -rw-r--r-- | tests/cross-compile/barycentrics-nv.slang.glsl | 12 | ||||
| -rw-r--r-- | tests/diagnostics/discard-in-compute.slang | 13 | ||||
| -rw-r--r-- | tests/language-feature/capability/capability1.slang | 28 | ||||
| -rw-r--r-- | tests/language-feature/capability/capability2.slang | 61 | ||||
| -rw-r--r-- | tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.glsl | 7 | ||||
| -rw-r--r-- | tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.hlsl | 2 | ||||
| -rw-r--r-- | tests/pipeline/rasterization/get-attribute-at-vertex.slang.hlsl | 2 | ||||
| -rw-r--r-- | tests/vkray/callable-caller.slang | 6 | ||||
| -rw-r--r-- | tests/vkray/callable-caller.slang.glsl | 49 | ||||
| -rw-r--r-- | tests/vkray/miss.slang.glsl | 10 |
12 files changed, 123 insertions, 86 deletions
diff --git a/tests/bugs/vk-structured-buffer-load.hlsl.glsl b/tests/bugs/vk-structured-buffer-load.hlsl.glsl index 35fad779b..93181d0a3 100644 --- a/tests/bugs/vk-structured-buffer-load.hlsl.glsl +++ b/tests/bugs/vk-structured-buffer-load.hlsl.glsl @@ -1,12 +1,10 @@ #version 460 -#extension GL_NV_ray_tracing : require +#extension GL_EXT_ray_tracing : require layout(row_major) uniform; layout(row_major) buffer; - layout(std430, binding = 1) readonly buffer StructuredBuffer_float_t_0 { float _data[]; } gParamBlock_sbuf_0; - float rcp_0(float x_0) { return 1.0 / x_0; @@ -17,24 +15,22 @@ struct RayHitInfoPacked_0 vec4 PackedHitInfoA_0; }; -rayPayloadInNV RayHitInfoPacked_0 _S1; +rayPayloadInEXT RayHitInfoPacked_0 _S1; struct BuiltInTriangleIntersectionAttributes_0 { vec2 barycentrics_0; }; -hitAttributeNV BuiltInTriangleIntersectionAttributes_0 _S2; +hitAttributeEXT BuiltInTriangleIntersectionAttributes_0 _S2; void main() { - float HitT_0 = ((gl_RayTmaxNV)); + float HitT_0 = ((gl_RayTmaxEXT)); _S1.PackedHitInfoA_0[0] = HitT_0; float offsfloat_0 = gParamBlock_sbuf_0._data[0]; - uint use_rcp_0 = 0U | uint(HitT_0 > 0.0); - if(use_rcp_0 != 0U) { _S1.PackedHitInfoA_0[1] = rcp_0(offsfloat_0); diff --git a/tests/cross-compile/barycentrics-nv.slang b/tests/cross-compile/barycentrics-nv.slang index fb0272679..60070f913 100644 --- a/tests/cross-compile/barycentrics-nv.slang +++ b/tests/cross-compile/barycentrics-nv.slang @@ -1,4 +1,9 @@ -//TEST:CROSS_COMPILE: -target spirv-assembly -capability GL_NV_fragment_shader_barycentric -entry main -stage fragment +//TEST:SIMPLE(filecheck=CHECK): -target spirv-assembly -capability GL_NV_fragment_shader_barycentric -entry main -stage fragment + +// CHECK: OpCapability FragmentBarycentricKHR +// CHECK: OpDecorate [[NAME:%[A-Za-z0-9_]+]] BuiltIn BaryCoordKHR +// CHECK: [[NAME]] = OpVariable {{.*}} Input +// CHECK: {{.*}} = OpLoad %v3float [[NAME]] float4 main(float3 bary : SV_Barycentrics) : SV_Target { diff --git a/tests/cross-compile/barycentrics-nv.slang.glsl b/tests/cross-compile/barycentrics-nv.slang.glsl deleted file mode 100644 index 583310125..000000000 --- a/tests/cross-compile/barycentrics-nv.slang.glsl +++ /dev/null @@ -1,12 +0,0 @@ -#version 450 - -#extension GL_NV_fragment_shader_barycentric : enable - -layout(location = 0) -out vec4 main_0; - -void main() -{ - main_0 = vec4(gl_BaryCoordNV, float(0)); - return; -} diff --git a/tests/diagnostics/discard-in-compute.slang b/tests/diagnostics/discard-in-compute.slang new file mode 100644 index 000000000..e530881bd --- /dev/null +++ b/tests/diagnostics/discard-in-compute.slang @@ -0,0 +1,13 @@ +//TEST:SIMPLE(filecheck=CHECK): -target hlsl -entry main -profile cs_6_1 +void test() +{ + discard; // This should lead to `test` having `fragment` capability requirement. +} + +[shader("compute")] +[numthreads(1,1,1)] +void main() +{ + // CHECK: error 36107 + test(); // compute shader cannot call `test` that require capabiltiy `fragment`. +} diff --git a/tests/language-feature/capability/capability1.slang b/tests/language-feature/capability/capability1.slang new file mode 100644 index 000000000..bccccb964 --- /dev/null +++ b/tests/language-feature/capability/capability1.slang @@ -0,0 +1,28 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly -entry main2 -stage compute + +[require(spvShaderClockKHR)] +void leafFunc1() {} + +[require(spvShaderNonUniform)] +void leafFunc2() {} + +void caller() +{ + leafFunc1(); + leafFunc2(); +} + +[require(spirv, shaderclock)] +// CHECK: ([[# @LINE+1]]): error 36104: +void main1() +{ + caller(); // Error, shaderclock does not imply spvShaderNonUniform. +} + + +[require(spirv, shaderclock)] +void main2() +{ + // CHECK-NOT: error + leafFunc1(); // OK, shaderclock implies spvShaderClockKHR. +} diff --git a/tests/language-feature/capability/capability2.slang b/tests/language-feature/capability/capability2.slang new file mode 100644 index 000000000..743f998cf --- /dev/null +++ b/tests/language-feature/capability/capability2.slang @@ -0,0 +1,61 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly -entry main -stage compute +module test; + +[require(spvAtomicFloat16AddEXT)] +interface IFoo +{ + [require(spvRayQueryKHR)] + void method1(); + + void method2(); +} + +[require(spvGroupNonUniformArithmetic)] +void useNonUniformArithmetic() +{} + +[require(spvRayQueryKHR)] +void useRayQueryKHR() +{} + +[require(spvAtomicFloat16AddEXT)] +void useAtomicFloat16() +{} + +// This should be OK, uses nothing past what is declared in the interface. +struct Impl1 : IFoo +{ + void method1() + { + useAtomicFloat16(); + useRayQueryKHR(); + } + + void method2() + { + useAtomicFloat16(); + } +} + +// CHECK-NOT: error 361 + +struct Impl2 : IFoo +{ + // CHECK: ([[# @LINE+1]]): error 36104: {{.*}}spvGroupNonUniformArithmetic + void method1() + { + useRayQueryKHR(); // OK. + useNonUniformArithmetic(); // error. + } + // CHECK-NOT: error 361 + + // CHECK: ([[# @LINE+1]]): error 36104: {{.*}}spvGroupNonUniformArithmetic + void method2() + { + useAtomicFloat16(); + useNonUniformArithmetic(); // error. + } +} + +void main() +{} diff --git a/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.glsl b/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.glsl index 1897c6467..820918d8b 100644 --- a/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.glsl +++ b/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.glsl @@ -2,11 +2,11 @@ //TEST_IGNORE_FILE: #version 450 -#extension GL_NV_fragment_shader_barycentric : require +#extension GL_EXT_fragment_shader_barycentric : require layout(row_major) uniform; layout(row_major) buffer; -pervertexNV layout(location = 0) +pervertexEXT layout(location = 0) in vec4 color_0[3]; layout(location = 0) @@ -14,6 +14,7 @@ out vec4 result_0; void main() { - result_0 = gl_BaryCoordNV.x * ((color_0)[(0U)]) + gl_BaryCoordNV.y * ((color_0)[(1U)]) + gl_BaryCoordNV.z * ((color_0)[(2U)]); + result_0 = gl_BaryCoordEXT.x * ((color_0)[(0U)]) + gl_BaryCoordEXT.y * ((color_0)[(1U)]) + gl_BaryCoordEXT.z * ((color_0)[(2U)]); return; } + diff --git a/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.hlsl b/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.hlsl index ce23492c9..a6b45eab4 100644 --- a/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.hlsl +++ b/tests/pipeline/rasterization/get-attribute-at-vertex-nv.slang.hlsl @@ -2,6 +2,8 @@ //TEST_IGNORE_FILE: +#pragma warning(disable: 3557) + [shader("pixel")] void main( nointerpolation vector<float,4> color_0 : COLOR, diff --git a/tests/pipeline/rasterization/get-attribute-at-vertex.slang.hlsl b/tests/pipeline/rasterization/get-attribute-at-vertex.slang.hlsl index ce23492c9..9322964d5 100644 --- a/tests/pipeline/rasterization/get-attribute-at-vertex.slang.hlsl +++ b/tests/pipeline/rasterization/get-attribute-at-vertex.slang.hlsl @@ -11,4 +11,4 @@ void main( result_0 = bary_0.x * GetAttributeAtVertex(color_0, 0U) + bary_0.y * GetAttributeAtVertex(color_0, 1U) + bary_0.z * GetAttributeAtVertex(color_0, 2U); -} +}
\ No newline at end of file diff --git a/tests/vkray/callable-caller.slang b/tests/vkray/callable-caller.slang index 64311988a..6a0c85c38 100644 --- a/tests/vkray/callable-caller.slang +++ b/tests/vkray/callable-caller.slang @@ -1,6 +1,8 @@ // callable-caller.slang -//TEST:CROSS_COMPILE: -profile glsl_460 -capability GL_NV_ray_tracing -stage raygeneration -entry main -target spirv-assembly +//TEST:SIMPLE(filecheck=CHECK): -profile glsl_460 -capability GL_NV_ray_tracing -stage raygeneration -entry main -target spirv-assembly +//TEST:SIMPLE(filecheck=CHECK): -profile glsl_460 -capability GL_NV_ray_tracing -stage raygeneration -entry main -target spirv-assembly -emit-spirv-directly + import callable_shared; @@ -16,7 +18,7 @@ void main() MaterialPayload payload; payload.albedo = 0; payload.uv = float2(DispatchRaysIndex().xy) / float2(DispatchRaysDimensions().xy); - + // CHECK: OpExecuteCallable CallShader(shaderIndex, payload); gImage[DispatchRaysIndex().xy] = payload.albedo; diff --git a/tests/vkray/callable-caller.slang.glsl b/tests/vkray/callable-caller.slang.glsl deleted file mode 100644 index a42e6eaf3..000000000 --- a/tests/vkray/callable-caller.slang.glsl +++ /dev/null @@ -1,49 +0,0 @@ -#version 460 -#extension GL_NV_ray_tracing : require -layout(row_major) uniform; -layout(row_major) buffer; -struct MaterialPayload_0 -{ - vec4 albedo_0; - vec2 uv_0; -}; - -layout(location = 0) -callableDataNV -MaterialPayload_0 p_0; - -struct SLANG_ParameterGroup_C_0 -{ - uint shaderIndex_0; -}; - -layout(binding = 0) -layout(std140) uniform _S1 -{ - uint shaderIndex_0; -} C_0; -void CallShader_0(uint shaderIndex_1, inout MaterialPayload_0 payload_0) -{ - p_0 = payload_0; - executeCallableNV(shaderIndex_1, (0)); - payload_0 = p_0; - return; -} - -layout(rgba32f) -layout(binding = 1) -uniform image2D gImage_0; - -void main() -{ - MaterialPayload_0 payload_1; - payload_1.albedo_0 = vec4(0.0); - uvec3 _S2 = ((gl_LaunchIDNV)); - vec2 _S3 = vec2(_S2.xy); - uvec3 _S4 = ((gl_LaunchSizeNV)); - payload_1.uv_0 = _S3 / vec2(_S4.xy); - CallShader_0(C_0.shaderIndex_0, payload_1); - uvec3 _S5 = ((gl_LaunchIDNV)); - imageStore((gImage_0), ivec2((_S5.xy)), payload_1.albedo_0); - return; -} diff --git a/tests/vkray/miss.slang.glsl b/tests/vkray/miss.slang.glsl index df7647411..1bc6af5b3 100644 --- a/tests/vkray/miss.slang.glsl +++ b/tests/vkray/miss.slang.glsl @@ -1,17 +1,7 @@ //TEST_IGNORE_FILE: #version 460 -#if USE_NV_RT -#extension GL_NV_ray_tracing : require -#define callableDataInEXT callableDataInNV -#define gl_LaunchIDEXT gl_LaunchIDNV -#define hitAttributeEXT hitAttributeNV -#define ignoreIntersectionEXT ignoreIntersectionNV -#define rayPayloadInEXT rayPayloadInNV -#define terminateRayEXT terminateRayNV -#else #extension GL_EXT_ray_tracing : require -#endif struct ShadowRay_0 { |
