Skip to content

[Dawn] Add multiple color-attachment support#594

Merged
sarahM0 merged 13 commits intogoogle:masterfrom
sarahM0:multi_color
Jul 25, 2019
Merged

[Dawn] Add multiple color-attachment support#594
sarahM0 merged 13 commits intogoogle:masterfrom
sarahM0:multi_color

Conversation

@sarahM0
Copy link
Contributor

@sarahM0 sarahM0 commented Jul 23, 2019

fixs #547 and simplifies DoClear by using helper functions

@sarahM0 sarahM0 changed the title [WIP] [Dawn] Add multicolor attachment support [Dawn] Add multicolor attachment support Jul 23, 2019
@sarahM0 sarahM0 changed the title [Dawn] Add multicolor attachment support [Dawn] Add multiple color-attachment support Jul 23, 2019
@sarahM0 sarahM0 requested a review from dneto0 July 23, 2019 21:26
Copy link
Collaborator

@dneto0 dneto0 left a comment

Choose a reason for hiding this comment

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

Do any tests start passing for Dawn, with this change?

::dawn::Buffer copy_buffer = device.CreateBuffer(&descriptor);

::dawn::BufferCopyView copy_buffer_view =
CreateBufferCopyView(copy_buffer, 0, dawn_row_pitch, 0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems you can pull the creation of the buffer and the buffer view outside the the loop. Their parameters are independent of i.

if (!mapped_device_texture.result.IsSuccess())
return mapped_device_texture.result;

if (i < render_pipeline.pipeline->GetColorAttachments().size()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a bit weird. Why is the for loop at line 581 up to kMaxColorAttachments but then we only restrict this later part to colour attachments attached to this pipeline? It seems weird that we would be copying buffers back to the host when they are not attached to the pipeline and hence not accessible to the pipeline.??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point!

Copy link
Collaborator

Choose a reason for hiding this comment

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

i has not changed since it was bounds-checked at line 596. So this "if" should disappear. Its condition always evaluates to true. Replace this if construct by its "then" body.

rpd.colorAttachmentCount = 1;
rpd.colorAttachments = color_attachment_descriptor;
rpd.depthStencilAttachment = depth_stencil_descriptor;
DawnPipelineHelper helper;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This whole routine is a lot simpler now! :-)

@sarahM0
Copy link
Contributor Author

sarahM0 commented Jul 24, 2019

../amber/tests/cases/draw_rect_multiple_color_attachment.amber
is the test that passes now (I'd forgotten to add run_tests.py).

@sarahM0 sarahM0 requested a review from dneto0 July 24, 2019 19:58
if (!mapped_device_texture.result.IsSuccess())
return mapped_device_texture.result;

if (i < render_pipeline.pipeline->GetColorAttachments().size()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

i has not changed since it was bounds-checked at line 596. So this "if" should disappear. Its condition always evaluates to true. Replace this if construct by its "then" body.


RUN my_pipeline DRAW_RECT POS 0 0 SIZE 800 600
EXPECT framebuffer IDX 0 0 SIZE 800 600 EQ_RGBA 0 128 0 204
EXPECT framebuffer IDX 0 0 SIZE 800 600 EQ_RGBA 0 127 0 204
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, I think this will fail on a vulkan host now (as it worked previously). Is this just a numerical difference between the dawn and vulkan engines?

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 see your point however right now Vulkan fails with 128 and passes with 127, at least on my machine. Is there any reasons for this to behave differently on different machines?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe? But, if both Vulkan and Dawn engines pass with this on your machine then I'm good with it. Maybe add a comment that we flipped the 128 to a 127 and if folks see this failing we need to find a better solution than changing the number? Just so we don't end up constantly flipping it back and forth, heh.

Copy link
Contributor Author

@sarahM0 sarahM0 Jul 25, 2019

Choose a reason for hiding this comment

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

How about changing 0.5 to 0.499 to eliminate the confusion?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If that works, go for it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, I suspect something funny with quantization of the very-low-precision floating point used in rendering. I could see it flipping back and forth.

All the other AmberScript scripts in the tests/cases directory use 127, except for the clear_color.amber script, but it's using an explicit 128 in that component of the clear color and it's using a UNORM so that's right in the middle of the range.

In short, I'm ok with this change. But let's keep an eye on this as an issue coming up.

Copy link
Collaborator

Choose a reason for hiding this comment

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

FYI. This is what Vulkan says about how UNORM and SNORM are treated

https://www.khronos.org/registry/vulkan/specs/1.1/html/vkspec.html#fundamentals-fpfixedconv

Copy link
Collaborator

Choose a reason for hiding this comment

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

I particular "Implementations should round to nearest. If r is equal to an integer, then that integer value must be returned."
So we could put 127.0/255.0 and it should get it. (that's 0.4980 while 128/255 is .50196) So 0.499 should be sufficient.

@sarahM0 sarahM0 merged commit 03f8d9a into google:master Jul 25, 2019
@sarahM0 sarahM0 deleted the multi_color branch July 25, 2019 16:28
Copy link
Collaborator

@dneto0 dneto0 left a comment

Choose a reason for hiding this comment

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

For what it's worth, I ran this version of the test, and it passes on my old NV Quadro K2000 desktop GPU. It used to fail with the 128 expectation.


RUN my_pipeline DRAW_RECT POS 0 0 SIZE 800 600
EXPECT framebuffer IDX 0 0 SIZE 800 600 EQ_RGBA 0 128 0 204
EXPECT framebuffer IDX 0 0 SIZE 800 600 EQ_RGBA 0 127 0 204
Copy link
Collaborator

Choose a reason for hiding this comment

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

FYI. This is what Vulkan says about how UNORM and SNORM are treated

https://www.khronos.org/registry/vulkan/specs/1.1/html/vkspec.html#fundamentals-fpfixedconv


RUN my_pipeline DRAW_RECT POS 0 0 SIZE 800 600
EXPECT framebuffer IDX 0 0 SIZE 800 600 EQ_RGBA 0 128 0 204
EXPECT framebuffer IDX 0 0 SIZE 800 600 EQ_RGBA 0 127 0 204
Copy link
Collaborator

Choose a reason for hiding this comment

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

I particular "Implementations should round to nearest. If r is equal to an integer, then that integer value must be returned."
So we could put 127.0/255.0 and it should get it. (that's 0.4980 while 128/255 is .50196) So 0.499 should be sufficient.

sarahM0 added a commit to sarahM0/amber that referenced this pull request Jul 25, 2019
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.

3 participants