Skip to content

Commit

Permalink
Add naive implementation of beginWebGPUAccess.
Browse files Browse the repository at this point in the history
Explainer:
https://github.com/fserb/canvas2D/blob/master/spec/webgpu.md

This API converts a canvas' currently-displayed image to a
GPUTexture which can be used by WebGPU. At present, the current
implementation uses Snapshot(), which always clones the image.
An ideal design would avoid this copy, but this gives us a
starting point to iterate from.

We do not yet have any guards against continuing to use the
Canvas2D APIs after calling `beginWebGPUAccess`. This is safe
because we don't actually steal the existing texture away from
the canvas; it still has its own storage, distinct from the WebGPU
texture. Once `endWebGPUAccess` is implemented, it is expected
that this would clobber any canvas changes that might have
occurred during WebGPU access (as the canvas texture would be
replaced by the GPUTexture from WebGPU).

Change-Id: Ied046431fbfdfff673ae61280317f8e0931ece7e
Bug: 41490345
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5289055
Reviewed-by: Austin Eng <[email protected]>
Reviewed-by: Jean-Philippe Gravel <[email protected]>
Reviewed-by: Vasiliy Telezhnikov <[email protected]>
Auto-Submit: John Stiles <[email protected]>
Commit-Queue: John Stiles <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1275839}
  • Loading branch information
johnstiles-google authored and BruceDai committed Mar 25, 2024
1 parent 2980c72 commit cae3bfa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion html/canvas/tools/gentestutilsunion.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def _render(jinja_env: jinja2.Environment, template_name: str,
params = dict(params)
params.update({
# Render the code on its own, as it could contain templates expanding
# to multuple lines. This is needed to get proper indentation of the
# to multiple lines. This is needed to get proper indentation of the
# code in the main template.
'code': _render_template(jinja_env,
jinja_env.from_string(params['code']),
Expand Down

0 comments on commit cae3bfa

Please sign in to comment.