From b21a673a8da0da14bf598d7252dcc0fe2efc75c6 Mon Sep 17 00:00:00 2001 From: Robin Kertels Date: Mon, 14 Sep 2020 22:19:03 +0200 Subject: [PATCH] [d3d11] Don't use clamped constant buffer range for bounds checking --- src/d3d11/d3d11_context.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index b7f0aef4a..379e578dd 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -3652,7 +3652,8 @@ namespace dxvk { UINT constantBound; if (likely(newBuffer != nullptr)) { - constantBound = std::min(newBuffer->Desc()->ByteWidth / 16, UINT(D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT)); + UINT bufferConstantsCount = newBuffer->Desc()->ByteWidth / 16; + constantBound = std::min(bufferConstantsCount, UINT(D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT)); if (likely(pFirstConstant && pNumConstants)) { constantOffset = pFirstConstant[i]; @@ -3661,8 +3662,8 @@ namespace dxvk { if (unlikely(constantCount > D3D11_REQ_CONSTANT_BUFFER_ELEMENT_COUNT)) continue; - constantBound = (constantOffset + constantCount > constantBound) - ? constantBound - std::min(constantOffset, constantBound) + constantBound = (constantOffset + constantCount > bufferConstantsCount) + ? bufferConstantsCount - std::min(constantOffset, bufferConstantsCount) : constantCount; } else { constantOffset = 0;