-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[DirectX] Updating DXContainer Yaml to represent Root Signature 1.2 #159659
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
Changes from 6 commits
787c776
57fd710
d72adfe
23803b7
367ac8c
a08c05e
ddf9945
284901c
73e6bb5
efcd873
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -74,6 +74,7 @@ struct StaticSampler { | |||||||
uint32_t ShaderRegister; | ||||||||
uint32_t RegisterSpace; | ||||||||
dxbc::ShaderVisibility ShaderVisibility; | ||||||||
uint32_t Flags; | ||||||||
|
uint32_t Flags; | |
// Version 3 onwards: | |
uint32_t Flags; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,9 @@ static uint32_t rewriteOffsetToCurrentByte(raw_svector_ostream &Stream, | |
size_t RootSignatureDesc::getSize() const { | ||
uint32_t StaticSamplersOffset = computeStaticSamplersOffset(); | ||
size_t StaticSamplersSize = | ||
StaticSamplers.size() * sizeof(dxbc::RTS0::v1::StaticSampler); | ||
(Version > 2 ? sizeof(dxbc::RTS0::v3::StaticSampler) | ||
: sizeof(dxbc::RTS0::v1::StaticSampler)) * | ||
|
||
StaticSamplers.size(); | ||
|
||
return size_t(StaticSamplersOffset) + StaticSamplersSize; | ||
} | ||
|
@@ -171,6 +173,9 @@ void RootSignatureDesc::write(raw_ostream &OS) const { | |
support::endian::write(BOS, S.ShaderRegister, llvm::endianness::little); | ||
support::endian::write(BOS, S.RegisterSpace, llvm::endianness::little); | ||
support::endian::write(BOS, S.ShaderVisibility, llvm::endianness::little); | ||
|
||
if (Version > 2) | ||
support::endian::write(BOS, S.Flags, llvm::endianness::little); | ||
} | ||
assert(Storage.size() == getSize()); | ||
OS.write(Storage.data(), Storage.size()); | ||
|
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. Should we also add an equivalent test for invalid sampler flag values? edit: I guess we haven't added that validation in this pr yet |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
; RUN: not opt -passes='print<dxil-root-signature>' %s -S -o - 2>&1 | FileCheck %s | ||
|
||
target triple = "dxil-unknown-shadermodel6.0-compute" | ||
|
||
|
||
; CHECK: error: Invalid value for Version: 4 | ||
; CHECK-NOT: Root Signature Definitions | ||
define void @main() #0 { | ||
entry: | ||
ret void | ||
} | ||
attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" } | ||
|
||
|
||
!dx.rootsignatures = !{!2, !3, !4, !5} ; list of function/root signature pairs | ||
!2 = !{ ptr @main, !6, i32 1 } ; function, root signature | ||
!3 = !{ ptr @main, !6, i32 4 } ; function, root signature | ||
!4 = !{ ptr @main, !6, i32 2 } ; function, root signature | ||
!5 = !{ ptr @main, !6, i32 3 } ; function, root signature | ||
!6 = !{ } ; list of root signature elements |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -526,3 +526,64 @@ TEST(RootSignature, ParseStaticSamplers) { | |
EXPECT_EQ(Storage.size(), 144u); | ||
EXPECT_TRUE(memcmp(Buffer, Storage.data(), 144u) == 0); | ||
} | ||
|
||
TEST(RootSignature, ParseStaticSamplersV13) { | ||
SmallString<160> Storage; | ||
|
||
|
||
// First read a fully explicit yaml with all sizes and offsets provided | ||
ASSERT_TRUE(convert(Storage, R"(--- !dxcontainer | ||
Header: | ||
Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, | ||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ] | ||
Version: | ||
Major: 1 | ||
Minor: 0 | ||
PartCount: 1 | ||
PartOffsets: [ 60 ] | ||
Parts: | ||
- Name: RTS0 | ||
Size: 76 | ||
RootSignature: | ||
Version: 3 | ||
NumRootParameters: 0 | ||
RootParametersOffset: 24 | ||
NumStaticSamplers: 1 | ||
StaticSamplersOffset: 24 | ||
Parameters: [] | ||
Samplers: | ||
- Filter: MinLinearMagMipPoint | ||
AddressU: Wrap | ||
AddressV: Mirror | ||
AddressW: MirrorOnce | ||
|
||
MipLODBias: 1.23 | ||
MaxAnisotropy: 20 | ||
ComparisonFunc: LessEqual | ||
BorderColor: TransparentBlack | ||
MinLOD: 4.56 | ||
MaxLOD: 8.90 | ||
ShaderRegister: 31 | ||
RegisterSpace: 32 | ||
ShaderVisibility: Mesh | ||
SAMPLER_FLAG_UINT_BORDER_COLOR: true | ||
AllowInputAssemblerInputLayout: true | ||
DenyGeometryShaderRootAccess: true | ||
)")); | ||
|
||
uint8_t Buffer[] = { | ||
0x44, 0x58, 0x42, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | ||
0x90, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x52, 0x54, 0x53, 0x30, 0x4c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, | ||
0x18, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, | ||
0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, | ||
0xa4, 0x70, 0x9d, 0x3f, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x85, 0xeb, 0x91, 0x40, 0x66, 0x66, 0x0e, 0x41, | ||
0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, | ||
0x01, 0x00, 0x00, 0x00}; | ||
|
||
EXPECT_EQ(Storage.size(), 148U); | ||
EXPECT_TRUE(memcmp(Buffer, Storage.data(), 148U) == 0); | ||
} |
Uh oh!
There was an error while loading. Please reload this page.