-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[DirectX][NFC] Refactoring DirectX backend to not use llvm::to_underlying
in switch cases.
#151032
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
Closed
joaosaffran
wants to merge
13
commits into
llvm:main
from
joaosaffran:refactoring/remove_to_undeling
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ea35c41
remove the to_undernlying switch
3c1fc51
remove comment
591d12a
remove compiling errors
0d55d28
improve comment, maybe
7841a83
Merge branch 'main' into refactoring/remove_to_undeling
joaosaffran 98be089
Merge branch 'main' into refactoring/remove_to_undeling
25ee6d7
fixing merge issues
94fef90
Merge branch 'main' into refactoring/remove_to_undeling
3924438
fix
5f26016
finish changing
c975cc2
fix tests
joaosaffran 1d080aa
Merge branch 'main' into refactoring/remove_to_undeling
joaosaffran 3b5f497
clean up
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -200,9 +200,9 @@ enum class DescriptorRangeType : uint32_t { | |||||
LLVM_ABI ArrayRef<EnumEntry<DescriptorRangeType>> getDescriptorRangeTypes(); | ||||||
|
||||||
#define ROOT_PARAMETER(Val, Enum) \ | ||||||
case Val: \ | ||||||
case dxbc::RootParameterType::Enum: \ | ||||||
return true; | ||||||
inline bool isValidParameterType(uint32_t V) { | ||||||
inline bool isValidParameterType(dxbc::RootParameterType V) { | ||||||
switch (V) { | ||||||
#include "DXContainerConstants.def" | ||||||
} | ||||||
|
@@ -217,9 +217,9 @@ enum class ShaderVisibility : uint32_t { | |||||
LLVM_ABI ArrayRef<EnumEntry<ShaderVisibility>> getShaderVisibility(); | ||||||
|
||||||
#define SHADER_VISIBILITY(Val, Enum) \ | ||||||
case Val: \ | ||||||
case dxbc::ShaderVisibility::Enum: \ | ||||||
return true; | ||||||
inline bool isValidShaderVisibility(uint32_t V) { | ||||||
inline bool isValidShaderVisibility(dxbc::ShaderVisibility V) { | ||||||
switch (V) { | ||||||
#include "DXContainerConstants.def" | ||||||
} | ||||||
|
@@ -254,6 +254,14 @@ enum class StaticBorderColor : uint32_t { | |||||
|
||||||
LLVM_ABI ArrayRef<EnumEntry<StaticBorderColor>> getStaticBorderColors(); | ||||||
|
||||||
// D3D_ROOT_SIGNATURE_VERSION | ||||||
enum class RootSignatureVersion { | ||||||
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.
Suggested change
|
||||||
V1_0 = 0x1, | ||||||
V1_1 = 0x2, | ||||||
}; | ||||||
|
||||||
LLVM_ABI ArrayRef<EnumEntry<RootSignatureVersion>> getRootSignatureVersions(); | ||||||
|
||||||
LLVM_ABI PartType parsePartType(StringRef S); | ||||||
|
||||||
struct VertexPSVInfo { | ||||||
|
@@ -646,19 +654,19 @@ static_assert(sizeof(ProgramSignatureElement) == 32, | |||||
namespace RTS0 { | ||||||
namespace v1 { | ||||||
struct StaticSampler { | ||||||
uint32_t Filter; | ||||||
uint32_t AddressU; | ||||||
uint32_t AddressV; | ||||||
uint32_t AddressW; | ||||||
dxbc::SamplerFilter Filter; | ||||||
dxbc::TextureAddressMode AddressU; | ||||||
dxbc::TextureAddressMode AddressV; | ||||||
dxbc::TextureAddressMode AddressW; | ||||||
float MipLODBias; | ||||||
uint32_t MaxAnisotropy; | ||||||
uint32_t ComparisonFunc; | ||||||
uint32_t BorderColor; | ||||||
dxbc::ComparisonFunc ComparisonFunc; | ||||||
dxbc::StaticBorderColor BorderColor; | ||||||
float MinLOD; | ||||||
float MaxLOD; | ||||||
uint32_t ShaderRegister; | ||||||
uint32_t RegisterSpace; | ||||||
uint32_t ShaderVisibility; | ||||||
dxbc::ShaderVisibility ShaderVisibility; | ||||||
void swapBytes() { | ||||||
sys::swapByteOrder(Filter); | ||||||
sys::swapByteOrder(AddressU); | ||||||
|
@@ -677,7 +685,7 @@ struct StaticSampler { | |||||
}; | ||||||
|
||||||
struct DescriptorRange { | ||||||
uint32_t RangeType; | ||||||
dxbc::DescriptorRangeType RangeType; | ||||||
uint32_t NumDescriptors; | ||||||
uint32_t BaseShaderRegister; | ||||||
uint32_t RegisterSpace; | ||||||
|
@@ -715,8 +723,8 @@ struct RootConstants { | |||||
}; | ||||||
|
||||||
struct RootParameterHeader { | ||||||
uint32_t ParameterType; | ||||||
uint32_t ShaderVisibility; | ||||||
dxbc::RootParameterType ParameterType; | ||||||
dxbc::ShaderVisibility ShaderVisibility; | ||||||
uint32_t ParameterOffset; | ||||||
|
||||||
void swapBytes() { | ||||||
|
@@ -760,7 +768,7 @@ struct RootDescriptor : public v1::RootDescriptor { | |||||
}; | ||||||
|
||||||
struct DescriptorRange { | ||||||
uint32_t RangeType; | ||||||
dxbc::DescriptorRangeType RangeType; | ||||||
uint32_t NumDescriptors; | ||||||
uint32_t BaseShaderRegister; | ||||||
uint32_t RegisterSpace; | ||||||
|
@@ -778,12 +786,6 @@ struct DescriptorRange { | |||||
} // namespace v2 | ||||||
} // namespace RTS0 | ||||||
|
||||||
// D3D_ROOT_SIGNATURE_VERSION | ||||||
enum class RootSignatureVersion { | ||||||
V1_0 = 0x1, | ||||||
V1_1 = 0x2, | ||||||
}; | ||||||
|
||||||
} // namespace dxbc | ||||||
} // namespace llvm | ||||||
|
||||||
|
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 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -28,9 +28,9 @@ class Metadata; | |||||||||||||
namespace hlsl { | ||||||||||||||
namespace rootsig { | ||||||||||||||
|
||||||||||||||
template <typename T> | ||||||||||||||
template <typename T, typename ET = T> | ||||||||||||||
class RootSignatureValidationError | ||||||||||||||
: public ErrorInfo<RootSignatureValidationError<T>> { | ||||||||||||||
: public ErrorInfo<RootSignatureValidationError<T, ET>> { | ||||||||||||||
public: | ||||||||||||||
static char ID; | ||||||||||||||
StringRef ParamName; | ||||||||||||||
|
@@ -40,7 +40,7 @@ class RootSignatureValidationError | |||||||||||||
: ParamName(ParamName), Value(Value) {} | ||||||||||||||
|
||||||||||||||
void log(raw_ostream &OS) const override { | ||||||||||||||
OS << "Invalid value for " << ParamName << ": " << Value; | ||||||||||||||
OS << "Invalid value for " << ParamName << ": " << static_cast<ET>(Value); | ||||||||||||||
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. We can probably eliminate the
Suggested change
|
||||||||||||||
} | ||||||||||||||
|
||||||||||||||
std::error_code convertToErrorCode() const override { | ||||||||||||||
|
@@ -143,7 +143,7 @@ class MetadataParser { | |||||||||||||
MetadataParser(MDNode *Root) : Root(Root) {} | ||||||||||||||
|
||||||||||||||
LLVM_ABI llvm::Expected<llvm::mcdxbc::RootSignatureDesc> | ||||||||||||||
ParseRootSignature(uint32_t Version); | ||||||||||||||
ParseRootSignature(dxbc::RootSignatureVersion Version); | ||||||||||||||
|
||||||||||||||
private: | ||||||||||||||
llvm::Error parseRootFlags(mcdxbc::RootSignatureDesc &RSD, | ||||||||||||||
|
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
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 seems like a hack used to print the minor version number. We should instead have a better enum->string conversion that can produce the correct version number.