[d3d8/9] Use numeric_limits globally

This commit is contained in:
WinterSnowfall 2025-02-19 21:39:10 +02:00 committed by Philip Rebohle
parent 317607e192
commit 3716d48c89
10 changed files with 21 additions and 21 deletions

View file

@ -9,7 +9,7 @@
namespace dxvk { namespace dxvk {
static inline uint32_t parseDword(std::string_view str) { static inline uint32_t parseDword(std::string_view str) {
uint32_t value = UINT32_MAX; uint32_t value = std::numeric_limits<uint32_t>::max();
std::from_chars(str.data(), str.data() + str.size(), value); std::from_chars(str.data(), str.data() + str.size(), value);
return value; return value;
} }

View file

@ -588,7 +588,7 @@ namespace dxvk {
// Max Vertex Shader Const // Max Vertex Shader Const
pCaps->MaxVertexShaderConst = MaxFloatConstantsVS; pCaps->MaxVertexShaderConst = MaxFloatConstantsVS;
// Max PS1 Value // Max PS1 Value
pCaps->PixelShader1xMaxValue = options.shaderModel > 0 ? FLT_MAX : 0.0f; pCaps->PixelShader1xMaxValue = options.shaderModel > 0 ? std::numeric_limits<float>::max() : 0.0f;
// Dev Caps 2 // Dev Caps 2
pCaps->DevCaps2 = D3DDEVCAPS2_STREAMOFFSET pCaps->DevCaps2 = D3DDEVCAPS2_STREAMOFFSET
/* | D3DDEVCAPS2_DMAPNPATCH */ /* | D3DDEVCAPS2_DMAPNPATCH */

View file

@ -75,7 +75,7 @@ namespace dxvk {
public: public:
static constexpr UINT AllLayers = UINT32_MAX; static constexpr UINT AllLayers = std::numeric_limits<uint32_t>::max();
D3D9CommonTexture( D3D9CommonTexture(
D3D9DeviceEx* pDevice, D3D9DeviceEx* pDevice,

View file

@ -1760,7 +1760,7 @@ namespace dxvk {
m_state.depthStencil = ds; m_state.depthStencil = ds;
UpdateActiveHazardsDS(UINT32_MAX); UpdateActiveHazardsDS(std::numeric_limits<uint32_t>::max());
return D3D_OK; return D3D_OK;
} }
@ -2157,7 +2157,7 @@ namespace dxvk {
if (m_state.IsLightEnabled(Index) == !!Enable) if (m_state.IsLightEnabled(Index) == !!Enable)
return D3D_OK; return D3D_OK;
uint32_t searchIndex = UINT32_MAX; uint32_t searchIndex = std::numeric_limits<uint32_t>::max();
uint32_t setIndex = Index; uint32_t setIndex = Index;
if (!Enable) if (!Enable)
@ -2384,7 +2384,7 @@ namespace dxvk {
case D3DRS_ZWRITEENABLE: case D3DRS_ZWRITEENABLE:
if (likely(!old != !Value)) if (likely(!old != !Value))
UpdateActiveHazardsDS(UINT32_MAX); UpdateActiveHazardsDS(std::numeric_limits<uint32_t>::max());
[[fallthrough]]; [[fallthrough]];
case D3DRS_STENCILENABLE: case D3DRS_STENCILENABLE:
case D3DRS_ZENABLE: case D3DRS_ZENABLE:
@ -3795,8 +3795,8 @@ namespace dxvk {
if (m_psShaderMasks.samplerMask != newShaderMasks.samplerMask || if (m_psShaderMasks.samplerMask != newShaderMasks.samplerMask ||
m_psShaderMasks.rtMask != newShaderMasks.rtMask) { m_psShaderMasks.rtMask != newShaderMasks.rtMask) {
m_psShaderMasks = newShaderMasks; m_psShaderMasks = newShaderMasks;
UpdateActiveHazardsRT(UINT32_MAX); UpdateActiveHazardsRT(std::numeric_limits<uint32_t>::max());
UpdateActiveHazardsDS(UINT32_MAX); UpdateActiveHazardsDS(std::numeric_limits<uint32_t>::max());
} }
return D3D_OK; return D3D_OK;
@ -7815,7 +7815,7 @@ namespace dxvk {
if (key.Data.Contents.UseLighting) { if (key.Data.Contents.UseLighting) {
for (uint32_t i = 0; i < caps::MaxEnabledLights; i++) { for (uint32_t i = 0; i < caps::MaxEnabledLights; i++) {
if (m_state.enabledLightIndices[i] != UINT32_MAX) if (m_state.enabledLightIndices[i] != std::numeric_limits<uint32_t>::max())
lightCount++; lightCount++;
} }
} }
@ -7912,7 +7912,7 @@ namespace dxvk {
uint32_t lightIdx = 0; uint32_t lightIdx = 0;
for (uint32_t i = 0; i < caps::MaxEnabledLights; i++) { for (uint32_t i = 0; i < caps::MaxEnabledLights; i++) {
auto idx = m_state.enabledLightIndices[i]; auto idx = m_state.enabledLightIndices[i];
if (idx == UINT32_MAX) if (idx == std::numeric_limits<uint32_t>::max())
continue; continue;
data->Lights[lightIdx++] = D3D9Light(m_state.lights[idx].value(), m_state.transforms[GetTransformIndex(D3DTS_VIEW)]); data->Lights[lightIdx++] = D3D9Light(m_state.lights[idx].value(), m_state.transforms[GetTransformIndex(D3DTS_VIEW)]);

View file

@ -1297,7 +1297,7 @@ namespace dxvk {
uint32_t atten = m_module.opFFma (m_floatType, d, atten2, atten1); uint32_t atten = m_module.opFFma (m_floatType, d, atten2, atten1);
atten = m_module.opFFma (m_floatType, d, atten, atten0); atten = m_module.opFFma (m_floatType, d, atten, atten0);
atten = m_module.opFDiv (m_floatType, m_module.constf32(1.0f), atten); atten = m_module.opFDiv (m_floatType, m_module.constf32(1.0f), atten);
atten = m_module.opNMin (m_floatType, atten, m_module.constf32(FLT_MAX)); atten = m_module.opNMin (m_floatType, atten, m_module.constf32(std::numeric_limits<float>::max()));
atten = m_module.opSelect(m_floatType, m_module.opFOrdGreaterThan(bool_t, d, range), m_module.constf32(0.0f), atten); atten = m_module.opSelect(m_floatType, m_module.opFOrdGreaterThan(bool_t, d, range), m_module.constf32(0.0f), atten);
atten = m_module.opSelect(m_floatType, isDirectional, m_module.constf32(1.0f), atten); atten = m_module.opSelect(m_floatType, isDirectional, m_module.constf32(1.0f), atten);

View file

@ -10,7 +10,7 @@ namespace dxvk {
streamFreq[i] = 1; streamFreq[i] = 1;
for (uint32_t i = 0; i < enabledLightIndices.size(); i++) for (uint32_t i = 0; i < enabledLightIndices.size(); i++)
enabledLightIndices[i] = UINT32_MAX; enabledLightIndices[i] = std::numeric_limits<uint32_t>::max();
} }

View file

@ -204,7 +204,7 @@ namespace dxvk {
if (m_state.IsLightEnabled(Index) == !!Enable) if (m_state.IsLightEnabled(Index) == !!Enable)
return D3D_OK; return D3D_OK;
uint32_t searchIndex = UINT32_MAX; uint32_t searchIndex = std::numeric_limits<uint32_t>::max();
uint32_t setIndex = Index; uint32_t setIndex = Index;
if (!Enable) if (!Enable)

View file

@ -1957,7 +1957,7 @@ namespace dxvk {
if (m_moduleInfo.options.d3d9FloatEmulation == D3D9FloatEmulation::Enabled) { if (m_moduleInfo.options.d3d9FloatEmulation == D3D9FloatEmulation::Enabled) {
result.id = m_module.opNMin(typeId, result.id, result.id = m_module.opNMin(typeId, result.id,
m_module.constfReplicant(FLT_MAX, result.type.ccount)); m_module.constfReplicant(std::numeric_limits<float>::max(), result.type.ccount));
} }
break; break;
case DxsoOpcode::Rsq: case DxsoOpcode::Rsq:
@ -1969,7 +1969,7 @@ namespace dxvk {
if (m_moduleInfo.options.d3d9FloatEmulation == D3D9FloatEmulation::Enabled) { if (m_moduleInfo.options.d3d9FloatEmulation == D3D9FloatEmulation::Enabled) {
result.id = m_module.opNMin(typeId, result.id, result.id = m_module.opNMin(typeId, result.id,
m_module.constfReplicant(FLT_MAX, result.type.ccount)); m_module.constfReplicant(std::numeric_limits<float>::max(), result.type.ccount));
} }
break; break;
case DxsoOpcode::Dp3: { case DxsoOpcode::Dp3: {
@ -2029,7 +2029,7 @@ namespace dxvk {
if (m_moduleInfo.options.d3d9FloatEmulation == D3D9FloatEmulation::Enabled) { if (m_moduleInfo.options.d3d9FloatEmulation == D3D9FloatEmulation::Enabled) {
result.id = m_module.opNMin(typeId, result.id, result.id = m_module.opNMin(typeId, result.id,
m_module.constfReplicant(FLT_MAX, result.type.ccount)); m_module.constfReplicant(std::numeric_limits<float>::max(), result.type.ccount));
} }
break; break;
} }
@ -2040,7 +2040,7 @@ namespace dxvk {
if (m_moduleInfo.options.d3d9FloatEmulation == D3D9FloatEmulation::Enabled) { if (m_moduleInfo.options.d3d9FloatEmulation == D3D9FloatEmulation::Enabled) {
result.id = m_module.opNMin(typeId, result.id, result.id = m_module.opNMin(typeId, result.id,
m_module.constfReplicant(FLT_MAX, result.type.ccount)); m_module.constfReplicant(std::numeric_limits<float>::max(), result.type.ccount));
} }
break; break;
case DxsoOpcode::Pow: { case DxsoOpcode::Pow: {
@ -2102,7 +2102,7 @@ namespace dxvk {
rcpLength.type = scalarType; rcpLength.type = scalarType;
rcpLength.id = m_module.opInverseSqrt(scalarTypeId, dot.id); rcpLength.id = m_module.opInverseSqrt(scalarTypeId, dot.id);
if (m_moduleInfo.options.d3d9FloatEmulation == D3D9FloatEmulation::Enabled) { if (m_moduleInfo.options.d3d9FloatEmulation == D3D9FloatEmulation::Enabled) {
rcpLength.id = m_module.opNMin(scalarTypeId, rcpLength.id, m_module.constf32(FLT_MAX)); rcpLength.id = m_module.opNMin(scalarTypeId, rcpLength.id, m_module.constf32(std::numeric_limits<float>::max()));
} }
// r * rsq(r . r) // r * rsq(r . r)
@ -2216,7 +2216,7 @@ namespace dxvk {
result.id = m_module.opLog2(typeId, result.id); result.id = m_module.opLog2(typeId, result.id);
if (m_moduleInfo.options.d3d9FloatEmulation == D3D9FloatEmulation::Enabled) { if (m_moduleInfo.options.d3d9FloatEmulation == D3D9FloatEmulation::Enabled) {
result.id = m_module.opNMax(typeId, result.id, result.id = m_module.opNMax(typeId, result.id,
m_module.constfReplicant(-FLT_MAX, result.type.ccount)); m_module.constfReplicant(-std::numeric_limits<float>::max(), result.type.ccount));
} }
break; break;
case DxsoOpcode::Lrp: case DxsoOpcode::Lrp:

View file

@ -86,7 +86,7 @@ namespace dxvk {
case DxsoOpcode::SetP: return 3; case DxsoOpcode::SetP: return 3;
case DxsoOpcode::TexLdl: return 3; case DxsoOpcode::TexLdl: return 3;
case DxsoOpcode::BreakP: return 2; case DxsoOpcode::BreakP: return 2;
default: Logger::warn("DxsoGetDefaultOpcodeLength: unknown opcode to get default length for."); return UINT32_MAX; default: Logger::warn("DxsoGetDefaultOpcodeLength: unknown opcode to get default length for."); return std::numeric_limits<uint32_t>::max();
} }
} }

View file

@ -4,7 +4,7 @@
namespace dxvk { namespace dxvk {
constexpr uint32_t InvalidOpcodeLength = UINT32_MAX; constexpr uint32_t InvalidOpcodeLength = std::numeric_limits<uint32_t>::max();
uint32_t DxsoGetDefaultOpcodeLength(DxsoOpcode opcode); uint32_t DxsoGetDefaultOpcodeLength(DxsoOpcode opcode);