summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-19 11:03:21 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-19 11:03:21 +1000
commitf926234600af1883c2be259360b44173bb7c12b4 (patch)
tree8938056cf43f7fc1fa5c2362ee022c5599ac8b28
parent0942a484a90695749f05d49273951f2b8d452866 (diff)
updating docs
-rw-r--r--README.md12
-rw-r--r--docs/index.md4
-rw-r--r--docs/project-layout.md27
-rw-r--r--docs/rendering.md2
-rw-r--r--src/defines.h7
-rw-r--r--src/logos/threadpool.h4
-rw-r--r--src/new_render/render.c22
-rw-r--r--src/new_render/render.h3
-rw-r--r--src/new_render/render_frame.c20
-rw-r--r--src/new_render/render_frame.h27
-rw-r--r--src/platform/path.c2
-rw-r--r--src/ral/backends/opengl/backend_opengl.h2
12 files changed, 117 insertions, 15 deletions
diff --git a/README.md b/README.md
index b9c3bf6..f9ad098 100644
--- a/README.md
+++ b/README.md
@@ -48,7 +48,7 @@ All third-party dependencies are licensed under their own license.
#### Scene
- [ ] Transform hierarchy / Scene tree
- - [ ] transform propagation
+ - [ ] Transform propagation
### Renderer
@@ -56,3 +56,13 @@ All third-party dependencies are licensed under their own license.
- [x] Basic implementation using learnopengl
- [ ] Implementation using filament as a reference for first in class PBR
- [ ] Handle metallic / roughness being in different channels, combined, or absent
+- [ ] Shadows
+ - [x] Shadowmaps
+ - [ ] PCF
+ - [ ] Cascading shadowmaps (CSM)
+- [ ] Cel shading
+- [ ] Terrain
+- [ ] Animation
+ - [x] Joint and keyframe loading
+ - [ ] Handle multiple animations in one GLTF
+ - [ ] Animation Blending
diff --git a/docs/index.md b/docs/index.md
index 54d6383..f71d8fe 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -30,9 +30,7 @@ Celeritas is the original Latin word for celerity that the English is derived fr
**Roadmap going forwards**
-* Collision detection
-* Terrain rendering
-* GPU-driven rendering
+[See here (README)](https://github.com/omnisci3nce/celeritas-core/blob/winter-cleaning/README.md#todo)
## Getting started
diff --git a/docs/project-layout.md b/docs/project-layout.md
index 74a84aa..3d8f466 100644
--- a/docs/project-layout.md
+++ b/docs/project-layout.md
@@ -1,9 +1,30 @@
---
-title: Project Layout
+title: Project Structure
---
```
deps/ - third-party dependencies
docs/ - these docs you're reading now that get built with mkdocs
-TODO: the rest...
-``` \ No newline at end of file
+src/
+ core/ - core game engine facilities
+ logos/ -
+ maths/
+ platform/
+ ral/
+ render/
+ resources/
+ std/
+ systems/
+ ui/
+```
+
+
+#### Core
+
+Core holds specifically functionality vital to making games or 3D applications. Contrast this with `std` which contains
+code that could form the base layer of almost any software out there.
+
+#### Std
+
+Data structures, algorithms, memory management, etc - all code here forms a foundation for everything above it and can conceivably
+be reused in non-game applications. \ No newline at end of file
diff --git a/docs/rendering.md b/docs/rendering.md
index 05da5fc..f23fbd1 100644
--- a/docs/rendering.md
+++ b/docs/rendering.md
@@ -3,5 +3,5 @@
Rendering is split into 3 'registers'.
1. **RAL** (Render Abstraction Layer) - thin abstraction over graphics APIs
-2. **render** - implements the default renderer and higher-level functions like `draw_scene`
+2. **render** - implements the default renderer and higher-level functions
3. **immediate** - immediate-mode drawing API for things like debug visualisation and UI \ No newline at end of file
diff --git a/src/defines.h b/src/defines.h
index 2edba8a..7275a4d 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -53,6 +53,9 @@ CORE_DEFINE_HANDLE(Handle); // Untyped handle that can be casted to a strongly t
#define PUB // For collecting public APIs to expose in an amalgamation header file
+#define MB(x) ((size_t) x * 1000 * 1000)
+#define KB(x) ((size_t) x * 1000)
+
// NOTE: The below is now handled in xmake.lua
// Platform will inform renderer backend (unless user overrides)
#if defined(CEL_PLATFORM_LINUX)
@@ -68,6 +71,6 @@ CORE_DEFINE_HANDLE(Handle); // Untyped handle that can be casted to a strongly t
#if defined(CEL_PLATFORM_MAC)
// #define CEL_REND_BACKEND_METAL 1
-// #define CEL_REND_BACKEND_OPENGL 1
-#define CEL_REND_BACKEND_VULKAN 1
+#define CEL_REND_BACKEND_OPENGL 1
+// #define CEL_REND_BACKEND_VULKAN 1
#endif
diff --git a/src/logos/threadpool.h b/src/logos/threadpool.h
index d5df2cd..fbe43d6 100644
--- a/src/logos/threadpool.h
+++ b/src/logos/threadpool.h
@@ -91,4 +91,6 @@ bool threadpool_add_task(threadpool *pool, tpool_task_start do_task,
bool buffer_result_for_main_thread, void *param_data, u32 param_data_size,
u32 result_data_size);
-void threadpool_process_results(threadpool *pool, int num_to_process); \ No newline at end of file
+void threadpool_process_results(threadpool *pool, int num_to_process);
+
+u32 Tpool_GetNumWorkers(); // how many threads are we using \ No newline at end of file
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
diff --git a/src/new_render/render.h b/src/new_render/render.h
index 718ac3e..0043c6c 100644
--- a/src/new_render/render.h
+++ b/src/new_render/render.h
@@ -64,3 +64,6 @@ PUB void DrawMesh(Mesh* mesh, Material* material, Mat4 model);
/** @brief the renderer does some internal bookkeeping for terrain so we use the terrain
stored on the Renderer rather than accept it as a parameter */
PUB void Render_DrawTerrain();
+
+// --- Getters (not in love with this but I'm finding keeping Renderer internals private to be okay)
+arena* GetRenderFrameArena(Renderer* r); \ No newline at end of file
diff --git a/src/new_render/render_frame.c b/src/new_render/render_frame.c
new file mode 100644
index 0000000..2dc98b0
--- /dev/null
+++ b/src/new_render/render_frame.c
@@ -0,0 +1,20 @@
+
+
+#include "render_frame.h"
+#include <assert.h>
+#include "logos/threadpool.h"
+#include "mem.h"
+#include "render.h"
+
+
+Cull_Result Frame_Cull(Renderer* ren, RenderEnt *entities, size_t entity_count, Camera *camera) {
+ // TODO: u32 chunk_count = Tpool_GetNumWorkers();
+
+ arena* frame_arena = GetRenderFrameArena(ren);
+
+ Cull_Result result = {0};
+ result.visible_ent_indices = arena_alloc(frame_arena, sizeof(u32) * entity_count); // make space for if all ents are visible
+
+ assert((result.n_visible_objects + result.n_culled_objects == entity_count));
+ return result;
+} \ No newline at end of file
diff --git a/src/new_render/render_frame.h b/src/new_render/render_frame.h
new file mode 100644
index 0000000..11b24f2
--- /dev/null
+++ b/src/new_render/render_frame.h
@@ -0,0 +1,27 @@
+#pragma once
+#include "camera.h"
+#include "defines.h"
+#include "ral_types.h"
+#include "render_types.h"
+
+// Frame lifecycle on CPU
+
+// 1. extract
+// 2. culling
+// 3. render
+// 4. dispatch (combined with render for now)
+
+typedef struct Cull_Result {
+ u64 n_visible_objects;
+ u64 n_culled_objects;
+ u32* visible_ent_indices; // allocated on frame arena
+ size_t index_count;
+} Cull_Result;
+
+// everything that can be in the world, knows how to extract rendering data
+typedef void (*ExtractRenderData)(void* world_data);
+
+typedef struct Renderer Renderer;
+
+/** @brief Produces a smaller set of only those meshes visible in the camera frustum on the CPU */
+Cull_Result Frame_Cull(Renderer* ren, RenderEnt* entities, size_t entity_count, Camera *camera); \ No newline at end of file
diff --git a/src/platform/path.c b/src/platform/path.c
index e49aa3a..31fa59c 100644
--- a/src/platform/path.c
+++ b/src/platform/path.c
@@ -12,7 +12,7 @@ path_opt path_parent(arena* a, const char* path) {
char* path_copy = arena_alloc(a, strlen(path) + 1);
strcpy(path_copy, path);
char* path_dirname = dirname(path_copy);
- return (path_opt){ .path = str8_cstr_view(path_dirname), .has_value = true };
+ return (path_opt){ .path = Str8_cstr_view(path_dirname), .has_value = true };
}
#endif
#ifdef CEL_PLATFORM_WINDOWS
diff --git a/src/ral/backends/opengl/backend_opengl.h b/src/ral/backends/opengl/backend_opengl.h
index f8e76b8..f5ab9c8 100644
--- a/src/ral/backends/opengl/backend_opengl.h
+++ b/src/ral/backends/opengl/backend_opengl.h
@@ -66,7 +66,7 @@ typedef struct GPU_Texture {
typedef struct opengl_support {
} opengl_support;
-u32 shader_create_separate(const char *vert_shader, const char *frag_shader);
+// u32 shader_create_separate(const char *vert_shader, const char *frag_shader);
void uniform_vec3f(u32 program_id, const char *uniform_name, Vec3 *value);
void uniform_f32(u32 program_id, const char *uniform_name, f32 value);