Skip to content
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

WebGPURenderer: Initial Antialiasing #20281

Merged
merged 1 commit into from
Sep 7, 2020

Conversation

takahirox
Copy link
Collaborator

@takahirox takahirox commented Sep 7, 2020

This PR adds initial antialiasing support to WebGPURenderer.

API

WebGPURenderer constructor takes antialias parameter. Default is false.

const new renderer = WebGPURenderer( { antialias: true } );

Screenshot

Left with antialiasing and right without antialiasing.

image

Changes

In WebGL, HTMLCanvasElement.getContext() takes antialias parameter and if it's true hardware antialiasing is enabled.

In WebGPU, HTMLCanvasElement.getContext() doesn't take antialias and we seem to need to manually setup MSAA (at least now).


colorAttachment.attachment = renderTargetProperties.colorBuffer.createView();
colorAttachment.resolveTarget = renderTargetProperties.colorTextureGPU.createView();
colorAttachment.storeOp = GPUStoreOp.Store;
Copy link

Choose a reason for hiding this comment

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

This should be GPUStoreOp.Clear, unless you're planning on reusing the content of the multisampled texture. It helps a TON with memory bandwidth on tiler GPUs. The resolve target pixels will be stored, but multisampled pixels will be forgotten and the texture marked for lazy-clearing internally in Dawn/Chromium.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the comment. Updated.

Copy link
Collaborator

@Mugen87 Mugen87 Sep 8, 2020

Choose a reason for hiding this comment

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

@takahirox I had to remove the modifications to storeOp since enabling antialiasing produced a red screen. Would be great if you can revisit this setting. It's now using the default store again. 8e70942

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can you share a demo or code snippet which causes the problem? Here I enabled antialias in webgpu sandbox example but couldn't reproduce it.

Copy link
Collaborator

@Mugen87 Mugen87 Sep 8, 2020

Choose a reason for hiding this comment

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

Strange, it does not work on my system (macOS 10.15.6). I've just added the code back and set antialias to true in the example. I've updated to the latest Canary version (Version 87.0.4258.0) but without success. The entire screen becomes red.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hm it could be platform or hardware specific issue? Working fine on my Windows10 + Canary(87.0.4257.0) + intel(R) HD graphics 530.

Anyways, using default for now is ok to me because it still works on my system, too. Let's revisit later if needed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay, I'll try to check the demo tomorrow on a Windows 10 notebook.

@Kangz
Copy link

Kangz commented Sep 7, 2020

WebGPU canvas textures will always have a sample count of 1 because it makes the expensive MSAA resolve step explicit compared to WebGL where you could accidentally trigger resolves in some cases.

@mrdoob mrdoob added this to the r121 milestone Sep 7, 2020
@mrdoob mrdoob merged commit 56e4e44 into mrdoob:dev Sep 7, 2020
@mrdoob
Copy link
Owner

mrdoob commented Sep 7, 2020

Thanks!

@takahirox takahirox deleted the InitialAntialiasing branch September 7, 2020 21:16
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