[Impeller] Add a flat VertexAttributeFormat for vertex inputs#188684
[Impeller] Add a flat VertexAttributeFormat for vertex inputs#188684auto-submit[bot] merged 3 commits into
Conversation
Introduce a VertexAttributeFormat enum derived from a reflected ShaderStageIOSlot, and route the Metal, Vulkan, and GLES backends through it instead of three independent switches over the slot's scalar type, bit width, and component count. This is behavior preserving. Only the formats reflection produces today are reachable, and each backend keeps its current support set, so GLES still rejects half-float and 32-bit integer attributes. Boolean vertex inputs, which are not expressible in a vertex stage, now map to invalid on every backend. Related to flutter#186309.
92f6155 to
ef4c1b4
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces a unified VertexAttributeFormat enum and a GetVertexAttributeFormat helper on ShaderStageIOSlot to centralize vertex attribute format derivation. The GLES, Metal, and Vulkan backends are updated to use this new format, simplifying their vertex format mapping logic, and corresponding unit tests are added. Feedback suggests capturing vec_size by value instead of capturing this in the lambda within GetVertexAttributeFormat to avoid potential compilation issues on older compilers in a constexpr context.
Avoids capturing this in the constexpr lambda, which can fail compile-time evaluation on some compilers.
|
@walley892 I'm confused, I can't remember if bdero needs 2 reviews or not. If so can you please provide a second review. LGTM. |
I only need one. :) |
Related to #186309.
Adds a
VertexAttributeFormatenum and derives it from a reflectedShaderStageIOSlot, then routes the Metal, Vulkan, and GLES backends through it when building their native vertex input format. This replaces three independent switches over the slot's scalar type, bit width, and component count with one shared vocabulary, which is the foundation for the vertex format expansion tracked in the issue.This is a behavior preserving refactor. Only the formats reflection produces today are reachable, and each backend keeps its existing support set, so GLES still rejects half-float and 32-bit integer attributes while Metal and Vulkan accept them. The one intentional cleanup is that boolean vertex inputs, which are not expressible in a vertex stage, now map to invalid on every backend instead of the previous inconsistent mappings.
New tests cover the format derivation across scalar kinds, component counts, bit widths, and matrix inputs, plus the GLES mapping including the half-float and 32-bit integer formats it rejects.
Pre-launch Checklist
///).