1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-23 03:02:53 +01:00

rsx: Framebuffer setup fixes

- Sometimes square renders are done to surfaces with pitch=64 and re-uploaded with swizzle scanning
-- This setup avoids discarding targets if they are square and pitch == 64
This commit is contained in:
kd-11 2017-12-08 12:48:01 +03:00
parent ff0f1510e5
commit 7c7cd4153e
3 changed files with 35 additions and 5 deletions

View File

@ -1297,7 +1297,7 @@ namespace rsx
sampled_image_descriptor upload_texture(commandbuffer_type& cmd, RsxTextureType& tex, surface_store_type& m_rtts, Args&&... extras)
{
const u32 texaddr = rsx::get_address(tex.offset(), tex.location());
const u32 tex_size = (u32)get_placed_texture_storage_size(tex, 1, 256);
const u32 tex_size = (u32)get_placed_texture_storage_size(tex, 256, 512);
const u32 format = tex.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN);
const bool is_compressed_format = (format == CELL_GCM_TEXTURE_COMPRESSED_DXT1 || format == CELL_GCM_TEXTURE_COMPRESSED_DXT23 || format == CELL_GCM_TEXTURE_COMPRESSED_DXT45);

View File

@ -186,7 +186,10 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk
const auto depth_format = rsx::method_registers.surface_depth_fmt();
const auto target = rsx::method_registers.surface_color_target();
//NOTE: Z buffers with pitch = 64 are valid even if they would not fit (GT HD Concept)
//NOTE: Its is possible that some renders are done on a swizzled context. Pitch is meaningless in that case
//Seen in Nier (color) and GT HD concept (z buffer)
//Restriction is that the RTT is always a square region for that dimensions are powers of 2
const auto required_zeta_pitch = std::max<u32>((u32)(depth_format == rsx::surface_depth_format::z16 ? clip_horizontal * 2 : clip_horizontal * 4), 64u);
const auto required_color_pitch = std::max<u32>((u32)rsx::utility::get_packed_pitch(surface_format, clip_horizontal), 64u);
const bool stencil_test_enabled = depth_format == rsx::surface_depth_format::z24s8 && rsx::method_registers.stencil_test_enabled();
@ -204,12 +207,21 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk
m_framebuffer_state_contested = true;
}
}
if (depth_address && zeta_pitch < required_zeta_pitch)
{
if (zeta_pitch < 64 || clip_vertical != clip_horizontal)
depth_address = 0;
}
}
for (const auto &index : rsx::utility::get_rtt_indexes(target))
{
if (pitchs[index] < required_color_pitch)
surface_addresses[index] = 0;
{
if (pitchs[index] < 64 || clip_vertical != clip_horizontal)
surface_addresses[index] = 0;
}
if (surface_addresses[index] == depth_address)
{
@ -237,7 +249,10 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk
}
if (!framebuffer_status_valid && !depth_address)
{
LOG_WARNING(RSX, "Framebuffer setup failed. Draw calls may have been lost");
return;
}
m_rtts.prepare_render_target(nullptr, surface_format, depth_format, clip_horizontal, clip_vertical,
target, surface_addresses, depth_address);

View File

@ -2424,7 +2424,10 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context)
const auto depth_fmt = rsx::method_registers.surface_depth_fmt();
const auto target = rsx::method_registers.surface_color_target();
//NOTE: Z buffers with pitch = 64 are valid even if they would not fit (GT HD Concept)
//NOTE: Its is possible that some renders are done on a swizzled context. Pitch is meaningless in that case
//Seen in Nier (color) and GT HD concept (z buffer)
//Restriction is that the RTT is always a square region for that dimensions are powers of 2
const auto required_zeta_pitch = std::max<u32>((u32)(depth_fmt == rsx::surface_depth_format::z16 ? clip_width * 2 : clip_width * 4), 64u);
const auto required_color_pitch = std::max<u32>((u32)rsx::utility::get_packed_pitch(color_fmt, clip_width), 64u);
const bool stencil_test_enabled = depth_fmt == rsx::surface_depth_format::z24s8 && rsx::method_registers.stencil_test_enabled();
@ -2442,12 +2445,21 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context)
m_framebuffer_state_contested = true;
}
}
if (zeta_address && zeta_pitch < required_zeta_pitch)
{
if (zeta_pitch < 64 || clip_width != clip_height)
zeta_address = 0;
}
}
for (const auto &index : rsx::utility::get_rtt_indexes(target))
{
if (surface_pitchs[index] < required_color_pitch)
surface_addresses[index] = 0;
{
if (surface_pitchs[index] < 64 || clip_width != clip_height)
surface_addresses[index] = 0;
}
if (surface_addresses[index] == zeta_address)
{
@ -2474,7 +2486,10 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context)
}
if (!framebuffer_status_valid && !zeta_address)
{
LOG_WARNING(RSX, "Framebuffer setup failed. Draw calls may have been lost");
return;
}
//At least one attachment exists
framebuffer_status_valid = true;