Skip to content

WebGPURenderer: Persistent video texture approach #31416

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

Merged
merged 1 commit into from
Jul 15, 2025
Merged

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Jul 15, 2025

Closes #31330, #31397

Description

Replaces texture_external with a persistent texture using copyExternalImageToTexture() updating by requestVideoFrameCallback of VideoTexture, reusing all of the core's texture management, including sharing between materials, and adds support for vertex stage usage too.

@Mugen87 I think this is the best way, in addition to the benefits, it reduces the total code.

Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 338.28
78.93
338.28
78.93
+0 B
+0 B
WebGPU 558.52
154.58
557.63
154.34
-893 B
-248 B
WebGPU Nodes 557.45
154.37
556.55
154.12
-893 B
-249 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 469.62
113.66
469.62
113.66
+0 B
+0 B
WebGPU 634.18
171.62
633.28
171.4
-892 B
-220 B
WebGPU Nodes 589.31
160.95
588.42
160.71
-892 B
-239 B

@mrdoob mrdoob added this to the r179 milestone Jul 15, 2025
@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 15, 2025

Yes, that sounds like a good solution 👍 .

Are parts of the PR missing though? I don't see any changes to VideoTexture or usage of copyExternalImageToTexture()?

@sunag sunag marked this pull request as ready for review July 15, 2025 14:40
@sunag
Copy link
Collaborator Author

sunag commented Jul 15, 2025

Great, right? The current texture system was reused, and most things worked auto-magically.

@sunag sunag merged commit b38ac17 into mrdoob:dev Jul 15, 2025
13 of 14 checks passed
@sunag sunag deleted the dev-video branch July 15, 2025 14:56
@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 15, 2025

Ah I see, the code goes now in the WebGPUTextureUtils._copyImageToTexture() branch. Neat!

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.

ProjectorLight : VideoTexture projected on multiple meshes fails with multiple "Destroyed texture" warnings
3 participants