Add support for rendering into 3d textures on Vulkan

#136
This commit is contained in:
Wojtek Figat
2021-05-18 11:40:38 +02:00
parent 5a7efe9019
commit 9cba6bad6d
10 changed files with 89 additions and 102 deletions

View File

@@ -346,7 +346,6 @@ void GPUContextVulkan::BeginRenderPass()
{
layout.RTVsFormats[i] = handle->GetFormat();
framebufferKey.Attachments[i] = handle->GetFramebufferView();
AddImageBarrier(handle, handle->LayoutRTV);
}
else
@@ -355,36 +354,31 @@ void GPUContextVulkan::BeginRenderPass()
framebufferKey.Attachments[i] = VK_NULL_HANDLE;
}
}
GPUTextureViewVulkan* handle;
if (_rtDepth)
{
auto handle = _rtDepth;
layout.MSAA = handle->GetMSAA();
layout.Extent = handle->Extent;
handle = _rtDepth;
layout.ReadDepth = true; // TODO: use proper depthStencilAccess flags
layout.WriteDepth = handle->LayoutRTV == VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; // TODO: do it in a proper way
framebufferKey.AttachmentCount++;
framebufferKey.Attachments[_rtCount] = handle->GetFramebufferView();
AddImageBarrier(handle, handle->LayoutRTV);
}
else if (_rtHandles[0])
{
layout.MSAA = _rtHandles[0]->GetMSAA();
layout.Extent = _rtHandles[0]->Extent;
layout.ReadDepth = false;
layout.WriteDepth = false;
}
else
{
// No depth or render target binded?
CRASH;
handle = _rtHandles[0];
layout.ReadDepth = false;
layout.WriteDepth = false;
}
layout.MSAA = handle->GetMSAA();
layout.Extent.width = handle->Extent.width;
layout.Extent.height = handle->Extent.height;
layout.Layers = handle->Layers;
// Get or create objects
auto renderPass = _device->GetOrCreateRenderPass(layout);
framebufferKey.RenderPass = renderPass;
uint32 layers = 1; // TODO: support rendering to many layers (eg. texture array)
auto framebuffer = _device->GetOrCreateFramebuffer(framebufferKey, layout.Extent, layers);
auto framebuffer = _device->GetOrCreateFramebuffer(framebufferKey, layout.Extent, layout.Layers);
_renderPass = renderPass;
FlushBarriers();
@@ -519,7 +513,7 @@ void GPUContextVulkan::UpdateDescriptorSets(const SpirvShaderDescriptorInfo& des
}
default:
// Unknown or invalid descriptor type
CRASH;
CRASH;
break;
}
}