mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-01 16:24:12 +01:00
[d3d9] Improve naming of texture dirty flag and dirty boxes
This commit is contained in:
parent
6f139791d2
commit
4f45e74d96
@ -17,8 +17,8 @@ namespace dxvk {
|
||||
? D3D9Format::D32
|
||||
: D3D9Format::X8R8G8B8;
|
||||
|
||||
for (uint32_t i = 0; i < m_updateDirtyBoxes.size(); i++) {
|
||||
AddUpdateDirtyBox(nullptr, i);
|
||||
for (uint32_t i = 0; i < m_dirtyBoxes.size(); i++) {
|
||||
AddDirtyBox(nullptr, i);
|
||||
}
|
||||
|
||||
m_mapping = pDevice->LookupFormat(m_desc.Format);
|
||||
@ -489,7 +489,7 @@ namespace dxvk {
|
||||
if (IsManaged()) {
|
||||
auto lock = m_device->LockDevice();
|
||||
|
||||
if (GetNeedsUpload(Subresource)) {
|
||||
if (NeedsUpload(Subresource)) {
|
||||
m_device->FlushImage(this, Subresource);
|
||||
SetNeedsUpload(Subresource, false);
|
||||
|
||||
|
@ -223,7 +223,7 @@ namespace dxvk {
|
||||
*/
|
||||
void DestroyBufferSubresource(UINT Subresource) {
|
||||
m_buffers[Subresource] = nullptr;
|
||||
SetDirty(Subresource, true);
|
||||
SetWrittenByGPU(Subresource, true);
|
||||
}
|
||||
|
||||
bool IsDynamic() const {
|
||||
@ -308,11 +308,11 @@ namespace dxvk {
|
||||
|
||||
bool GetLocked(UINT Subresource) const { return m_locked.get(Subresource); }
|
||||
|
||||
void SetDirty(UINT Subresource, bool value) { m_dirty.set(Subresource, value); }
|
||||
void SetWrittenByGPU(UINT Subresource, bool value) { m_wasWrittenByGPU.set(Subresource, value); }
|
||||
|
||||
bool GetDirty(UINT Subresource) const { return m_dirty.get(Subresource); }
|
||||
bool WasWrittenByGPU(UINT Subresource) const { return m_wasWrittenByGPU.get(Subresource); }
|
||||
|
||||
void MarkAllDirty() { m_dirty.setAll(); }
|
||||
void MarkAllWrittenByGPU() { m_wasWrittenByGPU.setAll(); }
|
||||
|
||||
void SetReadOnlyLocked(UINT Subresource, bool readOnly) { return m_readOnly.set(Subresource, readOnly); }
|
||||
|
||||
@ -353,7 +353,7 @@ namespace dxvk {
|
||||
D3D9SubresourceBitset& GetUploadBitmask() { return m_needsUpload; }
|
||||
|
||||
void SetNeedsUpload(UINT Subresource, bool upload) { m_needsUpload.set(Subresource, upload); }
|
||||
bool GetNeedsUpload(UINT Subresource) const { return m_needsUpload.get(Subresource); }
|
||||
bool NeedsUpload(UINT Subresource) const { return m_needsUpload.get(Subresource); }
|
||||
bool NeedsAnyUpload() { return m_needsUpload.any(); }
|
||||
void ClearNeedsUpload() { return m_needsUpload.clearAll(); }
|
||||
|
||||
@ -368,7 +368,7 @@ namespace dxvk {
|
||||
void PreLoadAll();
|
||||
void PreLoadSubresource(UINT Subresource);
|
||||
|
||||
void AddUpdateDirtyBox(CONST D3DBOX* pDirtyBox, uint32_t layer) {
|
||||
void AddDirtyBox(CONST D3DBOX* pDirtyBox, uint32_t layer) {
|
||||
if (pDirtyBox) {
|
||||
D3DBOX box = *pDirtyBox;
|
||||
if (box.Right <= box.Left
|
||||
@ -376,30 +376,30 @@ namespace dxvk {
|
||||
|| box.Back <= box.Front)
|
||||
return;
|
||||
|
||||
D3DBOX& updateBox = m_updateDirtyBoxes[layer];
|
||||
if (updateBox.Left == updateBox.Right) {
|
||||
updateBox = box;
|
||||
D3DBOX& dirtyBox = m_dirtyBoxes[layer];
|
||||
if (dirtyBox.Left == dirtyBox.Right) {
|
||||
dirtyBox = box;
|
||||
} else {
|
||||
updateBox.Left = std::min(updateBox.Left, box.Left);
|
||||
updateBox.Right = std::max(updateBox.Right, box.Right);
|
||||
updateBox.Top = std::min(updateBox.Top, box.Top);
|
||||
updateBox.Bottom = std::max(updateBox.Bottom, box.Bottom);
|
||||
updateBox.Front = std::min(updateBox.Front, box.Front);
|
||||
updateBox.Back = std::max(updateBox.Back, box.Back);
|
||||
dirtyBox.Left = std::min(dirtyBox.Left, box.Left);
|
||||
dirtyBox.Right = std::max(dirtyBox.Right, box.Right);
|
||||
dirtyBox.Top = std::min(dirtyBox.Top, box.Top);
|
||||
dirtyBox.Bottom = std::max(dirtyBox.Bottom, box.Bottom);
|
||||
dirtyBox.Front = std::min(dirtyBox.Front, box.Front);
|
||||
dirtyBox.Back = std::max(dirtyBox.Back, box.Back);
|
||||
}
|
||||
} else {
|
||||
m_updateDirtyBoxes[layer] = { 0, 0, m_desc.Width, m_desc.Height, 0, m_desc.Depth };
|
||||
m_dirtyBoxes[layer] = { 0, 0, m_desc.Width, m_desc.Height, 0, m_desc.Depth };
|
||||
}
|
||||
}
|
||||
|
||||
void ClearUpdateDirtyBoxes() {
|
||||
for (uint32_t i = 0; i < m_updateDirtyBoxes.size(); i++) {
|
||||
m_updateDirtyBoxes[i] = { 0, 0, 0, 0, 0, 0 };
|
||||
void ClearDirtyBoxes() {
|
||||
for (uint32_t i = 0; i < m_dirtyBoxes.size(); i++) {
|
||||
m_dirtyBoxes[i] = { 0, 0, 0, 0, 0, 0 };
|
||||
}
|
||||
}
|
||||
|
||||
const D3DBOX& GetUpdateDirtyBox(uint32_t layer) const {
|
||||
return m_updateDirtyBoxes[layer];
|
||||
const D3DBOX& GetDirtyBox(uint32_t layer) const {
|
||||
return m_dirtyBoxes[layer];
|
||||
}
|
||||
|
||||
private:
|
||||
@ -432,7 +432,7 @@ namespace dxvk {
|
||||
|
||||
D3D9SubresourceBitset m_readOnly = { };
|
||||
|
||||
D3D9SubresourceBitset m_dirty = { };
|
||||
D3D9SubresourceBitset m_wasWrittenByGPU = { };
|
||||
|
||||
D3D9SubresourceBitset m_needsUpload = { };
|
||||
|
||||
@ -442,7 +442,7 @@ namespace dxvk {
|
||||
|
||||
D3DTEXTUREFILTERTYPE m_mipFilter = D3DTEXF_LINEAR;
|
||||
|
||||
std::array<D3DBOX, 6> m_updateDirtyBoxes;
|
||||
std::array<D3DBOX, 6> m_dirtyBoxes;
|
||||
|
||||
/**
|
||||
* \brief Mip level
|
||||
|
@ -659,9 +659,9 @@ namespace dxvk {
|
||||
updateDirtyRect.Left = pDestPoint->x;
|
||||
updateDirtyRect.Top = pDestPoint->y;
|
||||
}
|
||||
dstTextureInfo->AddUpdateDirtyBox(&updateDirtyRect, dst->GetFace());
|
||||
dstTextureInfo->AddDirtyBox(&updateDirtyRect, dst->GetFace());
|
||||
} else {
|
||||
dstTextureInfo->AddUpdateDirtyBox(nullptr, dst->GetFace());
|
||||
dstTextureInfo->AddDirtyBox(nullptr, dst->GetFace());
|
||||
}
|
||||
}
|
||||
|
||||
@ -718,7 +718,7 @@ namespace dxvk {
|
||||
cSrcExtent);
|
||||
});
|
||||
|
||||
dstTextureInfo->SetDirty(dst->GetSubresource(), true);
|
||||
dstTextureInfo->SetWrittenByGPU(dst->GetSubresource(), true);
|
||||
|
||||
if (dstTextureInfo->IsAutomaticMip())
|
||||
MarkTextureMipsDirty(dstTextureInfo);
|
||||
@ -753,7 +753,7 @@ namespace dxvk {
|
||||
mipLevels = 1;
|
||||
|
||||
for (uint32_t a = 0; a < arraySlices; a++) {
|
||||
const D3DBOX& box = srcTexInfo->GetUpdateDirtyBox(a);
|
||||
const D3DBOX& box = srcTexInfo->GetDirtyBox(a);
|
||||
if (box.Left >= box.Right || box.Top >= box.Bottom || box.Front >= box.Back)
|
||||
continue;
|
||||
|
||||
@ -799,11 +799,11 @@ namespace dxvk {
|
||||
cSrcExtent);
|
||||
});
|
||||
|
||||
dstTexInfo->SetDirty(dstTexInfo->CalcSubresource(a, m), true);
|
||||
dstTexInfo->SetWrittenByGPU(dstTexInfo->CalcSubresource(a, m), true);
|
||||
}
|
||||
}
|
||||
|
||||
srcTexInfo->ClearUpdateDirtyBoxes();
|
||||
srcTexInfo->ClearDirtyBoxes();
|
||||
if (dstTexInfo->IsAutomaticMip() && mipLevels != dstTexInfo->Desc()->MipLevels)
|
||||
MarkTextureMipsDirty(dstTexInfo);
|
||||
|
||||
@ -861,7 +861,7 @@ namespace dxvk {
|
||||
cLevelExtent);
|
||||
});
|
||||
|
||||
dstTexInfo->SetDirty(dst->GetSubresource(), true);
|
||||
dstTexInfo->SetWrittenByGPU(dst->GetSubresource(), true);
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
@ -1071,7 +1071,7 @@ namespace dxvk {
|
||||
});
|
||||
}
|
||||
|
||||
dstTextureInfo->SetDirty(dst->GetSubresource(), true);
|
||||
dstTextureInfo->SetWrittenByGPU(dst->GetSubresource(), true);
|
||||
|
||||
if (dstTextureInfo->IsAutomaticMip())
|
||||
MarkTextureMipsDirty(dstTextureInfo);
|
||||
@ -1149,7 +1149,7 @@ namespace dxvk {
|
||||
});
|
||||
}
|
||||
|
||||
dstTextureInfo->SetDirty(dst->GetSubresource(), true);
|
||||
dstTextureInfo->SetWrittenByGPU(dst->GetSubresource(), true);
|
||||
|
||||
if (dstTextureInfo->IsAutomaticMip())
|
||||
MarkTextureMipsDirty(dstTextureInfo);
|
||||
@ -1242,7 +1242,7 @@ namespace dxvk {
|
||||
if (texInfo->IsAutomaticMip())
|
||||
texInfo->SetNeedsMipGen(true);
|
||||
|
||||
texInfo->SetDirty(rt->GetSubresource(), true);
|
||||
texInfo->SetWrittenByGPU(rt->GetSubresource(), true);
|
||||
}
|
||||
|
||||
if (originalAlphaSwizzleRTs != m_alphaSwizzleRTs)
|
||||
@ -3980,7 +3980,7 @@ namespace dxvk {
|
||||
Flags &= ~D3DLOCK_DISCARD;
|
||||
|
||||
if (!(Flags & D3DLOCK_NO_DIRTY_UPDATE) && !(Flags & D3DLOCK_READONLY)) {
|
||||
pResource->AddUpdateDirtyBox(pBox, Face);
|
||||
pResource->AddDirtyBox(pBox, Face);
|
||||
}
|
||||
|
||||
auto& desc = *(pResource->Desc());
|
||||
@ -4033,14 +4033,15 @@ namespace dxvk {
|
||||
|
||||
bool renderable = desc.Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL);
|
||||
|
||||
// If we are dirty, then we need to copy -> buffer
|
||||
// If we recently wrote to the texture on the gpu,
|
||||
// then we need to copy -> buffer
|
||||
// We are also always dirty if we are a render target,
|
||||
// a depth stencil, or auto generate mipmaps.
|
||||
bool dirty = pResource->GetDirty(Subresource) || renderable;
|
||||
pResource->SetDirty(Subresource, false);
|
||||
|
||||
bool wasWrittenByGPU = pResource->WasWrittenByGPU(Subresource) || renderable;
|
||||
pResource->SetWrittenByGPU(Subresource, false);
|
||||
|
||||
DxvkBufferSliceHandle physSlice;
|
||||
|
||||
|
||||
if (Flags & D3DLOCK_DISCARD) {
|
||||
// We do not have to preserve the contents of the
|
||||
// buffer if the entire image gets discarded.
|
||||
@ -4064,9 +4065,9 @@ namespace dxvk {
|
||||
// calling app promises not to overwrite data that is in use
|
||||
// or is reading. Remember! This will only trigger for MANAGED resources
|
||||
// that cannot get affected by GPU, therefore readonly is A-OK for NOT waiting.
|
||||
const bool skipWait = (readOnly && managed) || scratch || (readOnly && systemmem && !dirty);
|
||||
const bool skipWait = (readOnly && managed) || scratch || (readOnly && systemmem && !wasWrittenByGPU);
|
||||
|
||||
bool doImplicitDiscard = (managed || (systemmem && !dirty)) && !doNotWait;
|
||||
bool doImplicitDiscard = (managed || (systemmem && !wasWrittenByGPU)) && !doNotWait;
|
||||
|
||||
doImplicitDiscard = doImplicitDiscard && m_d3d9Options.allowImplicitDiscard;
|
||||
|
||||
@ -4097,7 +4098,7 @@ namespace dxvk {
|
||||
else {
|
||||
physSlice = mappedBuffer->getSliceHandle();
|
||||
|
||||
if (unlikely(dirty)) {
|
||||
if (unlikely(wasWrittenByGPU)) {
|
||||
Rc<DxvkImage> resourceImage = pResource->GetImage();
|
||||
|
||||
Rc<DxvkImage> mappedImage = resourceImage->info().sampleCount != 1
|
||||
@ -4166,7 +4167,7 @@ namespace dxvk {
|
||||
if (!WaitForResource(mappedBuffer, Flags))
|
||||
return D3DERR_WASSTILLDRAWING;
|
||||
} else if (alloced) {
|
||||
// If we are a new alloc, and we weren't dirty
|
||||
// If we are a new alloc, and we weren't written by the GPU
|
||||
// that means that we are a newly initialized
|
||||
// texture, and hence can just memset -> 0 and
|
||||
// avoid a wait here.
|
||||
@ -4251,7 +4252,7 @@ namespace dxvk {
|
||||
|
||||
if (shouldToss) {
|
||||
pResource->DestroyBufferSubresource(Subresource);
|
||||
pResource->SetDirty(Subresource, true);
|
||||
pResource->SetWrittenByGPU(Subresource, true);
|
||||
}
|
||||
|
||||
return D3D_OK;
|
||||
@ -5011,7 +5012,7 @@ namespace dxvk {
|
||||
|
||||
void D3D9DeviceEx::UploadManagedTexture(D3D9CommonTexture* pResource) {
|
||||
for (uint32_t subresource = 0; subresource < pResource->CountSubresources(); subresource++) {
|
||||
if (!pResource->GetNeedsUpload(subresource))
|
||||
if (!pResource->NeedsUpload(subresource))
|
||||
continue;
|
||||
|
||||
this->FlushImage(pResource, subresource);
|
||||
@ -5047,7 +5048,7 @@ namespace dxvk {
|
||||
|
||||
void D3D9DeviceEx::MarkTextureMipsDirty(D3D9CommonTexture* pResource) {
|
||||
pResource->SetNeedsMipGen(true);
|
||||
pResource->MarkAllDirty();
|
||||
pResource->MarkAllWrittenByGPU();
|
||||
|
||||
for (uint32_t tex = m_activeTextures; tex; tex &= tex - 1) {
|
||||
// Guaranteed to not be nullptr...
|
||||
@ -6663,7 +6664,7 @@ namespace dxvk {
|
||||
});
|
||||
}
|
||||
|
||||
dstTextureInfo->MarkAllDirty();
|
||||
dstTextureInfo->MarkAllWrittenByGPU();
|
||||
}
|
||||
|
||||
|
||||
|
@ -462,7 +462,7 @@ namespace dxvk {
|
||||
cLevelExtent);
|
||||
});
|
||||
|
||||
dstTexInfo->SetDirty(dst->GetSubresource(), true);
|
||||
dstTexInfo->SetWrittenByGPU(dst->GetSubresource(), true);
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
@ -78,9 +78,9 @@ namespace dxvk {
|
||||
HRESULT STDMETHODCALLTYPE D3D9Texture2D::AddDirtyRect(CONST RECT* pDirtyRect) {
|
||||
if (pDirtyRect) {
|
||||
D3DBOX box = { UINT(pDirtyRect->left), UINT(pDirtyRect->top), UINT(pDirtyRect->right), UINT(pDirtyRect->bottom), 0, 1 };
|
||||
m_texture.AddUpdateDirtyBox(&box, 0);
|
||||
m_texture.AddDirtyBox(&box, 0);
|
||||
} else {
|
||||
m_texture.AddUpdateDirtyBox(nullptr, 0);
|
||||
m_texture.AddDirtyBox(nullptr, 0);
|
||||
}
|
||||
return D3D_OK;
|
||||
}
|
||||
@ -158,7 +158,7 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE D3D9Texture3D::AddDirtyBox(CONST D3DBOX* pDirtyBox) {
|
||||
m_texture.AddUpdateDirtyBox(pDirtyBox, 0);
|
||||
m_texture.AddDirtyBox(pDirtyBox, 0);
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
@ -238,9 +238,9 @@ namespace dxvk {
|
||||
HRESULT STDMETHODCALLTYPE D3D9TextureCube::AddDirtyRect(D3DCUBEMAP_FACES Face, CONST RECT* pDirtyRect) {
|
||||
if (pDirtyRect) {
|
||||
D3DBOX box = { UINT(pDirtyRect->left), UINT(pDirtyRect->top), UINT(pDirtyRect->right), UINT(pDirtyRect->bottom), 0, 1 };
|
||||
m_texture.AddUpdateDirtyBox(&box, Face);
|
||||
m_texture.AddDirtyBox(&box, Face);
|
||||
} else {
|
||||
m_texture.AddUpdateDirtyBox(nullptr, Face);
|
||||
m_texture.AddDirtyBox(nullptr, Face);
|
||||
}
|
||||
return D3D_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user