How to manage multiple rgb lcd frame buffers?

KallDrexx
Posts: 13
Joined: Sun Jul 30, 2023 6:25 pm

How to manage multiple rgb lcd frame buffers?

Postby KallDrexx » Sat Mar 23, 2024 8:15 pm

The RGB lcd panel API maintains it's own buffers, allowing you to double buffer easily. However, to increase performance I need to manually draw to the frame buffer, since I will be executing multiple draw commands on a buffer before it should be displayed on the RGB lcd display (e.g. draw a circle, draw a square, draw a bitmap, all as independent commands that need to be put on the frame buffer in separate calls before being displayed).

I already have the logic coded to manually draw each operation to an RGB565 byte buffer. Today I maintain my own buffer and upon frame completion I call

Code: Select all

esp_lcd_panel_draw_bitmap()
to push that frame to the RGB LCD. This causes a PSRAM to PSRAM copy, making things slow.

It would be better to directly draw to the byte buffer maintained by the rgb lcd API. While you can tell the API to create multiple buffers and use

Code: Select all

esp_lcd_rgb_panel_get_frame_buffer
to get all the frame buffers, there's no way to know which frame buffer is safe to draw to. We don't want to draw to fb0 if that's feeding the display, as we will get tearing and artifacts when performing draw operations on the next frame.

Likewise, even if we know which frame buffer to draw, it's not clear how we tell the API how to switch which one is active.

So is there a way to know which frame buffer is actively being drawn to the lcd, and if so how do I tell the API to switch?

ESP_morris
Posts: 290
Joined: Wed Sep 05, 2018 6:23 am

Re: How to manage multiple rgb lcd frame buffers?

Postby ESP_morris » Mon Mar 25, 2024 7:17 am

there's no way to know which frame buffer is safe to draw to
The order of the frame buffers to be flushed to the display is controlled by the user. Let's say you ask the driver to create 3 frame buffer and get them all in

Code: Select all

esp_lcd_rgb_panel_get_frame_buffer
(fb0, fb1, fb2). By default, the LCD controller will use fb0 as the working frame buffer, then you can prepare others in fb1 and fb2. If you want to tell the LCD controller to switch to the new frame buffer, you can still call the

Code: Select all

esp_lcd_panel_draw_bitmap
, and pass in the address of fb1 or fb2.

Inside

Code: Select all

esp_lcd_panel_draw_bitmap
, it won't do memory copy but a cache sync. After that, it will manipulate the DMA descriptor to let the DMA switch to the new DMA descriptors gracefully.

KallDrexx
Posts: 13
Joined: Sun Jul 30, 2023 6:25 pm

Re: How to manage multiple rgb lcd frame buffers?

Postby KallDrexx » Wed Mar 27, 2024 1:25 am

(fb0, fb1, fb2). By default, the LCD controller will use fb0 as the working frame buffer, then you can prepare others in fb1 and fb2. If you want to tell the LCD controller to switch to the new frame buffer, you can still call the

Code: Select all

esp_lcd_panel_draw_bitmap

, and pass in the address of fb1 or fb2.
Can you expand on that? The documentation for esp_lcd_panel_draw_bitmap doesn't list a parameter that allows me to specify which framebuffer I want to draw.

KallDrexx
Posts: 13
Joined: Sun Jul 30, 2023 6:25 pm

Re: How to manage multiple rgb lcd frame buffers?

Postby KallDrexx » Wed Mar 27, 2024 1:31 am

Oh I see. So the color data I pass to esp_lcd_panel_draw_bitmap can be fb1 instead of a different buffer. When that happens ESP-IDF recognizes that it's it's own managed frame buffer and not to do a copy. And therefore, since I'm telling it which ESP-IDF managed frame buffer to draw, that allows me to know and control which frame buffer is active at any given time.

Who is online

Users browsing this forum: No registered users and 388 guests