D3D11: Cache last created SRV and RTV in the Texture class.
It's a common scenario that users create a texture's view transiently
once per frame and never cache it.
e.g:
void renderStep() {
// Create a view and attach it to a render pass.
wgpu::RenderPassDescriptor renderPassDesc = ...;
renderPassDesc.colorAttachments[0].view = texture.CreateView();
// Draw the render pass.
}
In this case, D3D11 has to repeatedly re-create the texture's D3D native
view every frame. This is not a cheap operation. Unlike metal backend,
where the view creation could be skipped entirely in some simple
scenarios:
See: https://source.chromium.org/chromium/chromium/src/+/main:third_party/dawn/src/dawn/native/metal/TextureMTL.mm;drc=5ca64904963dc4676216ddfd226779522c271540;l=104
This CL adds a small optimization for this scenario by:
- Caching last created D3D views within the wgpu::Texture object.
- Checking the cache for an existing D3D view before creating a new one
when a wgpu::TextureView is initialized.
Bug: chromium:377716220
Bug: 409035452
Change-Id: Id99c38f8c91dc441f9a6ba92ca888dea3e8d37dc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/234254
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Quyen Le <lehoangquyen@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.