diff --git a/src/graphics/device.hpp b/src/graphics/device.hpp index 466a3c4..e292d7f 100644 --- a/src/graphics/device.hpp +++ b/src/graphics/device.hpp @@ -16,6 +16,7 @@ const std::vector VALIDATION_LAYERS = { const std::vector DEVICE_EXTENSIONS = { VK_KHR_SWAPCHAIN_EXTENSION_NAME, VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME, + VK_EXT_DYNAMIC_RENDERING_UNUSED_ATTACHMENTS_EXTENSION_NAME, }; typedef struct GraphicsDevice { diff --git a/src/graphics/pipeline.cpp b/src/graphics/pipeline.cpp index 4318436..16b24aa 100644 --- a/src/graphics/pipeline.cpp +++ b/src/graphics/pipeline.cpp @@ -94,6 +94,18 @@ Pipeline* pipeline_create(GraphicsDevice* device, SwapChain* swap, Shader* shade pipeline->ColorBlending.blendConstants[2] = 0.0f; // Optional pipeline->ColorBlending.blendConstants[3] = 0.0f; // pipeline->Optional + pipeline->DepthState.sType + = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; + pipeline->DepthState.depthTestEnable = VK_TRUE; + pipeline->DepthState.depthWriteEnable = VK_TRUE; + pipeline->DepthState.depthCompareOp = VK_COMPARE_OP_LESS; + pipeline->DepthState.depthBoundsTestEnable = VK_FALSE; + pipeline->DepthState.minDepthBounds = 0.0f; + pipeline->DepthState.maxDepthBounds = 1.0f; + pipeline->DepthState.stencilTestEnable = VK_FALSE; + pipeline->DepthState.front = {}; + pipeline->DepthState.back = {}; + VkPipelineLayoutCreateInfo pipelineLayoutInfo {}; pipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; pipelineLayoutInfo.setLayoutCount = descriptorSetLayoutCount; @@ -135,6 +147,7 @@ Pipeline* pipeline_create(GraphicsDevice* device, SwapChain* swap, Shader* shade pipelineInfo.pMultisampleState = &pipeline->Multisampling; pipelineInfo.pColorBlendState = &pipeline->ColorBlending; pipelineInfo.pDynamicState = &pipeline->DynamicStates; + pipelineInfo.pDepthStencilState = &pipeline->DepthState; pipelineInfo.layout = pipeline->Layout; pipelineInfo.subpass = 0; pipelineInfo.basePipelineHandle = VK_NULL_HANDLE; // Optional diff --git a/src/graphics/pipeline.hpp b/src/graphics/pipeline.hpp index 1f32a3d..e6132c2 100644 --- a/src/graphics/pipeline.hpp +++ b/src/graphics/pipeline.hpp @@ -25,6 +25,7 @@ typedef struct Pipeline { VkPipelineMultisampleStateCreateInfo Multisampling; VkPipelineColorBlendAttachmentState ColorBlendAttachment; VkPipelineColorBlendStateCreateInfo ColorBlending; + VkPipelineDepthStencilStateCreateInfo DepthState; } Pipeline; Pipeline* pipeline_create(GraphicsDevice* device, SwapChain* swap, Shader* shader, diff --git a/src/graphics/swapchain.cpp b/src/graphics/swapchain.cpp index 9d80421..73453a2 100644 --- a/src/graphics/swapchain.cpp +++ b/src/graphics/swapchain.cpp @@ -128,9 +128,11 @@ VkFormat find_format(GraphicsDevice* device, const std::vector& candid VkFormat find_depth_format(GraphicsDevice* device) { - return find_format(device, { VK_FORMAT_D32_SFLOAT, VK_FORMAT_D32_SFLOAT_S8_UINT, - VK_FORMAT_D24_UNORM_S8_UINT }, - VK_IMAGE_TILING_OPTIMAL, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT); + // depth and stencil format + return VK_FORMAT_D32_SFLOAT_S8_UINT; + // return find_format(device, { VK_FORMAT_D, VK_FORMAT_D32_SFLOAT_S8_UINT, + // VK_FORMAT_D24_UNORM_S8_UINT }, + // VK_IMAGE_TILING_OPTIMAL, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT); } VkSurfaceFormatKHR device_choose_swap_surface_format( diff --git a/src/graphics/vkrenderer.cpp b/src/graphics/vkrenderer.cpp index 53c3dbd..9b67f62 100644 --- a/src/graphics/vkrenderer.cpp +++ b/src/graphics/vkrenderer.cpp @@ -112,7 +112,7 @@ void renderer_record_command_buffer(Renderer* renderer, uint32_t imageIndex) &imageMemoryBarrier); VkClearValue clearColor = { { { 0.0f, 0.0f, 0.0f, 1.0f } } }; - VkRenderingAttachmentInfoKHR attachmentInfo {}; + VkRenderingAttachmentInfo attachmentInfo {}; attachmentInfo.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR; attachmentInfo.imageView = renderer->Swap->ImageViews[imageIndex]; attachmentInfo.imageLayout = VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL_KHR; @@ -120,17 +120,19 @@ void renderer_record_command_buffer(Renderer* renderer, uint32_t imageIndex) attachmentInfo.storeOp = VK_ATTACHMENT_STORE_OP_STORE; attachmentInfo.clearValue = clearColor; - VkRenderingAttachmentInfoKHR depthAttachmentInfo; + VkRenderingAttachmentInfo depthAttachmentInfo; depthAttachmentInfo.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR; depthAttachmentInfo.imageView = renderer->Swap->DepthImageView; depthAttachmentInfo.imageLayout = VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL_KHR; depthAttachmentInfo.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; depthAttachmentInfo.storeOp = VK_ATTACHMENT_STORE_OP_STORE; depthAttachmentInfo.clearValue.depthStencil = { 1.0f, 0 }; + depthAttachmentInfo.resolveMode = VK_RESOLVE_MODE_NONE; depthAttachmentInfo.resolveImageView = VK_NULL_HANDLE; depthAttachmentInfo.resolveImageLayout = VK_IMAGE_LAYOUT_GENERAL; + depthAttachmentInfo.pNext = VK_NULL_HANDLE; - VkRenderingInfoKHR renderingInfo {}; + VkRenderingInfo renderingInfo {}; renderingInfo.sType = VK_STRUCTURE_TYPE_RENDERING_INFO_KHR; renderingInfo.renderArea = { 0, 0, renderer->Swap->Extent.width, renderer->Swap->Extent.height }; diff --git a/src/inferno.cpp b/src/inferno.cpp index a05e4ab..223e3a1 100644 --- a/src/inferno.cpp +++ b/src/inferno.cpp @@ -307,6 +307,7 @@ int inferno_run(InfernoApp* app) inferno_timer_get_time(app->MainTimer).count()); inferno_move_input(app, inferno_timer_get_time(app->MainTimer)); + exit(0); // // Menu Bar // static bool showPreview = true;