@@ -571,7 +571,7 @@ void CreateRTBuffers(RTContext& Ctx, Uint32 VBSize, Uint32 IBSize, Uint32 Instan
571571
572572 if (IBSize > 0 )
573573 {
574- BuffCI.size = VBSize ;
574+ BuffCI.size = IBSize ;
575575 res = vkCreateBuffer (Ctx.vkDevice , &BuffCI, nullptr , &Ctx.vkIndexBuffer );
576576 ASSERT_GE (res, VK_SUCCESS);
577577 ASSERT_TRUE (Ctx.vkIndexBuffer != VK_NULL_HANDLE);
@@ -788,15 +788,15 @@ void RayTracingTriangleClosestHitReferenceVk(ISwapChain* pSwapChain)
788788
789789 VkAccelerationStructureBuildGeometryInfoKHR ASBuildInfo = {};
790790 VkAccelerationStructureGeometryKHR Geometry = {};
791- VkAccelerationStructureBuildRangeInfoKHR Offset = {};
791+ VkAccelerationStructureBuildRangeInfoKHR Offset = {1 , 0 , 0 , 0 };
792792 VkAccelerationStructureBuildRangeInfoKHR const * OffsetPtr = &Offset;
793793
794794 Geometry.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR;
795795 Geometry.flags = VK_GEOMETRY_OPAQUE_BIT_KHR;
796796 Geometry.geometryType = VK_GEOMETRY_TYPE_TRIANGLES_KHR;
797797 Geometry.geometry .triangles .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR;
798798 Geometry.geometry .triangles .vertexFormat = VK_FORMAT_R32G32B32_SFLOAT;
799- Geometry.geometry .triangles .maxVertex = _countof (Vertices);
799+ Geometry.geometry .triangles .maxVertex = _countof (Vertices) - 1u ;
800800 Geometry.geometry .triangles .vertexStride = sizeof (Vertices[0 ]);
801801 Geometry.geometry .triangles .indexType = VK_INDEX_TYPE_NONE_KHR;
802802
@@ -808,7 +808,6 @@ void RayTracingTriangleClosestHitReferenceVk(ISwapChain* pSwapChain)
808808 AccelStructBarrier (Ctx);
809809
810810 Geometry.geometry .triangles .vertexData .deviceAddress = Ctx.vkVertexBufferAddress ;
811- Offset.primitiveCount = 1 ;
812811
813812 ASBuildInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR;
814813 ASBuildInfo.type = VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR;
@@ -839,8 +838,6 @@ void RayTracingTriangleClosestHitReferenceVk(ISwapChain* pSwapChain)
839838 Geometry.geometry .instances .arrayOfPointers = VK_FALSE;
840839 Geometry.geometry .instances .data .deviceAddress = Ctx.vkInstanceBufferAddress ;
841840
842- Offset.primitiveCount = 1 ;
843-
844841 ASBuildInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR;
845842 ASBuildInfo.type = VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR;
846843 ASBuildInfo.mode = VK_BUILD_ACCELERATION_STRUCTURE_MODE_BUILD_KHR;
@@ -947,7 +944,7 @@ void RayTracingTriangleAnyHitReferenceVk(ISwapChain* pSwapChain)
947944 const auto & Vertices = TestingConstants::TriangleAnyHit::Vertices;
948945
949946 VkAccelerationStructureBuildGeometryInfoKHR ASBuildInfo = {};
950- VkAccelerationStructureBuildRangeInfoKHR Offset = {};
947+ VkAccelerationStructureBuildRangeInfoKHR Offset = {3 , 0 , 0 , 0 };
951948 VkAccelerationStructureGeometryKHR Geometry = {};
952949 VkAccelerationStructureBuildRangeInfoKHR const * OffsetPtr = &Offset;
953950
@@ -957,7 +954,7 @@ void RayTracingTriangleAnyHitReferenceVk(ISwapChain* pSwapChain)
957954 Geometry.geometry .triangles .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR;
958955 Geometry.geometry .triangles .vertexFormat = VK_FORMAT_R32G32B32_SFLOAT;
959956 Geometry.geometry .triangles .vertexStride = sizeof (Vertices[0 ]);
960- Geometry.geometry .triangles .maxVertex = _countof (Vertices);
957+ Geometry.geometry .triangles .maxVertex = _countof (Vertices) - 1 ;
961958 Geometry.geometry .triangles .indexType = VK_INDEX_TYPE_NONE_KHR;
962959
963960 CreateBLAS (Ctx, &Geometry, OffsetPtr, 1 , Ctx.BLAS );
@@ -968,7 +965,6 @@ void RayTracingTriangleAnyHitReferenceVk(ISwapChain* pSwapChain)
968965 AccelStructBarrier (Ctx);
969966
970967 Geometry.geometry .triangles .vertexData .deviceAddress = Ctx.vkVertexBufferAddress ;
971- Offset.primitiveCount = 3 ;
972968
973969 ASBuildInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR;
974970 ASBuildInfo.type = VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR;
@@ -1107,7 +1103,7 @@ void RayTracingProceduralIntersectionReferenceVk(ISwapChain* pSwapChain)
11071103 const auto & Boxes = TestingConstants::ProceduralIntersection::Boxes;
11081104
11091105 VkAccelerationStructureBuildGeometryInfoKHR ASBuildInfo = {};
1110- VkAccelerationStructureBuildRangeInfoKHR Offset = {};
1106+ VkAccelerationStructureBuildRangeInfoKHR Offset = {1 , 0 , 0 , 0 };
11111107 VkAccelerationStructureGeometryKHR Geometry = {};
11121108 VkAccelerationStructureBuildRangeInfoKHR const * OffsetPtr = &Offset;
11131109
@@ -1126,7 +1122,6 @@ void RayTracingProceduralIntersectionReferenceVk(ISwapChain* pSwapChain)
11261122 AccelStructBarrier (Ctx);
11271123
11281124 Geometry.geometry .aabbs .data .deviceAddress = Ctx.vkVertexBufferAddress ;
1129- Offset.primitiveCount = 1 ;
11301125
11311126 ASBuildInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR;
11321127 ASBuildInfo.type = VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR;
@@ -1157,8 +1152,6 @@ void RayTracingProceduralIntersectionReferenceVk(ISwapChain* pSwapChain)
11571152 Geometry.geometry .instances .arrayOfPointers = VK_FALSE;
11581153 Geometry.geometry .instances .data .deviceAddress = Ctx.vkInstanceBufferAddress ;
11591154
1160- Offset.primitiveCount = 1 ;
1161-
11621155 ASBuildInfo.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR;
11631156 ASBuildInfo.type = VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR;
11641157 ASBuildInfo.mode = VK_BUILD_ACCELERATION_STRUCTURE_MODE_BUILD_KHR;
@@ -1291,7 +1284,7 @@ void RayTracingMultiGeometryReferenceVk(ISwapChain* pSwapChain)
12911284 Geometries[0 ].geometry .triangles .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR;
12921285 Geometries[0 ].geometry .triangles .vertexFormat = VK_FORMAT_R32G32B32_SFLOAT;
12931286 Geometries[0 ].geometry .triangles .vertexStride = sizeof (Vertices[0 ]);
1294- Geometries[0 ].geometry .triangles .maxVertex = PrimitiveOffsets[1 ] * 3 ;
1287+ Geometries[0 ].geometry .triangles .maxVertex = PrimitiveOffsets[1 ] * 3 - 1 ;
12951288 Geometries[0 ].geometry .triangles .indexType = VK_INDEX_TYPE_UINT32;
12961289
12971290 Geometries[1 ].sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR;
@@ -1300,7 +1293,7 @@ void RayTracingMultiGeometryReferenceVk(ISwapChain* pSwapChain)
13001293 Geometries[1 ].geometry .triangles .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR;
13011294 Geometries[1 ].geometry .triangles .vertexFormat = VK_FORMAT_R32G32B32_SFLOAT;
13021295 Geometries[1 ].geometry .triangles .vertexStride = sizeof (Vertices[0 ]);
1303- Geometries[1 ].geometry .triangles .maxVertex = (PrimitiveOffsets[2 ] - PrimitiveOffsets[1 ]) * 3 ;
1296+ Geometries[1 ].geometry .triangles .maxVertex = (PrimitiveOffsets[2 ] - PrimitiveOffsets[1 ]) * 3 - 1 ;
13041297 Geometries[1 ].geometry .triangles .indexType = VK_INDEX_TYPE_UINT32;
13051298
13061299 Geometries[2 ].sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR;
@@ -1309,9 +1302,13 @@ void RayTracingMultiGeometryReferenceVk(ISwapChain* pSwapChain)
13091302 Geometries[2 ].geometry .triangles .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR;
13101303 Geometries[2 ].geometry .triangles .vertexFormat = VK_FORMAT_R32G32B32_SFLOAT;
13111304 Geometries[2 ].geometry .triangles .vertexStride = sizeof (Vertices[0 ]);
1312- Geometries[2 ].geometry .triangles .maxVertex = (_countof (Primitives) - PrimitiveOffsets[2 ]) * 3 ;
1305+ Geometries[2 ].geometry .triangles .maxVertex = (_countof (Primitives) - PrimitiveOffsets[2 ]) * 3 - 1 ;
13131306 Geometries[2 ].geometry .triangles .indexType = VK_INDEX_TYPE_UINT32;
13141307
1308+ Offsets[0 ].primitiveCount = PrimitiveOffsets[1 ];
1309+ Offsets[1 ].primitiveCount = PrimitiveOffsets[2 ] - PrimitiveOffsets[1 ];
1310+ Offsets[2 ].primitiveCount = _countof (Primitives) - PrimitiveOffsets[2 ];
1311+
13151312 CreateBLAS (Ctx, Geometries, OffsetPtr, _countof (Geometries), Ctx.BLAS );
13161313 CreateTLAS (Ctx, InstanceCount, Ctx.TLAS );
13171314 CreateRTBuffers (Ctx, sizeof (Vertices), sizeof (Indices), InstanceCount, 1 , HitGroupCount, TestingConstants::MultiGeometry::ShaderRecordSize);
0 commit comments