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

Compat: Disallow vertex stride of 0 #4515

Closed
Kangz opened this issue Mar 13, 2024 · 3 comments
Closed

Compat: Disallow vertex stride of 0 #4515

Kangz opened this issue Mar 13, 2024 · 3 comments
Labels
compat WebGPU Compatibility Mode

Comments

@Kangz
Copy link
Contributor

Kangz commented Mar 13, 2024

I think this is another thing that needs to be added to the list. WebGPU supports a stride of 0 for attributes. OpenGL ES does not. Stride of 0 in GL = advance the size of the attribute. Stride of 0 in WebGPU = a stride of 0 as in don't advance the attribute. Just keep reading the same value.

I guess in Compat a stride if 0 in an attribute would generate a validation error? Otherwise you could read value in the buffer, turn off the attribute (gl.disableVertexAttribPointer), and set the attribute's constant value (gl.vertexAttrib4f(...valueReadFromBuffer))

Originally posted by @greggman in #4266 (comment)

@Kangz Kangz added the compat WebGPU Compatibility Mode label Mar 13, 2024
@greggman
Copy link
Contributor

greggman commented Mar 13, 2024

There's a comment further down, there's a CTS test for that and it's already passing

https://github.com/gpuweb/cts/blob/6e75f19212e3deaebd5bd8542fe10a6fdedc0cdf/src/webgpu/api/operation/vertex_state/correctness.spec.ts#L728

It's passing because in OpenGL this can be emulated by setting the divisor for the attribute to a high number

glVertexAttribDivisor(attribLocation, 0xffffffff)

Which is what Dawn is currently doing. So I guess no spec changes are needed for this. Just passing on the existing solution.

@greggman
Copy link
Contributor

Instancing works fine and is tested in the test linked above. glVertexAttribDivisor sets how many instances you have to draw before the attribute advances and setting it to 0xffffffff means you'll never advance since that's also the maximum instance count.

@kdashg

I'm going to close this issue since it's solved/done. Re-open if needed.

@Kangz
Copy link
Contributor Author

Kangz commented Mar 26, 2024

GPU Web CG 2024-03-13 Atlantic-time
* GT: already a solution. Set divisor of attribute to a giant number, and it works.
* KG: instance and non-instance values?
* CW: think we have tests for both. Remember writing tests for them.
* GT: I can double-check.
* Consensus. If it works, good - don't need to disallow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compat WebGPU Compatibility Mode
Projects
None yet
Development

No branches or pull requests

2 participants