Vertex input: description, mental model, naming - #469
Conversation
I've been struggling with coming up with a mental model for vertex input ever since we rephrased it in terms of the "push" model. Because we were talking about vertex pulling recently, in which things can really be phrased as arrays-of-structures, I realized that was the basis I needed to make the mental model finally make sense. The key naming change is that "vertex buffers" no longer contain "attributes". Instead, they are arrays which contain "structures", and each structure is defined by a sequence of "members". Those members *secondarily* specify their shader input location. I also wrote some text to describe this mental model. There is also one functional change aside from naming: the attribute byte offset is no longer optional. I think it's crucial to the mental modeling that the offset be front-and-center in the vertex structure definition.
kvark
left a comment
There was a problem hiding this comment.
I appreciate non-default offset :)
| required GPUBufferSize elementStride; | ||
| GPUInputStepMode stepMode = "vertex"; | ||
| required sequence<GPUVertexAttributeDescriptor> attributeSet; | ||
| required sequence<GPUVertexStructureMemberDescriptor> structure; |
There was a problem hiding this comment.
There might be a bit of a clash between "element" and "structure". Perhaps, we can use one of those more consistently, e.g. call the other thing structureStride, or rename this one to sequence<GPUVertexElementDescriptor> elements?
There was a problem hiding this comment.
I was going to comment on this, but it got a bit too close to bikeshedding, but I think this exposes the problem.
Structures aren't the same as elements. The mental model here is:
struct {
float3 Position;
float2 TexCoord;
float4 Color;
} VertexArray[];VertexArray[i] is an "element", VertexArray[i].Position is a "structure member".
Ultimately, I don't like the name "element" because it could also mean "structure element" (as in structure member), or "primitive element" (e.g. one triangle, as used by glDrawElements)
This also ignores the admittedly rare case that vertex arrays might have extra data used by the draw, and that's OK. That is:
struct {
float4 Position;
char pad[29];
} VertexArray[];
is perfectly allowed just by setting the buffer stride to a greater value, and using a single element at offset +0x00. Imagine if you could explicitly size a struct with __attribute__((size=0x3f)) struct Foo or something in GCC.
There was a problem hiding this comment.
Could you distill that to concrete wording and names you think we should be using? Or are you arguing that the PR as it stands is clear enough?
There was a problem hiding this comment.
I would vote to keep existing language. Quick survey:
D3D12
-
GPUVertexInputDescriptormaps to an "input layout" (described by D3D12_INPUT_LAYOUT_DESC). -
GPUVertexBufferDescriptoris the odd one out, since it's not required at input layout creation time. Instead, it's part of D3D12_VERTEX_BUFFER_VIEW, which also includes the buffer handle for the data. -
GPUVertexAttributeDescriptormaps to D3D12_INPUT_ELEMENT_DESC (another mismatch for "element", being used in the "structure element" case as above). Instead of it being hierarchical, a number-based binding scheme is used.
Vulkan
-
GPUVertexInputDescriptormaps to VkPipelineVertexInputStateCreateInfo -
GPUVertexBufferDescriptormaps to VkVertexInputBindingDescription, again, though, a number-based binding is used like D3D11/D3D12 rather than the hierarchy. -
GPUVertexAttributeDescriptormaps to VkVertexInputAttributeDescription
Jasper's Personal Taste
I'm not entirely happy with "GPUVertexBufferDescriptor", because it's not yet attached to a vertex buffer with data, it's simply a skeleton for what might fit. However, I'm having a hard time coming up with something better, especially if we don't have the number-based binding approach and mandate strides at input layout creation time. "VertexInputBinding" is way worse.
GPUVertexInputDescriptor and GPUVertexAttributeDescriptor are fine.
There was a problem hiding this comment.
got a bit too close to bikeshedding
I think this is 100% ok. After all, this PR is pretty much just renaming things.
I will catch up on this thread when I have a chance.
There was a problem hiding this comment.
@magcius thank you for the mini-investigation!
I think the links you provided support the idea of not using the "element" as this PR suggests: D3D12 "element" is a member of the struct (so, our "struct member"). I don't think we should introduce semantics that will confuse D3D12 users, if we can avoid this.
How about elementStride -> structureStride and structure -> structureMembers?
There was a problem hiding this comment.
That sounds pretty good to me. Maybe arrayStride and structureMembers? structMembers?
I'm not entirely happy with "GPUVertexBufferDescriptor"
Perhaps we should steal from Vulkan: GPUVertexBindingDescriptor? That said, I'm also fine with GPUVertexBufferDescriptor.
There was a problem hiding this comment.
Updated with arrayStride and structMembers
|
PTAL @RafaelCintron @JusSn |
| GPUBufferSize offset = 0; | ||
| required GPUVertexFormat format; | ||
| required unsigned long shaderLocation; | ||
| dictionary GPUVertexInputDescriptor { |
There was a problem hiding this comment.
I'm happy to propose this elsewhere, but I think GPUVertexInputsDescriptor (InputS) would make it easier to keep straight vs Vertex[Buffer,Attribute]Desc.
There was a problem hiding this comment.
Right after I pushed the previous commit I decided to rename this too. WDYT?
There was a problem hiding this comment.
"State" is a little vague, but I think it's an improvement.
I think adding "Layout" is more verbose than we need, but it's also fine.
I'm happy with this overall, thanks!
|
@magcius PTAL as well |
|
I like these names. |
ee3f11a to
6b24523
Compare
Spec changes: gpuweb/gpuweb#469
Spec changes: gpuweb/gpuweb#469
Specification change: gpuweb/gpuweb#469 Dawn roll: https://dawn.googlesource.com/dawn/+log/c3284fa40ec6b12731ed66c2f2a9256ae3fa692e..ae1f25fee85ebf2773b24a0a4f39c160839b1dbb CTS roll: gpuweb/cts@3dc37c8...e114192 TBR: haraken@chromium.org Bug: dawn:22 Change-Id: Ib427760b9fba4b2cc4290de046c4a31d77e0b67a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900807 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Yunchao He <yunchao.he@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Kai Ninomiya <kainino@chromium.org> Cr-Commit-Position: refs/heads/master@{#713682}
Specification change: gpuweb/gpuweb#469 Dawn roll: https://dawn.googlesource.com/dawn/+log/c3284fa40ec6b12731ed66c2f2a9256ae3fa692e..ae1f25fee85ebf2773b24a0a4f39c160839b1dbb CTS roll: gpuweb/cts@3dc37c8...e114192 TBR: haraken@chromium.org Bug: dawn:22 Change-Id: Ib427760b9fba4b2cc4290de046c4a31d77e0b67a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900807 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Yunchao He <yunchao.he@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Kai Ninomiya <kainino@chromium.org> Cr-Commit-Position: refs/heads/master@{#713682}
1.Add Vulkan validation layers on Windows https://dawn-review.googlesource.com/c/dawn/+/11120 Vulkan validation layer is defaultly enabled on Windows, to disable Vulkan validation layer, pass args "dawn_enable_vulkan_validation_layers=false" 2.Update naming for vertex state gpuweb/gpuweb#469 https://dawn-review.googlesource.com/c/dawn/+/13100
1.Add Vulkan validation layers on Windows https://dawn-review.googlesource.com/c/dawn/+/11120 Vulkan validation layer is defaultly enabled on Windows, to disable Vulkan validation layer, pass args "dawn_enable_vulkan_validation_layers=false" 2.Update naming for vertex state gpuweb/gpuweb#469 https://dawn-review.googlesource.com/c/dawn/+/13100
1.Add Vulkan validation layers on Windows https://dawn-review.googlesource.com/c/dawn/+/11120 Vulkan validation layer is defaultly enabled on Windows, to disable Vulkan validation layer, pass args "dawn_enable_vulkan_validation_layers=false" 2.Update naming for vertex state gpuweb/gpuweb#469 https://dawn-review.googlesource.com/c/dawn/+/13100
1.Add Vulkan validation layers on Windows https://dawn-review.googlesource.com/c/dawn/+/11120 Vulkan validation layer is defaultly enabled on Windows, to disable Vulkan validation layer, pass args "dawn_enable_vulkan_validation_layers=false" 2.Update naming for vertex state gpuweb/gpuweb#469 https://dawn-review.googlesource.com/c/dawn/+/13100
1.Add Vulkan validation layers on Windows https://dawn-review.googlesource.com/c/dawn/+/11120 Vulkan validation layer is defaultly enabled on Windows, to disable Vulkan validation layer, pass args "dawn_enable_vulkan_validation_layers=false" 2.Update naming for vertex state gpuweb/gpuweb#469 https://dawn-review.googlesource.com/c/dawn/+/13100
Automatic update from web-platform-tests Update naming for vertex state Specification change: gpuweb/gpuweb#469 Dawn roll: https://dawn.googlesource.com/dawn/+log/c3284fa40ec6b12731ed66c2f2a9256ae3fa692e..ae1f25fee85ebf2773b24a0a4f39c160839b1dbb CTS roll: gpuweb/cts@3dc37c8...e114192 TBR: haraken@chromium.org Bug: dawn:22 Change-Id: Ib427760b9fba4b2cc4290de046c4a31d77e0b67a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900807 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Yunchao He <yunchao.he@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Kai Ninomiya <kainino@chromium.org> Cr-Commit-Position: refs/heads/master@{#713682} -- wpt-commits: 4831b37a33f002e67ecc5f9f5b41145721e0ab60 wpt-pr: 20186
Automatic update from web-platform-tests Update naming for vertex state Specification change: gpuweb/gpuweb#469 Dawn roll: https://dawn.googlesource.com/dawn/+log/c3284fa40ec6b12731ed66c2f2a9256ae3fa692e..ae1f25fee85ebf2773b24a0a4f39c160839b1dbb CTS roll: gpuweb/cts@3dc37c8...e114192 TBR: haraken@chromium.org Bug: dawn:22 Change-Id: Ib427760b9fba4b2cc4290de046c4a31d77e0b67a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900807 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Yunchao He <yunchao.he@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Kai Ninomiya <kainino@chromium.org> Cr-Commit-Position: refs/heads/master@{#713682} -- wpt-commits: 4831b37a33f002e67ecc5f9f5b41145721e0ab60 wpt-pr: 20186
Automatic update from web-platform-tests Update naming for vertex state Specification change: gpuweb/gpuweb#469 Dawn roll: https://dawn.googlesource.com/dawn/+log/c3284fa40ec6b12731ed66c2f2a9256ae3fa692e..ae1f25fee85ebf2773b24a0a4f39c160839b1dbb CTS roll: gpuweb/cts@3dc37c8...e114192 TBR: harakenchromium.org Bug: dawn:22 Change-Id: Ib427760b9fba4b2cc4290de046c4a31d77e0b67a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900807 Reviewed-by: Austin Eng <engachromium.org> Reviewed-by: Yunchao He <yunchao.heintel.com> Reviewed-by: Corentin Wallez <cwallezchromium.org> Commit-Queue: Kai Ninomiya <kaininochromium.org> Cr-Commit-Position: refs/heads/master{#713682} -- wpt-commits: 4831b37a33f002e67ecc5f9f5b41145721e0ab60 wpt-pr: 20186 UltraBlame original commit: 9839ef573c437b6f4f2550b8514fd36964f525fe
Automatic update from web-platform-tests Update naming for vertex state Specification change: gpuweb/gpuweb#469 Dawn roll: https://dawn.googlesource.com/dawn/+log/c3284fa40ec6b12731ed66c2f2a9256ae3fa692e..ae1f25fee85ebf2773b24a0a4f39c160839b1dbb CTS roll: gpuweb/cts@3dc37c8...e114192 TBR: harakenchromium.org Bug: dawn:22 Change-Id: Ib427760b9fba4b2cc4290de046c4a31d77e0b67a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900807 Reviewed-by: Austin Eng <engachromium.org> Reviewed-by: Yunchao He <yunchao.heintel.com> Reviewed-by: Corentin Wallez <cwallezchromium.org> Commit-Queue: Kai Ninomiya <kaininochromium.org> Cr-Commit-Position: refs/heads/master{#713682} -- wpt-commits: 4831b37a33f002e67ecc5f9f5b41145721e0ab60 wpt-pr: 20186 UltraBlame original commit: 9839ef573c437b6f4f2550b8514fd36964f525fe
Automatic update from web-platform-tests Update naming for vertex state Specification change: gpuweb/gpuweb#469 Dawn roll: https://dawn.googlesource.com/dawn/+log/c3284fa40ec6b12731ed66c2f2a9256ae3fa692e..ae1f25fee85ebf2773b24a0a4f39c160839b1dbb CTS roll: gpuweb/cts@3dc37c8...e114192 TBR: harakenchromium.org Bug: dawn:22 Change-Id: Ib427760b9fba4b2cc4290de046c4a31d77e0b67a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900807 Reviewed-by: Austin Eng <engachromium.org> Reviewed-by: Yunchao He <yunchao.heintel.com> Reviewed-by: Corentin Wallez <cwallezchromium.org> Commit-Queue: Kai Ninomiya <kaininochromium.org> Cr-Commit-Position: refs/heads/master{#713682} -- wpt-commits: 4831b37a33f002e67ecc5f9f5b41145721e0ab60 wpt-pr: 20186 UltraBlame original commit: 9839ef573c437b6f4f2550b8514fd36964f525fe
* Add validation tests for Timestamp Query - Test writeTimestamp in all possible encoders. - Test resolveQuerySet for all types of queries. - Test destoryed query set in writeTimestamp and resolveQuerySet. * Refactor to use cases, subcases, createEncoder, createQuerySetWithState, createBufferWithState * Fix typo * Add control case in resolveQuerySet,invalid_queryset_and_destination_buffer * Add comments for control cases * Add missed condition in expectValidationError
Automatic update from web-platform-tests Update naming for vertex state Specification change: gpuweb/gpuweb#469 Dawn roll: https://dawn.googlesource.com/dawn/+log/c3284fa40ec6b12731ed66c2f2a9256ae3fa692e..ae1f25fee85ebf2773b24a0a4f39c160839b1dbb CTS roll: gpuweb/cts@3dc37c8...e114192 TBR: haraken@chromium.org Bug: dawn:22 Change-Id: Ib427760b9fba4b2cc4290de046c4a31d77e0b67a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900807 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Yunchao He <yunchao.he@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Kai Ninomiya <kainino@chromium.org> Cr-Commit-Position: refs/heads/master@{#713682} -- wpt-commits: 4831b37a33f002e67ecc5f9f5b41145721e0ab60 wpt-pr: 20186
I've been struggling with coming up with a mental model for vertex input
ever since we rephrased it in terms of the "push" model. Because we were
talking about vertex pulling recently, in which things can really be
phrased as arrays-of-structures, I realized that was the basis I needed
to make the mental model finally make sense.
The key naming change is that "vertex buffers" no longer contain
"attributes". Instead, they are arrays which contain "structures", and
each structure is defined by a sequence of "members". Those members
secondarily specify their shader input location.
I also wrote some text to describe this mental model.
There is also one functional change aside from naming: the attribute
byte offset is no longer optional. I think it's crucial to the mental
modeling that the offset be front-and-center in the vertex structure
definition.
Preview | Diff