extensions icon indicating copy to clipboard operation
extensions copied to clipboard

Add GPU.sb3 extension

Open derpygamer2142 opened this issue 1 year ago • 29 comments

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

derpygamer2142 avatar Nov 26 '24 05:11 derpygamer2142

It fails to get WebGPU adapter

Thebloxers998 avatar Nov 26 '24 18:11 Thebloxers998

What does the extension do

Thebloxers998 avatar Nov 26 '24 18:11 Thebloxers998

It fails to get WebGPU adapter

what browser are you on, and what os

derpygamer2142 avatar Nov 26 '24 21:11 derpygamer2142

What does the extension do

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

derpygamer2142 avatar Nov 26 '24 21:11 derpygamer2142

It fails to get WebGPU adapter

what browser are you on, and what os

Chrome, Android, Why did you ask?

Thebloxers998 avatar Nov 26 '24 21:11 Thebloxers998

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

Thebloxers998 avatar Nov 26 '24 21:11 Thebloxers998

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.

derpygamer2142 avatar Nov 26 '24 21:11 derpygamer2142

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

Thebloxers998 avatar Nov 26 '24 22:11 Thebloxers998

well this is rough, make it more readable.

FurryR avatar Dec 27 '24 00:12 FurryR

well this is rough, make it more readable.

that's fair, I will work on that

derpygamer2142 avatar Dec 27 '24 03:12 derpygamer2142

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.

FurryR avatar Dec 27 '24 23:12 FurryR

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 avatar Dec 28 '24 00:12 derpygamer2142

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 avatar Dec 28 '24 23:12 derpygamer2142

i have finally updated documentation to add the 3 new blocks

derpygamer2142 avatar Jan 22 '25 15:01 derpygamer2142

what the sigma why lint fail

derpygamer2142 avatar Jan 28 '25 15:01 derpygamer2142

The latest commit(https://github.com/TurboWarp/extensions/pull/1762/commits/84c7b87ca44ab8815907336960d6518894e34ac2) 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 avatar Jan 31 '25 14:01 derpygamer2142

chose the last option as suggested https://discord.com/channels/837024174865776680/1132437506655268926/1337565380243099679

derpygamer2142 avatar Feb 08 '25 01:02 derpygamer2142

gpu errors aren't going to be translated with Scratch.translate as they're browser-specific, they might already be translated by the browser(couldn't find too much good information), and it's already established as being fine in the game jolt extension. discussion is around here: https://discord.com/channels/837024174865776680/1132437506655268926/1344686905194971166

derpygamer2142 avatar Feb 27 '25 15:02 derpygamer2142

i need to make some changes to the gpu.sb3 compiler so it doesn't get broken by translations

derpygamer2142 avatar Feb 28 '25 18:02 derpygamer2142

changes complete, this is ready for review

derpygamer2142 avatar Apr 05 '25 20:04 derpygamer2142

i'm planning on adding some utilities for struct building on the cpu and maybe possible perhaps some rendering stuff, let me know if you have any ideas as to what this should look like

derpygamer2142 avatar May 18 '25 05:05 derpygamer2142

vadik came in clutch and told me that I can just put the texture of a skin to a canvas that was rendered to via webgpu, I'm going to add that

derpygamer2142 avatar May 27 '25 20:05 derpygamer2142

Is this still a thing or is it stagnant?

Brackets-Coder avatar Sep 16 '25 22:09 Brackets-Coder

Is this still a thing or is it stagnant?

it is, i'm just waiting for this pr to be reviewed and i'm working on adding rendering

derpygamer2142 avatar Sep 17 '25 02:09 derpygamer2142

Is this still a thing or is it stagnant?

it is, i'm just waiting for this pr to be reviewed and i'm working on adding rendering

Okay this one is bigger so I'll review it when I have time

Brackets-Coder avatar Sep 17 '25 11:09 Brackets-Coder

Is this still a thing or is it stagnant?

it is, i'm just waiting for this pr to be reviewed and i'm working on adding rendering

Okay this one is bigger so I'll review it when I have time

thats what they all said

derpygamer2142 avatar Sep 17 '25 12:09 derpygamer2142

Is this still a thing or is it stagnant?

it is, i'm just waiting for this pr to be reviewed and i'm working on adding rendering

Okay this one is bigger so I'll review it when I have time

thats what they all said

Okay, I'll tell you what. I'll get around to it at my earliest convenience, likely sometime today

Brackets-Coder avatar Sep 17 '25 12:09 Brackets-Coder

I'll look over it too

CubesterYT avatar Sep 17 '25 13:09 CubesterYT

I'd recommend putting your documentation at extensions.turbowarp.com, just because some users may not trust your personal site.

Also, considering how much this extension appears to be a work-in-progress, I'm going to convert it to a draft, but if I'm wrong please feel free to open it up again.

Brackets-Coder avatar Sep 17 '25 13:09 Brackets-Coder