Skip to content

Define WebGPU canvas read behavior#1839

Merged
kainino0x merged 2 commits intogpuweb:mainfrom
kainino0x:read-from-webgpu
Jun 16, 2021
Merged

Define WebGPU canvas read behavior#1839
kainino0x merged 2 commits intogpuweb:mainfrom
kainino0x:read-from-webgpu

Conversation

@kainino0x
Copy link
Copy Markdown
Contributor

@kainino0x kainino0x commented Jun 15, 2021

Fixes #1781


Preview | Diff

@github-actions
Copy link
Copy Markdown
Contributor

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

@kainino0x kainino0x requested review from kvark and toji June 15, 2021 23:49
@kainino0x kainino0x marked this pull request as ready for review June 15, 2021 23:49
@gpuweb gpuweb deleted a comment from github-actions bot Jun 15, 2021
@github-actions
Copy link
Copy Markdown
Contributor

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

@toji
Copy link
Copy Markdown
Member

toji commented Jun 16, 2021

Tweaked verbiage looks good, thanks!

@Juanmihd
Copy link
Copy Markdown

I thought worth mentioning that in the html spec TransferToImageBitmap is reference more as "moving out the original content" and then leaving one new in place, rather than how it will be mentioned in the WebGPU spec of copying out the internal content and reseting the internal one.

Nevertheless, the outcome and expectations are the same, so I think it's good as it is written!

lgtm, thanks adding this!

spec/index.bs Outdated
Note:
When the *user* initiates a read of a WebGPU canvas, e.g. using "Copy to Clipboard",
"Save Image As...", printing, etc., the user agent **should** return the contents displayed on the
screen at that moment, if possible (not the contents of {{GPUPresentationContext/[[currentTexture]]}}.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Want to make sure this matches the behavior of other canvas types. I don't think webgl or 2d canvas have a way to export the previously displayed frame since that's been handed over to the display compositor. One way of meeting this requirement is triggering a compositing update when any of these actions are initiated so that the contents on screen matches the content copied/saved.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did some quick investigation and it looks like all of these actions actually cannot happen during a JS task anyway - I think they occur as events on the event loop which means they can just trigger "update the rendering [of the] Document" to get the contents. At least in the case of printing, I think they must trigger it, because printing requires page relayout; I think copying probably triggers it as well.

Anyway, based on that, I don't think there's any danger of implementations returning [[currentTexture]]'s contents in the middle of a frame, so I'm just going to remove this note.

@kainino0x kainino0x enabled auto-merge (rebase) June 16, 2021 21:59
@kainino0x kainino0x merged commit eee1e8c into gpuweb:main Jun 16, 2021
@github-actions
Copy link
Copy Markdown
Contributor

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

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.

Define behavior of reading from WebGPU canvases using other Web APIs

5 participants