Skip to content
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

[SPIR-V] Fix image write to unknown format #6984

Merged
merged 2 commits into from
Oct 28, 2024
Merged

Conversation

Keenuts
Copy link
Collaborator

@Keenuts Keenuts commented Oct 24, 2024

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

When 'unknown' was used in vk::image_format, the value was ignored,
and a format was still guessed.

The fix revealed a bug with Write/ReadWithoutFormat capability gen:
- image formats attributes are applied as a fix-up after initial
  codegen.
- the variable is changed, but not all related operations are fixed.
- capabilities visitor assumed types were coherent, and only looked at
  the OpImageWrite/Read operand type. Not the source variable.
- legalization fixes those incoherences, but runs after the visitor.

Using the capability trimming pass for this is an easy way to solve this
issue.

One test was checking for ReadWithoutFormat, but doesn't require it
since no OpImageRead is done on a Unknown format.

Signed-off-by: Nathan Gauër <[email protected]>
Signed-off-by: Nathan Gauër <[email protected]>
@Keenuts Keenuts requested a review from a team as a code owner October 24, 2024 12:02
@Keenuts Keenuts merged commit 6a7eae1 into microsoft:main Oct 28, 2024
14 checks passed
@Keenuts Keenuts deleted the fix-6981 branch October 28, 2024 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[SPIR-V] Unable to set 'unknown' format when using image_format attribute
3 participants