这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions design/ImageBitmapToTexture.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dictionary GPUImageBitmapCopyView {
GPUOrigin2D origin;
};

partial interface GPUCommandEncoder {
partial interface GPUQueue {
void copyImageBitmapToTexture(
GPUImageBitmapCopyView source,
GPUTextureCopyView destination,
Expand All @@ -15,14 +15,16 @@ partial interface GPUCommandEncoder {
};
```

`copyImageBitmapToTexture` encodes a copy from a source sub-rectangle of an `ImageBitmap` into a destination sub-resource of a `GPUTexture`.
When the command buffer is submitted, the `ImageBitmap` must not be detached.
If it is, a validation error is generated.
`copyImageBitmapToTexture` submits a copy from a source sub-rectangle of an `ImageBitmap` into a destination sub-resource of a `GPUTexture`.
The `ImageBitmap` must not be detached, if it is, a validation error is generated.

## Alternatives Considered

* Creating a `GPUTexture` directly from an `ImageBitmap`, attempting to avoid copies, is impractical because it requires the GPUTexture's format to match the internal representation of the `ImageBitmap`, which is not exposed to the Web platform.
Additionally, `ImageBitmap`s may be GPU- or CPU-backed, and wrapping a CPU-backed `ImageBitmap` is a significant meta-operation that requires an additional copy to be submitted.
* Having `copyImageBitmapToTexture` on `GPUCommandEncoder`: this makes implementations much more complicated because they can't know when the copy will be effectively submitted.
It also allows having multiple `copyImageBitmapToTexture` at different sports in the `GPUCommandEncoder` which would require splicing the encoder and keeping track of all the chunks.
Realistically, copying `ImageBitmap`s will be during loading to copy from `<img>` elements, or at most a couple times per frame for example to copy a camera frame, so an immediate copy is fine.

## Issues

Expand Down
16 changes: 8 additions & 8 deletions spec/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1591,11 +1591,6 @@ interface GPUCommandEncoder {
GPUTextureCopyView destination,
GPUExtent3D copySize);

void copyImageBitmapToTexture(
GPUImageBitmapCopyView source,
GPUTextureCopyView destination,
GPUExtent3D copySize);

void pushDebugGroup(DOMString groupLabel);
void popDebugGroup();
void insertDebugMarker(DOMString markerLabel);
Expand All @@ -1605,9 +1600,6 @@ interface GPUCommandEncoder {
GPUCommandEncoder includes GPUObjectBase;
</script>

* {{GPUCommandEncoder/copyImageBitmapToTexture()}}:
* For now, `copySize.z` must be `1`.

### Creation ### {#command-encoder-creation}

<script type=idl>
Expand Down Expand Up @@ -1849,10 +1841,18 @@ interface GPUQueue {

GPUFence createFence(optional GPUFenceDescriptor descriptor = {});
void signal(GPUFence fence, unsigned long long signalValue);

void copyImageBitmapToTexture(
GPUImageBitmapCopyView source,
GPUTextureCopyView destination,
GPUExtent3D copySize);
};
GPUQueue includes GPUObjectBase;
</script>

- {{GPUQueue/copyImageBitmapToTexture()}}:
- For now, `copySize.z` must be `1`.

{{GPUQueue/submit(commandBuffers)}} does nothing and produces an error if any of the following is true:

- Any {{GPUBuffer}} referenced in any element of `commandBuffers` isn't in the `"unmapped"` [=buffer state=].
Expand Down