mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-23 19:54:16 +01:00
[d3d9] Fix x64 crash on SetVertexShaderConstantF index overflow
This commit is contained in:
parent
4a89b75bb7
commit
92523fc0dd
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <climits>
|
|
||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
|
||||||
@ -83,7 +82,7 @@ namespace dxvk {
|
|||||||
D3DPRIMITIVETYPE PrimitiveType = D3DPT_INVALID;
|
D3DPRIMITIVETYPE PrimitiveType = D3DPT_INVALID;
|
||||||
std::vector<uint16_t> Indices;
|
std::vector<uint16_t> Indices;
|
||||||
UINT Offset = 0;
|
UINT Offset = 0;
|
||||||
UINT MinVertex = UINT_MAX;
|
UINT MinVertex = std::numeric_limits<uint32_t>::max();
|
||||||
UINT MaxVertex = 0;
|
UINT MaxVertex = 0;
|
||||||
UINT PrimitiveCount = 0;
|
UINT PrimitiveCount = 0;
|
||||||
UINT DrawCallCount = 0;
|
UINT DrawCallCount = 0;
|
||||||
@ -126,7 +125,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
draw.PrimitiveType = D3DPRIMITIVETYPE(0);
|
draw.PrimitiveType = D3DPRIMITIVETYPE(0);
|
||||||
draw.Offset = 0;
|
draw.Offset = 0;
|
||||||
draw.MinVertex = UINT_MAX;
|
draw.MinVertex = std::numeric_limits<uint32_t>::max();
|
||||||
draw.MaxVertex = 0;
|
draw.MaxVertex = 0;
|
||||||
draw.PrimitiveCount = 0;
|
draw.PrimitiveCount = 0;
|
||||||
draw.DrawCallCount = 0;
|
draw.DrawCallCount = 0;
|
||||||
|
@ -1481,7 +1481,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
return GetD3D9()->DrawIndexedPrimitive(
|
return GetD3D9()->DrawIndexedPrimitive(
|
||||||
d3d9::D3DPRIMITIVETYPE(PrimitiveType),
|
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,
|
MinVertexIndex,
|
||||||
NumVertices,
|
NumVertices,
|
||||||
StartIndex,
|
StartIndex,
|
||||||
@ -1621,7 +1621,7 @@ namespace dxvk {
|
|||||||
if (unlikely(ShouldRecord()))
|
if (unlikely(ShouldRecord()))
|
||||||
return m_recorder->SetIndices(pIndexData, BaseVertexIndex);
|
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");
|
Logger::warn("D3D8Device::SetIndices: BaseVertexIndex exceeds INT_MAX");
|
||||||
|
|
||||||
// used by DrawIndexedPrimitive
|
// used by DrawIndexedPrimitive
|
||||||
|
@ -7693,6 +7693,10 @@ namespace dxvk {
|
|||||||
const uint32_t regCountHardware = DetermineHardwareRegCount<ProgramType, ConstantType>();
|
const uint32_t regCountHardware = DetermineHardwareRegCount<ProgramType, ConstantType>();
|
||||||
constexpr uint32_t regCountSoftware = DetermineSoftwareRegCount<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))
|
if (unlikely(StartRegister + Count > regCountSoftware))
|
||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user