From 44f46b6ae903fbd127f373fbb491f284c61672a5 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 15 Apr 2020 15:12:41 +0100 Subject: [PATCH] Clamp buffer offset for mesh view input * If the calculated offset is larger than the buffer size we should be sure to clamp it. --- qrenderdoc/Windows/BufferViewer.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/qrenderdoc/Windows/BufferViewer.cpp b/qrenderdoc/Windows/BufferViewer.cpp index b66eb39fe..1f6a954fc 100644 --- a/qrenderdoc/Windows/BufferViewer.cpp +++ b/qrenderdoc/Windows/BufferViewer.cpp @@ -1528,7 +1528,13 @@ static void ConfigureMeshColumns(ICaptureContext &ctx, PopulateBufferData *bufda BufferDescription *buf = ctx.GetBuffer(ib.resourceId); if(buf) - bytesAvailable = buf->length - ib.byteOffset - draw->indexOffset * draw->indexByteWidth; + { + uint64_t offset = ib.byteOffset - draw->indexOffset * draw->indexByteWidth; + if(offset > buf->length) + bytesAvailable = 0; + else + bytesAvailable = buf->length - offset; + } // drawing more than this many indices will read off the end of the index buffer - which while // technically not invalid is certainly not intended, so serves as a good 'upper bound'