这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@kainino0x
Copy link
Contributor

@kainino0x kainino0x commented May 18, 2022

Proposal.

This allows drawImage/toDataURL/etc. to see the canvas contents
presented in the previous frame, as long as getCurrentTexture (or
configure/unconfigure) hasn't been called yet this frame.

alphaMode (née compositingAlphaMode) now affects using the canvas as an
image source (drawImage/etc.) as well as compositing, so that the
observed contents don't change on a frame boundary.

REVISION: destroy()ing a canvas texture now does not cancel presentation.
Instead, it just terminates writable-access to the drawing buffer early.
You can't get a new texture in the same frame without reallocating the
drawing buffer (configure or resize).

As a weird aside (necessary to fully define the image source behavior),
defines super-luminant values as being in the extended color space (i.e.
once un-premultiplied). This definition emerges naturally, but it's also
weird.

Fixes #2743
Fixes #1847
Fixes a leftover bit from #2373 (placeholder canvases) never mind that was for copyExternalImageToTexture


Preview | Diff

This allows drawImage/toDataURL/etc. to see the canvas contents
presented in the previous frame, as long as getCurrentTexture (or
configure/unconfigure) hasn't been called yet this frame.

alphaMode (née compositingAlphaMode) now affects using the canvas as an
image source (drawImage/etc.) as well as compositing, so that the
observed contents don't change on a frame boundary.

As a weird aside (necessary to fully define the image source behavior),
defines super-luminant values as being in the extended color space (i.e.
once un-premultiplied). This definition emerges naturally, but it's also
weird.

Fixes gpuweb#2743
Fixes gpuweb#1847
Fixes a leftover bit from gpuweb#2373 (placeholder canvases)
@kainino0x kainino0x added this to the V1.0 milestone May 18, 2022
@kainino0x kainino0x requested a review from toji May 18, 2022 02:45
@kainino0x
Copy link
Contributor Author

kainino0x commented May 18, 2022

@toji @kdashg @shaoboyan PTAL, but don't worry about the fine details just yet because we still need to bring this proposal to the group.

@kainino0x kainino0x requested review from kdashg and shaoboyan May 18, 2022 02:45
@github-actions
Copy link
Contributor

Previews, as seen when this build job started (810856b):
WebGPU | IDL
WGSL
Explainer

@kainino0x
Copy link
Contributor Author

For some examples of the behavior of this proposal, see here:
#2743 (comment)

kainino0x added 2 commits May 19, 2022 18:02
This fixes several problems:
- Unnecessary complexity in how currentTexture logic works.
- Errors in the previous commit, where this was just not fully handled.
- Using the "destroyed" state on the content process (minor issue).
@kainino0x
Copy link
Contributor Author

REVISION: destroy()ing a canvas texture now does not cancel presentation.
Instead, it just terminates writable-access to the drawing buffer early.
You can't get a new texture in the same frame without reallocating the
drawing buffer (configure or resize).

This fixes several problems:

  • Unnecessary complexity in how currentTexture logic works.
  • Errors in the previous revision of this PR, where this was just not fully handled.
  • Using the "destroyed" state on the content process (minor issue).

@kainino0x
Copy link
Contributor Author

The proposal for readback after present is accepted, so @toji PTAL

Copy link
Member

@toji toji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kainino0x kainino0x enabled auto-merge (squash) May 26, 2022 01:20
@github-actions
Copy link
Contributor

Previews, as seen when this build job started (2a5734e):
WebGPU | IDL
WGSL
Explainer

@kainino0x
Copy link
Contributor Author

Something wrong with CI, forcing merge

@kainino0x kainino0x disabled auto-merge May 26, 2022 01:34
@kainino0x kainino0x merged commit b085e00 into gpuweb:main May 26, 2022
@kainino0x kainino0x deleted the readback-after-present branch May 26, 2022 01:34
github-actions bot added a commit that referenced this pull request May 26, 2022
SHA: b085e00
Reason: push, by @kainino0x

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit that referenced this pull request May 26, 2022
SHA: b085e00
Reason: push, by @kainino0x

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
aarongable pushed a commit to chromium/chromium that referenced this pull request May 31, 2022
Syncs up Blink with change recently made to the WebGPU spec.
See: gpuweb/gpuweb#2905

Bug: 1069302
Change-Id: I091aceabaa1d2998dc39dd575bc0de92e596026f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3673936
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1009248}
kainino0x added a commit to kainino0x/gpuweb that referenced this pull request Jul 23, 2022
Without this, `getCurrentTexture()` doesn't know it's supposed to
allocate a new texture, it just keeps using the destroyed one.

And related language tweaks.

Issue introduced in gpuweb#2905. This PR still implements the behavior
described and agreed upon there. Issue found in whatwg/html#8123.
kainino0x added a commit that referenced this pull request Jul 23, 2022
* Set currentTexture to null on presentation

Without this, `getCurrentTexture()` doesn't know it's supposed to
allocate a new texture, it just keeps using the destroyed one.

And related language tweaks.

Issue introduced in #2905. This PR still implements the behavior
described and agreed upon there. Issue found in whatwg/html#8123.

* nit
jdarpinian pushed a commit to jdarpinian/gpuweb that referenced this pull request Aug 12, 2022
* Allow reading back from canvases after present

This allows drawImage/toDataURL/etc. to see the canvas contents
presented in the previous frame, as long as getCurrentTexture (or
configure/unconfigure) hasn't been called yet this frame.

alphaMode (née compositingAlphaMode) now affects using the canvas as an
image source (drawImage/etc.) as well as compositing, so that the
observed contents don't change on a frame boundary.

As a weird aside (necessary to fully define the image source behavior),
defines super-luminant values as being in the extended color space (i.e.
once un-premultiplied). This definition emerges naturally, but it's also
weird.

Fixes gpuweb#2743
Fixes gpuweb#1847
Fixes a leftover bit from gpuweb#2373 (placeholder canvases)

* nit

* Remove the "cancel present" behavior of destroy()

This fixes several problems:
- Unnecessary complexity in how currentTexture logic works.
- Errors in the previous commit, where this was just not fully handled.
- Using the "destroyed" state on the content process (minor issue).

* nits

* nit
jdarpinian pushed a commit to jdarpinian/gpuweb that referenced this pull request Aug 12, 2022
* Set currentTexture to null on presentation

Without this, `getCurrentTexture()` doesn't know it's supposed to
allocate a new texture, it just keeps using the destroyed one.

And related language tweaks.

Issue introduced in gpuweb#2905. This PR still implements the behavior
described and agreed upon there. Issue found in whatwg/html#8123.

* nit
juj added a commit to juj/wasm_webgpu that referenced this pull request Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebGPURenderingContext should support preserveDrawingBuffer: true Does compositingAlphaMode affect using the canvas as an image source?

2 participants