-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[DirectX] Removing dxbc DescriptorRange from mcbxdc #154629
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
joaosaffran
merged 27 commits into
llvm:main
from
joaosaffran:refactoring/updating-descriptor-range
Sep 10, 2025
Merged
Changes from 14 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
31ec5e5
making parameter type and shader visibility use enums
joaosaffran 1690a9c
clean up
joaosaffran f6f2e61
removing root parameter header from MC
joaosaffran 6539364
clean up
joaosaffran 1d29111
fix whitespace in test
joaosaffran 8eb82fd
adding missing import
joaosaffran d38c00d
remove unused
joaosaffran 3b25b34
save a copy
joaosaffran 567a3d4
remove default constructor
joaosaffran fb248da
rename visibility
joaosaffran dc436d5
remove cstdint
joaosaffran 8353fe0
remove Loc
joaosaffran f3ecd8a
removing dependency of Object
joaosaffran 8c143ba
removing binary format descriptor range dependency
joaosaffran a4d77d7
Revert "removing binary format descriptor range dependency"
joaosaffran 19ec1c3
Merge branch 'main' into refactoring/updating-descriptor-range
joaosaffran 182c817
removing binary format descriptor range dependency
joaosaffran f9d16d2
creating toDescriptorRange and change verifyDescriptorRangeFlag signa…
joaosaffran 42f8f11
adding test and removing string switch
joaosaffran 7ada31b
removing copy
joaosaffran fa60959
clean up
joaosaffran e065a82
removing function I thought I needed
joaosaffran 17dbe9f
refactoring to use dxil::ResourceClass for range type
joaosaffran 5c23b7e
adding assert
joaosaffran 1c539f0
changing casting to use proper llvm-casting
joaosaffran 4074ceb
removing unused code
joaosaffran 36afa22
removing assert and adding lastEntry
joaosaffran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,75 +19,88 @@ namespace llvm { | |
class raw_ostream; | ||
namespace mcdxbc { | ||
|
||
struct RootConstants { | ||
uint32_t ShaderRegister; | ||
uint32_t RegisterSpace; | ||
uint32_t Num32BitValues; | ||
}; | ||
|
||
struct RootDescriptor { | ||
uint32_t ShaderRegister; | ||
uint32_t RegisterSpace; | ||
uint32_t Flags; | ||
}; | ||
|
||
struct DescriptorRange { | ||
dxbc::DescriptorRangeType RangeType; | ||
uint32_t NumDescriptors; | ||
uint32_t BaseShaderRegister; | ||
uint32_t RegisterSpace; | ||
uint32_t Flags; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided to keep the flags as |
||
uint32_t OffsetInDescriptorsFromTableStart; | ||
}; | ||
|
||
struct RootParameterInfo { | ||
dxbc::RTS0::v1::RootParameterHeader Header; | ||
dxbc::RootParameterType Type; | ||
dxbc::ShaderVisibility Visibility; | ||
size_t Location; | ||
|
||
RootParameterInfo() = default; | ||
|
||
RootParameterInfo(dxbc::RTS0::v1::RootParameterHeader Header, size_t Location) | ||
: Header(Header), Location(Location) {} | ||
RootParameterInfo(dxbc::RootParameterType Type, | ||
dxbc::ShaderVisibility Visibility, size_t Location) | ||
: Type(Type), Visibility(Visibility), Location(Location) {} | ||
}; | ||
|
||
struct DescriptorTable { | ||
SmallVector<dxbc::RTS0::v2::DescriptorRange> Ranges; | ||
SmallVector<dxbc::RTS0::v2::DescriptorRange>::const_iterator begin() const { | ||
SmallVector<DescriptorRange> Ranges; | ||
SmallVector<DescriptorRange>::const_iterator begin() const { | ||
return Ranges.begin(); | ||
} | ||
SmallVector<dxbc::RTS0::v2::DescriptorRange>::const_iterator end() const { | ||
SmallVector<DescriptorRange>::const_iterator end() const { | ||
return Ranges.end(); | ||
} | ||
}; | ||
|
||
struct RootParametersContainer { | ||
SmallVector<RootParameterInfo> ParametersInfo; | ||
|
||
SmallVector<dxbc::RTS0::v1::RootConstants> Constants; | ||
SmallVector<dxbc::RTS0::v2::RootDescriptor> Descriptors; | ||
SmallVector<RootConstants> Constants; | ||
SmallVector<RootDescriptor> Descriptors; | ||
SmallVector<DescriptorTable> Tables; | ||
|
||
void addInfo(dxbc::RTS0::v1::RootParameterHeader Header, size_t Location) { | ||
ParametersInfo.push_back(RootParameterInfo(Header, Location)); | ||
void addInfo(dxbc::RootParameterType Type, dxbc::ShaderVisibility Visibility, | ||
size_t Location) { | ||
ParametersInfo.emplace_back(Type, Visibility, Location); | ||
} | ||
|
||
void addParameter(dxbc::RTS0::v1::RootParameterHeader Header, | ||
dxbc::RTS0::v1::RootConstants Constant) { | ||
addInfo(Header, Constants.size()); | ||
void addParameter(dxbc::RootParameterType Type, | ||
dxbc::ShaderVisibility Visibility, RootConstants Constant) { | ||
addInfo(Type, Visibility, Constants.size()); | ||
Constants.push_back(Constant); | ||
} | ||
|
||
void addInvalidParameter(dxbc::RTS0::v1::RootParameterHeader Header) { | ||
addInfo(Header, -1); | ||
} | ||
|
||
void addParameter(dxbc::RTS0::v1::RootParameterHeader Header, | ||
dxbc::RTS0::v2::RootDescriptor Descriptor) { | ||
addInfo(Header, Descriptors.size()); | ||
void addParameter(dxbc::RootParameterType Type, | ||
dxbc::ShaderVisibility Visibility, | ||
RootDescriptor Descriptor) { | ||
addInfo(Type, Visibility, Descriptors.size()); | ||
Descriptors.push_back(Descriptor); | ||
} | ||
|
||
void addParameter(dxbc::RTS0::v1::RootParameterHeader Header, | ||
DescriptorTable Table) { | ||
addInfo(Header, Tables.size()); | ||
void addParameter(dxbc::RootParameterType Type, | ||
dxbc::ShaderVisibility Visibility, DescriptorTable Table) { | ||
addInfo(Type, Visibility, Tables.size()); | ||
Tables.push_back(Table); | ||
} | ||
|
||
std::pair<uint32_t, uint32_t> | ||
getTypeAndLocForParameter(uint32_t Location) const { | ||
const RootParameterInfo &Info = ParametersInfo[Location]; | ||
return {Info.Header.ParameterType, Info.Location}; | ||
} | ||
|
||
const dxbc::RTS0::v1::RootParameterHeader &getHeader(size_t Location) const { | ||
const RootParameterInfo &getInfo(uint32_t Location) const { | ||
const RootParameterInfo &Info = ParametersInfo[Location]; | ||
return Info.Header; | ||
return Info; | ||
} | ||
|
||
const dxbc::RTS0::v1::RootConstants &getConstant(size_t Index) const { | ||
const RootConstants &getConstant(size_t Index) const { | ||
return Constants[Index]; | ||
} | ||
|
||
const dxbc::RTS0::v2::RootDescriptor &getRootDescriptor(size_t Index) const { | ||
const RootDescriptor &getRootDescriptor(size_t Index) const { | ||
return Descriptors[Index]; | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,6 +149,16 @@ ArrayRef<EnumEntry<RootParameterType>> dxbc::getRootParameterTypes() { | |
return ArrayRef(RootParameterTypes); | ||
} | ||
|
||
#define DESCRIPTOR_RANGE(Val, Enum) {#Enum, DescriptorRangeType::Enum}, | ||
|
||
static const EnumEntry<DescriptorRangeType> DescriptorRangeTypes[] = { | ||
#include "llvm/BinaryFormat/DXContainerConstants.def" | ||
}; | ||
|
||
ArrayRef<EnumEntry<DescriptorRangeType>> dxbc::getDescriptorRangeTypes() { | ||
|
||
return ArrayRef(DescriptorRangeTypes); | ||
} | ||
|
||
#define SEMANTIC_KIND(Val, Enum) {#Enum, PSV::SemanticKind::Enum}, | ||
|
||
static const EnumEntry<PSV::SemanticKind> SemanticKindNames[] = { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be simpler with a
toDescriptorRangeType()
helper (whether as a static function or even just a lambda). Also, the flags argument toverifyDescriptorRangeFlag
looks like it's just immediately cast back to a dxbc::DescriptorRangeFlags - we should just update the signature to take the enum in the first place.