Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

toji
Copy link
Member

@toji toji commented Jun 2, 2020

This pull request is incomplete, but I wanted to verify that the pattern I'm using here is what the group would like to see. Started with simply documenting beginRenderPass() and fell down a rabbit hole real quick.

It looks like elsewhere in the spec validation of various descriptors is described in the algorithms that make use of them. It feels cleaner to me, however, to describe the criteria for a valid descriptor with the descriptor dictionary definition. Not only does this make it easier for those reading the spec later to reference, as all the rules for a type are in one place, but also allows for multiple algorithms to reference the same validation rules and makes validation of nested descriptors more palatable.

If this approach works for the group I'll be happy to flesh out this PR with a more complete set of validation rules and key descriptions.


Preview | Diff

@toji toji requested review from kvark and kainino0x June 2, 2020 22:26
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.

I've wrangled with this a bit before too. This looks great to me.

The guiding principle I want to use is that this spec should be usable as a reference for WebGPU programmers, and the gnarly details should stay out of the way. I think this works pretty well.

I also like the approach to make the descriptor-member definitions fairly informal. Their formal behaviors can be explained by other algorithms/rules that reference them.

toji and others added 2 commits June 2, 2020 18:59
Co-authored-by: Kai Ninomiya <[email protected]>
Co-authored-by: Kai Ninomiya <[email protected]>
Copy link
Contributor

@Kangz Kangz left a comment

Choose a reason for hiding this comment

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

LGTM

::
Issue: Describe this dictionary member

: <dfn>depthReadOnly</dfn>
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we might need to require that depthReadOnly implies depthLoadOp == "load", likewise for stencil.

Copy link
Contributor

Choose a reason for hiding this comment

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

since the load ops are required, they can't currently be implied
but yes, we do need some wording to ensure that depthReadOnly == true can only be used with "load".

Copy link
Contributor

@kainino0x kainino0x Jun 3, 2020

Choose a reason for hiding this comment

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

I think depthReadOnly (/stencil) also means depthStoreOp (/stencil) needs to be "store".

Copy link
Contributor

Choose a reason for hiding this comment

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

both store ops don't make any sense for the read-only depth

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 depthStoreOp "store" makes sense because the pass-local depth values wouldn't be able to change at all with depthReadOnly. So you "load" the original value and "store" without any changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes it does

Copy link
Contributor

Choose a reason for hiding this comment

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

It needs OUTPUT_ATTACHMENT regardless of any of the flags here, even if you can't actually output to it at all.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kvark

dictionary GPURenderPassDepthStencilAttachmentDescriptor {
    required GPUTextureView attachment;
    required (GPURenderPassDepthStencilReadOnly or GPURenderPassDepthReadWriteDescriptor) depth;
    required (GPURenderPassDepthStencilReadOnly or GPURenderPassStencilReadWriteDescriptor) stencil;
};
enum GPURenderPassDepthStencilReadOnly {
    "readonly"
};
dictionary GPURenderPassDepthReadWriteDescriptor {
    required (GPULoadOp or float) loadValue;
    required GPUStoreOp storeOp;
};
dictionary GPURenderPassStencilReadWriteDescriptor {
    required (GPULoadOp or GPUStencilValue) loadValue;
    required GPUStoreOp storeOp;
};

maybe?

Copy link
Contributor

Choose a reason for hiding this comment

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

that's fancy! Do you think we could merge those structs? i.e. having something like GPULoadOp or number, where number can dynamically be float or int

Copy link
Contributor

Choose a reason for hiding this comment

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

It's certainly possible, we can just say "convert the number to GPUStencilValue" in text or something. But I would prefer to leave it this way and let IDL take care of that. Plus it couldn't be reused in GPURenderPassColorAttachmentDescriptor (except using a union/any) since the type there is totally different.

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.

Nice work there, thank you!

It feels cleaner to me, however, to describe the criteria for a valid descriptor with the descriptor dictionary definition.

I think that makes sense to do. We just need to be careful to avoid sending the reader to a maze of links saying what can and what can't be done.
For example, Vulkan valid usage rules are required to describe all the rules in a single list for every function. This is more difficult to write and maintain, but from the user perspective it's great to see everything in one place.

::
Issue: Describe this dictionary member

: <dfn>depthReadOnly</dfn>
Copy link
Contributor

Choose a reason for hiding this comment

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

since the load ops are required, they can't currently be implied
but yes, we do need some wording to ensure that depthReadOnly == true can only be used with "load".

@toji
Copy link
Member Author

toji commented Jun 3, 2020

Addressed some of the feedback, had a question about what a "single subresource" means.

@toji toji marked this pull request as ready for review June 4, 2020 22:21
@toji
Copy link
Member Author

toji commented Jun 4, 2020

Took one more pass at this to address the remaining feedback and fill in a few details I had passed over previously. Please take another look!

::
Issue: Describe this dictionary member

: <dfn>depthReadOnly</dfn>
Copy link
Contributor

Choose a reason for hiding this comment

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

yes it does

@Kangz
Copy link
Contributor

Kangz commented Jun 5, 2020

Feel free to address my comments in another PR if that's too much churn.

@toji toji force-pushed the validate-renderpass branch from 2a90106 to ae64f57 Compare June 5, 2020 22:13
@toji
Copy link
Member Author

toji commented Jun 5, 2020

Thanks all! All feedback should be resolved at this point. Let me know if you see anything else I've missed.

Issue: Describe this dictionary member
</dl>

<div class=validusage dfn-for=GPURenderPassDescriptor>
Copy link
Contributor

Choose a reason for hiding this comment

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

hm, these should be algorithms, but we can't actually trivially make them algorithms easily with <div algorithm class=validusage ...> because they'll just end up with the algorithm name "Valid Usage". We'll figure this out later.

@kainino0x
Copy link
Contributor

Made some minor revisions; I think this is ready to land.

@kainino0x kainino0x merged commit 1660ec7 into gpuweb:master Jun 5, 2020
@toji toji deleted the validate-renderpass branch June 6, 2020 18:00
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this pull request Sep 6, 2022
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.

4 participants