Skip to content

[DXContainer] Update DXContainer to match D3D12 spec #143201

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

Conversation

joaosaffran
Copy link
Contributor

@joaosaffran joaosaffran commented Jun 6, 2025

Update the descriptor range flag values in DXContainerConstants.def to match
the Direct3D12 specification. This changes two aspects:

  1. Modify the DESCRIPTOR_RANGE_FLAG macro to use direct values instead of
    bit shifts
  2. Update the flag values to use hex notation and match D3D12's
    D3D12_DESCRIPTOR_RANGE_FLAGS enumeration:
    • DESCRIPTORS_VOLATILE: 0x1
    • DATA_VOLATILE: 0x2
    • DATA_STATIC_WHILE_SET_AT_EXECUTE: 0x4
    • DATA_STATIC: 0x8
    • DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS: 0x10000
  3. Removed NONE value from ROOT_DESCRIPTOR_FLAG

This ensures better compatibility with the D3D12 API and makes the values
more explicit in the code.

Requested here: #138315 (comment)

@llvmbot
Copy link
Member

llvmbot commented Jun 6, 2025

@llvm/pr-subscribers-backend-directx

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

Author: None (joaosaffran)

Changes

Update the descriptor range flag values in DXContainerConstants.def to match
the Direct3D12 specification. This changes two aspects:

  1. Modify the DESCRIPTOR_RANGE_FLAG macro to use direct values instead of
    bit shifts
  2. Update the flag values to use hex notation and match D3D12's
    D3D12_DESCRIPTOR_RANGE_FLAGS enumeration:
    • DESCRIPTORS_VOLATILE: 0x1
    • DATA_VOLATILE: 0x2
    • DATA_STATIC_WHILE_SET_AT_EXECUTE: 0x4
    • DATA_STATIC: 0x8
    • DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS: 0x10000

This ensures better compatibility with the D3D12 API and makes the values
more explicit in the code.

Requested here: #138315 (comment)


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

2 Files Affected:

  • (modified) llvm/include/llvm/BinaryFormat/DXContainer.h (+1-1)
  • (modified) llvm/include/llvm/BinaryFormat/DXContainerConstants.def (+5-5)
diff --git a/llvm/include/llvm/BinaryFormat/DXContainer.h b/llvm/include/llvm/BinaryFormat/DXContainer.h
index 08949e39716d5..725c405b77e55 100644
--- a/llvm/include/llvm/BinaryFormat/DXContainer.h
+++ b/llvm/include/llvm/BinaryFormat/DXContainer.h
@@ -164,7 +164,7 @@ enum class RootDescriptorFlag : uint32_t {
 #include "DXContainerConstants.def"
 };
 
-#define DESCRIPTOR_RANGE_FLAG(Num, Val) Val = 1ull << Num,
+#define DESCRIPTOR_RANGE_FLAG(Num, Val) Val = Num,
 enum class DescriptorRangeFlag : uint32_t {
 #include "DXContainerConstants.def"
 };
diff --git a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
index 501ef0c31cdd0..c4895ee8ed655 100644
--- a/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
+++ b/llvm/include/llvm/BinaryFormat/DXContainerConstants.def
@@ -90,11 +90,11 @@ ROOT_DESCRIPTOR_FLAG(3, DATA_STATIC)
 #ifdef DESCRIPTOR_RANGE_FLAG
 
 DESCRIPTOR_RANGE_FLAG(0, NONE)
-DESCRIPTOR_RANGE_FLAG(1, DESCRIPTORS_VOLATILE)
-DESCRIPTOR_RANGE_FLAG(2, DATA_VOLATILE)
-DESCRIPTOR_RANGE_FLAG(3, DATA_STATIC_WHILE_SET_AT_EXECUTE)
-DESCRIPTOR_RANGE_FLAG(4, DATA_STATIC)
-DESCRIPTOR_RANGE_FLAG(16, DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS)
+DESCRIPTOR_RANGE_FLAG(0x1, DESCRIPTORS_VOLATILE)
+DESCRIPTOR_RANGE_FLAG(0x2, DATA_VOLATILE)
+DESCRIPTOR_RANGE_FLAG(0x4, DATA_STATIC_WHILE_SET_AT_EXECUTE)
+DESCRIPTOR_RANGE_FLAG(0x8, DATA_STATIC)
+DESCRIPTOR_RANGE_FLAG(0x10000, DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS)
 #undef DESCRIPTOR_RANGE_FLAG
 #endif // DESCRIPTOR_RANGE_FLAG
 

@joaosaffran joaosaffran changed the title [DXContainer] Update DXContainer descriptor range flag values to match D3D12 spec [DXContainer] Update DXContainer to match D3D12 spec Jun 11, 2025
@joaosaffran joaosaffran requested a review from inbelic June 12, 2025 18:23
@joaosaffran joaosaffran merged commit 2ab9c35 into llvm:main Jun 17, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants