From 0042786b77186e24c974617db9288840a7060858 Mon Sep 17 00:00:00 2001 From: antifallobst Date: Fri, 3 Mar 2023 17:50:24 +0100 Subject: [PATCH] fix (renderer): made renderer update thread safe --- kernel/inc/drivers/graphics/renderer.h | 1 + kernel/src/drivers/graphics/renderer.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/kernel/inc/drivers/graphics/renderer.h b/kernel/inc/drivers/graphics/renderer.h index a5416ad..6140213 100644 --- a/kernel/inc/drivers/graphics/renderer.h +++ b/kernel/inc/drivers/graphics/renderer.h @@ -60,6 +60,7 @@ typedef struct { graphics_buffer_T** graphics_buffer_layers; font_T font; bool initialized; + bool blocked; } graphics_renderer_T; graphics_buffer_T* graphics_buffer_request (uint32_t pos_x, uint32_t pos_y, uint32_t width, uint32_t height, graphics_buffer_layer_E layer); diff --git a/kernel/src/drivers/graphics/renderer.c b/kernel/src/drivers/graphics/renderer.c index 979f1f8..6a4ed35 100644 --- a/kernel/src/drivers/graphics/renderer.c +++ b/kernel/src/drivers/graphics/renderer.c @@ -163,6 +163,7 @@ void graphics_renderer_init(boot_info_T* boot_info_T) { g_renderer.back_buffer = memory_allocate(g_renderer.buffer_size); g_renderer.graphics_buffer_layers = memory_allocate(GRAPHICS_BUFFER_ENUM_MAX * sizeof(graphics_buffer_T*)); g_renderer.font = g_font; + g_renderer.blocked = false; memory_set(g_renderer.graphics_buffer_layers, 0, GRAPHICS_BUFFER_ENUM_MAX * sizeof(graphics_buffer_T*)); memory_set(g_renderer.back_buffer, 0, g_renderer.buffer_size); @@ -202,6 +203,9 @@ void graphics_renderer_update_graphics_buffer(graphics_buffer_T* graphics_buffer } void graphics_renderer_update() { + CORE_HALT_WHILE(g_renderer.blocked) + g_renderer.blocked = true; + memory_set(g_renderer.back_buffer, 0, g_renderer.buffer_size); graphics_buffer_T* graphics_buffer = g_renderer.graphics_buffer_layers[GRAPHICS_BUFFER_STANDARD]; @@ -219,6 +223,8 @@ void graphics_renderer_update() { // swap back_buffer into framebuffer memory_copy(g_renderer.back_buffer, g_renderer.framebuffer.address, g_renderer.buffer_size); + + g_renderer.blocked = false; } graphics_buffer_T* graphics_renderer_get_top_buffer(graphics_buffer_layer_E layer) {