diff --git a/rpcs3/Emu/RSX/Core/RSXContext.cpp b/rpcs3/Emu/RSX/Core/RSXContext.cpp new file mode 100644 index 0000000000..ababec24cc --- /dev/null +++ b/rpcs3/Emu/RSX/Core/RSXContext.cpp @@ -0,0 +1,34 @@ +#include "stdafx.h" +#include "Emu/RSX/rsx_utils.h" +#include "RSXContext.h" + +namespace rsx +{ + GCM_tile_reference GCM_context::get_tiled_memory_region(const utils::address_range& range) const + { + if (rsx::get_location(range.start) != CELL_GCM_LOCATION_MAIN) + { + // Local mem can be tiled but access is transparent from the memory controller + return {}; + } + + for (const auto& tile : tiles) + { + if (!tile.bound || tile.location != CELL_GCM_LOCATION_MAIN) + { + continue; + } + + const auto tile_base_address = iomap_table.get_addr(tile.offset); + const auto tile_range = utils::address_range::start_length(tile_base_address, tile.size); + + if (range.inside(tile_range)) + { + ensure(tile_base_address + 1); + return { .base_address = tile_base_address, .tile = &tile }; + } + } + + return {}; + } +} diff --git a/rpcs3/Emu/RSX/Core/RSXContext.h b/rpcs3/Emu/RSX/Core/RSXContext.h new file mode 100644 index 0000000000..13fe40e77e --- /dev/null +++ b/rpcs3/Emu/RSX/Core/RSXContext.h @@ -0,0 +1,55 @@ +#pragma once + +#include +#include "Emu/Cell/lv2/sys_rsx.h" +#include "Emu/RSX/GCM.h" +#include "RSXIOMap.hpp" + +namespace rsx +{ + namespace gcm + { + enum limits + { + tiles_count = 15, + zculls_count = 8 + }; + } + + struct GCM_tile_reference + { + u32 base_address = 0; + const GcmTileInfo* tile = nullptr; + + operator bool() const + { + return !!tile; + } + }; + + struct GCM_context + { + RsxDmaControl* ctrl = nullptr; + u32 dma_address{ 0 }; + rsx_iomap_table iomap_table; + + GcmTileInfo tiles[gcm::limits::tiles_count]; + GcmZcullInfo zculls[gcm::limits::zculls_count]; + + RsxDisplayInfo display_buffers[8]; + u32 display_buffers_count{ 0 }; + u32 current_display_buffer{ 0 }; + + shared_mutex sys_rsx_mtx; + u32 device_addr{ 0 }; + u32 label_addr{ 0 }; + u32 main_mem_size{ 0 }; + u32 local_mem_size{ 0 }; + u32 rsx_event_port{ 0 }; + u32 driver_info{ 0 }; + + atomic_t unsent_gcm_events = 0; // Unsent event bits when aborting RSX/VBLANK thread (will be sent on savestate load) + + GCM_tile_reference get_tiled_memory_region(const utils::address_range& range) const; + }; +} diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index a1be7e35ec..bbae4b3c5a 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -29,6 +29,7 @@ #include "Core/RSXDisplay.h" #include "Core/RSXFrameBuffer.h" +#include "Core/RSXContext.h" #include "Core/RSXIOMap.hpp" #include "Core/RSXVertexTypes.h" @@ -147,7 +148,7 @@ namespace rsx }; // TODO: This class is a mess, this needs to be broken into smaller chunks, like I did for RSXFIFO and RSXZCULL (kd) - class thread : public cpu_thread + class thread : public cpu_thread, public GCM_context { u64 timestamp_ctrl = 0; u64 timestamp_subvalue = 0; @@ -204,11 +205,8 @@ namespace rsx u32 m_pause_after_x_flips = 0; public: - RsxDmaControl* ctrl = nullptr; - u32 dma_address{0}; - rsx_iomap_table iomap_table; - u32 restore_point = 0; atomic_t new_get_put = u64{umax}; + u32 restore_point = 0; u32 dbg_step_pc = 0; u32 last_known_code_start = 0; atomic_t external_interrupt_lock{ 0 }; @@ -257,9 +255,6 @@ namespace rsx atomic_bitmask_t async_flip_requested{}; u8 async_flip_buffer{ 0 }; - GcmTileInfo tiles[limits::tiles_count]; - GcmZcullInfo zculls[limits::zculls_count]; - void capture_frame(const std::string &name); const backend_configuration& get_backend_config() const { return backend_config; } @@ -276,20 +271,6 @@ namespace rsx atomic_t requested_vsync{true}; atomic_t enable_second_vhandler{false}; - RsxDisplayInfo display_buffers[8]; - u32 display_buffers_count{0}; - u32 current_display_buffer{0}; - - shared_mutex sys_rsx_mtx; - u32 device_addr{0}; - u32 label_addr{0}; - u32 main_mem_size{0}; - u32 local_mem_size{0}; - u32 rsx_event_port{0}; - u32 driver_info{0}; - - atomic_t unsent_gcm_events = 0; // Unsent event bits when aborting RSX/VBLANK thread (will be sent on savestate load) - bool send_event(u64, u64, u64); std::array m_textures_dirty; diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index 9854e484ae..8b22fd6b69 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -91,6 +91,7 @@ + @@ -558,6 +559,7 @@ + diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index b780716bbf..de842b5845 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -1168,6 +1168,9 @@ Emu\Io + + Emu\GPU\RSX\Core + @@ -2374,6 +2377,9 @@ Utilities + + Emu\GPU\RSX\Core +