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

Allow mat2/3/4 as attribute types #1652

Open
Popov72 opened this issue Apr 21, 2021 · 4 comments
Open

Allow mat2/3/4 as attribute types #1652

Popov72 opened this issue Apr 21, 2021 · 4 comments
Labels
api WebGPU API
Milestone

Comments

@Popov72
Copy link

Popov72 commented Apr 21, 2021

That would be nice (and would help our WebGPU support in Babylon.js) to allow having attributes of types mat2/3/4 in the vertex shader.

According to @kainino0x, Vulkan does allow it, for Metal/D3D12 it has to be looked for.

Note that we can do it in WebGL by "binding" 4 vec4 in sequence with enableVertexAttribArray/vertexAttribPointer.

@kvark
Copy link
Contributor

kvark commented Apr 21, 2021

Marking as Needs Action to get this investigated first.

@kainino0x
Copy link
Contributor

kainino0x commented Apr 21, 2021

I investigated this briefly. I'm not 100% sure, but I think neither D3D12 nor Metal has this feature. I couldn't find documentation on them.

Vulkan: https://www.khronos.org/registry/vulkan/specs/1.2/html/chap21.html#fxvertex-attrib-location

Metal examples like this one promote the idea of indexing into a constant buffer with the vertexID. So for this case, I think the WebGPU equivalent would be to use a readonly storage buffer of array<mat4x4<f32>> and do the same thing.

SPIRV-Cross translates SPIR-V mat4 attributes into four float4 attributes when targeting both MSL and HLSL (and reconstructs them into a mat4 in the generated code).

@kvark
Copy link
Contributor

kvark commented Apr 21, 2021

So it appears that the following are true:

  • only supported on 1/3 backend APIs
  • users can do it themselves
  • there is no performance cost for users to do it

Seems straightforward that we could just defer this until after MVP?

In my previous discussions on the topic within wgpu community, I always advocated against passing matrices in attributes. Almost never people really need mat4x4 in the attribute. At most it's mat3x4, or better - a position/scale/rotation combination, which can often be encoded into 2 vectors (e.g. dual-quaternions).

@kainino0x
Copy link
Contributor

Got a confirmation from magcius that HLSL doesn't support this.

@kdashg kdashg added this to the post-MVP milestone Apr 26, 2021
ben-clayton pushed a commit to ben-clayton/gpuweb that referenced this issue Sep 6, 2022
…#1652)

If occlusionQuerySet is not null, the type should be occlusion.
So, this PR adds a test to check if the type is invalid if the
type is not occlusion.

Issue: gpuweb#1618
@kainino0x kainino0x added the api WebGPU API label Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api WebGPU API
Projects
None yet
Development

No branches or pull requests

4 participants