mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-12 22:08:59 +01:00
[d3d9] Mark managed for upload in Lock rather than Unlock
Fixes Nekopara properly. Also refactor some locking checks
This commit is contained in:
parent
86e8315416
commit
ed5cbb99b6
@ -4098,6 +4098,22 @@ namespace dxvk {
|
|||||||
|
|
||||||
pResource->SetLocked(Subresource, true);
|
pResource->SetLocked(Subresource, true);
|
||||||
|
|
||||||
|
if (pResource->IsManaged() && !m_d3d9Options.evictManagedOnUnlock) {
|
||||||
|
pResource->SetNeedsUpload(Subresource, true);
|
||||||
|
|
||||||
|
for (uint32_t tex = m_activeTextures; tex; tex &= tex - 1) {
|
||||||
|
// Guaranteed to not be nullptr...
|
||||||
|
const uint32_t i = bit::tzcnt(tex);
|
||||||
|
auto texInfo = GetCommonTexture(m_state.textures[i]);
|
||||||
|
|
||||||
|
if (texInfo == pResource) {
|
||||||
|
m_activeTexturesToUpload |= 1 << i;
|
||||||
|
// We can early out here, no need to add another index for this.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const uint32_t offset = CalcImageLockOffset(
|
const uint32_t offset = CalcImageLockOffset(
|
||||||
pLockedBox->SlicePitch,
|
pLockedBox->SlicePitch,
|
||||||
pLockedBox->RowPitch,
|
pLockedBox->RowPitch,
|
||||||
@ -4125,31 +4141,22 @@ namespace dxvk {
|
|||||||
|
|
||||||
pResource->SetLocked(Subresource, false);
|
pResource->SetLocked(Subresource, false);
|
||||||
|
|
||||||
// Do we have a pending copy?
|
// Flush image contents from staging if we aren't read only
|
||||||
if (!pResource->GetReadOnlyLocked(Subresource)) {
|
// and we aren't deferring for managed.
|
||||||
// Only flush buffer -> image if we actually have an image
|
bool shouldFlush = pResource->GetMapMode() == D3D9_COMMON_TEXTURE_MAP_MODE_BACKED;
|
||||||
if (pResource->IsManaged() && !m_d3d9Options.evictManagedOnUnlock) {
|
shouldFlush &= !pResource->GetReadOnlyLocked(Subresource);
|
||||||
pResource->SetNeedsUpload(Subresource, true);
|
shouldFlush &= !pResource->IsManaged() || m_d3d9Options.evictManagedOnUnlock;
|
||||||
|
|
||||||
for (uint32_t tex = m_activeTextures; tex; tex &= tex - 1) {
|
if (shouldFlush)
|
||||||
// Guaranteed to not be nullptr...
|
|
||||||
const uint32_t i = bit::tzcnt(tex);
|
|
||||||
auto texInfo = GetCommonTexture(m_state.textures[i]);
|
|
||||||
|
|
||||||
if (texInfo == pResource) {
|
|
||||||
m_activeTexturesToUpload |= 1 << i;
|
|
||||||
// We can early out here, no need to add another index for this.
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (pResource->GetMapMode() == D3D9_COMMON_TEXTURE_MAP_MODE_BACKED)
|
|
||||||
this->FlushImage(pResource, Subresource);
|
this->FlushImage(pResource, Subresource);
|
||||||
}
|
|
||||||
|
|
||||||
if (pResource->GetMapMode() == D3D9_COMMON_TEXTURE_MAP_MODE_BACKED
|
// Toss our staging buffer if we're not dynamic
|
||||||
&& (!pResource->IsDynamic())
|
// and we aren't managed (for sysmem copy.)
|
||||||
&& (!pResource->IsManaged() || m_d3d9Options.evictManagedOnUnlock)) {
|
bool shouldToss = pResource->GetMapMode() == D3D9_COMMON_TEXTURE_MAP_MODE_BACKED;
|
||||||
|
shouldToss &= !pResource->IsDynamic();
|
||||||
|
shouldToss &= !pResource->IsManaged() || m_d3d9Options.evictManagedOnUnlock;
|
||||||
|
|
||||||
|
if (shouldToss) {
|
||||||
pResource->DestroyBufferSubresource(Subresource);
|
pResource->DestroyBufferSubresource(Subresource);
|
||||||
pResource->SetDirty(Subresource, true);
|
pResource->SetDirty(Subresource, true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user