From 8813c610562b1c30222ec3ef0734ef601d43b617 Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Wed, 12 Jun 2024 16:38:23 -0400 Subject: 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 --- tests/pipeline/rasterization/get-attribute-at-vertex.slang | 4 ++-- tests/pipeline/rasterization/mesh/component-write.slang | 2 +- tests/pipeline/rasterization/mesh/dead-loop.slang | 2 +- tests/pipeline/rasterization/mesh/hlsl-syntax.slang | 2 +- tests/pipeline/rasterization/mesh/nested-component-write.slang | 2 +- tests/pipeline/rasterization/mesh/simple.slang | 5 +++-- tests/pipeline/rasterization/mesh/swizzled-store.slang | 2 +- tests/pipeline/rasterization/mesh/task-groupshared.slang | 2 +- tests/pipeline/rasterization/mesh/task-simple.slang | 2 +- tests/pipeline/ray-tracing/trace-ray-inline.slang | 9 ++++++++- 10 files changed, 20 insertions(+), 12 deletions(-) (limited to 'tests/pipeline') 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, -- cgit v1.2.3