summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2021-01-05 09:00:00 -0800
committerGitHub <noreply@github.com>2021-01-05 09:00:00 -0800
commitb4f94629f225b837e7102acc337610c5d4d8a7c1 (patch)
treecb75cc2059d517fa41dfe2954f2893e04fa6af3b /tests
parentf5fffa90e936ab462b3842f9b2cfa996ae870fe4 (diff)
Use "capability" system to select VKRT extension (#1647)
* Use "capability" system to select VKRT extension Slang currently supports translation of ray tracing shader code to Vulkan GLSL code that uses the `GL_NV_ray_tracing` extension. A multi-vendor equivalent of that extension has been released as `GL_EXT_ray_tracing` and we want Slang to support that extension as well. At the simplest, making the change from one extension to the other is just a matter of changing a few strings, since it does not appear that anything of significance was changed at the GLSL level (or even in SPIR-V). Where this gets trickier is when we have users who want us to support *both* extensions, and to be able to switch between them. The solution we've implemented here more or less amounts to: * If you don't tell the compiler which extension to use, it will default to `GL_EXT_ray_tracing` (the newer multi-vendor one). * If you explicitly want the older extension, you can opt into it using the `-profile` option or via a new API for explicitly adding capabilities to your target. Making that work required a few different kinds of changes: * The options parsing and public API needed ways to add optional capabilities to a target. * During GLSL code emit, we can check the capabilities that were added to the target to see if the `GL_NV_ray_tracing` extension was explicitly enabled and, if not, default to using the `GL_EXT_ray_tracing` names for things. This step is needed because some of the modifiers/attributes involved in the extension have to be handled explicitly in the code generator rather than implicitly as part of mapping intrinsic functions. * We add two different translations to the relevant operatiosn in the stdlib, one marked with each of the extensions. If profile/capability-based overload resolution can be relied on to pick the right one, this should Just Work. * Next, a bunch of work had to go into making capability-based overloading Just Work for the purposes of this change. There's been a nearly complete reworking of the implementation of `CapabilitySet` here to make it more suitable for our needs. * The tests that were using ray tracing translation for Vulkan needed to be updated. For some of them I updated their baselines to use `GL_EXT_ray_tracing` so that they can test the new path. For others, I updated the command line for the test case so that it explicitly opts into using `GL_NV_ray_tracing`. The result is that we have some coverage of each extension. I would have liked to have each test run in both modes, but our pass-through glslang support doesn't support `-D` options, so I couldn't take that step easily. This change does *not* add support for `GL_EXT_ray_query`, the extension that supports "DXR 1.1" style queries under Vulkan. Adding support for that extension should hopefully be a smaller step because it doesn't have the same multiple-extensions issue. This change does *not* address a lot of possible avenues for improvement or cleanup around the capability system. It focuses only on those changes that are necessary to make the ray tracing feature work and leaves the rest for future work. * fixup: infinite loop * Comment-only change to retrigger TC build
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/vk-structured-buffer-load.hlsl2
-rw-r--r--tests/bugs/vk-structured-buffer-load.hlsl.glsl2
-rw-r--r--tests/vkray/anyhit.slang8
-rw-r--r--tests/vkray/anyhit.slang.glsl17
-rw-r--r--tests/vkray/callable-caller.slang2
-rw-r--r--tests/vkray/callable.slang2
-rw-r--r--tests/vkray/callable.slang.glsl11
-rw-r--r--tests/vkray/closesthit.slang2
-rw-r--r--tests/vkray/closesthit.slang.glsl2
-rw-r--r--tests/vkray/entry-point-params.slang2
-rw-r--r--tests/vkray/entry-point-params.slang.glsl16
-rw-r--r--tests/vkray/intersection.slang2
-rw-r--r--tests/vkray/miss.slang2
-rw-r--r--tests/vkray/miss.slang.glsl12
-rw-r--r--tests/vkray/raygen.slang2
-rw-r--r--tests/vkray/raygen.slang.glsl36
16 files changed, 89 insertions, 31 deletions
diff --git a/tests/bugs/vk-structured-buffer-load.hlsl b/tests/bugs/vk-structured-buffer-load.hlsl
index bd5d16882..ce862c0c8 100644
--- a/tests/bugs/vk-structured-buffer-load.hlsl
+++ b/tests/bugs/vk-structured-buffer-load.hlsl
@@ -1,4 +1,4 @@
-//TEST:CROSS_COMPILE: -profile lib_6_3 -entry HitMain -stage closesthit -target spirv-assembly
+//TEST:CROSS_COMPILE: -profile glsl_460+GL_NV_ray_tracing -entry HitMain -stage closesthit -target spirv-assembly
#define USE_RCP 0
diff --git a/tests/bugs/vk-structured-buffer-load.hlsl.glsl b/tests/bugs/vk-structured-buffer-load.hlsl.glsl
index 8a545ad1e..1c7ec8043 100644
--- a/tests/bugs/vk-structured-buffer-load.hlsl.glsl
+++ b/tests/bugs/vk-structured-buffer-load.hlsl.glsl
@@ -40,7 +40,7 @@ hitAttributeNV BuiltInTriangleIntersectionAttributes_0 Attributes;
void main()
{
- float HitT_0 = (gl_HitTNV);
+ float HitT_0 = (gl_RayTmaxNV);
RayData.PackedHitInfoA_0.x = HitT_0;
const uint use_rcp_0 = uint(0);
diff --git a/tests/vkray/anyhit.slang b/tests/vkray/anyhit.slang
index 6959efc9c..1c216b683 100644
--- a/tests/vkray/anyhit.slang
+++ b/tests/vkray/anyhit.slang
@@ -1,5 +1,11 @@
// closesthit.slang
-//TEST:CROSS_COMPILE: -profile sm_6_3 -stage anyhit -entry main -target spirv-assembly
+
+// Note: explicitly requesting `spirv_1_4` as part of the compiler
+// options is for the benefit of the glslang pass-through path,
+// where we cannot infer the required SPIR-V version from the code
+// (and glslang doesn't include any such inference ability).
+
+//TEST:CROSS_COMPILE: -profile glsl_460+spirv_1_4 -stage anyhit -entry main -target spirv-assembly
struct SphereHitAttributes
{
diff --git a/tests/vkray/anyhit.slang.glsl b/tests/vkray/anyhit.slang.glsl
index 622080399..a37df119c 100644
--- a/tests/vkray/anyhit.slang.glsl
+++ b/tests/vkray/anyhit.slang.glsl
@@ -1,6 +1,15 @@
// anyhit.slang.glsl
#version 460
+
+#if USE_NV_RT
#extension GL_NV_ray_tracing : require
+#define hitAttributeEXT hitAttributeNV
+#define rayPayloadInEXT rayPayloadInNV
+#define terminateRayEXT terminateRayNV
+#define ignoreIntersectionEXT ignoreIntersectionNV
+#else
+#extension GL_EXT_ray_tracing : require
+#endif
struct Params_0
{
@@ -23,13 +32,13 @@ struct SphereHitAttributes_0
{
vec3 normal_0;
};
-hitAttributeNV SphereHitAttributes_0 _S2;
+hitAttributeEXT SphereHitAttributes_0 _S2;
struct ShadowRay_0
{
vec4 hitDistance_0;
};
-rayPayloadInNV ShadowRay_0 _S3;
+rayPayloadInEXT ShadowRay_0 _S3;
void main()
{
@@ -43,11 +52,11 @@ void main()
if(val_0 > float(0))
{
- terminateRayNV();
+ terminateRayEXT();
}
else
{
- ignoreIntersectionNV();
+ ignoreIntersectionEXT();
}
}
diff --git a/tests/vkray/callable-caller.slang b/tests/vkray/callable-caller.slang
index e423f2bec..93d9dd3cb 100644
--- a/tests/vkray/callable-caller.slang
+++ b/tests/vkray/callable-caller.slang
@@ -1,6 +1,6 @@
// callable-caller.slang
-//TEST:CROSS_COMPILE: -profile sm_6_3 -stage raygeneration -entry main -target spirv-assembly
+//TEST:CROSS_COMPILE: -profile glsl_460+GL_NV_ray_tracing -stage raygeneration -entry main -target spirv-assembly
import callable_shared;
diff --git a/tests/vkray/callable.slang b/tests/vkray/callable.slang
index 59d42546a..5fdbd0eb5 100644
--- a/tests/vkray/callable.slang
+++ b/tests/vkray/callable.slang
@@ -1,6 +1,6 @@
// callable.slang
-//TEST:CROSS_COMPILE: -profile sm_6_3 -stage callable -entry main -target spirv-assembly
+//TEST:CROSS_COMPILE: -profile glsl_460+spirv_1_4 -stage callable -entry main -target spirv-assembly
import callable_shared;
diff --git a/tests/vkray/callable.slang.glsl b/tests/vkray/callable.slang.glsl
index 9b573a8ab..dd99cc440 100644
--- a/tests/vkray/callable.slang.glsl
+++ b/tests/vkray/callable.slang.glsl
@@ -1,6 +1,15 @@
#version 460
+#if USE_NV_RT
#extension GL_NV_ray_tracing : require
+#define callableDataInEXT callableDataInNV
+#define hitAttributeEXT hitAttributeNV
+#define ignoreIntersectionEXT ignoreIntersectionNV
+#define rayPayloadInEXT rayPayloadInNV
+#define terminateRayEXT terminateRayNV
+#else
+#extension GL_EXT_ray_tracing : require
+#endif
layout(binding = 0) uniform texture2D gAlbedoMap_0;
layout(binding = 1) uniform sampler gSampler_0;
@@ -11,7 +20,7 @@ struct MaterialPayload_0
vec2 uv_0;
};
-callableDataInNV MaterialPayload_0 _S1;
+callableDataInEXT MaterialPayload_0 _S1;
void main()
{
diff --git a/tests/vkray/closesthit.slang b/tests/vkray/closesthit.slang
index 419c22a46..28c759175 100644
--- a/tests/vkray/closesthit.slang
+++ b/tests/vkray/closesthit.slang
@@ -1,5 +1,5 @@
// closesthit.slang
-//TEST:CROSS_COMPILE: -profile sm_6_3 -stage closesthit -entry main -target spirv-assembly
+//TEST:CROSS_COMPILE: -profile glsl_460+GL_NV_ray_tracing -stage closesthit -entry main -target spirv-assembly
struct ReflectionRay
{
diff --git a/tests/vkray/closesthit.slang.glsl b/tests/vkray/closesthit.slang.glsl
index 67072e9ff..e3af26a04 100644
--- a/tests/vkray/closesthit.slang.glsl
+++ b/tests/vkray/closesthit.slang.glsl
@@ -59,7 +59,7 @@ void main()
vec4 color_1 = colors_0._data[tmp_add_1 + tmp_hitkind + ShaderRecord_0._data.shaderRecordID_0];
- float tmp_hitt = gl_HitTNV;
+ float tmp_hitt = gl_RayTmaxNV;
float tmp_tmin = gl_RayTminNV;
tmp_payload.color_0 = color_1 * (tmp_hitt - tmp_tmin);
diff --git a/tests/vkray/entry-point-params.slang b/tests/vkray/entry-point-params.slang
index 84c8ecb50..25ee29d0d 100644
--- a/tests/vkray/entry-point-params.slang
+++ b/tests/vkray/entry-point-params.slang
@@ -3,7 +3,7 @@
// Test that entry-point `uniform` parameters on ray-tracing
// shaders properly map to the "shader record" in SPIR-V output.
-//TEST:CROSS_COMPILE: -profile glsl_460 -stage raygeneration -entry main -target spirv-assembly
+//TEST:CROSS_COMPILE: -profile glsl_460+spirv_1_4 -stage raygeneration -entry main -target spirv-assembly
RWStructuredBuffer<float> buffer;
diff --git a/tests/vkray/entry-point-params.slang.glsl b/tests/vkray/entry-point-params.slang.glsl
index 8333f21c9..f4531ea84 100644
--- a/tests/vkray/entry-point-params.slang.glsl
+++ b/tests/vkray/entry-point-params.slang.glsl
@@ -1,6 +1,18 @@
//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 shaderRecordEXT shaderRecordNV
+#define terminateRayEXT terminateRayNV
+#else
+#extension GL_EXT_ray_tracing : require
+#endif
layout(std430, binding = 0)
buffer _S1 {
@@ -12,7 +24,7 @@ struct EntryPointParams_0
float value_0;
};
-layout(shaderRecordNV)
+layout(shaderRecordEXT)
buffer _S2
{
EntryPointParams_0 _data;
@@ -20,7 +32,7 @@ buffer _S2
void main()
{
- uvec3 _S4 = gl_LaunchIDNV;
+ uvec3 _S4 = gl_LaunchIDEXT;
buffer_0._data[_S4.x] = _S3._data.value_0;
return;
}
diff --git a/tests/vkray/intersection.slang b/tests/vkray/intersection.slang
index e69ccdbfb..65705c845 100644
--- a/tests/vkray/intersection.slang
+++ b/tests/vkray/intersection.slang
@@ -1,5 +1,5 @@
// intersection.slang
-//TEST:CROSS_COMPILE: -profile sm_6_3 -stage intersection -entry main -target spirv-assembly
+//TEST:CROSS_COMPILE: -profile glsl_460+GL_NV_ray_tracing -stage intersection -entry main -target spirv-assembly
struct Sphere
{
diff --git a/tests/vkray/miss.slang b/tests/vkray/miss.slang
index c99518150..ce946662c 100644
--- a/tests/vkray/miss.slang
+++ b/tests/vkray/miss.slang
@@ -1,4 +1,4 @@
-//TEST:CROSS_COMPILE: -profile sm_6_3 -stage miss -entry main -target spirv-assembly
+//TEST:CROSS_COMPILE: -profile glsl_460+GL_EXT_ray_tracing -stage miss -entry main -target spirv-assembly
struct ShadowRay
{
diff --git a/tests/vkray/miss.slang.glsl b/tests/vkray/miss.slang.glsl
index 33cff4a34..df7647411 100644
--- a/tests/vkray/miss.slang.glsl
+++ b/tests/vkray/miss.slang.glsl
@@ -1,14 +1,24 @@
//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
{
float hitDistance_0;
};
-rayPayloadInNV ShadowRay_0 _S1;
+rayPayloadInEXT ShadowRay_0 _S1;
void main()
{
diff --git a/tests/vkray/raygen.slang b/tests/vkray/raygen.slang
index ad377938f..ac82ccf1a 100644
--- a/tests/vkray/raygen.slang
+++ b/tests/vkray/raygen.slang
@@ -1,4 +1,4 @@
-//TEST:CROSS_COMPILE: -profile glsl_460 -stage raygeneration -entry main -target spirv-assembly
+//TEST:CROSS_COMPILE: -profile glsl_460+GL_EXT_ray_tracing -stage raygeneration -entry main -target spirv-assembly
#define TRACING_EPSILON 1e-6
diff --git a/tests/vkray/raygen.slang.glsl b/tests/vkray/raygen.slang.glsl
index 859f5036e..79162be9f 100644
--- a/tests/vkray/raygen.slang.glsl
+++ b/tests/vkray/raygen.slang.glsl
@@ -3,7 +3,19 @@
layout(row_major) uniform;
+#if USE_NV_RT
#extension GL_NV_ray_tracing : require
+#define accelerationStructureEXT accelerationStructureNV
+#define callableDataInEXT callableDataInNV
+#define gl_LaunchIDEXT gl_LaunchIDNV
+#define hitAttributeEXT hitAttributeNV
+#define ignoreIntersectionEXT ignoreIntersectionNV
+#define rayPayloadInEXT rayPayloadInNV
+#define terminateRayEXT terminateRayNV
+#define traceRayEXT traceNV
+#else
+#extension GL_EXT_ray_tracing : require
+#endif
#define TRACING_EPSILON 1e-6
@@ -66,19 +78,19 @@ layout(std140) uniform tmp_ubo
Uniforms_0 _data;
} ubo_0;
-layout(binding = 5) uniform accelerationStructureNV as_0;
+layout(binding = 5) uniform accelerationStructureEXT as_0;
struct ShadowRay_0
{
float hitDistance_0;
};
-layout(location = 0) rayPayloadNV ShadowRay_0 p_0;
+layout(location = 0) rayPayloadEXT ShadowRay_0 p_0;
struct ReflectionRay_0
{
float color_1;
};
-layout(location = 1) rayPayloadNV ReflectionRay_0 p_1;
+layout(location = 1) rayPayloadEXT ReflectionRay_0 p_1;
layout(rgba32f) layout(binding = 4) uniform image2D outputImage_0;
@@ -91,7 +103,7 @@ struct RayDesc_0
};
void TraceRay_0(
- accelerationStructureNV AccelerationStructure_0,
+ accelerationStructureEXT AccelerationStructure_0,
uint RayFlags_0,
uint InstanceInclusionMask_0,
uint RayContributionToHitGroupIndex_0,
@@ -101,7 +113,7 @@ void TraceRay_0(
inout ShadowRay_0 Payload_0)
{
p_0 = Payload_0;
- traceNV(
+ traceRayEXT(
AccelerationStructure_0,
RayFlags_0,
InstanceInclusionMask_0,
@@ -118,7 +130,7 @@ void TraceRay_0(
}
void TraceRay_1(
- accelerationStructureNV AccelerationStructure_1,
+ accelerationStructureEXT AccelerationStructure_1,
uint RayFlags_1,
uint InstanceInclusionMask_1,
uint RayContributionToHitGroupIndex_1,
@@ -128,7 +140,7 @@ void TraceRay_1(
inout ReflectionRay_0 Payload_1)
{
p_1 = Payload_1;
- traceNV(
+ traceRayEXT(
AccelerationStructure_1,
RayFlags_1,
InstanceInclusionMask_1,
@@ -154,14 +166,14 @@ void main()
{
float atten_0;
- uvec3 tmp_launchID_x = gl_LaunchIDNV;
+ uvec3 tmp_launchID_x = gl_LaunchIDEXT;
float tmp_add_x = float(tmp_launchID_x.x) + 0.5;
- uvec3 tmp_launchSize_x = gl_LaunchSizeNV;
+ uvec3 tmp_launchSize_x = gl_LaunchSizeEXT;
float tmp_div_x = tmp_add_x / float(tmp_launchSize_x.x);
- uvec3 tmp_launchID_y = gl_LaunchIDNV;
+ uvec3 tmp_launchID_y = gl_LaunchIDEXT;
float tmp_add_y = float(tmp_launchID_y.y) + 0.5;
- uvec3 tmp_launchSize_y = gl_LaunchSizeNV;
+ uvec3 tmp_launchSize_y = gl_LaunchSizeEXT;
float tmp_div_y = tmp_add_y / float(tmp_launchSize_y.y);
vec2 inUV_0 = vec2(tmp_div_x, tmp_div_y);
@@ -224,7 +236,7 @@ void main()
vec3 color_3 = color_2 + tmp_trace2_payload.color_1;
- uvec3 tmp_storeIdx = gl_LaunchIDNV;
+ uvec3 tmp_storeIdx = gl_LaunchIDEXT;
imageStore(outputImage_0, ivec2(uvec2(ivec2(tmp_storeIdx.xy))), vec4(color_3, 1.0));
return;
}