mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +09:00
[Fix] (MG_Backend/DirectVulkan): uninitialized vars in VkRenderPassManager
This commit is contained in:
@@ -150,22 +150,22 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
|||||||
attachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
attachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Depth attachment description
|
// Depth attachment description
|
||||||
VkAttachmentDescription depthAttachmentDescription;
|
|
||||||
auto& depthAtt = fbo.GetAttachment(FramebufferAttachmentType::Depth);
|
auto& depthAtt = fbo.GetAttachment(FramebufferAttachmentType::Depth);
|
||||||
depthAttachmentDescription.format =
|
VkAttachmentDescription depthAttachmentDescription;
|
||||||
MG_Util::ConvertTextureInternalFormatToVkEnum(depthAtt.GetTexture()->GetFormat());
|
if (depthAtt.IsComplete()) {
|
||||||
depthAttachmentDescription.samples = VK_SAMPLE_COUNT_1_BIT;
|
depthAttachmentDescription.format =
|
||||||
depthAttachmentDescription.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
MG_Util::ConvertTextureInternalFormatToVkEnum(depthAtt.GetTexture()->GetFormat());
|
||||||
depthAttachmentDescription.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
depthAttachmentDescription.samples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
depthAttachmentDescription.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
depthAttachmentDescription.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||||
depthAttachmentDescription.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
depthAttachmentDescription.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||||
depthAttachmentDescription.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
depthAttachmentDescription.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||||
depthAttachmentDescription.finalLayout = isDefaultFbo ?
|
depthAttachmentDescription.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||||
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR :
|
depthAttachmentDescription.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||||
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
depthAttachmentDescription.finalLayout = isDefaultFbo ?
|
||||||
|
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR :
|
||||||
|
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||||
|
}
|
||||||
|
|
||||||
// Depth attachment ref
|
// Depth attachment ref
|
||||||
VkAttachmentReference depthAttachmentRef;
|
VkAttachmentReference depthAttachmentRef;
|
||||||
@@ -174,18 +174,28 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
|||||||
|
|
||||||
// Subpass
|
// Subpass
|
||||||
VkSubpassDescription subpassDesc;
|
VkSubpassDescription subpassDesc;
|
||||||
|
subpassDesc.flags = 0;
|
||||||
subpassDesc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
|
subpassDesc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
|
||||||
|
subpassDesc.inputAttachmentCount = 0;
|
||||||
|
subpassDesc.pInputAttachments = nullptr;
|
||||||
subpassDesc.colorAttachmentCount = colorAttachmentRefs.size();
|
subpassDesc.colorAttachmentCount = colorAttachmentRefs.size();
|
||||||
subpassDesc.pColorAttachments = colorAttachmentRefs.data();
|
subpassDesc.pColorAttachments = colorAttachmentRefs.data();
|
||||||
subpassDesc.pDepthStencilAttachment = &depthAttachmentRef;
|
subpassDesc.pResolveAttachments = nullptr;
|
||||||
|
subpassDesc.pDepthStencilAttachment = depthAtt.IsComplete() ? &depthAttachmentRef : VK_NULL_HANDLE;
|
||||||
|
subpassDesc.preserveAttachmentCount = 0;
|
||||||
|
subpassDesc.pPreserveAttachments = nullptr;
|
||||||
|
|
||||||
// Render Pass
|
// Render Pass
|
||||||
VkRenderPassCreateInfo renderPassCreateInfo;
|
VkRenderPassCreateInfo renderPassCreateInfo;
|
||||||
renderPassCreateInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
renderPassCreateInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
||||||
|
renderPassCreateInfo.pNext = VK_NULL_HANDLE;
|
||||||
|
renderPassCreateInfo.flags = 0;
|
||||||
renderPassCreateInfo.attachmentCount = colorAttachmentDescriptions.size();
|
renderPassCreateInfo.attachmentCount = colorAttachmentDescriptions.size();
|
||||||
renderPassCreateInfo.pAttachments = colorAttachmentDescriptions.data();
|
renderPassCreateInfo.pAttachments = colorAttachmentDescriptions.data();
|
||||||
renderPassCreateInfo.subpassCount = 1;
|
renderPassCreateInfo.subpassCount = 1;
|
||||||
renderPassCreateInfo.pSubpasses = &subpassDesc;
|
renderPassCreateInfo.pSubpasses = &subpassDesc;
|
||||||
|
renderPassCreateInfo.dependencyCount = 0;
|
||||||
|
renderPassCreateInfo.pDependencies = nullptr;
|
||||||
|
|
||||||
VkRenderPass renderPass = VK_NULL_HANDLE;
|
VkRenderPass renderPass = VK_NULL_HANDLE;
|
||||||
VK_VERIFY(vkCreateRenderPass(m_device, &renderPassCreateInfo, nullptr, &renderPass));
|
VK_VERIFY(vkCreateRenderPass(m_device, &renderPassCreateInfo, nullptr, &renderPass));
|
||||||
@@ -198,11 +208,14 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
|||||||
// Framebuffer
|
// Framebuffer
|
||||||
VkFramebufferCreateInfo framebufferCreateInfo;
|
VkFramebufferCreateInfo framebufferCreateInfo;
|
||||||
framebufferCreateInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
|
framebufferCreateInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
|
||||||
|
framebufferCreateInfo.pNext = nullptr;
|
||||||
|
framebufferCreateInfo.flags = 0;
|
||||||
framebufferCreateInfo.renderPass = renderPass;
|
framebufferCreateInfo.renderPass = renderPass;
|
||||||
framebufferCreateInfo.attachmentCount = attachmentViews.size();
|
framebufferCreateInfo.attachmentCount = attachmentViews.size();
|
||||||
framebufferCreateInfo.pAttachments = attachmentViews.data();
|
framebufferCreateInfo.pAttachments = attachmentViews.data();
|
||||||
framebufferCreateInfo.width = width;
|
framebufferCreateInfo.width = width;
|
||||||
framebufferCreateInfo.height = height;
|
framebufferCreateInfo.height = height;
|
||||||
|
framebufferCreateInfo.layers = 1;
|
||||||
VkFramebuffer framebuffer = VK_NULL_HANDLE;
|
VkFramebuffer framebuffer = VK_NULL_HANDLE;
|
||||||
VK_VERIFY(vkCreateFramebuffer(m_device, &framebufferCreateInfo, nullptr, &framebuffer));
|
VK_VERIFY(vkCreateFramebuffer(m_device, &framebufferCreateInfo, nullptr, &framebuffer));
|
||||||
IntVec2 extent = {width, height};
|
IntVec2 extent = {width, height};
|
||||||
@@ -217,6 +230,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
|||||||
m_activeRenderPass = &renderPassEntry;
|
m_activeRenderPass = &renderPassEntry;
|
||||||
VkRenderPassBeginInfo renderPassBeginInfo;
|
VkRenderPassBeginInfo renderPassBeginInfo;
|
||||||
renderPassBeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
|
renderPassBeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
|
||||||
|
renderPassBeginInfo.pNext = nullptr;
|
||||||
renderPassBeginInfo.renderPass = m_activeRenderPass->renderPass;
|
renderPassBeginInfo.renderPass = m_activeRenderPass->renderPass;
|
||||||
renderPassBeginInfo.framebuffer = m_activeRenderPass->framebuffer;
|
renderPassBeginInfo.framebuffer = m_activeRenderPass->framebuffer;
|
||||||
renderPassBeginInfo.renderArea.offset = { 0, 0 };
|
renderPassBeginInfo.renderArea.offset = { 0, 0 };
|
||||||
@@ -227,6 +241,10 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
|||||||
VkClearValue clearValue;
|
VkClearValue clearValue;
|
||||||
clearValue.color = { 0.0f, 0.0f, 0.0f, 1.0f };
|
clearValue.color = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||||
clearValue.depthStencil = { 1.0f, 0 };
|
clearValue.depthStencil = { 1.0f, 0 };
|
||||||
|
|
||||||
|
renderPassBeginInfo.clearValueCount = 1;
|
||||||
|
renderPassBeginInfo.pClearValues = &clearValue;
|
||||||
|
|
||||||
vkCmdBeginRenderPass(commandBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
|
vkCmdBeginRenderPass(commandBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user