-
Notifications
You must be signed in to change notification settings - Fork 692
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPIR-V] Fix cast elision with initializer lists (#6992)
When an a chain of casts were performed in an initializer list, only the source and destination types were considered. This means float -> uint was the same as float -> int -> uint. This however is not correct: intermediate casts can change the result. Removing the shortcut we took solves this issue. Fixes #6975 Signed-off-by: Nathan Gauër <[email protected]>
- Loading branch information
Showing
6 changed files
with
96 additions
and
43 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// RUN: %dxc -T cs_6_6 -E main -fcgl %s -spirv | FileCheck %s | ||
|
||
RWStructuredBuffer<float> buffer; | ||
RWStructuredBuffer<float4> buffer4; | ||
|
||
[numthreads(1, 1, 1)] | ||
void main() { | ||
{ | ||
// CHECK: [[f:%[0-9]+]] = OpLoad %float {{.*}} | ||
// CHECK: [[s:%[0-9]+]] = OpConvertFToS %int [[f]] | ||
// CHECK: [[u:%[0-9]+]] = OpBitcast %uint [[s]] | ||
// CHECK: OpStore {{.*}} [[u]] | ||
uint p = uint(int(buffer[0])); | ||
} | ||
|
||
{ | ||
// CHECK: [[f:%[0-9]+]] = OpLoad %v4float {{.*}} | ||
// CHECK: [[s:%[0-9]+]] = OpConvertFToS %v4int [[f]] | ||
// CHECK: [[u:%[0-9]+]] = OpBitcast %v4uint [[s]] | ||
// CHECK: OpStore {{.*}} [[u]] | ||
uint4 p4 = uint4(int4(buffer4[0])); | ||
} | ||
|
||
{ | ||
// CHECK: [[f:%[0-9]+]] = OpLoad %v4float {{.*}} | ||
// CHECK: [[s:%[0-9]+]] = OpConvertFToS %v4int [[f]] | ||
// CHECK: [[u:%[0-9]+]] = OpBitcast %v4uint [[s]] | ||
// CHECK: OpStore {{.*}} [[u]] | ||
uint4 p4 = int4(buffer4[0]); | ||
} | ||
|
||
{ | ||
// CHECK: [[f:%[0-9]+]] = OpLoad %v4float {{.*}} | ||
// CHECK: [[u:%[0-9]+]] = OpConvertFToU %v4uint [[f]] | ||
// CHECK: OpStore {{.*}} [[u]] | ||
uint4 p4 = uint4(uint4(buffer4[0])); | ||
} | ||
} |
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
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