[dxbc] Rework TGSM workaround

This commit is contained in:
Philip Rebohle 2022-09-09 13:59:58 +02:00
parent 8176101228
commit ccfb986e72
6 changed files with 30 additions and 18 deletions

View File

@ -16,7 +16,7 @@ namespace dxvk {
this->dcSingleUseMode = config.getOption<bool>("d3d11.dcSingleUseMode", true);
this->enableRtOutputNanFixup = config.getOption<bool>("d3d11.enableRtOutputNanFixup", false);
this->zeroInitWorkgroupMemory = config.getOption<bool>("d3d11.zeroInitWorkgroupMemory", false);
this->forceTgsmBarriers = config.getOption<bool>("d3d11.forceTgsmBarriers", false);
this->forceVolatileTgsmAccess = config.getOption<bool>("d3d11.forceVolatileTgsmAccess", false);
this->relaxedBarriers = config.getOption<bool>("d3d11.relaxedBarriers", false);
this->ignoreGraphicsBarriers = config.getOption<bool>("d3d11.ignoreGraphicsBarriers", false);
this->maxTessFactor = config.getOption<int32_t>("d3d11.maxTessFactor", 0);

View File

@ -30,12 +30,12 @@ namespace dxvk {
/// TGSM in compute shaders before reading it.
bool zeroInitWorkgroupMemory;
/// Force thread-group shared memory barriers
/// Force thread-group shared memory accesses to be volatile
///
/// Workaround for compute shaders that read and
/// write from the same shared memory location
/// without explicit synchronization.
bool forceTgsmBarriers;
bool forceVolatileTgsmAccess;
/// Use relaxed memory barriers
///

View File

@ -5190,17 +5190,23 @@ namespace dxvk {
SpirvImageOperands imageOperands;
imageOperands.sparse = sparseFeedbackId != 0;
if (isTgsm)
uint32_t coherence = bufferInfo.coherence;
if (isTgsm || coherence)
memoryOperands.flags = spv::MemoryAccessNonPrivatePointerMask;
if (bufferInfo.coherence) {
memoryOperands.flags = spv::MemoryAccessNonPrivatePointerMask
| spv::MemoryAccessMakePointerVisibleMask;
memoryOperands.makeVisible = m_module.constu32(bufferInfo.coherence);
if (isTgsm && m_moduleInfo.options.forceVolatileTgsmAccess) {
memoryOperands.flags |= spv::MemoryAccessVolatileMask;
coherence = spv::ScopeWorkgroup;
}
if (coherence) {
memoryOperands.flags |= spv::MemoryAccessMakePointerVisibleMask;
memoryOperands.makeVisible = m_module.constu32(coherence);
imageOperands.flags = spv::ImageOperandsNonPrivateTexelMask
| spv::ImageOperandsMakeTexelVisibleMask;
imageOperands.makeVisible = m_module.constu32(bufferInfo.coherence);
imageOperands.makeVisible = m_module.constu32(coherence);
}
sparseFeedbackId = 0;
@ -5308,17 +5314,23 @@ namespace dxvk {
SpirvMemoryOperands memoryOperands;
SpirvImageOperands imageOperands;
if (isTgsm)
uint32_t coherence = bufferInfo.coherence;
if (isTgsm || coherence)
memoryOperands.flags = spv::MemoryAccessNonPrivatePointerMask;
if (bufferInfo.coherence) {
memoryOperands.flags = spv::MemoryAccessNonPrivatePointerMask
| spv::MemoryAccessMakePointerAvailableMask;
memoryOperands.makeAvailable = m_module.constu32(bufferInfo.coherence);
if (isTgsm && m_moduleInfo.options.forceVolatileTgsmAccess) {
memoryOperands.flags |= spv::MemoryAccessVolatileMask;
coherence = spv::ScopeWorkgroup;
}
if (coherence) {
memoryOperands.flags |= spv::MemoryAccessMakePointerAvailableMask;
memoryOperands.makeAvailable = m_module.constu32(coherence);
imageOperands.flags = spv::ImageOperandsNonPrivateTexelMask
| spv::ImageOperandsMakeTexelAvailableMask;
imageOperands.makeAvailable = m_module.constu32(bufferInfo.coherence);
imageOperands.makeAvailable = m_module.constu32(coherence);
}
for (uint32_t i = 0; i < 4; i++) {

View File

@ -37,7 +37,7 @@ namespace dxvk {
invariantPosition = options.invariantPosition;
enableRtOutputNanFixup = options.enableRtOutputNanFixup;
zeroInitWorkgroupMemory = options.zeroInitWorkgroupMemory;
forceTgsmBarriers = options.forceTgsmBarriers;
forceVolatileTgsmAccess = options.forceVolatileTgsmAccess;
disableMsaa = options.disableMsaa;
// Figure out float control flags to match D3D11 rules

View File

@ -41,7 +41,7 @@ namespace dxvk {
bool invariantPosition = false;
/// Insert memory barriers after TGSM stoes
bool forceTgsmBarriers = false;
bool forceVolatileTgsmAccess = false;
/// Replace ld_ms with ld
bool disableMsaa = false;

View File

@ -181,7 +181,7 @@ namespace dxvk {
/* F1 games - do not synchronize TGSM access *
* in a compute shader, causing artifacts */
{ R"(\\F1_20(1[89]|[2-9][0-9])\.exe$)", {{
{ "d3d11.forceTgsmBarriers", "True" },
{ "d3d11.forceVolatileTgsmAccess", "True" },
}} },
/* Darksiders Warmastered - apparently reads *
* from write-only mapped buffers */