diff options
| author | iwubcode <iwubcode@users.noreply.github.com> | 2017-08-06 23:05:42 -0500 |
|---|---|---|
| committer | iwubcode <iwubcode@users.noreply.github.com> | 2017-11-17 22:11:29 -0600 |
| commit | 33bc286baaafe31b2b564dd5d5574307cbd9e921 (patch) | |
| tree | 5386d3079307b82abe0b6768d0f84a6618ca2d27 /Source/Core/VideoBackends/Vulkan | |
| parent | 081b92b8a7927fe699c5515cb1c90dcf8fe44179 (diff) | |
Remove old XFB logic
Diffstat (limited to 'Source/Core/VideoBackends/Vulkan')
| -rw-r--r-- | Source/Core/VideoBackends/Vulkan/FramebufferManager.cpp | 89 | ||||
| -rw-r--r-- | Source/Core/VideoBackends/Vulkan/FramebufferManager.h | 25 | ||||
| -rw-r--r-- | Source/Core/VideoBackends/Vulkan/Renderer.cpp | 356 | ||||
| -rw-r--r-- | Source/Core/VideoBackends/Vulkan/Renderer.h | 66 |
4 files changed, 0 insertions, 536 deletions
diff --git a/Source/Core/VideoBackends/Vulkan/FramebufferManager.cpp b/Source/Core/VideoBackends/Vulkan/FramebufferManager.cpp index c23c19b544..305f0343f7 100644 --- a/Source/Core/VideoBackends/Vulkan/FramebufferManager.cpp +++ b/Source/Core/VideoBackends/Vulkan/FramebufferManager.cpp @@ -1377,93 +1377,4 @@ void FramebufferManager::DestroyPokeShaders() } } -std::unique_ptr<XFBSourceBase> FramebufferManager::CreateXFBSource(unsigned int target_width, - unsigned int target_height, - unsigned int layers) -{ - TextureConfig config; - config.width = target_width; - config.height = target_height; - config.layers = layers; - config.rendertarget = true; - auto texture = TextureCache::GetInstance()->CreateTexture(config); - if (!texture) - { - PanicAlert("Failed to create texture for XFB source"); - return nullptr; - } - - return std::make_unique<XFBSource>(std::move(texture)); -} - -void FramebufferManager::CopyToRealXFB(u32 xfb_addr, u32 fb_stride, u32 fb_height, - const EFBRectangle& source_rc, float gamma) -{ - // Pending/batched EFB pokes should be included in the copied image. - FlushEFBPokes(); - - // Schedule early command-buffer execution. - StateTracker::GetInstance()->EndRenderPass(); - StateTracker::GetInstance()->OnReadback(); - - // GPU EFB textures -> Guest memory - u8* xfb_ptr = Memory::GetPointer(xfb_addr); - _assert_(xfb_ptr); - - // source_rc is in native coordinates, so scale it to the internal resolution. - TargetRectangle scaled_rc = g_renderer->ConvertEFBRectangle(source_rc); - VkRect2D scaled_rc_vk = { - {scaled_rc.left, scaled_rc.top}, - {static_cast<u32>(scaled_rc.GetWidth()), static_cast<u32>(scaled_rc.GetHeight())}}; - Texture2D* src_texture = ResolveEFBColorTexture(scaled_rc_vk); - - // The destination stride can differ from the copy region width, in which case the pixels - // outside the copy region should not be written to. - TextureCache::GetInstance()->GetTextureConverter()->EncodeTextureToMemoryYUYV( - xfb_ptr, static_cast<u32>(source_rc.GetWidth()), fb_stride, fb_height, src_texture, - scaled_rc); - - // If we sourced directly from the EFB framebuffer, restore it to a color attachment. - if (src_texture == m_efb_color_texture.get()) - { - src_texture->TransitionToLayout(g_command_buffer_mgr->GetCurrentCommandBuffer(), - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); - } -} - -XFBSource::XFBSource(std::unique_ptr<AbstractTexture> texture) - : XFBSourceBase(), m_texture(std::move(texture)) -{ -} - -XFBSource::~XFBSource() -{ -} - -VKTexture* XFBSource::GetTexture() const -{ - return static_cast<VKTexture*>(m_texture.get()); -} - -void XFBSource::CopyEFB(float gamma) -{ - // Pending/batched EFB pokes should be included in the copied image. - FramebufferManager::GetInstance()->FlushEFBPokes(); - - // Virtual XFB, copy EFB at native resolution to m_texture - MathUtil::Rectangle<int> rect(0, 0, static_cast<int>(texWidth), static_cast<int>(texHeight)); - VkRect2D vk_rect = {{rect.left, rect.top}, - {static_cast<u32>(rect.GetWidth()), static_cast<u32>(rect.GetHeight())}}; - - Texture2D* src_texture = FramebufferManager::GetInstance()->ResolveEFBColorTexture(vk_rect); - static_cast<VKTexture*>(m_texture.get())->CopyRectangleFromTexture(src_texture, rect, rect); - - // If we sourced directly from the EFB framebuffer, restore it to a color attachment. - if (src_texture == FramebufferManager::GetInstance()->GetEFBColorTexture()) - { - src_texture->TransitionToLayout(g_command_buffer_mgr->GetCurrentCommandBuffer(), - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); - } -} - } // namespace Vulkan diff --git a/Source/Core/VideoBackends/Vulkan/FramebufferManager.h b/Source/Core/VideoBackends/Vulkan/FramebufferManager.h index 3f2a251662..0c1a160728 100644 --- a/Source/Core/VideoBackends/Vulkan/FramebufferManager.h +++ b/Source/Core/VideoBackends/Vulkan/FramebufferManager.h @@ -44,14 +44,6 @@ public: VkSampleCountFlagBits GetEFBSamples() const; MultisamplingState GetEFBMultisamplingState() const; - std::unique_ptr<XFBSourceBase> CreateXFBSource(unsigned int target_width, - unsigned int target_height, - unsigned int layers) override; - - // GPU EFB textures -> Guest - void CopyToRealXFB(u32 xfb_addr, u32 fb_stride, u32 fb_height, const EFBRectangle& source_rc, - float gamma = 1.0f) override; - void ResizeEFBTextures(); // Recompile shaders, use when MSAA mode changes. @@ -168,21 +160,4 @@ private: VkShaderModule m_poke_fragment_shader = VK_NULL_HANDLE; }; -// The XFB source class simply wraps a texture cache entry. -// All the required functionality is provided by TextureCache. -class XFBSource final : public XFBSourceBase -{ -public: - explicit XFBSource(std::unique_ptr<AbstractTexture> texture); - ~XFBSource(); - - VKTexture* GetTexture() const; - - // Used for virtual XFB - void CopyEFB(float gamma) override; - -private: - std::unique_ptr<AbstractTexture> m_texture; -}; - } // namespace Vulkan diff --git a/Source/Core/VideoBackends/Vulkan/Renderer.cpp b/Source/Core/VideoBackends/Vulkan/Renderer.cpp index ce77fb68fd..af0bfba451 100644 --- a/Source/Core/VideoBackends/Vulkan/Renderer.cpp +++ b/Source/Core/VideoBackends/Vulkan/Renderer.cpp @@ -61,11 +61,6 @@ Renderer::~Renderer() { UpdateActiveConfig(); - // Ensure all frames are written to frame dump at shutdown. - if (m_frame_dumping_active) - EndFrameDumping(); - - DestroyFrameDumpResources(); DestroyShaders(); DestroySemaphores(); } @@ -491,12 +486,6 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& rc, u64 ti // Pending/batched EFB pokes should be included in the final image. FramebufferManager::GetInstance()->FlushEFBPokes(); - // Check that we actually have an image to render in XFB-on modes. - if (!m_xfb_written) - { - Core::Callback_VideoCopiedToXFB(false); - } - auto* xfb_texture = static_cast<VKTexture*>(texture); // End the current render pass. @@ -563,90 +552,6 @@ void Renderer::SwapImpl(AbstractTexture* texture, const EFBRectangle& rc, u64 ti g_shader_cache->RetrieveAsyncShaders(); } -void Renderer::TransitionBuffersForSwap(const TargetRectangle& scaled_rect, - const XFBSourceBase* const* xfb_sources, u32 xfb_count) -{ - VkCommandBuffer command_buffer = g_command_buffer_mgr->GetCurrentCommandBuffer(); - - // Drawing XFB sources, so transition all of them. - // Don't need the EFB, so leave it as-is. - for (u32 i = 0; i < xfb_count; i++) - { - const XFBSource* xfb_source = static_cast<const XFBSource*>(xfb_sources[i]); - xfb_source->GetTexture()->GetRawTexIdentifier()->TransitionToLayout( - command_buffer, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); - } -} - -void Renderer::DrawFrame(VkRenderPass render_pass, const TargetRectangle& target_rect, - const TargetRectangle& scaled_efb_rect, u32 xfb_addr, - const XFBSourceBase* const* xfb_sources, u32 xfb_count, u32 fb_width, - u32 fb_stride, u32 fb_height) -{ -} - -void Renderer::DrawEFB(VkRenderPass render_pass, const TargetRectangle& target_rect, - const TargetRectangle& scaled_efb_rect) -{ - // Transition the EFB render target to a shader resource. - Texture2D* efb_color_texture = - g_ActiveConfig.iMultisamples > 1 ? - FramebufferManager::GetInstance()->GetResolvedEFBColorTexture() : - FramebufferManager::GetInstance()->GetEFBColorTexture(); - - // Copy EFB -> backbuffer - BlitScreen(render_pass, target_rect, scaled_efb_rect, efb_color_texture); -} - -void Renderer::DrawVirtualXFB(VkRenderPass render_pass, const TargetRectangle& target_rect, - u32 xfb_addr, const XFBSourceBase* const* xfb_sources, u32 xfb_count, - u32 fb_width, u32 fb_stride, u32 fb_height) -{ - for (u32 i = 0; i < xfb_count; ++i) - { - const XFBSource* xfb_source = static_cast<const XFBSource*>(xfb_sources[i]); - TargetRectangle source_rect = xfb_source->sourceRc; - TargetRectangle draw_rect; - - int xfb_width = static_cast<int>(xfb_source->srcWidth); - int xfb_height = static_cast<int>(xfb_source->srcHeight); - int h_offset = (static_cast<s32>(xfb_source->srcAddr) - static_cast<s32>(xfb_addr)) / - (static_cast<s32>(fb_stride) * 2); - draw_rect.top = - target_rect.top + h_offset * target_rect.GetHeight() / static_cast<s32>(fb_height); - draw_rect.bottom = - target_rect.top + - (h_offset + xfb_height) * target_rect.GetHeight() / static_cast<s32>(fb_height); - draw_rect.left = target_rect.left + - (target_rect.GetWidth() - - xfb_width * target_rect.GetWidth() / static_cast<s32>(fb_stride)) / - 2; - draw_rect.right = target_rect.left + - (target_rect.GetWidth() + - xfb_width * target_rect.GetWidth() / static_cast<s32>(fb_stride)) / - 2; - - source_rect.right -= Renderer::EFBToScaledX(fb_stride - fb_width); - BlitScreen(render_pass, draw_rect, source_rect, - xfb_source->GetTexture()->GetRawTexIdentifier()); - } -} - -void Renderer::DrawRealXFB(VkRenderPass render_pass, const TargetRectangle& target_rect, - const XFBSourceBase* const* xfb_sources, u32 xfb_count, u32 fb_width, - u32 fb_stride, u32 fb_height) -{ - for (u32 i = 0; i < xfb_count; ++i) - { - const XFBSource* xfb_source = static_cast<const XFBSource*>(xfb_sources[i]); - TargetRectangle source_rect = xfb_source->sourceRc; - TargetRectangle draw_rect = target_rect; - source_rect.right -= fb_stride - fb_width; - BlitScreen(render_pass, draw_rect, source_rect, - xfb_source->GetTexture()->GetRawTexIdentifier()); - } -} - void Renderer::DrawScreen(VKTexture* xfb_texture) { VkResult res; @@ -718,173 +623,6 @@ void Renderer::DrawScreen(VKTexture* xfb_texture) VK_IMAGE_LAYOUT_PRESENT_SRC_KHR); } -bool Renderer::DrawFrameDump(const TargetRectangle& scaled_efb_rect, u32 xfb_addr, - const XFBSourceBase* const* xfb_sources, u32 xfb_count, u32 fb_width, - u32 fb_stride, u32 fb_height, u64 ticks) -{ - TargetRectangle target_rect = CalculateFrameDumpDrawRectangle(); - u32 width = std::max(1u, static_cast<u32>(target_rect.GetWidth())); - u32 height = std::max(1u, static_cast<u32>(target_rect.GetHeight())); - if (!ResizeFrameDumpBuffer(width, height)) - return false; - - // If there was a previous frame dumped, we'll still be in TRANSFER_SRC layout. - m_frame_dump_render_texture->TransitionToLayout(g_command_buffer_mgr->GetCurrentCommandBuffer(), - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); - - VkClearValue clear_value = {{{0.0f, 0.0f, 0.0f, 1.0f}}}; - VkClearRect clear_rect = {{{0, 0}, {width, height}}, 0, 1}; - VkClearAttachment clear_attachment = {VK_IMAGE_ASPECT_COLOR_BIT, 0, clear_value}; - VkRenderPassBeginInfo info = { - VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, - nullptr, - FramebufferManager::GetInstance()->GetColorCopyForReadbackRenderPass(), - m_frame_dump_framebuffer, - {{0, 0}, {width, height}}, - 1, - &clear_value}; - vkCmdBeginRenderPass(g_command_buffer_mgr->GetCurrentCommandBuffer(), &info, - VK_SUBPASS_CONTENTS_INLINE); - vkCmdClearAttachments(g_command_buffer_mgr->GetCurrentCommandBuffer(), 1, &clear_attachment, 1, - &clear_rect); - DrawFrame(FramebufferManager::GetInstance()->GetColorCopyForReadbackRenderPass(), target_rect, - scaled_efb_rect, xfb_addr, xfb_sources, xfb_count, fb_width, fb_stride, fb_height); - vkCmdEndRenderPass(g_command_buffer_mgr->GetCurrentCommandBuffer()); - - // Prepare the readback texture for copying. - StagingTexture2D* readback_texture = PrepareFrameDumpImage(width, height, ticks); - if (!readback_texture) - return false; - - // Queue a copy to the current frame dump buffer. It will be written to the frame dump later. - m_frame_dump_render_texture->TransitionToLayout(g_command_buffer_mgr->GetCurrentCommandBuffer(), - VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); - readback_texture->CopyFromImage(g_command_buffer_mgr->GetCurrentCommandBuffer(), - m_frame_dump_render_texture->GetImage(), - VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, width, height, 0, 0); - return true; -} - -void Renderer::StartFrameDumping() -{ - _assert_(!m_frame_dumping_active); - - // Register fence callback so that we know when frames are ready to be written to the dump. - // This is done by clearing the fence pointer, so WriteFrameDumpFrame doesn't have to wait. - auto queued_callback = [](VkCommandBuffer, VkFence) {}; - auto signaled_callback = std::bind(&Renderer::OnFrameDumpImageReady, this, std::placeholders::_1); - - // We use the array pointer as a key here, that way if Renderer needed fence callbacks in - // the future it could be used without conflicting. - // We're not interested in when fences are submitted, so the first callback is a no-op. - g_command_buffer_mgr->AddFencePointCallback( - m_frame_dump_images.data(), std::move(queued_callback), std::move(signaled_callback)); - m_frame_dumping_active = true; -} - -void Renderer::EndFrameDumping() -{ - _assert_(m_frame_dumping_active); - - // Write any pending frames to the frame dump. - FlushFrameDump(); - - // Remove the fence callback that we registered earlier, one less function that needs to be - // called when preparing a command buffer. - g_command_buffer_mgr->RemoveFencePointCallback(m_frame_dump_images.data()); - m_frame_dumping_active = false; -} - -void Renderer::OnFrameDumpImageReady(VkFence fence) -{ - for (FrameDumpImage& frame : m_frame_dump_images) - { - // fence being a null handle means that we don't have to wait to re-use this image. - if (frame.fence == fence) - frame.fence = VK_NULL_HANDLE; - } -} - -void Renderer::WriteFrameDumpImage(size_t index) -{ - /*FrameDumpImage& frame = m_frame_dump_images[index]; - _assert_(frame.pending); - - // Check fence has been signaled. - // The callback here should set fence to null. - if (frame.fence != VK_NULL_HANDLE) - { - g_command_buffer_mgr->WaitForFence(frame.fence); - _assert_(frame.fence == VK_NULL_HANDLE); - } - - // Copy the now-populated image data to the output file. - DumpFrameData(reinterpret_cast<const u8*>(frame.readback_texture->GetMapPointer()), - static_cast<int>(frame.readback_texture->GetWidth()), - static_cast<int>(frame.readback_texture->GetHeight()), - static_cast<int>(frame.readback_texture->GetRowStride()), frame.dump_state); - - frame.pending = false;*/ -} - -StagingTexture2D* Renderer::PrepareFrameDumpImage(u32 width, u32 height, u64 ticks) -{ - // Ensure the last frame that was sent to the frame dump has completed encoding before we send - // the next image to it. - //FinishFrameData(); - - // If the last image hasn't been written to the frame dump yet, write it now. - // This is necessary so that the worker thread is no more than one frame behind, and the pointer - // (which is actually the buffer) is safe for us to re-use next time. - if (m_frame_dump_images[m_current_frame_dump_image].pending) - WriteFrameDumpImage(m_current_frame_dump_image); - - // Move to the next image buffer - m_current_frame_dump_image = (m_current_frame_dump_image + 1) % FRAME_DUMP_BUFFERED_FRAMES; - FrameDumpImage& image = m_frame_dump_images[m_current_frame_dump_image]; - - // Ensure the dimensions of the readback texture are sufficient. - if (!image.readback_texture || width != image.readback_texture->GetWidth() || - height != image.readback_texture->GetHeight()) - { - // Allocate a new readback texture. - // The reset() call is here so that the memory is released before allocating the new texture. - image.readback_texture.reset(); - image.readback_texture = StagingTexture2D::Create(STAGING_BUFFER_TYPE_READBACK, width, height, - EFB_COLOR_TEXTURE_FORMAT); - - if (!image.readback_texture || !image.readback_texture->Map()) - { - // Not actually fatal, just means we can't dump this frame. - PanicAlert("Failed to allocate frame dump readback texture."); - image.readback_texture.reset(); - return nullptr; - } - } - - // The copy happens immediately after this function returns, so flag this frame as pending. - image.fence = g_command_buffer_mgr->GetCurrentCommandBufferFence(); - image.dump_state = AVIDump::FetchState(ticks); - image.pending = true; - return image.readback_texture.get(); -} - -void Renderer::FlushFrameDump() -{ - // We must write frames in order, so this is why we use a counter rather than a range. - for (size_t i = 0; i < FRAME_DUMP_BUFFERED_FRAMES; i++) - { - if (m_frame_dump_images[m_current_frame_dump_image].pending) - WriteFrameDumpImage(m_current_frame_dump_image); - - m_current_frame_dump_image = (m_current_frame_dump_image + 1) % FRAME_DUMP_BUFFERED_FRAMES; - } - - // Since everything has been written now, may as well start at index zero. - // count-1 here because the index is incremented before usage. - m_current_frame_dump_image = FRAME_DUMP_BUFFERED_FRAMES - 1; -} - void Renderer::BlitScreen(VkRenderPass render_pass, const TargetRectangle& dst_rect, const TargetRectangle& src_rect, const Texture2D* src_tex) { @@ -908,100 +646,6 @@ void Renderer::BlitScreen(VkRenderPass render_pass, const TargetRectangle& dst_r } } -bool Renderer::ResizeFrameDumpBuffer(u32 new_width, u32 new_height) -{ - if (m_frame_dump_render_texture && m_frame_dump_render_texture->GetWidth() == new_width && - m_frame_dump_render_texture->GetHeight() == new_height) - { - return true; - } - - // Ensure all previous frames have been dumped, since we are destroying a framebuffer - // that may still be in use. - FlushFrameDump(); - - if (m_frame_dump_framebuffer != VK_NULL_HANDLE) - { - vkDestroyFramebuffer(g_vulkan_context->GetDevice(), m_frame_dump_framebuffer, nullptr); - m_frame_dump_framebuffer = VK_NULL_HANDLE; - } - - m_frame_dump_render_texture = - Texture2D::Create(new_width, new_height, 1, 1, EFB_COLOR_TEXTURE_FORMAT, - VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_TILING_OPTIMAL, - VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); - - if (!m_frame_dump_render_texture) - { - WARN_LOG(VIDEO, "Failed to resize frame dump render texture"); - m_frame_dump_render_texture.reset(); - return false; - } - - VkImageView attachment = m_frame_dump_render_texture->GetView(); - VkFramebufferCreateInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; - info.renderPass = FramebufferManager::GetInstance()->GetColorCopyForReadbackRenderPass(); - info.attachmentCount = 1; - info.pAttachments = &attachment; - info.width = new_width; - info.height = new_height; - info.layers = 1; - - VkResult res = - vkCreateFramebuffer(g_vulkan_context->GetDevice(), &info, nullptr, &m_frame_dump_framebuffer); - if (res != VK_SUCCESS) - { - WARN_LOG(VIDEO, "Failed to create frame dump framebuffer"); - m_frame_dump_render_texture.reset(); - return false; - } - - // Render pass expects texture is in transfer src to start with. - m_frame_dump_render_texture->TransitionToLayout(g_command_buffer_mgr->GetCurrentCommandBuffer(), - VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); - - return true; -} - -void Renderer::DestroyFrameDumpResources() -{ - if (m_frame_dump_framebuffer != VK_NULL_HANDLE) - { - vkDestroyFramebuffer(g_vulkan_context->GetDevice(), m_frame_dump_framebuffer, nullptr); - m_frame_dump_framebuffer = VK_NULL_HANDLE; - } - - m_frame_dump_render_texture.reset(); - - for (FrameDumpImage& image : m_frame_dump_images) - { - image.readback_texture.reset(); - image.fence = VK_NULL_HANDLE; - image.dump_state = {}; - image.pending = false; - } - m_current_frame_dump_image = FRAME_DUMP_BUFFERED_FRAMES - 1; -} - -void Renderer::CheckForTargetResize(u32 fb_width, u32 fb_stride, u32 fb_height) -{ - /*if (FramebufferManagerBase::LastXfbWidth() == fb_stride && - FramebufferManagerBase::LastXfbHeight() == fb_height) - { - return; - } - - u32 new_width = (fb_stride < 1 || fb_stride > MAX_XFB_WIDTH) ? MAX_XFB_WIDTH : fb_stride; - u32 new_height = (fb_height < 1 || fb_height > MAX_XFB_HEIGHT) ? MAX_XFB_HEIGHT : fb_height; - FramebufferManagerBase::SetLastXfbWidth(new_width); - FramebufferManagerBase::SetLastXfbHeight(new_height); - - // Changing the XFB source area may alter the target size. - if (CalculateTargetSize()) - ResizeEFBTextures();*/ -} - void Renderer::CheckForSurfaceChange() { if (!m_surface_needs_change.IsSet()) diff --git a/Source/Core/VideoBackends/Vulkan/Renderer.h b/Source/Core/VideoBackends/Vulkan/Renderer.h index b9d746582c..a94d44138b 100644 --- a/Source/Core/VideoBackends/Vulkan/Renderer.h +++ b/Source/Core/VideoBackends/Vulkan/Renderer.h @@ -72,7 +72,6 @@ private: void BeginFrame(); - void CheckForTargetResize(u32 fb_width, u32 fb_stride, u32 fb_height); void CheckForSurfaceChange(); void CheckForConfigChanges(); @@ -86,61 +85,13 @@ private: bool CompileShaders(); void DestroyShaders(); - // Transitions EFB/XFB buffers to SHADER_READ_ONLY, ready for presenting/dumping. - // If MSAA is enabled, and XFB is disabled, also resolves the EFB buffer. - void TransitionBuffersForSwap(const TargetRectangle& scaled_rect, - const XFBSourceBase* const* xfb_sources, u32 xfb_count); - - // Draw either the EFB, or specified XFB sources to the currently-bound framebuffer. - void DrawFrame(VkRenderPass render_pass, const TargetRectangle& target_rect, - const TargetRectangle& scaled_efb_rect, u32 xfb_addr, - const XFBSourceBase* const* xfb_sources, u32 xfb_count, u32 fb_width, - u32 fb_stride, u32 fb_height); - void DrawEFB(VkRenderPass render_pass, const TargetRectangle& target_rect, - const TargetRectangle& scaled_efb_rect); - void DrawVirtualXFB(VkRenderPass render_pass, const TargetRectangle& target_rect, u32 xfb_addr, - const XFBSourceBase* const* xfb_sources, u32 xfb_count, u32 fb_width, - u32 fb_stride, u32 fb_height); - void DrawRealXFB(VkRenderPass render_pass, const TargetRectangle& target_rect, - const XFBSourceBase* const* xfb_sources, u32 xfb_count, u32 fb_width, - u32 fb_stride, u32 fb_height); - // Draw the frame, as well as the OSD to the swap chain. void DrawScreen(VKTexture* xfb_texture); - // Draw the frame only to the screenshot buffer. - bool DrawFrameDump(const TargetRectangle& scaled_efb_rect, u32 xfb_addr, - const XFBSourceBase* const* xfb_sources, u32 xfb_count, u32 fb_width, - u32 fb_stride, u32 fb_height, u64 ticks); - - // Sets up renderer state to permit framedumping. - // Ideally we would have EndFrameDumping be a virtual method of Renderer, but due to various - // design issues it would have to end up being called in the destructor, which won't work. - void StartFrameDumping(); - void EndFrameDumping(); - - // Fence callback so that we know when frames are ready to be written to the dump. - // This is done by clearing the fence pointer, so WriteFrameDumpFrame doesn't have to wait. - void OnFrameDumpImageReady(VkFence fence); - - // Writes the specified buffered frame to the frame dump. - // NOTE: Assumes that frame.ticks and frame.pending are valid. - void WriteFrameDumpImage(size_t index); - - // If there is a pending frame in this buffer, writes it to the frame dump. - // Ensures that the specified readback buffer meets the size requirements of the current frame. - StagingTexture2D* PrepareFrameDumpImage(u32 width, u32 height, u64 ticks); - - // Ensures all buffered frames are written to frame dump. - void FlushFrameDump(); - // Copies/scales an image to the currently-bound framebuffer. void BlitScreen(VkRenderPass render_pass, const TargetRectangle& dst_rect, const TargetRectangle& src_rect, const Texture2D* src_tex); - bool ResizeFrameDumpBuffer(u32 new_width, u32 new_height); - void DestroyFrameDumpResources(); - VkSemaphore m_image_available_semaphore = VK_NULL_HANDLE; VkSemaphore m_rendering_finished_semaphore = VK_NULL_HANDLE; @@ -153,22 +104,5 @@ private: // Shaders used for clear/blit. VkShaderModule m_clear_fragment_shader = VK_NULL_HANDLE; - - // Texture used for screenshot/frame dumping - std::unique_ptr<Texture2D> m_frame_dump_render_texture; - VkFramebuffer m_frame_dump_framebuffer = VK_NULL_HANDLE; - - // Readback resources for frame dumping - static const size_t FRAME_DUMP_BUFFERED_FRAMES = 2; - struct FrameDumpImage - { - std::unique_ptr<StagingTexture2D> readback_texture; - VkFence fence = VK_NULL_HANDLE; - AVIDump::Frame dump_state = {}; - bool pending = false; - }; - std::array<FrameDumpImage, FRAME_DUMP_BUFFERED_FRAMES> m_frame_dump_images; - size_t m_current_frame_dump_image = FRAME_DUMP_BUFFERED_FRAMES - 1; - bool m_frame_dumping_active = false; }; } |
