-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[HLSL] Implement D3DCOLORtoUBYTE4 intrinsic #122202
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5610b22
[HLSL] Implement the D3DCOLORtoUBYTE4 intrinsic
Icohedron e2c4abd
Address some PR comments
Icohedron 57f9048
Merge remote-tracking branch 'upstream/main' into feature-D3DCOLORtoU…
Icohedron 6d17064
Link to DXC implementation in comment
Icohedron 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// RUN: %clang_cc1 -finclude-default-header -triple \ | ||
// RUN: dxil-pc-shadermodel6.3-library %s \ | ||
// RUN: -emit-llvm -O1 -o - | FileCheck %s --check-prefixes=CHECK | ||
|
||
// CHECK-LABEL: D3DCOLORtoUBYTE4 | ||
int4 test_D3DCOLORtoUBYTE4(float4 p1) { | ||
// CHECK: %[[SCALED:.*]] = fmul [[FMFLAGS:.*]][[FLOAT_TYPE:<4 x float>]] %{{.*}}, splat (float 0x406FE01000000000) | ||
// CHECK: %[[CONVERTED:.*]] = fptoui [[FLOAT_TYPE]] %[[SCALED]] to [[INT_TYPE:<4 x i32>]] | ||
// CHECK: %[[SHUFFLED:.*]] = shufflevector [[INT_TYPE]] %[[CONVERTED]], [[INT_TYPE]] poison, <4 x i32> <i32 2, i32 1, i32 0, i32 3> | ||
// CHECK: ret [[INT_TYPE]] %[[SHUFFLED]] | ||
return D3DCOLORtoUBYTE4(p1); | ||
} |
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,29 @@ | ||
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -emit-llvm-only -disable-llvm-passes -verify | ||
|
||
int4 test_too_few_arg() { | ||
return D3DCOLORtoUBYTE4(); | ||
// expected-error@-1 {{no matching function for call to 'D3DCOLORtoUBYTE4'}} | ||
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function not viable: requires single argument 'V', but no arguments were provided}} | ||
} | ||
|
||
int4 test_too_many_arg(float4 v) { | ||
return D3DCOLORtoUBYTE4(v, v); | ||
// expected-error@-1 {{no matching function for call to 'D3DCOLORtoUBYTE4'}} | ||
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function not viable: requires single argument 'V', but 2 arguments were provided}} | ||
} | ||
|
||
int4 float2_arg(float2 v) { | ||
return D3DCOLORtoUBYTE4(v); | ||
// expected-error@-1 {{no matching function for call to 'D3DCOLORtoUBYTE4'}} | ||
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function not viable: no known conversion from 'vector<[...], 2>' to 'vector<[...], 4>' for 1st argument}} | ||
} | ||
|
||
struct S { | ||
float4 f; | ||
}; | ||
|
||
int4 struct_arg(S v) { | ||
return D3DCOLORtoUBYTE4(v); | ||
// expected-error@-1 {{no matching function for call to 'D3DCOLORtoUBYTE4'}} | ||
// expected-note@hlsl/hlsl_intrinsics.h:* {{candidate function not viable: no known conversion from 'S' to 'vector<float, 4>' (vector of 4 'float' values) for 1st argument}} | ||
} |
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 implementation of
D3DCOLORtoUBYTE4
scales the vector by255.001953
. This matches the way it was done in DXC.However, it differs from the SPIRV custom implementation which scales the vector by
255.002
.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 think the change from DXC for SPIR-V is fine. The DXIL behaviour is the correct behaviour.