fix (renderer): made renderer update thread safe
This commit is contained in:
parent
dd0c2a3169
commit
0042786b77
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue