diff options
Diffstat (limited to 'src/ral')
-rw-r--r-- | src/ral/backends/opengl/backend_opengl.h | 73 | ||||
-rw-r--r-- | src/ral/backends/opengl/opengl_helpers.h | 15 | ||||
-rw-r--r-- | src/ral/ral_impl.h | 6 | ||||
-rw-r--r-- | src/ral/ral_types.h | 23 |
4 files changed, 60 insertions, 57 deletions
diff --git a/src/ral/backends/opengl/backend_opengl.h b/src/ral/backends/opengl/backend_opengl.h index 805914e..7bd1b81 100644 --- a/src/ral/backends/opengl/backend_opengl.h +++ b/src/ral/backends/opengl/backend_opengl.h @@ -20,12 +20,12 @@ typedef struct GPU_Device { } GPU_Device; typedef struct GPU_PipelineLayout { - void *pad; + void* pad; } GPU_PipelineLayout; typedef struct GPU_Pipeline { u32 shader_id; - GPU_Renderpass *renderpass; + GPU_Renderpass* renderpass; VertexDescription vertex_desc; BufferHandle uniform_bindings[MAX_PIPELINE_UNIFORM_BUFFERS]; u32 uniform_count; @@ -38,11 +38,11 @@ typedef struct GPU_Renderpass { } GPU_Renderpass; typedef struct GPU_CmdEncoder { - GPU_Pipeline *pipeline; + GPU_Pipeline* pipeline; } GPU_CmdEncoder; // Recording typedef struct GPU_CmdBuffer { - void *pad; + void* pad; } GPU_CmdBuffer; // Ready for submission typedef struct GPU_Buffer { @@ -55,7 +55,7 @@ typedef struct GPU_Buffer { u32 vao; u32 ubo_binding_point; }; // Optional - char *name; + char* name; u64 size; } GPU_Buffer; @@ -68,43 +68,42 @@ typedef struct opengl_support { u32 pad; } opengl_support; - -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); +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, + 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; + 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/backends/opengl/opengl_helpers.h b/src/ral/backends/opengl/opengl_helpers.h index b73eaea..706e2a0 100644 --- a/src/ral/backends/opengl/opengl_helpers.h +++ b/src/ral/backends/opengl/opengl_helpers.h @@ -140,11 +140,16 @@ static GLenum opengl_tex_type(GPU_TextureType tex_type) { static GLenum opengl_prim_topology(PrimitiveTopology t) { switch (t) { - case CEL_POINT: return GL_POINT; - case CEL_LINE: return GL_LINES; - case CEL_LINE_STRIP: return GL_LINE_STRIP; - case CEL_TRI: return GL_TRIANGLES; - case CEL_TRI_STRIP: return GL_TRIANGLE_STRIP; + case CEL_POINT: + return GL_POINT; + case CEL_LINE: + return GL_LINES; + case CEL_LINE_STRIP: + return GL_LINE_STRIP; + case CEL_TRI: + return GL_TRIANGLES; + case CEL_TRI_STRIP: + return GL_TRIANGLE_STRIP; case PRIMITIVE_TOPOLOGY_COUNT: WARN("Invalid PrimitiveTopology value"); break; diff --git a/src/ral/ral_impl.h b/src/ral/ral_impl.h index 3374d91..16c9767 100644 --- a/src/ral/ral_impl.h +++ b/src/ral/ral_impl.h @@ -62,7 +62,8 @@ PUB void GPU_TextureDestroy(TextureHandle handle); PUB void GPU_TextureUpload(TextureHandle handle, size_t n_bytes, const void* data); // --- Data copy commands -PUB void GPU_EncodeCopyBufToBuf(GPU_CmdEncoder* encoder, BufferHandle src, u64 src_offset, BufferHandle dst, u64 dst_offset, u64 copy_size); +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); @@ -81,7 +82,8 @@ 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, PrimitiveTopology topology, u64 count); -PUB void GPU_EncodeDrawIndexed(GPU_CmdEncoder* encoder, PrimitiveTopology topology, u64 index_count); +PUB void GPU_EncodeDrawIndexed(GPU_CmdEncoder* encoder, PrimitiveTopology topology, + u64 index_count); // convenience versions of the above PUB void GPU_EncodeDrawTris(GPU_CmdEncoder* encoder, u64 count); PUB void GPU_EncodeDrawIndexedTris(GPU_CmdEncoder* encoder, u64 index_count); diff --git a/src/ral/ral_types.h b/src/ral/ral_types.h index 7c83af6..1f98e88 100644 --- a/src/ral/ral_types.h +++ b/src/ral/ral_types.h @@ -243,22 +243,19 @@ typedef enum PrimitiveTopology { typedef enum CullMode { CULL_BACK_FACE, CULL_FRONT_FACE, CULL_COUNT } CullMode; -typedef enum Winding { - WINDING_CCW, - WINDING_CW -} Winding; +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 + 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 { |