Skip to content

Commit 0ebdda6

Browse files
author
devsh
committed
proper default initializer for triangle BLAS geometry transforms
1 parent 4b03383 commit 0ebdda6

File tree

1 file changed

+34
-25
lines changed

1 file changed

+34
-25
lines changed

include/nbl/asset/IAccelerationStructure.h

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -92,31 +92,40 @@ class IBottomLevelAccelerationStructure : public IAccelerationStructure
9292
template<typename BufferType> requires std::is_base_of_v<IBuffer,BufferType>
9393
struct Triangles
9494
{
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
95+
public:
96+
using buffer_t = std::remove_const_t<BufferType>;
97+
constexpr static inline bool Host = std::is_same_v<buffer_t,ICPUBuffer>;
98+
// we make our life easier by not taking pointers to single matrix values
99+
using transform_t = std::conditional_t<Host,hlsl::float32_t3x4,asset::SBufferBinding<const buffer_t>>;
100+
101+
inline bool hasTransform() const
102+
{
103+
if constexpr (Host)
104+
return !core::isnan(transform[0][0]);
105+
else
106+
return bool(transform.buffer);
107+
}
108+
109+
// optional, only useful for baking model transforms of multiple meshes into one BLAS
110+
transform_t transform = __transform_initializer();
111+
// vertexData[1] are the vertex positions at time 1.0, and only used for AccelerationStructures created with `MOTION_BIT`
112+
asset::SBufferBinding<const buffer_t> vertexData[2] = {{},{}};
113+
asset::SBufferBinding<const buffer_t> indexData = {};
114+
uint32_t maxVertex = 0u;
115+
// type implicitly satisfies: https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819
116+
uint32_t vertexStride = sizeof(float);
117+
E_FORMAT vertexFormat = EF_R32G32B32_SFLOAT;
118+
E_INDEX_TYPE indexType = EIT_UNKNOWN;
119+
core::bitflag<GEOMETRY_FLAGS> geometryFlags = GEOMETRY_FLAGS::NONE;
120+
// TODO: opacity and displacement micromap buffers and shizz
121+
122+
private:
123+
constexpr static transform_t __transform_initializer()
124+
{
125+
if constexpr (Host)
126+
return hlsl::float32_t3x4(std::numeric_limits<float>::quiet_NaN());
127+
return {};
128+
}
120129
};
121130

122131
//

0 commit comments

Comments
 (0)