Skip to content

Clarify behavior of out-of-gamut canvas - #4476

Merged
kainino0x merged 4 commits into
gpuweb:mainfrom
kainino0x:premultiplied-nit
Apr 12, 2024
Merged

kainino0x merged 4 commits into
gpuweb:mainfrom
kainino0x:premultiplied-nit

Conversation

@kainino0x

@kainino0x kainino0x commented Jan 31, 2024 •

Copy link
Copy Markdown
Contributor

It's OK if out-of-gamut intermediate values are written to the canvas, it only matters what's there when it gets presented.

Also move the existing explanation of the undefined behavior to a note, and expand it with an example.

It's OK if out-of-gamut intermediate values are written to the canvas,
it only matters what's there when it gets presented.
@kainino0x kainino0x added the copyediting Pure editorial stuff (copyediting, *.bs file syntax, etc.) label Jan 31, 2024
@kainino0x kainino0x added this to the Milestone 0 milestone Jan 31, 2024
@kainino0x
kainino0x requested a review from jimblandy January 31, 2024 22:48
@kainino0x

Copy link
Copy Markdown
Contributor Author

@jimblandy revised, PTAL

@github-actions

github-actions Bot commented Mar 11, 2024 •

Copy link
Copy Markdown
Contributor

Previews, as seen when this build job started (fe175dc):
WebGPU webgpu.idl | Explainer | Correspondence Reference
WGSL grammar.js | wgsl.lalr.txt

Comment thread spec/index.bs Outdated
{{GPUCanvasAlphaMode/"premultiplied"}}, {{PredefinedColorSpace/"srgb"}},
{{GPUTextureFormat/"rgba8unorm"}} canvas, the color `[0.51, 0, 0, 0.5]` represents
<code><a funcdef>color</a>(srgb 1.02 0 0 / 0.5)</code>,
however upon presentation it could be internally unpremultiplied before color

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.

It's probably not actually likely that a browser would unpremultiply like this, as basically everything prefers to operate in premultiplied space. I don't think this is the only case under which bad things would happen. It was the easiest to explain, but could it mislead people to believe this is actually a likely scenario?

The example is not critical, but it's very helpful to demonstrate what we're talking about. Maybe it would be possible to show other examples as well of hypothetical compositing+display pipelines?

@kainino0x

Copy link
Copy Markdown
Contributor Author

I thought about this further, and I think there are some cases that this doesn't allow that we need to allow. I'm going to tentatively close this and open a new PR that does that.

@kainino0x kainino0x closed this Mar 18, 2024
@kainino0x kainino0x reopened this Mar 18, 2024
@kainino0x

Copy link
Copy Markdown
Contributor Author

It's OK if out-of-gamut intermediate values are written to the canvas, it only matters what's there when it gets presented.

Actually, we still need to fix this. I will still open another PR that both reduces the undefined behaviors and expands the examples.

@kainino0x

Copy link
Copy Markdown
Contributor Author

Actually, we still need to fix this. I will still open another PR that both reduces the undefined behaviors and expands the examples.

Opened draft #4526.

@kainino0x

kainino0x commented Mar 19, 2024 •

Copy link
Copy Markdown
Contributor Author

(This PR is ready for review though. PTAL)

@ccameron-chromium

Copy link
Copy Markdown
Contributor

The change makes sense to me.

@kainino0x
kainino0x requested a review from toji April 11, 2024 02:21

@toji toji left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, especially if @ccameron-chromium is comfortable with it.

@kainino0x
kainino0x merged commit 8bb5ca9 into gpuweb:main Apr 12, 2024
@kainino0x
kainino0x deleted the premultiplied-nit branch April 12, 2024 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copyediting Pure editorial stuff (copyediting, *.bs file syntax, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants