Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[Impeller] Support binding multiple vertex buffer views. #49670

Closed
wants to merge 3 commits into from

Conversation

bdero
Copy link
Member

@bdero bdero commented Jan 10, 2024

Resolves flutter/flutter#116168.

Makes it possible for us to use arbitrary vertex layouts, including SoA layouts with attributes stored in different DeviceBuffers.

@bdero bdero self-assigned this Jan 10, 2024
@bdero bdero changed the title [Impeller] Support multiple vertex bindings. [Impeller] Support binding multiple vertex buffer views. Jan 10, 2024
@bdero bdero force-pushed the bdero/multiple-vertex-buffers branch 2 times, most recently from 79a8a26 to 7fd8dca Compare January 10, 2024 10:30
Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

Concern with this is that now we're on a path to do another heap allocation per command, despite most commands not needing it. Its possible I could also fix this in #49480 but I would prefer if this API starts out such that commands that only bind a single vertex buffer don't use any head allocated storage.

So you could have something like:

VertexBuffer {
BufferView single_vertex_buffer
std::vector additional_vectors
..
}

Maybe?

@bdero
Copy link
Member Author

bdero commented Jan 10, 2024

I'm strongly considering std::variant<BufferView, std::vector<BufferView>> vertex_buffers

I know it seems cringe on the surface, but hear me out:

  • No funky business on the assignment side.
  • On the consumer side, we're forced to deal with both cases either way.

@jonahwilliams
Copy link
Contributor

that seems reasonable to me, am I crazy 🤔

@bdero bdero force-pushed the bdero/multiple-vertex-buffers branch from 65d3846 to f9282f9 Compare January 11, 2024 09:30
@bdero bdero force-pushed the bdero/multiple-vertex-buffers branch from ae0a146 to d274e7d Compare January 11, 2024 11:39
Comment on lines +433 to +434
std::vector<vk::Buffer> vertex_buffers;
std::vector<vk::DeviceSize> vertex_buffer_offsets;
Copy link
Contributor

Choose a reason for hiding this comment

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

Move these under the else if clause so we don't have per-command heap allocation.

@bdero
Copy link
Member Author

bdero commented Jan 22, 2024

Need to rewrite this for the new command encoding interface, keeping it in draft for a while longer until I have time to iterate.

@bdero
Copy link
Member Author

bdero commented Mar 26, 2024

This patch is still on my radar, will rewrite this against the updated HAL API when I find some time.

@bdero
Copy link
Member Author

bdero commented Jun 4, 2024

Still on my radar

@bdero
Copy link
Member Author

bdero commented Aug 13, 2024

Still on my radar, but closing to stop it from continuing to come up in the stale PR triage.

@bdero bdero closed this Aug 13, 2024
auto-submit bot pushed a commit that referenced this pull request Oct 15, 2024
Resolves flutter/flutter#116168.
(Continuation of #49670)

Makes it possible for us to use arbitrary vertex layouts, including SoA layouts with attributes stored in different DeviceBuffers. CanRenderPerspectiveCube was converted to an SoA attribute layout with two separate buffers as an example.

Works on all the backends!

OpenGLES:
<img width="1136" alt="image" src="https://github.com/user-attachments/assets/e2398fde-532f-402d-899a-39aaa556f24f">

Vulkan:
<img width="1136" alt="image" src="https://github.com/user-attachments/assets/1c1bf664-bec1-43cb-ab2e-eb2a74718bfd">

Metal:
<img width="1136" alt="image" src="https://github.com/user-attachments/assets/bf59da17-cf52-4913-88e4-ab6f0bd6fc96">
nick9822 pushed a commit to nick9822/flutter that referenced this pull request Dec 18, 2024
…e#55856)

Resolves flutter#116168.
(Continuation of flutter/engine#49670)

Makes it possible for us to use arbitrary vertex layouts, including SoA layouts with attributes stored in different DeviceBuffers. CanRenderPerspectiveCube was converted to an SoA attribute layout with two separate buffers as an example.

Works on all the backends!

OpenGLES:
<img width="1136" alt="image" src="https://github.com/user-attachments/assets/e2398fde-532f-402d-899a-39aaa556f24f">

Vulkan:
<img width="1136" alt="image" src="https://github.com/user-attachments/assets/1c1bf664-bec1-43cb-ab2e-eb2a74718bfd">

Metal:
<img width="1136" alt="image" src="https://github.com/user-attachments/assets/bf59da17-cf52-4913-88e4-ab6f0bd6fc96">
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Status: 🤔 Needs Triage
Development

Successfully merging this pull request may close these issues.

[Impeller] Allow vertex layout customization at runtime.
2 participants