-
Notifications
You must be signed in to change notification settings - Fork 305
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
Conversation
Co-authored-by: Kai Ninomiya <kainino1@gmail.com>
There was a problem hiding this 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.
: <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. | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
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. |
From this discussion I think: https://docs.google.com/document/d/1eiDkPsGbrrYjoiHKBTSH_KspYmqJj3ZWbjXuoMAk_rk/preview#heading=h.gf9b6fshc4aw |
* 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.
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 betweenrgba8-unorm
,rgba8-unorm-srgb
andrgba8-uint
. On the other hand, conversion betweenrgba8-unorm
andr32-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