File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -139,10 +139,12 @@ class IBottomLevelAccelerationStructure : public AccelerationStructure
139
139
// forward declare for `static_assert`
140
140
class ICPUBottomLevelAccelerationStructure ;
141
141
142
+ // TODO: maybe we should introduce a base class so that flags and Instance declarations aren't doubled up
142
143
template <class AccelerationStructure >
143
144
class ITopLevelAccelerationStructure : public AccelerationStructure
144
145
{
145
146
static_assert (std::is_base_of_v<IAccelerationStructure,AccelerationStructure>);
147
+
146
148
public:
147
149
inline bool isBLAS () const override {return false ;}
148
150
@@ -246,6 +248,22 @@ class ITopLevelAccelerationStructure : public AccelerationStructure
246
248
SRT_MOTION
247
249
};
248
250
251
+ static uint16_t getInstanceSize (const INSTANCE_TYPE type)
252
+ {
253
+ switch (type)
254
+ {
255
+ case INSTANCE_TYPE::SRT_MOTION:
256
+ return sizeof (SRTMotionInstance<ptrdiff_t >);
257
+ break ;
258
+ case INSTANCE_TYPE::MATRIX_MOTION:
259
+ return sizeof (MatrixMotionInstance<ptrdiff_t >);
260
+ break ;
261
+ default :
262
+ break ;
263
+ }
264
+ return sizeof (StaticInstance<ptrdiff_t >);
265
+ }
266
+
249
267
protected:
250
268
using AccelerationStructure::AccelerationStructure;
251
269
virtual ~ITopLevelAccelerationStructure () = default ;
Original file line number Diff line number Diff line change @@ -483,6 +483,41 @@ class IGPUTopLevelAccelerationStructure : public asset::ITopLevelAccelerationStr
483
483
using DeviceBuildInfo = BuildInfo<IGPUBuffer>;
484
484
using HostBuildInfo = BuildInfo<asset::ICPUBuffer>;
485
485
486
+ static inline auto encodeTypeInRef (const INSTANCE_TYPE type, IGPUBottomLevelAccelerationStructure::device_op_ref_t ref)
487
+ {
488
+ // aligned to 16 bytes as per the spec
489
+ assert (ref.deviceAddress %16 ==0 );
490
+ switch (type)
491
+ {
492
+ case INSTANCE_TYPE::SRT_MOTION:
493
+ ref.deviceAddress += 2 ;
494
+ break ;
495
+ case INSTANCE_TYPE::MATRIX_MOTION:
496
+ ref.deviceAddress += 1 ;
497
+ break ;
498
+ default :
499
+ break ;
500
+ }
501
+ return ref;
502
+ }
503
+ static inline auto encodeTypeInRef (const INSTANCE_TYPE type, IGPUBottomLevelAccelerationStructure::host_op_ref_t ref)
504
+ {
505
+ // aligned to 16 bytes as per the spec
506
+ assert (ref.apiHandle %16 ==0 );
507
+ switch (type)
508
+ {
509
+ case INSTANCE_TYPE::SRT_MOTION:
510
+ ref.apiHandle += 2 ;
511
+ break ;
512
+ case INSTANCE_TYPE::MATRIX_MOTION:
513
+ ref.apiHandle += 1 ;
514
+ break ;
515
+ default :
516
+ break ;
517
+ }
518
+ return ref;
519
+ }
520
+
486
521
// ! BEWARE, OUR RESOURCE LIFETIME TRACKING DOES NOT WORK ACROSS TLAS->BLAS boundaries with these types of BLAS references!
487
522
using DeviceInstance = Instance<IGPUBottomLevelAccelerationStructure::device_op_ref_t >;
488
523
using HostInstance = Instance<IGPUBottomLevelAccelerationStructure::host_op_ref_t >;
You can’t perform that action at this time.
0 commit comments