Skip to content

WebGPURenderer: Initial commit. - #20254

Merged
mrdoob merged 1 commit into
mrdoob:devfrom
Mugen87:dev35
Sep 2, 2020
Merged

mrdoob merged 1 commit into
mrdoob:devfrom
Mugen87:dev35

Conversation

@Mugen87

@Mugen87 Mugen87 commented Sep 2, 2020

Copy link
Copy Markdown
Collaborator

This PR introduces a very basic implementation of a new renderer targeting WebGPU.

The new renderer only provides three basic shaders (mesh, points lines) but already some building blocks for handling geometries, UBOs and textures. Compared to WebGLRenderer the API of WebGPURenderer is very limited and most engine features are not supported yet. However, I think it's a good starting point for further developments and for interested WebGPU devs^^.

I've invested no time in a material system up to now since I've planned to suggest the usage of node based materials right from the beginning.

@Mugen87

Mugen87 commented Sep 2, 2020

Copy link
Copy Markdown
Collaborator Author

I'm also planning to invest a certain amount of my future development time in enhancing this renderer. Over time, more and more features will be added which will make WebGPURenderer usable in more scenarios.

@mrdoob is it okay if I commit smaller changes and bug fixes related to WebGPURenderer directly to dev? I mean as long as it stays experimental 😇 ?

@mrdoob mrdoob added this to the r121 milestone Sep 2, 2020
@mrdoob

mrdoob commented Sep 2, 2020

Copy link
Copy Markdown
Owner

Excellent!!

@mrdoob is it okay if I commit smaller changes and bug fixes related to WebGPURenderer directly to dev? I mean as long as it stays experimental 😇 ?

Sounds good! 👌

@mrdoob
mrdoob merged commit 8ca2f55 into mrdoob:dev Sep 2, 2020
@mrdoob

mrdoob commented Sep 2, 2020

Copy link
Copy Markdown
Owner

Thanks!!

@Mugen87

Mugen87 commented Sep 2, 2020

Copy link
Copy Markdown
Collaborator Author

Yay! WebGPU is coming!!!

@mrdoob

mrdoob commented Sep 2, 2020

Copy link
Copy Markdown
Owner

Exciting! Yes, using NodeMaterial directly sounds great.
We'll have to figure out how to produce WGSL from it at some point though.

/cc @sunag @martinRenou

@Mugen87

Mugen87 commented Sep 2, 2020 •

Copy link
Copy Markdown
Collaborator Author

FYI: The current GLSL 4.5 shaders in WebGPURenderer are meant as a temporal solution so it's possible to implement the internals of the renderer. However, we definitely want WGSL. It would be great if NodeMaterial could support this. A small version of MeshBasicMaterial (similar to what I have implemented) would be a good start!

I can of course help with the integration of a node material system since writing shaders for WebGPU is quite different to WebGL. E.g. using UBOs is a must.

Besides, the renderer already expects the uniform data of a material as an array of WebGPUBinding objects. When the renderer has the shader source code and the WebGPUBinding array, it should have all information to create the renderer pipeline object (which is in some sense the WebGLProgram pendant).

@takahirox

Copy link
Copy Markdown
Collaborator

Regarding decode image and send data to WebGPU texture. Does anyone know whether WebGPU plans to directly take image or not? If it doesn't and we need to keep doing that manually, maybe we would ideally better to offload image decoding from main thread to workers (and make _createTexture() async function?). It would be future optimization, we don't need to do now.

@sunag

sunag commented Sep 2, 2020

Copy link
Copy Markdown
Collaborator

I think that can start in jsm/renderers/webgpu/nodes/ a basic version of NodeMaterial?

@Mugen87

Mugen87 commented Sep 2, 2020

Copy link
Copy Markdown
Collaborator Author

Does anyone know whether WebGPU plans to directly take image or not?

Would be good to know. Unfortunately, I couldn't fine something in the spec or elsewhere.

@takahirox

takahirox commented Sep 2, 2020 •

Copy link
Copy Markdown
Collaborator

Unfortunately, I couldn't fine something in the spec or elsewhere.

Yeah, it seems we need to decode by ourselves for now.


} else if ( uniform.isMatrix3 ) {

size = 36;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm right, it's 48 here?

In my webgpu renderer experience, I found matrix3 seems being 4columns x 3rows in WebGPU memory and fourth columns seem ignored.

https://github.com/takahirox/THREE.WebGPURenderer/blob/master/src/renderers/WebGPURenderer.js#L1066-L1077

@Mugen87 Mugen87 Sep 2, 2020 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not had a chance to test this so far (the shaders do no use a normal matrix yet^^). I have similar code like you in my WebGL2/UBO PR but I wanted to verify first if a sizing of 48 is still required.

@takahirox takahirox Sep 2, 2020 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mine uses normal matrix so it seems to take actually 48 bytes (at least in my demos). But yeah verification should be first. I didn't find the mention about sizing of 48 yet neither.

@mrdoob

mrdoob commented Sep 2, 2020 •

Copy link
Copy Markdown
Owner

Does anyone know whether WebGPU plans to directly take image or not?

They say we have to use ImageBitmap and copyImageBitmapToTexture.

@takahirox

takahirox commented Sep 2, 2020 •

Copy link
Copy Markdown
Collaborator

Does anyone know whether WebGPU plans to directly take image or not?

They say we have to use ImageBitmap and copyImageBitmapToTexture.

Thanks, I had missed that function. createImageBitmap() (which creates ImageBitmap from image and other resources) should mostly run off main thread then we see less main thread blocking. Good to know that.

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.

4 participants