-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[DirectX] Add llvm.dx.resource.getdimensions.x
intrinsic and lowering to DXIL
#161753
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
Open
hekota
wants to merge
5
commits into
llvm:main
Choose a base branch
from
hekota:dxil-get-dimensions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+152
−0
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3d57b10
[DirectX] Introduce `llvm.dx.resource.getdimensions and lower it to g…
hekota e8b85ac
Change to buffer-specific LLVM intrinsic
hekota af82ba8
Update intrinsic name to llvm.dx.resource.getdimensions.x
hekota 600283a
Add documentation of the getdimensions intrinsics
hekota 08b6495
fix doc compile errors
hekota 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
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
; RUN: opt -S -dxil-op-lower %s | FileCheck %s | ||
|
||
target triple = "dxil-pc-shadermodel6.6-compute" | ||
|
||
define i32 @test_getdimensions_no_mips() { | ||
; CHECK: [[HANDLE1:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, | ||
; CHECK-NEXT: [[ANNOT_HANDLE1:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[HANDLE1]] | ||
%handle1 = call target("dx.TypedBuffer", <4 x float>, 0, 0, 0) @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 1, i32 0, ptr null) | ||
|
||
; CHECK-NEXT: [[RETVAL1:%.*]] = call %dx.types.Dimensions @dx.op.getDimensions(i32 72, %dx.types.Handle [[ANNOT_HANDLE1]], i32 undef) | ||
%1 = call { i32, i32, i32, i32 } @llvm.dx.resource.getdimensions.tdx.RawBuffer_i32_1_0t(target("dx.TypedBuffer", <4 x float>, 0, 0, 0) %handle1, i32 poison) | ||
hekota marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
; CHECK-NEXT: %[[DIM1:.*]] = extractvalue %dx.types.Dimensions [[RETVAL1]], 0 | ||
%2 = extractvalue { i32, i32, i32, i32 } %1, 0 | ||
|
||
; CHECK-NEXT: ret i32 %[[DIM1]] | ||
ret i32 %2 | ||
} | ||
|
||
|
||
define i32 @test_getdimensions_with_0_mips() { | ||
; CHECK: [[HANDLE2:%.*]] = call %dx.types.Handle @dx.op.createHandleFromBinding(i32 217, | ||
; CHECK-NEXT: [[ANNOT_HANDLE2:%.*]] = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle [[HANDLE2]] | ||
%handle1 = call target("dx.RawBuffer", float, 0, 0) @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 1, i32 0, ptr null) | ||
|
||
; CHECK-NEXT: [[RETVAL2:%.*]] = call %dx.types.Dimensions @dx.op.getDimensions(i32 72, %dx.types.Handle [[ANNOT_HANDLE2]], i32 0) | ||
%1 = call { i32, i32, i32, i32 } @llvm.dx.resource.getdimensions.tdx.RawBuffer_i32_1_0t(target("dx.RawBuffer", float, 0, 0) %handle1, i32 0) | ||
hekota marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
; CHECK-NEXT: %[[DIM2:.*]] = extractvalue %dx.types.Dimensions [[RETVAL2]], 0 | ||
%2 = extractvalue { i32, i32, i32, i32 } %1, 0 | ||
|
||
; CHECK-NEXT: ret i32 %[[DIM2]] | ||
ret i32 %2 | ||
} |
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.
There isn't really a great place to do it, but we should validate here that the results are being used correctly (That is, none of the
undef
s in the table in https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst#getdimensions are being accessed) based on the type of the resource. This will prevent us from generating DXIL that wouldn't pass the validator if we're given bogus IR.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.
Based on our 1:1 discussion earlier I realized it is indeed better to have multiple LLVM intrinsic to implement the GetDimensions. I have updated this PR to have a getdimensions intrinsic specific just for buffers, and now we can avoid this validation in the lowering pass.