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

Add GPUTextureDescriptor.viewFormats #811

Closed
wants to merge 2 commits into from
Closed

Conversation

Kangz
Copy link
Contributor

@Kangz Kangz commented May 27, 2020

This is an addition that would allow using different view formats than the texture's main format.

On Metal it would translate to looking at whether the format can be reinterpreted without the MTLTextureUsagePixelFormatView usage flag. I believe it is possible for example between rgba8-unorm, rgba8-unorm-srgb and rgba8-uint. On the other hand, conversion between rgba8-unorm and r32-uint wouldn't be free like that.

On Vulkan it would translate to using VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT if any format is set. That flag is a bit pessimistic so when available we'd use VK_KHR_image_format_list instead.

On D3D12, well I'm not sure because I wasn't not able to find the relevant documentation again. But something similar would happen (like we'd use a typeless format only if we need to).


Preview | Diff

@Kangz Kangz requested review from kvark and litherum May 27, 2020 14:56
spec/index.bs Outdated Show resolved Hide resolved
Co-authored-by: Kai Ninomiya <kainino1@gmail.com>
Copy link
Contributor

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a right direction. The only concern is how we are going to specify (in the near future) which formats the user can request in this list.

Comment on lines +1462 to +1468
: <dfn>\[[viewFormats]]</dfn> of type `sequence<{{GPUTextureFormat}}>`.
::
The additional formats that are allowed to be used as {{GPUTextureViewDescriptor}}.{{GPUTextureViewDescriptor/format}}
for views created from this {{GPUTexture}}.

The base texture format {{GPUTextureFormatDescriptor/format}} is always allowed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec text you're adding doesn't match the title of the PR. The PR title talks about GPUTextureDescriptor.viewformats but here you're adding the sequence of formats to the GPUTexture object itself.

For D3D12, you need to tell the API that you want a typeless texture at object creation time. So specifying something like viewFormats would be best as part of the descriptor as the title of the PR states.

The best place to look at the mapping for compatible formats for D3D can be found in the format tables for the various feature levels. https://microsoft.github.io/DirectX-Specs/d3d/archive/images/d3d11/D3D11_3_Formats_FL11_1.xls is a link to the one for FL11_1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The section you commented on contains the "internal slots" for the texture. It saves creation arguments so they can be later used by other parts of the spec for validation. The real API change is [1] which adds viewFormats to the GPUTextureDescriptor.

Thanks for the link, [lease help build the compatibility classes for WebGPU in #744

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, Corentin. I admit I overlooked the viewFormats section.

I think we should go forward with this PR and amend the spec pending the outcome of #774 about which ones are allowed to go together.

@kvark kvark changed the base branch from master to main June 23, 2020 13:15
@Kangz
Copy link
Contributor Author

Kangz commented Jul 3, 2020

Closing this PR as we decided to go with a single flag for now. We might reopen this later if we decide it is worth adding an explicit list of view compatible formats.

@Kangz Kangz closed this Jul 3, 2020
@kainino0x
Copy link
Contributor

@Kangz Kangz deleted the formatlist branch March 25, 2022 14:22
ben-clayton added a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
* shader/execution/builtin: Add `cos()` test

* shader/execution/builtin: Untitle scalar constructors

The CTS has a convention of untitled function names, and this matches the WGSL syntax better anyway.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants