mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-11 10:24:10 +01:00
[d3d9] Clean up resource locking code
This commit is contained in:
parent
e8fc7ea23a
commit
8c2ec5d9c9
@ -3999,6 +3999,7 @@ namespace dxvk {
|
|||||||
const bool systemmem = desc.Pool == D3DPOOL_SYSTEMMEM;
|
const bool systemmem = desc.Pool == D3DPOOL_SYSTEMMEM;
|
||||||
const bool managed = IsPoolManaged(desc.Pool);
|
const bool managed = IsPoolManaged(desc.Pool);
|
||||||
const bool scratch = desc.Pool == D3DPOOL_SCRATCH;
|
const bool scratch = desc.Pool == D3DPOOL_SCRATCH;
|
||||||
|
const bool doNotWait = Flags & D3DLOCK_DONOTWAIT;
|
||||||
|
|
||||||
bool fullResource = pBox == nullptr;
|
bool fullResource = pBox == nullptr;
|
||||||
if (unlikely(!fullResource)) {
|
if (unlikely(!fullResource)) {
|
||||||
@ -4065,10 +4066,15 @@ namespace dxvk {
|
|||||||
// that cannot get affected by GPU, therefore readonly is A-OK for NOT waiting.
|
// 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 && !dirty);
|
||||||
|
|
||||||
if (alloced)
|
bool doImplicitDiscard = (managed || (systemmem && !dirty)) && !doNotWait;
|
||||||
|
|
||||||
|
doImplicitDiscard = doImplicitDiscard && m_d3d9Options.allowImplicitDiscard;
|
||||||
|
|
||||||
|
if (alloced) {
|
||||||
std::memset(physSlice.mapPtr, 0, physSlice.length);
|
std::memset(physSlice.mapPtr, 0, physSlice.length);
|
||||||
else if ((managed || (systemmem && !dirty)) && !(Flags & D3DLOCK_DONOTWAIT) && !skipWait
|
}
|
||||||
&& m_d3d9Options.allowImplicitDiscard) {
|
else if (!skipWait) {
|
||||||
|
if (doImplicitDiscard) {
|
||||||
if (!WaitForResource(mappedBuffer, D3DLOCK_DONOTWAIT)) {
|
if (!WaitForResource(mappedBuffer, D3DLOCK_DONOTWAIT)) {
|
||||||
// if the mapped buffer is currently being copied to image
|
// if the mapped buffer is currently being copied to image
|
||||||
// we can just avoid a stall by allocating a new slice and copying the existing contents
|
// we can just avoid a stall by allocating a new slice and copying the existing contents
|
||||||
@ -4082,11 +4088,12 @@ namespace dxvk {
|
|||||||
ctx->invalidateBuffer(cImageBuffer, cBufferSlice);
|
ctx->invalidateBuffer(cImageBuffer, cBufferSlice);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (!skipWait) {
|
} else {
|
||||||
if (!WaitForResource(mappedBuffer, Flags))
|
if (!WaitForResource(mappedBuffer, Flags))
|
||||||
return D3DERR_WASSTILLDRAWING;
|
return D3DERR_WASSTILLDRAWING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
physSlice = mappedBuffer->getSliceHandle();
|
physSlice = mappedBuffer->getSliceHandle();
|
||||||
|
|
||||||
@ -4414,8 +4421,15 @@ namespace dxvk {
|
|||||||
quickRead ||
|
quickRead ||
|
||||||
(boundsCheck && !pResource->DirtyRange().Overlaps(pResource->LockRange()));
|
(boundsCheck && !pResource->DirtyRange().Overlaps(pResource->LockRange()));
|
||||||
if (!skipWait) {
|
if (!skipWait) {
|
||||||
if ((IsPoolManaged(desc.Pool) || desc.Pool == D3DPOOL_SYSTEMMEM) && !(Flags & D3DLOCK_DONOTWAIT) && pResource->GetLockCount() == 0
|
const bool managed = IsPoolManaged(desc.Pool);
|
||||||
&& m_d3d9Options.allowImplicitDiscard) {
|
const bool systemmem = desc.Pool == D3DPOOL_SYSTEMMEM;
|
||||||
|
const bool doNotWait = Flags & D3DLOCK_DONOTWAIT;
|
||||||
|
|
||||||
|
bool doImplicitDiscard = (managed || systemmem) && !doNotWait && pResource->GetLockCount() == 0;
|
||||||
|
|
||||||
|
doImplicitDiscard = doImplicitDiscard && m_d3d9Options.allowImplicitDiscard;
|
||||||
|
|
||||||
|
if (doImplicitDiscard) {
|
||||||
if (!WaitForResource(mappingBuffer, D3DLOCK_DONOTWAIT)) {
|
if (!WaitForResource(mappingBuffer, D3DLOCK_DONOTWAIT)) {
|
||||||
// if the mapped buffer is currently being copied to the primary buffer
|
// if the mapped buffer is currently being copied to the primary buffer
|
||||||
// we can just avoid a stall by allocating a new slice and copying the existing contents
|
// we can just avoid a stall by allocating a new slice and copying the existing contents
|
||||||
|
Loading…
Reference in New Issue
Block a user