From 928719b6583c53b6dac4a475beabfe0396a3c8c9 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sun, 25 Aug 2019 15:04:20 +0300 Subject: [PATCH] Use g_fxo for rsx::avconf --- rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp | 4 ++-- rpcs3/Emu/Cell/Modules/cellVideoOut.cpp | 5 +++-- rpcs3/Emu/RSX/GL/GLGSRender.cpp | 20 +++++++++++--------- rpcs3/Emu/RSX/VK/VKGSRender.cpp | 12 +++++++----- rpcs3/Emu/RSX/rsx_utils.h | 5 +++-- 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp b/rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp index 216ab99fd1..a74b9a5a68 100644 --- a/rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp +++ b/rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp @@ -175,7 +175,7 @@ s32 cellVideoOutGetGamma(u32 videoOut, vm::ptr gamma) return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT; } - auto conf = fxm::get_always(); + auto conf = g_fxo->get(); *gamma = conf->gamma; return CELL_OK; @@ -222,7 +222,7 @@ s32 cellVideoOutSetGamma(u32 videoOut, f32 gamma) return CELL_VIDEO_OUT_ERROR_ILLEGAL_PARAMETER; } - auto conf = fxm::get_always(); + auto conf = g_fxo->get(); conf->gamma = gamma; return CELL_OK; diff --git a/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp b/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp index 451a4b4426..ef6d830f67 100644 --- a/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp +++ b/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp @@ -121,7 +121,7 @@ error_code cellVideoOutGetResolution(u32 resolutionId, vm::ptr(); + auto conf = g_fxo->get(); conf->aspect = config->aspect; conf->format = config->format; conf->scanline_pitch = config->pitch; conf->resolution_x = u32(res_info.first); conf->resolution_y = u32(res_info.second); + conf->state = 1; return CELL_OK; } diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index 6215b58532..32b0f997af 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -492,7 +492,7 @@ void GLGSRender::end() { if (rsx::method_registers.current_draw_clause.execute_pipeline_dependencies() & rsx::vertex_base_changed) { - // Rebase vertex bases instead of + // Rebase vertex bases instead of for (auto &info : m_vertex_layout.interleaved_blocks) { const auto vertex_base_offset = rsx::method_registers.vertex_data_base_offset(); @@ -1314,7 +1314,7 @@ void GLGSRender::load_program_env() if (update_fragment_env) m_fragment_env_buffer->reserve_storage_on_heap(128); if (update_vertex_env) m_vertex_env_buffer->reserve_storage_on_heap(256); if (update_fragment_texture_env) m_texture_parameters_buffer->reserve_storage_on_heap(256); - if (update_fragment_constants) m_fragment_constants_buffer->reserve_storage_on_heap(align(fragment_constants_size, 256)); + if (update_fragment_constants) m_fragment_constants_buffer->reserve_storage_on_heap(align(fragment_constants_size, 256)); if (update_transform_constants) m_transform_constants_buffer->reserve_storage_on_heap(8192); } @@ -1564,12 +1564,13 @@ void GLGSRender::flip(int buffer, bool emu_flip) u32 buffer_pitch = display_buffers[buffer].pitch; u32 av_format; - const auto avconfig = fxm::get(); + const auto avconfig = g_fxo->get(); - if (avconfig) + if (avconfig->state) { av_format = avconfig->get_compatible_gcm_format(); - if (!buffer_pitch) buffer_pitch = buffer_width * avconfig->get_bpp(); + if (!buffer_pitch) + buffer_pitch = buffer_width * avconfig->get_bpp(); buffer_width = std::min(buffer_width, avconfig->resolution_x); buffer_height = std::min(buffer_height, avconfig->resolution_y); @@ -1577,7 +1578,8 @@ void GLGSRender::flip(int buffer, bool emu_flip) else { av_format = CELL_GCM_TEXTURE_A8R8G8B8; - if (!buffer_pitch) buffer_pitch = buffer_width * 4; + if (!buffer_pitch) + buffer_pitch = buffer_width * 4; } // Disable scissor test (affects blit, clear, etc) @@ -1648,7 +1650,7 @@ void GLGSRender::flip(int buffer, bool emu_flip) // TODO: Should emit only once to avoid flooding the log file // TODO: Take AA scaling into account LOG_WARNING(RSX, "Selected output image does not satisfy the video configuration. Display buffer resolution=%dx%d, avconf resolution=%dx%d, surface=%dx%d", - display_buffers[buffer].width, display_buffers[buffer].height, avconfig ? avconfig->resolution_x : 0, avconfig ? avconfig->resolution_y : 0, + display_buffers[buffer].width, display_buffers[buffer].height, avconfig->state * avconfig->resolution_x, avconfig->state * avconfig->resolution_y, render_target_texture->get_surface_width(rsx::surface_metrics::pixels), render_target_texture->get_surface_height(rsx::surface_metrics::pixels)); buffer_width = render_target_texture->width(); @@ -1705,7 +1707,7 @@ void GLGSRender::flip(int buffer, bool emu_flip) areai screen_area = coordi({}, { (int)buffer_width, (int)buffer_height }); - if (g_cfg.video.full_rgb_range_output && (!avconfig || avconfig->gamma == 1.f)) + if (g_cfg.video.full_rgb_range_output && avconfig->gamma == 1.f) { // Blit source image to the screen m_flip_fbo.recreate(); @@ -1717,7 +1719,7 @@ void GLGSRender::flip(int buffer, bool emu_flip) } else { - const f32 gamma = avconfig ? avconfig->gamma : 1.f; + const f32 gamma = avconfig->gamma; const bool limited_range = !g_cfg.video.full_rgb_range_output; gl::screen.bind(); diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index 70d0d5343f..028aec2335 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -3173,12 +3173,13 @@ void VKGSRender::flip(int buffer, bool emu_flip) u32 buffer_pitch = display_buffers[buffer].pitch; u32 av_format; - const auto avconfig = fxm::get(); + const auto avconfig = g_fxo->get(); - if (avconfig) + if (avconfig->state) { av_format = avconfig->get_compatible_gcm_format(); - if (!buffer_pitch) buffer_pitch = buffer_width * avconfig->get_bpp(); + if (!buffer_pitch) + buffer_pitch = buffer_width * avconfig->get_bpp(); buffer_width = std::min(buffer_width, avconfig->resolution_x); buffer_height = std::min(buffer_height, avconfig->resolution_y); @@ -3186,7 +3187,8 @@ void VKGSRender::flip(int buffer, bool emu_flip) else { av_format = CELL_GCM_TEXTURE_A8R8G8B8; - if (!buffer_pitch) buffer_pitch = buffer_width * 4; + if (!buffer_pitch) + buffer_pitch = buffer_width * 4; } coordi aspect_ratio; @@ -3288,7 +3290,7 @@ void VKGSRender::flip(int buffer, bool emu_flip) // TODO: Should emit only once to avoid flooding the log file // TODO: Take AA scaling into account LOG_WARNING(RSX, "Selected output image does not satisfy the video configuration. Display buffer resolution=%dx%d, avconf resolution=%dx%d, surface=%dx%d", - display_buffers[buffer].width, display_buffers[buffer].height, avconfig? avconfig->resolution_x : 0, avconfig? avconfig->resolution_y : 0, + display_buffers[buffer].width, display_buffers[buffer].height, avconfig->state * avconfig->resolution_x, avconfig->state * avconfig->resolution_y, render_target_texture->get_surface_width(rsx::surface_metrics::pixels), render_target_texture->get_surface_height(rsx::surface_metrics::pixels)); buffer_width = render_target_texture->width(); diff --git a/rpcs3/Emu/RSX/rsx_utils.h b/rpcs3/Emu/RSX/rsx_utils.h index 2a011e163a..87e250a75f 100644 --- a/rpcs3/Emu/RSX/rsx_utils.h +++ b/rpcs3/Emu/RSX/rsx_utils.h @@ -148,9 +148,10 @@ namespace rsx u8 format = 0; // XRGB u8 aspect = 0; // AUTO u32 scanline_pitch = 0; // PACKED - f32 gamma = 1.f; // NO GAMMA CORRECTION + atomic_t gamma = 1.f; // NO GAMMA CORRECTION u32 resolution_x = 1280; // X RES u32 resolution_y = 720; // Y RES + atomic_t state = 0; // 1 after cellVideoOutConfigure was called u32 get_compatible_gcm_format() { @@ -407,7 +408,7 @@ namespace rsx const u32 log2_w = ceil_log2(width); const u32 log2_h = ceil_log2(height); const u32 log2_d = ceil_log2(depth); - + for (u32 z = 0; z < depth; ++z) { for (u32 y = 0; y < height; ++y)