missed some depth info in the pipeline
This commit is contained in:
@@ -16,6 +16,7 @@ const std::vector<const char*> VALIDATION_LAYERS = {
|
||||
const std::vector<const char*> DEVICE_EXTENSIONS = {
|
||||
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
||||
VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME,
|
||||
VK_EXT_DYNAMIC_RENDERING_UNUSED_ATTACHMENTS_EXTENSION_NAME,
|
||||
};
|
||||
|
||||
typedef struct GraphicsDevice {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -128,9 +128,11 @@ VkFormat find_format(GraphicsDevice* device, const std::vector<VkFormat>& 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(
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user