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

Pass attachments state by value - #102

Merged
kvark merged 1 commit into
gpuweb:masterfrom
kvark:at-state
Oct 31, 2018
Merged

kvark merged 1 commit into
gpuweb:masterfrom
kvark:at-state

Conversation

@kvark

@kvark kvark commented Oct 25, 2018 •

Copy link
Copy Markdown
Contributor

This is an alternative to #92. I like it less, but I need this problem to be solved so here is what the other position can look like. Please do form an opinion on which approach works better for us!

Fixes #103

The way this proposal works is: attachments state is not baked. We provide it as a dictionary when creating a render pipeline, and it has the necessary information to figure out what attachments need to be resolved by the end of an implicit pass. When beginning a render pass, we have the actual textures, so we can derive the same formats and sample counts, plus we provide the MSAA sample count of rasterization, which should allow us to reconstruct/derive the render pass object to use.

The reason I like this solution less is: there are more implicit bits, and more work for the backend. We need to document that the attachment formats and sample counts have to exactly match between render pipelines and render passes where they are used, and the backend needs to check for them. In #92, the idea was that the actual handle to baked WebGPUAttachmentsState has to match, which is easier to document, and the backend doesn't have to keep a global map between the attachment descriptions and actual native render passes.

@kvark
kvark requested a review from Kangz October 25, 2018 01:20
Comment thread design/sketch.webidl Outdated
sequence<WebGPURenderPassColorAttachmentDescriptor> colorAttachments;
WebGPURenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
// Number of MSAA samples for rasterization
u32 samples;

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.

Isn't that already encoded in the textures themselves? We have to check that all textures have the same sample count.

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.

that's the point: we'll go through the actual textures and check their sample counts:

  • if it matches, good
  • it this one is higher than 1, but the texture sample count is 1, then this is a resolve attachment
  • otherwise, it's an error

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.

What if samples is 2 and the texture has a sample count of 4? I'm not sure that having magic values is the best way to describe multisample resolves. Didn't we have a whole GitHub investigation on multisampling?

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 am also confused by the samples field. Having one samples field prevents us from resolving some of the attachments to 4 and others to 2. I think we also need additional data to know which textures are resolve sources and which ones are resolve destinations.

Comment thread design/sketch.webidl
// Array of color attachments
sequence<WebGPUAttachment> colorAttachments;
// Optional depth/stencil attachment
WebGPUAttachment? depthStencilAttachment;

@Kangz Kangz Oct 25, 2018 •

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.

Not important for WebGPU, but this will translate to a nullable pointer to struct in Dawn, which our remoting layer doesn't have support for atm.

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.

How else do you express a proper Option? :)

Comment thread design/sketch.webidl
// Attachment data format
WebGPUTextureFormatEnum format;
// Number of MSAA samples
u32 samples;

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.

This is pending discussion of multisampling, but I think we also need to add "boolean isResolvedAtEndOfRenderPass" because VkRenderPass compatibility includes "VkSubpassDescription:: pResolveAttachments". I'll open an issue on Vulkan-Docs to ask if this can be relaxed for single-subpass render passes.

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.

the point of this PR is that we can derive the need of those being resolved simply by looking at the sample counts

Comment thread design/sketch.webidl

interface WebGPUAttachmentsState {
// Description of the framebuffer attachments
dictionary WebGPUAttachmentsState {

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.

Why make it a dictionary?

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.

The point of this PR is to remove the attachment state as a handle, because there is no backend-specific data to associate with it. The render pass details is derived from the actual data passed to render pipeline creation and the beginning of a render pass.

Comment thread design/sketch.webidl Outdated
sequence<WebGPURenderPassColorAttachmentDescriptor> colorAttachments;
WebGPURenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
// Number of MSAA samples for rasterization
u32 samples;

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.

What if samples is 2 and the texture has a sample count of 4? I'm not sure that having magic values is the best way to describe multisample resolves. Didn't we have a whole GitHub investigation on multisampling?

Comment thread design/sketch.webidl Outdated
WebGPUInputState inputState;
WebGPUAttachmentsState attachmentsState;
// Number of MSAA samples for
u32 samples;

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.

so this u32 samples is compared to the u32 samples below? I'm a little confused.

Comment thread design/sketch.webidl
sequence<WebGPUTextureFormatEnum> formats;
// TODO other stuff like sample count etc.
// Description of a single attachment
dictionary WebGPUAttachment {

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.

Is this eventually going to be the place where we add things like blending operations?

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.

We might want to have separate types for color attachments and depth/stencil attachments before we add blending.

@kvark

kvark commented Oct 29, 2018

Copy link
Copy Markdown
Contributor Author

I removed the MSAA bits from everything except WebGPUAttachment until we figure out the details. The resolve attachments can't be derived properly at the moment, but we'll keep them in mind when designing the MSAA bits of the API.

@kvark kvark changed the title Pass attachments state by value, plus a few MSAA bits Pass attachments state by value Oct 29, 2018

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

Thanks for the update, LGTM

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

@kvark 's latest change LGTM.

bors Bot added a commit to gfx-rs/wgpu that referenced this pull request Oct 31, 2018
25: Proper render pass support r=grovesNL a=kvark

This PR implements the API scheme of gpuweb/gpuweb#102 and caches both render passes and framebuffers properly in the device.

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
@kvark
kvark merged commit 99e532c into gpuweb:master Oct 31, 2018
@kvark
kvark deleted the at-state branch October 31, 2018 14:46
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.

Clarify the attachments state semantics

4 participants