1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-23 10:54:14 +01:00

[d3d9] Fix x64 crash on SetVertexShaderConstantF index overflow

This commit is contained in:
WinterSnowfall 2025-02-15 13:43:40 +02:00 committed by Philip Rebohle
parent 4a89b75bb7
commit 92523fc0dd
3 changed files with 8 additions and 5 deletions

View File

@ -6,7 +6,6 @@
#include <vector>
#include <cstdint>
#include <climits>
namespace dxvk {
@ -83,7 +82,7 @@ namespace dxvk {
D3DPRIMITIVETYPE PrimitiveType = D3DPT_INVALID;
std::vector<uint16_t> Indices;
UINT Offset = 0;
UINT MinVertex = UINT_MAX;
UINT MinVertex = std::numeric_limits<uint32_t>::max();
UINT MaxVertex = 0;
UINT PrimitiveCount = 0;
UINT DrawCallCount = 0;
@ -126,7 +125,7 @@ namespace dxvk {
draw.PrimitiveType = D3DPRIMITIVETYPE(0);
draw.Offset = 0;
draw.MinVertex = UINT_MAX;
draw.MinVertex = std::numeric_limits<uint32_t>::max();
draw.MaxVertex = 0;
draw.PrimitiveCount = 0;
draw.DrawCallCount = 0;

View File

@ -1481,7 +1481,7 @@ namespace dxvk {
return GetD3D9()->DrawIndexedPrimitive(
d3d9::D3DPRIMITIVETYPE(PrimitiveType),
static_cast<INT>(std::min(m_baseVertexIndex, static_cast<UINT>(INT_MAX))), // set by SetIndices
static_cast<INT>(std::min(m_baseVertexIndex, static_cast<UINT>(std::numeric_limits<int32_t>::max()))), // set by SetIndices
MinVertexIndex,
NumVertices,
StartIndex,
@ -1621,7 +1621,7 @@ namespace dxvk {
if (unlikely(ShouldRecord()))
return m_recorder->SetIndices(pIndexData, BaseVertexIndex);
if (unlikely(BaseVertexIndex > INT_MAX))
if (unlikely(BaseVertexIndex > std::numeric_limits<int32_t>::max()))
Logger::warn("D3D8Device::SetIndices: BaseVertexIndex exceeds INT_MAX");
// used by DrawIndexedPrimitive

View File

@ -7693,6 +7693,10 @@ namespace dxvk {
const uint32_t regCountHardware = DetermineHardwareRegCount<ProgramType, ConstantType>();
constexpr uint32_t regCountSoftware = DetermineSoftwareRegCount<ProgramType, ConstantType>();
// Error out in case of StartRegister + Count overflow
if (unlikely(StartRegister > std::numeric_limits<uint32_t>::max() - Count))
return D3DERR_INVALIDCALL;
if (unlikely(StartRegister + Count > regCountSoftware))
return D3DERR_INVALIDCALL;