mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-08 13:14:56 +00:00
Add WGPUDawnEncoderInternalUsageDescriptor
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>
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
# Dawn Internal Usages
|
||||
|
||||
The `dawn-internal-usages` feature allows adding additional usage which affects how a texture is allocated, but does not affect frontend validation.
|
||||
The `dawn-internal-usages` feature allows adding additional usage which affects how a texture is allocated, but does not affect normal frontend validation.
|
||||
|
||||
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.
|
||||
Adds `WGPUDawnTextureInternalUsageDescriptor` for specifying additional internal usages to create a texture with.
|
||||
|
||||
Example Usage:
|
||||
```
|
||||
Usage:
|
||||
|
||||
wgpu::DawnTextureInternalUsageDescriptor internalDesc = {};
|
||||
internalDesc.internalUsage = wgpu::TextureUsage::CopySrc;
|
||||
|
||||
@@ -14,5 +13,26 @@ wgpu::TextureDescriptor desc = {};
|
||||
// set properties of desc.
|
||||
desc.nextInChain = &internalDesc;
|
||||
|
||||
device.createTexture(&desc);
|
||||
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`.
|
||||
|
||||
Reference in New Issue
Block a user