Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify OffscreenCanvas.transferToImageBitmap and preserveDrawingBuffer #3612

Open
kkinnunen-apple opened this issue Jan 19, 2024 · 5 comments
Assignees

Comments

@kkinnunen-apple
Copy link
Contributor

Clarify OffscreenCanvas.transferToImageBitmap and preserveDrawingBuffer

It mandates that color buffer is cleared.
Are depth and stencil buffers preserved or cleared?

The transferToImageBitmap() method, when invoked, must run the following steps:
....

Set this OffscreenCanvas object's bitmap to reference a newly created bitmap of the same dimensions and color space as the previous bitmap, and with its pixels initialized to [transparent black>(https://drafts.csswg.org/css-color/#transparent-black), or opaque black if the rendering context's alpha flag is set to false.

This means that if the rendering context of this OffscreenCanvas is a WebGLRenderingContext, the value of preserveDrawingBuffer will have no effect. [WEBGL]

@kenrussell
Copy link
Member

I think the depth and stencil buffers, if they exist, should be cleared to the default values defined in https://registry.khronos.org/webgl/specs/latest/1.0/#2.2 . What do you and others think?

@kkinnunen-apple
Copy link
Contributor Author

The depth, stencil and color buffers should be cleared if preserveDrawingBuffer == false.
The depth, stencil and color buffers should be preserved if preserveDrawingBuffer == true.

Otherwise transferToImageBitmap + Placeholder Canvas + preserveDrawingBuffer == true seems hard to implement:

  • A early transferToImageBitmap would clear
  • A later commit to placeholder canvas would preserve
  • --> code needs to support both

@kdashg
Copy link
Contributor

kdashg commented Mar 7, 2024

I agree, clearing implies clearing depth-stencil as well.

@kdashg kdashg self-assigned this Mar 7, 2024
@kdashg
Copy link
Contributor

kdashg commented Apr 4, 2024

@kdashg
Copy link
Contributor

kdashg commented Apr 4, 2024

WebGL meeting 2024-03-21:

  • KR: Kimmo, could you write a test for this?
  • KK: If someone was relying on the previous spec - we're going to say that you should change your code
  • KG: thought this was just a clarification. Thought depth/stencil was cleared if and only if the color buffer was cleared.
  • KK: clarity is around depth/stencil buffer. Not mentioned at all. Other thing to clarify - how does preserveDrawingBuffer affect all the buffers?
  • Today, most implementations clear upon transferToImageBitmap regardless of preserveDrawingBuffer state
  • KG: if you want to change the preserveDrawingBuffer semantics, that's not a clarification. But if you want to state that depth/stencil are cleared, that's a clarification.
  • Agreed:
    • We'll clear depth/stencil if and only if color is cleared
  • AIs:
    • KG to write the spec change
    • KK to write the test

kkinnunen-apple added a commit to kkinnunen-apple/WebGL that referenced this issue Apr 18, 2024
…roup#3612

Test following spec clarifications:
  * the value of preserveDrawingBuffer will have no effect
  * the contents of any depth and/or stencil buffers will be cleared to
    initial values
kkinnunen-apple added a commit to kkinnunen-apple/WebGL that referenced this issue Apr 18, 2024
…roup#3612

Test following spec clarifications:
  * the value of preserveDrawingBuffer will have no effect
  * the contents of any depth and/or stencil buffers will be cleared to
    initial values
kkinnunen-apple added a commit to kkinnunen-apple/WebGL that referenced this issue Apr 18, 2024
…Group#3612)

Test following spec clarifications:
  * the value of preserveDrawingBuffer will have no effect
  * the contents of any depth and/or stencil buffers will be cleared to
    initial values
kkinnunen-apple added a commit to kkinnunen-apple/WebGL that referenced this issue Apr 18, 2024
…Group#3612)

Test following spec clarifications:
  * the value of preserveDrawingBuffer will have no effect
  * the contents of any depth and/or stencil buffers will be cleared to
    initial values
kkinnunen-apple added a commit to kkinnunen-apple/WebGL that referenced this issue Apr 18, 2024
…Group#3612)

Test following spec clarifications:
  * the value of preserveDrawingBuffer will have no effect
  * the contents of any depth and/or stencil buffers will be cleared to
    initial values
kkinnunen-apple added a commit to kkinnunen-apple/WebGL that referenced this issue Apr 19, 2024
…Group#3612)

Test following spec clarifications:
  * the value of preserveDrawingBuffer will have no effect
  * the contents of any depth and/or stencil buffers will be cleared to
    initial values
kenrussell pushed a commit that referenced this issue Oct 31, 2024
…3643)

Test following spec clarifications:
  * the value of preserveDrawingBuffer will have no effect
  * the contents of any depth and/or stencil buffers will be cleared to
    initial values
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

No branches or pull requests

3 participants