Skip to content

Commit

Permalink
Go Vulkan 1.3 for now and implement render passes
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Feb 4, 2025
1 parent 3de8f20 commit 2488379
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 9 deletions.
62 changes: 59 additions & 3 deletions Backends/Graphics5/Vulkan/Sources/kope/vulkan/commandlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,66 @@ void kope_vulkan_command_list_destroy(kope_g5_command_list *list) {
vkFreeCommandBuffers(list->vulkan.device, list->vulkan.command_pool, 1, &list->vulkan.command_buffer);
}

void kope_vulkan_command_list_begin_render_pass(kope_g5_command_list *list, const kope_g5_render_pass_parameters *parameters) {}
void kope_vulkan_command_list_begin_render_pass(kope_g5_command_list *list, const kope_g5_render_pass_parameters *parameters) {
const kope_g5_texture *texture = parameters->color_attachments[0].texture.texture;

const VkClearValue clear_value = {
.color =
{
.float32 = {0.0f, 0.0f, 0.0f, 1.0f},
},
.depthStencil =
{
.depth = 1.0f,
.stencil = 0,
},
};

void kope_vulkan_command_list_end_render_pass(kope_g5_command_list *list) {}
const VkRenderingAttachmentInfo color_attachment_info = {
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
.pNext = NULL,
.imageView = texture->vulkan.image_view,
.imageLayout = VK_IMAGE_LAYOUT_GENERAL,
.resolveMode = VK_RESOLVE_MODE_NONE,
.resolveImageView = VK_NULL_HANDLE,
.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL,
.loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
.clearValue = clear_value,
};

const VkRect2D render_area = {
.offset =
{
.x = 0,
.y = 0,
},
.extent =
{
.width = texture->vulkan.width,
.height = texture->vulkan.height,
},
};

const VkRenderingInfo rendering_info = {
.sType = VK_STRUCTURE_TYPE_RENDERING_INFO,
.pNext = NULL,
.flags = 0,
.renderArea = render_area,
.layerCount = 1,
.viewMask = 0,
.colorAttachmentCount = 1,
.pColorAttachments = &color_attachment_info,
.pDepthAttachment = VK_NULL_HANDLE,
.pStencilAttachment = VK_NULL_HANDLE,
};

vkCmdBeginRendering(list->vulkan.command_buffer, &rendering_info);
}

void kope_vulkan_command_list_end_render_pass(kope_g5_command_list *list) {
vkCmdEndRendering(list->vulkan.command_buffer);
}

void kope_vulkan_command_list_present(kope_g5_command_list *list) {}

Expand All @@ -32,7 +89,6 @@ void kope_vulkan_command_list_set_vertex_buffer(kope_g5_command_list *list, uint
void kope_vulkan_command_list_set_render_pipeline(kope_g5_command_list *list, kope_vulkan_render_pipeline *pipeline) {}

void kope_vulkan_command_list_draw(kope_g5_command_list *list, uint32_t vertex_count, uint32_t instance_count, uint32_t first_vertex, uint32_t first_instance) {

}

void kope_vulkan_command_list_draw_indexed(kope_g5_command_list *list, uint32_t index_count, uint32_t instance_count, uint32_t first_index, int32_t base_vertex,
Expand Down
6 changes: 1 addition & 5 deletions Backends/Graphics5/Vulkan/Sources/kope/vulkan/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,7 @@ void kope_vulkan_device_create(kope_g5_device *device, const kope_g5_device_wish
.applicationVersion = 0,
.pEngineName = "Kope",
.engineVersion = 0,
#ifdef KINC_VKRT
.apiVersion = VK_API_VERSION_1_2,
#else
.apiVersion = VK_API_VERSION_1_0,
#endif
.apiVersion = VK_API_VERSION_1_3,
};

const VkInstanceCreateInfo instance_create_info = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ extern "C" {
#endif

typedef struct kope_vulkan_texture {
int nothing;
uint32_t width;
uint32_t height;
VkImageView image_view;
} kope_vulkan_texture;

#ifdef __cplusplus
Expand Down

0 comments on commit 2488379

Please sign in to comment.