-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Set shader analysis flag EnableRawAndStructuredBuffers for RawBuffer and StructuredBuffer resource types #114449
Closed
coopp
wants to merge
10
commits into
llvm:main
from
coopp:user/coopp/rawandstructuredbuff_shaderflags
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cf6b6d8
Add simple shader flags tests for structured and raw buffer
28580c2
Fix raw_buffers test
cecb423
cleanup tests
98e8969
Update tests with new IR
607fdc1
rename test
a3c0af0
Work in progress (contains checks for shader profile type, shader mod…
87a63a6
Add cs4 test and updated logic to handle legacy pass manager
0d820cc
Remove structured buffer because it is not working for some reason
931a684
Added more tests and updated logic
adb6619
Remove setting ComputeShadersPlusRawAndStructuredBuffers flag and tes…
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 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 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 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
; RUN: opt -S --passes="print-dx-shader-flags" 2>&1 %s | FileCheck %s | ||
|
||
target triple = "dxil-pc-shadermodel6.3-compute" | ||
|
||
@G = external constant <4 x float>, align 4 | ||
|
||
define void @test_bufferflags() { | ||
|
||
; ByteAddressBuffer Buf : register(t8, space1) | ||
%srv0 = call target("dx.RawBuffer", i8, 0, 0) | ||
@llvm.dx.handle.fromBinding.tdx.RawBuffer_i8_0_0t( | ||
i32 1, i32 8, i32 1, i32 0, i1 false) | ||
|
||
ret void | ||
} | ||
|
||
attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) } | ||
|
||
; CHECK: ; Shader Flags Value: 0x00000010 | ||
; CHECK: ; Note: shader requires additional functionality: | ||
; CHECK-NEXT: ; Note: extra DXIL module flags: | ||
; CHECK-NEXT: ; D3D11_SB_GLOBAL_FLAG_ENABLE_RAW_AND_STRUCTURED_BUFFERS | ||
; CHECK-NEXT: {{^;$}} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
; RUN: opt -S --passes="print-dx-shader-flags" 2>&1 %s | FileCheck %s | ||
|
||
target triple = "dxil-pc-shadermodel6.3-compute" | ||
|
||
@G = external constant <4 x float>, align 4 | ||
|
||
define void @test_bufferflags() { | ||
|
||
; RWByteAddressBuffer Buf : register(u8, space1) | ||
%uav0 = call target("dx.RawBuffer", i8, 1, 0) | ||
@llvm.dx.handle.fromBinding.tdx.RawBuffer_i8_0_0t( | ||
i32 1, i32 8, i32 1, i32 0, i1 false) | ||
|
||
ret void | ||
} | ||
|
||
attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) } | ||
|
||
; CHECK: ; Shader Flags Value: 0x00000010 | ||
; CHECK: ; Note: shader requires additional functionality: | ||
; CHECK-NEXT: ; Note: extra DXIL module flags: | ||
; CHECK-NEXT: ; D3D11_SB_GLOBAL_FLAG_ENABLE_RAW_AND_STRUCTURED_BUFFERS | ||
; CHECK-NEXT: {{^;$}} |
24 changes: 24 additions & 0 deletions
24
llvm/test/CodeGen/DirectX/ShaderFlags/rwstructuredbuffer.ll
This file contains 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
; RUN: opt -S --passes="print-dx-shader-flags" 2>&1 %s | FileCheck %s | ||
|
||
target triple = "dxil-pc-shadermodel6.7-library" | ||
|
||
@G = external constant <4 x float>, align 4 | ||
|
||
define void @test_bufferflags() { | ||
|
||
; struct S { float4 a; uint4 b; }; | ||
; RWStructuredBuffer<S> Buf : register(u2, space4) | ||
%struct0 = call target("dx.RawBuffer", {<4 x float>, <4 x i32>}, 1, 0) | ||
@llvm.dx.handle.fromBinding.tdx.RawBuffer_sl_v4f32v4i32s_0_0t( | ||
i32 4, i32 2, i32 1, i32 10, i1 true) | ||
|
||
ret void | ||
} | ||
|
||
attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) } | ||
|
||
; CHECK: ; Shader Flags Value: 0x00000010 | ||
; CHECK: ; Note: shader requires additional functionality: | ||
; CHECK-NEXT: ; Note: extra DXIL module flags: | ||
; CHECK-NEXT: ; D3D11_SB_GLOBAL_FLAG_ENABLE_RAW_AND_STRUCTURED_BUFFERS | ||
; CHECK-NEXT: {{^;$}} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
; RUN: opt -S --passes="print-dx-shader-flags" 2>&1 %s | FileCheck %s | ||
|
||
target triple = "dxil-pc-shadermodel6.7-library" | ||
|
||
@G = external constant <4 x float>, align 4 | ||
|
||
define void @test_bufferflags() { | ||
|
||
; struct S { float4 a; uint4 b; }; | ||
; StructuredBuffer<S> Buf : register(t2, space4) | ||
%struct0 = call target("dx.RawBuffer", {<4 x float>, <4 x i32>}, 0, 0) | ||
@llvm.dx.handle.fromBinding.tdx.RawBuffer_sl_v4f32v4i32s_0_0t( | ||
i32 4, i32 2, i32 1, i32 10, i1 true) | ||
|
||
ret void | ||
} | ||
|
||
attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) } | ||
|
||
; CHECK: ; Shader Flags Value: 0x00000010 | ||
; CHECK: ; Note: shader requires additional functionality: | ||
; CHECK-NEXT: ; Note: extra DXIL module flags: | ||
; CHECK-NEXT: ; D3D11_SB_GLOBAL_FLAG_ENABLE_RAW_AND_STRUCTURED_BUFFERS | ||
; CHECK-NEXT: {{^;$}} |
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 isn't one of the optional feature flags used by the runtime. So, it should not have a comment saying "shader requires additional functionality". You can tell which flags should be reported under this statement by looking at the ones set in the ShaderFlags::GetFeatureInfo method in DxilShaderFlags.cpp in DXC.
Instead, this flag mirrors a global flag that was set in the DXBC dcl_globalFlags instruction token:
D3D11_SB_GLOBAL_FLAG_ENABLE_RAW_AND_STRUCTURED_BUFFERS
. This value this identifier is defined to in the DXBC token stream is not the same value as in the DXIL Shader Flags, so that could be a bit confusing to write that out here as the flag name.Additionally: It turns out that this flag is only generated for SRV raw/structured buffers on
ps_4_0
orps_4_1
. UAV's not allowed for those targets at all.It only exists in DXIL as the way to preserve this DXBC flag when we were writing the initial version of the DXBC to DXIL converter (DxilConv.dll), which originally would try to preserve the shader model and any flags set in the original DXBC.
So due to these limitations, I believe we shouldn't ever need to set this flag for DXIL in this compiler after all.
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.
I've opened microsoft/DirectXShaderCompiler#7003 to track removal for validation.