[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->dcSingleUseMode = config.getOption<bool>("d3d11.dcSingleUseMode", true);
this->enableRtOutputNanFixup = config.getOption<bool>("d3d11.enableRtOutputNanFixup", false); this->enableRtOutputNanFixup = config.getOption<bool>("d3d11.enableRtOutputNanFixup", false);
this->zeroInitWorkgroupMemory = config.getOption<bool>("d3d11.zeroInitWorkgroupMemory", 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->relaxedBarriers = config.getOption<bool>("d3d11.relaxedBarriers", false);
this->ignoreGraphicsBarriers = config.getOption<bool>("d3d11.ignoreGraphicsBarriers", false); this->ignoreGraphicsBarriers = config.getOption<bool>("d3d11.ignoreGraphicsBarriers", false);
this->maxTessFactor = config.getOption<int32_t>("d3d11.maxTessFactor", 0); this->maxTessFactor = config.getOption<int32_t>("d3d11.maxTessFactor", 0);

View File

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

View File

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

View File

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

View File

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

View File

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