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: update sampler bindings on texture change #28268

Merged
merged 2 commits into from
May 3, 2024

Conversation

aardgoose
Copy link
Contributor

Replacing the matcap texture by dragging a new matcap png in recent MeshMatcapNode Material exposes a bug where when a texture is changed, the related sampler binding is not, resulting in a failure in createBindGroup().

Update the sampler texture in these cases, we don't need to flag the update because the related sampledTexture binding will flag the update as required. The WebGL backend does not have this problem.

@Mugen87 Mugen87 added this to the r165 milestone May 3, 2024
@sunag sunag merged commit 5a6c9e1 into mrdoob:dev May 3, 2024
7 of 11 checks passed
@RenaudRohlinger
Copy link
Collaborator

RenaudRohlinger commented May 6, 2024

In some rare case I've experienced unsync of Sampler, as I dug deeper I also found issue with NodeSampled when resizing the screen with a node using a RenderTarget like so:

this._fbo = new RenderTarget();
const sampler = texture(this._fbo.texture);

I get this error (on screen resize):
image
Which will then generator an error in WebGPUBindingUtils.createBindGroup --> textureData.texture is not defined:

// `textureData.texture` is not defined because `textureData` is equal to `{}`
resourceGPU = textureData.texture.createView( { aspect: aspectGPU, dimension: dimensionViewGPU, mipLevelCount: binding.store ? 1 : textureData.mipLevelCount } );

I suspect it's due to the call of renderTarget.setSize() triggering a dispose event, which destroys the current textures attached to the renderTarget. Then, the textureGPU is re-bound too late to textureData.texture, possibly on the subsequent frame or even never?


Edit: My issue was only on Sampled node Sampler, the similarity of the names confused me, everything is alright regarding this PR!

/cc @aardgoose @sunag

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