Skip to content

[DirectX] Revise descriptions of DXIL module flags #133543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 29, 2025

Conversation

Icohedron
Copy link
Contributor

This PR revises the descriptions of DXIL module flags.

Descriptions such as D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION are referring to Global Flags in DXBC.
DXBC is not a supported backend target, so references to DXBC should not be present.

There is also confusion with regards to the description of the LowPrecisionPresent DXIL module flag, which currently reads D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION and implies the use of minimum-precision to handle 16-bit types.
However this is not true, because both the flags LowPrecisionPresent and UseNativeLowPrecision can simultaneously be set in the same DXIL module, and minimum precision mode is mutually exclusive with native low precision.
This PR revises the description of the LowPrecisionPresent flag to accurately describe what it represents.

@llvmbot
Copy link
Member

llvmbot commented Mar 28, 2025

@llvm/pr-subscribers-objectyaml
@llvm/pr-subscribers-backend-directx

@llvm/pr-subscribers-llvm-binary-utilities

Author: Deric C. (Icohedron)

Changes

This PR revises the descriptions of DXIL module flags.

Descriptions such as D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION are referring to Global Flags in DXBC.
DXBC is not a supported backend target, so references to DXBC should not be present.

There is also confusion with regards to the description of the LowPrecisionPresent DXIL module flag, which currently reads D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION and implies the use of minimum-precision to handle 16-bit types.
However this is not true, because both the flags LowPrecisionPresent and UseNativeLowPrecision can simultaneously be set in the same DXIL module, and minimum precision mode is mutually exclusive with native low precision.
This PR revises the description of the LowPrecisionPresent flag to accurately describe what it represents.


Full diff: https://github.com/llvm/llvm-project/pull/133543.diff

5 Files Affected:

  • (modified) llvm/include/llvm/BinaryFormat/DXContainerConstants.def (+8-8)
  • (modified) llvm/test/CodeGen/DirectX/ShaderFlags/disable-opt-cs.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/ShaderFlags/disable-opt-lib.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/ShaderFlags/low-precision.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/ShaderFlags/raw-and-structured-buffers.ll (+1-1)
diff --git a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
index 6d44ea14df444..8bf7048df1b56 100644
--- a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
+++ b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
@@ -17,7 +17,7 @@ CONTAINER_PART(PSG1)
 // SHADER_FEATURE_FLAG(bit offset for the shader info flag, bit offset for DXIL module flag, name, description.
 
 SHADER_FEATURE_FLAG(0,   2, Doubles, "Double-precision floating point")
-SHADER_FEATURE_FLAG(1,  17, ComputeShadersPlusRawAndStructuredBuffers, "Raw and Structured buffers")
+SHADER_FEATURE_FLAG(1,  17, ComputeShadersPlusRawAndStructuredBuffers, "CS4 raw and structured buffers")
 SHADER_FEATURE_FLAG(2,  16, UAVsAtEveryStage, "UAVs at every shader stage")
 SHADER_FEATURE_FLAG(3,  15, Max64UAVs, "64 UAV slots")
 SHADER_FEATURE_FLAG(4,  -1, MinimumPrecision, "Minimum-precision data types")
@@ -76,13 +76,13 @@ ROOT_ELEMENT_FLAG(11, SamplerHeapDirectlyIndexed)
 #ifdef DXIL_MODULE_FLAG
 
 // Only save DXIL module flags which not map to feature flags here.
-DXIL_MODULE_FLAG( 0,  DisableOptimizations,   "D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION")
-DXIL_MODULE_FLAG( 1,  DisableMathRefactoring, "D3D10_SB_GLOBAL_FLAG_REFACTORING_ALLOWED")
-DXIL_MODULE_FLAG( 3,  ForceEarlyDepthStencil, "D3D11_SB_GLOBAL_FLAG_FORCE_EARLY_DEPTH_STENCIL")
-DXIL_MODULE_FLAG( 4,  EnableRawAndStructuredBuffers, "Raw and Structured buffers")
-DXIL_MODULE_FLAG( 5,  LowPrecisionPresent, "D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION")
-DXIL_MODULE_FLAG( 8,  AllResourcesBound, "D3D12_SB_GLOBAL_FLAG_ALL_RESOURCES_BOUND")
-DXIL_MODULE_FLAG(23,  UseNativeLowPrecision, "Native 16bit types enabled")
+DXIL_MODULE_FLAG( 0,  DisableOptimizations,   "Disable shader optimizations")
+DXIL_MODULE_FLAG( 1,  DisableMathRefactoring, "Disable math refactoring")
+DXIL_MODULE_FLAG( 3,  ForceEarlyDepthStencil, "Force early depth-stencil test")
+DXIL_MODULE_FLAG( 4,  EnableRawAndStructuredBuffers, "Raw and structured buffers")
+DXIL_MODULE_FLAG( 5,  LowPrecisionPresent, "Low-precision data types")
+DXIL_MODULE_FLAG( 8,  AllResourcesBound, "All resources bound")
+DXIL_MODULE_FLAG(23,  UseNativeLowPrecision, "Native 16-bit types enabled")
 DXIL_MODULE_FLAG(33,  ResMayNotAlias, "Any UAV may not alias any other UAV")
 
 #undef DXIL_MODULE_FLAG
diff --git a/llvm/test/CodeGen/DirectX/ShaderFlags/disable-opt-cs.ll b/llvm/test/CodeGen/DirectX/ShaderFlags/disable-opt-cs.ll
index 421c8b67350c2..8bf242fdbec67 100644
--- a/llvm/test/CodeGen/DirectX/ShaderFlags/disable-opt-cs.ll
+++ b/llvm/test/CodeGen/DirectX/ShaderFlags/disable-opt-cs.ll
@@ -5,7 +5,7 @@
 ; CHECK-NEXT: ; Shader Flags Value: 0x00000001
 
 ; CHECK: ; Note: extra DXIL module flags:
-; CHECK-NEXT: ;       D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION
+; CHECK-NEXT: ;       Disable shader optimizations
 
 ; CHECK: ; Shader Flags for Module Functions
 ; CHECK: ; Function main : 0x00000000
diff --git a/llvm/test/CodeGen/DirectX/ShaderFlags/disable-opt-lib.ll b/llvm/test/CodeGen/DirectX/ShaderFlags/disable-opt-lib.ll
index 240bd314cd1b2..3bf582cc2e255 100644
--- a/llvm/test/CodeGen/DirectX/ShaderFlags/disable-opt-lib.ll
+++ b/llvm/test/CodeGen/DirectX/ShaderFlags/disable-opt-lib.ll
@@ -5,7 +5,7 @@
 ; CHECK-NEXT: ; Shader Flags Value: 0x00000001
 
 ; CHECK: ; Note: extra DXIL module flags:
-; CHECK-NEXT: ;       D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION
+; CHECK-NEXT: ;       Disable shader optimizations
 
 ; CHECK: ; Shader Flags for Module Functions
 ; CHECK: ; Function main : 0x00000000
diff --git a/llvm/test/CodeGen/DirectX/ShaderFlags/low-precision.ll b/llvm/test/CodeGen/DirectX/ShaderFlags/low-precision.ll
index fd25a165bfe8d..73f1d5d2456af 100644
--- a/llvm/test/CodeGen/DirectX/ShaderFlags/low-precision.ll
+++ b/llvm/test/CodeGen/DirectX/ShaderFlags/low-precision.ll
@@ -8,7 +8,7 @@ target triple = "dxil-pc-shadermodel6.7-library"
 ;CHECK-NEXT: ;
 ;CHECK-NEXT: ; Note: shader requires additional functionality:
 ;CHECK-NEXT: ; Note: extra DXIL module flags:
-;CHECK-NEXT: ;       D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION
+;CHECK-NEXT: ;       Low-precision data types
 ;CHECK-NEXT: ;
 ;CHECK-NEXT: ; Shader Flags for Module Functions
 
diff --git a/llvm/test/CodeGen/DirectX/ShaderFlags/raw-and-structured-buffers.ll b/llvm/test/CodeGen/DirectX/ShaderFlags/raw-and-structured-buffers.ll
index 9cb83c4e992ba..03112b60c8811 100644
--- a/llvm/test/CodeGen/DirectX/ShaderFlags/raw-and-structured-buffers.ll
+++ b/llvm/test/CodeGen/DirectX/ShaderFlags/raw-and-structured-buffers.ll
@@ -9,7 +9,7 @@ target triple = "dxil-pc-shadermodel6.7-library"
 ; CHECK-NEXT: Shader Flags Value: 0x00000010
 
 ; CHECK: Note: shader requires additional functionality:
-; CHECK:       Raw and Structured buffers
+; CHECK:       Raw and structured buffers
 
 ; CHECK: Function rawbuf : 0x00000010
 define float @rawbuf() "hlsl.export" {

@@ -17,7 +17,7 @@ CONTAINER_PART(PSG1)
// SHADER_FEATURE_FLAG(bit offset for the shader info flag, bit offset for DXIL module flag, name, description.

SHADER_FEATURE_FLAG(0, 2, Doubles, "Double-precision floating point")
SHADER_FEATURE_FLAG(1, 17, ComputeShadersPlusRawAndStructuredBuffers, "Raw and Structured buffers")
SHADER_FEATURE_FLAG(1, 17, ComputeShadersPlusRawAndStructuredBuffers, "CS4 raw and structured buffers")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does CS4 mean/denote? We are also not currently checking for it in the FileCheck

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Compute Shader in Shader Model 4.x.

Clang isn't going to support SM 4.x (AFAIK), so there shouldn't be a need to test for it.

@Icohedron
Copy link
Contributor Author

I pushed a new commit that alters the descriptions of the shader flags to match the PR for an update to the DXIL documentation in the DXC repository: microsoft/DirectXShaderCompiler#7295

@Icohedron Icohedron changed the title [DirectX] [NFC] Revise descriptions of DXIL module flags [DirectX] Revise descriptions of DXIL module flags Apr 3, 2025
@Icohedron Icohedron merged commit ad66e54 into llvm:main Apr 29, 2025
9 of 12 checks passed
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
This PR revises the descriptions of DXIL module flags.

Descriptions such as `D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION` are
referring to Global Flags in DXBC.
DXBC is not a supported backend target, so references to DXBC should not
be present.

There is also confusion with regards to the description of the
`LowPrecisionPresent` DXIL module flag, which currently reads
`D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION` and implies the use of
minimum-precision to handle 16-bit types.
However this is not true, because both the flags `LowPrecisionPresent`
and `UseNativeLowPrecision` can simultaneously be set in the same DXIL
module, and minimum precision mode is mutually exclusive with native low
precision.
This PR revises the description of the `LowPrecisionPresent` flag to
accurately describe what it represents.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
This PR revises the descriptions of DXIL module flags.

Descriptions such as `D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION` are
referring to Global Flags in DXBC.
DXBC is not a supported backend target, so references to DXBC should not
be present.

There is also confusion with regards to the description of the
`LowPrecisionPresent` DXIL module flag, which currently reads
`D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION` and implies the use of
minimum-precision to handle 16-bit types.
However this is not true, because both the flags `LowPrecisionPresent`
and `UseNativeLowPrecision` can simultaneously be set in the same DXIL
module, and minimum precision mode is mutually exclusive with native low
precision.
This PR revises the description of the `LowPrecisionPresent` flag to
accurately describe what it represents.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
This PR revises the descriptions of DXIL module flags.

Descriptions such as `D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION` are
referring to Global Flags in DXBC.
DXBC is not a supported backend target, so references to DXBC should not
be present.

There is also confusion with regards to the description of the
`LowPrecisionPresent` DXIL module flag, which currently reads
`D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION` and implies the use of
minimum-precision to handle 16-bit types.
However this is not true, because both the flags `LowPrecisionPresent`
and `UseNativeLowPrecision` can simultaneously be set in the same DXIL
module, and minimum precision mode is mutually exclusive with native low
precision.
This PR revises the description of the `LowPrecisionPresent` flag to
accurately describe what it represents.
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
This PR revises the descriptions of DXIL module flags.

Descriptions such as `D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION` are
referring to Global Flags in DXBC.
DXBC is not a supported backend target, so references to DXBC should not
be present.

There is also confusion with regards to the description of the
`LowPrecisionPresent` DXIL module flag, which currently reads
`D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION` and implies the use of
minimum-precision to handle 16-bit types.
However this is not true, because both the flags `LowPrecisionPresent`
and `UseNativeLowPrecision` can simultaneously be set in the same DXIL
module, and minimum precision mode is mutually exclusive with native low
precision.
This PR revises the description of the `LowPrecisionPresent` flag to
accurately describe what it represents.
Ankur-0429 pushed a commit to Ankur-0429/llvm-project that referenced this pull request May 9, 2025
This PR revises the descriptions of DXIL module flags.

Descriptions such as `D3D11_1_SB_GLOBAL_FLAG_SKIP_OPTIMIZATION` are
referring to Global Flags in DXBC.
DXBC is not a supported backend target, so references to DXBC should not
be present.

There is also confusion with regards to the description of the
`LowPrecisionPresent` DXIL module flag, which currently reads
`D3D11_1_SB_GLOBAL_FLAG_ENABLE_MINIMUM_PRECISION` and implies the use of
minimum-precision to handle 16-bit types.
However this is not true, because both the flags `LowPrecisionPresent`
and `UseNativeLowPrecision` can simultaneously be set in the same DXIL
module, and minimum precision mode is mutually exclusive with native low
precision.
This PR revises the description of the `LowPrecisionPresent` flag to
accurately describe what it represents.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

5 participants