diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-08-12 01:07:35 +1000 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-08-12 01:07:35 +1000 |
commit | 43d915b2ceb3f5e439c09c772e9ebc7542c1a2bb (patch) | |
tree | 57c9cf036674dcb8162ae153ccb9c2000ac7a81f | |
parent | 72b8d26fcfcee36ca67f963b9c6a4b616e2d5d4d (diff) |
s
-rw-r--r-- | docs/Contributing/naming.md | 4 | ||||
-rw-r--r-- | src/core/camera.h | 6 | ||||
-rw-r--r-- | src/defines.h | 1 | ||||
-rw-r--r-- | src/ral/backends/opengl/backend_opengl.h | 35 | ||||
-rw-r--r-- | src/ral/ral_impl.h | 24 | ||||
-rw-r--r-- | src/ral/ral_types.h | 18 | ||||
-rw-r--r-- | src/render/render_types.h | 3 |
7 files changed, 66 insertions, 25 deletions
diff --git a/docs/Contributing/naming.md b/docs/Contributing/naming.md index 518c22e..f865f67 100644 --- a/docs/Contributing/naming.md +++ b/docs/Contributing/naming.md @@ -19,6 +19,8 @@ e.g. #### 2. Long-running systems +in celeritas a "system" is roughly something that runs every frame + systems that run for the lifetime of the application or for a very long time should have: * `bool system_init(system_state* state)` a `init` function @@ -26,4 +28,4 @@ systems that run for the lifetime of the application or for a very long time sho --- -#### 3. TODO
\ No newline at end of file +#### 3. TODO diff --git a/src/core/camera.h b/src/core/camera.h index 536feca..4300f87 100644 --- a/src/core/camera.h +++ b/src/core/camera.h @@ -1,12 +1,10 @@ -/** - * @file camera.h - * @brief - */ #pragma once #include "defines.h" #include "maths_types.h" +// TODO: swap to position + quaternion + typedef struct Camera { Vec3 position; Vec3 front; diff --git a/src/defines.h b/src/defines.h index 67a4f17..e9db543 100644 --- a/src/defines.h +++ b/src/defines.h @@ -2,7 +2,6 @@ * @file defines.h * @brief Typedefs for common integer/floating point types and very basic macros * @date 2024-02-24 - * @copyright Copyright (c) 2024 */ #pragma once diff --git a/src/ral/backends/opengl/backend_opengl.h b/src/ral/backends/opengl/backend_opengl.h index 3e40945..805914e 100644 --- a/src/ral/backends/opengl/backend_opengl.h +++ b/src/ral/backends/opengl/backend_opengl.h @@ -68,10 +68,43 @@ typedef struct opengl_support { u32 pad; } opengl_support; -// 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); void uniform_i32(u32 program_id, const char *uniform_name, i32 value); void uniform_mat4f(u32 program_id, const char *uniform_name, Mat4 *value); + +typedef enum GlCommandType { + GLCMD_DRAW, + GLCMD_DRAW_INDEXED, + GLCMD_BIND_VBUF, + GLCMD_BIND_IBUF, + GLCMD_SET_PROGRAM, +} GlCommandType; + +typedef struct GlCommand { + GlCommandType cmd_type; + union { + struct { + PrimitiveTopology topology; + u32 start_vertex; + u32 vertex_count; + // TODO: instance + } draw; + struct { + PrimitiveTopology topology; + u32 index_count; + } draw_indexed; + struct { + u32 buffer_id; + } bind_vbuf; + struct { + u32 buffer_id; + } bind_ibuf; + struct { + u32 program_id; + } set_program; + } data; +} GlCommand; + #endif diff --git a/src/ral/ral_impl.h b/src/ral/ral_impl.h index 8f96bc3..2ca75d6 100644 --- a/src/ral/ral_impl.h +++ b/src/ral/ral_impl.h @@ -62,22 +62,7 @@ PUB void GPU_TextureDestroy(TextureHandle handle); PUB void GPU_TextureUpload(TextureHandle handle, size_t n_bytes, const void* data); // --- Data copy commands -// TODO: Rename these to reflect current coding style -void encode_buffer_copy(GPU_CmdEncoder* encoder, BufferHandle src, u64 src_offset, BufferHandle dst, - u64 dst_offset, u64 copy_size); -void buffer_upload_bytes(BufferHandle gpu_buf, bytebuffer cpu_buf, u64 offset, u64 size); - -void copy_buffer_to_buffer_oneshot(BufferHandle src, u64 src_offset, BufferHandle dst, - u64 dst_offset, u64 copy_size); -void copy_buffer_to_image_oneshot(BufferHandle src, TextureHandle dst); - -// --- Render commands -PUB void GPU_EncodeBindPipeline(GPU_CmdEncoder* encoder, GPU_Pipeline* pipeline); -PUB void GPU_EncodeBindShaderData(GPU_CmdEncoder* encoder, u32 group, ShaderDataLayout layout); -void GPU_EncodeSetDefaults(GPU_CmdEncoder* encoder); -PUB void GPU_EncodeSetVertexBuffer(GPU_CmdEncoder* encoder, BufferHandle buf); -PUB void GPU_EncodeSetIndexBuffer(GPU_CmdEncoder* encoder, BufferHandle buf); -PUB void GPU_EncodeCopyBufToBuf(); +PUB void GPU_EncodeCopyBufToBuf(GPU_CmdEncoder* encoder, BufferHandle src, u64 src_offset, BufferHandle dst, u64 dst_offset, u64 copy_size); // PUB void GPU_EncodeCopyBufToTex(GPU_CmdEncoder* encoder, BufferHandle src, TextureHandle dst, // u32 x_offset, u32 y_offset, u32 width, u32 height, const void* data); @@ -88,6 +73,13 @@ PUB void GPU_WriteTextureRegion(GPU_CmdEncoder* encoder, TextureHandle dst, u32 PUB void GPU_WriteBuffer(GPU_CmdEncoder* encoder, BufferHandle buf, u64 offset, u64 size, const void* data); +// --- Render commands +PUB void GPU_EncodeBindPipeline(GPU_CmdEncoder* encoder, GPU_Pipeline* pipeline); +PUB void GPU_EncodeBindShaderData(GPU_CmdEncoder* encoder, u32 group, ShaderDataLayout layout); +void GPU_EncodeSetDefaults(GPU_CmdEncoder* encoder); +PUB void GPU_EncodeSetVertexBuffer(GPU_CmdEncoder* encoder, BufferHandle buf); +PUB void GPU_EncodeSetIndexBuffer(GPU_CmdEncoder* encoder, BufferHandle buf); + PUB void GPU_EncodeDraw(GPU_CmdEncoder* encoder, u64 count); PUB void GPU_EncodeDrawIndexed(GPU_CmdEncoder* encoder, u64 index_count); PUB void GPU_EncodeDrawInstanced(GPU_CmdEncoder* encoder, u64 index_count, diff --git a/src/ral/ral_types.h b/src/ral/ral_types.h index 470e4e9..e15e0f4 100644 --- a/src/ral/ral_types.h +++ b/src/ral/ral_types.h @@ -232,6 +232,24 @@ typedef enum PrimitiveTopology { typedef enum CullMode { CULL_BACK_FACE, CULL_FRONT_FACE, CULL_COUNT } CullMode; +typedef enum Winding { + WINDING_CCW, + WINDING_CW +} Winding; + +// based on https://registry.khronos.org/OpenGL-Refpages/gl4/html/glDepthFunc.xhtml +typedef enum CompareFunc { + COMPARE_NEVER, + COMPARE_LESS, + COMPARE_EQUAL, + COMPARE_LESS_EQUAL, + COMPARE_GREATER, + COMPARE_NOT_EQUAL, + COMPARE_GREATER_EQUAL, + COMPARE_ALWAYS, + COMPARE_COUNT +} CompareFunc; + typedef struct GraphicsPipelineDesc { const char* debug_name; VertexDescription vertex_desc; diff --git a/src/render/render_types.h b/src/render/render_types.h index ce2c7b8..89773a5 100644 --- a/src/render/render_types.h +++ b/src/render/render_types.h @@ -1,5 +1,4 @@ /** - * @file render_types.h * @brief */ @@ -140,4 +139,4 @@ typedef struct RenderEnt { #ifndef TYPED_RENDERENT_ARRAY KITC_DECL_TYPED_ARRAY(RenderEnt) #define TYPED_RENDERENT_ARRAY -#endif
\ No newline at end of file +#endif |