gs: continue merge, modify plugin boundaries and expose signature

This commit is contained in:
Gauvain 'GovanifY' Roussel-Tarbouriech 2021-05-11 16:31:20 +02:00 committed by Kojin
parent e68a3606a9
commit f04f941dbb
9 changed files with 90 additions and 183 deletions

View File

@ -52,11 +52,9 @@ void __fastcall ReadFIFO_VIF1(mem128_t* out)
}
if (vif1Regs.stat.FQC > 0) {
GetMTGS().WaitGS();
if (GSinitReadFIFO) {
GetMTGS().SendPointerPacket(GS_RINGTYPE_INIT_READ_FIFO1, 0, out);
GetMTGS().WaitGS(false); // wait without reg sync
}
GSreadFIFO((u64*)out);
GetMTGS().SendPointerPacket(GS_RINGTYPE_INIT_READ_FIFO1, 0, out);
GetMTGS().WaitGS(false); // wait without reg sync
GSreadFIFO((u8*)out);
vif1.GSLastDownloadSize--;
GUNIT_LOG("ReadFIFO_VIF1");
if (vif1.GSLastDownloadSize <= 16)

View File

@ -18,6 +18,7 @@
#include "Common.h"
#include "System/SysThreads.h"
#include "Gif.h"
#include "GS/GS.h"
extern Fixed100 GetVerticalFrequency();
extern __aligned16 u8 g_RealGSMem[Ps2MemSize::GSregs];

View File

@ -65,25 +65,7 @@ static bool s_exclusive = true;
static std::string s_renderer_name;
bool gsopen_done = false; // crash guard for GSgetTitleInfo2 and GSKeyEvent (replace with lock?)
EXPORT_C_(uint32) PS2EgetLibType()
{
return PS2E_LT_GS;
}
EXPORT_C_(const char*) PS2EgetLibName()
{
return GSUtil::GetLibName();
}
EXPORT_C_(uint32) PS2EgetLibVersion2(uint32 type)
{
const uint32 revision = 1;
const uint32 build = 2;
return (build << 0) | (revision << 8) | (PS2E_GS_VERSION << 16) | (PLUGIN_VERSION << 24);
}
EXPORT_C_(uint32) PS2EgetCpuPlatform()
uint32 PS2EgetCpuPlatform()
{
#ifdef _M_AMD64
@ -96,7 +78,7 @@ EXPORT_C_(uint32) PS2EgetCpuPlatform()
#endif
}
EXPORT_C GSsetBaseMem(uint8* mem)
void GSsetBaseMem(uint8* mem)
{
s_basemem = mem;
@ -106,12 +88,12 @@ EXPORT_C GSsetBaseMem(uint8* mem)
}
}
EXPORT_C GSsetSettingsDir(const char* dir)
void GSsetSettingsDir(const char* dir)
{
theApp.SetConfigDir(dir);
}
EXPORT_C_(int) GSinit()
int GSinit()
{
if (!GSUtil::CheckSSE())
{
@ -138,7 +120,7 @@ EXPORT_C_(int) GSinit()
return 0;
}
EXPORT_C GSshutdown()
void GSshutdown()
{
gsopen_done = false;
@ -157,7 +139,7 @@ EXPORT_C GSshutdown()
#endif
}
EXPORT_C GSclose()
void GSclose()
{
gsopen_done = false;
@ -402,19 +384,19 @@ static int _GSopen(void** dsp, const char* title, GSRendererType renderer, int t
return 0;
}
EXPORT_C_(void) GSosdLog(const char* utf8, uint32 color)
void GSosdLog(const char* utf8, uint32 color)
{
if (s_gs && s_gs->m_dev)
s_gs->m_dev->m_osd.Log(utf8);
}
EXPORT_C_(void) GSosdMonitor(const char* key, const char* value, uint32 color)
void GSosdMonitor(const char* key, const char* value, uint32 color)
{
if (s_gs && s_gs->m_dev)
s_gs->m_dev->m_osd.Monitor(key, value);
}
EXPORT_C_(int) GSopen2(void** dsp, uint32 flags)
int GSopen2(void** dsp, uint32 flags)
{
static bool stored_toggle_state = false;
const bool toggle_state = !!(flags & 4);
@ -466,7 +448,7 @@ EXPORT_C_(int) GSopen2(void** dsp, uint32 flags)
return retval;
}
EXPORT_C_(int) GSopen(void** dsp, const char* title, int mt)
int GSopen(void** dsp, const char* title, int mt)
{
GSRendererType renderer = GSRendererType::Default;
@ -500,7 +482,7 @@ EXPORT_C_(int) GSopen(void** dsp, const char* title, int mt)
return retval;
}
EXPORT_C GSreset()
void GSreset()
{
try
{
@ -511,7 +493,7 @@ EXPORT_C GSreset()
}
}
EXPORT_C GSgifSoftReset(uint32 mask)
void GSgifSoftReset(uint32 mask)
{
try
{
@ -522,7 +504,7 @@ EXPORT_C GSgifSoftReset(uint32 mask)
}
}
EXPORT_C GSwriteCSR(uint32 csr)
void GSwriteCSR(uint32 csr)
{
try
{
@ -533,7 +515,7 @@ EXPORT_C GSwriteCSR(uint32 csr)
}
}
EXPORT_C GSinitReadFIFO(uint8* mem)
void GSinitReadFIFO(uint8* mem)
{
GL_PERF("Init Read FIFO1");
try
@ -549,7 +531,7 @@ EXPORT_C GSinitReadFIFO(uint8* mem)
}
}
EXPORT_C GSreadFIFO(uint8* mem)
void GSreadFIFO(uint8* mem)
{
try
{
@ -564,7 +546,7 @@ EXPORT_C GSreadFIFO(uint8* mem)
}
}
EXPORT_C GSinitReadFIFO2(uint8* mem, uint32 size)
void GSinitReadFIFO2(uint8* mem, uint32 size)
{
GL_PERF("Init Read FIFO2");
try
@ -580,7 +562,7 @@ EXPORT_C GSinitReadFIFO2(uint8* mem, uint32 size)
}
}
EXPORT_C GSreadFIFO2(uint8* mem, uint32 size)
void GSreadFIFO2(uint8* mem, uint32 size)
{
try
{
@ -595,7 +577,7 @@ EXPORT_C GSreadFIFO2(uint8* mem, uint32 size)
}
}
EXPORT_C GSgifTransfer(const uint8* mem, uint32 size)
void GSgifTransfer(const uint8* mem, uint32 size)
{
try
{
@ -606,7 +588,7 @@ EXPORT_C GSgifTransfer(const uint8* mem, uint32 size)
}
}
EXPORT_C GSgifTransfer1(uint8* mem, uint32 addr)
void GSgifTransfer1(uint8* mem, uint32 addr)
{
try
{
@ -617,7 +599,7 @@ EXPORT_C GSgifTransfer1(uint8* mem, uint32 addr)
}
}
EXPORT_C GSgifTransfer2(uint8* mem, uint32 size)
void GSgifTransfer2(uint8* mem, uint32 size)
{
try
{
@ -628,7 +610,7 @@ EXPORT_C GSgifTransfer2(uint8* mem, uint32 size)
}
}
EXPORT_C GSgifTransfer3(uint8* mem, uint32 size)
void GSgifTransfer3(uint8* mem, uint32 size)
{
try
{
@ -639,7 +621,7 @@ EXPORT_C GSgifTransfer3(uint8* mem, uint32 size)
}
}
EXPORT_C GSvsync(int field)
void GSvsync(int field)
{
try
{
@ -671,7 +653,7 @@ EXPORT_C GSvsync(int field)
}
}
EXPORT_C_(uint32) GSmakeSnapshot(char* path)
uint32 GSmakeSnapshot(char* path)
{
try
{
@ -700,7 +682,7 @@ EXPORT_C_(uint32) GSmakeSnapshot(char* path)
}
}
EXPORT_C GSkeyEvent(GSKeyEventData* e)
void GSkeyEvent(GSKeyEventData* e)
{
try
{
@ -714,7 +696,7 @@ EXPORT_C GSkeyEvent(GSKeyEventData* e)
}
}
EXPORT_C_(int) GSfreeze(int mode, GSFreezeData* data)
int GSfreeze(int mode, GSFreezeData* data)
{
try
{
@ -738,7 +720,7 @@ EXPORT_C_(int) GSfreeze(int mode, GSFreezeData* data)
return 0;
}
EXPORT_C GSconfigure()
void GSconfigure()
{
try
{
@ -786,7 +768,7 @@ EXPORT_C GSconfigure()
}
}
EXPORT_C_(int) GStest()
int GStest()
{
if (!GSUtil::CheckSSE())
return -1;
@ -794,11 +776,7 @@ EXPORT_C_(int) GStest()
return 0;
}
EXPORT_C GSabout()
{
}
EXPORT_C GSirqCallback(void (*irq)())
void GSirqCallback(void (*irq)())
{
s_irq = irq;
@ -819,7 +797,7 @@ void pt(const char* str)
printf("%02i:%02i:%02i%s", current->tm_hour, current->tm_min, current->tm_sec, str);
}
EXPORT_C_(bool) GSsetupRecording(std::string& filename)
bool GSsetupRecording(std::string& filename)
{
if (s_gs == NULL)
{
@ -846,24 +824,24 @@ EXPORT_C_(bool) GSsetupRecording(std::string& filename)
}
}
EXPORT_C_(void) GSendRecording()
void GSendRecording()
{
printf("GSdx: Recording end command\n");
s_gs->EndCapture();
pt(" - Capture ended\n");
}
EXPORT_C GSsetGameCRC(uint32 crc, int options)
void GSsetGameCRC(uint32 crc, int options)
{
s_gs->SetGameCRC(crc, options);
}
EXPORT_C GSgetLastTag(uint32* tag)
void GSgetLastTag(uint32* tag)
{
s_gs->GetLastTag(tag);
}
EXPORT_C GSgetTitleInfo2(char* dest, size_t length)
void GSgetTitleInfo2(char* dest, size_t length)
{
std::string s;
s.append(s_renderer_name);
@ -883,12 +861,12 @@ EXPORT_C GSgetTitleInfo2(char* dest, size_t length)
strcpy(dest, s.c_str());
}
EXPORT_C GSsetFrameSkip(int frameskip)
void GSsetFrameSkip(int frameskip)
{
s_gs->SetFrameSkip(frameskip);
}
EXPORT_C GSsetVsync(int vsync)
void GSsetVsync(int vsync)
{
s_vsync = vsync;
@ -898,7 +876,7 @@ EXPORT_C GSsetVsync(int vsync)
}
}
EXPORT_C GSsetExclusive(int enabled)
void GSsetExclusive(int enabled)
{
s_exclusive = !!enabled;
@ -985,7 +963,7 @@ public:
// First parameter is the renderer.
// Second parameter is the gs file to load and run.
EXPORT_C GSReplay(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
void GSReplay(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
{
GSRendererType renderer = GSRendererType::Undefined;
@ -1131,7 +1109,7 @@ EXPORT_C GSReplay(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
GSshutdown();
}
EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
void GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
{
::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS);
@ -1348,7 +1326,7 @@ inline unsigned long timeGetTime()
}
// Note
EXPORT_C GSReplay(char* lpszCmdLine, int renderer)
void GSReplay(char* lpszCmdLine, int renderer)
{
GLLoader::in_replayer = true;
// Required by multithread driver

View File

@ -24,8 +24,6 @@
// This file is filled with stuff that breaks clang-format
// clang-format off
#define PLUGIN_VERSION 0
#define VM_SIZE 4194304u
#define HALF_VM_SIZE (VM_SIZE / 2u)
#define PAGE_SIZE 8192u
@ -1455,11 +1453,12 @@ struct GSFreezeData
uint8* data;
};
// ST_WRITE is defined in libc, avoid this
enum stateType
{
ST_WRITE,
ST_TRANSFER,
ST_VSYNC
SAVE_WRITE,
SAVE_TRANSFER,
SAVE_VSYNC
};
enum class GSVideoMode : uint8
@ -1512,3 +1511,40 @@ const GSVector2i default_rt_size(2048, 2048);
#else
const GSVector2i default_rt_size(1280, 1024);
#endif
void GSsetBaseMem(uint8* mem);
void GSsetSettingsDir(const char* dir);
int GSinit();
void GSshutdown();
void GSclose();
int _GSopen(void** dsp, const char* title, GSRendererType renderer, int threads = -1);
void GSosdLog(const char* utf8, uint32 color);
void GSosdMonitor(const char* key, const char* value, uint32 color);
int GSopen2(void** dsp, uint32 flags);
int GSopen(void** dsp, const char* title, int mt);
void GSreset();
void GSgifSoftReset(uint32 mask);
void GSwriteCSR(uint32 csr);
void GSinitReadFIFO(uint8* mem);
void GSreadFIFO(uint8* mem);
void GSinitReadFIFO2(uint8* mem, uint32 size);
void GSreadFIFO2(uint8* mem, uint32 size);
void GSgifTransfer(const uint8* mem, uint32 size);
void GSgifTransfer1(uint8* mem, uint32 addr);
void GSgifTransfer2(uint8* mem, uint32 size);
void GSgifTransfer3(uint8* mem, uint32 size);
void GSvsync(int field);
uint32 GSmakeSnapshot(char* path);
void GSkeyEvent(GSKeyEventData* e);
int GSfreeze(int mode, GSFreezeData* data);
void GSconfigure();
int GStest();
void GSirqCallback(void (*irq)());
bool GSsetupRecording(std::string& filename);
void GSendRecording();
void GSsetGameCRC(uint32 crc, int options);
void GSgetLastTag(uint32* tag);
void GSgetTitleInfo2(char* dest, size_t length);
void GSsetFrameSkip(int frameskip);
void GSsetVsync(int vsync);
void GSsetExclusive(int enabled);

View File

@ -231,20 +231,3 @@ void fifo_free(void* ptr, size_t size, size_t repeat)
}
#endif
#if !defined(_MSC_VER)
// declare linux equivalents (alignment must be power of 2 (1,2,4...2^15)
#if !defined(__USE_ISOC11) || defined(ASAN_WORKAROUND)
void* _aligned_malloc(size_t size, size_t alignment)
{
void* ret = 0;
posix_memalign(&ret, alignment, size);
return ret;
}
#endif
#endif

View File

@ -26,6 +26,7 @@
#pragma once
#include "config.h"
#include "Pcsx2Types.h"
#ifdef _WIN32
@ -49,8 +50,6 @@
#endif
#include <PluginCompatibility.h>
#ifdef __x86_64__
#define _M_AMD64
#endif
@ -65,12 +64,6 @@ typedef unsigned int uint32;
typedef signed int int32;
typedef unsigned long long uint64;
typedef signed long long int64;
#ifdef _M_AMD64
typedef uint64 uptr;
#else
typedef uint32 uptr;
#endif
// xbyak compatibilities
typedef int64 sint64;
@ -167,10 +160,6 @@ typedef int64 sint64;
#define EXPORT_C EXPORT_C_(void)
#ifdef __GNUC__
#define __forceinline __inline__ __attribute__((always_inline,unused))
// #define __forceinline __inline__ __attribute__((__always_inline__, __gnu_inline__))
#define __assume(c) do { if (!(c)) __builtin_unreachable(); } while(0)
// GCC removes the variable as dead code and generates some warnings.
// Stack is automatically realigned due to SSE/AVX operations
#define ALIGN_STACK(n) (void)0;
@ -289,21 +278,6 @@ typedef int64 sint64;
#undef abs
#if !defined(_MSC_VER)
#if defined(__USE_ISOC11) && !defined(ASAN_WORKAROUND) // not supported yet on gcc 4.9
#define _aligned_malloc(size, a) aligned_alloc(a, size)
#else
extern void* _aligned_malloc(size_t size, size_t alignment);
#endif
static inline void _aligned_free(void* p)
{
free(p);
}
// http://svn.reactos.org/svn/reactos/trunk/reactos/include/crt/mingw32/intrin_x86.h?view=markup
__forceinline int _BitScanForward(unsigned long* const Index, const unsigned long Mask)

View File

@ -59,32 +59,6 @@ enum GIF_PATH_STATE {
GIF_PATH_WAIT = 4 // Used only by PATH3 to simulate packet length (Path 3 Masking)
};
enum GIF_FLG {
GIF_FLG_PACKED = 0,
GIF_FLG_REGLIST = 1,
GIF_FLG_IMAGE = 2,
GIF_FLG_IMAGE2 = 3
};
enum GIF_REG {
GIF_REG_PRIM = 0x00,
GIF_REG_RGBA = 0x01,
GIF_REG_STQ = 0x02,
GIF_REG_UV = 0x03,
GIF_REG_XYZF2 = 0x04,
GIF_REG_XYZ2 = 0x05,
GIF_REG_TEX0_1 = 0x06,
GIF_REG_TEX0_2 = 0x07,
GIF_REG_CLAMP_1 = 0x08,
GIF_REG_CLAMP_2 = 0x09,
GIF_REG_FOG = 0x0a,
GIF_REG_INVALID = 0x0b,
GIF_REG_XYZF3 = 0x0c,
GIF_REG_XYZ3 = 0x0d,
GIF_REG_A_D = 0x0e,
GIF_REG_NOP = 0x0f,
};
enum gifstate_t {
GIF_STATE_READY = 0,
GIF_STATE_EMPTY = 0x10

View File

@ -16,6 +16,7 @@
#include "PrecompiledHeader.h"
#include "Common.h"
#include "Gif_Unit.h"
#include "Gif.h"
#define GIF_PARSE DevCon.WriteLn

View File

@ -19,45 +19,7 @@
#include "SaveState.h"
#include "Saveslots.h"
// --------------------------------------------------------------------------------------
// SysExecEvent_SaveSinglePlugin
// --------------------------------------------------------------------------------------
// fixme : Ideally this should use either Close or Pause depending on if the system is in
// Fullscreen Exclusive mode or regular mode. But since we don't yet support Fullscreen
// Exclusive mode, and since I'm too lazy to make some third suspend class for that, we're
// just using CoreThreadPause. --air
//
class SysExecEvent_SaveSinglePlugin : public BaseSysExecEvent_ScopedCore
{
typedef BaseSysExecEvent_ScopedCore _parent;
protected:
PluginsEnum_t m_pid;
public:
wxString GetEventName() const { return L"SaveSinglePlugin"; }
virtual ~SysExecEvent_SaveSinglePlugin() = default;
SysExecEvent_SaveSinglePlugin* Clone() const { return new SysExecEvent_SaveSinglePlugin( *this ); }
SysExecEvent_SaveSinglePlugin( PluginsEnum_t pid=PluginId_GS )
{
m_pid = pid;
}
SysExecEvent_SaveSinglePlugin& SetPluginId( PluginsEnum_t pid )
{
m_pid = pid;
return *this;
}
protected:
void InvokeEvent();
void CleanupEvent();
};
extern void StateCopy_SaveToFile( const wxString& file );
extern void StateCopy_LoadFromFile( const wxString& file );
extern void StateCopy_SaveToSlot( uint num );
extern void StateCopy_LoadFromSlot( uint slot, bool isFromBackup = false );
extern void StateCopy_SaveToFile(const wxString& file);
extern void StateCopy_LoadFromFile(const wxString& file);
extern void StateCopy_SaveToSlot(uint num);
extern void StateCopy_LoadFromSlot(uint slot, bool isFromBackup = false);