diff options
| author | Yong He <yonghe@outlook.com> | 2023-05-09 09:44:33 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-09 09:44:33 -0700 |
| commit | 38ed03a7203baacf36fca62539ac74fd45ed42d2 (patch) | |
| tree | 9648daee25c0a2aaac2fa8cd7d91908fd2aeef2f /tests/pipeline | |
| parent | 89a1234964a1927c4936a2758f72b7d6c9d0bc73 (diff) | |
Fix function side-effectness prop logic. (#2875)
Diffstat (limited to 'tests/pipeline')
7 files changed, 227 insertions, 103 deletions
diff --git a/tests/pipeline/ray-tracing/acceleration-structure-in-compute-nv.slang.glsl b/tests/pipeline/ray-tracing/acceleration-structure-in-compute-nv.slang.glsl index 5819d657d..0374569fe 100644 --- a/tests/pipeline/ray-tracing/acceleration-structure-in-compute-nv.slang.glsl +++ b/tests/pipeline/ray-tracing/acceleration-structure-in-compute-nv.slang.glsl @@ -1,18 +1,11 @@ #version 460 - -#extension GL_NV_ray_tracing : require - -int helper_0(accelerationStructureNV a_0, int b_0) -{ - return b_0; -} - -layout(binding = 1) -uniform accelerationStructureNV entryPointParams_x_0; +layout(row_major) uniform; +layout(row_major) buffer; layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - int _S1 = helper_0(entryPointParams_x_0, 1); + return; } + diff --git a/tests/pipeline/ray-tracing/acceleration-structure-in-compute.slang.glsl b/tests/pipeline/ray-tracing/acceleration-structure-in-compute.slang.glsl index 83797d2d5..0374569fe 100644 --- a/tests/pipeline/ray-tracing/acceleration-structure-in-compute.slang.glsl +++ b/tests/pipeline/ray-tracing/acceleration-structure-in-compute.slang.glsl @@ -1,18 +1,11 @@ #version 460 -#extension GL_EXT_ray_tracing : require layout(row_major) uniform; layout(row_major) buffer; -int helper_0(accelerationStructureEXT a_0, int b_0) -{ - return b_0; -} - -layout(binding = 1) -uniform accelerationStructureEXT entryPointParams_x_0; layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - int _S1 = helper_0(entryPointParams_x_0, 1); + return; } + diff --git a/tests/pipeline/ray-tracing/ray-query-subroutine.slang b/tests/pipeline/ray-tracing/ray-query-subroutine.slang index 501071717..3279acc12 100644 --- a/tests/pipeline/ray-tracing/ray-query-subroutine.slang +++ b/tests/pipeline/ray-tracing/ray-query-subroutine.slang @@ -7,7 +7,7 @@ RWStructuredBuffer<int> gOutput; RaytracingAccelerationStructure gScene; -int helper<let N : int>(RayQuery<N> q) +float3 helper<let N : int>(RayQuery<N> q) { RayDesc ray; ray.Origin = 0; @@ -20,7 +20,7 @@ int helper<let N : int>(RayQuery<N> q) /* instanceInclusionmask: */ 0xFFFFFFFF, /* ray: */ ray ); - return 1; + return q.WorldRayDirection(); } [shader("compute")] @@ -36,5 +36,5 @@ void computeMain(uint tid : SV_DispatchThreadID) RayQuery<0> rayQuery; let result = helper(rayQuery); - gOutput[tid.x] = result; + gOutput[tid.x] = int(result.x); } diff --git a/tests/pipeline/ray-tracing/ray-query-subroutine.slang.hlsl b/tests/pipeline/ray-tracing/ray-query-subroutine.slang.hlsl index 5906823e5..db97f4278 100644 --- a/tests/pipeline/ray-tracing/ray-query-subroutine.slang.hlsl +++ b/tests/pipeline/ray-tracing/ray-query-subroutine.slang.hlsl @@ -1,26 +1,32 @@ -//TEST_IGNORE_FILE: - RaytracingAccelerationStructure gScene_0 : register(t0); -int helper_0(RayQuery<int(0) > q_0) +RWStructuredBuffer<int > gOutput_0 : register(u0); + +float3 helper_0(RayQuery<int(0) > q_0) { + RayQuery<int(0) > _S1 = q_0; + RayDesc ray_0; - ray_0.Origin = (vector<float,3>) int(0); - ray_0.Direction = (vector<float,3>) int(0); - ray_0.TMin = (float) int(0); - ray_0.TMax = 1000.00000000000000000000; - q_0.TraceRayInline(gScene_0, (uint) int(0), (uint) int(-1), ray_0); - return int(1); + float3 _S2 = (float3)0.0; + + ray_0.Origin = _S2; + ray_0.Direction = _S2; + ray_0.TMin = 0.0; + ray_0.TMax = 1000.0; + _S1.TraceRayInline(gScene_0, 0U, 4294967295U, ray_0); + + return _S1.WorldRayDirection(); } -RWStructuredBuffer<int > gOutput_0 : register(u0); [shader("compute")][numthreads(1, 1, 1)] void computeMain(uint tid_0 : SV_DISPATCHTHREADID) { RayQuery<int(0) > rayQuery_0; - int _S1 = helper_0(rayQuery_0); - gOutput_0[tid_0.x] = _S1; + int _S3 = int(helper_0(rayQuery_0).x); + + gOutput_0[tid_0.x] = _S3; return; } + diff --git a/tests/pipeline/ray-tracing/trace-ray-inline.slang b/tests/pipeline/ray-tracing/trace-ray-inline.slang index d44500e18..e952bb802 100644 --- a/tests/pipeline/ray-tracing/trace-ray-inline.slang +++ b/tests/pipeline/ray-tracing/trace-ray-inline.slang @@ -83,6 +83,8 @@ bool myProceduralIntersection(inout float tHit, inout MyProceduralHitAttrs hitAt return true; } +RWStructuredBuffer<int> resultBuffer; + // In order to kick of tracing we need the properties of a ray // query to trace, so we will pipe those in via a constant buffer. // @@ -169,4 +171,6 @@ void main(uint3 tid : SV_DispatchThreadID) myMiss(payload); break; } + + resultBuffer[index] = payload.value; }
\ No newline at end of file diff --git a/tests/pipeline/ray-tracing/trace-ray-inline.slang.glsl b/tests/pipeline/ray-tracing/trace-ray-inline.slang.glsl index bb605a14a..56926e956 100644 --- a/tests/pipeline/ray-tracing/trace-ray-inline.slang.glsl +++ b/tests/pipeline/ray-tracing/trace-ray-inline.slang.glsl @@ -4,7 +4,7 @@ layout(row_major) uniform; layout(row_major) buffer; -#line 89 "tests/pipeline/ray-tracing/trace-ray-inline.slang" +#line 91 "tests/pipeline/ray-tracing/trace-ray-inline.slang" struct SLANG_ParameterGroup_C_0 { vec3 origin_0; @@ -17,8 +17,8 @@ struct SLANG_ParameterGroup_C_0 }; -#line 89 -layout(binding = 1) +#line 91 +layout(binding = 2) layout(std140) uniform _S1 { vec3 origin_0; @@ -35,6 +35,11 @@ layout(binding = 0) uniform accelerationStructureEXT myAccelerationStructure_0; +#line 86 +layout(std430, binding = 1) buffer _S2 { + int _data[]; +} resultBuffer_0; + #line 59 struct MyProceduralHitAttrs_0 { @@ -94,61 +99,64 @@ void myMiss_0(inout MyRayPayload_0 payload_4) } -#line 103 +#line 105 layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main() { - rayQueryEXT query_0; - +#line 107 + uint index_0 = gl_GlobalInvocationID.x; +#line 112 MyRayPayload_0 payload_5; -#line 110 +#line 112 payload_5.value_1 = -1; +#line 109 + rayQueryEXT query_0; + +#line 114 rayQueryInitializeEXT((query_0), (myAccelerationStructure_0), (C_0.rayFlags_0 | 512), (C_0.instanceMask_0), (C_0.origin_0), (C_0.tMin_0), (C_0.direction_0), (C_0.tMax_0)); -#line 112 +#line 114 MyProceduralHitAttrs_0 committedProceduralAttrs_0; -#line 112 +#line 114 for(;;) { -#line 121 - bool _S2 = rayQueryProceedEXT(query_0); +#line 123 + bool _S3 = rayQueryProceedEXT(query_0); -#line 121 - if(!_S2) +#line 123 + if(!_S3) { -#line 121 +#line 123 break; } - uint _S3 = (rayQueryGetIntersectionTypeEXT((query_0), false)); #line 123 MyProceduralHitAttrs_0 committedProceduralAttrs_1; -#line 123 - switch(_S3) + switch((rayQueryGetIntersectionTypeEXT((query_0), false))) { case 1U: { MyProceduralHitAttrs_0 candidateProceduralAttrs_0; -#line 127 +#line 129 candidateProceduralAttrs_0.value_0 = 0; float tHit_1 = 0.0; bool _S4 = myProceduralIntersection_0(tHit_1, candidateProceduralAttrs_0); -#line 129 +#line 131 if(_S4) { bool _S5 = myProceduralAnyHit_0(payload_5); -#line 131 +#line 133 if(_S5) { rayQueryGenerateIntersectionEXT(query_0, tHit_1); @@ -156,136 +164,132 @@ void main() if(C_0.shouldStopAtFirstHit_0 != 0U) { -#line 136 +#line 138 rayQueryTerminateEXT(query_0); -#line 135 +#line 137 } else { -#line 135 +#line 137 } -#line 135 +#line 137 committedProceduralAttrs_1 = _S6; -#line 135 +#line 137 } else { -#line 135 +#line 137 committedProceduralAttrs_1 = committedProceduralAttrs_0; -#line 135 +#line 137 } -#line 135 +#line 137 } else { -#line 135 +#line 137 committedProceduralAttrs_1 = committedProceduralAttrs_0; -#line 135 +#line 137 } -#line 135 +#line 137 break; } case 0U: { -#line 144 +#line 146 bool _S7 = myTriangleAnyHit_0(payload_5); -#line 144 +#line 146 if(_S7) { rayQueryConfirmIntersectionEXT(query_0); if(C_0.shouldStopAtFirstHit_0 != 0U) { -#line 148 +#line 150 rayQueryTerminateEXT(query_0); -#line 147 +#line 149 } else { -#line 147 +#line 149 } -#line 144 +#line 146 } else { -#line 144 +#line 146 } -#line 144 +#line 146 committedProceduralAttrs_1 = committedProceduralAttrs_0; -#line 144 +#line 146 break; } default: { -#line 144 +#line 146 committedProceduralAttrs_1 = committedProceduralAttrs_0; -#line 144 +#line 146 break; } } -#line 119 +#line 121 committedProceduralAttrs_0 = committedProceduralAttrs_1; -#line 119 +#line 121 } -#line 158 - uint _S8 = (rayQueryGetIntersectionTypeEXT((query_0), true)); - -#line 158 - switch(_S8) +#line 160 + switch((rayQueryGetIntersectionTypeEXT((query_0), true))) { case 1U: { -#line 161 +#line 163 myTriangleClosestHit_0(payload_5); break; } case 2U: { -#line 165 +#line 167 myProceduralClosestHit_0(payload_5, committedProceduralAttrs_0); break; } case 0U: { -#line 169 +#line 171 myMiss_0(payload_5); break; } default: { -#line 170 +#line 172 break; } } - -#line 172 + ((resultBuffer_0)._data[(index_0)]) = payload_5.value_1; return; } diff --git a/tests/pipeline/ray-tracing/trace-ray-inline.slang.hlsl b/tests/pipeline/ray-tracing/trace-ray-inline.slang.hlsl index a85415065..e96cbb8f4 100644 --- a/tests/pipeline/ray-tracing/trace-ray-inline.slang.hlsl +++ b/tests/pipeline/ray-tracing/trace-ray-inline.slang.hlsl @@ -4,6 +4,8 @@ #endif #pragma warning(disable: 3557) + +#line 91 "tests/pipeline/ray-tracing/trace-ray-inline.slang" struct SLANG_ParameterGroup_C_0 { float3 origin_0; @@ -15,150 +17,272 @@ struct SLANG_ParameterGroup_C_0 uint shouldStopAtFirstHit_0; }; + +#line 91 cbuffer C_0 : register(b0) { SLANG_ParameterGroup_C_0 C_0; } + +#line 12 RaytracingAccelerationStructure myAccelerationStructure_0 : register(t0); + +#line 86 +RWStructuredBuffer<int > resultBuffer_0 : register(u0); + + +#line 59 struct MyProceduralHitAttrs_0 { int value_0; }; + +#line 81 bool myProceduralIntersection_0(inout float tHit_0, inout MyProceduralHitAttrs_0 hitAttrs_0) { return true; } + +#line 26 struct MyRayPayload_0 { int value_1; }; + +#line 69 bool myProceduralAnyHit_0(inout MyRayPayload_0 payload_0) { return true; } + +#line 51 bool myTriangleAnyHit_0(inout MyRayPayload_0 payload_1) { return true; } + +#line 40 void myTriangleClosestHit_0(inout MyRayPayload_0 payload_2) { payload_2.value_1 = int(1); return; } + +#line 65 void myProceduralClosestHit_0(inout MyRayPayload_0 payload_3, MyProceduralHitAttrs_0 attrs_0) { payload_3.value_1 = attrs_0.value_0; return; } + +#line 33 void myMiss_0(inout MyRayPayload_0 payload_4) { payload_4.value_1 = int(0); return; } + +#line 105 [shader("compute")][numthreads(1, 1, 1)] void main(uint3 tid_0 : SV_DISPATCHTHREADID) { - RayQuery<int(512) > query_0; +#line 107 + uint index_0 = tid_0.x; + +#line 112 MyRayPayload_0 payload_5; + +#line 112 payload_5.value_1 = int(-1); RayDesc ray_0 = { C_0.origin_0, C_0.tMin_0, C_0.direction_0, C_0.tMax_0 }; + +#line 109 + RayQuery<int(512) > query_0; + +#line 114 query_0.TraceRayInline(myAccelerationStructure_0, C_0.rayFlags_0, C_0.instanceMask_0, ray_0); + +#line 114 MyProceduralHitAttrs_0 committedProceduralAttrs_0; + +#line 114 for(;;) { + +#line 123 bool _S1 = query_0.Proceed(); + +#line 123 if(!_S1) { + +#line 123 break; } - uint _S2 = query_0.CandidateType(); + +#line 123 MyProceduralHitAttrs_0 committedProceduralAttrs_1; - switch(_S2) + + switch(query_0.CandidateType()) { case 1U: { MyProceduralHitAttrs_0 candidateProceduralAttrs_0; + +#line 129 candidateProceduralAttrs_0.value_0 = int(0); float tHit_1 = 0.0; - bool _S3 = myProceduralIntersection_0(tHit_1, candidateProceduralAttrs_0); - if(_S3) + bool _S2 = myProceduralIntersection_0(tHit_1, candidateProceduralAttrs_0); + +#line 131 + if(_S2) { - bool _S4 = myProceduralAnyHit_0(payload_5); - if(_S4) + bool _S3 = myProceduralAnyHit_0(payload_5); + +#line 133 + if(_S3) { query_0.CommitProceduralPrimitiveHit(tHit_1); - MyProceduralHitAttrs_0 _S5 = candidateProceduralAttrs_0; + MyProceduralHitAttrs_0 _S4 = candidateProceduralAttrs_0; if(C_0.shouldStopAtFirstHit_0 != 0U) { + +#line 138 query_0.Abort(); + +#line 137 + } + else + { + +#line 137 } - committedProceduralAttrs_1 = _S5; + +#line 137 + committedProceduralAttrs_1 = _S4; + +#line 137 } else { + +#line 137 committedProceduralAttrs_1 = committedProceduralAttrs_0; + +#line 137 } + +#line 137 } else { + +#line 137 committedProceduralAttrs_1 = committedProceduralAttrs_0; + +#line 137 } + +#line 137 break; } case 0U: { - bool _S6 = myTriangleAnyHit_0(payload_5); - if(_S6) + +#line 146 + bool _S5 = myTriangleAnyHit_0(payload_5); + +#line 146 + if(_S5) { query_0.CommitNonOpaqueTriangleHit(); if(C_0.shouldStopAtFirstHit_0 != 0U) { + +#line 150 query_0.Abort(); + +#line 149 + } + else + { + +#line 149 } + +#line 146 + } + else + { + +#line 146 } + +#line 146 committedProceduralAttrs_1 = committedProceduralAttrs_0; + +#line 146 break; } default: { + +#line 146 committedProceduralAttrs_1 = committedProceduralAttrs_0; + +#line 146 break; } } + +#line 121 committedProceduralAttrs_0 = committedProceduralAttrs_1; + +#line 121 } - uint _S7 = query_0.CommittedStatus(); - switch(_S7) + +#line 160 + switch(query_0.CommittedStatus()) { case 1U: { + +#line 163 myTriangleClosestHit_0(payload_5); break; } case 2U: { + +#line 167 myProceduralClosestHit_0(payload_5, committedProceduralAttrs_0); break; } case 0U: { + +#line 171 myMiss_0(payload_5); break; } default: { + +#line 172 break; } } + resultBuffer_0[index_0] = payload_5.value_1; return; } + |
