-
Notifications
You must be signed in to change notification settings - Fork 714
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPIR-V] Avoid emitting Int64 when loading Float64 (#7073)
When loading a Float64 from a raw buffer, we used an Int64, which required an additional capability, even if the code wasn't using any Int64. In practice, it seems most devices supporting Float64 do also support Int64, but this it doesn't have to. By changing the codegen a bit, we can avoid the Int64 value. Tested the word-order using a vulkan compute shader, and checking the returned value on the API side. ```hlsl double tmp = buffer.Load<double>(0); if (tmp == 12.0) buffer.Store<double>(0, 13.0); ``` Fixes #7038 --------- Signed-off-by: Nathan Gauër <[email protected]>
- Loading branch information
Showing
6 changed files
with
229 additions
and
235 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
39 changes: 39 additions & 0 deletions
39
tools/clang/test/CodeGenSPIRV/method.byte-address-buffer.load.double.capability.hlsl
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,39 @@ | ||
// RUN: %dxc -T cs_6_0 -E main -O0 %s -spirv | FileCheck %s | ||
|
||
// CHECK-NOT: OpCapability Int64 | ||
// CHECK-DAG: OpCapability Float64 | ||
// CHECK-NOT: OpCapability Int64 | ||
|
||
RWByteAddressBuffer buffer; | ||
|
||
[numthreads(1, 1, 1)] | ||
void main() { | ||
double tmp; | ||
|
||
// CHECK: [[addr1:%[0-9]+]] = OpShiftRightLogical %uint %uint_0 %uint_2 | ||
// CHECK: [[ptr:%[0-9]+]] = OpAccessChain %_ptr_Uniform_uint %buffer %uint_0 [[addr1]] | ||
// CHECK: [[word0:%[0-9]+]] = OpLoad %uint [[ptr]] | ||
// CHECK: [[addr2:%[0-9]+]] = OpIAdd %uint [[addr1]] %uint_1 | ||
// CHECK: [[ptr:%[0-9]+]] = OpAccessChain %_ptr_Uniform_uint %buffer %uint_0 [[addr2]] | ||
// CHECK: [[word1:%[0-9]+]] = OpLoad %uint [[ptr]] | ||
// CHECK: [[addr3:%[0-9]+]] = OpIAdd %uint [[addr2]] %uint_1 | ||
// CHECK: [[merge:%[0-9]+]] = OpCompositeConstruct %v2uint [[word0]] [[word1]] | ||
// CHECK: [[value:%[0-9]+]] = OpBitcast %double [[merge]] | ||
// CHECK: OpStore %tmp [[value]] | ||
tmp = buffer.Load<double>(0); | ||
|
||
// CHECK: [[value:%[0-9]+]] = OpLoad %double %tmp | ||
// CHECK: [[merge:%[0-9]+]] = OpBitcast %v2uint [[value]] | ||
// CHECK: [[word0:%[0-9]+]] = OpCompositeExtract %uint [[merge]] 0 | ||
// CHECK: [[word1:%[0-9]+]] = OpCompositeExtract %uint [[merge]] 1 | ||
|
||
// CHECK: [[addr1:%[0-9]+]] = OpShiftRightLogical %uint %uint_0 %uint_2 | ||
// CHECK: [[ptr:%[0-9]+]] = OpAccessChain %_ptr_Uniform_uint %buffer %uint_0 [[addr1]] | ||
// CHECK: OpStore [[ptr]] [[word0]] | ||
// CHECK: [[addr2:%[0-9]+]] = OpIAdd %uint [[addr1]] %uint_1 | ||
// CHECK: [[ptr:%[0-9]+]] = OpAccessChain %_ptr_Uniform_uint %buffer %uint_0 [[addr2]] | ||
// CHECK: OpStore [[ptr]] [[word1]] | ||
// CHECK: [[addr3:%[0-9]+]] = OpIAdd %uint [[addr2]] %uint_1 | ||
buffer.Store<double>(0, tmp); | ||
} | ||
|
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
Oops, something went wrong.