@@ -88,42 +88,62 @@ class IBottomLevelAccelerationStructure : public IAccelerationStructure
88
88
NO_DUPLICATE_ANY_HIT_INVOCATION_BIT = 0x1u <<1u ,
89
89
};
90
90
91
+ enum class GeometryType : uint8_t
92
+ {
93
+ Triangles = 0 ,
94
+ AABBs = 1 ,
95
+ // Later: LSS and friends
96
+ Count = 2
97
+ };
98
+
91
99
// Note that in Vulkan strides are 64-bit value but restricted to be 32-bit in range
92
- template <typename BufferType> requires std::is_base_of_v<IBuffer,BufferType>
100
+ template <typename BufferType> requires (! std::is_const_v<BufferType> && std:: is_base_of_v<IBuffer,BufferType>)
93
101
struct Triangles
94
102
{
95
- using buffer_t = std::remove_const_t <BufferType>;
96
- constexpr static inline bool Host = std::is_same_v<buffer_t ,ICPUBuffer>;
97
- // we make our life easier by not taking pointers to single matrix values
98
- using transform_t = std::conditional_t <Host,hlsl::float32_t3x4,asset::SBufferBinding<const buffer_t >>;
99
-
100
- inline bool hasTransform () const
101
- {
102
- if constexpr (Host)
103
- return !core::isnan (transform[0 ][0 ]);
104
- else
105
- return bool (transform.buffer );
106
- }
107
-
108
- // optional, only useful for baking model transforms of multiple meshes into one BLAS
109
- transform_t transform = {};
110
- // vertexData[1] are the vertex positions at time 1.0, and only used for AccelerationStructures created with `MOTION_BIT`
111
- asset::SBufferBinding<const buffer_t > vertexData[2 ] = {{},{}};
112
- asset::SBufferBinding<const buffer_t > indexData = {};
113
- uint32_t maxVertex = 0u ;
114
- // type implicitly satisfies: https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819
115
- uint32_t vertexStride = sizeof (float );
116
- E_FORMAT vertexFormat = EF_R32G32B32_SFLOAT;
117
- E_INDEX_TYPE indexType = EIT_UNKNOWN;
118
- core::bitflag<GEOMETRY_FLAGS> geometryFlags = GEOMETRY_FLAGS::NONE;
119
- // TODO: opacity and displacement micromap buffers and shizz
103
+ public:
104
+ using buffer_t = BufferType;
105
+ constexpr static inline GeometryType Type = GeometryType::Triangles;
106
+
107
+ constexpr static inline bool HostTransform = std::is_same_v<buffer_t ,ICPUBuffer>;
108
+ // we make our life easier by not taking pointers to single matrix values
109
+ using transform_t = std::conditional_t <HostTransform,hlsl::float32_t3x4,asset::SBufferBinding<const buffer_t >>;
110
+
111
+ inline bool hasTransform () const
112
+ {
113
+ if constexpr (HostTransform)
114
+ return !core::isnan (transform[0 ][0 ]);
115
+ else
116
+ return bool (transform.buffer );
117
+ }
118
+
119
+ // optional, only useful for baking model transforms of multiple meshes into one BLAS
120
+ transform_t transform = __transform_initializer ();
121
+ // vertexData[1] are the vertex positions at time 1.0, and only used for AccelerationStructures created with `MOTION_BIT`
122
+ asset::SBufferBinding<const buffer_t > vertexData[2 ] = {{},{}};
123
+ asset::SBufferBinding<const buffer_t > indexData = {};
124
+ uint32_t maxVertex = 0u ;
125
+ // type implicitly satisfies: https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819
126
+ uint32_t vertexStride = sizeof (float );
127
+ E_FORMAT vertexFormat = EF_R32G32B32_SFLOAT;
128
+ E_INDEX_TYPE indexType = EIT_UNKNOWN;
129
+ core::bitflag<GEOMETRY_FLAGS> geometryFlags = GEOMETRY_FLAGS::NONE;
130
+ // TODO: opacity and displacement micromap buffers and shizz
131
+
132
+ private:
133
+ constexpr static transform_t __transform_initializer ()
134
+ {
135
+ if constexpr (HostTransform)
136
+ return hlsl::float32_t3x4 (std::numeric_limits<float >::quiet_NaN ());
137
+ return {};
138
+ }
120
139
};
121
140
122
141
//
123
- template <typename BufferType> requires std::is_base_of_v<IBuffer,BufferType>
142
+ template <typename BufferType> requires (! std::is_const_v<BufferType> && std:: is_base_of_v<IBuffer,BufferType>)
124
143
struct AABBs
125
144
{
126
- using buffer_t = std::remove_const_t <BufferType>;
145
+ using buffer_t = BufferType;
146
+ constexpr static inline GeometryType Type = GeometryType::AABBs;
127
147
128
148
// for `MOTION_BIT` you don't get a second buffer for AABBs at different times because linear interpolation of AABBs doesn't work
129
149
asset::SBufferBinding<const BufferType> data = {};
0 commit comments