diff options
| author | ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> | 2024-06-12 16:38:23 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-12 13:38:23 -0700 |
| commit | 8813c610562b1c30222ec3ef0734ef601d43b617 (patch) | |
| tree | b012aa178a52a0313ce9deab31006556a2637011 /tests | |
| parent | 7447fcafa71440336f553d6e0af21b12fc74d138 (diff) | |
Capability System: Implicit capability upgrade warning/error (#4241)
* capability upgrade warning/error
adjusted implementation + tests to support a warning/error if capabilities are implicitly upgraded and test accordingly.
* add glsl profile caps
* add GLSL and HLSL capabilities to the associated capability
* syntax error in capdef
* only error if user explicitly enables capabilities
1. changed testing infrastructure to not set a `profile` explicitly,
2. Added tests to be sure this works as intended with user API and with slangc command line
* Change capability atom definitions and how Slang manages them to fix errors
1. most `glsl_spirv` version atoms have been removed from `.capdef`, instead we will translate `spirv` version atoms into `glsl_spirv` since there is no point in writing the same code twice in `.capdef` files to define `spirv` versions.
2. add spirv version, and hlsl sm version (and equivlent) capability dependencies
3. removed some stage requirments which were set on objects, keep the wrapper capabilities. I am keeping the wrapper capabilities since I am unaware on if there are stage limitations (spec says code in practice does not work).
* check internal version instead of version profile (_spirv_1_5 vs. spirv_1_5)
* remove unused OpCapability. adjust SPIRV version'ing again for glsl_spirv
* apply workaround for glslang bug with rayquery usage
* ensure capabilities targetted by a profile and added together by a user are valid
* remove additions to `spirv_1_*` wrapper
* spirv_* -> glsl_spirv fix
* fix bug where incompatable profiles would cause invalid target caps
* try to avoid joining invalid capabilities
* fix the warning/error & printing
* run through tests to fix capability system and test mistakes
many mistakes were mesh shaders doing `-profile glsl_450+spirv_1_4`. This is not allowed for a few reasons
1. the test tooling does not handle arguments the same as `slangc`
2. glsl_450 core profile does not support mesh shaders, nor does spirv_1_4. sm_6_5 does work in this senario
* set some sm_4_1 intrinsics to sm_4_0
* replace `GLSL_` defs with `glsl_`
* swap the unsupported render-test syntax for working syntax
* set d3d11/d3d12 profile defaults
this is required since sm version changes compiled code & behavior
* adjusted nvapi capabilities with atomics + d3d11 set to use sm_5_0 as per default
* cleanup
* address review
* incorrect styling
* change `bitscanForward` to work as intended on 32 bit targets
---------
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tests')
18 files changed, 88 insertions, 28 deletions
diff --git a/tests/bugs/sample-grad-clamp-lod.slang b/tests/bugs/sample-grad-clamp-lod.slang index cdb48fba0..8d1d232c7 100644 --- a/tests/bugs/sample-grad-clamp-lod.slang +++ b/tests/bugs/sample-grad-clamp-lod.slang @@ -1,4 +1,4 @@ -//TEST:CROSS_COMPILE: -profile glsl_460+GL_EXT_ray_tracing -stage miss -entry main -target spirv-assembly +//TEST:CROSS_COMPILE: -profile sm_6_3 -stage miss -entry main -target spirv-assembly Texture2DArray t2D; SamplerState samplerState; diff --git a/tests/compute/dynamic-dispatch-14.slang b/tests/compute/dynamic-dispatch-14.slang index 0dc99b432..609d1a215 100644 --- a/tests/compute/dynamic-dispatch-14.slang +++ b/tests/compute/dynamic-dispatch-14.slang @@ -2,8 +2,8 @@ //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile sm_6_0 -use-dxil //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx11 -profile sm_5_0 -//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -gl -profile glsl440 -//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -vk -profile glsl440 +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -gl -profile glsl_440 +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -vk -profile glsl_440 //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cpu diff --git a/tests/feature/source-embed/source-embed-1.slang b/tests/feature/source-embed/source-embed-1.slang index ecacaed9b..b595cc173 100644 --- a/tests/feature/source-embed/source-embed-1.slang +++ b/tests/feature/source-embed/source-embed-1.slang @@ -1,4 +1,4 @@ -//TEST:SIMPLE(filecheck=CHECK):-target spirv -entry computeMain -profile cs_6_3 -line-directive-mode none -source-embed-style default -emit-spirv-via-glsl +//TEST:SIMPLE(filecheck=CHECK):-target spirv -entry computeMain -profile cs_5_1 -line-directive-mode none -source-embed-style default -emit-spirv-via-glsl //TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer RWStructuredBuffer<int> outputBuffer; diff --git a/tests/language-feature/capability/capability5.slang b/tests/language-feature/capability/capability5.slang new file mode 100644 index 000000000..6199f045a --- /dev/null +++ b/tests/language-feature/capability/capability5.slang @@ -0,0 +1,29 @@ +//TEST:SIMPLE(filecheck=PASS): -target glsl -entry main -stage compute -allow-glsl +//TEST:SIMPLE(filecheck=PASS): -target glsl -entry main -stage compute -allow-glsl -capability shader5_sm_5_0 +//TEST:SIMPLE(filecheck=PASS): -target glsl -entry main -stage compute -allow-glsl -profile sm_6_0 +//TEST:SIMPLE(filecheck=WARN): -target glsl -entry main -stage compute -allow-glsl -capability GLSL_130 +//TEST:SIMPLE(filecheck=ERROR): -target glsl -entry main -stage compute -allow-glsl -capability GLSL_130 -restrictive-capability-check +// CHECK_IGNORE_CAPS-NOT: error 36104 + +// Check that a non-static member method implictly requires capabilities +// defined in ThisType. + +//PASS-NOT: warning 41012 +//PASS-NOT: error 41012 + +//WARN: warning 41012 +//WARN-NOT: error 41012 + +//ERROR-NOT: warning 41012 +//ERROR: error 41012 + +buffer MyBlockName +{ + int data; +} inputBuffer; + +[numthreads(1,1,1)] +void main() +{ + inputBuffer.data = firstbithigh(1); +} diff --git a/tests/language-feature/capability/specializeTargetSwitch.slang b/tests/language-feature/capability/specializeTargetSwitch.slang index 251adfaf8..e1e5d4225 100644 --- a/tests/language-feature/capability/specializeTargetSwitch.slang +++ b/tests/language-feature/capability/specializeTargetSwitch.slang @@ -1,6 +1,8 @@ //TEST:SIMPLE(filecheck=CHECK_HLSL): -target hlsl -entry main -stage compute -capability _sm_5_1 //TEST:SIMPLE(filecheck=CHECK_GLSL1): -target glsl -entry main -stage compute -capability _GLSL_420 +//TEST:SIMPLE(filecheck=CHECK_GLSL1): -target glsl -entry main -stage compute -capability _GLSL_420 //TEST:SIMPLE(filecheck=CHECK_GLSL2): -target glsl -entry main -stage compute -capability _GLSL_330 +//TEST:SIMPLE(filecheck=CHECK_GLSL2_NO_UPGRADE): -target glsl -entry main -stage compute -capability _GLSL_330 -DTURN_OFF_LARGER_GLSL_TARGETS //TEST:SIMPLE(filecheck=CHECK_METAL): -target cpp -entry main -stage compute -capability image_loadstore //TEST:SIMPLE(filecheck=CHECK_WILL_ERROR1): -target glsl -entry main -stage compute -capability image_loadstore -DWILL_ERROR1 //TEST:SIMPLE(filecheck=CHECK_WILL_ERROR2): -target glsl -entry main -stage compute -capability _GLSL_130 -DWILL_ERROR2 @@ -9,11 +11,19 @@ RWTexture1D<int> tex; //CHECK_HLSL: {{.*}}21{{.*}}; + //CHECK_GLSL1: {{.*}}13{{.*}} + //CHECK_GLSL2: {{.*}}11{{.*}} + +//CHECK_GLSL2_NO_UPGRADE-NOT: warning 41012 +//CHECK_GLSL2_NO_UPGRADE-NOT: error 41012 + //CHECK_METAL: {{.*}}30{{.*}} + //CHECK_WILL_ERROR1: error 36109 //CHECK_WILL_ERROR2: error 41011 + //CHECK_GLSL3: {{.*}}30{{.*}} int specialize() @@ -31,10 +41,12 @@ int specialize() return 10; case _GLSL_330: return 11; +#ifndef TURN_OFF_LARGER_GLSL_TARGETS case _GLSL_400: return 12; case _GLSL_410: return 13; +#endif #ifdef WILL_ERROR1 case image_loadstore: return 14; diff --git a/tests/language-feature/capability/testing-framework-with-profiles.slang b/tests/language-feature/capability/testing-framework-with-profiles.slang new file mode 100644 index 000000000..215ba887e --- /dev/null +++ b/tests/language-feature/capability/testing-framework-with-profiles.slang @@ -0,0 +1,21 @@ + +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -profile sm_6_1 +//TEST:SIMPLE(filecheck=CHECK): -target hlsl -entry computeMain -stage compute +//TEST:SIMPLE(filecheck=CHECK): -target hlsl -entry computeMain -stage compute -capability sm_6_1 +//TEST:SIMPLE(filecheck=CHECK): -target hlsl -entry computeMain -stage compute -profile sm_6_1 +//TEST:SIMPLE(filecheck=CHECK_WARN): -target hlsl -entry computeMain -stage compute -capability sm_4_0 + +//CHECK-NOT: warning 41012 +//CHECK_WARN: warning 41012 +//CHECK: computeMain + +//TEST_INPUT:ubuffer(data=[1], stride=4):out,name outputBuffer +RWStructuredBuffer<uint> outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + // BUF: 1 + outputBuffer[0] = WaveMaskSum(0xFF, 1); +} diff --git a/tests/pipeline/rasterization/get-attribute-at-vertex.slang b/tests/pipeline/rasterization/get-attribute-at-vertex.slang index a88cf8d24..9ae347a3a 100644 --- a/tests/pipeline/rasterization/get-attribute-at-vertex.slang +++ b/tests/pipeline/rasterization/get-attribute-at-vertex.slang @@ -3,8 +3,8 @@ // Basic test for `GetAttributeAtVertex` function //TEST:CROSS_COMPILE:-target dxil -entry main -stage fragment -profile sm_6_1 -//TEST:CROSS_COMPILE:-target spirv -entry main -stage fragment -profile glsl_450 -//TEST:SIMPLE(filecheck=CHECK):-emit-spirv-directly -target spirv -entry main -stage fragment -profile glsl_450 +//TEST:CROSS_COMPILE:-target spirv -entry main -stage fragment -profile glsl_450+GL_EXT_fragment_shader_barycentric +//TEST:SIMPLE(filecheck=CHECK):-emit-spirv-directly -target spirv -entry main -stage fragment -profile glsl_450+GL_EXT_fragment_shader_barycentric // CHECK: OpCapability FragmentBarycentricKHR // CHECK: OpExtension "SPV_KHR_fragment_shader_barycentric" diff --git a/tests/pipeline/rasterization/mesh/component-write.slang b/tests/pipeline/rasterization/mesh/component-write.slang index afa5cd291..ed2d8e9a3 100644 --- a/tests/pipeline/rasterization/mesh/component-write.slang +++ b/tests/pipeline/rasterization/mesh/component-write.slang @@ -2,7 +2,7 @@ // This tests that writing to individual components of the output struct works -//TEST:CROSS_COMPILE:-target spirv -profile glsl_450+spirv_1_4 -entry main -stage mesh +//TEST:CROSS_COMPILE:-target spirv -profile glsl_450+GL_EXT_mesh_shader -entry main -stage mesh const static float2 positions[3] = { float2(0.0, -0.5), diff --git a/tests/pipeline/rasterization/mesh/dead-loop.slang b/tests/pipeline/rasterization/mesh/dead-loop.slang index 875a12db5..987463104 100644 --- a/tests/pipeline/rasterization/mesh/dead-loop.slang +++ b/tests/pipeline/rasterization/mesh/dead-loop.slang @@ -1,5 +1,5 @@ //TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -mesh -output-using-type -dx12 -use-dxil -profile sm_6_6 -render-features mesh-shader -//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -mesh -output-using-type -vk -profile glsl_450+spirv_1_4 -render-features mesh-shader +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -mesh -output-using-type -vk -profile sm_6_5 -render-features mesh-shader // See https://github.com/shader-slang/slang/issues/3401 diff --git a/tests/pipeline/rasterization/mesh/hlsl-syntax.slang b/tests/pipeline/rasterization/mesh/hlsl-syntax.slang index eaa853a04..76ac3a598 100644 --- a/tests/pipeline/rasterization/mesh/hlsl-syntax.slang +++ b/tests/pipeline/rasterization/mesh/hlsl-syntax.slang @@ -2,7 +2,7 @@ // Test that we can ingest hlsl mesh output syntax -//TEST:CROSS_COMPILE:-target spirv -profile glsl_450+spirv_1_4 -entry main -stage mesh +//TEST:CROSS_COMPILE:-target spirv -profile sm_6_5 -entry main -stage mesh const static float2 positions[3] = { float2(0.0, -0.5), diff --git a/tests/pipeline/rasterization/mesh/nested-component-write.slang b/tests/pipeline/rasterization/mesh/nested-component-write.slang index f55d5365e..681331a51 100644 --- a/tests/pipeline/rasterization/mesh/nested-component-write.slang +++ b/tests/pipeline/rasterization/mesh/nested-component-write.slang @@ -3,7 +3,7 @@ // This tests that writing to individual components nested structs works for // mesh shader outputs. -//TEST:CROSS_COMPILE:-target spirv -profile glsl_450+spirv_1_4 -entry main -stage mesh +//TEST:CROSS_COMPILE:-target spirv -profile glsl_450+GL_EXT_mesh_shader -entry main -stage mesh struct Foo { diff --git a/tests/pipeline/rasterization/mesh/simple.slang b/tests/pipeline/rasterization/mesh/simple.slang index de1195d71..70dbfb73a 100644 --- a/tests/pipeline/rasterization/mesh/simple.slang +++ b/tests/pipeline/rasterization/mesh/simple.slang @@ -1,5 +1,6 @@ -//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -mesh -output-using-type -dx12 -use-dxil -profile sm_6_6 -render-features mesh-shader -//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -mesh -output-using-type -vk -profile glsl_450+spirv_1_4 -render-features mesh-shader +//T-EST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -mesh -output-using-type -dx12 -use-dxil -profile sm_6_6 -render-features mesh-shader +//T-EST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -mesh -output-using-type -vk -render-features mesh-shader +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -mesh -output-using-type -vk -profile sm_6_5 -render-features mesh-shader // To test a simple mesh shader, we'll generate 4 triangles, the vertices of // each one will hold the triangle index and a value (the square). The fragment diff --git a/tests/pipeline/rasterization/mesh/swizzled-store.slang b/tests/pipeline/rasterization/mesh/swizzled-store.slang index 713416430..6636ef31d 100644 --- a/tests/pipeline/rasterization/mesh/swizzled-store.slang +++ b/tests/pipeline/rasterization/mesh/swizzled-store.slang @@ -2,7 +2,7 @@ // This tests that writing to individual components of the output struct works -//TEST:CROSS_COMPILE:-target spirv -profile glsl_450+spirv_1_4 -entry main -stage mesh +//TEST:CROSS_COMPILE:-target spirv -profile sm_6_5 -entry main -stage mesh const static uint MAX_VERTS = 3; const static uint MAX_PRIMS = 1; diff --git a/tests/pipeline/rasterization/mesh/task-groupshared.slang b/tests/pipeline/rasterization/mesh/task-groupshared.slang index 518d94bfb..46334bf3e 100644 --- a/tests/pipeline/rasterization/mesh/task-groupshared.slang +++ b/tests/pipeline/rasterization/mesh/task-groupshared.slang @@ -1,5 +1,5 @@ //TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -task -output-using-type -dx12 -use-dxil -profile sm_6_6 -render-features mesh-shader -//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -task -output-using-type -vk -profile glsl_450+spirv_1_4 -render-features mesh-shader +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -task -output-using-type -vk -profile sm_6_5 -render-features mesh-shader // Similar to task-simple, except that the payload is declared as a groupshared // variable. During lowerin to GLSL and SPIR-V we'll have to identify this as diff --git a/tests/pipeline/rasterization/mesh/task-simple.slang b/tests/pipeline/rasterization/mesh/task-simple.slang index 2b2f3d186..053b24045 100644 --- a/tests/pipeline/rasterization/mesh/task-simple.slang +++ b/tests/pipeline/rasterization/mesh/task-simple.slang @@ -1,5 +1,5 @@ //TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -task -output-using-type -dx12 -use-dxil -profile sm_6_6 -render-features mesh-shader -//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -task -output-using-type -vk -profile glsl_450+spirv_1_4 -render-features mesh-shader +//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK): -task -output-using-type -vk -profile sm_6_5 -render-features mesh-shader //TEST:SIMPLE(filecheck=HLSL):-target hlsl -entry meshMain -stage mesh //TEST:SIMPLE(filecheck=CHECK_SPV):-target spirv -entry taskMain -stage amplification diff --git a/tests/pipeline/ray-tracing/trace-ray-inline.slang b/tests/pipeline/ray-tracing/trace-ray-inline.slang index 23ec90885..009dffbc7 100644 --- a/tests/pipeline/ray-tracing/trace-ray-inline.slang +++ b/tests/pipeline/ray-tracing/trace-ray-inline.slang @@ -1,7 +1,14 @@ // trace-ray-inline.slang //TEST:CROSS_COMPILE:-target dxil-asm -stage compute -profile sm_6_5 -entry main -line-directive-mode none -//TEST:CROSS_COMPILE:-target spirv-asm -stage compute -profile glsl_460+spirv_1_4 -entry main -line-directive-mode none +//TEST:SIMPLE(filecheck=CHECK):-target spirv-asm -stage compute -profile glsl_460+GL_EXT_ray_query -entry main -line-directive-mode none + +// CHECK: OpCapability RayQueryKHR +// CHECK: OpExtension "SPV_KHR_ray_query" +// CHECK: OpRayQueryInitializeKHR +// CHECK: OpRayQueryProceedKHR +// CHECK: OpRayQueryGetIntersectionTypeKHR +// CHECK: OpRayQueryConfirmIntersectionKHR // The goal of this shader is to use all the main pieces // of functionality in DXR 1.1's `TraceRayInline` feature, diff --git a/tests/slang-extension/atomic-float-byte-address-buffer-cross.slang b/tests/slang-extension/atomic-float-byte-address-buffer-cross.slang index c3204a37c..4d26317b7 100644 --- a/tests/slang-extension/atomic-float-byte-address-buffer-cross.slang +++ b/tests/slang-extension/atomic-float-byte-address-buffer-cross.slang @@ -1,7 +1,8 @@ // atomic-float-byte-address-buffer-cross.slang //TEST:SIMPLE(filecheck=CHECK_SPV): -profile cs_6_5 -entry computeMain -target spirv-assembly -//TEST:SIMPLE(filecheck=CHECK): -profile cs_6_5 -entry computeMain -target spirv-assembly -emit-spirv-via-glsl +//TEST:SIMPLE(filecheck=CHECK_SPV): -profile cs_6_5 -entry computeMain -target spirv-assembly -emit-spirv-via-glsl +//TEST:SIMPLE(filecheck=CHECK_GLSL): -profile cs_6_5 -entry computeMain -target glsl // We can't do this test, because it relies on nvAPI //DISABLE_TEST:CROSS_COMPILE: -profile cs_6_5 -entry computeMain -target dxil @@ -19,16 +20,6 @@ RWStructuredBuffer<float> anotherBuffer; [numthreads(16, 1, 1)] void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) { - // CHECK-DAG: OpDecorate %[[V1:[a-zA-Z0-9_]+]] Binding 1 - // CHECK-DAG: OpDecorate %[[V2:[a-zA-Z0-9_]+]] Binding 0 - // CHECK-DAG: %[[P1:[a-zA-Z0-9_]+]] = OpTypePointer Uniform %float - // CHECK-DAG: %[[P2:[a-zA-Z0-9_]+]] = OpTypePointer Input %uint - // CHECK: OpAccessChain %[[P2]] - // CHECK: OpAccessChain %[[P1]] %[[V1]] - // CHECK: OpAccessChain %[[P1]] %[[V2]] - // CHECK: OpAtomicFAddEXT - // CHECK: OpAccessChain %[[P1]] %[[V2]] - // CHECK: OpAtomicFAddEXT uint tid = dispatchThreadID.x; int idx = int((tid & 3) ^ (tid >> 2)); diff --git a/tests/vkray/rayquery-closesthit.slang b/tests/vkray/rayquery-closesthit.slang index 6576e09bd..33e1c9c9a 100644 --- a/tests/vkray/rayquery-closesthit.slang +++ b/tests/vkray/rayquery-closesthit.slang @@ -25,7 +25,6 @@ void main( } // CHECK: OpCapability RayQueryKHR -// CHECK: OpCapability RayTracingPositionFetchKHR // CHECK: OpCapability RayQueryPositionFetchKHR // CHECK: OpExtension "SPV_KHR_ray_query" // CHECK: OpExtension "SPV_KHR_ray_tracing_position_fetch" |
