-
Notifications
You must be signed in to change notification settings - Fork 694
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 image write to unknown format (#6984)
By default, texture format is guessed from the type. But the `vk::image_format` attribute can be added to specify it. The `unknown` value was used to convey `no format selected`, and require the guess to happen. This made selecting `unknown` as value impossible. Once the optional added, we have a new issue: - The format setup relied on the legalizer. - load/stores are done using the default format, then we fix it, then we use the legalizer to propagate the format fix to all users. The capability visitor is running before the legalizer, meaning it can look at a non-fixed load, which still carries the old type. The way to solve this is to remove this logic, and move the capability addition/deletion to the capability_trimming pass, run after legalization. Fixes #6981 --------- Signed-off-by: Nathan Gauër <[email protected]>
- Loading branch information
Showing
7 changed files
with
50 additions
and
38 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
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
14 changes: 14 additions & 0 deletions
14
tools/clang/test/CodeGenSPIRV/vk.attribute.image-format.unknown.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,14 @@ | ||
// RUN: %dxc -T cs_6_7 -E main -spirv -fspv-target-env=vulkan1.3 %s | ||
|
||
// CHECK: OpCapability StorageImageWriteWithoutFormat | ||
|
||
// CHECK: %[[#image:]] = OpTypeImage %float 3D 2 0 0 2 Unknown | ||
[[vk::image_format("unknown")]] RWTexture3D<float32_t2> untypedImage; | ||
|
||
[numthreads(8,8,8)] | ||
void main(uint32_t3 gl_GlobalInvocationID : SV_DispatchThreadID) | ||
{ | ||
// CHECK: %[[#tmp:]] = OpLoad %[[#image]] %[[#]] | ||
// CHECK: OpImageWrite [[#tmp]] %[[#]] %[[#]] None | ||
untypedImage[gl_GlobalInvocationID] = float32_t2(4,5); | ||
} |
16 changes: 16 additions & 0 deletions
16
tools/clang/test/CodeGenSPIRV/vk.attribute.image-format.unknown.read.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,16 @@ | ||
// RUN: %dxc -T cs_6_7 -E main -spirv -fspv-target-env=vulkan1.3 %s | ||
|
||
// CHECK: OpCapability StorageImageReadWithoutFormat | ||
|
||
// CHECK: %[[#image:]] = OpTypeImage %float 1D 2 0 0 2 Unknown | ||
[[vk::image_format("unknown")]] RWTexture1D<float32_t2> untypedImage; | ||
RWStructuredBuffer<float32_t2> output; | ||
|
||
[numthreads(8,8,8)] | ||
void main() | ||
{ | ||
// CHECK: %[[#tmp:]] = OpLoad %[[#image]] %[[#]] | ||
// CHECK: OpImageRead %[[#]] [[#tmp]] %[[#]] None | ||
output[0] = untypedImage[0]; | ||
} | ||
|