Sitelet https://github.com/gpuweb/gpuweb/pull/313
Skip to content

Set initial frontFace value to "ccw" - #313

Merged
kainino0x merged 1 commit into
masterfrom
beaufortfrancois-patch-1
Jun 24, 2019
Merged

kainino0x merged 1 commit into
masterfrom
beaufortfrancois-patch-1

Conversation

@beaufortfrancois

@beaufortfrancois beaufortfrancois commented Jun 3, 2019 •

Copy link
Copy Markdown
Contributor

Instead of having web developers to specify a rasterizationState frontFace value for every singleGPURenderPipelineDescriptor and GPUComputePipelineDescriptor, how about having a default value as in OpenGL?

See https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glFrontFace.xhtml

@kvark

kvark commented Jun 3, 2019

Copy link
Copy Markdown
Contributor

The native APIs disagree what the default is, so the group decided to not default here, see #241 (comment)

@beaufortfrancois

beaufortfrancois commented Jun 3, 2019 •

Copy link
Copy Markdown
Contributor Author

If all native APIs provide a default value for frontFace, I don't see why Web GPU API should not provide one as well. No matter what the value is.

There are cases where web developers don't care about the frontFace value. Even though Web GPU is an explicit API, we should do our best to ease things when we can, and this seems like an easy thing to do.

@kvark

kvark commented Jun 3, 2019

Copy link
Copy Markdown
Contributor

If all native APIs provide a default value for frontFace, I don't see why Web GPU API should not provide one as well. No matter what the value is.

If there was the same value defaulted by the API, then I'd happily agree with you. If it's different, there is no huge need for us to pick one.

There are cases where web developers don't care about the frontFace value.

We shouldn't optimize the API ergonomics for the minority of cases. A scenario "I don't care, so I pick any" to me is much more affordable (from the API design perspective) than "I do care, but now I have a bug because I missed it", which affects not just the writing code experience, but also examples, reviews, etc.

Even though Web GPU is an explicit API, we should do our best to ease things when we can, and this seems like an easy thing to do.

Ergonomics of this API isn't high on the list. Portability, security, performance - these are top priorities. Digging the pit of success for the user - this is high for me: making sure the code is clear to read and that the change to accidentally making an error is low. This applies to the frontFace default.

@Kangz

Kangz commented Jun 6, 2019

Copy link
Copy Markdown
Contributor

If there was the same value defaulted by the API, then I'd happily agree with you. If it's different, there is no huge need for us to pick one.

The value of the default doesn't matter but I think having a default is important: it doesn't matter for experienced developers that know frontFace is a thing and have a convention in their engine, but it helps people starting to use WebGPU by removing unnecessary noise. frontFace is even better in that the other defaults (for cullMode and stencil front/back) make it so cww or cw don't have any effect if the other values in the descriptor are defaulted.

Ergonomics of this API isn't high on the list. Portability, security, performance - these are top priorities. Digging the pit of success for the user - this is high for me: making sure the code is clear to read and that the change to accidentally making an error is low. This applies to the frontFace default.

While ergonomics is lower on the list, I believe that having defaults for harmless values like frontFace doesn't trade any portability, security or performance and doesn't move us out away from the pit of success.

@kvark

kvark commented Jun 6, 2019

Copy link
Copy Markdown
Contributor

it helps people starting to use WebGPU by removing unnecessary noise

I don't see how this is an unnecessary noise. Back face culling is ubiquitous. And since we are not the source of vertex/mesh data for the user, it's their responsibility to communicate to us what convention that data uses.

I would argue that a case where frontFace doesn't make a difference - drawing screen-space aligned quads - is more on the advanced side (post-fx or UI systems) than drawing simple meshes, which means having a default there doesn't help a novice developer anyway.

While ergonomics is lower on the list, I believe that having defaults for harmless values like frontFace doesn't trade any portability, security or performance and doesn't move us out away from the pit of success.

This is true, it doesn't harm any of the hard requirements we have on the API. What it affects is how we play with the ecosystem: do we state an opinion that we try to push downstream, or do we stay unopinionated? It doesn't appear to me that stating the opinion brings us any closer to these goals either.

@magcius

magcius commented Jun 6, 2019

Copy link
Copy Markdown

We can always add a default later, but never take one away.

As a developer, I've been tripped up by the differing frontface defaults before during ports between D3D/GL, and it's still common to see people reverse cull mode instead of setting the proper front face, so at least adding that slight moment of pause might be helpful.

@Kangz

Kangz commented Jun 6, 2019

Copy link
Copy Markdown
Contributor

I don't see how this is an unnecessary noise.

@beaufortfrancois is currently learning WebGPU, and this noise is making it more difficult to understand the API, even if I'm right there to explain things. Also he is looking at how to make articles to teach WebGPU 101 to evangelize the API and this kind of noise will scare people away. frontFace is just one example and there are many others things that make even the most simple WebGPU examples feel "experts-only".

@kvark

kvark commented Jun 6, 2019

Copy link
Copy Markdown
Contributor

@Kangz I fail to understand how you call frontFace "experts-only" while the very same tutorials create pipelines, bind groups and layouts, command and pass encoders, do mapping and submissions, etc.

@Kangz

Kangz commented Jun 6, 2019

Copy link
Copy Markdown
Contributor

Imagine you come from a Javascript background and maybe have used three.js but not WebGL itself. If we want to teach you WebGPU from the basics and start with a 30-line render pipeline descriptor that introduces 10 different concepts including frontFace, it looks "experts only". Meaning that you already need to be an expert to understand that API. It may not be true but this matters for beginners, and has no costs for more advanced users of the API.

@magcius

magcius commented Jun 6, 2019 •

Copy link
Copy Markdown

One thing that is certainly awkward is that frontFace is a strange pick for "the only required field". An alternate solution to this might be to make a few more fields required as well, so instead of createRenderPipeline({ frontFace: 'cw' }), you get createRenderPipeline({ cullMode: 'none', frontFace: 'cw', depthTest: 'lequal', depthWrite: true }), which feels more balanced.

API ergonomics is a strange thing to quantify, but I feel if we're going to have a few fields be required, they should be the ones that count. It doesn't really harm professionals either, since they're going to be passing everything anyway, and being explicit can be friendly to beginners.

@kdashg

kdashg commented Jun 6, 2019

Copy link
Copy Markdown
Contributor

Some of us were thinking of perhaps letting frontFace be optional in webidl, but have unset-frontFace with triangle prims be a validation error.

@kainino0x

Copy link
Copy Markdown
Contributor

Just for a little extra context, IIRC we previously discussed merging frontFace with cullMode. (It may seem like frontFace doesn't matter if culling is disabled.) But there was at least one reason we couldn't do that: gl_FrontFacing (Were/are there others?)

Still, maybe there is value in a specced default that's only allowed with cullMode "none", under the assumption that caring about the winding order without culling is relatively rare.

@kainino0x

kainino0x commented Jun 7, 2019 •

Copy link
Copy Markdown
Contributor

I.e. GPUFrontFace frontFace;: not required, but no default. Only valid to omit frontFace with cullMode: "none", in which case it means "ccw".

@Kangz

Kangz commented Jun 7, 2019

Copy link
Copy Markdown
Contributor

frontFace also interacts with the stencilFront and stencilBack members of the GPUDepthStencilDescriptor. We could allow it not being present when the primitiveTopology isn't triangle based.

@magcius

magcius commented Jun 7, 2019

Copy link
Copy Markdown

Do we expect non-triangle-based topologies often? If this is raised because it's awkward for beginners to use, I don't expect point/line topologies to be part of that use case.

@kainino0x

Copy link
Copy Markdown
Contributor

Agreed, although, in addition to a "learning" cost, there's also an "annoyance" cost. And I think in cases where there's no downside to reducing the annoyance cost, we should.

@grorg

grorg commented Jun 24, 2019

Copy link
Copy Markdown
Contributor

Discussed at 25 Jun 2019 teleconference

@kainino0x

Copy link
Copy Markdown
Contributor

Resolution: merge without changes.

@kainino0x
kainino0x merged commit 2ac88d2 into master Jun 24, 2019
@beaufortfrancois
beaufortfrancois deleted the beaufortfrancois-patch-1 branch June 24, 2019 19:45
aarongable pushed a commit to chromium/chromium that referenced this pull request Jun 25, 2019
Instead of having web developers to specify a rasterizationState frontFace
value for every singleGPURenderPipelineDescriptor, a default value is now
provided according to spec change.
See gpuweb/gpuweb#313

Bug: 877147
Change-Id: I05b059b9e189c996d8a087b45f4a3e82cffc7df0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1675764
Auto-Submit: François Beaufort <beaufort.francois@gmail.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672010}
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
This changes the generated code to use class properties instead of
polyfilling them. This cleans up the generated code for a lot of files.

According to MDN, these are supported starting from Chrome 72,
Firefox 69, and Safari 14.
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.

7 participants