@@ -433,7 +433,7 @@ bool VerifyStateTransitionDesc(const IRenderDevice* pDevice,
433433}
434434
435435
436- bool VerifyBuildBLASAttribs (const BuildBLASAttribs& Attribs)
436+ bool VerifyBuildBLASAttribs (const IRenderDevice* pDevice, const BuildBLASAttribs& Attribs)
437437{
438438#define CHECK_BUILD_BLAS_ATTRIBS (Expr, ...) CHECK_PARAMETER(Expr, " Build BLAS attribs are invalid: " , __VA_ARGS__)
439439
@@ -443,7 +443,8 @@ bool VerifyBuildBLASAttribs(const BuildBLASAttribs& Attribs)
443443 CHECK_BUILD_BLAS_ATTRIBS (Attribs.pBoxData != nullptr || Attribs.BoxDataCount == 0 , " BoxDataCount is " , Attribs.BoxDataCount , " , but pBoxData is null." );
444444 CHECK_BUILD_BLAS_ATTRIBS (Attribs.pTriangleData != nullptr || Attribs.TriangleDataCount == 0 , " TriangleDataCount is " , Attribs.TriangleDataCount , " , but pTriangleData is null." );
445445
446- const auto & BLASDesc = Attribs.pBLAS ->GetDesc ();
446+ const auto & BLASDesc = Attribs.pBLAS ->GetDesc ();
447+ const auto DeviceType = pDevice->GetDeviceInfo ().Type ;
447448
448449 CHECK_BUILD_BLAS_ATTRIBS (Attribs.BoxDataCount <= BLASDesc.BoxCount , " BoxDataCount (" , Attribs.BoxDataCount , " ) must be less than or equal to pBLAS->GetDesc().BoxCount (" , BLASDesc.BoxCount , " )." );
449450 CHECK_BUILD_BLAS_ATTRIBS (Attribs.TriangleDataCount <= BLASDesc.TriangleCount , " TriangleDataCount (" , Attribs.TriangleDataCount , " ) must be less than or equal to pBLAS->GetDesc().TriangleCount (" , BLASDesc.TriangleCount , " )." );
@@ -491,6 +492,10 @@ bool VerifyBuildBLASAttribs(const BuildBLASAttribs& Attribs)
491492 CHECK_BUILD_BLAS_ATTRIBS ((VertBufDesc.BindFlags & BIND_RAY_TRACING) == BIND_RAY_TRACING,
492493 " pTriangleData[" , i, " ].pVertexBuffer was not created with BIND_RAY_TRACING flag." );
493494
495+ CHECK_BUILD_BLAS_ATTRIBS (tri.VertexOffset % tri.VertexStride == 0 ,
496+ " pTriangleData[" , i, " ].VertexOffset (" , tri.VertexOffset , " ) must be a multiple of VertexStride (" ,
497+ tri.VertexStride , " )." );
498+
494499 CHECK_BUILD_BLAS_ATTRIBS (tri.VertexOffset + VertexDataSize <= VertBufDesc.uiSizeInBytes ,
495500 " pTriangleData[" , i, " ].pVertexBuffer is too small for the specified VertexStride (" , tri.VertexStride , " ) and VertexCount (" ,
496501 tri.VertexCount , " ): at least " , tri.VertexOffset + VertexDataSize, " bytes are required." );
@@ -516,6 +521,17 @@ bool VerifyBuildBLASAttribs(const BuildBLASAttribs& Attribs)
516521 CHECK_BUILD_BLAS_ATTRIBS (tri.IndexOffset + IndexDataSize <= InstBufDesc.uiSizeInBytes ,
517522 " pTriangleData[" , i, " ].pIndexBuffer is too small for specified IndexType and IndexCount: at least" ,
518523 tri.IndexOffset + IndexDataSize, " bytes are required." );
524+
525+ CHECK_BUILD_BLAS_ATTRIBS (tri.IndexOffset % GetValueSize (TriDesc.IndexType ) == 0 ,
526+ " pTriangleData[" , i, " ].IndexOffset (" , tri.IndexOffset , " ) must be a multiple of (" , GetValueSize (TriDesc.IndexType ), " ) bytes." );
527+
528+ if (DeviceType == RENDER_DEVICE_TYPE_METAL)
529+ {
530+ const Uint32 MtlIndexOffsetAlignment = 32 ;
531+ CHECK_BUILD_BLAS_ATTRIBS (tri.IndexOffset % MtlIndexOffsetAlignment == 0 ,
532+ " pTriangleData[" , i, " ].IndexOffset (" , tri.IndexOffset ,
533+ " ) must be a multiple of the platform buffer offset alignment (" , MtlIndexOffsetAlignment, " )." );
534+ }
519535 }
520536 else
521537 {
0 commit comments