这是indexloc提供的服务,不要输入任何密码
Skip to content

Add default values to most dictionary fields #241

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

Merged
merged 1 commit into from
Apr 15, 2019

Conversation

litherum
Copy link
Contributor

@litherum litherum commented Mar 9, 2019

Default values make authors' lives easier.

@litherum
Copy link
Contributor Author

litherum commented Mar 9, 2019

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

Copy link
Contributor

@grorg grorg left a comment

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!

Copy link
Contributor

@kainino0x kainino0x left a comment

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

boolean depthWriteEnabled;
GPUCompareFunction depthCompare;
boolean depthWriteEnabled = false;
GPUCompareFunction depthCompare = "always";

GPUStencilStateFaceDescriptor stencilFront;
GPUStencilStateFaceDescriptor stencilBack;
Copy link
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
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
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
Copy link
Contributor

@kvark kvark left a comment

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.

@grorg
Copy link
Contributor

grorg commented Mar 18, 2019

Discussed at 18 Mar 2019 teleconference

@kainino0x
Copy link
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

sequence<GPURenderPassColorAttachmentDescriptor> colorAttachments;
GPURenderPassDepthStencilAttachmentDescriptor? depthStencilAttachment;
required sequence<GPURenderPassColorAttachmentDescriptor> colorAttachments;
GPURenderPassDepthStencilAttachmentDescriptor? depthStencilAttachment = null;
Copy link
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.

@grorg
Copy link
Contributor

grorg commented Apr 1, 2019

Discussed at the 1 April Teleconference

Copy link
Contributor

@kainino0x kainino0x left a comment

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.

};

dictionary GPUInputStateDescriptor {
GPUIndexFormat indexFormat;
required GPUIndexFormat indexFormat;
Copy link
Contributor

@JusSn JusSn Apr 9, 2019

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
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
Contributor

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

@litherum
Copy link
Contributor Author

Rebased.

Copy link
Contributor

@kainino0x kainino0x left a comment

Choose a reason for hiding this comment

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

LGTM!

@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
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