Skip to content

render.calls is always 0 #42

@davcri

Description

@davcri

Issue

https://codesandbox.io/s/r3f-perf-issue-with-gl-0do0bm

const perf = getPerf()
console.log(perf.gl?.info.render.calls) // 0
console.log(perf.gl?.info.render.triangles) // 0

I think this is because of the gl.info.reset() in https://github.com/utsuboco/r3f-perf/blob/main/src/components/PerfHeadless.tsx#L262

Possible fix

Could we save render.calls and render.triangles in the store? In this way we don't break code which relies on that number.

Possible workaround

const info = usePerf((state) => state.gl?.info)
    
useFrame((state) => {
    const { camera, gl, scene } = state
    gl.render(scene, camera)
    console.log(info.render.frames) 
}, 1)

I'm not sure though if this can cause some issue. Do gl.render() gets called twice in this way? Once for useFrame(...,1) and then for useFrame(..., Infinity)?

const Renderer = () =>{
useFrame(function updateR3FPerf({ gl, scene, camera }) {
camera.updateMatrix()
matriceCount.value -= 1
camera.matrixWorld.copy(camera.matrix)
camera.matrixWorldInverse.copy(camera.matrixWorld).invert();
gl.render(scene,camera)
matriceWorldCount.value = 0
matriceCount.value = 0
}, Infinity)
return null
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions