GPU: Remove global indirection
This commit is contained in:
parent
c4b0430d5e
commit
26db661a05
|
@ -1875,7 +1875,7 @@ template<MemoryAccessSize size>
|
||||||
u32 Bus::HWHandlers::GPURead(PhysicalMemoryAddress address)
|
u32 Bus::HWHandlers::GPURead(PhysicalMemoryAddress address)
|
||||||
{
|
{
|
||||||
const u32 offset = address & GPU_MASK;
|
const u32 offset = address & GPU_MASK;
|
||||||
u32 value = g_gpu->ReadRegister(FIXUP_WORD_OFFSET(size, offset));
|
u32 value = g_gpu.ReadRegister(FIXUP_WORD_OFFSET(size, offset));
|
||||||
value = FIXUP_WORD_READ_VALUE(size, offset, value);
|
value = FIXUP_WORD_READ_VALUE(size, offset, value);
|
||||||
BUS_CYCLES(2);
|
BUS_CYCLES(2);
|
||||||
return value;
|
return value;
|
||||||
|
@ -1885,7 +1885,7 @@ template<MemoryAccessSize size>
|
||||||
void Bus::HWHandlers::GPUWrite(PhysicalMemoryAddress address, u32 value)
|
void Bus::HWHandlers::GPUWrite(PhysicalMemoryAddress address, u32 value)
|
||||||
{
|
{
|
||||||
const u32 offset = address & GPU_MASK;
|
const u32 offset = address & GPU_MASK;
|
||||||
g_gpu->WriteRegister(FIXUP_WORD_OFFSET(size, offset), FIXUP_WORD_WRITE_VALUE(size, offset, value));
|
g_gpu.WriteRegister(FIXUP_WORD_OFFSET(size, offset), FIXUP_WORD_WRITE_VALUE(size, offset, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<MemoryAccessSize size>
|
template<MemoryAccessSize size>
|
||||||
|
|
|
@ -802,9 +802,9 @@ TickCount DMA::TransferMemoryToDevice(u32 address, u32 increment, u32 word_count
|
||||||
{
|
{
|
||||||
case Channel::GPU:
|
case Channel::GPU:
|
||||||
{
|
{
|
||||||
if (g_gpu->BeginDMAWrite()) [[likely]]
|
if (g_gpu.BeginDMAWrite()) [[likely]]
|
||||||
{
|
{
|
||||||
if (GPUDump::Recorder* dump = g_gpu->GetGPUDump()) [[unlikely]]
|
if (GPUDump::Recorder* dump = g_gpu.GetGPUDump()) [[unlikely]]
|
||||||
{
|
{
|
||||||
// No wraparound?
|
// No wraparound?
|
||||||
dump->BeginGP0Packet(word_count);
|
dump->BeginGP0Packet(word_count);
|
||||||
|
@ -831,10 +831,10 @@ TickCount DMA::TransferMemoryToDevice(u32 address, u32 increment, u32 word_count
|
||||||
{
|
{
|
||||||
u32 value;
|
u32 value;
|
||||||
std::memcpy(&value, &ram_pointer[address], sizeof(u32));
|
std::memcpy(&value, &ram_pointer[address], sizeof(u32));
|
||||||
g_gpu->DMAWrite(address, value);
|
g_gpu.DMAWrite(address, value);
|
||||||
address = (address + increment) & mask;
|
address = (address + increment) & mask;
|
||||||
}
|
}
|
||||||
g_gpu->EndDMAWrite();
|
g_gpu.EndDMAWrite();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -900,7 +900,7 @@ TickCount DMA::TransferDeviceToMemory(u32 address, u32 increment, u32 word_count
|
||||||
switch (channel)
|
switch (channel)
|
||||||
{
|
{
|
||||||
case Channel::GPU:
|
case Channel::GPU:
|
||||||
g_gpu->DMARead(dest_pointer, word_count);
|
g_gpu.DMARead(dest_pointer, word_count);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Channel::CDROM:
|
case Channel::CDROM:
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
LOG_CHANNEL(GPU);
|
LOG_CHANNEL(GPU);
|
||||||
|
|
||||||
std::unique_ptr<GPU> g_gpu;
|
ALIGN_TO_CACHE_LINE GPU g_gpu;
|
||||||
|
|
||||||
// aligning VRAM to 4K is fine, since the ARM64 instructions compute 4K page aligned addresses
|
// aligning VRAM to 4K is fine, since the ARM64 instructions compute 4K page aligned addresses
|
||||||
// or it would be, except we want to import the memory for readbacks on metal..
|
// or it would be, except we want to import the memory for readbacks on metal..
|
||||||
|
@ -60,13 +60,13 @@ u16 g_gpu_clut[GPU_CLUT_SIZE];
|
||||||
const GPU::GP0CommandHandlerTable GPU::s_GP0_command_handler_table = GPU::GenerateGP0CommandHandlerTable();
|
const GPU::GP0CommandHandlerTable GPU::s_GP0_command_handler_table = GPU::GenerateGP0CommandHandlerTable();
|
||||||
|
|
||||||
static TimingEvent s_crtc_tick_event(
|
static TimingEvent s_crtc_tick_event(
|
||||||
"GPU CRTC Tick", 1, 1, [](void* param, TickCount ticks, TickCount ticks_late) { g_gpu->CRTCTickEvent(ticks); },
|
"GPU CRTC Tick", 1, 1, [](void* param, TickCount ticks, TickCount ticks_late) { g_gpu.CRTCTickEvent(ticks); },
|
||||||
nullptr);
|
nullptr);
|
||||||
static TimingEvent s_command_tick_event(
|
static TimingEvent s_command_tick_event(
|
||||||
"GPU Command Tick", 1, 1, [](void* param, TickCount ticks, TickCount ticks_late) { g_gpu->CommandTickEvent(ticks); },
|
"GPU Command Tick", 1, 1, [](void* param, TickCount ticks, TickCount ticks_late) { g_gpu.CommandTickEvent(ticks); },
|
||||||
nullptr);
|
nullptr);
|
||||||
static TimingEvent s_frame_done_event(
|
static TimingEvent s_frame_done_event(
|
||||||
"Frame Done", 1, 1, [](void* param, TickCount ticks, TickCount ticks_late) { g_gpu->FrameDoneEvent(ticks); },
|
"Frame Done", 1, 1, [](void* param, TickCount ticks, TickCount ticks_late) { g_gpu.FrameDoneEvent(ticks); },
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
// #define PSX_GPU_STATS
|
// #define PSX_GPU_STATS
|
||||||
|
@ -77,14 +77,7 @@ static u32 s_active_gpu_cycles_frames = 0;
|
||||||
|
|
||||||
GPU::GPU() = default;
|
GPU::GPU() = default;
|
||||||
|
|
||||||
GPU::~GPU()
|
GPU::~GPU() = default;
|
||||||
{
|
|
||||||
s_command_tick_event.Deactivate();
|
|
||||||
s_crtc_tick_event.Deactivate();
|
|
||||||
s_frame_done_event.Deactivate();
|
|
||||||
|
|
||||||
StopRecordingGPUDump();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GPU::Initialize()
|
void GPU::Initialize()
|
||||||
{
|
{
|
||||||
|
@ -104,6 +97,15 @@ void GPU::Initialize()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GPU::Shutdown()
|
||||||
|
{
|
||||||
|
s_command_tick_event.Deactivate();
|
||||||
|
s_crtc_tick_event.Deactivate();
|
||||||
|
s_frame_done_event.Deactivate();
|
||||||
|
|
||||||
|
StopRecordingGPUDump();
|
||||||
|
}
|
||||||
|
|
||||||
void GPU::UpdateSettings(const Settings& old_settings)
|
void GPU::UpdateSettings(const Settings& old_settings)
|
||||||
{
|
{
|
||||||
m_force_progressive_scan = (g_settings.display_deinterlacing_mode == DisplayDeinterlacingMode::Progressive);
|
m_force_progressive_scan = (g_settings.display_deinterlacing_mode == DisplayDeinterlacingMode::Progressive);
|
||||||
|
|
|
@ -95,6 +95,7 @@ public:
|
||||||
~GPU();
|
~GPU();
|
||||||
|
|
||||||
void Initialize();
|
void Initialize();
|
||||||
|
void Shutdown();
|
||||||
void Reset(bool clear_vram);
|
void Reset(bool clear_vram);
|
||||||
bool DoState(StateWrapper& sw, bool update_display);
|
bool DoState(StateWrapper& sw, bool update_display);
|
||||||
void DoMemoryState(StateWrapper& sw, System::MemorySaveState& mss, bool update_display);
|
void DoMemoryState(StateWrapper& sw, System::MemorySaveState& mss, bool update_display);
|
||||||
|
@ -561,6 +562,6 @@ private:
|
||||||
static const GP0CommandHandlerTable s_GP0_command_handler_table;
|
static const GP0CommandHandlerTable s_GP0_command_handler_table;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern std::unique_ptr<GPU> g_gpu;
|
extern GPU g_gpu;
|
||||||
extern u16 g_vram[VRAM_SIZE / sizeof(u16)];
|
extern u16 g_vram[VRAM_SIZE / sizeof(u16)];
|
||||||
extern u16 g_gpu_clut[GPU_CLUT_SIZE];
|
extern u16 g_gpu_clut[GPU_CLUT_SIZE];
|
||||||
|
|
|
@ -76,7 +76,7 @@ std::unique_ptr<GPUDump::Recorder> GPUDump::Recorder::Create(std::string path, s
|
||||||
|
|
||||||
ret = std::unique_ptr<Recorder>(new Recorder(std::move(fp), num_frames, std::move(path)));
|
ret = std::unique_ptr<Recorder>(new Recorder(std::move(fp), num_frames, std::move(path)));
|
||||||
ret->WriteHeaders(serial);
|
ret->WriteHeaders(serial);
|
||||||
g_gpu->WriteCurrentVideoModeToDump(ret.get());
|
g_gpu.WriteCurrentVideoModeToDump(ret.get());
|
||||||
ret->WriteCurrentVRAM();
|
ret->WriteCurrentVRAM();
|
||||||
|
|
||||||
// Write start of stream.
|
// Write start of stream.
|
||||||
|
@ -285,7 +285,7 @@ void GPUDump::Recorder::WriteHeaders(std::string_view serial)
|
||||||
|
|
||||||
// Write textual video mode.
|
// Write textual video mode.
|
||||||
BeginPacket(PacketType::TextualVideoFormat);
|
BeginPacket(PacketType::TextualVideoFormat);
|
||||||
WriteString(g_gpu->IsInPALMode() ? "PAL" : "NTSC");
|
WriteString(g_gpu.IsInPALMode() ? "PAL" : "NTSC");
|
||||||
EndPacket();
|
EndPacket();
|
||||||
|
|
||||||
// Write DuckStation version.
|
// Write DuckStation version.
|
||||||
|
@ -520,7 +520,7 @@ void GPUDump::Player::ProcessPacket(const PacketRef& pkt)
|
||||||
if (pkt.type <= PacketType::VSyncEvent)
|
if (pkt.type <= PacketType::VSyncEvent)
|
||||||
{
|
{
|
||||||
// gp0/gp1/vsync => direct to gpu
|
// gp0/gp1/vsync => direct to gpu
|
||||||
g_gpu->ProcessGPUDumpPacket(pkt.type, pkt.data);
|
g_gpu.ProcessGPUDumpPacket(pkt.type, pkt.data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3483,7 +3483,6 @@ void GPUTextureCache::ReloadTextureReplacements(bool show_info)
|
||||||
|
|
||||||
PurgeUnreferencedTexturesFromCache();
|
PurgeUnreferencedTexturesFromCache();
|
||||||
|
|
||||||
DebugAssert(g_gpu);
|
|
||||||
UpdateVRAMTrackingState();
|
UpdateVRAMTrackingState();
|
||||||
InvalidateSources();
|
InvalidateSources();
|
||||||
|
|
||||||
|
|
|
@ -506,10 +506,11 @@ struct PixelVectors
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
template<bool texture_enable, bool raw_texture_enable, bool transparency_enable>
|
template<bool texture_enable, bool raw_texture_enable, bool transparency_enable>
|
||||||
ALWAYS_INLINE_RELEASE static void
|
ALWAYS_INLINE_RELEASE static void ShadePixel(const PixelVectors<texture_enable>& RESTRICT pv,
|
||||||
ShadePixel(const PixelVectors<texture_enable>& pv, GPUTextureMode texture_mode, GPUTransparencyMode transparency_mode,
|
GPUTextureMode texture_mode, GPUTransparencyMode transparency_mode,
|
||||||
u32 start_x, u32 y, GSVectorNi vertex_color_rg, GSVectorNi vertex_color_ba, GSVectorNi texcoord_x,
|
u32 start_x, u32 y, GSVectorNi vertex_color_rg, GSVectorNi vertex_color_ba,
|
||||||
GSVectorNi texcoord_y, GSVectorNi preserve_mask, GSVectorNi dither)
|
GSVectorNi texcoord_x, GSVectorNi texcoord_y, GSVectorNi preserve_mask,
|
||||||
|
GSVectorNi dither)
|
||||||
{
|
{
|
||||||
static constexpr GSVectorNi coord_mask_x = GSVectorNi::cxpr(VRAM_WIDTH_MASK);
|
static constexpr GSVectorNi coord_mask_x = GSVectorNi::cxpr(VRAM_WIDTH_MASK);
|
||||||
static constexpr GSVectorNi coord_mask_y = GSVectorNi::cxpr(VRAM_HEIGHT_MASK);
|
static constexpr GSVectorNi coord_mask_y = GSVectorNi::cxpr(VRAM_HEIGHT_MASK);
|
||||||
|
@ -693,7 +694,7 @@ ShadePixel(const PixelVectors<texture_enable>& pv, GPUTextureMode texture_mode,
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool texture_enable, bool raw_texture_enable, bool transparency_enable>
|
template<bool texture_enable, bool raw_texture_enable, bool transparency_enable>
|
||||||
static void DrawRectangle(const GPUBackendDrawRectangleCommand* cmd)
|
static void DrawRectangle(const GPUBackendDrawRectangleCommand* RESTRICT cmd)
|
||||||
{
|
{
|
||||||
const s32 origin_x = cmd->x;
|
const s32 origin_x = cmd->x;
|
||||||
const s32 origin_y = cmd->y;
|
const s32 origin_y = cmd->y;
|
||||||
|
@ -765,8 +766,9 @@ static void DrawRectangle(const GPUBackendDrawRectangleCommand* cmd)
|
||||||
|
|
||||||
// TODO: Vectorize line draw.
|
// TODO: Vectorize line draw.
|
||||||
template<bool shading_enable, bool transparency_enable>
|
template<bool shading_enable, bool transparency_enable>
|
||||||
static void DrawLine(const GPUBackendDrawLineCommand* cmd, const GPUBackendDrawLineCommand::Vertex* p0,
|
static void DrawLine(const GPUBackendDrawLineCommand* RESTRICT cmd,
|
||||||
const GPUBackendDrawLineCommand::Vertex* p1)
|
const GPUBackendDrawLineCommand::Vertex* RESTRICT p0,
|
||||||
|
const GPUBackendDrawLineCommand::Vertex* RESTRICT p1)
|
||||||
{
|
{
|
||||||
static constexpr u32 XY_SHIFT = 32;
|
static constexpr u32 XY_SHIFT = 32;
|
||||||
static constexpr u32 RGB_SHIFT = 12;
|
static constexpr u32 RGB_SHIFT = 12;
|
||||||
|
@ -971,8 +973,8 @@ struct TrianglePart
|
||||||
#ifndef USE_VECTOR
|
#ifndef USE_VECTOR
|
||||||
|
|
||||||
template<bool shading_enable, bool texture_enable, bool raw_texture_enable, bool transparency_enable>
|
template<bool shading_enable, bool texture_enable, bool raw_texture_enable, bool transparency_enable>
|
||||||
static void DrawSpan(const GPUBackendDrawCommand* cmd, s32 y, s32 x_start, s32 x_bound, UVStepper uv,
|
static void DrawSpan(const GPUBackendDrawCommand* RESTRICT cmd, s32 y, s32 x_start, s32 x_bound, UVStepper uv,
|
||||||
const UVSteps& uvstep, RGBStepper rgb, const RGBSteps& rgbstep)
|
const UVSteps& RESTRICT uvstep, RGBStepper rgb, const RGBSteps& RESTRICT rgbstep)
|
||||||
{
|
{
|
||||||
s32 width = x_bound - x_start;
|
s32 width = x_bound - x_start;
|
||||||
s32 current_x = TruncateGPUVertexPosition(x_start);
|
s32 current_x = TruncateGPUVertexPosition(x_start);
|
||||||
|
@ -1011,9 +1013,10 @@ static void DrawSpan(const GPUBackendDrawCommand* cmd, s32 y, s32 x_start, s32 x
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool shading_enable, bool texture_enable, bool raw_texture_enable, bool transparency_enable>
|
template<bool shading_enable, bool texture_enable, bool raw_texture_enable, bool transparency_enable>
|
||||||
ALWAYS_INLINE_RELEASE static void DrawTrianglePart(const GPUBackendDrawCommand* cmd, const TrianglePart& tp,
|
ALWAYS_INLINE_RELEASE static void DrawTrianglePart(const GPUBackendDrawCommand* RESTRICT cmd,
|
||||||
const UVStepper& uv, const UVSteps& uvstep, const RGBStepper& rgb,
|
const TrianglePart& RESTRICT tp, const UVStepper& RESTRICT uv,
|
||||||
const RGBSteps& rgbstep)
|
const UVSteps& RESTRICT uvstep, const RGBStepper& RESTRICT rgb,
|
||||||
|
const RGBSteps& RESTRICT rgbstep)
|
||||||
{
|
{
|
||||||
static constexpr auto unfp_xy = [](s64 xfp) -> s32 { return static_cast<s32>(static_cast<u64>(xfp) >> 32); };
|
static constexpr auto unfp_xy = [](s64 xfp) -> s32 { return static_cast<s32>(static_cast<u64>(xfp) >> 32); };
|
||||||
|
|
||||||
|
@ -1150,9 +1153,10 @@ struct TriangleVectors : PixelVectors<texture_enable>
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
template<bool shading_enable, bool texture_enable, bool raw_texture_enable, bool transparency_enable>
|
template<bool shading_enable, bool texture_enable, bool raw_texture_enable, bool transparency_enable>
|
||||||
ALWAYS_INLINE_RELEASE static void DrawSpan(const GPUBackendDrawCommand* cmd, s32 y, s32 x_start, s32 x_bound,
|
ALWAYS_INLINE_RELEASE static void DrawSpan(const GPUBackendDrawCommand* RESTRICT cmd, s32 y, s32 x_start, s32 x_bound,
|
||||||
UVStepper uv, const UVSteps& uvstep, RGBStepper rgb, const RGBSteps& rgbstep,
|
UVStepper uv, const UVSteps& RESTRICT uvstep, RGBStepper rgb,
|
||||||
const TriangleVectors<shading_enable, texture_enable>& tv)
|
const RGBSteps& RESTRICT rgbstep,
|
||||||
|
const TriangleVectors<shading_enable, texture_enable>& RESTRICT tv)
|
||||||
{
|
{
|
||||||
s32 width = x_bound - x_start;
|
s32 width = x_bound - x_start;
|
||||||
s32 current_x = TruncateGPUVertexPosition(x_start);
|
s32 current_x = TruncateGPUVertexPosition(x_start);
|
||||||
|
@ -1255,9 +1259,10 @@ ALWAYS_INLINE_RELEASE static void DrawSpan(const GPUBackendDrawCommand* cmd, s32
|
||||||
}
|
}
|
||||||
|
|
||||||
template<bool shading_enable, bool texture_enable, bool raw_texture_enable, bool transparency_enable>
|
template<bool shading_enable, bool texture_enable, bool raw_texture_enable, bool transparency_enable>
|
||||||
ALWAYS_INLINE_RELEASE static void DrawTrianglePart(const GPUBackendDrawCommand* cmd, const TrianglePart& tp,
|
ALWAYS_INLINE_RELEASE static void DrawTrianglePart(const GPUBackendDrawCommand* RESTRICT cmd,
|
||||||
const UVStepper& uv, const UVSteps& uvstep, const RGBStepper& rgb,
|
const TrianglePart& RESTRICT tp, const UVStepper& RESTRICT uv,
|
||||||
const RGBSteps& rgbstep)
|
const UVSteps& RESTRICT uvstep, const RGBStepper& RESTRICT rgb,
|
||||||
|
const RGBSteps& RESTRICT rgbstep)
|
||||||
{
|
{
|
||||||
static constexpr auto unfp_xy = [](s64 xfp) -> s32 { return static_cast<s32>(static_cast<u64>(xfp) >> 32); };
|
static constexpr auto unfp_xy = [](s64 xfp) -> s32 { return static_cast<s32>(static_cast<u64>(xfp) >> 32); };
|
||||||
|
|
||||||
|
@ -1356,13 +1361,15 @@ ALWAYS_INLINE_RELEASE static void DrawTrianglePart(const GPUBackendDrawCommand*
|
||||||
#endif // USE_VECTOR
|
#endif // USE_VECTOR
|
||||||
|
|
||||||
template<bool shading_enable, bool texture_enable, bool raw_texture_enable, bool transparency_enable>
|
template<bool shading_enable, bool texture_enable, bool raw_texture_enable, bool transparency_enable>
|
||||||
static void DrawTriangle(const GPUBackendDrawCommand* cmd, const GPUBackendDrawPolygonCommand::Vertex* v0,
|
static void DrawTriangle(const GPUBackendDrawCommand* RESTRICT cmd,
|
||||||
const GPUBackendDrawPolygonCommand::Vertex* v1, const GPUBackendDrawPolygonCommand::Vertex* v2)
|
const GPUBackendDrawPolygonCommand::Vertex* RESTRICT v0,
|
||||||
|
const GPUBackendDrawPolygonCommand::Vertex* RESTRICT v1,
|
||||||
|
const GPUBackendDrawPolygonCommand::Vertex* RESTRICT v2)
|
||||||
{
|
{
|
||||||
#ifdef CHECK_VECTOR
|
#ifdef CHECK_VECTOR
|
||||||
const GPUBackendDrawPolygonCommand::Vertex* orig_v0 = v0;
|
const GPUBackendDrawPolygonCommand::Vertex* RESTRICT orig_v0 = v0;
|
||||||
const GPUBackendDrawPolygonCommand::Vertex* orig_v1 = v1;
|
const GPUBackendDrawPolygonCommand::Vertex* RESTRICT orig_v1 = v1;
|
||||||
const GPUBackendDrawPolygonCommand::Vertex* orig_v2 = v2;
|
const GPUBackendDrawPolygonCommand::Vertex* RESTRICT orig_v2 = v2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Sort vertices so that v0 is the top vertex, v1 is the bottom vertex, and v2 is the side vertex.
|
// Sort vertices so that v0 is the top vertex, v1 is the bottom vertex, and v2 is the side vertex.
|
||||||
|
@ -1417,8 +1424,8 @@ static void DrawTriangle(const GPUBackendDrawCommand* cmd, const GPUBackendDrawP
|
||||||
const u32 ofi = BoolToUInt32(!right_facing);
|
const u32 ofi = BoolToUInt32(!right_facing);
|
||||||
|
|
||||||
TrianglePart triparts[2];
|
TrianglePart triparts[2];
|
||||||
TrianglePart& tpo = triparts[vo];
|
TrianglePart& RESTRICT tpo = triparts[vo];
|
||||||
TrianglePart& tpp = triparts[vo ^ 1];
|
TrianglePart& RESTRICT tpp = triparts[vo ^ 1];
|
||||||
tpo.start_y = vertices[0 ^ vo]->y;
|
tpo.start_y = vertices[0 ^ vo]->y;
|
||||||
tpo.end_y = vertices[1 ^ vo]->y;
|
tpo.end_y = vertices[1 ^ vo]->y;
|
||||||
tpp.start_y = vertices[1 ^ vp]->y;
|
tpp.start_y = vertices[1 ^ vp]->y;
|
||||||
|
@ -1469,7 +1476,7 @@ static void DrawTriangle(const GPUBackendDrawCommand* cmd, const GPUBackendDrawP
|
||||||
// Undo the start of the vertex, so that when we add the offset for each line, it starts at the beginning value.
|
// Undo the start of the vertex, so that when we add the offset for each line, it starts at the beginning value.
|
||||||
UVStepper uv;
|
UVStepper uv;
|
||||||
RGBStepper rgb;
|
RGBStepper rgb;
|
||||||
const GPUBackendDrawPolygonCommand::Vertex* top_left_vertex = vertices[tl];
|
const GPUBackendDrawPolygonCommand::Vertex* RESTRICT top_left_vertex = vertices[tl];
|
||||||
if constexpr (texture_enable)
|
if constexpr (texture_enable)
|
||||||
{
|
{
|
||||||
uv.Init(top_left_vertex->u, top_left_vertex->v);
|
uv.Init(top_left_vertex->u, top_left_vertex->v);
|
||||||
|
@ -1542,7 +1549,7 @@ static void FillVRAMImpl(u32 x, u32 y, u32 width, u32 height, u32 color, bool in
|
||||||
{
|
{
|
||||||
const u32 row = (y + yoffs) % VRAM_HEIGHT;
|
const u32 row = (y + yoffs) % VRAM_HEIGHT;
|
||||||
|
|
||||||
u16* row_ptr = &g_vram[row * VRAM_WIDTH + x];
|
u16* RESTRICT row_ptr = &g_vram[row * VRAM_WIDTH + x];
|
||||||
u32 xoffs = 0;
|
u32 xoffs = 0;
|
||||||
for (; xoffs < aligned_width; xoffs += vector_width, row_ptr += vector_width)
|
for (; xoffs < aligned_width; xoffs += vector_width, row_ptr += vector_width)
|
||||||
GSVector4i::store<false>(row_ptr, fill);
|
GSVector4i::store<false>(row_ptr, fill);
|
||||||
|
@ -1563,7 +1570,7 @@ static void FillVRAMImpl(u32 x, u32 y, u32 width, u32 height, u32 color, bool in
|
||||||
if ((row & u32(1)) == active_field)
|
if ((row & u32(1)) == active_field)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
u16* row_ptr = &g_vram[row * VRAM_WIDTH + x];
|
u16* RESTRICT row_ptr = &g_vram[row * VRAM_WIDTH + x];
|
||||||
u32 xoffs = 0;
|
u32 xoffs = 0;
|
||||||
for (; xoffs < aligned_width; xoffs += vector_width, row_ptr += vector_width)
|
for (; xoffs < aligned_width; xoffs += vector_width, row_ptr += vector_width)
|
||||||
GSVector4i::store<false>(row_ptr, fill);
|
GSVector4i::store<false>(row_ptr, fill);
|
||||||
|
@ -1579,7 +1586,7 @@ static void FillVRAMImpl(u32 x, u32 y, u32 width, u32 height, u32 color, bool in
|
||||||
if ((row & u32(1)) == active_field)
|
if ((row & u32(1)) == active_field)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
u16* row_ptr = &g_vram[row * VRAM_WIDTH];
|
u16* RESTRICT row_ptr = &g_vram[row * VRAM_WIDTH];
|
||||||
for (u32 xoffs = 0; xoffs < width; xoffs++)
|
for (u32 xoffs = 0; xoffs < width; xoffs++)
|
||||||
{
|
{
|
||||||
const u32 col = (x + xoffs) % VRAM_WIDTH;
|
const u32 col = (x + xoffs) % VRAM_WIDTH;
|
||||||
|
@ -1593,7 +1600,7 @@ static void FillVRAMImpl(u32 x, u32 y, u32 width, u32 height, u32 color, bool in
|
||||||
for (u32 yoffs = 0; yoffs < height; yoffs++)
|
for (u32 yoffs = 0; yoffs < height; yoffs++)
|
||||||
{
|
{
|
||||||
const u32 row = (y + yoffs) % VRAM_HEIGHT;
|
const u32 row = (y + yoffs) % VRAM_HEIGHT;
|
||||||
u16* row_ptr = &g_vram[row * VRAM_WIDTH];
|
u16* RESTRICT row_ptr = &g_vram[row * VRAM_WIDTH];
|
||||||
for (u32 xoffs = 0; xoffs < width; xoffs++)
|
for (u32 xoffs = 0; xoffs < width; xoffs++)
|
||||||
{
|
{
|
||||||
const u32 col = (x + xoffs) % VRAM_WIDTH;
|
const u32 col = (x + xoffs) % VRAM_WIDTH;
|
||||||
|
@ -1622,7 +1629,7 @@ static void FillVRAMImpl(u32 x, u32 y, u32 width, u32 height, u32 color, bool in
|
||||||
if ((row & u32(1)) == active_field)
|
if ((row & u32(1)) == active_field)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
u16* row_ptr = &g_vram[row * VRAM_WIDTH];
|
u16* RESTRICT row_ptr = &g_vram[row * VRAM_WIDTH];
|
||||||
for (u32 xoffs = 0; xoffs < width; xoffs++)
|
for (u32 xoffs = 0; xoffs < width; xoffs++)
|
||||||
{
|
{
|
||||||
const u32 col = (x + xoffs) % VRAM_WIDTH;
|
const u32 col = (x + xoffs) % VRAM_WIDTH;
|
||||||
|
@ -1635,7 +1642,7 @@ static void FillVRAMImpl(u32 x, u32 y, u32 width, u32 height, u32 color, bool in
|
||||||
for (u32 yoffs = 0; yoffs < height; yoffs++)
|
for (u32 yoffs = 0; yoffs < height; yoffs++)
|
||||||
{
|
{
|
||||||
const u32 row = (y + yoffs) % VRAM_HEIGHT;
|
const u32 row = (y + yoffs) % VRAM_HEIGHT;
|
||||||
u16* row_ptr = &g_vram[row * VRAM_WIDTH];
|
u16* RESTRICT row_ptr = &g_vram[row * VRAM_WIDTH];
|
||||||
for (u32 xoffs = 0; xoffs < width; xoffs++)
|
for (u32 xoffs = 0; xoffs < width; xoffs++)
|
||||||
{
|
{
|
||||||
const u32 col = (x + xoffs) % VRAM_WIDTH;
|
const u32 col = (x + xoffs) % VRAM_WIDTH;
|
||||||
|
@ -1646,12 +1653,13 @@ static void FillVRAMImpl(u32 x, u32 y, u32 width, u32 height, u32 color, bool in
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WriteVRAMImpl(u32 x, u32 y, u32 width, u32 height, const void* data, bool set_mask, bool check_mask)
|
static void WriteVRAMImpl(u32 x, u32 y, u32 width, u32 height, const void* RESTRICT data, bool set_mask,
|
||||||
|
bool check_mask)
|
||||||
{
|
{
|
||||||
// Fast path when the copy is not oversized.
|
// Fast path when the copy is not oversized.
|
||||||
if ((x + width) <= VRAM_WIDTH && (y + height) <= VRAM_HEIGHT && !set_mask && !check_mask)
|
if ((x + width) <= VRAM_WIDTH && (y + height) <= VRAM_HEIGHT && !set_mask && !check_mask)
|
||||||
{
|
{
|
||||||
const u16* src_ptr = static_cast<const u16*>(data);
|
const u16* RESTRICT src_ptr = static_cast<const u16*>(data);
|
||||||
u16* dst_ptr = &g_vram[y * VRAM_WIDTH + x];
|
u16* dst_ptr = &g_vram[y * VRAM_WIDTH + x];
|
||||||
for (u32 yoffs = 0; yoffs < height; yoffs++)
|
for (u32 yoffs = 0; yoffs < height; yoffs++)
|
||||||
{
|
{
|
||||||
|
@ -1664,7 +1672,7 @@ static void WriteVRAMImpl(u32 x, u32 y, u32 width, u32 height, const void* data,
|
||||||
{
|
{
|
||||||
// Slow path when we need to handle wrap-around.
|
// Slow path when we need to handle wrap-around.
|
||||||
// During transfer/render operations, if ((dst_pixel & mask_and) == 0) { pixel = src_pixel | mask_or }
|
// During transfer/render operations, if ((dst_pixel & mask_and) == 0) { pixel = src_pixel | mask_or }
|
||||||
const u16* src_ptr = static_cast<const u16*>(data);
|
const u16* RESTRICT src_ptr = static_cast<const u16*>(data);
|
||||||
const u16 mask_and = check_mask ? 0x8000u : 0x0000u;
|
const u16 mask_and = check_mask ? 0x8000u : 0x0000u;
|
||||||
const u16 mask_or = set_mask ? 0x8000u : 0x0000u;
|
const u16 mask_or = set_mask ? 0x8000u : 0x0000u;
|
||||||
|
|
||||||
|
@ -1713,7 +1721,7 @@ static void WriteVRAMImpl(u32 x, u32 y, u32 width, u32 height, const void* data,
|
||||||
for (; col < width;)
|
for (; col < width;)
|
||||||
{
|
{
|
||||||
// TODO: Handle unaligned reads...
|
// TODO: Handle unaligned reads...
|
||||||
u16* pixel_ptr = &dst_row_ptr[(x + col++) % VRAM_WIDTH];
|
u16* RESTRICT pixel_ptr = &dst_row_ptr[(x + col++) % VRAM_WIDTH];
|
||||||
if (((*pixel_ptr) & mask_and) == 0)
|
if (((*pixel_ptr) & mask_and) == 0)
|
||||||
*pixel_ptr = *(src_ptr++) | mask_or;
|
*pixel_ptr = *(src_ptr++) | mask_or;
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,12 +207,12 @@ void GunCon::UpdatePosition()
|
||||||
float display_x, display_y;
|
float display_x, display_y;
|
||||||
const auto& [window_x, window_y] = (m_has_relative_binds) ? GetAbsolutePositionFromRelativeAxes() :
|
const auto& [window_x, window_y] = (m_has_relative_binds) ? GetAbsolutePositionFromRelativeAxes() :
|
||||||
InputManager::GetPointerAbsolutePosition(m_cursor_index);
|
InputManager::GetPointerAbsolutePosition(m_cursor_index);
|
||||||
g_gpu->ConvertScreenCoordinatesToDisplayCoordinates(window_x, window_y, &display_x, &display_y);
|
g_gpu.ConvertScreenCoordinatesToDisplayCoordinates(window_x, window_y, &display_x, &display_y);
|
||||||
|
|
||||||
// are we within the active display area?
|
// are we within the active display area?
|
||||||
u32 tick, line;
|
u32 tick, line;
|
||||||
if (display_x < 0 || display_y < 0 ||
|
if (display_x < 0 || display_y < 0 ||
|
||||||
!g_gpu->ConvertDisplayCoordinatesToBeamTicksAndLines(display_x, display_y, m_x_scale, &tick, &line) ||
|
!g_gpu.ConvertDisplayCoordinatesToBeamTicksAndLines(display_x, display_y, m_x_scale, &tick, &line) ||
|
||||||
m_shoot_offscreen)
|
m_shoot_offscreen)
|
||||||
{
|
{
|
||||||
DEBUG_LOG("Lightgun out of range for window coordinates {:.0f},{:.0f}", window_x, window_y);
|
DEBUG_LOG("Lightgun out of range for window coordinates {:.0f},{:.0f}", window_x, window_y);
|
||||||
|
@ -222,7 +222,7 @@ void GunCon::UpdatePosition()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8MHz units for X = 44100*768*11/7 = 53222400 / 8000000 = 6.6528
|
// 8MHz units for X = 44100*768*11/7 = 53222400 / 8000000 = 6.6528
|
||||||
const double divider = static_cast<double>(g_gpu->GetCRTCFrequency()) / 8000000.0;
|
const double divider = static_cast<double>(g_gpu.GetCRTCFrequency()) / 8000000.0;
|
||||||
m_position_x = static_cast<u16>(static_cast<float>(tick) / static_cast<float>(divider));
|
m_position_x = static_cast<u16>(static_cast<float>(tick) / static_cast<float>(divider));
|
||||||
m_position_y = static_cast<u16>(line);
|
m_position_y = static_cast<u16>(line);
|
||||||
DEBUG_LOG("Lightgun window coordinates {:.0f},{:.0f} -> tick {} line {} 8mhz ticks {}", display_x, display_y, tick,
|
DEBUG_LOG("Lightgun window coordinates {:.0f},{:.0f} -> tick {} line {} 8mhz ticks {}", display_x, display_y, tick,
|
||||||
|
|
|
@ -85,7 +85,7 @@ static constexpr const char* DEBUG_WINDOW_CONFIG_SECTION = "DebugWindows";
|
||||||
static constexpr const std::array<DebugWindowInfo, NUM_DEBUG_WINDOWS> s_debug_window_info = {{
|
static constexpr const std::array<DebugWindowInfo, NUM_DEBUG_WINDOWS> s_debug_window_info = {{
|
||||||
{"SPU", "SPU State", ":icons/applications-system.png", &SPU::DrawDebugStateWindow, 800, 915},
|
{"SPU", "SPU State", ":icons/applications-system.png", &SPU::DrawDebugStateWindow, 800, 915},
|
||||||
{"CDROM", "CD-ROM State", ":icons/applications-system.png", &CDROM::DrawDebugWindow, 800, 540},
|
{"CDROM", "CD-ROM State", ":icons/applications-system.png", &CDROM::DrawDebugWindow, 800, 540},
|
||||||
{"GPU", "GPU State", ":icons/applications-system.png", [](float sc) { g_gpu->DrawDebugStateWindow(sc); }, 450, 550},
|
{"GPU", "GPU State", ":icons/applications-system.png", [](float sc) { g_gpu.DrawDebugStateWindow(sc); }, 450, 550},
|
||||||
{"DMA", "DMA State", ":icons/applications-system.png", &DMA::DrawDebugStateWindow, 860, 180},
|
{"DMA", "DMA State", ":icons/applications-system.png", &DMA::DrawDebugStateWindow, 860, 180},
|
||||||
{"MDEC", "MDEC State", ":icons/applications-system.png", &MDEC::DrawDebugStateWindow, 300, 350},
|
{"MDEC", "MDEC State", ":icons/applications-system.png", &MDEC::DrawDebugStateWindow, 300, 350},
|
||||||
{"Timers", "Timers State", ":icons/applications-system.png", &Timers::DrawDebugStateWindow, 800, 95},
|
{"Timers", "Timers State", ":icons/applications-system.png", &Timers::DrawDebugStateWindow, 800, 95},
|
||||||
|
@ -323,9 +323,9 @@ void ImGuiManager::DrawPerformanceOverlay(const GPUBackend* gpu, float& position
|
||||||
if (g_gpu_settings.display_show_resolution)
|
if (g_gpu_settings.display_show_resolution)
|
||||||
{
|
{
|
||||||
const u32 resolution_scale = gpu->GetResolutionScale();
|
const u32 resolution_scale = gpu->GetResolutionScale();
|
||||||
const auto [display_width, display_height] = g_gpu->GetFullDisplayResolution(); // NOTE: Racey read.
|
const auto [display_width, display_height] = g_gpu.GetFullDisplayResolution(); // NOTE: Racey read.
|
||||||
const bool interlaced = g_gpu->IsInterlacedDisplayEnabled();
|
const bool interlaced = g_gpu.IsInterlacedDisplayEnabled();
|
||||||
const bool pal = g_gpu->IsInPALMode();
|
const bool pal = g_gpu.IsInPALMode();
|
||||||
text.format("{}x{} {} {} [{}x]", display_width * resolution_scale, display_height * resolution_scale,
|
text.format("{}x{} {} {} [{}x]", display_width * resolution_scale, display_height * resolution_scale,
|
||||||
pal ? "PAL" : "NTSC", interlaced ? "Interlaced" : "Progressive", resolution_scale);
|
pal ? "PAL" : "NTSC", interlaced ? "Interlaced" : "Progressive", resolution_scale);
|
||||||
DRAW_LINE(fixed_font, text, IM_COL32(255, 255, 255, 255));
|
DRAW_LINE(fixed_font, text, IM_COL32(255, 255, 255, 255));
|
||||||
|
|
|
@ -215,12 +215,12 @@ void Justifier::UpdatePosition()
|
||||||
float display_x, display_y;
|
float display_x, display_y;
|
||||||
const auto [window_x, window_y] = (m_has_relative_binds) ? GetAbsolutePositionFromRelativeAxes() :
|
const auto [window_x, window_y] = (m_has_relative_binds) ? GetAbsolutePositionFromRelativeAxes() :
|
||||||
InputManager::GetPointerAbsolutePosition(m_cursor_index);
|
InputManager::GetPointerAbsolutePosition(m_cursor_index);
|
||||||
g_gpu->ConvertScreenCoordinatesToDisplayCoordinates(window_x, window_y, &display_x, &display_y);
|
g_gpu.ConvertScreenCoordinatesToDisplayCoordinates(window_x, window_y, &display_x, &display_y);
|
||||||
|
|
||||||
// are we within the active display area?
|
// are we within the active display area?
|
||||||
u32 tick, line;
|
u32 tick, line;
|
||||||
if (display_x < 0 || display_y < 0 ||
|
if (display_x < 0 || display_y < 0 ||
|
||||||
!g_gpu->ConvertDisplayCoordinatesToBeamTicksAndLines(display_x, display_y, m_x_scale, &tick, &line) ||
|
!g_gpu.ConvertDisplayCoordinatesToBeamTicksAndLines(display_x, display_y, m_x_scale, &tick, &line) ||
|
||||||
m_shoot_offscreen)
|
m_shoot_offscreen)
|
||||||
{
|
{
|
||||||
DEV_LOG("Lightgun out of range for window coordinates {:.0f},{:.0f}", window_x, window_y);
|
DEV_LOG("Lightgun out of range for window coordinates {:.0f},{:.0f}", window_x, window_y);
|
||||||
|
@ -234,11 +234,11 @@ void Justifier::UpdatePosition()
|
||||||
m_irq_tick = static_cast<u16>(static_cast<TickCount>(tick) +
|
m_irq_tick = static_cast<u16>(static_cast<TickCount>(tick) +
|
||||||
System::ScaleTicksToOverclock(static_cast<TickCount>(m_tick_offset)));
|
System::ScaleTicksToOverclock(static_cast<TickCount>(m_tick_offset)));
|
||||||
m_irq_first_line = static_cast<u16>(std::clamp<s32>(static_cast<s32>(line) + m_first_line_offset,
|
m_irq_first_line = static_cast<u16>(std::clamp<s32>(static_cast<s32>(line) + m_first_line_offset,
|
||||||
static_cast<s32>(g_gpu->GetCRTCActiveStartLine()),
|
static_cast<s32>(g_gpu.GetCRTCActiveStartLine()),
|
||||||
static_cast<s32>(g_gpu->GetCRTCActiveEndLine())));
|
static_cast<s32>(g_gpu.GetCRTCActiveEndLine())));
|
||||||
m_irq_last_line = static_cast<u16>(std::clamp<s32>(static_cast<s32>(line) + m_last_line_offset,
|
m_irq_last_line = static_cast<u16>(std::clamp<s32>(static_cast<s32>(line) + m_last_line_offset,
|
||||||
static_cast<s32>(g_gpu->GetCRTCActiveStartLine()),
|
static_cast<s32>(g_gpu.GetCRTCActiveStartLine()),
|
||||||
static_cast<s32>(g_gpu->GetCRTCActiveEndLine())));
|
static_cast<s32>(g_gpu.GetCRTCActiveEndLine())));
|
||||||
|
|
||||||
DEV_LOG("Lightgun window coordinates {},{} -> dpy {},{} -> tick {} line {} [{}-{}]", window_x, window_y, display_x,
|
DEV_LOG("Lightgun window coordinates {},{} -> dpy {},{} -> tick {} line {} [{}-{}]", window_x, window_y, display_x,
|
||||||
display_y, tick, line, m_irq_first_line, m_irq_last_line);
|
display_y, tick, line, m_irq_first_line, m_irq_last_line);
|
||||||
|
@ -255,7 +255,7 @@ void Justifier::UpdateIRQEvent()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
u32 current_tick, current_line;
|
u32 current_tick, current_line;
|
||||||
g_gpu->GetBeamPosition(¤t_tick, ¤t_line);
|
g_gpu.GetBeamPosition(¤t_tick, ¤t_line);
|
||||||
|
|
||||||
u32 target_line;
|
u32 target_line;
|
||||||
if (current_line < m_irq_first_line || current_line >= m_irq_last_line)
|
if (current_line < m_irq_first_line || current_line >= m_irq_last_line)
|
||||||
|
@ -263,7 +263,7 @@ void Justifier::UpdateIRQEvent()
|
||||||
else
|
else
|
||||||
target_line = current_line + 1;
|
target_line = current_line + 1;
|
||||||
|
|
||||||
const TickCount ticks_until_pos = g_gpu->GetSystemTicksUntilTicksAndLine(m_irq_tick, target_line);
|
const TickCount ticks_until_pos = g_gpu.GetSystemTicksUntilTicksAndLine(m_irq_tick, target_line);
|
||||||
DEBUG_LOG("Triggering IRQ in {} ticks @ tick {} line {}", ticks_until_pos, m_irq_tick, target_line);
|
DEBUG_LOG("Triggering IRQ in {} ticks @ tick {} line {}", ticks_until_pos, m_irq_tick, target_line);
|
||||||
m_irq_event.Schedule(ticks_until_pos);
|
m_irq_event.Schedule(ticks_until_pos);
|
||||||
}
|
}
|
||||||
|
|
|
@ -713,7 +713,7 @@ void System::UpdateOverclock()
|
||||||
s_state.max_slice_ticks = ScaleTicksToOverclock(MASTER_CLOCK / 10);
|
s_state.max_slice_ticks = ScaleTicksToOverclock(MASTER_CLOCK / 10);
|
||||||
SPU::CPUClockChanged();
|
SPU::CPUClockChanged();
|
||||||
CDROM::CPUClockChanged();
|
CDROM::CPUClockChanged();
|
||||||
g_gpu->CPUClockChanged();
|
g_gpu.CPUClockChanged();
|
||||||
Timers::CPUClocksChanged();
|
Timers::CPUClocksChanged();
|
||||||
UpdateThrottlePeriod();
|
UpdateThrottlePeriod();
|
||||||
}
|
}
|
||||||
|
@ -1882,9 +1882,8 @@ bool System::Initialize(std::unique_ptr<CDImage> disc, DiscRegion disc_region, b
|
||||||
!CDROM::InsertMedia(std::move(disc), disc_region, s_state.running_game_serial, s_state.running_game_title, error))
|
!CDROM::InsertMedia(std::move(disc), disc_region, s_state.running_game_serial, s_state.running_game_title, error))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// TODO: Drop pointer
|
// TODO: Drop class
|
||||||
g_gpu = std::make_unique<GPU>();
|
g_gpu.Initialize();
|
||||||
g_gpu->Initialize();
|
|
||||||
|
|
||||||
// This can fail due to the application being closed during startup.
|
// This can fail due to the application being closed during startup.
|
||||||
if (!GPUThread::CreateGPUBackend(s_state.running_game_serial,
|
if (!GPUThread::CreateGPUBackend(s_state.running_game_serial,
|
||||||
|
@ -1965,7 +1964,7 @@ void System::DestroySystem()
|
||||||
Timers::Shutdown();
|
Timers::Shutdown();
|
||||||
Pad::Shutdown();
|
Pad::Shutdown();
|
||||||
CDROM::Shutdown();
|
CDROM::Shutdown();
|
||||||
g_gpu.reset();
|
g_gpu.Shutdown();
|
||||||
DMA::Shutdown();
|
DMA::Shutdown();
|
||||||
PIO::Shutdown();
|
PIO::Shutdown();
|
||||||
CPU::CodeCache::Shutdown();
|
CPU::CodeCache::Shutdown();
|
||||||
|
@ -2100,7 +2099,7 @@ void System::FrameDone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Late submission of frame. This is needed because the input poll can determine whether we need to rewind.
|
// Late submission of frame. This is needed because the input poll can determine whether we need to rewind.
|
||||||
g_gpu->QueuePresentCurrentFrame();
|
g_gpu.QueuePresentCurrentFrame();
|
||||||
|
|
||||||
SaveMemoryState(AllocateMemoryState());
|
SaveMemoryState(AllocateMemoryState());
|
||||||
}
|
}
|
||||||
|
@ -2386,7 +2385,7 @@ bool System::DoState(StateWrapper& sw, bool update_display)
|
||||||
if (!sw.DoMarker("InterruptController") || !InterruptController::DoState(sw))
|
if (!sw.DoMarker("InterruptController") || !InterruptController::DoState(sw))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!sw.DoMarker("GPU") || !g_gpu->DoState(sw, update_display))
|
if (!sw.DoMarker("GPU") || !g_gpu.DoState(sw, update_display))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!sw.DoMarker("CDROM") || !CDROM::DoState(sw))
|
if (!sw.DoMarker("CDROM") || !CDROM::DoState(sw))
|
||||||
|
@ -2682,7 +2681,7 @@ void System::DoMemoryState(StateWrapper& sw, MemorySaveState& mss, bool update_d
|
||||||
SAVE_COMPONENT("DMA", DMA::DoState(sw));
|
SAVE_COMPONENT("DMA", DMA::DoState(sw));
|
||||||
SAVE_COMPONENT("InterruptController", InterruptController::DoState(sw));
|
SAVE_COMPONENT("InterruptController", InterruptController::DoState(sw));
|
||||||
|
|
||||||
g_gpu->DoMemoryState(sw, mss, update_display);
|
g_gpu.DoMemoryState(sw, mss, update_display);
|
||||||
|
|
||||||
SAVE_COMPONENT("CDROM", CDROM::DoState(sw));
|
SAVE_COMPONENT("CDROM", CDROM::DoState(sw));
|
||||||
SAVE_COMPONENT("Pad", Pad::DoState(sw, true));
|
SAVE_COMPONENT("Pad", Pad::DoState(sw, true));
|
||||||
|
@ -2731,7 +2730,7 @@ void System::InternalReset()
|
||||||
PIO::Reset();
|
PIO::Reset();
|
||||||
DMA::Reset();
|
DMA::Reset();
|
||||||
InterruptController::Reset();
|
InterruptController::Reset();
|
||||||
g_gpu->Reset(true);
|
g_gpu.Reset(true);
|
||||||
CDROM::Reset();
|
CDROM::Reset();
|
||||||
Pad::Reset();
|
Pad::Reset();
|
||||||
Timers::Reset();
|
Timers::Reset();
|
||||||
|
@ -3957,7 +3956,7 @@ bool System::DumpVRAM(const char* filename)
|
||||||
if (!IsValid())
|
if (!IsValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return g_gpu->DumpVRAMToFile(filename);
|
return g_gpu.DumpVRAMToFile(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool System::DumpSPURAM(const char* filename)
|
bool System::DumpSPURAM(const char* filename)
|
||||||
|
@ -5198,7 +5197,7 @@ bool System::StartRecordingGPUDump(const char* path /*= nullptr*/, u32 num_frame
|
||||||
if (!path)
|
if (!path)
|
||||||
path = (auto_path = GetScreenshotPath("psxgpu")).c_str();
|
path = (auto_path = GetScreenshotPath("psxgpu")).c_str();
|
||||||
|
|
||||||
return g_gpu->StartRecordingGPUDump(path, num_frames);
|
return g_gpu.StartRecordingGPUDump(path, num_frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::StopRecordingGPUDump()
|
void System::StopRecordingGPUDump()
|
||||||
|
@ -5206,7 +5205,7 @@ void System::StopRecordingGPUDump()
|
||||||
if (!IsValid())
|
if (!IsValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_gpu->StopRecordingGPUDump();
|
g_gpu.StopRecordingGPUDump();
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string_view GetCaptureTypeForMessage(bool capture_video, bool capture_audio)
|
static std::string_view GetCaptureTypeForMessage(bool capture_video, bool capture_audio)
|
||||||
|
@ -5686,9 +5685,9 @@ void System::RequestDisplaySize(float scale /*= 0.0f*/)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
requested_width = static_cast<float>(g_gpu->GetCRTCDisplayWidth()) * scale;
|
requested_width = static_cast<float>(g_gpu.GetCRTCDisplayWidth()) * scale;
|
||||||
requested_height = static_cast<float>(g_gpu->GetCRTCDisplayHeight()) * scale;
|
requested_height = static_cast<float>(g_gpu.GetCRTCDisplayHeight()) * scale;
|
||||||
g_gpu->ApplyPixelAspectRatioToSize(g_gpu->ComputePixelAspectRatio(), &requested_width, &requested_height);
|
g_gpu.ApplyPixelAspectRatioToSize(g_gpu.ComputePixelAspectRatio(), &requested_width, &requested_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_settings.display_rotation == DisplayRotation::Rotate90 ||
|
if (g_settings.display_rotation == DisplayRotation::Rotate90 ||
|
||||||
|
@ -5734,7 +5733,7 @@ void System::UpdateGTEAspectRatio()
|
||||||
{
|
{
|
||||||
// Pre-apply the native aspect ratio correction to the window size.
|
// Pre-apply the native aspect ratio correction to the window size.
|
||||||
// MatchWindow does not correct the display aspect ratio, so we need to apply it here.
|
// MatchWindow does not correct the display aspect ratio, so we need to apply it here.
|
||||||
const float correction = g_gpu->ComputeAspectRatioCorrection();
|
const float correction = g_gpu.ComputeAspectRatioCorrection();
|
||||||
custom_num =
|
custom_num =
|
||||||
static_cast<u32>(std::max(std::round(static_cast<float>(main_window_info.surface_width) / correction), 1.0f));
|
static_cast<u32>(std::max(std::round(static_cast<float>(main_window_info.surface_width) / correction), 1.0f));
|
||||||
custom_denom = std::max<u32>(main_window_info.surface_height, 1u);
|
custom_denom = std::max<u32>(main_window_info.surface_height, 1u);
|
||||||
|
|
|
@ -315,8 +315,8 @@ u32 Timers::ReadRegister(u32 offset)
|
||||||
if (timer_index < 2 && cs.external_counting_enabled)
|
if (timer_index < 2 && cs.external_counting_enabled)
|
||||||
{
|
{
|
||||||
// timers 0/1 depend on the GPU
|
// timers 0/1 depend on the GPU
|
||||||
if (timer_index == 0 || g_gpu->IsCRTCScanlinePending())
|
if (timer_index == 0 || g_gpu.IsCRTCScanlinePending())
|
||||||
g_gpu->SynchronizeCRTC();
|
g_gpu.SynchronizeCRTC();
|
||||||
}
|
}
|
||||||
|
|
||||||
s_state.sysclk_event.InvokeEarly();
|
s_state.sysclk_event.InvokeEarly();
|
||||||
|
@ -329,8 +329,8 @@ u32 Timers::ReadRegister(u32 offset)
|
||||||
if (timer_index < 2 && cs.external_counting_enabled)
|
if (timer_index < 2 && cs.external_counting_enabled)
|
||||||
{
|
{
|
||||||
// timers 0/1 depend on the GPU
|
// timers 0/1 depend on the GPU
|
||||||
if (timer_index == 0 || g_gpu->IsCRTCScanlinePending())
|
if (timer_index == 0 || g_gpu.IsCRTCScanlinePending())
|
||||||
g_gpu->SynchronizeCRTC();
|
g_gpu.SynchronizeCRTC();
|
||||||
}
|
}
|
||||||
|
|
||||||
s_state.sysclk_event.InvokeEarly();
|
s_state.sysclk_event.InvokeEarly();
|
||||||
|
@ -365,8 +365,8 @@ void Timers::WriteRegister(u32 offset, u32 value)
|
||||||
if (timer_index < 2 && cs.external_counting_enabled)
|
if (timer_index < 2 && cs.external_counting_enabled)
|
||||||
{
|
{
|
||||||
// timers 0/1 depend on the GPU
|
// timers 0/1 depend on the GPU
|
||||||
if (timer_index == 0 || g_gpu->IsCRTCScanlinePending())
|
if (timer_index == 0 || g_gpu.IsCRTCScanlinePending())
|
||||||
g_gpu->SynchronizeCRTC();
|
g_gpu.SynchronizeCRTC();
|
||||||
}
|
}
|
||||||
|
|
||||||
s_state.sysclk_event.InvokeEarly();
|
s_state.sysclk_event.InvokeEarly();
|
||||||
|
|
|
@ -2081,7 +2081,7 @@ void EmuThread::updatePerformanceCounters(const GPUBackend* gpu_backend)
|
||||||
if (gpu_backend)
|
if (gpu_backend)
|
||||||
{
|
{
|
||||||
const u32 render_scale = gpu_backend->GetResolutionScale();
|
const u32 render_scale = gpu_backend->GetResolutionScale();
|
||||||
std::tie(render_width, render_height) = g_gpu->GetFullDisplayResolution();
|
std::tie(render_width, render_height) = g_gpu.GetFullDisplayResolution();
|
||||||
render_width *= render_scale;
|
render_width *= render_scale;
|
||||||
render_height *= render_scale;
|
render_height *= render_scale;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue