Skip to content

Commit c2fde50

Browse files
Vulkan: fixed issues with max vertex in acceleration structures
1 parent 0749310 commit c2fde50

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

Graphics/GraphicsEngineVulkan/src/BottomLevelASVkImpl.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,16 @@ BottomLevelASVkImpl::BottomLevelASVkImpl(IReferenceCounters* pRefCounters,
6666
dst.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR;
6767
dst.pNext = nullptr;
6868
dst.geometryType = VK_GEOMETRY_TYPE_TRIANGLES_KHR;
69-
dst.flags = VkGeometryFlagsKHR(0);
70-
71-
tri.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR;
72-
tri.pNext = nullptr;
73-
tri.vertexFormat = TypeToVkFormat(src.VertexValueType, src.VertexComponentCount, src.VertexValueType < VT_FLOAT16);
74-
tri.maxVertex = src.MaxVertexCount;
75-
tri.indexType = TypeToVkIndexType(src.IndexType);
69+
dst.flags = 0;
70+
71+
tri.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR;
72+
tri.pNext = nullptr;
73+
tri.vertexFormat = TypeToVkFormat(src.VertexValueType, src.VertexComponentCount, src.VertexValueType < VT_FLOAT16);
74+
// maxVertex is the number of vertices in vertexData minus one.
75+
VERIFY(src.MaxVertexCount > 0, "MaxVertexCount must be greater than 0");
76+
tri.maxVertex = src.MaxVertexCount - 1;
77+
tri.indexType = TypeToVkIndexType(src.IndexType);
78+
// Non-null address indicates that non-null transform data will be provided to the build command.
7679
tri.transformData.deviceAddress = src.AllowsTransforms ? 1 : 0;
7780
MaxPrimitiveCounts[i] = src.MaxPrimitiveCount;
7881

Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3434,9 +3434,11 @@ void DeviceContextVkImpl::BuildBLAS(const BuildBLASAttribs& Attribs)
34343434
auto* const pVB = ClassPtrCast<BufferVkImpl>(SrcTris.pVertexBuffer);
34353435

34363436
// vertex format in SrcTris may be undefined, so use vertex format from description
3437-
vkTris.vertexFormat = TypeToVkFormat(TriDesc.VertexValueType, TriDesc.VertexComponentCount, TriDesc.VertexValueType < VT_FLOAT16);
3438-
vkTris.vertexStride = SrcTris.VertexStride;
3439-
vkTris.maxVertex = SrcTris.VertexCount;
3437+
vkTris.vertexFormat = TypeToVkFormat(TriDesc.VertexValueType, TriDesc.VertexComponentCount, TriDesc.VertexValueType < VT_FLOAT16);
3438+
vkTris.vertexStride = SrcTris.VertexStride;
3439+
// maxVertex is the number of vertices in vertexData minus one.
3440+
VERIFY(SrcTris.VertexCount > 0, "Vertex count must be greater than 0");
3441+
vkTris.maxVertex = SrcTris.VertexCount - 1;
34403442
vkTris.vertexData.deviceAddress = pVB->GetVkDeviceAddress() + SrcTris.VertexOffset;
34413443

34423444
// geometry.triangles.vertexData.deviceAddress must be aligned to the size in bytes of the smallest component of the format in vertexFormat

0 commit comments

Comments
 (0)