From f99a833f51990157e29b880b49182ceb3c936495 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 12 Jul 2022 02:09:39 +0200 Subject: [PATCH] [d3d11] Remove d3d11.constantBufferRangeCheck option --- dxvk.conf | 9 --------- src/d3d11/d3d11_buffer.cpp | 3 --- src/d3d11/d3d11_options.cpp | 3 --- src/d3d11/d3d11_options.h | 5 ----- src/dxbc/dxbc_compiler.cpp | 24 +++++------------------- src/dxbc/dxbc_compiler.h | 3 +-- src/dxbc/dxbc_options.cpp | 1 - src/dxbc/dxbc_options.h | 4 ---- src/util/config/config.cpp | 32 -------------------------------- 9 files changed, 6 insertions(+), 78 deletions(-) diff --git a/dxvk.conf b/dxvk.conf index dbb0e225..6839cd3d 100644 --- a/dxvk.conf +++ b/dxvk.conf @@ -113,15 +113,6 @@ # d3d9.tearFree = Auto -# Performs range check on dynamically indexed constant buffers in shaders. -# This may be needed to work around a certain type of game bug, but may -# also introduce incorrect behaviour. -# -# Supported values: True, False - -# d3d11.constantBufferRangeCheck = False - - # Assume single-use mode for command lists created on deferred contexts. # This may need to be disabled for some applications to avoid rendering # issues, which may come at a significant performance cost. diff --git a/src/d3d11/d3d11_buffer.cpp b/src/d3d11/d3d11_buffer.cpp index eb72fc1b..c53003a0 100644 --- a/src/d3d11/d3d11_buffer.cpp +++ b/src/d3d11/d3d11_buffer.cpp @@ -37,9 +37,6 @@ namespace dxvk { info.usage |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; info.stages |= m_parent->GetEnabledShaderStages(); info.access |= VK_ACCESS_UNIFORM_READ_BIT; - - if (m_parent->GetOptions()->constantBufferRangeCheck) - info.usage |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; } if (pDesc->BindFlags & D3D11_BIND_SHADER_RESOURCE) { diff --git a/src/d3d11/d3d11_options.cpp b/src/d3d11/d3d11_options.cpp index e78c5198..25e45229 100644 --- a/src/d3d11/d3d11_options.cpp +++ b/src/d3d11/d3d11_options.cpp @@ -35,9 +35,6 @@ namespace dxvk { ? VkDeviceSize(maxDynamicImageBufferSize) << 10 : VkDeviceSize(~0ull); - this->constantBufferRangeCheck = config.getOption("d3d11.constantBufferRangeCheck", false) - && DxvkGpuVendor(devInfo.core.properties.vendorID) != DxvkGpuVendor::Amd; - auto cachedDynamicResources = config.getOption("d3d11.cachedDynamicResources", std::string()); if (::GetModuleHandle("dxgitrace.dll")) { diff --git a/src/d3d11/d3d11_options.h b/src/d3d11/d3d11_options.h index 99353b30..3c3a2616 100644 --- a/src/d3d11/d3d11_options.h +++ b/src/d3d11/d3d11_options.h @@ -24,11 +24,6 @@ namespace dxvk { /// outputs with zero bool enableRtOutputNanFixup; - /// Enables out-of-bounds access check for constant - /// buffers. Workaround for a few broken games that - /// access random data inside their shaders. - bool constantBufferRangeCheck; - /// Zero-initialize workgroup memory /// /// Workargound for games that don't initialize diff --git a/src/dxbc/dxbc_compiler.cpp b/src/dxbc/dxbc_compiler.cpp index b86919a9..2fdf24d7 100644 --- a/src/dxbc/dxbc_compiler.cpp +++ b/src/dxbc/dxbc_compiler.cpp @@ -774,19 +774,15 @@ namespace dxvk { const uint32_t bufferId = ins.dst[0].idx[0].offset; const uint32_t elementCount = ins.dst[0].idx[1].offset; - bool asSsbo = m_moduleInfo.options.dynamicIndexedConstantBufferAsSsbo - && ins.controls.accessType() == DxbcConstantBufferAccessType::DynamicallyIndexed; - this->emitDclConstantBufferVar(bufferId, elementCount, - str::format("cb", bufferId).c_str(), asSsbo); + str::format("cb", bufferId).c_str()); } void DxbcCompiler::emitDclConstantBufferVar( uint32_t regIdx, uint32_t numConstants, - const char* name, - bool asSsbo) { + const char* name) { // Uniform buffer data is stored as a fixed-size array // of 4x32-bit vectors. SPIR-V requires explicit strides. const uint32_t arrayType = m_module.defArrayTypeUnique( @@ -798,9 +794,7 @@ namespace dxvk { // struct and decorate that struct as a block. const uint32_t structType = m_module.defStructTypeUnique(1, &arrayType); - m_module.decorate(structType, asSsbo - ? spv::DecorationBufferBlock - : spv::DecorationBlock); + m_module.decorate(structType, spv::DecorationBlock); m_module.memberDecorateOffset(structType, 0, 0); m_module.setDebugName (structType, str::format(name, "_t").c_str()); @@ -821,20 +815,13 @@ namespace dxvk { m_module.decorateDescriptorSet(varId, 0); m_module.decorateBinding(varId, bindingId); - if (asSsbo) - m_module.decorate(varId, spv::DecorationNonWritable); - DxbcConstantBuffer buf; buf.varId = varId; buf.size = numConstants; m_constantBuffers.at(regIdx) = buf; // Store descriptor info for the shader interface - VkDescriptorType descriptorType = asSsbo - ? VK_DESCRIPTOR_TYPE_STORAGE_BUFFER - : VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; - - DxvkBindingInfo binding = { descriptorType }; + DxvkBindingInfo binding = { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER }; binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM; binding.access = VK_ACCESS_UNIFORM_READ_BIT; binding.resourceBinding = bindingId; @@ -1507,8 +1494,7 @@ namespace dxvk { void DxbcCompiler::emitDclImmediateConstantBufferUbo( uint32_t dwordCount, const uint32_t* dwordArray) { - this->emitDclConstantBufferVar(Icb_BindingSlotId, dwordCount / 4, "icb", - m_moduleInfo.options.dynamicIndexedConstantBufferAsSsbo); + this->emitDclConstantBufferVar(Icb_BindingSlotId, dwordCount / 4, "icb"); m_immConstData.resize(dwordCount * sizeof(uint32_t)); std::memcpy(m_immConstData.data(), dwordArray, m_immConstData.size()); } diff --git a/src/dxbc/dxbc_compiler.h b/src/dxbc/dxbc_compiler.h index b38412cf..af2d00e8 100644 --- a/src/dxbc/dxbc_compiler.h +++ b/src/dxbc/dxbc_compiler.h @@ -583,8 +583,7 @@ namespace dxvk { void emitDclConstantBufferVar( uint32_t regIdx, uint32_t numConstants, - const char* name, - bool asSsbo); + const char* name); void emitDclSampler( const DxbcShaderInstruction& ins); diff --git a/src/dxbc/dxbc_options.cpp b/src/dxbc/dxbc_options.cpp index fc89f74b..df05d3ca 100644 --- a/src/dxbc/dxbc_options.cpp +++ b/src/dxbc/dxbc_options.cpp @@ -42,7 +42,6 @@ namespace dxvk { zeroInitWorkgroupMemory = options.zeroInitWorkgroupMemory; forceTgsmBarriers = options.forceTgsmBarriers; disableMsaa = options.disableMsaa; - dynamicIndexedConstantBufferAsSsbo = options.constantBufferRangeCheck; // Disable subgroup early discard on Nvidia because it may hurt performance if (adapter->matchesDriver(DxvkGpuVendor::Nvidia, VK_DRIVER_ID_NVIDIA_PROPRIETARY_KHR, 0, 0)) diff --git a/src/dxbc/dxbc_options.h b/src/dxbc/dxbc_options.h index d21f3b1a..ed399374 100644 --- a/src/dxbc/dxbc_options.h +++ b/src/dxbc/dxbc_options.h @@ -44,10 +44,6 @@ namespace dxvk { /// Enables NaN fixup for render target outputs bool enableRtOutputNanFixup = false; - /// Implement dynamically indexed uniform buffers - /// with storage buffers for tight bounds checking - bool dynamicIndexedConstantBufferAsSsbo = false; - /// Clear thread-group shared memory to zero bool zeroInitWorkgroupMemory = false; diff --git a/src/util/config/config.cpp b/src/util/config/config.cpp index 0bceb5be..b448cf75 100644 --- a/src/util/config/config.cpp +++ b/src/util/config/config.cpp @@ -107,18 +107,6 @@ namespace dxvk { { R"(\\starwarsbattlefront(trial)?\.exe$)", {{ { "dxgi.nvapiHack", "False" }, }} }, - /* Dark Souls Remastered */ - { R"(\\DarkSoulsRemastered\.exe$)", {{ - { "d3d11.constantBufferRangeCheck", "True" }, - }} }, - /* Grim Dawn */ - { R"(\\Grim Dawn\.exe$)", {{ - { "d3d11.constantBufferRangeCheck", "True" }, - }} }, - /* NieR:Automata */ - { R"(\\NieRAutomata\.exe$)", {{ - { "d3d11.constantBufferRangeCheck", "True" }, - }} }, /* NieR Replicant */ { R"(\\NieR Replicant ver\.1\.22474487139\.exe)", {{ { "dxgi.syncInterval", "1" }, @@ -137,18 +125,6 @@ namespace dxvk { { R"(\\h1_[ms]p64_ship\.exe$)", {{ { "dxgi.customVendorId", "10de" }, }} }, - /* Titan Quest */ - { R"(\\TQ\.exe$)", {{ - { "d3d11.constantBufferRangeCheck", "True" }, - }} }, - /* Saints Row IV */ - { R"(\\SaintsRowIV\.exe$)", {{ - { "d3d11.constantBufferRangeCheck", "True" }, - }} }, - /* Saints Row: The Third */ - { R"(\\SaintsRowTheThird_DX11\.exe$)", {{ - { "d3d11.constantBufferRangeCheck", "True" }, - }} }, /* Crysis 3 - slower if it notices AMD card * * Apitrace mode helps massively in cpu bound * * game parts */ @@ -201,14 +177,6 @@ namespace dxvk { { R"(\\F1_20(1[89]|[2-9][0-9])\.exe$)", {{ { "d3d11.forceTgsmBarriers", "True" }, }} }, - /* Blue Reflection */ - { R"(\\BLUE_REFLECTION\.exe$)", {{ - { "d3d11.constantBufferRangeCheck", "True" }, - }} }, - /* Secret World Legends */ - { R"(\\SecretWorldLegendsDX11\.exe$)", {{ - { "d3d11.constantBufferRangeCheck", "True" }, - }} }, /* Darksiders Warmastered - apparently reads * * from write-only mapped buffers */ { R"(\\darksiders1\.exe$)", {{