diff --git a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp index f5793bf35d..98246b566b 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp @@ -125,8 +125,9 @@ void D3D12GSRender::clear_surface(u32 arg) if (arg & 0x1) { - u32 clear_depth = rsx::method_registers.z_clear_value(); - u32 max_depth_value = get_max_depth_value(rsx::method_registers.surface_depth_fmt()); + auto depth_format = rsx::method_registers.surface_depth_fmt(); + u32 clear_depth = rsx::method_registers.z_clear_value(depth_format == rsx::surface_depth_format::z24s8); + u32 max_depth_value = get_max_depth_value(depth_format); get_current_resource_storage().command_list->ClearDepthStencilView(m_rtts.current_ds_handle, D3D12_CLEAR_FLAG_DEPTH, clear_depth / (float)max_depth_value, 0, 1, &get_scissor(rsx::method_registers.scissor_origin_x(), rsx::method_registers.scissor_origin_y(), rsx::method_registers.scissor_width(), rsx::method_registers.scissor_height())); } diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index 51b6f84c24..858e8f6f95 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -635,8 +635,7 @@ void GLGSRender::clear_surface(u32 arg) if (arg & 0x1) { u32 max_depth_value = get_max_depth_value(surface_depth_format); - - u32 clear_depth = rsx::method_registers.z_clear_value(); + u32 clear_depth = rsx::method_registers.z_clear_value(surface_depth_format == rsx::surface_depth_format::z24s8); glDepthMask(GL_TRUE); glClearDepth(double(clear_depth) / max_depth_value); diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index 7c568855f0..518d3883cb 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -889,7 +889,7 @@ void VKGSRender::clear_surface(u32 mask) { u32 max_depth_value = get_max_depth_value(surface_depth_format); - u32 clear_depth = rsx::method_registers.z_clear_value(); + u32 clear_depth = rsx::method_registers.z_clear_value(surface_depth_format == rsx::surface_depth_format::z24s8); float depth_clear = (float)clear_depth / max_depth_value; depth_stencil_clear_values.depthStencil.depth = depth_clear; diff --git a/rpcs3/Emu/RSX/rsx_decode.h b/rpcs3/Emu/RSX/rsx_decode.h index 7e793e3dad..c65b08fdab 100644 --- a/rpcs3/Emu/RSX/rsx_decode.h +++ b/rpcs3/Emu/RSX/rsx_decode.h @@ -3410,7 +3410,8 @@ struct registers_decoder union { u32 raw_value; - bitfield_decoder_t<8, 24> clear_z; + bitfield_decoder_t<0, 16> clear_z16; + bitfield_decoder_t<8, 24> clear_z24; bitfield_decoder_t<0, 8> clear_stencil; } m_data; public: @@ -3421,15 +3422,19 @@ struct registers_decoder return m_data.clear_stencil; } - u32 clear_z() const + u32 clear_z(bool is_depth_stencil) const { - return m_data.clear_z; + if (is_depth_stencil) + return m_data.clear_z24; + + return m_data.clear_z16; } }; static std::string dump(decoded_type &&decoded_values) { - return "Clear: Z = " + std::to_string(decoded_values.clear_z()) + + return "Clear: Z24 = " + std::to_string(decoded_values.clear_z(true)) + + " z16 = " + std::to_string(decoded_values.clear_z(false)) + " Stencil = " + std::to_string(decoded_values.clear_stencil()); } }; diff --git a/rpcs3/Emu/RSX/rsx_methods.h b/rpcs3/Emu/RSX/rsx_methods.h index 37b66f8e2a..6e4ee4f656 100644 --- a/rpcs3/Emu/RSX/rsx_methods.h +++ b/rpcs3/Emu/RSX/rsx_methods.h @@ -287,9 +287,9 @@ namespace rsx return decode().restart_index(); } - u32 z_clear_value() const + u32 z_clear_value(bool is_depth_stencil) const { - return decode().clear_z(); + return decode().clear_z(is_depth_stencil); } u8 stencil_clear_value() const