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

Add default values to most dictionary fields - #241

Merged
kainino0x merged 1 commit into
gpuweb:masterfrom
litherum:defaultvalues
Apr 15, 2019
Merged

kainino0x merged 1 commit into
gpuweb:masterfrom
litherum:defaultvalues

Conversation

@litherum

@litherum litherum commented Mar 9, 2019

Copy link
Copy Markdown
Contributor

Default values make authors' lives easier.

@litherum

litherum commented Mar 9, 2019

Copy link
Copy Markdown
Contributor Author

Looks like D3D12 also has some default values: https://docs.microsoft.com/en-us/windows/desktop/direct3d12/helper-structures-for-d3d12

@grorg grorg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also saves us having to do some work in the API wrapper!

@kainino0x kainino0x left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm overall, with a bunch of comments

Comment thread design/sketch.webidl Outdated
Comment thread design/sketch.webidl Outdated
Comment thread design/sketch.webidl Outdated
Comment thread design/sketch.webidl Outdated
Comment thread design/sketch.webidl Outdated
Comment thread design/sketch.webidl Outdated
Comment thread design/sketch.webidl Outdated
GPUCompareFunction depthCompare = "always";

GPUStencilStateFaceDescriptor stencilFront;
GPUStencilStateFaceDescriptor stencilBack;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If an app doesn't specify these, do they get the default values above? Or will we have to do that manually in implementations?

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 guess these should say = {}.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unfortunately doesn't seem to be valid idl, I tried it earlier. (https://w3c.github.io/webidl2.js/checker/)

kvark
kvark previously requested changes Mar 9, 2019

@kvark kvark left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I strongly believe that we shouldn't be over-opinionated here. It's still an explicit API that expects certain level of understanding from the user.

Defaults make sense for cases where "I don't want to think about it", "I don't know what it is", or "I don't care". A good example of this is depth bias options: defaults for them are perfectly fine because non-defaults mean something extra is done by the hardware. Same goes for other fixed-function blocks, such as depth or stencil (which is why the default depth/stencil comparison should be "always"). It can also be applied to texture parameters: until the user starts caring about the arrays, the number of layers can default to 1, and same for the number of mipmap levels. Interestingly, the logic can also be projected to the load/store operations: if the user doesn't care, the operations should preserve the contents by default.

Aside stand the parameters where the user has to select something, as opposed to a binary opt-in: texture format, front face, or things like the clear values for color/depth. I believe this is where we should be drawing a line: not provide defaults for these.

Comment thread design/sketch.webidl Outdated
Comment thread design/sketch.webidl Outdated
Comment thread design/sketch.webidl Outdated
Comment thread design/sketch.webidl Outdated
Comment thread design/sketch.webidl
Comment thread design/sketch.webidl Outdated
Comment thread design/sketch.webidl
Comment thread design/sketch.webidl
Comment thread design/sketch.webidl
Comment thread design/sketch.webidl Outdated
@grorg

grorg commented Mar 18, 2019

Copy link
Copy Markdown
Contributor

Discussed at 18 Mar 2019 teleconference

Comment thread design/sketch.webidl Outdated
Comment thread design/sketch.webidl Outdated
@kainino0x

Copy link
Copy Markdown
Contributor

(Sorry if this isn't ready yet.) Any chance we could get the last few contentious defaults split to another PR so we can land this asap?

BTW, here is the parsing rule for default values - but it's fine to have invalid IDL for now.

DefaultValue ::
    ConstValue
    string
    [ ]
    null

Comment thread design/sketch.webidl Outdated
Comment thread design/sketch.webidl
sequence<GPURenderPassColorAttachmentDescriptor> colorAttachments;
GPURenderPassDepthStencilAttachmentDescriptor? depthStencilAttachment;
required sequence<GPURenderPassColorAttachmentDescriptor> colorAttachments;
GPURenderPassDepthStencilAttachmentDescriptor? depthStencilAttachment = null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Our idl parser doesn't allow dictionary types to have a ?. (I think it wants GPURenderPassDepthStencilAttachmentDescriptor depthStencilAttachment = null maybe.) But webidl2.js does allow it, so I'm not sure if this is indicative of a problem.

Comment thread design/sketch.webidl Outdated
Comment thread design/sketch.webidl Outdated
Comment thread design/sketch.webidl
@grorg

grorg commented Apr 1, 2019

Copy link
Copy Markdown
Contributor

Discussed at the 1 April Teleconference

@kainino0x kainino0x left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TODO:

  • remove GPUBufferUsage.ALL
  • require GPUTextureDescriptor.format
  • require GPURenderPassColorAttachmentDescriptor.{load,store}Op
  • require GPURenderPassDepthStencilAttachmentDescriptor.{depth,stencil}{Load,Store}Op
  • require GPURenderPassDepthStencilAttachmentDescriptor.clearDepth (@kvark will open a PR to refactor it)
  • Merge!

We will consider adding more defaults later.

Comment thread design/sketch.webidl

dictionary GPUInputStateDescriptor {
GPUIndexFormat indexFormat;
required GPUIndexFormat indexFormat;

@JusSn JusSn Apr 9, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can this be optional (throw an error if drawIndexed is called and this is not set)? For the case where drawIndexed is never called with this pipeline.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's worth considering; we ran into this issue when we were writing demos too. Let's do it in another issue/PR after this one, though.

@kainino0x

Copy link
Copy Markdown
Contributor

ping: can we get this updated/rebased and merged?

@litherum

Copy link
Copy Markdown
Contributor Author

Rebased.

Comment thread spec/index.bs

@kainino0x kainino0x left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

Comment thread spec/index.bs
@kainino0x
kainino0x requested a review from kvark April 15, 2019 20:37
@kainino0x
kainino0x dismissed kvark’s stale review April 15, 2019 20:37

Issues resolved

@kainino0x

Copy link
Copy Markdown
Contributor

@kvark FYI, I think all of your comments are addressed. You can re-review when you're back if you want, but merging this now.

@kainino0x
kainino0x merged commit 15dadf3 into gpuweb:master Apr 15, 2019
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
Implements Validation Tests For StoreOp
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.

8 participants