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

st3m_gfx: fix direct ctx variants

Using busy-polling to wait for blit to be done, using a mutex here
instead did not work as intended. The direct modes are good for debugging
and currently without a graphics task that floats between cores can
be used in scenarios where cpu load for audio is high enough to starve
graphics. The direct modes also are good in that you can immediately
read rendered pixels back from framebuffers after issuing drawing commands
and do not need to wait for the next frame.
parent a4681f0a
No related branches found
No related tags found
No related merge requests found
...@@ -332,14 +332,7 @@ st3m_gfx_mode st3m_gfx_set_mode(st3m_gfx_mode mode) { ...@@ -332,14 +332,7 @@ st3m_gfx_mode st3m_gfx_set_mode(st3m_gfx_mode mode) {
_st3m_gfx_mode = (mode == default_mode) ? st3m_gfx_default : mode; _st3m_gfx_mode = (mode == default_mode) ? st3m_gfx_default : mode;
_st3m_gfx_low_latency = ((mode & st3m_gfx_low_latency) != 0); _st3m_gfx_low_latency = ((mode & st3m_gfx_low_latency) != 0);
switch ((int)mode) { if (mode & st3m_gfx_direct_ctx) _st3m_gfx_low_latency = 1;
case st3m_gfx_16bpp_direct_ctx:
case st3m_gfx_16bpp_direct_ctx_osd:
case st3m_gfx_8bpp_direct_ctx:
case st3m_gfx_32bpp_direct_ctx:
case st3m_gfx_24bpp_direct_ctx:
_st3m_gfx_low_latency = 1;
}
return mode; return mode;
} }
...@@ -377,6 +370,7 @@ uint8_t *st3m_gfx_fb(st3m_gfx_mode mode, int *width, int *height, int *stride) { ...@@ -377,6 +370,7 @@ uint8_t *st3m_gfx_fb(st3m_gfx_mode mode, int *width, int *height, int *stride) {
return st3m_fb2; return st3m_fb2;
} }
static int fb_ready = 1; // ugly synch hack
static void st3m_gfx_task(void *_arg) { static void st3m_gfx_task(void *_arg) {
(void)_arg; (void)_arg;
st3m_gfx_set_mode(st3m_gfx_default); st3m_gfx_set_mode(st3m_gfx_default);
...@@ -387,6 +381,7 @@ static void st3m_gfx_task(void *_arg) { ...@@ -387,6 +381,7 @@ static void st3m_gfx_task(void *_arg) {
xQueueReceiveNotifyStarved(user_ctx_rastq, &desc_no, xQueueReceiveNotifyStarved(user_ctx_rastq, &desc_no,
"rast task starved (user_ctx)!"); "rast task starved (user_ctx)!");
st3m_gfx_drawlist *drawlist = &drawlists[desc_no]; st3m_gfx_drawlist *drawlist = &drawlists[desc_no];
fb_ready = 0;
ctx_set_textureclock(fb_RGB565_BS_ctx, ctx_set_textureclock(fb_RGB565_BS_ctx,
ctx_textureclock(fb_RGB565_BS_ctx) + 1); ctx_textureclock(fb_RGB565_BS_ctx) + 1);
...@@ -456,9 +451,12 @@ static void st3m_gfx_task(void *_arg) { ...@@ -456,9 +451,12 @@ static void st3m_gfx_task(void *_arg) {
} else { } else {
flow3r_bsp_display_send_fb(user_fb, bits); flow3r_bsp_display_send_fb(user_fb, bits);
} }
fb_ready = 1;
if ((set_mode & st3m_gfx_direct_ctx) == 0) {
ctx_drawlist_clear(drawlist->user_ctx); ctx_drawlist_clear(drawlist->user_ctx);
st3m_gfx_viewport_transform(drawlist->user_ctx); st3m_gfx_viewport_transform(drawlist->user_ctx);
}
xQueueSend(user_ctx_freeq, &desc_no, portMAX_DELAY); xQueueSend(user_ctx_freeq, &desc_no, portMAX_DELAY);
st3m_counter_rate_sample(&rast_rate); st3m_counter_rate_sample(&rast_rate);
...@@ -778,7 +776,6 @@ void st3m_gfx_init(void) { ...@@ -778,7 +776,6 @@ void st3m_gfx_init(void) {
ESP_TASK_PRIO_MIN + 1, &graphics_task); ESP_TASK_PRIO_MIN + 1, &graphics_task);
assert(res == pdPASS); assert(res == pdPASS);
} }
static int last_descno = 0; static int last_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) {
BaseType_t res = xQueueReceive(user_ctx_freeq, &last_descno, ticks_to_wait); BaseType_t res = xQueueReceive(user_ctx_freeq, &last_descno, ticks_to_wait);
...@@ -791,11 +788,21 @@ static Ctx *st3m_gfx_drawctx_free_get(TickType_t ticks_to_wait) { ...@@ -791,11 +788,21 @@ static Ctx *st3m_gfx_drawctx_free_get(TickType_t ticks_to_wait) {
drawlist->osd_y1 = _st3m_osd_y1; drawlist->osd_y1 = _st3m_osd_y1;
st3m_gfx_mode set_mode = _st3m_gfx_mode ? _st3m_gfx_mode : default_mode; st3m_gfx_mode set_mode = _st3m_gfx_mode ? _st3m_gfx_mode : default_mode;
switch ((int)set_mode) {
case st3m_gfx_16bpp_direct_ctx: if (set_mode & st3m_gfx_direct_ctx) {
case st3m_gfx_16bpp_direct_ctx_osd: while (!fb_ready) usleep(1);
switch (_st3m_gfx_bpp(set_mode)) {
case 16:
st3m_gfx_viewport_transform(fb_RGB565_BS_ctx); st3m_gfx_viewport_transform(fb_RGB565_BS_ctx);
return fb_RGB565_BS_ctx; return fb_RGB565_BS_ctx;
case 8:
st3m_gfx_viewport_transform(fb_GRAY8_ctx);
return fb_GRAY8_ctx;
case 24:
st3m_gfx_viewport_transform(fb_RGB8_ctx);
return fb_RGB8_ctx;
}
} }
return drawlist->user_ctx; return drawlist->user_ctx;
...@@ -816,14 +823,6 @@ void st3m_gfx_end_frame(Ctx *ctx) { ...@@ -816,14 +823,6 @@ void st3m_gfx_end_frame(Ctx *ctx) {
} }
uint8_t st3m_gfx_pipe_full(void) { uint8_t st3m_gfx_pipe_full(void) {
st3m_gfx_mode mode = _st3m_gfx_mode ? _st3m_gfx_mode : default_mode;
switch ((int)mode) {
case st3m_gfx_16bpp_direct_ctx:
case st3m_gfx_16bpp_direct_ctx_osd:
return (uxQueueSpacesAvailable(user_ctx_rastq) == 0) ||
(uxQueueMessagesWaiting(user_ctx_freeq) <=
_st3m_gfx_low_latency);
}
return uxQueueMessagesWaiting(user_ctx_freeq) <= _st3m_gfx_low_latency; return uxQueueMessagesWaiting(user_ctx_freeq) <= _st3m_gfx_low_latency;
} }
......
...@@ -164,6 +164,8 @@ class App(Application): ...@@ -164,6 +164,8 @@ class App(Application):
ctx.text(str(curmode)) ctx.text(str(curmode))
bpp = self.draw_choice("bpp", ["8", "16", "24"], bpp) bpp = self.draw_choice("bpp", ["8", "16", "24"], bpp)
if bpp > 0:
palette = 0
palette = self.draw_choice("palette", ["RGB", "gray", "sepia", "cool"], palette) palette = self.draw_choice("palette", ["RGB", "gray", "sepia", "cool"], palette)
scale = self.draw_choice("scale", ["1x", "2x", "3x", "4x"], scale) scale = self.draw_choice("scale", ["1x", "2x", "3x", "4x"], scale)
low_latency = self.draw_boolean("low latency", low_latency) low_latency = self.draw_boolean("low latency", low_latency)
...@@ -172,9 +174,6 @@ class App(Application): ...@@ -172,9 +174,6 @@ class App(Application):
lock = self.draw_boolean("lock", lock) lock = self.draw_boolean("lock", lock)
if direct_ctx: if direct_ctx:
low_latency = True low_latency = True
bpp = 8
if palette < 1:
palette = 2
if palette != 0: if palette != 0:
bpp = 0 bpp = 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment