diff options
author | omnisci3nce <omniscient.oce@gmail.com> | 2024-07-14 21:47:25 +1000 |
---|---|---|
committer | omnisci3nce <omniscient.oce@gmail.com> | 2024-07-14 21:47:25 +1000 |
commit | 529a603128d5e9dc4701322f44961f165e2183e1 (patch) | |
tree | 3e5d65ac503b971412ae35bfc5fb67a438a3c364 /src/render | |
parent | 5b001d39d42314085164724d3a417fb8ebd54f98 (diff) |
generate api docs python
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/backends/opengl/backend_opengl.c | 16 | ||||
-rw-r--r-- | src/render/bind_group_layouts.h | 30 | ||||
-rw-r--r-- | src/render/immediate.h | 19 | ||||
-rw-r--r-- | src/render/ral.h | 40 | ||||
-rw-r--r-- | src/render/static_pipeline.h | 30 |
5 files changed, 13 insertions, 122 deletions
diff --git a/src/render/backends/opengl/backend_opengl.c b/src/render/backends/opengl/backend_opengl.c index 70e10d7..43105e2 100644 --- a/src/render/backends/opengl/backend_opengl.c +++ b/src/render/backends/opengl/backend_opengl.c @@ -1,7 +1,6 @@ #include <stddef.h> #include <stdio.h> #include <string.h> -#include "builtin_materials.h" #include "colours.h" #include "maths.h" #include "opengl_helpers.h" @@ -63,11 +62,6 @@ bool gpu_backend_init(const char* window_name, struct GLFWwindow* window) { return true; } -void gpu_backend_shutdown() {} - -bool gpu_device_create(gpu_device* out_device) { /* No-op in OpenGL */ } -void gpu_device_destroy() { /* No-op in OpenGL */ } - // --- Render Pipeline gpu_pipeline* gpu_graphics_pipeline_create(struct graphics_pipeline_desc description) { gpu_pipeline* pipeline = pipeline_pool_alloc(&context.gpu_pools.pipelines, NULL); @@ -168,10 +162,6 @@ gpu_renderpass* gpu_renderpass_create(const gpu_renderpass_desc* description) { } void gpu_renderpass_destroy(gpu_renderpass* pass) { glDeleteFramebuffers(1, &pass->fbo); } -// --- Swapchain -bool gpu_swapchain_create(gpu_swapchain* out_swapchain) {} -void gpu_swapchain_destroy(gpu_swapchain* swapchain) {} - // --- Command buffer gpu_cmd_encoder gpu_cmd_encoder_create() { gpu_cmd_encoder encoder = { 0 }; @@ -180,12 +170,9 @@ gpu_cmd_encoder gpu_cmd_encoder_create() { void gpu_cmd_encoder_destroy(gpu_cmd_encoder* encoder) {} void gpu_cmd_encoder_begin(gpu_cmd_encoder encoder) {} void gpu_cmd_encoder_begin_render(gpu_cmd_encoder* encoder, gpu_renderpass* renderpass) { - // glViewport(0, 0, 1000, 1000); glBindFramebuffer(GL_FRAMEBUFFER, renderpass->fbo); rgba clear_colour = STONE_800; glClearColor(clear_colour.r, clear_colour.g, clear_colour.b, 1.0f); - /* glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); */ - // FIXME: account for both if (renderpass->description.has_depth_stencil) { glClear(GL_DEPTH_BUFFER_BIT); } else { @@ -353,9 +340,6 @@ buffer_handle gpu_buffer_create(u64 size, gpu_buffer_type buf_type, gpu_buffer_f return handle; } -void gpu_buffer_destroy(buffer_handle buffer) {} -void gpu_buffer_upload(const void* data) {} - texture_handle gpu_texture_create(texture_desc desc, bool create_view, const void* data) { // "allocating" the cpu-side struct texture_handle handle; diff --git a/src/render/bind_group_layouts.h b/src/render/bind_group_layouts.h deleted file mode 100644 index 246d1ef..0000000 --- a/src/render/bind_group_layouts.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @file bind_group_layouts.h - * @author your name (you@domain.com) - * @brief Common bindgroups (descriptor set layouts) - * @version 0.1 - * @date 2024-04-28 - * - * @copyright Copyright (c) 2024 - * - */ -#pragma once -#include "defines.h" -#include "maths_types.h" - -// Three major sets - -// 1. Scene / Global -typedef struct bg_globals { - mat4 view; - mat4 projection; - f32 total_time; - f32 delta_time; -} bg_globals; - -// 2. Material (once per object) - -// 3. Per draw call -typedef struct bg_model { - mat4 model; -} bg_model; diff --git a/src/render/immediate.h b/src/render/immediate.h deleted file mode 100644 index f4b1729..0000000 --- a/src/render/immediate.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include "geometry.h" -#include "maths_types.h" - -typedef struct immdraw_system immdraw_system; - -bool immdraw_system_init(immdraw_system* state); -void immdraw_system_shutdown(immdraw_system* state); -void immdraw_system_render(immdraw_system* state); - -// 3. SIMA (simplified immediate mode api) / render.h -// - dont need to worry about uploading mesh data -// - very useful for debugging -void immdraw_plane(vec3 pos, quat rotation, f32 u_scale, f32 v_scale, vec4 colour); -void immdraw_cuboid(vec3 pos, quat rotation, f32x3 extents, vec4 colour); -void immdraw_sphere(vec3 pos, f32 radius, vec4 colour); - -void immdraw_camera_frustum(); diff --git a/src/render/ral.h b/src/render/ral.h index 792bb4e..fc3c96c 100644 --- a/src/render/ral.h +++ b/src/render/ral.h @@ -109,24 +109,24 @@ typedef struct gpu_renderpass_desc { } gpu_renderpass_desc; // --- Lifecycle functions -bool gpu_backend_init(const char* window_name, struct GLFWwindow* window); -void gpu_backend_shutdown(); +// bool gpu_backend_init(const char* window_name, struct GLFWwindow* window); +// void gpu_backend_shutdown(); void resource_pools_init(arena* a, struct resource_pools* res_pools); -bool gpu_device_create(gpu_device* out_device); -void gpu_device_destroy(); +// bool gpu_device_create(gpu_device* out_device); +// void gpu_device_destroy(); -// --- Render Pipeline -gpu_pipeline* gpu_graphics_pipeline_create(struct graphics_pipeline_desc description); -void gpu_pipeline_destroy(gpu_pipeline* pipeline); +// // --- Render Pipeline +// gpu_pipeline* gpu_graphics_pipeline_create(struct graphics_pipeline_desc description); +// void gpu_pipeline_destroy(gpu_pipeline* pipeline); -// --- Renderpass -gpu_renderpass* gpu_renderpass_create(const gpu_renderpass_desc* description); -void gpu_renderpass_destroy(gpu_renderpass* pass); +// // --- Renderpass +// gpu_renderpass* gpu_renderpass_create(const gpu_renderpass_desc* description); +// void gpu_renderpass_destroy(gpu_renderpass* pass); -// --- Swapchain -bool gpu_swapchain_create(gpu_swapchain* out_swapchain); -void gpu_swapchain_destroy(gpu_swapchain* swapchain); +// // --- Swapchain +// bool gpu_swapchain_create(gpu_swapchain* out_swapchain); +// void gpu_swapchain_destroy(gpu_swapchain* swapchain); // --- Command buffer gpu_cmd_encoder gpu_cmd_encoder_create(); @@ -167,20 +167,6 @@ void encode_draw_indexed(gpu_cmd_encoder* encoder, u64 index_count); void encode_clear_buffer(gpu_cmd_encoder* encoder, buffer_handle buf); // --- Buffers -buffer_handle gpu_buffer_create(u64 size, gpu_buffer_type buf_type, gpu_buffer_flags flags, - const void* data); -void gpu_buffer_destroy(buffer_handle buffer); -void gpu_buffer_upload(const void* data); - -// Textures -/** @brief Create a new GPU texture resource. - * @param create_view creates a texture view (with same dimensions) at the same time - * @param data if not NULL then the data stored at the pointer will be uploaded to the GPU texture - * @note automatically creates a sampler for you */ -texture_handle gpu_texture_create(texture_desc desc, bool create_view, const void* data); -void gpu_texture_destroy(texture_handle); -void gpu_texture_upload(texture_handle texture, const void* data); - // --- Vertex formats bytebuffer vertices_as_bytebuffer(arena* a, vertex_format format, vertex_darray* vertices); diff --git a/src/render/static_pipeline.h b/src/render/static_pipeline.h deleted file mode 100644 index bf5bc42..0000000 --- a/src/render/static_pipeline.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -#include "defines.h" -#include "maths_types.h" -#include "ral.h" -#include "ral_types.h" -#include "render_types.h" - -typedef struct mvp_uniforms { - mat4 model; - mat4 view; - mat4 projection; -} mvp_uniforms; -typedef struct my_shader_bind_group { - mvp_uniforms mvp; -} my_shader_bind_group; - -static shader_data_layout mvp_uniforms_layout(void* data) { - my_shader_bind_group* d = (my_shader_bind_group*)data; - bool has_data = data != NULL; - - shader_binding b1 = { .label = "Matrices", - .type = SHADER_BINDING_BYTES, - .stores_data = has_data, - .data = { .bytes = { .size = sizeof(mvp_uniforms) } } }; - - if (has_data) { - b1.data.bytes.data = &d->mvp; - } - return (shader_data_layout){ .name = "global_ubo", .bindings = { b1 }, .bindings_count = 1 }; -} |