diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-07-19 11:03:21 +1000 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-07-19 11:03:21 +1000 |
commit | f926234600af1883c2be259360b44173bb7c12b4 (patch) | |
tree | 8938056cf43f7fc1fa5c2362ee022c5599ac8b28 /src/new_render/render.c | |
parent | 0942a484a90695749f05d49273951f2b8d452866 (diff) |
updating docs
Diffstat (limited to 'src/new_render/render.c')
-rw-r--r-- | src/new_render/render.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/new_render/render.c b/src/new_render/render.c index 58041dd..bcdeb75 100644 --- a/src/new_render/render.c +++ b/src/new_render/render.c @@ -10,6 +10,7 @@ #include "log.h" #include "maths.h" #include "maths_types.h" +#include "mem.h" #include "pbr.h" #include "ral_common.h" #include "ral_impl.h" @@ -21,6 +22,8 @@ #define STB_IMAGE_IMPLEMENTATION #include <stb_image.h> +#define FRAME_ARENA_SIZE MB(1) + extern Core g_core; struct Renderer { @@ -36,6 +39,7 @@ struct Renderer { // Terrain_Storage terrain; // Text_Storage text; ResourcePools* resource_pools; + arena frame_arena; }; Renderer* get_renderer() { return g_core.renderer; } @@ -43,6 +47,8 @@ Renderer* get_renderer() { return g_core.renderer; } bool Renderer_Init(RendererConfig config, Renderer* ren, GLFWwindow** out_window) { INFO("Renderer init"); + ren->frame_arena = arena_create(malloc(FRAME_ARENA_SIZE), FRAME_ARENA_SIZE); + // init resource pools DEBUG("Initialise GPU resource pools"); arena pool_arena = arena_create(malloc(1024 * 1024), 1024 * 1024); @@ -100,10 +106,18 @@ bool Renderer_Init(RendererConfig config, Renderer* ren, GLFWwindow** out_window return true; } -void Renderer_Shutdown(Renderer* ren) { free(ren->shadows); } +void Renderer_Shutdown(Renderer* ren) { + free(ren->shadows); + DEBUG("Freed Shadows storage"); + free(ren->pbr); + DEBUG("Freed PBR storage"); + arena_free_storage(&ren->frame_arena); + DEBUG("Freed frame allocator buffer"); +} size_t Renderer_GetMemReqs() { return sizeof(Renderer); } void Render_FrameBegin(Renderer* ren) { + arena_free_all(&ren->frame_arena); ren->frame_aborted = false; if (!GPU_Backend_BeginFrame()) { ren->frame_aborted = true; @@ -207,4 +221,8 @@ void Geometry_Destroy(Geometry* geometry) { } void SetCamera(Camera camera) { g_core.renderer->scene.camera = camera; } -void SetMainLight(DirectionalLight light) { g_core.renderer->scene.sun = light; }
\ No newline at end of file +void SetMainLight(DirectionalLight light) { g_core.renderer->scene.sun = light; } + +arena* GetRenderFrameArena(Renderer* r) { + return &r->frame_arena; +}
\ No newline at end of file |