| commit | 3c20b6127e96f26e3019e6c7d2a1138f651d4af1 | [log] [tgz] |
|---|---|---|
| author | Corentin Wallez <cwallez@chromium.org> | Wed Oct 01 07:14:48 2025 -0700 |
| committer | Dawn LUCI CQ <dawn-scoped@luci-project-accounts.iam.gserviceaccount.com> | Wed Oct 01 07:14:48 2025 -0700 |
| tree | 488771f3f6a060a6761d2adcdcda63aacea8ff59 | |
| parent | 8e0def799cd5743e818502ea509be0277c895e23 [diff] |
[dawn][native] Store ExternalTexture in BGL BindingInfo Store both internal bindings and external bindings in the BGL. This is the new comment at the top of the class that explains the newly added APIBindingIndex as well. <copypaste> BindGroupLayout stores the information passed in the BindGroupLayoutDescriptor but processes it in various ways to make it more efficient to use internally and to add internal bindings used to implement WebGPU feature that don't exist in backend APIs. Storing information in hashmap<BindingNumber, T> would be inefficient because these numbers may be sparse. Instead the are compacted into vectors, and reordered using |BindingTypeOrder| to make it efficient to iterate over all the bindings of a same kind. Indexind the packed bindings is done with |BindingIndex| or |APIBindingIndex| (see below for the explanation). In other cases bindings need to be expanded because a single BGLEntry can match multiple BGEntries when bindingArraySize > 1. To make handling more regular, a fake BGLEntry is created for each array element such that most code doesn't need to be aware of bindingArraySize. We also need to have private bindings that cannot be set by the users: dynamic binding array or ExternalTextures add additional bindings for their inner workings which are private to Dawn. Conversely ExternalTexture is a pure frontend object and doesn't exist in backends, so dawn::native must mostly be unaware about it. This is where |BindingIndex| and |APIBindingIndex| are different: - |APIBindingIndex| are user-facing bindings and cannot be used to access private bindings. It is used in code for BindGroup validation and opertations and when reflecting/validating WGSL bind points. - |BindingIndex| are Dawn-facing bindings where ExternalTexture shouldn't be accessed and instead can be used to access internal bindings. Internally both |APIBindingIndex| and |BindingIndex| are used to access the same vector, but the types are used to force uses of different BindGroupLayout accessors that ASSERT the invariant above. </copypaste> ShaderModule in every backend is modified to iterate over the BGL's BindingInfo using the BindingMap. Previously they iterated over the list of bindings in the EntryPointMetadata. Iterating over the BGL's entries allow using the new ExternalTextureBindingInfo that points at the BindingIndex of its plane0/1/metadata, but requires converting from APIBindingIndex to BindingIndex. (in future CLs the GenerateBindings can be factored between all the backends) The OpenGL ShaderModule is modified further to use a BindingIndex instead of a BindingNumber in the CombinedSamplerPair. A few additional cleanups will be done in follow-up CLs: - The external texture expansion map will be removed. - BGL::GetBindingIndex(BindingNumber) will be removed. Bug: 42240282 Change-Id: I745d6dcaa1368be2656e09525e77edd0a34709bb Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/262196 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Dawn is an open-source and cross-platform implementation of the WebGPU standard. More precisely it implements webgpu.h that is a one-to-one mapping with the WebGPU IDL. Dawn is meant to be integrated as part of a larger system and is the underlying implementation of WebGPU in Chromium.
Dawn provides several WebGPU building blocks:
webgpu.h version that Dawn implements.webgpu.h.Helpful links:
Developer documentation:
User documentation: (TODO, figure out what overlaps with the webgpu.h docs)
BSD 3-Clause License, please see LICENSE.
This is not an officially supported Google product.