Vulkan: Rename screenshot buffer to frame dump buffer.

Name makes more sense given the methods it calls in the base class.
This commit is contained in:
Stenzek 2016-11-03 22:57:03 +11:00
parent 9aed27cdcf
commit c880c37244
2 changed files with 47 additions and 47 deletions

View File

@ -64,7 +64,7 @@ Renderer::~Renderer()
{ {
g_Config.bRunning = false; g_Config.bRunning = false;
UpdateActiveConfig(); UpdateActiveConfig();
DestroyScreenshotResources(); DestroyFrameDumpResources();
DestroyShaders(); DestroyShaders();
DestroySemaphores(); DestroySemaphores();
} }
@ -495,8 +495,8 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
// and the readback in one command buffer, wait for it, and then dump the frame. This allows us // and the readback in one command buffer, wait for it, and then dump the frame. This allows us
// to render to the screen and dump the frame in one command buffer instead of two. // to render to the screen and dump the frame in one command buffer instead of two.
VkFence frame_dump_fence = g_command_buffer_mgr->GetCurrentCommandBufferFence(); VkFence frame_dump_fence = g_command_buffer_mgr->GetCurrentCommandBufferFence();
bool dump_this_frame = IsFrameDumping() && DrawScreenshot(rc, xfb_addr, xfb_sources, xfb_count, bool dump_this_frame = IsFrameDumping() && DrawFrameDump(rc, xfb_addr, xfb_sources, xfb_count,
fb_width, fb_stride, fb_height); fb_width, fb_stride, fb_height);
// If we're dumping frames, don't bother waking the worker thread, since we have to wait anyway. // If we're dumping frames, don't bother waking the worker thread, since we have to wait anyway.
bool submit_on_background_thread = !dump_this_frame; bool submit_on_background_thread = !dump_this_frame;
@ -532,7 +532,7 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
if (dump_this_frame) if (dump_this_frame)
{ {
g_command_buffer_mgr->WaitForFence(frame_dump_fence); g_command_buffer_mgr->WaitForFence(frame_dump_fence);
DumpScreenshot(ticks); DumpFrame(ticks);
} }
// NOTE: It is important that no rendering calls are made to the EFB between submitting the // NOTE: It is important that no rendering calls are made to the EFB between submitting the
@ -702,9 +702,9 @@ void Renderer::DrawScreen(const EFBRectangle& rc, u32 xfb_addr,
VK_IMAGE_LAYOUT_PRESENT_SRC_KHR); VK_IMAGE_LAYOUT_PRESENT_SRC_KHR);
} }
bool Renderer::DrawScreenshot(const EFBRectangle& rc, u32 xfb_addr, bool Renderer::DrawFrameDump(const EFBRectangle& rc, u32 xfb_addr,
const XFBSourceBase* const* xfb_sources, u32 xfb_count, u32 fb_width, const XFBSourceBase* const* xfb_sources, u32 xfb_count, u32 fb_width,
u32 fb_stride, u32 fb_height) u32 fb_stride, u32 fb_height)
{ {
// Draw the screenshot to an image containing only the active screen area, removing any // Draw the screenshot to an image containing only the active screen area, removing any
// borders as a result of the game rendering in a different aspect ratio. // borders as a result of the game rendering in a different aspect ratio.
@ -715,7 +715,7 @@ bool Renderer::DrawScreenshot(const EFBRectangle& rc, u32 xfb_addr,
target_rect.top = 0; target_rect.top = 0;
u32 width = std::max(1u, static_cast<u32>(target_rect.GetWidth())); u32 width = std::max(1u, static_cast<u32>(target_rect.GetWidth()));
u32 height = std::max(1u, static_cast<u32>(target_rect.GetHeight())); u32 height = std::max(1u, static_cast<u32>(target_rect.GetHeight()));
if (!ResizeScreenshotBuffer(width, height)) if (!ResizeFrameDumpBuffer(width, height))
return false; return false;
VkClearValue clear_value = {{{0.0f, 0.0f, 0.0f, 1.0f}}}; VkClearValue clear_value = {{{0.0f, 0.0f, 0.0f, 1.0f}}};
@ -725,7 +725,7 @@ bool Renderer::DrawScreenshot(const EFBRectangle& rc, u32 xfb_addr,
VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
nullptr, nullptr,
FramebufferManager::GetInstance()->GetColorCopyForReadbackRenderPass(), FramebufferManager::GetInstance()->GetColorCopyForReadbackRenderPass(),
m_screenshot_framebuffer, m_frame_dump_framebuffer,
{{0, 0}, {width, height}}, {{0, 0}, {width, height}},
1, 1,
&clear_value}; &clear_value};
@ -738,19 +738,19 @@ bool Renderer::DrawScreenshot(const EFBRectangle& rc, u32 xfb_addr,
vkCmdEndRenderPass(g_command_buffer_mgr->GetCurrentCommandBuffer()); vkCmdEndRenderPass(g_command_buffer_mgr->GetCurrentCommandBuffer());
// Copy to the readback texture. // Copy to the readback texture.
m_screenshot_readback_texture->CopyFromImage( m_frame_dump_readback_texture->CopyFromImage(
g_command_buffer_mgr->GetCurrentCommandBuffer(), m_screenshot_render_texture->GetImage(), g_command_buffer_mgr->GetCurrentCommandBuffer(), m_frame_dump_render_texture->GetImage(),
VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, width, height, 0, 0); VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, width, height, 0, 0);
return true; return true;
} }
void Renderer::DumpScreenshot(u64 ticks) void Renderer::DumpFrame(u64 ticks)
{ {
DumpFrameData(reinterpret_cast<const u8*>(m_screenshot_readback_texture->GetMapPointer()), DumpFrameData(reinterpret_cast<const u8*>(m_frame_dump_readback_texture->GetMapPointer()),
static_cast<int>(m_screenshot_render_texture->GetWidth()), static_cast<int>(m_frame_dump_render_texture->GetWidth()),
static_cast<int>(m_screenshot_render_texture->GetHeight()), static_cast<int>(m_frame_dump_render_texture->GetHeight()),
static_cast<int>(m_screenshot_readback_texture->GetRowStride()), ticks); static_cast<int>(m_frame_dump_readback_texture->GetRowStride()), ticks);
FinishFrameData(); FinishFrameData();
} }
@ -792,37 +792,37 @@ void Renderer::BlitScreen(VkRenderPass render_pass, const TargetRectangle& dst_r
} }
} }
bool Renderer::ResizeScreenshotBuffer(u32 new_width, u32 new_height) bool Renderer::ResizeFrameDumpBuffer(u32 new_width, u32 new_height)
{ {
if (m_screenshot_render_texture && m_screenshot_render_texture->GetWidth() == new_width && if (m_frame_dump_render_texture && m_frame_dump_render_texture->GetWidth() == new_width &&
m_screenshot_render_texture->GetHeight() == new_height) m_frame_dump_render_texture->GetHeight() == new_height)
{ {
return true; return true;
} }
if (m_screenshot_framebuffer != VK_NULL_HANDLE) if (m_frame_dump_framebuffer != VK_NULL_HANDLE)
{ {
vkDestroyFramebuffer(g_vulkan_context->GetDevice(), m_screenshot_framebuffer, nullptr); vkDestroyFramebuffer(g_vulkan_context->GetDevice(), m_frame_dump_framebuffer, nullptr);
m_screenshot_framebuffer = VK_NULL_HANDLE; m_frame_dump_framebuffer = VK_NULL_HANDLE;
} }
m_screenshot_render_texture = m_frame_dump_render_texture =
Texture2D::Create(new_width, new_height, 1, 1, EFB_COLOR_TEXTURE_FORMAT, 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_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); VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
m_screenshot_readback_texture = StagingTexture2D::Create(STAGING_BUFFER_TYPE_READBACK, new_width, m_frame_dump_readback_texture = StagingTexture2D::Create(STAGING_BUFFER_TYPE_READBACK, new_width,
new_height, EFB_COLOR_TEXTURE_FORMAT); new_height, EFB_COLOR_TEXTURE_FORMAT);
if (!m_screenshot_render_texture || !m_screenshot_readback_texture || if (!m_frame_dump_render_texture || !m_frame_dump_readback_texture ||
!m_screenshot_readback_texture->Map()) !m_frame_dump_readback_texture->Map())
{ {
WARN_LOG(VIDEO, "Failed to resize screenshot render texture"); WARN_LOG(VIDEO, "Failed to resize screenshot render texture");
m_screenshot_render_texture.reset(); m_frame_dump_render_texture.reset();
m_screenshot_readback_texture.reset(); m_frame_dump_readback_texture.reset();
return false; return false;
} }
VkImageView attachment = m_screenshot_render_texture->GetView(); VkImageView attachment = m_frame_dump_render_texture->GetView();
VkFramebufferCreateInfo info = {}; VkFramebufferCreateInfo info = {};
info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
info.renderPass = FramebufferManager::GetInstance()->GetColorCopyForReadbackRenderPass(); info.renderPass = FramebufferManager::GetInstance()->GetColorCopyForReadbackRenderPass();
@ -833,32 +833,32 @@ bool Renderer::ResizeScreenshotBuffer(u32 new_width, u32 new_height)
info.layers = 1; info.layers = 1;
VkResult res = VkResult res =
vkCreateFramebuffer(g_vulkan_context->GetDevice(), &info, nullptr, &m_screenshot_framebuffer); vkCreateFramebuffer(g_vulkan_context->GetDevice(), &info, nullptr, &m_frame_dump_framebuffer);
if (res != VK_SUCCESS) if (res != VK_SUCCESS)
{ {
WARN_LOG(VIDEO, "Failed to resize screenshot framebuffer"); WARN_LOG(VIDEO, "Failed to resize screenshot framebuffer");
m_screenshot_render_texture.reset(); m_frame_dump_render_texture.reset();
m_screenshot_readback_texture.reset(); m_frame_dump_readback_texture.reset();
return false; return false;
} }
// Render pass expects texture is in transfer src to start with. // Render pass expects texture is in transfer src to start with.
m_screenshot_render_texture->TransitionToLayout(g_command_buffer_mgr->GetCurrentCommandBuffer(), m_frame_dump_render_texture->TransitionToLayout(g_command_buffer_mgr->GetCurrentCommandBuffer(),
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
return true; return true;
} }
void Renderer::DestroyScreenshotResources() void Renderer::DestroyFrameDumpResources()
{ {
if (m_screenshot_framebuffer != VK_NULL_HANDLE) if (m_frame_dump_framebuffer != VK_NULL_HANDLE)
{ {
vkDestroyFramebuffer(g_vulkan_context->GetDevice(), m_screenshot_framebuffer, nullptr); vkDestroyFramebuffer(g_vulkan_context->GetDevice(), m_frame_dump_framebuffer, nullptr);
m_screenshot_framebuffer = VK_NULL_HANDLE; m_frame_dump_framebuffer = VK_NULL_HANDLE;
} }
m_screenshot_render_texture.reset(); m_frame_dump_render_texture.reset();
m_screenshot_readback_texture.reset(); m_frame_dump_readback_texture.reset();
} }
void Renderer::CheckForTargetResize(u32 fb_width, u32 fb_stride, u32 fb_height) void Renderer::CheckForTargetResize(u32 fb_width, u32 fb_stride, u32 fb_height)

View File

@ -106,20 +106,20 @@ private:
u32 xfb_count, u32 fb_width, u32 fb_stride, u32 fb_height); u32 xfb_count, u32 fb_width, u32 fb_stride, u32 fb_height);
// Draw the frame only to the screenshot buffer. // Draw the frame only to the screenshot buffer.
bool DrawScreenshot(const EFBRectangle& rc, u32 xfb_addr, const XFBSourceBase* const* xfb_sources, bool DrawFrameDump(const EFBRectangle& rc, u32 xfb_addr, const XFBSourceBase* const* xfb_sources,
u32 xfb_count, u32 fb_width, u32 fb_stride, u32 fb_height); u32 xfb_count, u32 fb_width, u32 fb_stride, u32 fb_height);
// Copies the screenshot readback texture to the frame dumping buffer. // Copies the screenshot readback texture to the frame dumping buffer.
// NOTE: This assumes that DrawScreenshot has been called prior, and the fence associated // NOTE: This assumes that DrawScreenshot has been called prior, and the fence associated
// with the command buffer where the readback buffer was populated has been reached. // with the command buffer where the readback buffer was populated has been reached.
void DumpScreenshot(u64 ticks); void DumpFrame(u64 ticks);
// Copies/scales an image to the currently-bound framebuffer. // Copies/scales an image to the currently-bound framebuffer.
void BlitScreen(VkRenderPass render_pass, const TargetRectangle& dst_rect, void BlitScreen(VkRenderPass render_pass, const TargetRectangle& dst_rect,
const TargetRectangle& src_rect, const Texture2D* src_tex, bool linear_filter); const TargetRectangle& src_rect, const Texture2D* src_tex, bool linear_filter);
bool ResizeScreenshotBuffer(u32 new_width, u32 new_height); bool ResizeFrameDumpBuffer(u32 new_width, u32 new_height);
void DestroyScreenshotResources(); void DestroyFrameDumpResources();
VkSemaphore m_image_available_semaphore = VK_NULL_HANDLE; VkSemaphore m_image_available_semaphore = VK_NULL_HANDLE;
VkSemaphore m_rendering_finished_semaphore = VK_NULL_HANDLE; VkSemaphore m_rendering_finished_semaphore = VK_NULL_HANDLE;
@ -140,8 +140,8 @@ private:
VkShaderModule m_blit_fragment_shader = VK_NULL_HANDLE; VkShaderModule m_blit_fragment_shader = VK_NULL_HANDLE;
// Texture used for screenshot/frame dumping // Texture used for screenshot/frame dumping
std::unique_ptr<Texture2D> m_screenshot_render_texture; std::unique_ptr<Texture2D> m_frame_dump_render_texture;
std::unique_ptr<StagingTexture2D> m_screenshot_readback_texture; std::unique_ptr<StagingTexture2D> m_frame_dump_readback_texture;
VkFramebuffer m_screenshot_framebuffer = VK_NULL_HANDLE; VkFramebuffer m_frame_dump_framebuffer = VK_NULL_HANDLE;
}; };
} }