From 1f20688f36d448c36fb1276322048489c2e12e5b Mon Sep 17 00:00:00 2001 From: Icohedron Date: Fri, 28 Mar 2025 17:55:34 +0000 Subject: [PATCH 1/2] [NFC] Edit shader flag comments for clarity --- include/dxc/DXIL/DxilConstants.h | 2 +- include/dxc/DXIL/DxilShaderFlags.h | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/dxc/DXIL/DxilConstants.h b/include/dxc/DXIL/DxilConstants.h index 0a9c6a4ffd..9f2c48a3e8 100644 --- a/include/dxc/DXIL/DxilConstants.h +++ b/include/dxc/DXIL/DxilConstants.h @@ -76,7 +76,7 @@ inline bool UpdateToMaxOfVersions(unsigned &major, unsigned &minor, return false; } -// Shader flags. +// Global shader flags const unsigned kDisableOptimizations = 0x00000001; // D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION const unsigned kDisableMathRefactoring = diff --git a/include/dxc/DXIL/DxilShaderFlags.h b/include/dxc/DXIL/DxilShaderFlags.h index 7b065c63fa..b8662aa701 100644 --- a/include/dxc/DXIL/DxilShaderFlags.h +++ b/include/dxc/DXIL/DxilShaderFlags.h @@ -227,6 +227,7 @@ class ShaderFlags { m_bDisableMathRefactoring : 1; //~D3D10_SB_GLOBAL_FLAG_REFACTORING_ALLOWED unsigned m_bEnableDoublePrecision : 1; // D3D11_SB_GLOBAL_FLAG_ENABLE_DOUBLE_PRECISION_FLOAT_OPS + // SHADER_FEATURE_DOUBLES unsigned m_bForceEarlyDepthStencil : 1; // D3D11_SB_GLOBAL_FLAG_FORCE_EARLY_DEPTH_STENCIL @@ -234,10 +235,14 @@ class ShaderFlags { unsigned m_bEnableRawAndStructuredBuffers : 1; // D3D11_SB_GLOBAL_FLAG_ENABLE_RAW_AND_STRUCTURED_BUFFERS unsigned - m_bLowPrecisionPresent : 1; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION + m_bLowPrecisionPresent : 1; // AND ~m_bUseNativeLowPrecision => D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION + // AND ~m_bUseNativeLowPrecision => SHADER_FEATURE_MINIMUM_PRECISION + // AND m_bUseNativeLowPrecision => SHADER_FEATURE_NATIVE_LOW_PRECISION unsigned m_bEnableDoubleExtensions : 1; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_DOUBLE_EXTENSIONS + // SHADER_FEATURE_11_1_DOUBLE_EXTENSIONS unsigned m_bEnableMSAD : 1; // D3D11_1_SB_GLOBAL_FLAG_ENABLE_SHADER_EXTENSIONS + // SHADER_FEATURE_11_1_SHADER_EXTENSIONS // Bit: 8 unsigned m_bAllResourcesBound : 1; // D3D12_SB_GLOBAL_FLAG_ALL_RESOURCES_BOUND @@ -253,8 +258,6 @@ class ShaderFlags { m_bUAVLoadAdditionalFormats : 1; // SHADER_FEATURE_TYPED_UAV_LOAD_ADDITIONAL_FORMATS unsigned m_bLevel9ComparisonFiltering : 1; // SHADER_FEATURE_LEVEL_9_COMPARISON_FILTERING - // SHADER_FEATURE_11_1_SHADER_EXTENSIONS - // shared with EnableMSAD unsigned m_b64UAVs : 1; // SHADER_FEATURE_64_UAVS // Bit: 16 @@ -277,7 +280,7 @@ class ShaderFlags { unsigned m_bBarycentrics : 1; // SHADER_FEATURE_BARYCENTRICS // SM 6.2+ - unsigned m_bUseNativeLowPrecision : 1; + unsigned m_bUseNativeLowPrecision : 1; // see m_bLowPrecisionPresent for uses // SM 6.4+ // Bit: 24 From 151e31892cc475d5c581b8f344c30b6102c46d64 Mon Sep 17 00:00:00 2001 From: Icohedron Date: Sat, 29 Mar 2025 00:23:07 +0000 Subject: [PATCH 2/2] Add a comment to describe the bitmask and to refer to GetFeatureInfo() and GetGlobalFlags() for shader feature and global flags --- include/dxc/DXIL/DxilShaderFlags.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/dxc/DXIL/DxilShaderFlags.h b/include/dxc/DXIL/DxilShaderFlags.h index b8662aa701..06b50f6216 100644 --- a/include/dxc/DXIL/DxilShaderFlags.h +++ b/include/dxc/DXIL/DxilShaderFlags.h @@ -220,6 +220,13 @@ class ShaderFlags { bool GetRequiresGroup() const { return m_bRequiresGroup; } private: + // Each of the shader flags are defined below within a bitfield to form the + // shader flag bitmask of a DXIL module. + // These shader flags are also used to set Shader Feature Info flags via the + // function ShaderFlags::GetFeatureInfo(). + // For DXBC, these shader flags are also used to set Global Flags via the + // function ShaderFlags::GetGlobalFlags(). + // Bit: 0 unsigned m_bDisableOptimizations : 1; // D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION