| 253 | } |
| 254 | |
| 255 | VulkanFramebuffer* VkRenderBuffers::GetOutput(VkPPRenderPassSetup* passSetup, const PPOutput& output, WhichDepthStencil stencilTest, int& framebufferWidth, int& framebufferHeight) |
| 256 | { |
| 257 | VkTextureImage* tex = fb->GetTextureManager()->GetTexture(output.Type, output.Texture); |
| 258 | |
| 259 | VkImageView view; |
| 260 | std::unique_ptr<VulkanFramebuffer>* framebufferptr = nullptr; |
| 261 | int w, h; |
| 262 | if (tex) |
| 263 | { |
| 264 | VkImageTransition imageTransition; |
| 265 | imageTransition.AddImage(tex, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, output.Type == PPTextureType::NextPipelineTexture); |
| 266 | if (stencilTest == WhichDepthStencil::Scene) |
| 267 | imageTransition.AddImage(&fb->GetBuffers()->SceneDepthStencil, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, false); |
| 268 | |
| 269 | if (stencilTest == WhichDepthStencil::Pipeline) |
| 270 | imageTransition.AddImage(&fb->GetBuffers()->PipelineDepthStencil, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, false); |
| 271 | |
| 272 | imageTransition.Execute(fb->GetCommands()->GetDrawCommands()); |
| 273 | |
| 274 | view = tex->View->view; |
| 275 | w = tex->Image->width; |
| 276 | h = tex->Image->height; |
| 277 | framebufferptr = &tex->PPFramebuffer; |
| 278 | } |
| 279 | else |
| 280 | { |
| 281 | view = fb->GetFramebufferManager()->SwapChain->GetImageView(fb->GetFramebufferManager()->PresentImageIndex)->view; |
| 282 | framebufferptr = &fb->GetFramebufferManager()->Framebuffers[fb->GetFramebufferManager()->PresentImageIndex]; |
| 283 | w = fb->GetFramebufferManager()->SwapChain->Width(); |
| 284 | h = fb->GetFramebufferManager()->SwapChain->Height(); |
| 285 | } |
| 286 | |
| 287 | auto& framebuffer = *framebufferptr; |
| 288 | if (!framebuffer) |
| 289 | { |
| 290 | FramebufferBuilder builder; |
| 291 | builder.RenderPass(passSetup->RenderPass.get()); |
| 292 | builder.Size(w, h); |
| 293 | builder.AddAttachment(view); |
| 294 | if (stencilTest == WhichDepthStencil::Scene) |
| 295 | builder.AddAttachment(fb->GetBuffers()->SceneDepthStencil.View.get()); |
| 296 | if (stencilTest == WhichDepthStencil::Pipeline) |
| 297 | builder.AddAttachment(fb->GetBuffers()->PipelineDepthStencil.View.get()); |
| 298 | builder.DebugName("PPOutputFB"); |
| 299 | framebuffer = builder.Create(fb->device.get()); |
| 300 | } |
| 301 | |
| 302 | framebufferWidth = w; |
| 303 | framebufferHeight = h; |
| 304 | return framebuffer.get(); |
| 305 | } |
no test coverage detected