This descriptor, when chained on WGPUCommandEncoderDescriptor makes internal usages visible to validation. This CL is to help implement WebGPU Swiftshader support in Chrome. Bug: chromium:1266550 Change-Id: I7253fe45003e9ad5ac4d8ddd2d4782989e9b5c27 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/76440 Reviewed-by: Loko Kung <lokokung@google.com> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
1.7 KiB
Dawn Internal Usages
The dawn-internal-usages
feature allows adding additional usage which affects how a texture is allocated, but does not affect normal frontend validation.
Adds WGPUDawnTextureInternalUsageDescriptor
for specifying additional internal usages to create a texture with.
Example Usage:
wgpu::DawnTextureInternalUsageDescriptor internalDesc = {};
internalDesc.internalUsage = wgpu::TextureUsage::CopySrc;
wgpu::TextureDescriptor desc = {};
// set properties of desc.
desc.nextInChain = &internalDesc;
device.CreateTexture(&desc);
Adds WGPUDawnEncoderInternalUsageDescriptor
which may be chained on WGPUCommandEncoderDescriptor
. Setting WGPUDawnEncoderInternalUsageDescriptor::useInternalUsages
to true
means that internal resource usages will be visible during validation. ex.) A texture that has WGPUTextureUsage_CopySrc
in WGPUDawnEncoderInternalUsageDescriptor::internalUsage
, but not in WGPUTextureDescriptor::usage
may be used as the source of a copy command.
Example Usage:
wgpu::DawnEncoderInternalUsageDescriptor internalEncoderDesc = { true };
wgpu::CommandEncoderDescriptor encoderDesc = {};
encoderDesc.nextInChain = &internalEncoderDesc;
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(&encoderDesc);
// This will be valid
wgpu::ImageCopyTexture src = {};
src.texture = texture;
encoder.CopyTextureToBuffer(&src, ...);
One use case for this is so that Chromium can use an internal copyTextureToTexture command to implement copies from a WebGPU texture-backed canvas to other Web platform primitives when the swapchain texture was not explicitly created with CopySrc usage in Javascript.
Note: copyTextureToTextureInternal will be removed in favor of WGPUDawnEncoderInternalUsageDescriptor
.