From 4c4826d47eeef4675daae4ae53ff76f4d5ebd84a Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 16 Feb 2023 13:55:32 -0800 Subject: Overhaul global inst deduplication and cpp/cuda backend. (#2654) * Overhaul global inst deduplication and cpp/cuda backend. * Update IR documentation. --------- Co-authored-by: Yong He --- tests/bugs/vk-structured-buffer-load.hlsl.glsl | 41 +++++------ .../dynamic-dispatch-bindless-texture.slang | 2 +- .../cross-compile/function-static-const.slang.hlsl | 6 +- tests/hlsl-intrinsic/f16tof32.slang | 2 +- tests/hlsl-intrinsic/f32tof16.slang | 2 +- tests/hlsl-intrinsic/matrix-double.slang | 75 ++++++++++--------- .../hit-object-reorder-thread.slang.1.expected | 26 +++---- .../hit-object-trace-motion-ray.slang.1.expected | 8 +-- .../hit-object-trace-ray.slang.1.expected | 8 +-- .../nv-ray-tracing-motion-blur.slang.glsl | 81 +++++++++++++-------- .../rasterization/mesh/component-write.slang.glsl | 12 ++-- tests/pipeline/rasterization/mesh/hello.slang.glsl | 8 ++- tests/pipeline/rasterization/mesh/hello.slang.hlsl | 8 +-- .../rasterization/mesh/primitive-output.slang.glsl | 7 +- tests/vkray/raygen.slang.glsl | 83 +++++++++++----------- 15 files changed, 201 insertions(+), 168 deletions(-) (limited to 'tests') diff --git a/tests/bugs/vk-structured-buffer-load.hlsl.glsl b/tests/bugs/vk-structured-buffer-load.hlsl.glsl index 05c8de193..7f3ec40a2 100644 --- a/tests/bugs/vk-structured-buffer-load.hlsl.glsl +++ b/tests/bugs/vk-structured-buffer-load.hlsl.glsl @@ -2,17 +2,9 @@ //TEST_IGNORE_FILE: #version 460 +#extension GL_NV_ray_tracing : require layout(row_major) uniform; layout(row_major) buffer; -#extension GL_NV_ray_tracing : require - -#define rcp_tmp _S2 -#define RayData _S3 -#define Attributes _S4 - -#define tmpA _S5 -#define tmpB _S6 -#define tmpC _S7 layout(std430, binding = 1) readonly buffer _S1 { float _data[]; @@ -20,8 +12,8 @@ layout(std430, binding = 1) readonly buffer _S1 { float rcp_0(float x_0) { - float rcp_tmp = float(1.00000000000000000000) / x_0; - return rcp_tmp; + float _S2 = 1.0 / x_0; + return _S2; } struct RayHitInfoPacked_0 @@ -29,49 +21,48 @@ struct RayHitInfoPacked_0 vec4 PackedHitInfoA_0; }; -rayPayloadInNV RayHitInfoPacked_0 RayData; +rayPayloadInNV RayHitInfoPacked_0 _S3; struct BuiltInTriangleIntersectionAttributes_0 { vec2 barycentrics_0; }; -hitAttributeNV BuiltInTriangleIntersectionAttributes_0 Attributes; +hitAttributeNV BuiltInTriangleIntersectionAttributes_0 _S4; void main() { - float HitT_0 = (gl_RayTmaxNV); - RayData.PackedHitInfoA_0.x = HitT_0; - + float HitT_0 = ((gl_RayTmaxNV)); + _S3.PackedHitInfoA_0.x = HitT_0; float offsfloat_0 = ((gParamBlock_sbuf_0)._data[(0)]); - uint use_rcp_0 = 0U | uint(HitT_0 > 0.00000000000000000000); + uint use_rcp_0 = 0U | uint(HitT_0 > 0.0); - if(bool(use_rcp_0)) + if(use_rcp_0 != 0U) { - float tmpA = rcp_0(offsfloat_0); + float _S5 = rcp_0(offsfloat_0); - RayData.PackedHitInfoA_0.y = tmpA; + _S3.PackedHitInfoA_0.y = _S5; } else { - if(use_rcp_0 > 0U&&offsfloat_0 == 0.00000000000000000000) + if(use_rcp_0 > 0U&&offsfloat_0 == 0.0) { - float tmpB = (inversesqrt((offsfloat_0 + 1.00000000000000000000))); + float _S6 = (inversesqrt((offsfloat_0 + 1.0))); - RayData.PackedHitInfoA_0.y = tmpB; + _S3.PackedHitInfoA_0.y = _S6; } else { - float tmpC = (inversesqrt((offsfloat_0))); + float _S7 = (inversesqrt((offsfloat_0))); - RayData.PackedHitInfoA_0.y = tmpC; + _S3.PackedHitInfoA_0.y = _S7; } diff --git a/tests/compute/dynamic-dispatch-bindless-texture.slang b/tests/compute/dynamic-dispatch-bindless-texture.slang index 4611fbd48..04c1f1766 100644 --- a/tests/compute/dynamic-dispatch-bindless-texture.slang +++ b/tests/compute/dynamic-dispatch-bindless-texture.slang @@ -10,7 +10,7 @@ interface IInterface //TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer RWStructuredBuffer gOutputBuffer; -//TEST_INPUT: set gCb = new StructuredBuffer{new MyImpl{Texture2D(size=8, content = one)}} +//TEST_INPUT: set gCb = new StructuredBuffer{new MyImpl{Texture2D(size=8, content = one), Sampler}} StructuredBuffer gCb; [numthreads(4, 1, 1)] diff --git a/tests/cross-compile/function-static-const.slang.hlsl b/tests/cross-compile/function-static-const.slang.hlsl index a4f1118eb..95d1e3070 100644 --- a/tests/cross-compile/function-static-const.slang.hlsl +++ b/tests/cross-compile/function-static-const.slang.hlsl @@ -13,15 +13,15 @@ cbuffer C_0 : register(b0) SLANG_ParameterGroup_C_0 C_0; } -static const int kArray_0[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; +static const int kArray_0[int(16)] = { int(1), int(2), int(3), int(4), int(5), int(6), int(7), int(8), int(9), int(10), int(11), int(12), int(13), int(14), int(15), int(16) }; int test_0(int val_0) { return kArray_0[val_0]; } -vector main() : SV_TARGET +float4 main() : SV_TARGET { int _S1 = test_0(C_0.index_0); - return (vector) _S1; + return (float4) float(_S1); } diff --git a/tests/hlsl-intrinsic/f16tof32.slang b/tests/hlsl-intrinsic/f16tof32.slang index 78c5fdae6..d45eab00b 100644 --- a/tests/hlsl-intrinsic/f16tof32.slang +++ b/tests/hlsl-intrinsic/f16tof32.slang @@ -2,7 +2,7 @@ //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -render-features half +//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -render-features half //TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer RWStructuredBuffer outputBuffer; diff --git a/tests/hlsl-intrinsic/f32tof16.slang b/tests/hlsl-intrinsic/f32tof16.slang index ebcb6b40a..ad8e8e5df 100644 --- a/tests/hlsl-intrinsic/f32tof16.slang +++ b/tests/hlsl-intrinsic/f32tof16.slang @@ -2,7 +2,7 @@ //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -render-features half +//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -render-features half //TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer RWStructuredBuffer outputBuffer; diff --git a/tests/hlsl-intrinsic/matrix-double.slang b/tests/hlsl-intrinsic/matrix-double.slang index b9e36bef8..08bd78cee 100644 --- a/tests/hlsl-intrinsic/matrix-double.slang +++ b/tests/hlsl-intrinsic/matrix-double.slang @@ -35,8 +35,7 @@ Float calcTotal(FloatMatrix v) FloatMatrix makeFloatMatrix(Float f) { - FloatMatrix m = { { f, f }, { f, f } }; - return m; + return FloatMatrix(f); } IntMatrix makeIntMatrix(int v) @@ -45,68 +44,58 @@ IntMatrix makeIntMatrix(int v) return m; } -[numthreads(4, 1, 1)] -void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +void test1(inout FloatMatrix ft, inout FloatMatrix f, int idx) { - int idx = int(dispatchThreadID.x); - - Float scalarF = idx * (1.0f / (4.0f)); - - FloatMatrix ft = {}; - - FloatMatrix f = { { scalarF + 0.01, scalarF + 0.02}, { scalarF + 0.011, scalarF + 0.022}}; - // fmod ft += FloatMatrix(IntMatrix(((f % makeFloatMatrix(0.11f)) * makeFloatMatrix(100)) + makeFloatMatrix(0.5))); - + ft += sin(f); - + // Lets try some matrix/matrix ft = f * ft; - + // Lets try some vector matrix - + { - FloatMatrix r = {mul(f[0], ft), mul(ft, f[1])}; + FloatMatrix r = { mul(f[0], ft), mul(ft, f[1]) }; ft += r; } - + // Back to the transcendentals - + ft += cos(f); ft += tan(f); - + ft += asin(f); ft += acos(f); ft += atan(f); - - ft += atan2(f, makeFloatMatrix(2)); + ft += atan2(f, makeFloatMatrix(2)); { FloatMatrix sf, cf; sincos(f, sf, cf); - + ft += sf; ft += cf; } - + ft += rcp(makeFloatMatrix(1.0) + f); ft += FloatMatrix(sign(f - makeFloatMatrix(0.5))); - + ft += saturate(f * makeFloatMatrix(4) - makeFloatMatrix(2.0)); - + ft += sqrt(f); ft += rsqrt(makeFloatMatrix(1.0f) + f); - + ft += exp2(f); ft += exp(f); - + ft += frac(f * makeFloatMatrix(3)); ft += ceil(f * makeFloatMatrix(5) - makeFloatMatrix(3)); - + ft += floor(f * makeFloatMatrix(10) - makeFloatMatrix(7)); ft += trunc(f * makeFloatMatrix(7)); - + ft += log(f + makeFloatMatrix(10.0)); ft += log2(f * makeFloatMatrix(3) + makeFloatMatrix(2)); @@ -114,12 +103,15 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) float scalarVs[] = { 1, 10, 100, 1000 }; ft += FloatMatrix(IntMatrix(log10(makeFloatMatrix(scalarVs[idx])) + makeFloatMatrix(0.5f))); } - + ft += abs(f * makeFloatMatrix(4) - makeFloatMatrix(2.0f)); - + ft += min(makeFloatMatrix(0.5), f); ft += max(f, makeFloatMatrix(0.75)); +} +void test2(inout FloatMatrix ft, inout FloatMatrix f) +{ ft += pow(makeFloatMatrix(0.5), f); ft += smoothstep(makeFloatMatrix(0.2), makeFloatMatrix(0.7), f); @@ -135,7 +127,22 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) UIntMatrix vu = asuint(f); ft += asfloat(vu); -#endif - +#endif +} + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int idx = int(dispatchThreadID.x); + + Float scalarF = idx * (1.0f / (4.0f)); + + FloatMatrix ft = {}; + + FloatMatrix f = { { scalarF + 0.01, scalarF + 0.02}, { scalarF + 0.011, scalarF + 0.022}}; + + test1(ft, f, idx); + test2(ft, f); + outputBuffer[idx] = calcTotal(ft); } \ No newline at end of file diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-reorder-thread.slang.1.expected b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-reorder-thread.slang.1.expected index 58f06cfec..6e3e5d5d8 100644 --- a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-reorder-thread.slang.1.expected +++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-reorder-thread.slang.1.expected @@ -17,13 +17,17 @@ layout(location = 0) rayPayloadEXT SomeValues_0 p_0; -layout(binding = 0) -uniform accelerationStructureEXT scene_0; - layout(location = 0) hitObjectAttributeNV SomeValues_0 t_0; +layout(location = 1) +rayPayloadEXT +SomeValues_0 p_1; + +layout(binding = 0) +uniform accelerationStructureEXT scene_0; + SomeValues_0 HitObject_GetAttributes_0(hitObjectNV this_0) { hitObjectGetAttributesNV((this_0), ((0))); @@ -50,15 +54,11 @@ uint calcValue_0(hitObjectNV hit_0) return r_0; } -layout(location = 1) -rayPayloadEXT -SomeValues_0 p_1; - void HitObject_Invoke_0(accelerationStructureEXT AccelerationStructure_0, hitObjectNV HitOrMiss_0, inout SomeValues_0 Payload_0) { - p_1 = Payload_0; - hitObjectExecuteShaderNV(HitOrMiss_0, (1)); - Payload_0 = p_1; + p_0 = Payload_0; + hitObjectExecuteShaderNV(HitOrMiss_0, (0)); + Payload_0 = p_0; return; } @@ -87,10 +87,10 @@ void main() ray_0.Direction_0 = vec3(0.0, 1.0, 0.0); ray_0.TMax_0 = 10000.0; RayDesc_0 _S7 = ray_0; - p_0.a_0 = idx_0; - p_0.b_0 = _S6; + p_1.a_0 = idx_0; + p_1.b_0 = _S6; hitObjectNV hitObj_0; - hitObjectTraceRayNV(hitObj_0, scene_0, 20U, 255U, 0U, 4U, 0U, _S7.Origin_0, _S7.TMin_0, _S7.Direction_0, _S7.TMax_0, (0)); + hitObjectTraceRayNV(hitObj_0, scene_0, 20U, 255U, 0U, 4U, 0U, _S7.Origin_0, _S7.TMin_0, _S7.Direction_0, _S7.TMax_0, (1)); uint r_1 = calcValue_0(hitObj_0); reorderThreadNV(hitObj_0); float _S8 = _S5 * 4.0; diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-motion-ray.slang.1.expected b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-motion-ray.slang.1.expected index e6d31a3c8..12025efe0 100644 --- a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-motion-ray.slang.1.expected +++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-motion-ray.slang.1.expected @@ -14,6 +14,10 @@ struct SomeValues_0 float b_0; }; +layout(location = 0) +hitObjectAttributeNV +SomeValues_0 t_0; + layout(location = 0) rayPayloadEXT SomeValues_0 p_0; @@ -21,10 +25,6 @@ SomeValues_0 p_0; layout(binding = 0) uniform accelerationStructureEXT scene_0; -layout(location = 0) -hitObjectAttributeNV -SomeValues_0 t_0; - SomeValues_0 HitObject_GetAttributes_0(hitObjectNV this_0) { hitObjectGetAttributesNV((this_0), ((0))); diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-ray.slang.1.expected b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-ray.slang.1.expected index 9b5a4d193..ac4d78234 100644 --- a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-ray.slang.1.expected +++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-ray.slang.1.expected @@ -13,6 +13,10 @@ struct SomeValues_0 float b_0; }; +layout(location = 0) +hitObjectAttributeNV +SomeValues_0 t_0; + layout(location = 0) rayPayloadEXT SomeValues_0 p_0; @@ -20,10 +24,6 @@ SomeValues_0 p_0; layout(binding = 0) uniform accelerationStructureEXT scene_0; -layout(location = 0) -hitObjectAttributeNV -SomeValues_0 t_0; - SomeValues_0 HitObject_GetAttributes_0(hitObjectNV this_0) { hitObjectGetAttributesNV((this_0), ((0))); 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 79c6232f3..724a0a241 100644 --- a/tests/nv-extensions/nv-ray-tracing-motion-blur.slang.glsl +++ b/tests/nv-extensions/nv-ray-tracing-motion-blur.slang.glsl @@ -1,26 +1,49 @@ -//TEST_IGNORE_FILE: - #version 460 #extension GL_EXT_ray_tracing : require #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_0; + vec4 color_1; }; + struct Uniforms_0 { Light_0 light_0; @@ -29,21 +52,13 @@ struct Uniforms_0 mat4x4 model_0; }; + layout(binding = 3) layout(std140) uniform _S1 { Uniforms_0 _data; } ubo_0; -struct ShadowRay_0 -{ - float hitDistance_0; -}; - -layout(location = 0) -rayPayloadEXT -ShadowRay_0 p_0; - struct RayDesc_0 { vec3 Origin_0; @@ -52,18 +67,22 @@ 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_0 = 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, (0)); - Payload_0 = p_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); @@ -71,28 +90,23 @@ float saturate_0(float x_0) return _S2; } -struct ReflectionRay_0 -{ - float color_1; -}; - -layout(location = 1) -rayPayloadEXT -ReflectionRay_0 p_1; 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_1 = 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, (1)); - Payload_1 = p_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)); @@ -102,6 +116,7 @@ void main() 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); @@ -114,6 +129,7 @@ void main() vec3 N_0 = _S8.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); @@ -125,22 +141,30 @@ void main() 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; + } - vec3 _S10 = ubo_0._data.light_0.color_0.xyz; + vec3 _S10 = ubo_0._data.light_0.color_1.xyz; float _S11 = dot(N_0, L_0); @@ -148,9 +172,10 @@ void main() vec3 color_2 = _S10 * _S12 * 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_1, 1.0)); + imageStore((outputImage_0), ivec2((uvec2(launchID_0))), vec4(color_2 + reflectionRay_0.color_0, 1.0)); return; } \ No newline at end of file diff --git a/tests/pipeline/rasterization/mesh/component-write.slang.glsl b/tests/pipeline/rasterization/mesh/component-write.slang.glsl index 5234fb62f..143947504 100644 --- a/tests/pipeline/rasterization/mesh/component-write.slang.glsl +++ b/tests/pipeline/rasterization/mesh/component-write.slang.glsl @@ -2,26 +2,30 @@ #extension GL_EXT_mesh_shader : require layout(row_major) uniform; layout(row_major) buffer; -const vec3 colors_0[3] = { vec3(1.00000000000000000000, 1.00000000000000000000, 0.00000000000000000000), vec3(0.00000000000000000000, 1.00000000000000000000, 1.00000000000000000000), vec3(1.00000000000000000000, 0.00000000000000000000, 1.00000000000000000000) }; -const vec2 positions_0[3] = { vec2(0.00000000000000000000, -0.50000000000000000000), vec2(0.50000000000000000000, 0.50000000000000000000), vec2(-0.50000000000000000000, 0.50000000000000000000) }; +const vec2 positions_0[3] = { vec2(0.0, -0.5), vec2(0.5, 0.5), vec2(-0.5, 0.5) }; +const vec3 colors_0[3] = { vec3(1.0, 1.0, 0.0), vec3(0.0, 1.0, 1.0), vec3(1.0, 0.0, 1.0) }; layout(location = 0) out vec3 _S1[3]; + out gl_MeshPerVertexEXT { vec4 gl_Position; } gl_MeshVerticesEXT[3]; +out uvec3 gl_PrimitiveTriangleIndicesEXT[1]; + layout(local_size_x = 3, local_size_y = 1, local_size_z = 1) in; layout(max_vertices = 3) out; layout(max_primitives = 1) out; layout(triangles) out; void main() { + SetMeshOutputsEXT(3U, 1U); if(gl_LocalInvocationIndex < 3U) { - gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position = vec4(positions_0[gl_LocalInvocationIndex], 0.00000000000000000000, 1.00000000000000000000); + gl_MeshVerticesEXT[gl_LocalInvocationIndex].gl_Position = vec4(positions_0[gl_LocalInvocationIndex], 0.0, 1.0); _S1[gl_LocalInvocationIndex] = colors_0[gl_LocalInvocationIndex]; } else @@ -34,6 +38,6 @@ void main() else { } + return; } - diff --git a/tests/pipeline/rasterization/mesh/hello.slang.glsl b/tests/pipeline/rasterization/mesh/hello.slang.glsl index 3a0848dcb..0b3d4acb3 100644 --- a/tests/pipeline/rasterization/mesh/hello.slang.glsl +++ b/tests/pipeline/rasterization/mesh/hello.slang.glsl @@ -2,12 +2,12 @@ #extension GL_EXT_mesh_shader : require layout(row_major) uniform; layout(row_major) buffer; -const vec3 colors_0[3] = { vec3(1.0, 1.0, 0.0), vec3(0.0, 1.0, 1.0), vec3(1.0, 0.0, 1.0) }; const vec2 positions_0[3] = { vec2(0.0, -0.5), vec2(0.5, 0.5), vec2(-0.5, 0.5) }; - +const vec3 colors_0[3] = { vec3(1.0, 1.0, 0.0), vec3(0.0, 1.0, 1.0), vec3(1.0, 0.0, 1.0) }; layout(location = 0) out vec3 _S1[3]; + out gl_MeshPerVertexEXT { vec4 gl_Position; @@ -21,6 +21,7 @@ layout(max_primitives = 1) out; layout(triangles) out; void main() { + SetMeshOutputsEXT(3U, 1U); if(gl_LocalInvocationIndex < 3U) { @@ -30,6 +31,7 @@ void main() else { } + if(gl_LocalInvocationIndex < 1U) { gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex] = uvec3(0U, 1U, 2U); @@ -37,6 +39,6 @@ void main() else { } + return; } - diff --git a/tests/pipeline/rasterization/mesh/hello.slang.hlsl b/tests/pipeline/rasterization/mesh/hello.slang.hlsl index a10dc6884..06871fedd 100644 --- a/tests/pipeline/rasterization/mesh/hello.slang.hlsl +++ b/tests/pipeline/rasterization/mesh/hello.slang.hlsl @@ -4,16 +4,15 @@ #endif #pragma warning(disable: 3557) -static const float3 colors_0[int(3)] = { float3(1.0, 1.0, 0.0), float3(0.0, 1.0, 1.0), float3(1.0, 0.0, 1.0) }; static const float2 positions_0[int(3)] = { float2(0.0, -0.5), float2(0.5, 0.5), float2(-0.5, 0.5) }; +static const float3 colors_0[int(3)] = { float3(1.0, 1.0, 0.0), float3(0.0, 1.0, 1.0), float3(1.0, 0.0, 1.0) }; struct Vertex_0 { float4 pos_0 : SV_Position; float3 color_0 : Color; }; -[shader("mesh")] -[numthreads(3, 1, 1)] +[shader("mesh")][numthreads(3, 1, 1)] [outputtopology("triangle")] void main(uint tig_0 : SV_GROUPINDEX, vertices vertices out Vertex_0 verts_0[int(3)], indices indices out uint3 triangles_0[int(1)]) { @@ -26,6 +25,7 @@ void main(uint tig_0 : SV_GROUPINDEX, vertices vertices out Vertex_0 verts_0[in else { } + if(tig_0 < 1U) { triangles_0[tig_0] = uint3(0U, 1U, 2U); @@ -33,6 +33,6 @@ void main(uint tig_0 : SV_GROUPINDEX, vertices vertices out Vertex_0 verts_0[in else { } + return; } - diff --git a/tests/pipeline/rasterization/mesh/primitive-output.slang.glsl b/tests/pipeline/rasterization/mesh/primitive-output.slang.glsl index 35efcf4af..cfe266bec 100644 --- a/tests/pipeline/rasterization/mesh/primitive-output.slang.glsl +++ b/tests/pipeline/rasterization/mesh/primitive-output.slang.glsl @@ -2,9 +2,10 @@ #extension GL_EXT_mesh_shader : require layout(row_major) uniform; layout(row_major) buffer; -const vec3 colors_0[3] = { vec3(1.0, 1.0, 0.0), vec3(0.0, 1.0, 1.0), vec3(1.0, 0.0, 1.0) }; const vec2 positions_0[3] = { vec2(0.0, -0.5), vec2(0.5, 0.5), vec2(-0.5, 0.5) }; +const vec3 colors_0[3] = { vec3(1.0, 1.0, 0.0), vec3(0.0, 1.0, 1.0), vec3(1.0, 0.0, 1.0) }; out uvec3 gl_PrimitiveTriangleIndicesEXT[1]; + layout(location = 0) out vec3 _S1[3]; @@ -28,6 +29,7 @@ layout(max_primitives = 1) out; layout(triangles) out; void main() { + SetMeshOutputsEXT(3U, 1U); if(gl_LocalInvocationIndex < 3U) { @@ -37,6 +39,7 @@ void main() else { } + if(gl_LocalInvocationIndex < 1U) { gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex] = uvec3(0U, 1U, 2U); @@ -47,6 +50,6 @@ void main() else { } + return; } - diff --git a/tests/vkray/raygen.slang.glsl b/tests/vkray/raygen.slang.glsl index f8b97973b..e34f1f6e0 100644 --- a/tests/vkray/raygen.slang.glsl +++ b/tests/vkray/raygen.slang.glsl @@ -1,8 +1,25 @@ -//TEST_IGNORE_FILE: #version 460 #extension GL_EXT_ray_tracing : 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; @@ -11,11 +28,10 @@ uniform sampler sampler_0; layout(binding = 1) uniform texture2D samplerNormal_0; - struct Light_0 { vec4 position_0; - vec4 color_0; + vec4 color_1; }; struct Uniforms_0 @@ -31,15 +47,6 @@ layout(std140) uniform _S1 { Uniforms_0 _data; } ubo_0; -struct ShadowRay_0 -{ - float hitDistance_0; -}; - -layout(location = 0) -rayPayloadEXT -ShadowRay_0 p_0; - struct RayDesc_0 { vec3 Origin_0; @@ -50,26 +57,17 @@ struct RayDesc_0 void TraceRay_0(accelerationStructureEXT AccelerationStructure_0, uint RayFlags_0, uint InstanceInclusionMask_0, uint RayContributionToHitGroupIndex_0, uint MultiplierForGeometryContributionToHitGroupIndex_0, uint MissShaderIndex_0, RayDesc_0 Ray_0, inout ShadowRay_0 Payload_0) { - p_0 = Payload_0; - traceRayEXT(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, (0)); - Payload_0 = p_0; + p_1 = Payload_0; + traceRayEXT(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, (1)); + Payload_0 = p_1; return; } -struct ReflectionRay_0 -{ - float color_1; -}; - -layout(location = 1) -rayPayloadEXT -ReflectionRay_0 p_1; - void TraceRay_1(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_1 = 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, (1)); - Payload_1 = p_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; } @@ -78,7 +76,7 @@ uniform accelerationStructureEXT as_0; float saturate_0(float x_0) { - float _S2 = clamp(x_0, float(0), float(1)); + float _S2 = clamp(x_0, 0.0, 1.0); return _S2; } @@ -88,48 +86,51 @@ uniform image2D outputImage_0; void main() { - float atten_0; uvec3 _S3 = ((gl_LaunchIDEXT)); - float _S4 = float(_S3.x) + 0.50000000000000000000; + float _S4 = float(_S3.x) + 0.5; uvec3 _S5 = ((gl_LaunchSizeEXT)); float _S6 = _S4 / float(_S5.x); uvec3 _S7 = ((gl_LaunchIDEXT)); - float _S8 = float(_S7.y) + 0.50000000000000000000; + float _S8 = float(_S7.y) + 0.5; uvec3 _S9 = ((gl_LaunchSizeEXT)); float _S10 = _S8 / float(_S9.y); vec2 inUV_0 = vec2(_S6, _S10); vec4 _S11 = (texture(sampler2D(samplerPosition_0,sampler_0), (inUV_0))); vec3 P_0 = _S11.xyz; vec4 _S12 = (texture(sampler2D(samplerNormal_0,sampler_0), (inUV_0))); - vec3 N_0 = _S12.xyz * 2.00000000000000000000 - 1.00000000000000000000; + vec3 N_0 = _S12.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 _S13 = 1.00000000000000000000 / (lightDist_0 * lightDist_0); + float _S13 = 1.0 / (lightDist_0 * lightDist_0); RayDesc_0 ray_0; ray_0.Origin_0 = P_0; - ray_0.TMin_0 = 0.00000100000000000000; + 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 = float(0); - TraceRay_0(as_0, uint(1), uint(255), uint(0), uint(0), uint(2), ray_0, shadowRay_0); + shadowRay_0.hitDistance_0 = 0.0; + TraceRay_0(as_0, 1U, 255U, 0U, 0U, 2U, ray_0, shadowRay_0); + float atten_0; if(shadowRay_0.hitDistance_0 < lightDist_0) { - atten_0 = 0.00000000000000000000; + atten_0 = 0.0; } else { atten_0 = _S13; } - vec3 _S14 = ubo_0._data.light_0.color_0.xyz; + vec3 _S14 = ubo_0._data.light_0.color_1.xyz; float _S15 = dot(N_0, L_0); float _S16 = saturate_0(_S15); vec3 color_2 = _S14 * _S16 * atten_0; + ReflectionRay_0 reflectionRay_0; - TraceRay_1(as_0, uint(1), uint(255), uint(0), uint(0), uint(2), ray_0, reflectionRay_0); - vec3 color_3 = color_2 + reflectionRay_0.color_1; + TraceRay_1(as_0, 1U, 255U, 0U, 0U, 2U, ray_0, reflectionRay_0); + vec3 color_3 = color_2 + reflectionRay_0.color_0; uvec3 _S17 = ((gl_LaunchIDEXT)); - imageStore((outputImage_0), ivec2((uvec2(ivec2(_S17.xy)))), vec4(color_3, 1.00000000000000000000)); + imageStore((outputImage_0), ivec2((uvec2(ivec2(_S17.xy)))), vec4(color_3, 1.0)); return; } -- cgit v1.2.3