mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-23 19:54:16 +01:00
[dxvk] Fix resource hazard checks
Turns out we've had broken write-after-read checks for a while.
This commit is contained in:
parent
6ad5ee34e3
commit
d24dba21ee
@ -2025,20 +2025,33 @@ namespace dxvk {
|
|||||||
bool checkResourceBarrier(
|
bool checkResourceBarrier(
|
||||||
const Pred& pred,
|
const Pred& pred,
|
||||||
VkAccessFlags access) {
|
VkAccessFlags access) {
|
||||||
// Check for read-after-write first, this is common
|
// If we're only reading the resource, only pending
|
||||||
|
// writes matter for synchronization purposes.
|
||||||
bool hasPendingWrite = pred(DxvkAccess::Write);
|
bool hasPendingWrite = pred(DxvkAccess::Write);
|
||||||
|
|
||||||
if (access & vk::AccessReadMask)
|
if (!(access & vk::AccessWriteMask))
|
||||||
return hasPendingWrite;
|
return hasPendingWrite;
|
||||||
|
|
||||||
// Check for a write-after-write hazard, but
|
if (hasPendingWrite) {
|
||||||
// ignore it if there are no reads involved.
|
// If there is a write-after-write hazard and synchronization
|
||||||
bool ignoreWaW = canIgnoreWawHazards<BindPoint>();
|
// for those is not explicitly disabled, insert a barrier.
|
||||||
|
if (!canIgnoreWawHazards<BindPoint>())
|
||||||
|
return true;
|
||||||
|
|
||||||
if (hasPendingWrite && !ignoreWaW)
|
// If write-after-write checking is disabled and we're on graphics,
|
||||||
return true;
|
// be aggressive about avoiding barriers and ignore any reads if we
|
||||||
|
// do find a write-after-write hazard. This essentially assumes that
|
||||||
|
// back-to-back read-modify-write operations are safe, but will still
|
||||||
|
// consider read-only or transform feedback operations as unsafe.
|
||||||
|
if (BindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS)
|
||||||
|
return !(access & VK_ACCESS_SHADER_WRITE_BIT);
|
||||||
|
|
||||||
// Check whether there are any pending reads.
|
// On compute, if we are reading the resource, add a barrier.
|
||||||
|
if (access & vk::AccessReadMask)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if there are any pending reads to avoid write-after-read issues.
|
||||||
return pred(DxvkAccess::Read);
|
return pred(DxvkAccess::Read);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user