[d3d9] Clamp Dref to [0.0, 1.0] if the texture is emulated UNORM

This commit is contained in:
Georg Lehmann 2022-09-26 11:21:12 +02:00 committed by Joshie
parent 6fe96d7d82
commit a9bdea72e9
2 changed files with 10 additions and 4 deletions

View File

@ -3791,6 +3791,9 @@ namespace dxvk {
m_dirtySamplerStates |= 1u << StateSampler;
}
m_drefClamp &= ~(1u << StateSampler);
m_drefClamp |= uint32_t(newTexture->IsUpgradedToD32f()) << StateSampler;
const bool oldCube = m_cubeTextures & (1u << StateSampler);
const bool newCube = newTexture->GetType() == D3DRTYPE_CUBETEXTURE;
if (oldCube != newCube) {
@ -6249,7 +6252,8 @@ namespace dxvk {
const uint32_t nullTextureMask = usedSamplerMask & ~usedTextureMask;
const uint32_t depthTextureMask = m_depthTextures & usedTextureMask;
UpdateCommonSamplerSpec(nullTextureMask, depthTextureMask);
const uint32_t drefClampMask = m_drefClamp & depthTextureMask;
UpdateCommonSamplerSpec(nullTextureMask, depthTextureMask, drefClampMask);
if (m_flags.test(D3D9DeviceFlag::DirtySharedPixelShaderData)) {
m_flags.clr(D3D9DeviceFlag::DirtySharedPixelShaderData);
@ -7249,7 +7253,7 @@ namespace dxvk {
UpdatePixelShaderSamplerSpec(0u, 0u, 0u);
UpdateVertexBoolSpec(0u);
UpdatePixelBoolSpec(0u);
UpdateCommonSamplerSpec(0u, 0u);
UpdateCommonSamplerSpec(0u, 0u, 0u);
return D3D_OK;
}
@ -7443,9 +7447,10 @@ namespace dxvk {
}
void D3D9DeviceEx::UpdateCommonSamplerSpec(uint32_t nullMask, uint32_t depthMask) {
void D3D9DeviceEx::UpdateCommonSamplerSpec(uint32_t nullMask, uint32_t depthMask, uint32_t drefMask) {
bool dirty = m_specInfo.set<SpecSamplerDepthMode>(depthMask);
dirty |= m_specInfo.set<SpecSamplerNull>(nullMask);
dirty |= m_specInfo.set<SpecDrefClamp>(drefMask);
if (dirty)
m_flags.set(D3D9DeviceFlag::DirtySpecializationEntries);

View File

@ -1145,7 +1145,7 @@ namespace dxvk {
void UpdateVertexBoolSpec(uint32_t value);
void UpdatePixelBoolSpec(uint32_t value);
void UpdatePixelShaderSamplerSpec(uint32_t types, uint32_t projections, uint32_t fetch4);
void UpdateCommonSamplerSpec(uint32_t boundMask, uint32_t depthMask);
void UpdateCommonSamplerSpec(uint32_t boundMask, uint32_t depthMask, uint32_t drefMask);
void UpdatePointModeSpec(uint32_t mode);
void UpdateFogModeSpec(bool fogEnabled, D3DFOGMODE vertexFogMode, D3DFOGMODE pixelFogMode);
@ -1237,6 +1237,7 @@ namespace dxvk {
uint32_t m_instancedData = 0;
uint32_t m_depthTextures = 0;
uint32_t m_drefClamp = 0;
uint32_t m_cubeTextures = 0;
uint32_t m_textureTypes = 0;
uint32_t m_projectionBitfield = 0;