2020-12-05 13:08:24 +01:00
|
|
|
#pragma once
|
2015-12-02 10:23:25 +01:00
|
|
|
|
2020-03-26 08:05:20 +01:00
|
|
|
#include <queue>
|
2016-02-01 22:50:02 +01:00
|
|
|
#include <deque>
|
2019-11-30 13:44:47 +01:00
|
|
|
|
2018-09-24 15:03:25 +02:00
|
|
|
#include "RSXFIFO.h"
|
2019-06-18 18:47:23 +02:00
|
|
|
#include "RSXOffload.h"
|
2022-05-09 20:10:40 +02:00
|
|
|
#include "RSXZCULL.h"
|
2017-11-16 22:52:21 +01:00
|
|
|
#include "rsx_utils.h"
|
2021-09-17 22:01:53 +02:00
|
|
|
#include "Common/bitfield.hpp"
|
|
|
|
|
#include "Common/profiling_timer.hpp"
|
2020-12-13 12:54:43 +01:00
|
|
|
#include "Common/texture_cache_types.h"
|
2021-05-12 23:56:01 +02:00
|
|
|
#include "Program/RSXVertexProgram.h"
|
|
|
|
|
#include "Program/RSXFragmentProgram.h"
|
2012-11-15 00:39:56 +01:00
|
|
|
|
2014-08-25 16:56:13 +02:00
|
|
|
#include "Utilities/Thread.h"
|
2016-04-27 00:27:24 +02:00
|
|
|
#include "Utilities/geometry.h"
|
2018-05-13 11:18:05 +02:00
|
|
|
#include "Capture/rsx_trace.h"
|
|
|
|
|
#include "Capture/rsx_replay.h"
|
2015-11-06 00:56:27 +01:00
|
|
|
|
2017-07-26 04:33:32 +02:00
|
|
|
#include "Emu/Cell/lv2/sys_rsx.h"
|
2019-09-26 17:32:31 +02:00
|
|
|
#include "Emu/IdManager.h"
|
2017-07-26 04:33:32 +02:00
|
|
|
|
2023-01-07 17:20:21 +01:00
|
|
|
#include "Core/RSXDisplay.h"
|
2024-12-26 19:08:54 +01:00
|
|
|
#include "Core/RSXDrawCommands.h"
|
|
|
|
|
#include "Core/RSXDriverState.h"
|
2023-01-07 17:20:21 +01:00
|
|
|
#include "Core/RSXFrameBuffer.h"
|
2023-09-08 02:47:12 +02:00
|
|
|
#include "Core/RSXContext.h"
|
2023-01-07 17:20:21 +01:00
|
|
|
#include "Core/RSXVertexTypes.h"
|
|
|
|
|
|
2024-04-23 00:12:34 +02:00
|
|
|
#include "NV47/FW/GRAPH_backend.h"
|
|
|
|
|
|
2020-12-06 13:15:19 +01:00
|
|
|
extern atomic_t<bool> g_user_asked_for_frame_capture;
|
2023-01-09 18:03:01 +01:00
|
|
|
extern atomic_t<bool> g_disable_frame_limit;
|
2018-05-13 11:18:05 +02:00
|
|
|
extern rsx::frame_trace_data frame_debug;
|
|
|
|
|
extern rsx::frame_capture_data frame_capture;
|
2015-11-06 00:56:27 +01:00
|
|
|
|
2015-10-04 00:45:26 +02:00
|
|
|
namespace rsx
|
2013-11-09 22:29:49 +01:00
|
|
|
{
|
2024-10-23 01:47:19 +02:00
|
|
|
class RSXDMAWriter;
|
|
|
|
|
|
2024-04-10 03:02:12 +02:00
|
|
|
struct context;
|
|
|
|
|
|
2020-02-25 22:42:29 +01:00
|
|
|
namespace overlays
|
|
|
|
|
{
|
|
|
|
|
class display_manager;
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-15 16:50:41 +01:00
|
|
|
enum framebuffer_creation_context : u8
|
|
|
|
|
{
|
|
|
|
|
context_draw = 0,
|
|
|
|
|
context_clear_color = 1,
|
|
|
|
|
context_clear_depth = 2,
|
|
|
|
|
context_clear_all = context_clear_color | context_clear_depth
|
|
|
|
|
};
|
|
|
|
|
|
2022-05-16 22:38:11 +02:00
|
|
|
enum eng_interrupt_reason : u32
|
|
|
|
|
{
|
|
|
|
|
backend_interrupt = 0x0001, // Backend-related interrupt
|
|
|
|
|
memory_config_interrupt = 0x0002, // Memory configuration changed
|
|
|
|
|
display_interrupt = 0x0004, // Display handling
|
2022-05-20 23:53:48 +02:00
|
|
|
pipe_flush_interrupt = 0x0008, // Flush pipelines
|
2023-01-10 14:00:47 +01:00
|
|
|
dma_control_interrupt = 0x0010, // DMA interrupt
|
2022-05-16 22:38:11 +02:00
|
|
|
|
2022-05-20 23:53:48 +02:00
|
|
|
all_interrupt_bits = memory_config_interrupt | backend_interrupt | display_interrupt | pipe_flush_interrupt
|
2022-05-16 22:38:11 +02:00
|
|
|
};
|
|
|
|
|
|
2019-10-24 22:02:42 +02:00
|
|
|
enum result_flags: u8
|
|
|
|
|
{
|
|
|
|
|
result_none = 0,
|
|
|
|
|
result_error = 1,
|
|
|
|
|
result_zcull_intr = 2
|
|
|
|
|
};
|
|
|
|
|
|
2016-01-20 14:23:25 +01:00
|
|
|
u32 get_vertex_type_size_on_host(vertex_base_type type, u32 size);
|
2015-12-01 14:55:15 +01:00
|
|
|
|
2024-05-21 09:34:51 +02:00
|
|
|
u32 get_address(u32 offset, u32 location, u32 size_to_check = 0, std::source_location src_loc = std::source_location::current());
|
2014-02-02 21:47:17 +01:00
|
|
|
|
2019-10-13 21:37:10 +02:00
|
|
|
struct backend_configuration
|
|
|
|
|
{
|
2022-12-04 23:33:02 +01:00
|
|
|
bool supports_multidraw; // Draw call batching
|
|
|
|
|
bool supports_hw_a2c; // Alpha to coverage
|
2025-02-09 19:15:23 +01:00
|
|
|
bool supports_hw_a2c_1spp; // Alpha to coverage at 1 sample per pixel
|
2022-12-04 23:33:02 +01:00
|
|
|
bool supports_hw_renormalization; // Should be true on NV hardware which matches PS3 texture renormalization behaviour
|
|
|
|
|
bool supports_hw_msaa; // MSAA support
|
|
|
|
|
bool supports_hw_a2one; // Alpha to one
|
|
|
|
|
bool supports_hw_conditional_render; // Conditional render
|
|
|
|
|
bool supports_passthrough_dma; // DMA passthrough
|
|
|
|
|
bool supports_asynchronous_compute; // Async compute
|
|
|
|
|
bool supports_host_gpu_labels; // Advanced host synchronization
|
|
|
|
|
bool supports_normalized_barycentrics; // Basically all GPUs except NVIDIA have properly normalized barycentrics
|
2019-10-13 21:37:10 +02:00
|
|
|
};
|
|
|
|
|
|
2023-07-10 23:47:56 +02:00
|
|
|
class sampled_image_descriptor_base;
|
2017-10-30 13:27:22 +01:00
|
|
|
|
2022-09-27 19:34:11 +02:00
|
|
|
struct desync_fifo_cmd_info
|
|
|
|
|
{
|
|
|
|
|
u32 cmd;
|
|
|
|
|
u64 timestamp;
|
|
|
|
|
};
|
|
|
|
|
|
2023-01-07 17:20:21 +01:00
|
|
|
// TODO: This class is a mess, this needs to be broken into smaller chunks, like I did for RSXFIFO and RSXZCULL (kd)
|
2024-04-23 00:12:34 +02:00
|
|
|
class thread : public cpu_thread, public GCM_context, public GRAPH_backend
|
2015-10-04 00:45:26 +02:00
|
|
|
{
|
2018-07-24 23:33:55 +02:00
|
|
|
u64 timestamp_ctrl = 0;
|
|
|
|
|
u64 timestamp_subvalue = 0;
|
2022-05-14 17:41:33 +02:00
|
|
|
u64 m_cycles_counter = 0;
|
2018-07-24 23:33:55 +02:00
|
|
|
|
2019-09-27 20:02:49 +02:00
|
|
|
display_flip_info_t m_queued_flip{};
|
2019-09-19 19:08:06 +02:00
|
|
|
|
2021-01-22 09:11:54 +01:00
|
|
|
void cpu_task() override;
|
2015-10-04 00:45:26 +02:00
|
|
|
protected:
|
2019-08-25 17:47:49 +02:00
|
|
|
|
2017-09-07 21:32:52 +02:00
|
|
|
s32 m_skip_frame_ctr = 0;
|
2019-09-19 19:08:06 +02:00
|
|
|
bool skip_current_frame = false;
|
2017-09-07 21:32:52 +02:00
|
|
|
|
2022-12-04 23:51:14 +01:00
|
|
|
primitive_class m_current_draw_mode = primitive_class::polygon;
|
|
|
|
|
|
2019-10-13 21:37:10 +02:00
|
|
|
backend_configuration backend_config{};
|
2017-09-07 21:32:52 +02:00
|
|
|
|
2018-09-24 15:03:25 +02:00
|
|
|
// FIFO
|
2020-03-24 10:47:13 +01:00
|
|
|
public:
|
2018-09-24 15:03:25 +02:00
|
|
|
std::unique_ptr<FIFO::FIFO_control> fifo_ctrl;
|
2023-01-09 18:03:01 +01:00
|
|
|
atomic_t<bool> rsx_thread_running{ false };
|
2021-01-22 09:11:54 +01:00
|
|
|
std::vector<std::pair<u32, u32>> dump_callstack_list() const override;
|
2023-06-24 15:56:49 +02:00
|
|
|
std::string dump_misc() const override;
|
2021-01-15 19:28:45 +01:00
|
|
|
|
2020-03-24 10:47:13 +01:00
|
|
|
protected:
|
2018-11-07 10:34:03 +01:00
|
|
|
FIFO::flattening_helper m_flattener;
|
2019-09-28 09:29:16 +02:00
|
|
|
u32 fifo_ret_addr = RSX_CALL_STACK_EMPTY;
|
|
|
|
|
u32 saved_fifo_ret = RSX_CALL_STACK_EMPTY;
|
2022-07-11 09:26:38 +02:00
|
|
|
u32 restore_fifo_cmd = 0;
|
|
|
|
|
u32 restore_fifo_count = 0;
|
2018-09-24 15:03:25 +02:00
|
|
|
|
2018-05-23 11:55:14 +02:00
|
|
|
// Occlusion query
|
2017-11-16 22:52:21 +01:00
|
|
|
bool zcull_surface_active = false;
|
2018-03-05 12:09:43 +01:00
|
|
|
std::unique_ptr<reports::ZCULL_control> zcull_ctrl;
|
2017-11-16 22:52:21 +01:00
|
|
|
|
2018-05-23 11:55:14 +02:00
|
|
|
// Framebuffer setup
|
2017-11-16 22:52:21 +01:00
|
|
|
rsx::gcm_framebuffer_info m_surface_info[rsx::limits::color_buffers_count];
|
|
|
|
|
rsx::gcm_framebuffer_info m_depth_surface_info;
|
2020-06-14 13:18:34 +02:00
|
|
|
framebuffer_layout m_framebuffer_layout{};
|
2017-11-16 22:52:21 +01:00
|
|
|
|
2018-05-23 11:55:14 +02:00
|
|
|
// Overlays
|
2019-08-26 02:08:16 +02:00
|
|
|
rsx::overlays::display_manager* m_overlay_manager = nullptr;
|
2018-05-23 11:55:14 +02:00
|
|
|
|
2024-09-11 20:32:27 +02:00
|
|
|
atomic_t<u64> m_display_rate_fetch_count = 0;
|
|
|
|
|
atomic_t<f64> m_cached_display_rate = 60.;
|
|
|
|
|
f64 get_cached_display_refresh_rate();
|
|
|
|
|
virtual f64 get_display_refresh_rate() const = 0;
|
|
|
|
|
|
2018-05-23 11:55:14 +02:00
|
|
|
// Invalidated memory range
|
2018-09-22 02:14:26 +02:00
|
|
|
address_range m_invalidated_memory_range;
|
2018-01-17 17:14:00 +01:00
|
|
|
|
2019-06-18 20:31:35 +02:00
|
|
|
// Profiler
|
|
|
|
|
rsx::profiling_timer m_profiler;
|
2024-05-16 01:38:50 +02:00
|
|
|
frame_statistics_t m_frame_stats{};
|
2019-06-18 20:31:35 +02:00
|
|
|
|
2022-10-29 19:53:00 +02:00
|
|
|
// Savestates related
|
|
|
|
|
u32 m_pause_after_x_flips = 0;
|
2022-07-04 15:02:17 +02:00
|
|
|
|
2024-04-10 03:02:12 +02:00
|
|
|
// Context
|
|
|
|
|
context* m_ctx = nullptr;
|
|
|
|
|
|
2024-10-19 02:14:29 +02:00
|
|
|
// Host DMA
|
|
|
|
|
std::unique_ptr<RSXDMAWriter> m_host_dma_ctrl;
|
|
|
|
|
|
2024-12-26 19:08:54 +01:00
|
|
|
// Draw call management
|
|
|
|
|
draw_command_processor m_draw_processor;
|
|
|
|
|
|
2015-10-04 00:45:26 +02:00
|
|
|
public:
|
2023-01-09 18:03:01 +01:00
|
|
|
atomic_t<u64> new_get_put = u64{umax};
|
2023-09-08 02:47:12 +02:00
|
|
|
u32 restore_point = 0;
|
2021-02-19 12:53:09 +01:00
|
|
|
u32 dbg_step_pc = 0;
|
2022-03-25 16:17:25 +01:00
|
|
|
u32 last_known_code_start = 0;
|
2020-02-11 22:36:46 +01:00
|
|
|
atomic_t<u32> external_interrupt_lock{ 0 };
|
2017-12-09 11:14:00 +01:00
|
|
|
atomic_t<bool> external_interrupt_ack{ false };
|
2023-07-31 22:57:26 +02:00
|
|
|
atomic_t<u32> is_initialized{0};
|
2024-12-26 19:08:54 +01:00
|
|
|
|
2020-04-10 21:25:59 +02:00
|
|
|
bool is_fifo_idle() const;
|
2019-09-29 19:54:33 +02:00
|
|
|
void flush_fifo();
|
2021-08-13 20:46:38 +02:00
|
|
|
|
2022-03-25 16:17:25 +01:00
|
|
|
// Returns [count of found commands, PC of their start]
|
2023-08-31 10:35:23 +02:00
|
|
|
std::pair<u32, u32> try_get_pc_of_x_cmds_backwards(s32 count, u32 get) const;
|
2022-03-25 16:17:25 +01:00
|
|
|
|
2024-05-21 09:34:51 +02:00
|
|
|
void recover_fifo(std::source_location src_loc = std::source_location::current());
|
2021-08-13 20:46:38 +02:00
|
|
|
|
2022-06-30 10:22:17 +02:00
|
|
|
static void fifo_wake_delay(u64 div = 1);
|
2020-02-11 06:00:30 +01:00
|
|
|
u32 get_fifo_cmd() const;
|
2021-02-03 19:14:31 +01:00
|
|
|
|
2023-07-12 10:02:12 +02:00
|
|
|
void dump_regs(std::string&, std::any& custom_data) const override;
|
2021-02-13 15:50:07 +01:00
|
|
|
void cpu_wait(bs_t<cpu_flag> old) override;
|
2015-10-04 00:45:26 +02:00
|
|
|
|
2021-05-20 06:00:22 +02:00
|
|
|
static constexpr u32 id_base = 0x5555'5555; // See get_current_cpu_thread()
|
|
|
|
|
|
2018-05-23 11:55:14 +02:00
|
|
|
// Performance approximation counters
|
2018-02-28 12:46:39 +01:00
|
|
|
struct
|
|
|
|
|
{
|
2018-05-23 11:55:14 +02:00
|
|
|
atomic_t<u64> idle_time{ 0 }; // Time spent idling in microseconds
|
|
|
|
|
u64 last_update_timestamp = 0; // Timestamp of last load update
|
|
|
|
|
u64 FIFO_idle_timestamp = 0; // Timestamp of when FIFO queue becomes idle
|
2023-01-07 17:20:21 +01:00
|
|
|
FIFO::state state = FIFO::state::running;
|
2018-02-28 12:46:39 +01:00
|
|
|
u32 approximate_load = 0;
|
|
|
|
|
u32 sampled_frames = 0;
|
|
|
|
|
}
|
|
|
|
|
performance_counters;
|
|
|
|
|
|
2018-07-20 16:22:21 +02:00
|
|
|
enum class flip_request : u32
|
|
|
|
|
{
|
2018-09-22 09:51:48 +02:00
|
|
|
emu_requested = 1,
|
|
|
|
|
native_ui = 2,
|
2018-07-20 16:22:21 +02:00
|
|
|
|
2018-09-22 09:51:48 +02:00
|
|
|
any = emu_requested | native_ui
|
2018-07-20 16:22:21 +02:00
|
|
|
};
|
|
|
|
|
|
2018-09-22 09:51:48 +02:00
|
|
|
atomic_bitmask_t<flip_request> async_flip_requested{};
|
2018-07-20 16:22:21 +02:00
|
|
|
u8 async_flip_buffer{ 0 };
|
2018-01-17 17:14:00 +01:00
|
|
|
|
2024-05-16 01:38:50 +02:00
|
|
|
void capture_frame(const std::string& name);
|
2021-05-25 19:04:45 +02:00
|
|
|
const backend_configuration& get_backend_config() const { return backend_config; }
|
2016-01-20 13:46:58 +01:00
|
|
|
|
2024-12-26 19:08:54 +01:00
|
|
|
const draw_command_processor* draw_processor() const { return &m_draw_processor; }
|
|
|
|
|
|
2015-10-04 00:45:26 +02:00
|
|
|
public:
|
2024-12-22 19:59:48 +01:00
|
|
|
shared_ptr<named_thread<ppu_thread>> intr_thread;
|
2016-07-27 23:43:22 +02:00
|
|
|
|
2017-07-26 04:57:43 +02:00
|
|
|
// I hate this flag, but until hle is closer to lle, its needed
|
|
|
|
|
bool isHLE{ false };
|
2022-07-04 15:02:17 +02:00
|
|
|
bool serialized = false;
|
2017-07-26 04:57:43 +02:00
|
|
|
|
2024-05-16 01:38:50 +02:00
|
|
|
u32 flip_status = CELL_GCM_DISPLAY_FLIP_STATUS_DONE;
|
|
|
|
|
int debug_level = CELL_GCM_DEBUG_LEVEL0;
|
2015-10-04 00:45:26 +02:00
|
|
|
|
2022-05-21 18:39:14 +02:00
|
|
|
atomic_t<bool> requested_vsync{true};
|
2017-07-26 04:57:43 +02:00
|
|
|
atomic_t<bool> enable_second_vhandler{false};
|
2017-07-26 04:33:32 +02:00
|
|
|
|
2022-07-07 09:35:24 +02:00
|
|
|
bool send_event(u64, u64, u64);
|
2015-10-04 00:45:26 +02:00
|
|
|
|
2020-03-12 20:22:49 +01:00
|
|
|
std::array<bool, 16> m_textures_dirty;
|
|
|
|
|
std::array<bool, 4> m_vertex_textures_dirty;
|
2018-12-12 09:58:44 +01:00
|
|
|
rsx::framebuffer_creation_context m_current_framebuffer_context = rsx::framebuffer_creation_context::context_draw;
|
2018-07-23 23:55:15 +02:00
|
|
|
|
2022-05-16 22:38:11 +02:00
|
|
|
rsx::atomic_bitmask_t<rsx::eng_interrupt_reason> m_eng_interrupt_mask;
|
2023-01-25 13:03:52 +01:00
|
|
|
rsx::bitmask_t<rsx::pipeline_state> m_graphics_state;
|
2021-04-29 20:28:17 +02:00
|
|
|
u64 ROP_sync_timestamp = 0;
|
2017-06-30 00:20:23 +02:00
|
|
|
|
2018-07-09 20:31:31 +02:00
|
|
|
program_hash_util::fragment_program_utils::fragment_program_metadata current_fp_metadata = {};
|
|
|
|
|
program_hash_util::vertex_program_utils::vertex_program_metadata current_vp_metadata = {};
|
|
|
|
|
|
2016-01-19 18:23:09 +01:00
|
|
|
std::array<u32, 4> get_color_surface_addresses() const;
|
|
|
|
|
u32 get_zeta_surface_address() const;
|
2017-07-31 13:38:28 +02:00
|
|
|
|
2022-12-10 09:49:46 +01:00
|
|
|
protected:
|
2019-08-27 13:55:45 +02:00
|
|
|
void get_framebuffer_layout(rsx::framebuffer_creation_context context, framebuffer_layout &layout);
|
2019-07-20 13:58:05 +02:00
|
|
|
bool get_scissor(areau& region, bool clip_viewport);
|
2018-07-23 23:55:15 +02:00
|
|
|
|
2017-07-31 13:38:28 +02:00
|
|
|
RSXVertexProgram current_vertex_program = {};
|
|
|
|
|
RSXFragmentProgram current_fragment_program = {};
|
|
|
|
|
|
2021-05-12 23:56:01 +02:00
|
|
|
vertex_program_texture_state current_vp_texture_state = {};
|
|
|
|
|
fragment_program_texture_state current_fp_texture_state = {};
|
|
|
|
|
|
2020-12-13 11:39:58 +01:00
|
|
|
// Runs shader prefetch and resolves pipeline status flags
|
|
|
|
|
void analyse_current_rsx_pipeline();
|
|
|
|
|
|
2020-12-03 19:11:32 +01:00
|
|
|
// Prefetch and analyze the currently active fragment program ucode
|
|
|
|
|
void prefetch_fragment_program();
|
|
|
|
|
|
|
|
|
|
// Prefetch and analyze the currently active vertex program ucode
|
|
|
|
|
void prefetch_vertex_program();
|
|
|
|
|
|
|
|
|
|
void get_current_vertex_program(const std::array<std::unique_ptr<rsx::sampled_image_descriptor_base>, rsx::limits::vertex_textures_count>& sampler_descriptors);
|
2017-02-10 10:08:46 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets current fragment program and associated fragment state
|
|
|
|
|
*/
|
2017-10-30 13:27:22 +01:00
|
|
|
void get_current_fragment_program(const std::array<std::unique_ptr<rsx::sampled_image_descriptor_base>, rsx::limits::fragment_textures_count>& sampler_descriptors);
|
2020-06-14 13:18:34 +02:00
|
|
|
|
2020-03-28 11:17:40 +01:00
|
|
|
public:
|
|
|
|
|
bool invalidate_fragment_program(u32 dst_dma, u32 dst_offset, u32 size);
|
2020-06-14 13:18:34 +02:00
|
|
|
void on_framebuffer_options_changed(u32 opt);
|
2017-10-30 13:27:22 +01:00
|
|
|
|
2015-10-04 00:45:26 +02:00
|
|
|
public:
|
2020-03-07 23:11:35 +01:00
|
|
|
u64 target_rsx_flip_time = 0;
|
2017-11-10 15:31:02 +01:00
|
|
|
u64 int_flip_index = 0;
|
2022-04-13 21:29:26 +02:00
|
|
|
u64 last_guest_flip_timestamp = 0;
|
|
|
|
|
u64 last_host_flip_timestamp = 0;
|
|
|
|
|
|
2018-02-09 15:49:37 +01:00
|
|
|
vm::ptr<void(u32)> flip_handler = vm::null;
|
|
|
|
|
vm::ptr<void(u32)> user_handler = vm::null;
|
|
|
|
|
vm::ptr<void(u32)> vblank_handler = vm::null;
|
2022-06-04 19:16:53 +02:00
|
|
|
vm::ptr<void(u32)> queue_handler = vm::null;
|
2019-10-17 17:49:19 +02:00
|
|
|
atomic_t<u64> vblank_count{0};
|
2020-03-09 20:06:38 +01:00
|
|
|
bool capture_current_frame = false;
|
2015-10-04 00:45:26 +02:00
|
|
|
|
2022-05-21 18:39:14 +02:00
|
|
|
u64 vblank_at_flip = umax;
|
2022-06-25 13:54:05 +02:00
|
|
|
u64 flip_notification_count = 0;
|
2022-05-21 18:39:14 +02:00
|
|
|
void post_vblank_event(u64 post_event_time);
|
2022-05-21 12:05:35 +02:00
|
|
|
|
2015-10-04 00:45:26 +02:00
|
|
|
public:
|
2020-04-07 12:18:41 +02:00
|
|
|
atomic_t<bool> sync_point_request = false;
|
2022-12-10 09:57:05 +01:00
|
|
|
atomic_t<bool> pause_on_draw = false;
|
2017-03-25 22:59:57 +01:00
|
|
|
bool in_begin_end = false;
|
2015-10-04 00:45:26 +02:00
|
|
|
|
2020-03-26 08:05:20 +01:00
|
|
|
std::queue<desync_fifo_cmd_info> recovered_fifo_cmds_history;
|
2022-09-06 17:59:23 +02:00
|
|
|
std::deque<frame_time_t> frame_times;
|
|
|
|
|
u32 prevent_preempt_increase_tickets = 0;
|
2022-09-27 19:34:11 +02:00
|
|
|
u64 preempt_fail_old_preempt_count = 0;
|
2022-09-06 17:59:23 +02:00
|
|
|
|
2018-03-13 14:34:31 +01:00
|
|
|
atomic_t<s32> async_tasks_pending{ 0 };
|
|
|
|
|
|
2019-11-30 13:44:47 +01:00
|
|
|
reports::conditional_render_eval cond_render_ctrl;
|
|
|
|
|
|
2018-10-11 00:17:19 +02:00
|
|
|
virtual u64 get_cycles() = 0;
|
2019-09-26 17:32:31 +02:00
|
|
|
virtual ~thread();
|
|
|
|
|
|
|
|
|
|
static constexpr auto thread_name = "rsx::thread"sv;
|
2018-10-11 00:17:19 +02:00
|
|
|
|
2015-10-04 00:45:26 +02:00
|
|
|
protected:
|
2022-07-04 15:02:17 +02:00
|
|
|
thread(utils::serial* ar);
|
|
|
|
|
|
|
|
|
|
thread() : thread(static_cast<utils::serial*>(nullptr)) {}
|
|
|
|
|
|
2018-10-11 00:17:19 +02:00
|
|
|
virtual void on_task();
|
|
|
|
|
virtual void on_exit();
|
2018-02-09 15:49:37 +01:00
|
|
|
|
2017-02-16 19:29:56 +01:00
|
|
|
/**
|
|
|
|
|
* Execute a backend local task queue
|
|
|
|
|
*/
|
2023-01-07 17:20:21 +01:00
|
|
|
virtual void do_local_task(FIFO::state state);
|
2015-11-26 09:06:29 +01:00
|
|
|
|
2018-10-01 22:05:51 +02:00
|
|
|
virtual void emit_geometry(u32) {}
|
|
|
|
|
|
2018-09-24 15:03:25 +02:00
|
|
|
void run_FIFO();
|
|
|
|
|
|
2015-10-04 00:45:26 +02:00
|
|
|
public:
|
2021-04-19 13:22:03 +02:00
|
|
|
thread(const thread&) = delete;
|
|
|
|
|
thread& operator=(const thread&) = delete;
|
2022-07-04 15:02:17 +02:00
|
|
|
void save(utils::serial& ar);
|
2021-04-19 13:22:03 +02:00
|
|
|
|
2021-04-09 21:12:47 +02:00
|
|
|
virtual void clear_surface(u32 /*arg*/) {}
|
2015-10-04 00:45:26 +02:00
|
|
|
virtual void begin();
|
|
|
|
|
virtual void end();
|
2018-11-21 12:38:56 +01:00
|
|
|
virtual void execute_nop_draw();
|
2015-10-04 00:45:26 +02:00
|
|
|
|
2015-11-26 09:06:29 +01:00
|
|
|
virtual void on_init_thread() = 0;
|
2019-09-17 13:26:03 +02:00
|
|
|
virtual void on_frame_end(u32 buffer, bool forced = false);
|
2019-09-19 19:08:06 +02:00
|
|
|
virtual void flip(const display_flip_info_t& info) = 0;
|
2018-07-24 23:33:55 +02:00
|
|
|
virtual u64 timestamp();
|
2017-06-18 16:53:02 +02:00
|
|
|
virtual bool on_access_violation(u32 /*address*/, bool /*is_writing*/) { return false; }
|
2019-08-25 17:47:49 +02:00
|
|
|
virtual void on_invalidate_memory_range(const address_range & /*range*/, rsx::invalidation_cause) {}
|
2017-11-02 13:10:07 +01:00
|
|
|
virtual void notify_tile_unbound(u32 /*tile*/) {}
|
2015-10-04 00:45:26 +02:00
|
|
|
|
2019-12-07 14:28:35 +01:00
|
|
|
// control
|
2024-11-25 21:21:25 +01:00
|
|
|
virtual void renderctl(u32 request_code, void* args);
|
2019-12-07 14:28:35 +01:00
|
|
|
|
2018-05-23 11:55:14 +02:00
|
|
|
// zcull
|
2018-03-05 12:09:43 +01:00
|
|
|
void notify_zcull_info_changed();
|
|
|
|
|
void clear_zcull_stats(u32 type);
|
|
|
|
|
void check_zcull_status(bool framebuffer_swap);
|
|
|
|
|
void get_zcull_stats(u32 type, vm::addr_t sink);
|
2019-10-24 22:02:42 +02:00
|
|
|
u32 copy_zcull_stats(u32 memory_range_start, u32 memory_range, u32 destination);
|
2018-03-05 12:09:43 +01:00
|
|
|
|
2019-11-30 13:44:47 +01:00
|
|
|
void enable_conditional_rendering(vm::addr_t ref);
|
|
|
|
|
void disable_conditional_rendering();
|
2019-12-10 05:56:44 +01:00
|
|
|
virtual void begin_conditional_rendering(const std::vector<reports::occlusion_query_info*>& sources);
|
2019-11-30 13:44:47 +01:00
|
|
|
virtual void end_conditional_rendering();
|
|
|
|
|
|
2018-05-23 11:55:14 +02:00
|
|
|
// sync
|
2018-03-05 12:09:43 +01:00
|
|
|
void sync();
|
2019-10-24 22:02:42 +02:00
|
|
|
flags32_t read_barrier(u32 memory_address, u32 memory_range, bool unconditional);
|
2023-01-07 17:20:21 +01:00
|
|
|
virtual void sync_hint(FIFO::interrupt_hint hint, reports::sync_hint_payload_t payload);
|
2022-02-19 18:22:52 +01:00
|
|
|
virtual bool release_GCM_label(u32 /*address*/, u32 /*value*/) { return false; }
|
2018-09-25 14:21:04 +02:00
|
|
|
|
2017-06-25 22:14:56 +02:00
|
|
|
protected:
|
|
|
|
|
|
2017-07-31 13:38:28 +02:00
|
|
|
/**
|
|
|
|
|
* Computes VRAM requirements needed to upload raw vertex streams
|
|
|
|
|
* result.first contains persistent memory requirements
|
|
|
|
|
* result.second contains volatile memory requirements
|
|
|
|
|
*/
|
2019-01-21 19:07:27 +01:00
|
|
|
std::pair<u32, u32> calculate_memory_requirements(const vertex_input_layout& layout, u32 first_vertex, u32 vertex_count);
|
2017-06-25 22:14:56 +02:00
|
|
|
|
2022-09-14 14:03:51 +02:00
|
|
|
void evaluate_cpu_usage_reduction_limits();
|
|
|
|
|
|
2016-01-20 15:12:49 +01:00
|
|
|
private:
|
2018-03-05 12:09:43 +01:00
|
|
|
shared_mutex m_mtx_task;
|
2016-01-20 15:12:49 +01:00
|
|
|
|
2018-07-20 16:22:21 +02:00
|
|
|
void handle_emu_flip(u32 buffer);
|
|
|
|
|
void handle_invalidated_memory_range();
|
2016-01-20 15:12:49 +01:00
|
|
|
|
|
|
|
|
public:
|
2024-12-26 19:08:54 +01:00
|
|
|
|
|
|
|
|
draw_command_processor& GRAPH_frontend() { return m_draw_processor; }
|
|
|
|
|
|
2018-09-22 16:45:55 +02:00
|
|
|
/**
|
|
|
|
|
* Notify that a section of memory has been mapped
|
|
|
|
|
* If there is a notify_memory_unmapped request on this range yet to be handled,
|
|
|
|
|
* handles it immediately.
|
|
|
|
|
*/
|
|
|
|
|
void on_notify_memory_mapped(u32 address_base, u32 size);
|
|
|
|
|
|
2024-10-31 21:30:40 +01:00
|
|
|
/**
|
|
|
|
|
* Notify that a section of memory is to be unmapped
|
|
|
|
|
* Any data held in the defined range is discarded
|
2024-11-01 07:39:57 +01:00
|
|
|
* Sets optional unmap event data
|
2024-10-31 21:30:40 +01:00
|
|
|
*/
|
2024-11-01 07:39:57 +01:00
|
|
|
void on_notify_pre_memory_unmapped(u32 address_base, u32 size, std::vector<std::pair<u64, u64>>& event_data);
|
2024-10-31 21:30:40 +01:00
|
|
|
|
2018-05-23 11:55:14 +02:00
|
|
|
/**
|
|
|
|
|
* Notify that a section of memory has been unmapped
|
|
|
|
|
* Any data held in the defined range is discarded
|
|
|
|
|
*/
|
2024-11-01 07:39:57 +01:00
|
|
|
void on_notify_post_memory_unmapped(u64 event_data1, u64 event_data2);
|
2018-05-23 11:55:14 +02:00
|
|
|
|
2018-05-29 13:53:16 +02:00
|
|
|
/**
|
|
|
|
|
* Notify to check internal state during semaphore wait
|
|
|
|
|
*/
|
2019-08-25 17:47:49 +02:00
|
|
|
virtual void on_semaphore_acquire_wait() {}
|
2018-05-29 13:53:16 +02:00
|
|
|
|
2024-12-28 22:31:20 +01:00
|
|
|
/**
|
|
|
|
|
* Load an image from memory with optional scaling and rotation.
|
|
|
|
|
* Returns false to tell the HW decoder to perform the operation on the CPU as a fallback when the operation cannot be safely accelerated.
|
|
|
|
|
*/
|
|
|
|
|
virtual bool scaled_image_from_memory(const blit_src_info& /*src_info*/, const blit_dst_info& /*dst_info*/, bool /*interpolate*/) { return false; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Program public "get" handlers
|
2019-05-11 10:14:56 +02:00
|
|
|
virtual std::pair<std::string, std::string> get_programs() const { return std::make_pair("", ""); }
|
2016-01-20 13:46:58 +01:00
|
|
|
|
2024-12-28 22:31:20 +01:00
|
|
|
bool is_current_vertex_program_instanced() const { return !!(current_vertex_program.ctrl & RSX_SHADER_CONTROL_INSTANCED_CONSTANTS); }
|
2017-03-15 13:32:36 +01:00
|
|
|
|
2025-01-09 01:22:12 +01:00
|
|
|
virtual bool is_current_program_interpreted() const { return false; }
|
|
|
|
|
|
2015-10-04 00:45:26 +02:00
|
|
|
public:
|
|
|
|
|
void reset();
|
2019-06-29 00:27:49 +02:00
|
|
|
void init(u32 ctrlAddress);
|
2015-10-04 00:45:26 +02:00
|
|
|
|
2018-07-20 16:22:21 +02:00
|
|
|
// Emu App/Game flip, only immediately flips when called from rsxthread
|
2022-07-04 15:02:17 +02:00
|
|
|
bool request_emu_flip(u32 buffer);
|
2018-07-20 16:22:21 +02:00
|
|
|
|
2017-12-09 11:14:00 +01:00
|
|
|
void pause();
|
|
|
|
|
void unpause();
|
2020-02-11 22:36:46 +01:00
|
|
|
void wait_pause();
|
2018-01-17 17:14:00 +01:00
|
|
|
|
2019-08-25 17:47:49 +02:00
|
|
|
// Get RSX approximate load in %
|
2018-02-28 12:46:39 +01:00
|
|
|
u32 get_load();
|
2019-08-25 17:47:49 +02:00
|
|
|
|
2022-05-14 16:43:43 +02:00
|
|
|
// Get stats object
|
|
|
|
|
frame_statistics_t& get_stats() { return m_frame_stats; }
|
|
|
|
|
|
2019-08-25 17:47:49 +02:00
|
|
|
// Returns true if the current thread is the active RSX thread
|
2021-09-25 01:01:27 +02:00
|
|
|
inline bool is_current_thread() const
|
|
|
|
|
{
|
|
|
|
|
return !!cpu_thread::get_current<rsx::thread>();
|
|
|
|
|
}
|
2015-10-04 00:45:26 +02:00
|
|
|
};
|
2019-09-26 17:32:31 +02:00
|
|
|
|
|
|
|
|
inline thread* get_current_renderer()
|
|
|
|
|
{
|
2021-02-03 19:14:31 +01:00
|
|
|
return g_fxo->try_get<rsx::thread>();
|
2019-09-26 17:32:31 +02:00
|
|
|
}
|
2025-02-09 19:15:23 +01:00
|
|
|
|
|
|
|
|
inline const backend_configuration& get_renderer_backend_config()
|
|
|
|
|
{
|
|
|
|
|
return g_fxo->get<rsx::thread>().get_backend_config();
|
|
|
|
|
}
|
2015-10-04 00:45:26 +02:00
|
|
|
}
|