diff options
| author | Yong He <yonghe@outlook.com> | 2023-02-24 10:01:47 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-24 10:01:47 -0800 |
| commit | bd6306cdaa4a49344658bd026721b6532e103d09 (patch) | |
| tree | bb7f666d426e6cfc7777a3ccac0a1d628588eb39 /tests/nv-extensions | |
| parent | e8c08e7ecb1124f115a1d1042277776193122b57 (diff) | |
More control flow simplifications. (#2673)
* More control flow and Phi param simplifications.
* Fix.
* Fix gcc error.
* Fix.
* More IR cleanup.
* Fix bug in phi param dce + ifelse simplify.
* Propagate and DCE side-effect-free functions.
* Enhance CFG simplifcation to remove loops with no side effects.
* Fix.
* Fixes.
* Fix tests. Add [__AlwaysFoldIntoUseSite] for rayPayloadLocation.
* More cleanup.
* Fixes.
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests/nv-extensions')
| -rw-r--r-- | tests/nv-extensions/nv-ray-tracing-motion-blur.slang.glsl | 84 |
1 files changed, 17 insertions, 67 deletions
diff --git a/tests/nv-extensions/nv-ray-tracing-motion-blur.slang.glsl b/tests/nv-extensions/nv-ray-tracing-motion-blur.slang.glsl index 724a0a241..bae5f361d 100644 --- a/tests/nv-extensions/nv-ray-tracing-motion-blur.slang.glsl +++ b/tests/nv-extensions/nv-ray-tracing-motion-blur.slang.glsl @@ -3,47 +3,38 @@ #extension GL_NV_ray_tracing_motion_blur : require layout(row_major) uniform; layout(row_major) buffer; - struct ReflectionRay_0 { float color_0; }; - layout(location = 0) rayPayloadEXT ReflectionRay_0 p_0; - struct ShadowRay_0 { float hitDistance_0; }; - layout(location = 1) rayPayloadEXT ShadowRay_0 p_1; - layout(binding = 0) uniform texture2D samplerPosition_0; - layout(binding = 2) uniform sampler sampler_0; - layout(binding = 1) uniform texture2D samplerNormal_0; - struct Light_0 { vec4 position_0; vec4 color_1; }; - struct Uniforms_0 { Light_0 light_0; @@ -52,13 +43,11 @@ struct Uniforms_0 mat4x4 model_0; }; - layout(binding = 3) layout(std140) uniform _S1 { Uniforms_0 _data; } ubo_0; - struct RayDesc_0 { vec3 Origin_0; @@ -67,115 +56,76 @@ struct RayDesc_0 float TMax_0; }; - void TraceMotionRay_0(accelerationStructureEXT AccelerationStructure_0, uint RayFlags_0, uint InstanceInclusionMask_0, uint RayContributionToHitGroupIndex_0, uint MultiplierForGeometryContributionToHitGroupIndex_0, uint MissShaderIndex_0, RayDesc_0 Ray_0, float CurrentTime_0, inout ShadowRay_0 Payload_0) { - p_1 = Payload_0; traceRayMotionNV(AccelerationStructure_0, RayFlags_0, InstanceInclusionMask_0, RayContributionToHitGroupIndex_0, MultiplierForGeometryContributionToHitGroupIndex_0, MissShaderIndex_0, Ray_0.Origin_0, Ray_0.TMin_0, Ray_0.Direction_0, Ray_0.TMax_0, CurrentTime_0, (1)); - Payload_0 = p_1; return; } - layout(binding = 5) uniform accelerationStructureEXT as_0; - float saturate_0(float x_0) { - float _S2 = clamp(x_0, 0.0, 1.0); - - return _S2; + return clamp(x_0, 0.0, 1.0); } - void TraceRay_0(accelerationStructureEXT AccelerationStructure_1, uint RayFlags_1, uint InstanceInclusionMask_1, uint RayContributionToHitGroupIndex_1, uint MultiplierForGeometryContributionToHitGroupIndex_1, uint MissShaderIndex_1, RayDesc_0 Ray_1, inout ReflectionRay_0 Payload_1) { - p_0 = Payload_1; traceRayEXT(AccelerationStructure_1, RayFlags_1, InstanceInclusionMask_1, RayContributionToHitGroupIndex_1, MultiplierForGeometryContributionToHitGroupIndex_1, MissShaderIndex_1, Ray_1.Origin_0, Ray_1.TMin_0, Ray_1.Direction_0, Ray_1.TMax_0, (0)); - Payload_1 = p_0; return; } - layout(rgba32f) layout(binding = 4) uniform image2D outputImage_0; - void main() { - uvec3 _S3 = ((gl_LaunchIDEXT)); - - ivec2 launchID_0 = ivec2(_S3.xy); - uvec3 _S4 = ((gl_LaunchSizeEXT)); - - ivec2 launchSize_0 = ivec2(_S4.xy); - - - float _S5 = (float(launchID_0.x) + 0.5) / float(launchSize_0.x); - float _S6 = (float(launchID_0.y) + 0.5) / float(launchSize_0.y); - - vec2 inUV_0 = vec2(_S5, _S6); - - vec4 _S7 = (texture(sampler2D(samplerPosition_0,sampler_0), (inUV_0))); - - vec3 P_0 = _S7.xyz; - vec4 _S8 = (texture(sampler2D(samplerNormal_0,sampler_0), (inUV_0))); - - vec3 N_0 = _S8.xyz * 2.0 - 1.0; - + uvec3 _S2 = ((gl_LaunchIDEXT)); + ivec2 launchID_0 = ivec2(_S2.xy); + uvec3 _S3 = ((gl_LaunchSizeEXT)); + ivec2 launchSize_0 = ivec2(_S3.xy); + + float _S4 = (float(launchID_0.x) + 0.5) / float(launchSize_0.x); + float _S5 = (float(launchID_0.y) + 0.5) / float(launchSize_0.y); + vec2 inUV_0 = vec2(_S4, _S5); + vec4 _S6 = (texture(sampler2D(samplerPosition_0,sampler_0), (inUV_0))); + vec3 P_0 = _S6.xyz; + vec4 _S7 = (texture(sampler2D(samplerNormal_0,sampler_0), (inUV_0))); + vec3 N_0 = _S7.xyz * 2.0 - 1.0; vec3 lightDelta_0 = ubo_0._data.light_0.position_0.xyz - P_0; float lightDist_0 = length(lightDelta_0); vec3 L_0 = normalize(lightDelta_0); - float _S9 = 1.0 / (lightDist_0 * lightDist_0); - + float _S8 = 1.0 / (lightDist_0 * lightDist_0); RayDesc_0 ray_0; ray_0.Origin_0 = P_0; ray_0.TMin_0 = 0.00000099999999747524; ray_0.Direction_0 = lightDelta_0; ray_0.TMax_0 = lightDist_0; - ShadowRay_0 shadowRay_0; shadowRay_0.hitDistance_0 = 0.0; - - TraceMotionRay_0(as_0, 1U, 255U, 0U, 0U, 2U, ray_0, 1.0, shadowRay_0); - float atten_0; - if(shadowRay_0.hitDistance_0 < lightDist_0) { - atten_0 = 0.0; - } else { - - atten_0 = _S9; - + atten_0 = _S8; } - - vec3 _S10 = ubo_0._data.light_0.color_1.xyz; - - float _S11 = dot(N_0, L_0); - - float _S12 = saturate_0(_S11); - - vec3 color_2 = _S10 * _S12 * atten_0; - + vec3 color_2 = ubo_0._data.light_0.color_1.xyz * saturate_0(dot(N_0, L_0)) * atten_0; ReflectionRay_0 reflectionRay_0; TraceRay_0(as_0, 1U, 255U, 0U, 0U, 2U, ray_0, reflectionRay_0); - imageStore((outputImage_0), ivec2((uvec2(launchID_0))), vec4(color_2 + reflectionRay_0.color_0, 1.0)); return; -}
\ No newline at end of file +} |
