Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[d3d9] Don't clear mipGenBit if texture is bound as attachment #4350

Merged
merged 1 commit into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/d3d9/d3d9_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6151,9 +6151,11 @@ namespace dxvk {
// Guaranteed to not be nullptr...
auto texInfo = GetCommonTexture(m_state.textures[texIdx]);

if (texInfo->NeedsMipGen()) {
if (likely(texInfo->NeedsMipGen())) {
this->EmitGenerateMips(texInfo);
texInfo->SetNeedsMipGen(false);
if (likely(!IsTextureBoundAsAttachment(texInfo))) {
texInfo->SetNeedsMipGen(false);
}
}
}

Expand All @@ -6178,14 +6180,18 @@ namespace dxvk {


void D3D9DeviceEx::MarkTextureMipsUnDirty(D3D9CommonTexture* pResource) {
pResource->SetNeedsMipGen(false);
if (likely(!IsTextureBoundAsAttachment(pResource))) {
// We need to keep the texture marked as needing mipmap generation because we don't set that when rendering.
pResource->SetNeedsMipGen(false);

for (uint32_t i : bit::BitMask(m_activeTextures)) {
// Guaranteed to not be nullptr...
auto texInfo = GetCommonTexture(m_state.textures[i]);
for (uint32_t i : bit::BitMask(m_activeTextures)) {
// Guaranteed to not be nullptr...
auto texInfo = GetCommonTexture(m_state.textures[i]);

if (texInfo == pResource)
m_activeTexturesToGen &= ~(1 << i);
if (unlikely(texInfo == pResource)) {
m_activeTexturesToGen &= ~(1 << i);
}
}
}
}

Expand Down
17 changes: 17 additions & 0 deletions src/d3d9/d3d9_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,23 @@ namespace dxvk {
m_mostRecentlyUsedSwapchain = m_implicitSwapchain.ptr();
}

bool IsTextureBoundAsAttachment(const D3D9CommonTexture* pTexture) const {
if (unlikely(pTexture->IsRenderTarget())) {
for (uint32_t i : bit::BitMask(m_boundRTs)) {
auto texInfo = m_state.renderTargets[i]->GetCommonTexture();
if (unlikely(texInfo == pTexture)) {
return true;
}
}
} else if (unlikely(pTexture->IsDepthStencil() && m_state.depthStencil != nullptr)) {
auto texInfo = m_state.depthStencil->GetCommonTexture();
if (unlikely(texInfo == pTexture)) {
return true;
}
}
return false;
}

Com<D3D9InterfaceEx> m_parent;
D3DDEVTYPE m_deviceType;
HWND m_window;
Expand Down