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

Negative value on mac m3 with webgpu #8

Open
Makio64 opened this issue Apr 26, 2024 · 17 comments
Open

Negative value on mac m3 with webgpu #8

Makio64 opened this issue Apr 26, 2024 · 17 comments

Comments

@Makio64
Copy link

Makio64 commented Apr 26, 2024

I got negative value for the GPU time while checking last commits/examples update on threejs release164.

Screenshot 2024-04-26 at 14 09 33

I know webgpu is fast but this seems too fast haha :D

Device : macbook pro m3 max
OS : MacOs latest
Browser : Chrome latest

@RenaudRohlinger
Copy link
Owner

m3 max too stronk.

Unexpected indeed, will check.😁

@Makio64
Copy link
Author

Makio64 commented Jul 31, 2024

Hi @RenaudRohlinger , do you need help to investigate this issue and calm down the m3 max ? :D

The calculation from here seem correct : https://webgpu.github.io/webgpu-samples/?sample=bundleCulling
Screenshot 2024-07-31 at 17 48 31

@RenaudRohlinger
Copy link
Owner

Even with my M1 Max Pro and iPhone 12, I am unable to reproduce this issue, nor the one described in #11.

Without encountering these bugs myself, it's difficult for me to diagnose and fix the issue. Could you clarify if the problem seems to originate from the Three.js side or the stats-gl side?

You can try logging the values with console.log(gl.info.render.timestamp) in the examples to confirm this. /cc @Makio64.

@Makio64
Copy link
Author

Makio64 commented Jul 31, 2024

This console.log return me : gl is undefined
I cloned three.js and changed the example of batch adding some log on stats.gl but its always null
Your example https://stats.renaudrohlinger.com/ works as expected ( bellow screenshot )

Screenshot 2024-07-31 at 21 10 29

@Makio64
Copy link
Author

Makio64 commented Nov 2, 2024

The problem is still present on latest version ( macos chrome )

low power mode screenshot :
Screenshot 2024-11-02 at 11 55 06

normal mode :
Screenshot 2024-11-02 at 11 58 09

On safari it didnt display gpu informations even the webgpu mode is enabled, should i enabled other extension ?

@Makio64
Copy link
Author

Makio64 commented Nov 2, 2024

also didnt display on safari webgpu enabled on iOS

@darrinm
Copy link

darrinm commented Nov 13, 2024

I'm also seeing negative numbers (macOS Chrome, Mac Studio M2 Ultra):

screenshot 2024-11-13 at 08 51 09@2x

@Makio64
Copy link
Author

Makio64 commented Jan 26, 2025

Hello, just retried today, and the value are still negative in threejs examples but positive in the webgl example.

Looking forward your recent works on threejs gpu timestamp to be reflected on this lib 👍

@Makio64
Copy link
Author

Makio64 commented Jan 26, 2025

Just tested on a personal project and it seems to work with rendererAsync and r172 🤟
Image

@RenaudRohlinger
Copy link
Owner

RenaudRohlinger commented Jan 26, 2025

Nice! Could you try this example that uses the new TimestampQueryPool API see how it goes? @Makio64:

https://rawcdn.githack.com/mrdoob/three.js/dev/examples/webgpu_compute_particles_snow.html

@Makio64
Copy link
Author

Makio64 commented Jan 26, 2025

@RenaudRohlinger got negative value :(

Image

@RenaudRohlinger
Copy link
Owner

RenaudRohlinger commented Jan 26, 2025

I have exactly around 10.5ms with my M1 Max, I'm pretty sure that's a GPU Metal issue then, but the numbers seems more than accurate there. I might just end up Math.abs() in the tool then.

Image

@RenaudRohlinger
Copy link
Owner

RenaudRohlinger commented Jan 26, 2025

r172 only output the last query and wasn't accurate, which is why I ended up working on mrdoob/three.js#30359 to stabilize everything. I'm pretty confident with this new version and I don't think the code can output negative values on the threejs side. Maybe it's a stats-gl issue, did you had the same issues with r3f-perf?

@Makio64
Copy link
Author

Makio64 commented Jan 26, 2025

Value seems correct on r3f-perf ( also as i mentionned it's seems correct on my current r172 project + stats-gl )

Image

@Makio64
Copy link
Author

Makio64 commented Jan 26, 2025

sorry to bother you.. i just update from r172 to latest dev ( following your comment on .toConst implemented in dev ) and now i got this result, r172 was working :

Image

@RenaudRohlinger
Copy link
Owner

RenaudRohlinger commented Jan 26, 2025

You need to call resolveTimestampsAsync after (not need to await)

mrdoob/three.js#30359 (comment)

@Makio64
Copy link
Author

Makio64 commented Jan 26, 2025

Seems to work! I now got a value between 2 and -1 ( rarely )

		await this.renderer.renderAsync( this.scene, this.camera ) // await necessary else negative value output
		this.renderer.resolveTimestampsAsync( TimestampQuery.RENDER );
		this.stats.update()
Image

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

No branches or pull requests

3 participants