start cleanup

main
noah metz 2024-01-13 02:48:58 -07:00
parent bf291bd6e1
commit 3a887dc4f8
1 changed files with 60 additions and 0 deletions

@ -152,6 +152,25 @@ typedef struct VulkanContextStruct {
VkDevice device;
Queues queues;
// G Buffer
GPUPage* g_buffer_page;
VkRenderPass g_renderpass;
VkFramebuffer g_framebuffer;
GPUImage g_image_position;
GPUImage g_image_normal;
GPUImage g_image_depth;
VkImageView g_image_view_position;
VkImageView g_image_view_normal;
VkImageView g_image_view_depth;
VkFormat g_image_format_position;
VkFormat g_image_format_normal;
VkFormat g_image_format_depth;
// Present Swapchain
VkSurfaceKHR surface;
SwapchainDetails swapchain_details;
@ -2375,6 +2394,47 @@ VulkanContext* init_vulkan(GLFWwindow* window, uint32_t max_frames_in_flight) {
context->in_flight_fences = if_fences;
}
result = gpu_page_allocate(context->device, context->memories, 1000000, 0xFFFFFFFF, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT, &context->g_buffer_page);
if(result != VK_SUCCESS) {
return 0;
}
VkImageCreateInfo g_pos_info = {
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
.imageType = VK_IMAGE_TYPE_2D,
.extent = {
.width = context->swapchain_extent.width,
.height = context->swapchain_extent.height,
.depth = 1,
},
.mipLevels = 1,
.arrayLayers = 1,
.samples = VK_SAMPLE_COUNT_1_BIT,
.tiling = VK_IMAGE_TILING_OPTIMAL,
};
result = gpu_image_malloc(context->device, context->g_buffer_page, &g_pos_info, &context->g_image_position);
if(result != VK_SUCCESS) {
return 0;
}
VkImageViewCreateInfo g_pos_view_info = {
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
.image = context->g_image_position.handle,
.viewType = VK_IMAGE_VIEW_TYPE_2D,
.format = VK_FORMAT_R16G16B16A16_SFLOAT,
.subresourceRange = {
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
.baseMipLevel = 0,
.levelCount = 1,
.baseArrayLayer = 0,
.layerCount = 1,
},
};
result = vkCreateImageView(context->device, &g_pos_view_info, 0, &context->g_image_view_position);
return context;
}