diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-11-09 13:24:28 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-09 13:24:28 -0800 |
| commit | c07f60af241b1b0f7b7eba62c65d9fe750f8f3b7 (patch) | |
| tree | e2de0ee14561959f6af02e115d0c615b7ccc5950 /tests/vkray | |
| parent | d782a162a783eab3f4a57a22056c5eba04c2b4ae (diff) | |
Update Vulkan ray tracing support to final extension spec (#717)
* Update version of glslang used
* Update VK raytracing support for final extension spec
A lot of this change is just plain renaming: The `NVX` suffixes become just `NV`, and the extension name changes from `GL_NVX_raytracing` to `GL_NV_ray_tracing`.
The Slang standard library and the GLSL baselines for the tests are consistently updated.
The other detail is that the final spec requires the "payload" identifier in a `traceNV()` call to be a compile-time constant, which means it cannot be defined as a local variable first, as in:
```glsl
int payloadID = 0;
traceNV(..., payloadID); // ERROR
```
In terms of how the original support was implemented, the payload ID is being computed via a special builtin function that maps each global GLSL payload variable to a unique ID. There are a few ways we could try to resolve the problem here:
1. We could aspire to put our equivalent of the `constexpr` modifier on the output of the function, so that the GLSL variable gets declared `const` and thus fits the GLSL rules for a constant expression.
2. We could introduce a pass to replace the payload-location instructions with literal integers.
3. We could use a special-purpose instruction instead of a builtin function call, and have that instruction indicate that it doesn't have side effects (so it can be folded into the call site)
4. We could somehow mark the builtin function as not having side effects.
We choose option (4) simply because it provides a feature that could have other applications. This change adds a `[__readNone]` attribute that can be applied to function declarations to express a promise on the part of the programmer that the given function has no side effects and computes its result strictly from the bits of its input arguments (and not things they point to, etc.). This mirrors an equivalent function attribute in LLVM.
We mark the function that computes a ray payload location with this attribute, and propagate the attribute through the layers of the IR, so that when the emit logic asks if an operation has side effects (to see if it can be folded into the arguments of a subsequent expression), we get an affirmative response.
This change should get all of the features that were present in the experiemntal `NVX` extension working with the final extension spec. It does not address callable shaders, which will come as a subsequent change.
Diffstat (limited to 'tests/vkray')
| -rw-r--r-- | tests/vkray/anyhit.slang.glsl | 10 | ||||
| -rw-r--r-- | tests/vkray/closesthit.slang.glsl | 14 | ||||
| -rw-r--r-- | tests/vkray/intersection.slang.glsl | 14 | ||||
| -rw-r--r-- | tests/vkray/miss.slang.glsl | 4 | ||||
| -rw-r--r-- | tests/vkray/raygen.slang.glsl | 146 |
5 files changed, 89 insertions, 99 deletions
diff --git a/tests/vkray/anyhit.slang.glsl b/tests/vkray/anyhit.slang.glsl index 7fb9ac553..43fd29e01 100644 --- a/tests/vkray/anyhit.slang.glsl +++ b/tests/vkray/anyhit.slang.glsl @@ -1,6 +1,6 @@ // anyhit.slang.glsl #version 460 -#extension GL_NVX_raytracing : require +#extension GL_NV_ray_tracing : require struct Params_0 { @@ -23,13 +23,13 @@ struct SphereHitAttributes_0 { vec3 normal_0; }; -hitAttributeNVX SphereHitAttributes_0 _S2; +hitAttributeNV SphereHitAttributes_0 _S2; struct ShadowRay_0 { vec4 hitDistance_0; }; -rayPayloadInNVX ShadowRay_0 _S3; +rayPayloadInNV ShadowRay_0 _S3; void main() { @@ -45,11 +45,11 @@ void main() if(val_0 > float(0)) { - terminateRayNVX(); + terminateRayNV(); } else { - ignoreIntersectionNVX(); + ignoreIntersectionNV(); } } diff --git a/tests/vkray/closesthit.slang.glsl b/tests/vkray/closesthit.slang.glsl index 2db319a7f..d4b9e7a6a 100644 --- a/tests/vkray/closesthit.slang.glsl +++ b/tests/vkray/closesthit.slang.glsl @@ -1,6 +1,6 @@ // closesthit.slang.glsl #version 460 -#extension GL_NVX_raytracing : require +#extension GL_NV_ray_tracing : require layout(std430) buffer _S1 { @@ -12,32 +12,32 @@ struct BuiltInTriangleIntersectionAttributes_0 vec2 barycentrics_0; }; -hitAttributeNVX BuiltInTriangleIntersectionAttributes_0 _S2; +hitAttributeNV BuiltInTriangleIntersectionAttributes_0 _S2; struct ReflectionRay_0 { vec4 color_0; }; -rayPayloadInNVX ReflectionRay_0 _S3; +rayPayloadInNV ReflectionRay_0 _S3; void main() { BuiltInTriangleIntersectionAttributes_0 _S4 = _S2; - uint _S5 = gl_InstanceCustomIndexNVX; + uint _S5 = gl_InstanceCustomIndexNV; uint _S6 = gl_InstanceID; uint _S7 = _S5 + _S6; uint _S8 = gl_PrimitiveID; uint _S9 = _S7 + _S8; - uint _S10 = gl_HitKindNVX; + uint _S10 = gl_HitKindNV; vec4 color_1 = colors_0[_S9 + _S10]; - float _S11 = gl_HitTNVX; - float _S12 = gl_RayTminNVX; + float _S11 = gl_HitTNV; + float _S12 = gl_RayTminNV; _S3.color_0 = color_1 * (_S11 - _S12); diff --git a/tests/vkray/intersection.slang.glsl b/tests/vkray/intersection.slang.glsl index 2fb999947..cfa53efa7 100644 --- a/tests/vkray/intersection.slang.glsl +++ b/tests/vkray/intersection.slang.glsl @@ -1,7 +1,7 @@ //TEST_IGNORE_FILE: #version 460 -#extension GL_NVX_raytracing : require +#extension GL_NV_ray_tracing : require struct Sphere_0 { @@ -40,28 +40,28 @@ bool rayIntersectsSphere_0( return tHit_0 >= ray_0.TMin_0; } -hitAttributeNVX SphereHitAttributes_0 a_0; +hitAttributeNV SphereHitAttributes_0 a_0; bool ReportHit_0(float tHit_1, uint hitKind_0, SphereHitAttributes_0 attributes_0) { a_0 = attributes_0; - bool _S1 = reportIntersectionNVX(tHit_1, hitKind_0); + bool _S1 = reportIntersectionNV(tHit_1, hitKind_0); return _S1; } void main() { RayDesc_0 ray_1; - vec3 _S2 = gl_ObjectRayOriginNVX; + vec3 _S2 = gl_ObjectRayOriginNV; ray_1.Origin_0 = _S2; - vec3 _S3 = gl_ObjectRayDirectionNVX; + vec3 _S3 = gl_ObjectRayDirectionNV; ray_1.Direction_0 = _S3; - float _S4 = gl_RayTminNVX; + float _S4 = gl_RayTminNV; ray_1.TMin_0 = _S4; - float _S5 = gl_RayTmaxNVX; + float _S5 = gl_RayTmaxNV; ray_1.TMax_0 = _S5; diff --git a/tests/vkray/miss.slang.glsl b/tests/vkray/miss.slang.glsl index 7ced92c24..33cff4a34 100644 --- a/tests/vkray/miss.slang.glsl +++ b/tests/vkray/miss.slang.glsl @@ -1,14 +1,14 @@ //TEST_IGNORE_FILE: #version 460 -#extension GL_NVX_raytracing : require +#extension GL_NV_ray_tracing : require struct ShadowRay_0 { float hitDistance_0; }; -rayPayloadInNVX ShadowRay_0 _S1; +rayPayloadInNV ShadowRay_0 _S1; void main() { diff --git a/tests/vkray/raygen.slang.glsl b/tests/vkray/raygen.slang.glsl index 2df4b9219..512215a73 100644 --- a/tests/vkray/raygen.slang.glsl +++ b/tests/vkray/raygen.slang.glsl @@ -1,7 +1,7 @@ //TEST_IGNORE_FILE: #version 460 -#extension GL_NVX_raytracing : require +#extension GL_NV_ray_tracing : require #define TRACING_EPSILON 1e-6 @@ -26,19 +26,19 @@ layout(std140) uniform ubo_0 layout(row_major) mat4x4 model_0; }; -layout(binding = 5) uniform accelerationStructureNVX as_0; +layout(binding = 5) uniform accelerationStructureNV as_0; struct ShadowRay_0 { float hitDistance_0; }; -layout(location = 0) rayPayloadNVX ShadowRay_0 p_0; +layout(location = 0) rayPayloadNV ShadowRay_0 p_0; struct ReflectionRay_0 { float color_1; }; -layout(location = 1) rayPayloadNVX ReflectionRay_0 p_1; +layout(location = 1) rayPayloadNV ReflectionRay_0 p_1; layout(rgba32f) layout(binding = 4) uniform image2D outputImage_0; @@ -51,7 +51,7 @@ struct RayDesc_0 }; void TraceRay_0( - accelerationStructureNVX AccelerationStructure_0, + accelerationStructureNV AccelerationStructure_0, uint RayFlags_0, uint InstanceInclusionMask_0, uint RayContributionToHitGroupIndex_0, @@ -61,35 +61,30 @@ void TraceRay_0( inout ShadowRay_0 Payload_0) { p_0 = Payload_0; - vec3 _S1 = Ray_0.Origin_0; - float _S2 = Ray_0.TMin_0; - vec3 _S3 = Ray_0.Direction_0; - float _S4 = Ray_0.TMax_0; - int _S5 = 0; - traceNVX( + traceNV( AccelerationStructure_0, RayFlags_0, InstanceInclusionMask_0, RayContributionToHitGroupIndex_0, MultiplierForGeometryContributionToHitGroupIndex_0, MissShaderIndex_0, - _S1, - _S2, - _S3, - _S4, - _S5); + Ray_0.Origin_0, + Ray_0.TMin_0, + Ray_0.Direction_0, + Ray_0.TMax_0, + 0); Payload_0 = p_0; return; } float saturate_0(float x_0) { - float _S6 = clamp(x_0, float(0), float(1)); - return _S6; + float _S1 = clamp(x_0, float(0), float(1)); + return _S1; } void TraceRay_1( - accelerationStructureNVX AccelerationStructure_1, + accelerationStructureNV AccelerationStructure_1, uint RayFlags_1, uint InstanceInclusionMask_1, uint RayContributionToHitGroupIndex_1, @@ -99,23 +94,18 @@ void TraceRay_1( inout ReflectionRay_0 Payload_1) { p_1 = Payload_1; - vec3 _S7 = Ray_1.Origin_0; - float _S8 = Ray_1.TMin_0; - vec3 _S9 = Ray_1.Direction_0; - float _S10 = Ray_1.TMax_0; - int _S11 = 1; - traceNVX( + traceNV( AccelerationStructure_1, RayFlags_1, InstanceInclusionMask_1, RayContributionToHitGroupIndex_1, MultiplierForGeometryContributionToHitGroupIndex_1, MissShaderIndex_1, - _S7, - _S8, - _S9, - _S10, - _S11); + Ray_1.Origin_0, + Ray_1.TMin_0, + Ray_1.Direction_0, + Ray_1.TMax_0, + 1); Payload_1 = p_1; return; } @@ -124,27 +114,27 @@ void main() { float atten_0; - uvec3 _S12 = uvec3(gl_LaunchIDNVX, 0); - float _S13 = float(_S12.x) + 0.5; - uvec3 _S14 = uvec3(gl_LaunchSizeNVX, 0); - float _S15 = _S13 / float(_S14.x); - uvec3 _S16 = uvec3(gl_LaunchIDNVX, 0); - float _S17 = float(_S16.y) + 0.5; - uvec3 _S18 = uvec3(gl_LaunchSizeNVX, 0); - float _S19 = _S17 / float(_S18.y); - vec2 inUV_0 = vec2(_S15, _S19); + uvec3 _S2 = gl_LaunchIDNV; + float _S3 = float(_S2.x) + 0.5; + uvec3 _S4 = gl_LaunchSizeNV; + float _S5 = _S3 / float(_S4.x); + uvec3 _S6 = gl_LaunchIDNV; + float _S7 = float(_S6.y) + 0.5; + uvec3 _S8 = gl_LaunchSizeNV; + float _S9 = _S7 / float(_S8.y); + vec2 inUV_0 = vec2(_S5, _S9); - vec4 _S20 = texture(sampler2D(samplerPosition_0, sampler_0), inUV_0); - vec3 P_0 = _S20.xyz; + vec4 _S10 = texture(sampler2D(samplerPosition_0, sampler_0), inUV_0); + vec3 P_0 = _S10.xyz; - vec4 _S21 = texture(sampler2D(samplerNormal_0, sampler_0), inUV_0); - vec3 N_0 = _S21.xyz * 2.0 - 1.0; + vec4 _S11 = texture(sampler2D(samplerNormal_0, sampler_0), inUV_0); + vec3 N_0 = _S11.xyz * 2.0 - 1.0; vec3 lightDelta_0 = light_0.position_0.xyz - P_0; float lightDist_0 = length(lightDelta_0); vec3 L_0 = normalize(lightDelta_0); - float _S22 = 1.0 / (lightDist_0 * lightDist_0); + float _S12 = 1.0 / (lightDist_0 * lightDist_0); RayDesc_0 ray_0; ray_0.Origin_0 = P_0; @@ -154,47 +144,47 @@ void main() ShadowRay_0 shadowRay_0; shadowRay_0.hitDistance_0 = float(0); - const uint _S23 = uint(1); - const uint _S24 = uint(0xFF); - const uint _S25 = uint(0); - const uint _S26 = uint(0); - const uint _S27 = uint(2); - - RayDesc_0 _S28 = ray_0; - ShadowRay_0 _S29; - _S29 = shadowRay_0; - TraceRay_0(as_0, _S23, _S24, _S25, _S26, _S27, _S28, _S29); - shadowRay_0 = _S29; - - bool _S30 = shadowRay_0.hitDistance_0 < lightDist_0; + const uint _S13 = uint(1); + const uint _S14 = uint(0xFF); + const uint _S15 = uint(0); + const uint _S16 = uint(0); + const uint _S17 = uint(2); + + RayDesc_0 _S18 = ray_0; + ShadowRay_0 _S19; + _S19 = shadowRay_0; + TraceRay_0(as_0, _S13, _S14, _S15, _S16, _S17, _S18, _S19); + shadowRay_0 = _S19; + + bool _S20 = shadowRay_0.hitDistance_0 < lightDist_0; ReflectionRay_0 reflectionRay_0; - if(_S30) + if(_S20) { atten_0 = (0.00000000000000000000); } else { - atten_0 = _S22; + atten_0 = _S12; } - vec3 _S31 = light_0.color_0.xyz; - float _S32 = dot(N_0, L_0); - float _S33 = saturate_0(_S32); - vec3 color_2 = (_S31 * _S33) * atten_0; - - const uint _S34 = uint(1); - const uint _S35 = uint(255); - const uint _S36 = uint(0); - const uint _S37 = uint(0); - const uint _S38 = uint(2); - RayDesc_0 _S39 = ray_0; - ReflectionRay_0 _S40; - _S40 = reflectionRay_0; - TraceRay_1(as_0, _S34, _S35, _S36, _S37, _S38, _S39, _S40); - - vec3 color_3 = color_2 + _S40.color_1; - - uvec3 _S41 = uvec3(gl_LaunchIDNVX, 0); - imageStore(outputImage_0, ivec2(uvec2(ivec2(_S41.xy))), vec4(color_3, 1.0)); + vec3 _S21 = light_0.color_0.xyz; + float _S22 = dot(N_0, L_0); + float _S23 = saturate_0(_S22); + vec3 color_2 = (_S21 * _S23) * atten_0; + + const uint _S24 = uint(1); + const uint _S25 = uint(255); + const uint _S26 = uint(0); + const uint _S27 = uint(0); + const uint _S28 = uint(2); + RayDesc_0 _S29 = ray_0; + ReflectionRay_0 _S30; + _S30 = reflectionRay_0; + TraceRay_1(as_0, _S24, _S25, _S26, _S27, _S28, _S29, _S30); + + vec3 color_3 = color_2 + _S30.color_1; + + uvec3 _S31 = gl_LaunchIDNV; + imageStore(outputImage_0, ivec2(uvec2(ivec2(_S31.xy))), vec4(color_3, 1.0)); return; } |
