Add render_command_buffer handle type

Also unify handle types via macro
This commit is contained in:
Kevin Trogant 2024-02-09 10:09:39 +01:00
parent c23f03e622
commit 765e263979
5 changed files with 16 additions and 11 deletions

View File

@ -126,7 +126,7 @@ rt_pipeline_handle RT_RENDERER_API_FN(CompilePipeline)(const rt_pipeline_info *i
} }
rt_pipeline_slot *slot = _first_free; rt_pipeline_slot *slot = _first_free;
_first_free = slot->next_free; _first_free = slot->next_free;
slot->version = (slot->version + 1) & RT_GFX_HANDLE_MAX_VERSION; slot->version = (slot->version + 1) & RT_RENDER_BACKEND_HANDLE_MAX_VERSION;
/* No other thread that calls compile gets the same slot. /* No other thread that calls compile gets the same slot.
* Another thread accessing the slot via GetPipeline would get a version mismatch. * Another thread accessing the slot via GetPipeline would get a version mismatch.

View File

@ -147,7 +147,7 @@ rt_render_target_handle RT_RENDERER_API_FN(CreateRenderTarget)(const rt_render_t
} }
rt_render_target_slot *slot = _first_free; rt_render_target_slot *slot = _first_free;
_first_free = slot->next_free; _first_free = slot->next_free;
slot->version = (slot->version + 1) & RT_GFX_HANDLE_MAX_VERSION; slot->version = (slot->version + 1) & RT_RENDER_BACKEND_HANDLE_MAX_VERSION;
/* No other thread that calls compile gets the same slot. /* No other thread that calls compile gets the same slot.
* Another thread accessing the slot via GetPipeline would get a version mismatch. * Another thread accessing the slot via GetPipeline would get a version mismatch.

View File

@ -1,3 +1,4 @@
#define RT_DONT_DEFINE_MAIN_LOOP_GLOBAL
#include "main_loop.h" #include "main_loop.h"
#include "runtime.h" #include "runtime.h"
#include "config.h" #include "config.h"

View File

@ -23,8 +23,10 @@ typedef struct {
volatile int shutdown; volatile int shutdown;
} rt_main_loop; } rt_main_loop;
#ifndef RT_DONT_DEFINE_MAIN_LOOP_GLOBAL
/* The applications main-loop */ /* The applications main-loop */
extern RT_DLLIMPORT rt_main_loop g_main_loop; extern RT_DLLIMPORT rt_main_loop g_main_loop;
#endif
RT_DLLEXPORT rt_result rtInitMainLoop(rt_main_loop_update_fn *update_cb, RT_DLLEXPORT rt_result rtInitMainLoop(rt_main_loop_update_fn *update_cb,
rt_main_loop_render_fn *render_cb); rt_main_loop_render_fn *render_cb);

View File

@ -88,17 +88,19 @@ typedef struct {
/* Handles for backend objects */ /* Handles for backend objects */
#define RT_GFX_HANDLE_MAX_VERSION 255 #define RT_RENDER_BACKEND_HANDLE_MAX_VERSION 255
typedef struct { #define RT_RENDER_BACKEND_HANDLE(name) \
uint32_t version : 8; typedef struct { \
uint32_t index : 24; uint32_t version : 8; \
} rt_pipeline_handle; uint32_t index : 24; \
} name
typedef struct { RT_RENDER_BACKEND_HANDLE(rt_pipeline_handle);
uint32_t version : 8; RT_RENDER_BACKEND_HANDLE(rt_render_target_handle);
uint32_t index : 24; RT_RENDER_BACKEND_HANDLE(rt_render_command_buffer_handle);
} rt_render_target_handle;
#undef RT_RENDER_BACKEND_HANDLE
typedef void rt_register_renderer_cvars_fn(void); typedef void rt_register_renderer_cvars_fn(void);
typedef rt_result rt_init_renderer_fn(const rt_renderer_init_info *info); typedef rt_result rt_init_renderer_fn(const rt_renderer_init_info *info);