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: copyFramebufferToTexture() is broken when called outside of render(). #29713

Closed
ligaofeng0901 opened this issue Oct 21, 2024 · 3 comments · Fixed by #29729
Closed
Labels

Comments

@ligaofeng0901
Copy link
Contributor

ligaofeng0901 commented Oct 21, 2024

Description

In the old version, I use renderer.copyFramebufferToTexture to render something to texture. There are many generated textures from offscreen scenes with a shared RenderTarget. So I use renderer.copyFramebufferToTexture many times before the rendering of main scene.
After switching into WebGPU version, renderer.copyFramebufferToTexture is broken, the reason is that I invoke copyFramebufferToTexture out of the render() method. The code of this line

const renderContext = this._currentRenderContext;

this._currentRenderContext is valid only when the code between the start and end of render. And it always turns out null in my use case.

Reproduction steps

Code

 let oldRenderTarget = renderer.getRenderTarget();
  renderer.setRenderTarget(renderTarget);
  renderer.clear();
  renderer.render(this._mesh, _camera);
  renderer.copyFramebufferToTexture(outputTexture);
  renderer.setRenderTarget(oldRenderTarget);

Live example

Screenshots

No response

Version

r169

Device

No response

Browser

No response

OS

No response

@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 21, 2024

Do you mind sharing a live example that demonstrates the issue with WebGPURenderer?

@ligaofeng0901
Copy link
Contributor Author

Do you mind sharing a live example that demonstrates the issue with WebGPURenderer?

https://jsfiddle.net/ligaofeng0901/xnh8zt1y/

@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 22, 2024

I can confirm the issue. The problem is that copyFramebufferToTexture() requires a render context but it can't query it without a scene and camera.

We would run into the same issue if we would try to migrate webgl_framebuffer_texture to WebGPURenderer.

@Mugen87 Mugen87 added the Bug label Oct 22, 2024
@Mugen87 Mugen87 changed the title copyFramebufferToTexture is broken out of function render() WebGPURenderer: copyFramebufferToTexture() is broken when called outside of render(). Oct 22, 2024
@Mugen87 Mugen87 removed the Bug label Oct 22, 2024
@Mugen87 Mugen87 added the WebGPU label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants