mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-20 11:36:13 +00:00
rsx: Changes to surface pitch handling
- Zeta pitch is ignored by real HW for some reason - Monitor ptch value changes as well since they may affect disabled surfaces - TODO: Verify if MRT pitch is really taken into consideration
This commit is contained in:
parent
89bc333295
commit
da1e97618b
3 changed files with 11 additions and 23 deletions
|
@ -186,17 +186,12 @@ 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();
|
||||
|
||||
const auto required_z_pitch = depth_format == rsx::surface_depth_format::z16 ? clip_horizontal * 2u : clip_horizontal * 4u;
|
||||
//NOTE: Z buffers with pitch = 64 are valid even if they would not fit (GT HD Concept)
|
||||
const auto required_color_pitch = std::max<u32>((u32)rsx::utility::get_packed_pitch(surface_format, clip_horizontal), 64u);
|
||||
|
||||
if (depth_address)
|
||||
{
|
||||
//TODO: Verify that buffers <= 16 pixels in X (pitch=64) cannot have a depth buffer
|
||||
if (zeta_pitch < required_z_pitch || zeta_pitch <= 64)
|
||||
{
|
||||
depth_address = 0;
|
||||
}
|
||||
else if (!rsx::method_registers.depth_test_enabled() && target != rsx::surface_target::none)
|
||||
if (!rsx::method_registers.depth_test_enabled() && target != rsx::surface_target::none)
|
||||
{
|
||||
//Disable depth buffer if depth testing is not enabled, unless a clear command is targeting the depth buffer
|
||||
const bool is_depth_clear = !!(context & rsx::framebuffer_creation_context::context_clear_depth);
|
||||
|
@ -213,8 +208,7 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk
|
|||
if (pitchs[index] < required_color_pitch)
|
||||
surface_addresses[index] = 0;
|
||||
|
||||
if (surface_addresses[index] == depth_address &&
|
||||
zeta_pitch >= required_z_pitch)
|
||||
if (surface_addresses[index] == depth_address)
|
||||
{
|
||||
LOG_TRACE(RSX, "Framebuffer at 0x%X has aliasing color/depth targets, zeta_pitch = %d, color_pitch=%d", depth_address, zeta_pitch, pitchs[index]);
|
||||
//TODO: Research clearing both depth AND color
|
||||
|
@ -376,11 +370,6 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool sk
|
|||
if (m_depth_surface_info.depth_format != rsx::surface_depth_format::z16) pitch *= 2;
|
||||
|
||||
const u32 range = pitch * m_depth_surface_info.height;
|
||||
|
||||
//TODO: Verify that depth surface pitch variance affects results
|
||||
if (pitch != m_depth_surface_info.pitch)
|
||||
LOG_WARNING(RSX, "Depth surface pitch does not match computed pitch, %d vs %d", m_depth_surface_info.pitch, pitch);
|
||||
|
||||
m_gl_texture_cache.lock_memory_region(std::get<1>(m_rtts.m_bound_depth_stencil), m_depth_surface_info.address, range, m_depth_surface_info.width, m_depth_surface_info.height, pitch,
|
||||
depth_format_gl.format, depth_format_gl.type, true);
|
||||
}
|
||||
|
|
|
@ -2425,17 +2425,12 @@ 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();
|
||||
|
||||
const auto required_z_pitch = depth_fmt == rsx::surface_depth_format::z16 ? clip_width * 2 : clip_width * 4;
|
||||
//NOTE: Z buffers with pitch = 64 are valid even if they would not fit (GT HD Concept)
|
||||
const auto required_color_pitch = std::max<u32>((u32)rsx::utility::get_packed_pitch(color_fmt, clip_width), 64u);
|
||||
|
||||
if (zeta_address)
|
||||
{
|
||||
//TODO: Verify that buffers <= 16 pixels in X (pitch=64) cannot have a depth buffer
|
||||
if (zeta_pitch < required_z_pitch || zeta_pitch <= 64)
|
||||
{
|
||||
zeta_address = 0;
|
||||
}
|
||||
else if (!rsx::method_registers.depth_test_enabled() && target != rsx::surface_target::none)
|
||||
if (!rsx::method_registers.depth_test_enabled() && target != rsx::surface_target::none)
|
||||
{
|
||||
//Disable depth buffer if depth testing is not enabled, unless a clear command is targeting the depth buffer
|
||||
const bool is_depth_clear = !!(context & rsx::framebuffer_creation_context::context_clear_depth);
|
||||
|
@ -2452,8 +2447,7 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context)
|
|||
if (surface_pitchs[index] < required_color_pitch)
|
||||
surface_addresses[index] = 0;
|
||||
|
||||
if (surface_addresses[index] == zeta_address &&
|
||||
zeta_pitch >= required_z_pitch)
|
||||
if (surface_addresses[index] == zeta_address)
|
||||
{
|
||||
LOG_TRACE(RSX, "Framebuffer at 0x%X has aliasing color/depth targets, zeta_pitch = %d, color_pitch=%d", zeta_address, zeta_pitch, surface_pitchs[index]);
|
||||
if (context == rsx::framebuffer_creation_context::context_clear_depth ||
|
||||
|
|
|
@ -1581,6 +1581,11 @@ namespace rsx
|
|||
bind<NV4097_SET_CONTEXT_DMA_COLOR_D, nv4097::set_surface_dirty_bit>();
|
||||
bind<NV4097_SET_CONTEXT_DMA_ZETA, nv4097::set_surface_dirty_bit>();
|
||||
bind<NV4097_SET_SURFACE_FORMAT, nv4097::set_surface_dirty_bit>();
|
||||
bind<NV4097_SET_SURFACE_PITCH_A, nv4097::set_surface_dirty_bit>();
|
||||
bind<NV4097_SET_SURFACE_PITCH_B, nv4097::set_surface_dirty_bit>();
|
||||
bind<NV4097_SET_SURFACE_PITCH_C, nv4097::set_surface_dirty_bit>();
|
||||
bind<NV4097_SET_SURFACE_PITCH_D, nv4097::set_surface_dirty_bit>();
|
||||
bind<NV4097_SET_SURFACE_PITCH_Z, nv4097::set_surface_dirty_bit>();
|
||||
bind_range<NV4097_SET_TEXTURE_OFFSET, 8, 16, nv4097::set_texture_dirty_bit>();
|
||||
bind_range<NV4097_SET_TEXTURE_FORMAT, 8, 16, nv4097::set_texture_dirty_bit>();
|
||||
bind_range<NV4097_SET_TEXTURE_ADDRESS, 8, 16, nv4097::set_texture_dirty_bit>();
|
||||
|
|
Loading…
Add table
Reference in a new issue