From ff0f1510e5fbd50ea5214c75c533a686bf0e9e68 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Fri, 8 Dec 2017 00:37:48 +0300 Subject: [PATCH] rsx: Minor fixes - Abort nv406e semaphore acquire if the rsx thread stalls/crashes - Fix texture size approximation to take mipmaps into account. Fixes some games hanging with WCB --- rpcs3/Emu/RSX/Common/texture_cache.h | 4 ++-- rpcs3/Emu/RSX/rsx_methods.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index 057df1aa11..82564acb82 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -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_texture_size(tex); + const u32 tex_size = (u32)get_placed_texture_storage_size(tex, 1, 256); 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); @@ -1361,7 +1361,7 @@ namespace rsx } } - tex_pitch = is_compressed_format? (tex_size / tex_height) : tex_pitch; //NOTE: Compressed textures dont have a real pitch (tex_size = (w*h)/6) + tex_pitch = is_compressed_format? (u16)(get_texture_size(tex) / tex_height) : tex_pitch; //NOTE: Compressed textures dont have a real pitch (tex_size = (w*h)/6) if (tex_pitch == 0) tex_pitch = tex_width * get_format_block_size_in_bytes(format); const bool unnormalized = (tex.format() & CELL_GCM_TEXTURE_UN) != 0; diff --git a/rpcs3/Emu/RSX/rsx_methods.cpp b/rpcs3/Emu/RSX/rsx_methods.cpp index d1bf8850a1..5189fa43b5 100644 --- a/rpcs3/Emu/RSX/rsx_methods.cpp +++ b/rpcs3/Emu/RSX/rsx_methods.cpp @@ -63,6 +63,9 @@ namespace rsx void semaphore_acquire(thread* rsx, u32 _reg, u32 arg) { const u32 addr = get_address(method_registers.semaphore_offset_406e(), method_registers.semaphore_context_dma_406e()); + if (vm::ps3::read32(addr) == arg) return; + + const u64 start = get_system_time(); while (vm::ps3::read32(addr) != arg) { // todo: LLE: why does this one keep hanging? is it vsh system semaphore? whats actually pushing this to the command buffer?! @@ -72,6 +75,13 @@ namespace rsx if (Emu.IsStopped()) break; + if ((get_system_time() - start) > 33000) + { + //If longer than 33ms force exit (1 frame) + LOG_ERROR(RSX, "nv406e::semaphore_acquire has timed out. semaphore_address=0x%X", addr); + break; + } + std::this_thread::yield(); } }