From 6b2ae1183030c914b718a170c432bfd1cd9e263e Mon Sep 17 00:00:00 2001 From: Try Date: Mon, 3 Jul 2023 21:45:34 +0200 Subject: [PATCH] update rq unit tests --- ...ray-query.spv14.vk.ios.msl24..invalid.comp | 30 +++++++++++++++++-- ...ery-object-in-function.spv14.vk.msl24.frag | 28 ++++++++++++++++- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/reference/opt/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp b/reference/opt/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp index dde7f47b..6e777935 100644 --- a/reference/opt/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp +++ b/reference/opt/shaders-msl/comp/ray-query.spv14.vk.ios.msl24..invalid.comp @@ -1,3 +1,5 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include #if __METAL_VERSION__ >= 230 @@ -7,6 +9,30 @@ using namespace metal::raytracing; using namespace metal; +intersection_params spvMakeIntersectionParams(uint flags) +{ + intersection_params ip; + if ((flags & 1) != 0) + ip.force_opacity(forced_opacity::opaque); + if ((flags & 2) != 0) + ip.force_opacity(forced_opacity::non_opaque); + if ((flags & 4) != 0) + ip.accept_any_intersection(true); + if ((flags & 16) != 0) + ip.set_triangle_cull_mode(triangle_cull_mode::back); + if ((flags & 32) != 0) + ip.set_triangle_cull_mode(triangle_cull_mode::front); + if ((flags & 64) != 0) + ip.set_opacity_cull_mode(opacity_cull_mode::opaque); + if ((flags & 128) != 0) + ip.set_opacity_cull_mode(opacity_cull_mode::non_opaque); + if ((flags & 256) != 0) + ip.set_geometry_cull_mode(geometry_cull_mode::triangle); + if ((flags & 512) != 0) + ip.set_geometry_cull_mode(geometry_cull_mode::bounding_box); + return ip; +} + struct Params { uint ray_flags; @@ -22,9 +48,9 @@ struct Params kernel void main0(constant Params& _18 [[buffer(1)]], raytracing::acceleration_structure AS0 [[buffer(0)]], raytracing::acceleration_structure AS1 [[buffer(2)]]) { raytracing::intersection_query q; - q.reset(ray(_18.origin, _18.dir, _18.tmin, _18.tmax), AS0, intersection_params()); + q.reset(ray(_18.origin, _18.dir, _18.tmin, _18.tmax), AS0, spvMakeIntersectionParams(_18.ray_flags)); raytracing::intersection_query q2[2]; - q2[1].reset(ray(_18.origin, _18.dir, _18.tmin, _18.tmax), AS1, intersection_params()); + q2[1].reset(ray(_18.origin, _18.dir, _18.tmin, _18.tmax), AS1, spvMakeIntersectionParams(_18.ray_flags)); bool _63 = q.next(); bool res = _63; q2[0].abort(); diff --git a/reference/opt/shaders-msl/frag/ray-query-object-in-function.spv14.vk.msl24.frag b/reference/opt/shaders-msl/frag/ray-query-object-in-function.spv14.vk.msl24.frag index 859ace2c..9e23ab04 100644 --- a/reference/opt/shaders-msl/frag/ray-query-object-in-function.spv14.vk.msl24.frag +++ b/reference/opt/shaders-msl/frag/ray-query-object-in-function.spv14.vk.msl24.frag @@ -1,3 +1,5 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + #include #include #if __METAL_VERSION__ >= 230 @@ -7,6 +9,30 @@ using namespace metal::raytracing; using namespace metal; +intersection_params spvMakeIntersectionParams(uint flags) +{ + intersection_params ip; + if ((flags & 1) != 0) + ip.force_opacity(forced_opacity::opaque); + if ((flags & 2) != 0) + ip.force_opacity(forced_opacity::non_opaque); + if ((flags & 4) != 0) + ip.accept_any_intersection(true); + if ((flags & 16) != 0) + ip.set_triangle_cull_mode(triangle_cull_mode::back); + if ((flags & 32) != 0) + ip.set_triangle_cull_mode(triangle_cull_mode::front); + if ((flags & 64) != 0) + ip.set_opacity_cull_mode(opacity_cull_mode::opaque); + if ((flags & 128) != 0) + ip.set_opacity_cull_mode(opacity_cull_mode::non_opaque); + if ((flags & 256) != 0) + ip.set_geometry_cull_mode(geometry_cull_mode::triangle); + if ((flags & 512) != 0) + ip.set_geometry_cull_mode(geometry_cull_mode::bounding_box); + return ip; +} + struct main0_out { float4 outColor [[color(0)]]; @@ -21,7 +47,7 @@ fragment main0_out main0(main0_in in [[stage_in]], raytracing::acceleration_stru { main0_out out = {}; raytracing::intersection_query rayQuery; - rayQuery.reset(ray(float3((in.inPos.xy * 4.0) - float2(2.0), 1.0), float3(0.0, 0.0, -1.0), 0.001000000047497451305389404296875, 2.0), topLevelAS, intersection_params()); + rayQuery.reset(ray(float3((in.inPos.xy * 4.0) - float2(2.0), 1.0), float3(0.0, 0.0, -1.0), 0.001000000047497451305389404296875, 2.0), topLevelAS, spvMakeIntersectionParams(4u)); for (;;) { bool _88 = rayQuery.next();