rsx: Refactor out more junk from rsx::thread

This commit is contained in:
kd-11 2023-09-08 03:47:12 +03:00 committed by kd-11
parent 3afc379746
commit 6a7386ddb8
5 changed files with 100 additions and 22 deletions

View File

@ -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 {};
}
}

View File

@ -0,0 +1,55 @@
#pragma once
#include <util/types.hpp>
#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<u64> 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;
};
}

View File

@ -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<u64> new_get_put = u64{umax};
u32 restore_point = 0;
u32 dbg_step_pc = 0;
u32 last_known_code_start = 0;
atomic_t<u32> external_interrupt_lock{ 0 };
@ -257,9 +255,6 @@ namespace rsx
atomic_bitmask_t<flip_request> 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<bool> requested_vsync{true};
atomic_t<bool> 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<u64> 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<bool, 16> m_textures_dirty;

View File

@ -91,6 +91,7 @@
<ClCompile Include="Emu\NP\upnp_handler.cpp" />
<ClCompile Include="Emu\perf_monitor.cpp" />
<ClCompile Include="Emu\RSX\Common\texture_cache.cpp" />
<ClCompile Include="Emu\RSX\Core\RSXContext.cpp" />
<ClCompile Include="Emu\RSX\Overlays\HomeMenu\overlay_home_menu.cpp" />
<ClCompile Include="Emu\RSX\Overlays\HomeMenu\overlay_home_menu_components.cpp" />
<ClCompile Include="Emu\RSX\Overlays\HomeMenu\overlay_home_menu_message_box.cpp" />
@ -558,6 +559,7 @@
<ClInclude Include="Emu\RSX\Common\surface_cache_dma.hpp" />
<ClInclude Include="Emu\RSX\Common\time.hpp" />
<ClInclude Include="Emu\RSX\Common\unordered_map.hpp" />
<ClInclude Include="Emu\RSX\Core\RSXContext.h" />
<ClInclude Include="Emu\RSX\Core\RSXEngLock.hpp" />
<ClInclude Include="Emu\RSX\Core\RSXFrameBuffer.h" />
<ClInclude Include="Emu\RSX\Core\RSXIOMap.hpp" />

View File

@ -1168,6 +1168,9 @@
<ClCompile Include="Emu\Io\pad_types.cpp">
<Filter>Emu\Io</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\Core\RSXContext.cpp">
<Filter>Emu\GPU\RSX\Core</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Crypto\aes.h">
@ -2374,6 +2377,9 @@
<ClInclude Include="util\bless.hpp">
<Filter>Utilities</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Core\RSXContext.h">
<Filter>Emu\GPU\RSX\Core</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="Emu\RSX\Program\GLSLSnippets\GPUDeswizzle.glsl">