1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 18:53:28 +01:00

Change render target layout before clearing

Use LAYOUT_GENERAL during clear; move renderpass begin to draw call end
This commit is contained in:
kd-11 2016-03-09 13:23:25 +03:00
parent b018c91135
commit 47d251a818
2 changed files with 57 additions and 16 deletions

View File

@ -357,19 +357,6 @@ void VKGSRender::begin()
//TODO: Set up other render-state parameters into the program pipeline
VkRenderPassBeginInfo rp_begin;
rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
rp_begin.pNext = NULL;
rp_begin.renderPass = m_render_pass;
rp_begin.framebuffer = m_framebuffer;
rp_begin.renderArea.offset.x = 0;
rp_begin.renderArea.offset.y = 0;
rp_begin.renderArea.extent.width = m_frame->client_size().width;
rp_begin.renderArea.extent.height = m_frame->client_size().height;
rp_begin.clearValueCount = 0;
rp_begin.pClearValues = nullptr;
vkCmdBeginRenderPass(m_command_buffer, &rp_begin, VK_SUBPASS_CONTENTS_INLINE);
m_draw_calls++;
}
@ -394,7 +381,21 @@ namespace
}
void VKGSRender::end()
{
{
VkRenderPassBeginInfo rp_begin;
rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
rp_begin.pNext = NULL;
rp_begin.renderPass = m_render_pass;
rp_begin.framebuffer = m_framebuffer;
rp_begin.renderArea.offset.x = 0;
rp_begin.renderArea.offset.y = 0;
rp_begin.renderArea.extent.width = m_frame->client_size().width;
rp_begin.renderArea.extent.height = m_frame->client_size().height;
rp_begin.clearValueCount = 0;
rp_begin.pClearValues = nullptr;
vkCmdBeginRenderPass(m_command_buffer, &rp_begin, VK_SUBPASS_CONTENTS_INLINE);
vk::texture *texture0 = nullptr;
for (int i = 0; i < rsx::limits::textures_count; ++i)
{
@ -571,12 +572,22 @@ void VKGSRender::clear_surface(u32 mask)
if (std::get<1>(m_rtts.m_bound_render_targets[i]) == nullptr) continue;
VkImage color_image = (*std::get<1>(m_rtts.m_bound_render_targets[i]));
vkCmdClearColorImage(m_command_buffer, color_image, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, &color_clear_values.color, 1, &range);
VkImageLayout old_layout = std::get<1>(m_rtts.m_bound_render_targets[i])->get_layout();
std::get<1>(m_rtts.m_bound_render_targets[i])->change_layout(m_command_buffer, VK_IMAGE_LAYOUT_GENERAL);
vkCmdClearColorImage(m_command_buffer, color_image, VK_IMAGE_LAYOUT_GENERAL, &color_clear_values.color, 1, &range);
std::get<1>(m_rtts.m_bound_render_targets[i])->change_layout(m_command_buffer, old_layout);
}
}
if (mask & 0x3)
vkCmdClearDepthStencilImage(m_command_buffer, (*std::get<1>(m_rtts.m_bound_depth_stencil)), VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &depth_stencil_clear_values.depthStencil, 1, &depth_range);
{
VkImageLayout old_layout = std::get<1>(m_rtts.m_bound_depth_stencil)->get_layout();
std::get<1>(m_rtts.m_bound_depth_stencil)->change_layout(m_command_buffer, VK_IMAGE_LAYOUT_GENERAL);
vkCmdClearDepthStencilImage(m_command_buffer, (*std::get<1>(m_rtts.m_bound_depth_stencil)), VK_IMAGE_LAYOUT_GENERAL, &depth_stencil_clear_values.depthStencil, 1, &depth_range);
std::get<1>(m_rtts.m_bound_depth_stencil)->change_layout(m_command_buffer, old_layout);
}
if (!was_recording)
{

View File

@ -20,6 +20,18 @@ namespace rsx
vk::texture rtt;
rtt.create(device, requested_format, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_SAMPLED_BIT, width, height, 1, true);
rtt.change_layout(*cmd, VK_IMAGE_LAYOUT_GENERAL);
//Clear new surface
VkClearColorValue clear_color;
VkImageSubresourceRange range = vk::default_image_subresource_range();
clear_color.float32[0] = 0.f;
clear_color.float32[1] = 0.f;
clear_color.float32[2] = 0.f;
clear_color.float32[3] = 0.f;
vkCmdClearColorImage(*cmd, rtt, rtt.get_layout(), &clear_color, 1, &range);
rtt.change_layout(*cmd, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
return rtt;
@ -31,6 +43,24 @@ namespace rsx
vk::texture rtt;
rtt.create(device, requested_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT|VK_IMAGE_USAGE_SAMPLED_BIT, width, height, 1, true);
rtt.change_layout(*cmd, VK_IMAGE_LAYOUT_GENERAL);
//Clear new surface..
VkClearDepthStencilValue clear_depth;
VkImageSubresourceRange range;
range.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
range.baseArrayLayer = 0;
range.baseMipLevel = 0;
range.layerCount = 1;
range.levelCount = 1;
if (format == surface_depth_format::z24s8)
range.aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT;
clear_depth.depth = 1.f;
clear_depth.stencil = 0;
vkCmdClearDepthStencilImage(*cmd, rtt, rtt.get_layout(), &clear_depth, 1, &range);
rtt.change_layout(*cmd, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
return rtt;