Repository navigation
Convert matrix out/inout arguments with a matrix cast #8988
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
Joel Kiptoo (Kiptoo-Deus)
wants to merge
2
commits into
microsoft:main
Choose a base branch
from
Kiptoo-Deus:fix-matrix-out-param-conversion
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.
+83
−1
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
42 changes: 42 additions & 0 deletions
42
tools/clang/test/HLSLFileCheck/hlsl/functions/arguments/matrix_out_param_conversion.hlsl
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,42 @@ | ||
| // RUN: %dxc -E main -T cs_6_2 -enable-16bit-types -Od %s | FileCheck %s | ||
|
|
||
| // Out and inout matrix parameters whose argument has a different element type | ||
| // are converted like an explicit matrix cast when copied in and out, instead | ||
| // of hitting an assert in the scalar/vector conversion. | ||
|
|
||
| StructuredBuffer<float4> In : register(t0); | ||
| StructuredBuffer<int4> InInt : register(t1); | ||
| RWStructuredBuffer<float4> Out : register(u0); | ||
| RWStructuredBuffer<uint4> OutUint : register(u1); | ||
|
|
||
| void fill(out float2x2 m) { m = float2x2(In[0].xy, In[0].zw); } | ||
| void twice(inout float2x2 m) { m = m * 2; } | ||
| void fillInt(out int2x2 m) { m = int2x2(InInt[0].xy, InInt[0].zw); } | ||
|
|
||
| [numthreads(1, 1, 1)] | ||
| void main() { | ||
| // out float2x2 -> half2x2: converted when copied back. | ||
| // CHECK: fptrunc float %{{.*}} to half | ||
| // CHECK: fptrunc float %{{.*}} to half | ||
| // CHECK: fptrunc float %{{.*}} to half | ||
| // CHECK: fptrunc float %{{.*}} to half | ||
| half2x2 h; | ||
| fill(h); | ||
| Out[0] = float4(h[0], h[1]); | ||
|
|
||
| // inout half2x2 -> float2x2: converted on the way in and on the way out. | ||
| // CHECK: rawBufferLoad.f32 | ||
| // CHECK: fpext half %{{.*}} to float | ||
| // CHECK: fmul fast float %{{.*}}, 2.000000e+00 | ||
| // CHECK: fptrunc float %{{.*}} to half | ||
| half2x2 m = half2x2(In[1].xy, In[1].zw); | ||
| twice(m); | ||
| Out[1] = float4(m[0], m[1]); | ||
|
|
||
| // out int2x2 -> uint2x2: same bits, no conversion needed. | ||
| // CHECK: rawBufferLoad.i32 | ||
| // CHECK: rawBufferStore.i32 | ||
| uint2x2 u; | ||
| fillInt(u); | ||
| OutUint[0] = uint4(u[0], u[1]); | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.