-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Document how to do basic rendering in Impeller. #52703
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Let's create the data we will be giving our draw call. Remember, our vertex shader is a bit of slacker and doesn't do anything to the vertex information to convert it to normalized device coordinates. So we need to make sure the information is already in [normalized device coordinate](coordinate_system.md). | ||
|
||
```c++ | ||
VertexBufferBuilder<VS::PerVertexData> vertex_buffer_builder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interestingly this class is definitely on my list of abstractions to remove. I was thinking about some kind of either template or list initalization that would avoid the secondary std::vec allocation.
No action needed, just a note for me to update the doc if I do that.
|
||
Unlike `malloc` buffers that can be resized via `realloc`, device buffers cannot be resized in Impeller. Also, it is bad form to create many small device buffers. For this reason, Impeller prefers to stage all data (uniform, vertex, or otherwise) into one large allocation. Then at draw time, each draw call references information at a specific offset and length into that larger allocation. | ||
|
||
An easy to way to achieve this scheme is to use a `HostBuffer`. A host buffer is a buffer allocated on the heap (using `malloc` or similar) whose main usage is to grow as quickly as possible. Impeller stages all data for the frame in such a buffer. As the buffer is being constructed, views (offset and length) into this buffer are noted in the command stream. Just before the draw call is submitted, this information is uploaded to the GPU at which time with buffers being reused if necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
primarily this uses the driver's allocator, VMA, Metal allocator, or malloc on GLSL where there is no allocation API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was hand wavy about the implementation details since they're so different and we keep tinkering on them anyway.
Co-authored-by: Jonah Williams <jonahwilliams@google.com>
autosub bot is down. Landing manually flutter/flutter#148092 |
|
||
This guide details how to render a triangle using Impeller. We will use the lowest layer of the stack to do this and explore Impellers HAL and shader compilation machinery. | ||
|
||
A complete code example of this tutorial is in [`renderer_unittests.cc`](../renderer/renderer_unittests.cc) in `RendererTest.BabysFirstTriangle`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the example is a unit test in the impeller source base so it doesn't have the same requirements in terms of includes, linking, actually rendering to the screen, etc; is that worth calling out here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite follow. Like the unit-tests, the engine TUs that use Impeller have the same requirements. Maybe I am missing something? This guide was a logical successor to the "Setting up a Standalone Impeller in OpenGL ES" guide from last week.
Addresses comments made after flutter#52703 landed.
I addressed the feedback after this landed in #52718. PTAL. |
…148147) flutter/engine@d4f705c...ba8e0d3 2024-05-10 1961493+harryterkelsen@users.noreply.github.com [canvaskit] Clip before applying ColorFilter so it doesn't filter beyond child bounds (flutter/engine#52704) 2024-05-10 magder@google.com Migrate FlutterView, FlutterPlatformViews, FlutterOverlayView to ARC (flutter/engine#52535) 2024-05-10 matanlurey@users.noreply.github.com Infer `--rbe` based on the existence of `//flutter/build/rbe` (flutter/engine#52700) 2024-05-10 jonahwilliams@google.com [Impeller] Disable AHB swapchain. (flutter/engine#52713) 2024-05-10 skia-flutter-autoroll@skia.org Roll Skia from c7cd1e9690d1 to 11d892ce49b6 (25 revisions) (flutter/engine#52712) 2024-05-10 chinmaygarde@google.com [Impeller] Document how to do basic rendering in Impeller. (flutter/engine#52703) 2024-05-10 30870216+gaaclarke@users.noreply.github.com [impeller] adds experimental canvas docstring (flutter/engine#52710) 2024-05-10 daniel.l@hpcnt.com Roll third_party/freetype2 from 3bea27612 to af4c2d86d (2 revisions) (flutter/engine#52689) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Addresses comments made after #52703 landed.
Preview https://github.com/chinmaygarde/flutter_engine/blob/babys_first_triangle/impeller/docs/babys_first_triangle.md