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: Detect needsBindGroupRefresh more properly #20272

Merged
merged 1 commit into from
Sep 6, 2020

Conversation

takahirox
Copy link
Collaborator

@takahirox takahirox commented Sep 5, 2020

This PR lets WebGPURenderer detect needsBindGroupRefresh more properly.

Problem this PR fixes

Renderer seems to have overlooked a case where texture is shared in multiple materials. Currently it determines whether bind group refresh is necessary or not just with comparing texture version and GPU texture version. But it doesn't work correctly if texture is shared in multiple materials. The second or later materials can't detect needsBindGroupRefresh because when they check the GPU texture version it has been already updated by the first material.

Solution

An easy solution would be comparing bind group's GPU texture with the one in texture property managed by WebGPUTextures. Refer to the code for detail.

Without this change. (An example many materials use the same texture.)

image

With this change.

image

@Mugen87
Copy link
Collaborator

Mugen87 commented Sep 6, 2020

Good find! It seems we need a combination of both approaches. I'm working with render targets right now and this change won't work if a render target's texture is used as a texture. The texture object also requires a bind to the respective group. I'll merge and clean up!

@Mugen87 Mugen87 added this to the r121 milestone Sep 6, 2020
@Mugen87 Mugen87 merged commit 5c302a5 into mrdoob:dev Sep 6, 2020
@Mugen87
Copy link
Collaborator

Mugen87 commented Sep 6, 2020

b166f40

@takahirox takahirox deleted the FixBindGroupRefresh branch September 6, 2020 20:53
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.

None yet

2 participants