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

Add GPU.sb3 extension #1762

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Conversation

derpygamer2142
Copy link

This adds blocks to use compute shaders in a Turbowarp project. This uses WebGPU(which is experimental!), and only supports compute shaders. From what little research I've done it seems like it would be a pain to add any of the other types, so I'm not doing that.

  • Documentation here
  • Demos here
  • WGSL spec here
  • WebGPU spec here
  • WebGPU implementation status by browser here
  • WebGPU fundamentals here

Notes:

  • The only thing that's somewhat undocumented(I think, let me know if I forgot something) is buffer alignment and stuff, but webgpufundamentals does a better job of that.
  • This doesn't work in the packager with electron. Not sure why, a quick google search leads me to believe it's in beta.

gpusb3

@Thebloxers998
Copy link

It fails to get WebGPU adapter

@Thebloxers998
Copy link

What does the extension do

@derpygamer2142
Copy link
Author

It fails to get WebGPU adapter

what browser are you on, and what os

@derpygamer2142
Copy link
Author

What does the extension do

it's like pen+ but with numbers instead of colors and it all happens at the same time

@Thebloxers998
Copy link

Thebloxers998 commented Nov 26, 2024

It fails to get WebGPU adapter

what browser are you on, and what os

Chrome, Android, Why did you ask?

@Thebloxers998
Copy link

What does the extension do

it's like pen+ but with numbers instead of colors and it all happens at the same time

That would be more hard but ok

@derpygamer2142
Copy link
Author

It fails to get WebGPU adapter

what browser are you on, and what os

Chrome, Android, Why did you ask?

WebGPU is experimental and doesn't work on some devices. Seems like android wouldn't be supported based on webgpu.io.

@Thebloxers998
Copy link

It fails to get WebGPU adapter

what browser are you on, and what os

Chrome, Android, Why did you ask?

WebGPU is experimental and doesn't work on some devices. Seems like android wouldn't be supported based on webgpu.io.

Oh ok

@CubesterYT CubesterYT added the pr: new extension Pull requests that add a new extension label Nov 27, 2024
@FurryR
Copy link
Contributor

FurryR commented Dec 27, 2024

well this is rough, make it more readable.

@derpygamer2142
Copy link
Author

derpygamer2142 commented Dec 27, 2024

well this is rough, make it more readable.

that's fair, I will work on that

@FurryR
Copy link
Contributor

FurryR commented Dec 27, 2024

I'm excited to see the extension coming out as it means that we could now perform GPGPU calculations on TurboWarp, meaning that 3D applications will be blazingly fast and AI is now possible.

@derpygamer2142
Copy link
Author

I'm excited to see the extension coming out as it means that we could now perform GPGPU calculations on TurboWarp, meaning that 3D applications will be blazingly fast and AI is now possible.

this isn't really intended for 3d, I think vertex/fragment shader implementations such as those in webgl would be far faster than anything custom made

@derpygamer2142
Copy link
Author

added a bunch of comments, removed profanity, and I think I reordered stuff in a way that makes more sense but I don't remember

@derpygamer2142
Copy link
Author

i have finally updated documentation to add the 3 new blocks

@derpygamer2142
Copy link
Author

what the sigma why lint fail

important: this commit makes pretty much all the webgpu blocks async, so there's a 1 frame delay when they are run or something like that
@derpygamer2142
Copy link
Author

derpygamer2142 commented Jan 31, 2025

The latest commit(84c7b87) adds error handling in case the device was lost or the project was run before it was finished getting the adapter+device. this makes pretty much every webgpu block async, which is pretty cringe. I could alternatively:

  • use .thens on the promise instead of awaiting it, removing the need for async(? not sure if this would work)
  • check if the device is invalid, and if it is just don't run the block while also throwing an error
  • do it anyways and add a way to check if the last block run threw an error
  • have duplicates of all the blocks as an "unsafe" version which run anyways and just throw an error if something goes wrong
  • force the init block to be run before you can do anything (! this would be a lot easier than the alternatives)

Should I keep it as is or do one of the above?

@derpygamer2142
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: new extension Pull requests that add a new extension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants