Skip to content
Snippets Groups Projects
Commit deac3152 authored by pippin's avatar pippin
Browse files

st3m_gfx: allow rasterize to run in paralell with draw

parent cd998a51
No related branches found
No related tags found
No related merge requests found
...@@ -46,6 +46,7 @@ EXT_RAM_BSS_ATTR uint16_t st3m_overlay_backup[OVERLAY_WIDTH * OVERLAY_HEIGHT]; ...@@ -46,6 +46,7 @@ EXT_RAM_BSS_ATTR uint16_t st3m_overlay_backup[OVERLAY_WIDTH * OVERLAY_HEIGHT];
// drawlist ctx // drawlist ctx
static Ctx *user_ctx = NULL; static Ctx *user_ctx = NULL;
static Ctx *user_copy_ctx = NULL;
// RGB565_byteswapped framebuffer ctx - our global ctx // RGB565_byteswapped framebuffer ctx - our global ctx
// user_ctx gets replayed on this // user_ctx gets replayed on this
...@@ -210,7 +211,7 @@ static void st3m_gfx_task(void *_arg) { ...@@ -210,7 +211,7 @@ static void st3m_gfx_task(void *_arg) {
flow3r_bsp_display_send_fb(st3m_overlay_fb, 32); flow3r_bsp_display_send_fb(st3m_overlay_fb, 32);
break; break;
case st3m_gfx_default: case st3m_gfx_default:
ctx_render_ctx(user_ctx, fb_ctx); ctx_render_ctx(user_copy_ctx, fb_ctx);
if (_st3m_overlay_y1 != _st3m_overlay_y0) if (_st3m_overlay_y1 != _st3m_overlay_y0)
st3m_ctx_merge_overlay( st3m_ctx_merge_overlay(
fb, fb,
...@@ -233,7 +234,7 @@ static void st3m_gfx_task(void *_arg) { ...@@ -233,7 +234,7 @@ static void st3m_gfx_task(void *_arg) {
flow3r_bsp_display_send_fb(fb, 16); flow3r_bsp_display_send_fb(fb, 16);
break; break;
} }
ctx_drawlist_clear(user_ctx); ctx_drawlist_clear(user_copy_ctx);
xQueueSend(user_ctx_freeq, &descno, portMAX_DELAY); xQueueSend(user_ctx_freeq, &descno, portMAX_DELAY);
st3m_counter_rate_sample(&rast_rate); st3m_counter_rate_sample(&rast_rate);
...@@ -481,9 +482,9 @@ void st3m_gfx_init(void) { ...@@ -481,9 +482,9 @@ void st3m_gfx_init(void) {
flow3r_bsp_display_init(); flow3r_bsp_display_init();
// Create drawlist ctx queues. // Create drawlist ctx queues.
user_ctx_freeq = xQueueCreate(1 + 1, sizeof(int)); user_ctx_freeq = xQueueCreate(2 + 1, sizeof(int));
assert(user_ctx_freeq != NULL); assert(user_ctx_freeq != NULL);
user_ctx_rastq = xQueueCreate(1 + 1, sizeof(int)); user_ctx_rastq = xQueueCreate(2 + 1, sizeof(int));
assert(user_ctx_rastq != NULL); assert(user_ctx_rastq != NULL);
// Setup framebuffer descriptor. // Setup framebuffer descriptor.
...@@ -499,36 +500,42 @@ void st3m_gfx_init(void) { ...@@ -499,36 +500,42 @@ void st3m_gfx_init(void) {
// Setup user_ctx descriptor. // Setup user_ctx descriptor.
user_ctx = user_ctx =
ctx_new_drawlist(FLOW3R_BSP_DISPLAY_WIDTH, FLOW3R_BSP_DISPLAY_HEIGHT); ctx_new_drawlist(FLOW3R_BSP_DISPLAY_WIDTH, FLOW3R_BSP_DISPLAY_HEIGHT);
user_copy_ctx =
ctx_new_drawlist(FLOW3R_BSP_DISPLAY_WIDTH, FLOW3R_BSP_DISPLAY_HEIGHT);
assert(user_ctx != NULL); assert(user_ctx != NULL);
ctx_set_texture_cache(user_ctx, fb_ctx); ctx_set_texture_cache(user_ctx, fb_ctx);
ctx_set_texture_cache(user_copy_ctx, fb_ctx);
// Push descriptor to freeq. // Push descriptor to freeq.
int i = 0; for (int i = 0; i < 2; i++) {
BaseType_t res = xQueueSend(user_ctx_freeq, &i, 0); BaseType_t res = xQueueSend(user_ctx_freeq, &i, 0);
assert(res == pdTRUE); assert(res == pdTRUE);
}
// Start rasterization, compositing and scan-out // Start rasterization, compositing and scan-out
res = xTaskCreate(st3m_gfx_task, "graphics", 8192, NULL, BaseType_t res = xTaskCreate(st3m_gfx_task, "graphics", 8192, NULL,
ESP_TASK_PRIO_MIN + 1, &graphics_task); ESP_TASK_PRIO_MIN + 1, &graphics_task);
assert(res == pdPASS); assert(res == pdPASS);
} }
static int descno = 0;
static Ctx *st3m_gfx_drawctx_free_get(TickType_t ticks_to_wait) { static Ctx *st3m_gfx_drawctx_free_get(TickType_t ticks_to_wait) {
int descno; BaseType_t res = xQueueReceive(user_ctx_freeq, &descno, portMAX_DELAY);
BaseType_t res = xQueueReceive(user_ctx_freeq, &descno, ticks_to_wait); if (res != pdTRUE) return NULL;
if (res != pdTRUE) {
return NULL;
}
return user_ctx; return user_ctx;
} }
static void st3m_gfx_drawctx_pipe_put(void) { static void st3m_gfx_drawctx_pipe_put(void) {
int i = 0; Ctx *tmp = user_ctx;
xQueueSend(user_ctx_rastq, &i, portMAX_DELAY); user_ctx = user_copy_ctx;
user_copy_ctx = tmp;
xQueueSend(user_ctx_rastq, &descno, portMAX_DELAY);
} }
void st3m_ctx_end_frame(Ctx *ctx) { st3m_gfx_drawctx_pipe_put(); }
uint8_t st3m_gfx_drawctx_pipe_full(void) { uint8_t st3m_gfx_drawctx_pipe_full(void) {
return uxQueueSpacesAvailable(user_ctx_rastq) == 0; return uxQueueMessagesWaiting(user_ctx_freeq) == 0;
} }
void st3m_gfx_flush(void) { void st3m_gfx_flush(void) {
...@@ -544,14 +551,13 @@ void st3m_gfx_flush(void) { ...@@ -544,14 +551,13 @@ void st3m_gfx_flush(void) {
// And drain again. // And drain again.
xQueueReset(user_ctx_freeq); xQueueReset(user_ctx_freeq);
int i = 0; for (int i = 0; i < 2; i++) {
BaseType_t res = xQueueSend(user_ctx_freeq, &i, 0); BaseType_t res = xQueueSend(user_ctx_freeq, &i, 0);
assert(res == pdTRUE); assert(res == pdTRUE);
}
ESP_LOGW(TAG, "Pipeline flush/reset done."); ESP_LOGW(TAG, "Pipeline flush/reset done.");
} }
static int st3m_user_ctx_no = 0; // always 0 - but this keeps pipelined
// rendering working as a compile time opt-in
Ctx *st3m_ctx(TickType_t ticks_to_wait) { Ctx *st3m_ctx(TickType_t ticks_to_wait) {
Ctx *ctx = st3m_gfx_drawctx_free_get(ticks_to_wait); Ctx *ctx = st3m_gfx_drawctx_free_get(ticks_to_wait);
if (!ctx) return NULL; if (!ctx) return NULL;
...@@ -580,10 +586,6 @@ Ctx *st3m_overlay_ctx(void) { ...@@ -580,10 +586,6 @@ Ctx *st3m_overlay_ctx(void) {
return overlay_ctx; return overlay_ctx;
} }
void st3m_ctx_end_frame(Ctx *ctx) {
xQueueSend(user_ctx_rastq, &st3m_user_ctx_no, portMAX_DELAY);
}
void st3m_gfx_overlay_clip(int x0, int y0, int x1, int y1) { void st3m_gfx_overlay_clip(int x0, int y0, int x1, int y1) {
if (y1 < OVERLAY_Y) y1 = OVERLAY_Y; if (y1 < OVERLAY_Y) y1 = OVERLAY_Y;
if (y1 > OVERLAY_Y + OVERLAY_HEIGHT) y1 = OVERLAY_Y + OVERLAY_HEIGHT; if (y1 > OVERLAY_Y + OVERLAY_HEIGHT) y1 = OVERLAY_Y + OVERLAY_HEIGHT;
......
  • dos @dos

    mentioned in commit c5807712

    ·

    mentioned in commit c5807712

    Toggle commit list
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment