MSL: Never used templated array for RayQuery objects.

Not supported and compiler derps out.
This commit is contained in:
Hans-Kristian Arntzen 2021-10-21 22:02:01 +02:00
parent bc338710e1
commit 2b5e17eca5
3 changed files with 4 additions and 86 deletions

View File

@ -1,6 +1,3 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#pragma clang diagnostic ignored "-Wmissing-braces"
#include <metal_stdlib>
#include <simd/simd.h>
#if __METAL_VERSION__ >= 230
@ -10,44 +7,6 @@ using namespace metal::raytracing;
using namespace metal;
template<typename T, size_t Num>
struct spvUnsafeArray
{
T elements[Num ? Num : 1];
thread T& operator [] (size_t pos) thread
{
return elements[pos];
}
constexpr const thread T& operator [] (size_t pos) const thread
{
return elements[pos];
}
device T& operator [] (size_t pos) device
{
return elements[pos];
}
constexpr const device T& operator [] (size_t pos) const device
{
return elements[pos];
}
constexpr const constant T& operator [] (size_t pos) const constant
{
return elements[pos];
}
threadgroup T& operator [] (size_t pos) threadgroup
{
return elements[pos];
}
constexpr const threadgroup T& operator [] (size_t pos) const threadgroup
{
return elements[pos];
}
};
struct Params
{
uint ray_flags;
@ -64,7 +23,7 @@ kernel void main0(constant Params& _18 [[buffer(1)]], acceleration_structure<ins
{
intersection_query<instancing, triangle_data> q;
q.reset(ray(_18.origin, _18.dir, _18.tmin, _18.tmax), AS0, intersection_params());
spvUnsafeArray<intersection_query<instancing, triangle_data>, 2> q2;
intersection_query<instancing, triangle_data> q2[2];
q2[1].reset(ray(_18.origin, _18.dir, _18.tmin, _18.tmax), AS1, intersection_params());
bool _63 = q.next();
q2[0].abort();

View File

@ -1,6 +1,3 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#pragma clang diagnostic ignored "-Wmissing-braces"
#include <metal_stdlib>
#include <simd/simd.h>
#if __METAL_VERSION__ >= 230
@ -10,44 +7,6 @@ using namespace metal::raytracing;
using namespace metal;
template<typename T, size_t Num>
struct spvUnsafeArray
{
T elements[Num ? Num : 1];
thread T& operator [] (size_t pos) thread
{
return elements[pos];
}
constexpr const thread T& operator [] (size_t pos) const thread
{
return elements[pos];
}
device T& operator [] (size_t pos) device
{
return elements[pos];
}
constexpr const device T& operator [] (size_t pos) const device
{
return elements[pos];
}
constexpr const constant T& operator [] (size_t pos) const constant
{
return elements[pos];
}
threadgroup T& operator [] (size_t pos) threadgroup
{
return elements[pos];
}
constexpr const threadgroup T& operator [] (size_t pos) const threadgroup
{
return elements[pos];
}
};
struct Params
{
uint ray_flags;
@ -64,7 +23,7 @@ kernel void main0(constant Params& _18 [[buffer(1)]], acceleration_structure<ins
{
intersection_query<instancing, triangle_data> q;
q.reset(ray(_18.origin, _18.dir, _18.tmin, _18.tmax), AS0, intersection_params());
spvUnsafeArray<intersection_query<instancing, triangle_data>, 2> q2;
intersection_query<instancing, triangle_data> q2[2];
q2[1].reset(ray(_18.origin, _18.dir, _18.tmin, _18.tmax), AS1, intersection_params());
bool _63 = q.next();
bool res = _63;

View File

@ -13402,8 +13402,7 @@ string CompilerMSL::type_to_glsl(const SPIRType &type, uint32_t id)
SPIRV_CROSS_THROW("Acceleration Structure Type is supported in MSL 2.3 and above.");
break;
case SPIRType::RayQuery:
type_name = "intersection_query<instancing, triangle_data>";
break;
return "intersection_query<instancing, triangle_data>";
default:
return "unknown_type";
@ -13448,6 +13447,7 @@ string CompilerMSL::type_to_array_glsl(const SPIRType &type)
{
case SPIRType::AtomicCounter:
case SPIRType::ControlPointArray:
case SPIRType::RayQuery:
{
return CompilerGLSL::type_to_array_glsl(type);
}