summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmniscient <17525998+omnisci3nce@users.noreply.github.com>2024-05-11 00:22:13 +1000
committerOmniscient <17525998+omnisci3nce@users.noreply.github.com>2024-05-11 00:22:13 +1000
commiteedd332680dbdd367197616658903f00252f5a9c (patch)
treeb50b7fe4c014abd8fee65a2cb1567d8df9a38e7e
parent3bd21c92678c62e61c10ba730e8c839edc5e967a (diff)
upload data using staging buffer. use vertex buffer data
-rw-r--r--assets/shaders/triangle.vert11
-rw-r--r--examples/triangle/ex_triangle.c23
-rw-r--r--src/core.c9
-rw-r--r--src/core.h2
-rw-r--r--src/maths/maths.h5
-rw-r--r--src/renderer/backends/backend_vulkan.c170
-rw-r--r--src/renderer/backends/backend_vulkan.h8
-rw-r--r--src/renderer/ral.h7
-rw-r--r--src/renderer/ral_types.h22
-rw-r--r--src/renderer/render.c43
-rw-r--r--src/scene.h2
11 files changed, 250 insertions, 52 deletions
diff --git a/assets/shaders/triangle.vert b/assets/shaders/triangle.vert
index ee3675d..b8c8f63 100644
--- a/assets/shaders/triangle.vert
+++ b/assets/shaders/triangle.vert
@@ -1,12 +1,13 @@
#version 450
-vec2 positions[3] = vec2[](vec2(-0.5, 0.5), vec2(0.5, 0.5), vec2(0.0, -0.5));
-
-vec3 colors[3] = vec3[](vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0));
+layout(location = 0) in vec2 inPos;
+layout(location = 1) in vec3 inColor;
+// layout(location = 1) in vec3 inNormal;
+// layout(location = 2) in vec2 inTexCoords;
layout(location = 0) out vec3 fragColor;
void main() {
- gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0);
- fragColor = colors[gl_VertexIndex];
+ gl_Position = vec4(inPos, 0.0, 1.0);
+ fragColor = inColor;
}
diff --git a/examples/triangle/ex_triangle.c b/examples/triangle/ex_triangle.c
index 7b8a1d0..c4f90f2 100644
--- a/examples/triangle/ex_triangle.c
+++ b/examples/triangle/ex_triangle.c
@@ -1,6 +1,7 @@
#include <glfw3.h>
#include "backend_vulkan.h"
+#include "buf.h"
#include "camera.h"
#include "core.h"
#include "file.h"
@@ -8,12 +9,20 @@
#include "maths.h"
#include "mem.h"
#include "ral.h"
+#include "ral_types.h"
#include "render.h"
// Example setting up a renderer
extern core g_core;
+const custom_vertex vertices[] = {
+ (custom_vertex){ .pos = vec2(-0.5, 0.5), .color = vec3(0.0, 0.0, 1.0) },
+ (custom_vertex){ .pos = vec2(0.5, 0.5), .color = vec3(0.0, 1.0, 0.0) },
+ (custom_vertex){ .pos = vec2(0.0, -0.5), .color = vec3(1.0, 0.0, 0.0) },
+};
+_Static_assert(sizeof(vertices) == (5 * 3 * sizeof(float)), "");
+
int main() {
core_bringup();
arena scratch = arena_create(malloc(1024 * 1024), 1024 * 1024);
@@ -47,12 +56,19 @@ int main() {
};
gpu_pipeline* gfx_pipeline = gpu_graphics_pipeline_create(pipeline_description);
+ buffer_handle triangle_vert_buf = gpu_buffer_create(
+ 3 * sizeof(custom_vertex), CEL_BUFFER_VERTEX, CEL_BUFFER_FLAG_GPU,
+ vertices); // gpu_buffer_create(3 * sizeof(custom_vertex), CEL_BUFFER_VERTEX);
+ /* buffer_upload_bytes(triangle_vert_buf, (bytebuffer){ .buf = vertices, .size = sizeof(vertices)
+ * }, */
+ /* 0, sizeof(vertices)); */
+
// Main loop
while (!should_exit(&g_core)) {
glfwPollEvents();
input_update(&g_core.input);
- render_frame_begin(&g_core.renderer);
+ // render_frame_begin(&g_core.renderer);
static f64 x = 0.0;
x += 0.01;
@@ -68,7 +84,8 @@ int main() {
encode_set_default_settings(enc);
// Record draw calls
- gpu_temp_draw();
+ encode_set_vertex_buffer(enc, triangle_vert_buf);
+ gpu_temp_draw(3);
// End recording
gpu_cmd_encoder_end_render(enc);
@@ -78,7 +95,7 @@ int main() {
// Submit
gpu_backend_end_frame();
- render_frame_end(&g_core.renderer);
+ // render_frame_end(&g_core.renderer);
// glfwSwapBuffers(core->renderer.window);
}
diff --git a/src/core.c b/src/core.c
index 26e7613..84c9cae 100644
--- a/src/core.c
+++ b/src/core.c
@@ -59,9 +59,7 @@ void core_bringup() {
#include <glfw3.h>
/* bool should_window_close(core* core) { glfwWindowShouldClose(core->renderer.window); } */
-void core_input_update() {
- input_update(&g_core.input);
-}
+void core_input_update() { input_update(&g_core.input); }
void core_frame_begin(core* core) { render_frame_begin(&core->renderer); }
void core_frame_end(core* core) { render_frame_end(&core->renderer); }
@@ -76,7 +74,8 @@ bool should_exit() {
}
void frame_begin() {
- glfwPollEvents();
- render_frame_begin(&g_core.renderer); }
+ glfwPollEvents();
+ render_frame_begin(&g_core.renderer);
+}
void frame_draw() {}
void frame_end() { render_frame_end(&g_core.renderer); }
diff --git a/src/core.h b/src/core.h
index db711d0..1031868 100644
--- a/src/core.h
+++ b/src/core.h
@@ -1,8 +1,8 @@
#pragma once
#include "input.h"
-#include "screenspace.h"
#include "scene.h"
+#include "screenspace.h"
#include "terrain.h"
#include "text.h"
// #include "threadpool.h"
diff --git a/src/maths/maths.h b/src/maths/maths.h
index 88a5215..217f2e0 100644
--- a/src/maths/maths.h
+++ b/src/maths/maths.h
@@ -21,7 +21,7 @@
// Dimension 3
static inline vec3 vec3_create(f32 x, f32 y, f32 z) { return (vec3){ x, y, z }; }
-#define vec3(x, y, z) (vec3_create(x, y, z))
+#define vec3(x, y, z) ((vec3){ x, y, z })
static inline vec3 vec3_add(vec3 a, vec3 b) { return (vec3){ a.x + b.x, a.y + b.y, a.z + b.z }; }
static inline vec3 vec3_sub(vec3 a, vec3 b) { return (vec3){ a.x - b.x, a.y - b.y, a.z - b.z }; }
static inline vec3 vec3_mult(vec3 a, f32 s) { return (vec3){ a.x * s, a.y * s, a.z * s }; }
@@ -53,6 +53,7 @@ static inline void print_vec3(vec3 v) { printf("{ x: %f, y: %f, z: %f )\n", v.x,
// TODO: Dimension 2
static inline vec2 vec2_create(f32 x, f32 y) { return (vec2){ x, y }; }
+#define vec2(x, y) ((vec2){ x, y })
static inline vec2 vec2_div(vec2 a, f32 s) { return (vec2){ a.x / s, a.y / s }; }
// TODO: Dimension 4
@@ -320,4 +321,4 @@ static inline mat4 transform_to_mat(transform *tf) {
_Static_assert(alignof(vec3) == 4, "vec3 is 4 byte aligned");
_Static_assert(sizeof(vec3) == 12, "vec3 is 12 bytes so has no padding");
-_Static_assert(alignof(vec4) == 4, "vec4 is 4 byte aligned"); \ No newline at end of file
+_Static_assert(alignof(vec4) == 4, "vec4 is 4 byte aligned");
diff --git a/src/renderer/backends/backend_vulkan.c b/src/renderer/backends/backend_vulkan.c
index 5390f1f..e30d3c1 100644
--- a/src/renderer/backends/backend_vulkan.c
+++ b/src/renderer/backends/backend_vulkan.c
@@ -1,5 +1,6 @@
#include <assert.h>
#include <glfw3.h>
+#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -8,8 +9,10 @@
#include <vulkan/vulkan_core.h>
#include "backend_vulkan.h"
+#include "buf.h"
#include "maths_types.h"
#include "mem.h"
+#include "ral_types.h"
#include "str.h"
#include "vulkan_helpers.h"
@@ -54,6 +57,10 @@ typedef struct vulkan_context {
bool is_resizing;
GLFWwindow* window;
+ // Storage
+ gpu_buffer buffers[1024];
+ size_t buffer_count;
+
VkDebugUtilsMessengerEXT vk_debugger;
} vulkan_context;
@@ -366,17 +373,31 @@ gpu_pipeline* gpu_graphics_pipeline_create(struct graphics_pipeline_desc descrip
VkPipelineShaderStageCreateInfo shader_stages[2] = { vert_shader_stage_info,
frag_shader_stage_info };
- // Vertex Input
-
// TODO: Attributes
+ VkVertexInputAttributeDescription attribute_descs[2];
+ attribute_descs[0].binding = 0;
+ attribute_descs[0].location = 0;
+ attribute_descs[0].format = VK_FORMAT_R32G32_SFLOAT;
+ attribute_descs[0].offset = offsetof(custom_vertex, pos);
+
+ attribute_descs[1].binding = 0;
+ attribute_descs[1].location = 1;
+ attribute_descs[1].format = VK_FORMAT_R32G32B32_SFLOAT;
+ attribute_descs[1].offset = offsetof(custom_vertex, color);
+
+ // Vertex input
+ VkVertexInputBindingDescription binding_desc;
+ binding_desc.binding = 0;
+ binding_desc.stride = sizeof(custom_vertex);
+ binding_desc.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
VkPipelineVertexInputStateCreateInfo vertex_input_info = {
VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO
};
- vertex_input_info.vertexBindingDescriptionCount = 0;
- vertex_input_info.pVertexBindingDescriptions = NULL;
- vertex_input_info.vertexAttributeDescriptionCount = 0;
- vertex_input_info.pVertexAttributeDescriptions = NULL;
+ vertex_input_info.vertexBindingDescriptionCount = 1;
+ vertex_input_info.pVertexBindingDescriptions = &binding_desc;
+ vertex_input_info.vertexAttributeDescriptionCount = 2;
+ vertex_input_info.pVertexAttributeDescriptions = attribute_descs;
// Input Assembly
VkPipelineInputAssemblyStateCreateInfo input_assembly = {
@@ -633,6 +654,10 @@ gpu_cmd_encoder gpu_cmd_encoder_create() {
return encoder;
}
+void gpu_cmd_encoder_destroy(gpu_cmd_encoder* encoder) {
+ vkFreeCommandBuffers(context.device->logical_device, context.device->pool, 1,
+ &encoder->cmd_buffer);
+}
void gpu_cmd_encoder_begin(gpu_cmd_encoder encoder) {
VkCommandBufferBeginInfo begin_info = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO };
@@ -674,6 +699,12 @@ gpu_cmd_buffer gpu_cmd_encoder_finish(gpu_cmd_encoder* encoder) {
void encode_bind_pipeline(gpu_cmd_encoder* encoder, pipeline_kind kind, gpu_pipeline* pipeline) {
vkCmdBindPipeline(encoder->cmd_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline->handle);
}
+void encode_set_vertex_buffer(gpu_cmd_encoder* encoder, buffer_handle buf) {
+ gpu_buffer buffer = context.buffers[buf.raw];
+ VkBuffer vbs[] = { buffer.handle };
+ VkDeviceSize offsets[] = { 0 };
+ vkCmdBindVertexBuffers(encoder->cmd_buffer, 0, 1, vbs, offsets);
+}
// TEMP
void encode_set_default_settings(gpu_cmd_encoder* encoder) {
@@ -720,9 +751,9 @@ bool gpu_backend_begin_frame() {
return true;
}
-void gpu_temp_draw() {
+void gpu_temp_draw(size_t n_verts) {
gpu_cmd_encoder* encoder = gpu_get_default_cmd_encoder(); // &context.main_cmd_buf;
- vkCmdDraw(encoder->cmd_buffer, 3, 1, 0, 0);
+ vkCmdDraw(encoder->cmd_buffer, n_verts, 1, 0, 0);
}
void gpu_backend_end_frame() {
@@ -971,3 +1002,126 @@ void create_sync_objects() {
&context.in_flight_fences[i]));
}
}
+
+static i32 find_memory_index(u32 type_filter, u32 property_flags) {
+ VkPhysicalDeviceMemoryProperties memory_properties;
+ vkGetPhysicalDeviceMemoryProperties(context.device->physical_device, &memory_properties);
+
+ for (u32 i = 0; i < memory_properties.memoryTypeCount; ++i) {
+ // Check each memory type to see if its bit is set to 1.
+ if (type_filter & (1 << i) &&
+ (memory_properties.memoryTypes[i].propertyFlags & property_flags) == property_flags) {
+ return i;
+ }
+ }
+
+ WARN("Unable to find suitable memory type!");
+ return -1;
+}
+
+buffer_handle gpu_buffer_create(u64 size, gpu_buffer_type buf_type, gpu_buffer_flags flags,
+ const void* data) {
+ VkBufferCreateInfo buffer_info = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
+ buffer_info.size = size;
+ buffer_info.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
+
+ switch (buf_type) {
+ case CEL_BUFFER_DEFAULT:
+ buffer_info.usage |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
+ break;
+ case CEL_BUFFER_VERTEX:
+ buffer_info.usage |= VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
+ break;
+ case CEL_BUFFER_COUNT:
+ WARN("Incorrect gpu_buffer_type provided. using default");
+ break;
+ }
+
+ buffer_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+
+ // "allocating" the cpu-side buffer struct
+ gpu_buffer buffer;
+ buffer.size = size;
+ buffer_handle handle = { .raw = (u32)context.buffer_count };
+
+ VK_CHECK(vkCreateBuffer(context.device->logical_device, &buffer_info, context.allocator,
+ &buffer.handle));
+
+ VkMemoryRequirements requirements;
+ vkGetBufferMemoryRequirements(context.device->logical_device, buffer.handle, &requirements);
+
+ // Just make them always need all of them for now
+ i32 memory_index =
+ find_memory_index(requirements.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
+ VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
+ VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
+
+ // Allocate the actual VRAM
+ VkMemoryAllocateInfo allocate_info = { VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO };
+ allocate_info.allocationSize = requirements.size;
+ allocate_info.memoryTypeIndex = (u32)memory_index;
+
+ vkAllocateMemory(context.device->logical_device, &allocate_info, context.allocator,
+ &buffer.memory);
+ vkBindBufferMemory(context.device->logical_device, buffer.handle, buffer.memory, 0);
+
+ /* Now there are two options:
+ * 1. create CPU-accessible memory -> map memory -> memcpy -> unmap
+ * 2. use a staging buffer thats CPU-accessible and copy its contents to a
+ * GPU-only buffer
+ */
+
+ context.buffers[context.buffer_count] = buffer;
+ context.buffer_count++;
+
+ if (data) {
+ if (flags & CEL_BUFFER_FLAG_CPU) {
+ buffer_upload_bytes(handle, (bytebuffer){ .buf = (u8*)data, .size = size }, 0, size);
+ } else if (flags & CEL_BUFFER_FLAG_GPU) {
+ TRACE("Uploading data to buffer using staging buffer");
+ buffer_handle staging =
+ gpu_buffer_create(size, CEL_BUFFER_DEFAULT, CEL_BUFFER_FLAG_CPU, data);
+ gpu_cmd_encoder temp_encoder = gpu_cmd_encoder_create();
+ gpu_cmd_encoder_begin(temp_encoder);
+ encode_buffer_copy(&temp_encoder, handle, 0, staging, 0, size);
+ gpu_cmd_buffer copy_cmd_buffer = gpu_cmd_encoder_finish(&temp_encoder);
+
+ VkSubmitInfo submit_info = { VK_STRUCTURE_TYPE_SUBMIT_INFO };
+ submit_info.commandBufferCount = 1;
+ submit_info.pCommandBuffers = &temp_encoder.cmd_buffer;
+ vkQueueSubmit(context.device->graphics_queue, 1, &submit_info, VK_NULL_HANDLE);
+
+ vkQueueWaitIdle(context.device->graphics_queue);
+ gpu_cmd_encoder_destroy(&temp_encoder);
+ gpu_buffer_destroy(staging);
+ }
+ }
+
+ return handle;
+}
+
+void gpu_buffer_destroy(buffer_handle buffer) {
+ gpu_buffer b = context.buffers[buffer.raw];
+ vkDestroyBuffer(context.device->logical_device, b.handle, context.allocator);
+ vkFreeMemory(context.device->logical_device, b.memory, context.allocator);
+}
+
+// Upload data to a
+void buffer_upload_bytes(buffer_handle gpu_buf, bytebuffer cpu_buf, u64 offset, u64 size) {
+ gpu_buffer buffer = context.buffers[gpu_buf.raw];
+ void* data_ptr;
+ vkMapMemory(context.device->logical_device, buffer.memory, 0, size, 0, &data_ptr);
+ memcpy(data_ptr, cpu_buf.buf, size);
+ vkUnmapMemory(context.device->logical_device, buffer.memory);
+}
+
+void encode_buffer_copy(gpu_cmd_encoder* encoder, buffer_handle src, u64 src_offset,
+ buffer_handle dst, u64 dst_offset, u64 copy_size) {
+ VkBufferCopy copy_region;
+ copy_region.srcOffset = src_offset;
+ copy_region.dstOffset = dst_offset;
+ copy_region.size = copy_size;
+
+ vkCmdCopyBuffer(encoder->cmd_buffer, context.buffers[src.raw].handle,
+ context.buffers[dst.raw].handle, 1, &copy_region);
+}
diff --git a/src/renderer/backends/backend_vulkan.h b/src/renderer/backends/backend_vulkan.h
index 330ba18..0b0a492 100644
--- a/src/renderer/backends/backend_vulkan.h
+++ b/src/renderer/backends/backend_vulkan.h
@@ -75,4 +75,10 @@ typedef struct gpu_cmd_encoder {
typedef struct gpu_cmd_buffer {
VkCommandBuffer cmd_buffer;
-} gpu_cmd_buffer; \ No newline at end of file
+} gpu_cmd_buffer;
+
+typedef struct gpu_buffer {
+ VkBuffer handle;
+ VkDeviceMemory memory;
+ u64 size;
+} gpu_buffer;
diff --git a/src/renderer/ral.h b/src/renderer/ral.h
index ec9793e..2fb0166 100644
--- a/src/renderer/ral.h
+++ b/src/renderer/ral.h
@@ -28,6 +28,7 @@ typedef struct gpu_pipeline gpu_pipeline;
typedef struct gpu_renderpass gpu_renderpass;
typedef struct gpu_cmd_encoder gpu_cmd_encoder; // Recording
typedef struct gpu_cmd_buffer gpu_cmd_buffer; // Ready for submission
+typedef struct gpu_buffer gpu_buffer;
/** @brief A*/
// typedef struct gpu_bind_group
@@ -85,6 +86,7 @@ bool gpu_swapchain_create(gpu_swapchain* out_swapchain);
void gpu_swapchain_destroy(gpu_swapchain* swapchain);
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);
void gpu_cmd_encoder_end_render(gpu_cmd_encoder* encoder);
@@ -117,7 +119,8 @@ gpu_cmd_buffer gpu_cmd_encoder_finish(gpu_cmd_encoder* encoder);
void gpu_queue_submit(gpu_cmd_buffer* buffer);
// Buffers
-void gpu_buffer_create(u64 size);
+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();
void gpu_buffer_bind(buffer_handle buffer);
@@ -137,4 +140,4 @@ bytebuffer vertices_as_bytebuffer(arena* a, vertex_format format, vertex_darray*
// TEMP
-void gpu_temp_draw();
+void gpu_temp_draw(size_t n_verts);
diff --git a/src/renderer/ral_types.h b/src/renderer/ral_types.h
index ae54b53..7dd254e 100644
--- a/src/renderer/ral_types.h
+++ b/src/renderer/ral_types.h
@@ -55,6 +55,20 @@ typedef struct texture_desc {
u32x2 extents;
} texture_desc;
+typedef enum gpu_buffer_type {
+ CEL_BUFFER_DEFAULT, // on Vulkan this would be a storage buffer?
+ CEL_BUFFER_VERTEX,
+ CEL_BUFFER_COUNT
+} gpu_buffer_type;
+
+typedef enum gpu_buffer_flag {
+ CEL_BUFFER_FLAG_CPU = 1 << 0,
+ CEL_BUFFER_FLAG_GPU = 1 << 1,
+ CEL_BUFFER_FLAG_STORAGE = 1 << 2,
+ CEL_BUFFER_FLAG_COUNT
+} gpu_buffer_flag;
+typedef u32 gpu_buffer_flags;
+
typedef enum vertex_format {
VERTEX_STATIC_3D,
VERTEX_SPRITE,
@@ -99,6 +113,12 @@ KITC_DECL_TYPED_ARRAY(u32)
#define TYPED_VERTEX_ARRAY
#endif
+// TEMP
+typedef struct custom_vertex {
+ vec2 pos;
+ vec3 color;
+} custom_vertex;
+
typedef enum gpu_cull_mode { CULL_BACK_FACE, CULL_FRONT_FACE, CULL_COUNT } gpu_cull_mode;
// ? How to tie together materials and shaders
@@ -110,4 +130,4 @@ typedef enum gpu_cull_mode { CULL_BACK_FACE, CULL_FRONT_FACE, CULL_COUNT } gpu_c
// 3 - you don't need to know how the renderer works at all
// 2 - you need to know how the overall renderer is designed
-// 1 - you need to understand graphics API specifics \ No newline at end of file
+// 1 - you need to understand graphics API specifics
diff --git a/src/renderer/render.c b/src/renderer/render.c
index 10589e5..9f5b21a 100644
--- a/src/renderer/render.c
+++ b/src/renderer/render.c
@@ -55,7 +55,7 @@ bool renderer_init(renderer* ren) {
// default_material_init();
// Create default rendering pipeline
- default_pipelines_init(ren);
+ /* default_pipelines_init(ren); */
return true;
}
@@ -67,9 +67,6 @@ void renderer_shutdown(renderer* ren) {
void default_pipelines_init(renderer* ren) {
// Static opaque geometry
- // graphics_pipeline_desc gfx = {
- // };
- // ren->static_opaque_pipeline = gpu_graphics_pipeline_create();
arena scratch = arena_create(malloc(1024 * 1024), 1024 * 1024);
gpu_renderpass_desc pass_description = {};
@@ -77,8 +74,8 @@ void default_pipelines_init(renderer* ren) {
ren->default_renderpass = *renderpass;
- str8 vert_path = str8lit("celeritas-core/build/linux/x86_64/debug/triangle.vert.spv");
- str8 frag_path = str8lit("celeritas-core/build/linux/x86_64/debug/triangle.frag.spv");
+ str8 vert_path = str8lit("build/linux/x86_64/debug/triangle.vert.spv");
+ str8 frag_path = str8lit("build/linux/x86_64/debug/triangle.frag.spv");
str8_opt vertex_shader = str8_from_file(&scratch, vert_path);
str8_opt fragment_shader = str8_from_file(&scratch, frag_path);
if (!vertex_shader.has_value || !fragment_shader.has_value) {
@@ -104,28 +101,28 @@ void default_pipelines_init(renderer* ren) {
}
void render_frame_begin(renderer* ren) {
- ren->frame_aborted = false;
- if (!gpu_backend_begin_frame()) {
- ren->frame_aborted = true;
- return;
- }
- gpu_cmd_encoder* enc = gpu_get_default_cmd_encoder();
- // begin recording
- gpu_cmd_encoder_begin(*enc);
- gpu_cmd_encoder_begin_render(enc, &ren->default_renderpass);
- encode_bind_pipeline(enc, PIPELINE_GRAPHICS, &ren->static_opaque_pipeline);
- encode_set_default_settings(enc);
+ ren->frame_aborted = false;
+ if (!gpu_backend_begin_frame()) {
+ ren->frame_aborted = true;
+ return;
+ }
+ gpu_cmd_encoder* enc = gpu_get_default_cmd_encoder();
+ // begin recording
+ gpu_cmd_encoder_begin(*enc);
+ gpu_cmd_encoder_begin_render(enc, &ren->default_renderpass);
+ encode_bind_pipeline(enc, PIPELINE_GRAPHICS, &ren->static_opaque_pipeline);
+ encode_set_default_settings(enc);
}
void render_frame_end(renderer* ren) {
if (ren->frame_aborted) {
return;
}
- gpu_temp_draw();
- gpu_cmd_encoder* enc = gpu_get_default_cmd_encoder();
- gpu_cmd_encoder_end_render(enc);
- gpu_cmd_buffer buf = gpu_cmd_encoder_finish(enc);
- gpu_queue_submit(&buf);
- gpu_backend_end_frame();
+ gpu_temp_draw(3);
+ gpu_cmd_encoder* enc = gpu_get_default_cmd_encoder();
+ gpu_cmd_encoder_end_render(enc);
+ gpu_cmd_buffer buf = gpu_cmd_encoder_finish(enc);
+ gpu_queue_submit(&buf);
+ gpu_backend_end_frame();
}
void render_frame_draw(renderer* ren) {}
diff --git a/src/scene.h b/src/scene.h
index 5399ab7..24429b3 100644
--- a/src/scene.h
+++ b/src/scene.h
@@ -11,8 +11,8 @@
#pragma once
#include "camera.h"
#include "defines.h"
-#include "render_types.h"
#include "maths_types.h"
+#include "render_types.h"
typedef struct scene {
// camera