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: Add backend information to data-engine field. #29670

Merged
merged 3 commits into from
Oct 16, 2024

Conversation

jclaessens97
Copy link
Contributor

Description

Currently there is no easy way to debug if you're running on webgpu or webgl fallback. There is an data-engine attribute, but it's always set to webgpu. This should make it easier to debug that.

This contribution is funded by Segments.ai

Copy link

github-actions bot commented Oct 16, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 690.67
171.1
690.67
171.1
+0 B
+0 B
WebGPU 816.43
220.08
816.5
220.08
+66 B
+8 B
WebGPU Nodes 815.94
219.95
816.01
219.96
+66 B
+9 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 463.31
111.89
463.31
111.89
+0 B
+0 B
WebGPU 538.61
145.41
538.68
145.42
+66 B
+9 B
WebGPU Nodes 494.73
135.28
494.79
135.28
+66 B
+9 B

@jclaessens97 jclaessens97 changed the title feat: add engine field to easier debug if running on webgl or webgpu WebGPURenderer: add engine field to easier debug if running on webgl or webgpu Oct 16, 2024
@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 16, 2024

There is an data-engine attribute, but it's always set to webgpu.

How about we about the data-engine attribute so it provides more information? In this way, we don't have update Info. The following in Backend should do the trick:

getDomElement() {

    let domElement = this.domElement;

    if ( domElement === null ) {

        domElement = ( this.parameters.canvas !== undefined ) ? this.parameters.canvas : createCanvasElement();

        const backend = ( this.coordinateSystem === WebGPUCoordinateSystem ) ? 'WebGPU backend' : 'WebGL backend';

        // OffscreenCanvas does not have setAttribute, see #22811
        if ( 'setAttribute' in domElement ) domElement.setAttribute( 'data-engine', `three.js r${REVISION} WebGPURenderer, ${backend}` );

        this.domElement = domElement;

    }

    return domElement;

}

@Mugen87 Mugen87 added this to the r170 milestone Oct 16, 2024
@Mugen87 Mugen87 changed the title WebGPURenderer: add engine field to easier debug if running on webgl or webgpu WebGPURenderer: Add backend information to data-engine field. Oct 16, 2024
@Mugen87 Mugen87 merged commit ac5804d into mrdoob:dev Oct 16, 2024
12 checks passed
@jclaessens97 jclaessens97 deleted the chore/debug-info-engine branch October 16, 2024 13:03
@linbingquan
Copy link
Contributor

图片

I think this display is incorrect.

Renderer.domElement = backend.getDomElement(); code was runing before await Renderer.init().

Test browser: Firefox 131

@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 16, 2024

Good catch! I'll revert the PR for now. Let's think about a new solution.

@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 16, 2024

@jclaessens97 If you are interested in the current used backend, can't you just evaluate renderer.backend.coordinateSystem?

@jclaessens97
Copy link
Contributor Author

Probably yes. Thought it would be useful to have directly in three, but now that I know what to look for, I succesfully implemented it that way without a need of having it in threejs!

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.

3 participants