-
Notifications
You must be signed in to change notification settings - Fork 567
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MSL: fix mutability for rayQueryEXT parameters
- Loading branch information
Showing
3 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
reference/shaders-msl-no-opt/frag/ray-query-mutability.spv14.vk.msl24.frag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#pragma clang diagnostic ignored "-Wmissing-prototypes" | ||
|
||
#include <metal_stdlib> | ||
#include <simd/simd.h> | ||
#if __METAL_VERSION__ >= 230 | ||
#include <metal_raytracing> | ||
using namespace metal::raytracing; | ||
#endif | ||
|
||
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; | ||
} | ||
|
||
static inline __attribute__((always_inline)) | ||
void initFn(thread raytracing::intersection_query<raytracing::instancing, raytracing::triangle_data>& rayQuery, const raytracing::acceleration_structure<raytracing::instancing> topLevelAS) | ||
{ | ||
float3 rayOrigin = float3(0.0, 0.0, 1.0); | ||
float3 rayDirection = float3(0.0, 0.0, -1.0); | ||
float rayDistance = 2.0; | ||
rayQuery.reset(ray(rayOrigin, rayDirection, 0.001000000047497451305389404296875, rayDistance), topLevelAS, spvMakeIntersectionParams(4u)); | ||
} | ||
|
||
static inline __attribute__((always_inline)) | ||
uint proceeFn(thread raytracing::intersection_query<raytracing::instancing, raytracing::triangle_data>& rayQuery) | ||
{ | ||
for (;;) | ||
{ | ||
bool _46 = rayQuery.next(); | ||
if (_46) | ||
{ | ||
continue; | ||
} | ||
else | ||
{ | ||
break; | ||
} | ||
} | ||
uint _50 = uint(rayQuery.get_committed_intersection_type()); | ||
return _50; | ||
} | ||
|
||
fragment void main0(, raytracing::acceleration_structure<raytracing::instancing> topLevelAS [[buffer(0)]]) | ||
{ | ||
raytracing::intersection_query<raytracing::instancing, raytracing::triangle_data> rayQuery; | ||
initFn(rayQuery, topLevelAS); | ||
uint _55 = proceeFn(rayQuery); | ||
} | ||
|
26 changes: 26 additions & 0 deletions
26
shaders-msl-no-opt/frag/ray-query-mutability.spv14.vk.msl24.frag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#version 460 | ||
|
||
#extension GL_ARB_separate_shader_objects : enable | ||
#extension GL_EXT_ray_query : enable | ||
|
||
layout(binding = 0) uniform accelerationStructureEXT topLevelAS; | ||
|
||
void initFn(rayQueryEXT rayQuery) { | ||
vec3 rayOrigin = vec3(0, 0, 1); | ||
vec3 rayDirection = vec3(0, 0,-1); | ||
float rayDistance = 2.0; | ||
rayQueryInitializeEXT(rayQuery, topLevelAS, gl_RayFlagsTerminateOnFirstHitEXT, 0xFF, rayOrigin, 0.001, rayDirection, rayDistance); | ||
} | ||
|
||
uint proceeFn(rayQueryEXT rayQuery) { | ||
while(rayQueryProceedEXT(rayQuery)) | ||
; | ||
return rayQueryGetIntersectionTypeEXT(rayQuery, true); | ||
} | ||
|
||
void main() { | ||
rayQueryEXT rayQuery; | ||
|
||
initFn(rayQuery); | ||
proceeFn(rayQuery); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters