From d94d89c3ef1a9b4134e8e63abb5e9bce3e70acd4 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 15 May 2019 18:49:02 +0200 Subject: [PATCH] [dxbc] Add option to use subgroup ops for atomic counter operations This can greatly reduce the number of atomic operations when using append/consume buffers. --- src/dxbc/dxbc_options.cpp | 5 +++++ src/dxbc/dxbc_options.h | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/dxbc/dxbc_options.cpp b/src/dxbc/dxbc_options.cpp index 1189689e..6d35400b 100644 --- a/src/dxbc/dxbc_options.cpp +++ b/src/dxbc/dxbc_options.cpp @@ -14,11 +14,16 @@ namespace dxvk { const DxvkDeviceFeatures& devFeatures = device->features(); const DxvkDeviceInfo& devInfo = adapter->devicePropertiesExt(); + + const VkShaderStageFlags allShaderStages = device->getShaderPipelineStages(); useDepthClipWorkaround = !devFeatures.extDepthClipEnable.depthClipEnable; useStorageImageReadWithoutFormat = devFeatures.core.features.shaderStorageImageReadWithoutFormat; + useSubgroupOpsForAtomicCounters + = (devInfo.coreSubgroup.supportedStages & allShaderStages) == allShaderStages + && (devInfo.coreSubgroup.supportedOperations & VK_SUBGROUP_FEATURE_BALLOT_BIT); useSubgroupOpsForEarlyDiscard = (devInfo.coreSubgroup.subgroupSize >= 4) && (devInfo.coreSubgroup.supportedStages & VK_SHADER_STAGE_FRAGMENT_BIT) diff --git a/src/dxbc/dxbc_options.h b/src/dxbc/dxbc_options.h index c109ed92..5846756b 100644 --- a/src/dxbc/dxbc_options.h +++ b/src/dxbc/dxbc_options.h @@ -17,6 +17,10 @@ namespace dxvk { /// Use the ShaderImageReadWithoutFormat capability. bool useStorageImageReadWithoutFormat = false; + /// Use subgroup operations to reduce the number of + /// atomic operations for append/consume buffers. + bool useSubgroupOpsForAtomicCounters = false; + /// Use subgroup operations to discard fragment /// shader invocations if derivatives remain valid. bool useSubgroupOpsForEarlyDiscard = false;