diff --git a/common/Pcsx2Defs.h b/common/Pcsx2Defs.h index 97efb33010..c1a4d39efe 100644 --- a/common/Pcsx2Defs.h +++ b/common/Pcsx2Defs.h @@ -216,6 +216,10 @@ static const int __pagesize = PCSX2_PAGESIZE; #define __has_attribute(x) 0 #endif +#ifndef __has_builtin + #define __has_builtin(x) 0 +#endif + #ifdef __cpp_constinit #define CONSTINIT constinit #elif __has_attribute(require_constant_initialization) diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index d15e398d68..cea70b91ba 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -670,7 +670,10 @@ set(pcsx2GSHeaders GS/GSDrawingContext.h GS/GSDrawingEnvironment.h GS/GSDump.h - GS/GS_types.h + GS/GSExtra.h + GS/GSGL.h + GS/GSIntrin.h + GS/GSRegs.h GS/GS.h GS/GSLocalMemory.h GS/GSLzma.h diff --git a/pcsx2/GS.cpp b/pcsx2/GS.cpp index cc15f7ec7c..0839975175 100644 --- a/pcsx2/GS.cpp +++ b/pcsx2/GS.cpp @@ -18,7 +18,6 @@ #include -#include "GS.h" #include "Gif_Unit.h" #include "Counters.h" #include "Config.h" diff --git a/pcsx2/GS/GS.cpp b/pcsx2/GS/GS.cpp index 7a9c3e3857..a79587878d 100644 --- a/pcsx2/GS/GS.cpp +++ b/pcsx2/GS/GS.cpp @@ -17,7 +17,7 @@ #include "GS/Window/GSwxDialog.h" #include "GS.h" #include "GSUtil.h" -#include "GS_types.h" +#include "GSExtra.h" #include "Renderers/SW/GSRendererSW.h" #include "Renderers/Null/GSRendererNull.h" #include "Renderers/Null/GSDeviceNull.h" diff --git a/pcsx2/GS/GS.h b/pcsx2/GS/GS.h index 8cccdaefcc..b2bff8bc0e 100644 --- a/pcsx2/GS/GS.h +++ b/pcsx2/GS/GS.h @@ -15,13 +15,10 @@ #pragma once -// This file is filled with stuff that breaks clang-format -// clang-format off - -#include "config.h" -#include "common/Pcsx2Types.h" +#include "common/WindowInfo.h" #include "Window/GSSetting.h" #include "SaveState.h" +#include "Host.h" #ifdef _WIN32 @@ -35,360 +32,13 @@ #endif -#include "Renderers/OpenGL/GLLoader.h" - -#ifdef _WIN32 - - #define DIRECTORY_SEPARATOR '\\' - -#else - - #include // mkdir - - #define DIRECTORY_SEPARATOR '/' - -#endif - #include -#ifdef __POSIX__ -#include -#else -#include +#ifdef None + // X11 seems to like to define this, not fun + #undef None #endif -// Don't un-indent our ifdefs -// clang-format off - -#ifdef _MSC_VER - #define ALIGN_STACK(n) alignas(n) int dummy__; (void)dummy__; -#else - #ifdef __GNUC__ - // 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; - #else - // TODO Check clang behavior - #define ALIGN_STACK(n) alignas(n) int dummy__; - #endif -#endif - -#include -#include - -#include -#include - -#if _M_SSE >= 0x500 - - #include - -#endif - -#undef min -#undef max -#undef abs - -#if !defined(_MSC_VER) - // http://svn.reactos.org/svn/reactos/trunk/reactos/include/crt/mingw32/intrin_x86.h?view=markup - - static int _BitScanForward(unsigned long* const Index, const unsigned long Mask) - { -#if defined(__GCC_ASM_FLAG_OUTPUTS__) && 0 - // Need GCC6 to test the code validity - int flag; - __asm__("bsfl %k[Mask], %k[Index]" : [Index] "=r" (*Index), "=@ccz" (flag) : [Mask] "mr" (Mask)); - return flag; -#else - __asm__("bsfl %k[Mask], %k[Index]" : [Index] "=r" (*Index) : [Mask] "mr" (Mask) : "cc"); - return Mask ? 1 : 0; -#endif - } - -#endif - -extern std::string format(const char* fmt, ...); - -extern void* vmalloc(size_t size, bool code); -extern void vmfree(void* ptr, size_t size); - -extern void* fifo_alloc(size_t size, size_t repeat); -extern void fifo_free(void* ptr, size_t size, size_t repeat); - -#ifdef ENABLE_VTUNE - - #include "jitprofiling.h" - - #ifdef _WIN32 - - #pragma comment(lib, "jitprofiling.lib") - - #endif - -#endif - -// Note: GL messages are present in common code, so in all renderers. - -#define GL_INSERT(type, code, sev, ...) \ - do \ - if (glDebugMessageInsert) glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, type, code, sev, -1, format(__VA_ARGS__).c_str()); \ - while(0); - -#if defined(_DEBUG) - #define GL_CACHE(...) GL_INSERT(GL_DEBUG_TYPE_OTHER, 0xFEAD, GL_DEBUG_SEVERITY_NOTIFICATION, __VA_ARGS__) -#else - #define GL_CACHE(...) (void)(0); -#endif - -#if defined(ENABLE_TRACE_REG) && defined(_DEBUG) - #define GL_REG(...) GL_INSERT(GL_DEBUG_TYPE_OTHER, 0xB0B0, GL_DEBUG_SEVERITY_NOTIFICATION, __VA_ARGS__) -#else - #define GL_REG(...) (void)(0); -#endif - -#if defined(ENABLE_EXTRA_LOG) && defined(_DEBUG) - #define GL_DBG(...) GL_INSERT(GL_DEBUG_TYPE_OTHER, 0xD0D0, GL_DEBUG_SEVERITY_NOTIFICATION, __VA_ARGS__) -#else - #define GL_DBG(...) (void)(0); -#endif - -#if defined(ENABLE_OGL_DEBUG) - struct GLAutoPop - { - ~GLAutoPop() - { - if (glPopDebugGroup) - glPopDebugGroup(); - } - }; - - #define GL_PUSH_(...) do if (glPushDebugGroup) glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0xBAD, -1, format(__VA_ARGS__).c_str()); while(0); - #define GL_PUSH(...) do if (glPushDebugGroup) glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0xBAD, -1, format(__VA_ARGS__).c_str()); while(0); GLAutoPop gl_auto_pop; - #define GL_POP() do if (glPopDebugGroup) glPopDebugGroup(); while(0); - #define GL_INS(...) GL_INSERT(GL_DEBUG_TYPE_ERROR, 0xDEAD, GL_DEBUG_SEVERITY_MEDIUM, __VA_ARGS__) - #define GL_PERF(...) GL_INSERT(GL_DEBUG_TYPE_PERFORMANCE, 0xFEE1, GL_DEBUG_SEVERITY_NOTIFICATION, __VA_ARGS__) -#else - #define GL_PUSH_(...) (void)(0); - #define GL_PUSH(...) (void)(0); - #define GL_POP() (void)(0); - #define GL_INS(...) (void)(0); - #define GL_PERF(...) (void)(0); -#endif - -// Helper path to dump texture -extern const std::string root_sw; -extern const std::string root_hw; - -// MacOS headers define PAGE_SIZE to the size of an x86 page -#ifdef PAGE_SIZE - #undef PAGE_SIZE -#endif - -#define VM_SIZE 4194304u -#define HALF_VM_SIZE (VM_SIZE / 2u) -#define PAGE_SIZE 8192u -#define BLOCK_SIZE 256u -#define COLUMN_SIZE 64u - -#define MAX_PAGES (VM_SIZE / PAGE_SIZE) -#define MAX_BLOCKS (VM_SIZE / BLOCK_SIZE) -#define MAX_COLUMNS (VM_SIZE / COLUMN_SIZE) - -//if defined, will send much info in reply to the API title info queri from PCSX2 -//default should be undefined -//#define GSTITLEINFO_API_FORCE_VERBOSE - -#include "GSVector.h" - -#pragma pack(push, 1) - -enum GS_PRIM -{ - GS_POINTLIST = 0, - GS_LINELIST = 1, - GS_LINESTRIP = 2, - GS_TRIANGLELIST = 3, - GS_TRIANGLESTRIP = 4, - GS_TRIANGLEFAN = 5, - GS_SPRITE = 6, - GS_INVALID = 7, -}; - -enum GS_PRIM_CLASS -{ - GS_POINT_CLASS = 0, - GS_LINE_CLASS = 1, - GS_TRIANGLE_CLASS = 2, - GS_SPRITE_CLASS = 3, - GS_INVALID_CLASS = 7, -}; - -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 GIF_REG_COMPLEX -{ - GIF_REG_STQRGBAXYZF2 = 0x00, - GIF_REG_STQRGBAXYZ2 = 0x01, -}; - -enum GIF_A_D_REG -{ - GIF_A_D_REG_PRIM = 0x00, - GIF_A_D_REG_RGBAQ = 0x01, - GIF_A_D_REG_ST = 0x02, - GIF_A_D_REG_UV = 0x03, - GIF_A_D_REG_XYZF2 = 0x04, - GIF_A_D_REG_XYZ2 = 0x05, - GIF_A_D_REG_TEX0_1 = 0x06, - GIF_A_D_REG_TEX0_2 = 0x07, - GIF_A_D_REG_CLAMP_1 = 0x08, - GIF_A_D_REG_CLAMP_2 = 0x09, - GIF_A_D_REG_FOG = 0x0a, - GIF_A_D_REG_XYZF3 = 0x0c, - GIF_A_D_REG_XYZ3 = 0x0d, - GIF_A_D_REG_NOP = 0x0f, - GIF_A_D_REG_TEX1_1 = 0x14, - GIF_A_D_REG_TEX1_2 = 0x15, - GIF_A_D_REG_TEX2_1 = 0x16, - GIF_A_D_REG_TEX2_2 = 0x17, - GIF_A_D_REG_XYOFFSET_1 = 0x18, - GIF_A_D_REG_XYOFFSET_2 = 0x19, - GIF_A_D_REG_PRMODECONT = 0x1a, - GIF_A_D_REG_PRMODE = 0x1b, - GIF_A_D_REG_TEXCLUT = 0x1c, - GIF_A_D_REG_SCANMSK = 0x22, - GIF_A_D_REG_MIPTBP1_1 = 0x34, - GIF_A_D_REG_MIPTBP1_2 = 0x35, - GIF_A_D_REG_MIPTBP2_1 = 0x36, - GIF_A_D_REG_MIPTBP2_2 = 0x37, - GIF_A_D_REG_TEXA = 0x3b, - GIF_A_D_REG_FOGCOL = 0x3d, - GIF_A_D_REG_TEXFLUSH = 0x3f, - GIF_A_D_REG_SCISSOR_1 = 0x40, - GIF_A_D_REG_SCISSOR_2 = 0x41, - GIF_A_D_REG_ALPHA_1 = 0x42, - GIF_A_D_REG_ALPHA_2 = 0x43, - GIF_A_D_REG_DIMX = 0x44, - GIF_A_D_REG_DTHE = 0x45, - GIF_A_D_REG_COLCLAMP = 0x46, - GIF_A_D_REG_TEST_1 = 0x47, - GIF_A_D_REG_TEST_2 = 0x48, - GIF_A_D_REG_PABE = 0x49, - GIF_A_D_REG_FBA_1 = 0x4a, - GIF_A_D_REG_FBA_2 = 0x4b, - GIF_A_D_REG_FRAME_1 = 0x4c, - GIF_A_D_REG_FRAME_2 = 0x4d, - GIF_A_D_REG_ZBUF_1 = 0x4e, - GIF_A_D_REG_ZBUF_2 = 0x4f, - GIF_A_D_REG_BITBLTBUF = 0x50, - GIF_A_D_REG_TRXPOS = 0x51, - GIF_A_D_REG_TRXREG = 0x52, - GIF_A_D_REG_TRXDIR = 0x53, - GIF_A_D_REG_HWREG = 0x54, - GIF_A_D_REG_SIGNAL = 0x60, - GIF_A_D_REG_FINISH = 0x61, - GIF_A_D_REG_LABEL = 0x62, -}; - -enum GIF_FLG -{ - GIF_FLG_PACKED = 0, - GIF_FLG_REGLIST = 1, - GIF_FLG_IMAGE = 2, - GIF_FLG_IMAGE2 = 3, -}; - -enum GS_PSM -{ - PSM_PSMCT32 = 0, // 0000-0000 - PSM_PSMCT24 = 1, // 0000-0001 - PSM_PSMCT16 = 2, // 0000-0010 - PSM_PSMCT16S = 10, // 0000-1010 - PSM_PSGPU24 = 18, // 0001-0010 - PSM_PSMT8 = 19, // 0001-0011 - PSM_PSMT4 = 20, // 0001-0100 - PSM_PSMT8H = 27, // 0001-1011 - PSM_PSMT4HL = 36, // 0010-0100 - PSM_PSMT4HH = 44, // 0010-1100 - PSM_PSMZ32 = 48, // 0011-0000 - PSM_PSMZ24 = 49, // 0011-0001 - PSM_PSMZ16 = 50, // 0011-0010 - PSM_PSMZ16S = 58, // 0011-1010 -}; - -enum GS_TFX -{ - TFX_MODULATE = 0, - TFX_DECAL = 1, - TFX_HIGHLIGHT = 2, - TFX_HIGHLIGHT2 = 3, - TFX_NONE = 4, -}; - -enum GS_CLAMP -{ - CLAMP_REPEAT = 0, - CLAMP_CLAMP = 1, - CLAMP_REGION_CLAMP = 2, - CLAMP_REGION_REPEAT = 3, -}; - -enum GS_ZTST -{ - ZTST_NEVER = 0, - ZTST_ALWAYS = 1, - ZTST_GEQUAL = 2, - ZTST_GREATER = 3, -}; - -enum GS_ATST -{ - ATST_NEVER = 0, - ATST_ALWAYS = 1, - ATST_LESS = 2, - ATST_LEQUAL = 3, - ATST_EQUAL = 4, - ATST_GEQUAL = 5, - ATST_GREATER = 6, - ATST_NOTEQUAL = 7, -}; - -enum GS_AFAIL -{ - AFAIL_KEEP = 0, - AFAIL_FB_ONLY = 1, - AFAIL_ZB_ONLY = 2, - AFAIL_RGB_ONLY = 3, -}; - -enum class GS_MIN_FILTER : uint8_t -{ - Nearest = 0, - Linear = 1, - Nearest_Mipmap_Nearest = 2, - Nearest_Mipmap_Linear = 3, - Linear_Mipmap_Nearest = 4, - Linear_Mipmap_Linear = 5, -}; - enum class GSRendererType : int8_t { Undefined = -1, @@ -405,1192 +55,8 @@ enum class GSRendererType : int8_t // GSRenderOGL only GSDeviceOGL (not GSDeviceNULL) Default = OGL_HW #endif - }; - -#define REG32(name) \ - union name \ - { \ - u32 U32; \ - struct { \ - -#define REG64(name) \ - union name \ - { \ - u64 U64; \ - u32 U32[2]; \ - void operator = (const GSVector4i& v) {GSVector4i::storel(this, v);} \ - bool operator == (const union name& r) const {return ((GSVector4i)r).eq(*this);} \ - bool operator != (const union name& r) const {return !((GSVector4i)r).eq(*this);} \ - operator GSVector4i() const {return GSVector4i::loadl(this);} \ - struct { - -#define REG128(name) \ - union name \ - { \ - u64 U64[2]; \ - u32 U32[4]; \ - struct { - -#define REG32_(prefix, name) REG32(prefix##name) -#define REG64_(prefix, name) REG64(prefix##name) -#define REG128_(prefix, name) REG128(prefix##name) - -#define REG_END }; }; -#define REG_END2 }; - -#define REG32_SET(name) \ -union name \ -{ \ - u32 u32; - -#define REG64_SET(name) \ - union name \ - { \ - u64 U64; \ - u32 U32[2]; - -#define REG128_SET(name) \ - union name \ - { \ - __m128i m128; \ - u64 U64[2]; \ - u32 U32[4]; - -#define REG_SET_END }; - -REG64_(GSReg, BGCOLOR) - u8 R; - u8 G; - u8 B; - u8 _PAD1[5]; -REG_END - -REG64_(GSReg, BUSDIR) - u32 DIR : 1; - u32 _PAD1 : 31; - u32 _PAD2 : 32; -REG_END - -REG64_(GSReg, CSR) - u32 rSIGNAL : 1; - u32 rFINISH : 1; - u32 rHSINT : 1; - u32 rVSINT : 1; - u32 rEDWINT : 1; - u32 rZERO1 : 1; - u32 rZERO2 : 1; - u32 r_PAD1 : 1; - u32 rFLUSH : 1; - u32 rRESET : 1; - u32 r_PAD2 : 2; - u32 rNFIELD : 1; - u32 rFIELD : 1; - u32 rFIFO : 2; - u32 rREV : 8; - u32 rID : 8; - u32 wSIGNAL : 1; - u32 wFINISH : 1; - u32 wHSINT : 1; - u32 wVSINT : 1; - u32 wEDWINT : 1; - u32 wZERO1 : 1; - u32 wZERO2 : 1; - u32 w_PAD1 : 1; - u32 wFLUSH : 1; - u32 wRESET : 1; - u32 w_PAD2 : 2; - u32 wNFIELD : 1; - u32 wFIELD : 1; - u32 wFIFO : 2; - u32 wREV : 8; - u32 wID : 8; -REG_END - -REG64_(GSReg, DISPFB) // (-1/2) - u32 FBP : 9; - u32 FBW : 6; - u32 PSM : 5; - u32 _PAD : 12; - u32 DBX : 11; - u32 DBY : 11; - u32 _PAD2 : 10; -REG_END2 - u32 Block() const { return FBP << 5; } -REG_END2 - -REG64_(GSReg, DISPLAY) // (-1/2) - u32 DX : 12; - u32 DY : 11; - u32 MAGH : 4; - u32 MAGV : 2; - u32 _PAD : 3; - u32 DW : 12; - u32 DH : 11; - u32 _PAD2 : 9; -REG_END - -REG64_(GSReg, EXTBUF) - u32 EXBP : 14; - u32 EXBW : 6; - u32 FBIN : 2; - u32 WFFMD : 1; - u32 EMODA : 2; - u32 EMODC : 2; - u32 _PAD1 : 5; - u32 WDX : 11; - u32 WDY : 11; - u32 _PAD2 : 10; -REG_END - -REG64_(GSReg, EXTDATA) - u32 SX : 12; - u32 SY : 11; - u32 SMPH : 4; - u32 SMPV : 2; - u32 _PAD1 : 3; - u32 WW : 12; - u32 WH : 11; - u32 _PAD2 : 9; -REG_END - -REG64_(GSReg, EXTWRITE) - u32 WRITE : 1; - u32 _PAD1 : 31; - u32 _PAD2 : 32; -REG_END - -REG64_(GSReg, IMR) - u32 _PAD1 : 8; - u32 SIGMSK : 1; - u32 FINISHMSK : 1; - u32 HSMSK : 1; - u32 VSMSK : 1; - u32 EDWMSK : 1; - u32 _PAD2 : 19; - u32 _PAD3 : 32; -REG_END - -REG64_(GSReg, PMODE) -union -{ - struct - { - u32 EN1 : 1; - u32 EN2 : 1; - u32 CRTMD : 3; - u32 MMOD : 1; - u32 AMOD : 1; - u32 SLBG : 1; - u32 ALP : 8; - u32 _PAD : 16; - u32 _PAD1 : 32; - }; - - struct - { - u32 EN : 2; - u32 _PAD2 : 30; - u32 _PAD3 : 32; - }; -}; -REG_END - -REG64_(GSReg, SIGLBLID) - u32 SIGID; - u32 LBLID; -REG_END - -REG64_(GSReg, SMODE1) - u32 RC : 3; - u32 LC : 7; - u32 T1248 : 2; - u32 SLCK : 1; - u32 CMOD : 2; - u32 EX : 1; - u32 PRST : 1; - u32 SINT : 1; - u32 XPCK : 1; - u32 PCK2 : 2; - u32 SPML : 4; - u32 GCONT : 1; // YCrCb - u32 PHS : 1; - u32 PVS : 1; - u32 PEHS : 1; - u32 PEVS : 1; - u32 CLKSEL : 2; - u32 NVCK : 1; - u32 SLCK2 : 1; - u32 VCKSEL : 2; - u32 VHP : 1; - u32 _PAD1 : 27; -REG_END - -/* - -// pal - -CLKSEL=1 CMOD=3 EX=0 GCONT=0 LC=32 NVCK=1 PCK2=0 PEHS=0 PEVS=0 PHS=0 PRST=1 PVS=0 RC=4 SINT=0 SLCK=0 SLCK2=1 SPML=4 T1248=1 VCKSEL=1 VHP=0 XPCK=0 - -// ntsc - -CLKSEL=1 CMOD=2 EX=0 GCONT=0 LC=32 NVCK=1 PCK2=0 PEHS=0 PEVS=0 PHS=0 PRST=1 PVS=0 RC=4 SINT=0 SLCK=0 SLCK2=1 SPML=4 T1248=1 VCKSEL=1 VHP=0 XPCK=0 - -// ntsc progressive (SoTC) - -CLKSEL=1 CMOD=0 EX=0 GCONT=0 LC=32 NVCK=1 PCK2=0 PEHS=0 PEVS=0 PHS=0 PRST=1 PVS=0 RC=4 SINT=0 SLCK=0 SLCK2=1 SPML=2 T1248=1 VCKSEL=1 VHP=1 XPCK=0 - -*/ - -REG64_(GSReg, SMODE2) - u32 INT : 1; - u32 FFMD : 1; - u32 DPMS : 2; - u32 _PAD2 : 28; - u32 _PAD3 : 32; -REG_END - -REG64_(GSReg, SRFSH) - u32 _DUMMY; - // TODO -REG_END - -REG64_(GSReg, SYNCH1) - u32 _DUMMY; - // TODO -REG_END - -REG64_(GSReg, SYNCH2) - u32 _DUMMY; - // TODO -REG_END - -REG64_(GSReg, SYNCV) - u32 VFP : 10; // Vertical Front Porchinterval (?s) - u32 VFPE : 10; // Vertical Front Porchinterval End (?s) - u32 VBP : 12; // Vertical Back Porchinterval (?s) - u32 VBPE : 10; // Vertical Back Porchinterval End (?s) - u32 VDP : 11; // Vertical Differential Phase - u32 VS : 11; // Vertical Synchronization Timing -REG_END - -REG64_SET(GSReg) - GSRegBGCOLOR BGCOLOR; - GSRegBUSDIR BUSDIR; - GSRegCSR CSR; - GSRegDISPFB DISPFB; - GSRegDISPLAY DISPLAY; - GSRegEXTBUF EXTBUF; - GSRegEXTDATA EXTDATA; - GSRegEXTWRITE EXTWRITE; - GSRegIMR IMR; - GSRegPMODE PMODE; - GSRegSIGLBLID SIGLBLID; - GSRegSMODE1 SMODE1; - GSRegSMODE2 SMODE2; -REG_SET_END - -// -// GIFTag - -REG128(GIFTag) - u32 NLOOP : 15; - u32 EOP : 1; - u32 _PAD1 : 16; - u32 _PAD2 : 14; - u32 PRE : 1; - u32 PRIM : 11; - u32 FLG : 2; // enum GIF_FLG - u32 NREG : 4; - u64 REGS; -REG_END - -// GIFReg - -REG64_(GIFReg, ALPHA) - u32 A : 2; - u32 B : 2; - u32 C : 2; - u32 D : 2; - u32 _PAD1 : 24; - u8 FIX; - u8 _PAD2[3]; -REG_END2 - // opaque => output will be Cs/As - __forceinline bool IsOpaque() const { return ((A == B || (C == 2 && FIX == 0)) && D == 0) || (A == 0 && B == D && C == 2 && FIX == 0x80); } - __forceinline bool IsOpaque(int amin, int amax) const { return ((A == B || amax == 0) && D == 0) || (A == 0 && B == D && amin == 0x80 && amax == 0x80); } - __forceinline bool IsCd() { return (A == B) && (D == 1); } -REG_END2 - -REG64_(GIFReg, BITBLTBUF) - u32 SBP : 14; - u32 _PAD1 : 2; - u32 SBW : 6; - u32 _PAD2 : 2; - u32 SPSM : 6; - u32 _PAD3 : 2; - u32 DBP : 14; - u32 _PAD4 : 2; - u32 DBW : 6; - u32 _PAD5 : 2; - u32 DPSM : 6; - u32 _PAD6 : 2; -REG_END - -REG64_(GIFReg, CLAMP) -union -{ - struct - { - u32 WMS : 2; - u32 WMT : 2; - u32 MINU : 10; - u32 MAXU : 10; - u32 _PAD1 : 8; - u32 _PAD2 : 2; - u32 MAXV : 10; - u32 _PAD3 : 20; - }; - - struct - { - u64 _PAD4 : 24; - u64 MINV : 10; - u64 _PAD5 : 30; - }; -}; -REG_END - -REG64_(GIFReg, COLCLAMP) - u32 CLAMP : 1; - u32 _PAD1 : 31; - u32 _PAD2 : 32; -REG_END - -REG64_(GIFReg, DIMX) - s32 DM00 : 3; - s32 _PAD00 : 1; - s32 DM01 : 3; - s32 _PAD01 : 1; - s32 DM02 : 3; - s32 _PAD02 : 1; - s32 DM03 : 3; - s32 _PAD03 : 1; - s32 DM10 : 3; - s32 _PAD10 : 1; - s32 DM11 : 3; - s32 _PAD11 : 1; - s32 DM12 : 3; - s32 _PAD12 : 1; - s32 DM13 : 3; - s32 _PAD13 : 1; - s32 DM20 : 3; - s32 _PAD20 : 1; - s32 DM21 : 3; - s32 _PAD21 : 1; - s32 DM22 : 3; - s32 _PAD22 : 1; - s32 DM23 : 3; - s32 _PAD23 : 1; - s32 DM30 : 3; - s32 _PAD30 : 1; - s32 DM31 : 3; - s32 _PAD31 : 1; - s32 DM32 : 3; - s32 _PAD32 : 1; - s32 DM33 : 3; - s32 _PAD33 : 1; -REG_END - -REG64_(GIFReg, DTHE) - u32 DTHE : 1; - u32 _PAD1 : 31; - u32 _PAD2 : 32; -REG_END - -REG64_(GIFReg, FBA) - u32 FBA : 1; - u32 _PAD1 : 31; - u32 _PAD2 : 32; -REG_END - -REG64_(GIFReg, FINISH) - u32 _PAD1[2]; -REG_END - -REG64_(GIFReg, FOG) - u8 _PAD1[7]; - u8 F; -REG_END - -REG64_(GIFReg, FOGCOL) - u8 FCR; - u8 FCG; - u8 FCB; - u8 _PAD1[5]; -REG_END - -REG64_(GIFReg, FRAME) - u32 FBP : 9; - u32 _PAD1 : 7; - u32 FBW : 6; - u32 _PAD2 : 2; - u32 PSM : 6; - u32 _PAD3 : 2; - u32 FBMSK; -REG_END2 - u32 Block() const { return FBP << 5; } -REG_END2 - -REG64_(GIFReg, HWREG) - u32 DATA_LOWER; - u32 DATA_UPPER; -REG_END - -REG64_(GIFReg, LABEL) - u32 ID; - u32 IDMSK; -REG_END - -REG64_(GIFReg, MIPTBP1) - u64 TBP1 : 14; - u64 TBW1 : 6; - u64 TBP2 : 14; - u64 TBW2 : 6; - u64 TBP3 : 14; - u64 TBW3 : 6; - u64 _PAD : 4; -REG_END - -REG64_(GIFReg, MIPTBP2) - u64 TBP4 : 14; - u64 TBW4 : 6; - u64 TBP5 : 14; - u64 TBW5 : 6; - u64 TBP6 : 14; - u64 TBW6 : 6; - u64 _PAD : 4; -REG_END - -REG64_(GIFReg, NOP) - u32 _PAD[2]; -REG_END - -REG64_(GIFReg, PABE) - u32 PABE : 1; - u32 _PAD1 : 31; - u32 _PAD2 : 32; -REG_END - -REG64_(GIFReg, PRIM) - u32 PRIM : 3; - u32 IIP : 1; - u32 TME : 1; - u32 FGE : 1; - u32 ABE : 1; - u32 AA1 : 1; - u32 FST : 1; - u32 CTXT : 1; - u32 FIX : 1; - u32 _PAD1 : 21; - u32 _PAD2 : 32; -REG_END - -REG64_(GIFReg, PRMODE) - u32 _PRIM : 3; - u32 IIP : 1; - u32 TME : 1; - u32 FGE : 1; - u32 ABE : 1; - u32 AA1 : 1; - u32 FST : 1; - u32 CTXT : 1; - u32 FIX : 1; - u32 _PAD2 : 21; - u32 _PAD3 : 32; -REG_END - -REG64_(GIFReg, PRMODECONT) - u32 AC : 1; - u32 _PAD1 : 31; - u32 _PAD2 : 32; -REG_END - -REG64_(GIFReg, RGBAQ) - u8 R; - u8 G; - u8 B; - u8 A; - float Q; -REG_END - -REG64_(GIFReg, SCANMSK) - u32 MSK : 2; - u32 _PAD1 : 30; - u32 _PAD2 : 32; -REG_END - -REG64_(GIFReg, SCISSOR) - u32 SCAX0 : 11; - u32 _PAD1 : 5; - u32 SCAX1 : 11; - u32 _PAD2 : 5; - u32 SCAY0 : 11; - u32 _PAD3 : 5; - u32 SCAY1 : 11; - u32 _PAD4 : 5; -REG_END - -REG64_(GIFReg, SIGNAL) - u32 ID; - u32 IDMSK; -REG_END - -REG64_(GIFReg, ST) - float S; - float T; -REG_END - -REG64_(GIFReg, TEST) - u32 ATE : 1; - u32 ATST : 3; - u32 AREF : 8; - u32 AFAIL : 2; - u32 DATE : 1; - u32 DATM : 1; - u32 ZTE : 1; - u32 ZTST : 2; - u32 _PAD1 : 13; - u32 _PAD2 : 32; -REG_END2 - __forceinline bool DoFirstPass() const { return !ATE || ATST != ATST_NEVER; } // not all pixels fail automatically - __forceinline bool DoSecondPass() const { return ATE && ATST != ATST_ALWAYS && AFAIL != AFAIL_KEEP; } // pixels may fail, write fb/z - __forceinline bool NoSecondPass() const { return ATE && ATST != ATST_ALWAYS && AFAIL == AFAIL_KEEP; } // pixels may fail, no output -REG_END2 - -REG64_(GIFReg, TEX0) -union -{ - struct - { - u32 TBP0 : 14; - u32 TBW : 6; - u32 PSM : 6; - u32 TW : 4; - u32 _PAD1 : 2; - u32 _PAD2 : 2; - u32 TCC : 1; - u32 TFX : 2; - u32 CBP : 14; - u32 CPSM : 4; - u32 CSM : 1; - u32 CSA : 5; - u32 CLD : 3; - }; - - struct - { - u64 _PAD3 : 30; - u64 TH : 4; - u64 _PAD4 : 30; - }; -}; -REG_END2 - __forceinline bool IsRepeating() const - { - if (TBW < 2) - { - if (PSM == PSM_PSMT8) - return TW > 7 || TH > 6; - if (PSM == PSM_PSMT4) - return TW > 7 || TH > 7; - } - - // The recast of TBW seems useless but it avoid tons of warning from GCC... - return ((u32)TBW << 6u) < (1u << TW); - } -REG_END2 - -REG64_(GIFReg, TEX1) - u32 LCM : 1; - u32 _PAD1 : 1; - u32 MXL : 3; - u32 MMAG : 1; - u32 MMIN : 3; - u32 MTBA : 1; - u32 _PAD2 : 9; - u32 L : 2; - u32 _PAD3 : 11; - s32 K : 12; // 1:7:4 - u32 _PAD4 : 20; -REG_END2 - bool IsMinLinear() const { return (MMIN == 1) || (MMIN & 4); } - bool IsMagLinear() const { return MMAG; } -REG_END2 - -REG64_(GIFReg, TEX2) - u32 _PAD1 : 20; - u32 PSM : 6; - u32 _PAD2 : 6; - u32 _PAD3 : 5; - u32 CBP : 14; - u32 CPSM : 4; - u32 CSM : 1; - u32 CSA : 5; - u32 CLD : 3; -REG_END - -REG64_(GIFReg, TEXA) - u8 TA0; - u8 _PAD1 : 7; - u8 AEM : 1; - u16 _PAD2; - u8 TA1 : 8; - u8 _PAD3[3]; -REG_END - -REG64_(GIFReg, TEXCLUT) - u32 CBW : 6; - u32 COU : 6; - u32 COV : 10; - u32 _PAD1 : 10; - u32 _PAD2 : 32; -REG_END - -REG64_(GIFReg, TEXFLUSH) - u32 _PAD1 : 32; - u32 _PAD2 : 32; -REG_END - -REG64_(GIFReg, TRXDIR) - u32 XDIR : 2; - u32 _PAD1 : 30; - u32 _PAD2 : 32; -REG_END - -REG64_(GIFReg, TRXPOS) - u32 SSAX : 11; - u32 _PAD1 : 5; - u32 SSAY : 11; - u32 _PAD2 : 5; - u32 DSAX : 11; - u32 _PAD3 : 5; - u32 DSAY : 11; - u32 DIRY : 1; - u32 DIRX : 1; - u32 _PAD4 : 3; -REG_END - -REG64_(GIFReg, TRXREG) - u32 RRW : 12; - u32 _PAD1 : 20; - u32 RRH : 12; - u32 _PAD2 : 20; -REG_END - -// GSState::GIFPackedRegHandlerUV and GSState::GIFRegHandlerUV will make sure that the _PAD1/2 bits are set to zero - -REG64_(GIFReg, UV) - u16 U; - // u32 _PAD1 : 2; - u16 V; - // u32 _PAD2 : 2; - u32 _PAD3; -REG_END - -// GSState::GIFRegHandlerXYOFFSET will make sure that the _PAD1/2 bits are set to zero - -REG64_(GIFReg, XYOFFSET) - u32 OFX; // : 16; u32 _PAD1 : 16; - u32 OFY; // : 16; u32 _PAD2 : 16; -REG_END - -REG64_(GIFReg, XYZ) - u16 X; - u16 Y; - u32 Z; -REG_END - -REG64_(GIFReg, XYZF) - u16 X; - u16 Y; - u32 Z : 24; - u32 F : 8; -REG_END - -REG64_(GIFReg, ZBUF) - u32 ZBP : 9; - u32 _PAD1 : 15; - // u32 PSM : 4; - // u32 _PAD2 : 4; - u32 PSM : 6; - u32 _PAD2 : 2; - u32 ZMSK : 1; - u32 _PAD3 : 31; -REG_END2 - u32 Block() const { return ZBP << 5; } -REG_END2 - -REG64_SET(GIFReg) - GIFRegALPHA ALPHA; - GIFRegBITBLTBUF BITBLTBUF; - GIFRegCLAMP CLAMP; - GIFRegCOLCLAMP COLCLAMP; - GIFRegDIMX DIMX; - GIFRegDTHE DTHE; - GIFRegFBA FBA; - GIFRegFINISH FINISH; - GIFRegFOG FOG; - GIFRegFOGCOL FOGCOL; - GIFRegFRAME FRAME; - GIFRegHWREG HWREG; - GIFRegLABEL LABEL; - GIFRegMIPTBP1 MIPTBP1; - GIFRegMIPTBP2 MIPTBP2; - GIFRegNOP NOP; - GIFRegPABE PABE; - GIFRegPRIM PRIM; - GIFRegPRMODE PRMODE; - GIFRegPRMODECONT PRMODECONT; - GIFRegRGBAQ RGBAQ; - GIFRegSCANMSK SCANMSK; - GIFRegSCISSOR SCISSOR; - GIFRegSIGNAL SIGNAL; - GIFRegST ST; - GIFRegTEST TEST; - GIFRegTEX0 TEX0; - GIFRegTEX1 TEX1; - GIFRegTEX2 TEX2; - GIFRegTEXA TEXA; - GIFRegTEXCLUT TEXCLUT; - GIFRegTEXFLUSH TEXFLUSH; - GIFRegTRXDIR TRXDIR; - GIFRegTRXPOS TRXPOS; - GIFRegTRXREG TRXREG; - GIFRegUV UV; - GIFRegXYOFFSET XYOFFSET; - GIFRegXYZ XYZ; - GIFRegXYZF XYZF; - GIFRegZBUF ZBUF; -REG_SET_END - -// GIFPacked - -REG128_(GIFPacked, PRIM) - u32 PRIM : 11; - u32 _PAD1 : 21; - u32 _PAD2[3]; -REG_END - -REG128_(GIFPacked, RGBA) - u8 R; - u8 _PAD1[3]; - u8 G; - u8 _PAD2[3]; - u8 B; - u8 _PAD3[3]; - u8 A; - u8 _PAD4[3]; -REG_END - -REG128_(GIFPacked, STQ) - float S; - float T; - float Q; - u32 _PAD1 : 32; -REG_END - -REG128_(GIFPacked, UV) - u32 U : 14; - u32 _PAD1 : 18; - u32 V : 14; - u32 _PAD2 : 18; - u32 _PAD3 : 32; - u32 _PAD4 : 32; -REG_END - -REG128_(GIFPacked, XYZF2) - u16 X; - u16 _PAD1; - u16 Y; - u16 _PAD2; - u32 _PAD3 : 4; - u32 Z : 24; - u32 _PAD4 : 4; - u32 _PAD5 : 4; - u32 F : 8; - u32 _PAD6 : 3; - u32 ADC : 1; - u32 _PAD7 : 16; -REG_END2 -u32 Skip() const { return U32[3] & 0x8000; } -REG_END2 - -REG128_(GIFPacked, XYZ2) - u16 X; - u16 _PAD1; - u16 Y; - u16 _PAD2; - u32 Z; - u32 _PAD3 : 15; - u32 ADC : 1; - u32 _PAD4 : 16; -REG_END2 - u32 Skip() const { return U32[3] & 0x8000; } -REG_END2 - -REG128_(GIFPacked, FOG) - u32 _PAD1; - u32 _PAD2; - u32 _PAD3; - u32 _PAD4 : 4; - u32 F : 8; - u32 _PAD5 : 20; -REG_END - -REG128_(GIFPacked, A_D) - u64 DATA; - u8 ADDR : 8; // enum GIF_A_D_REG - u8 _PAD1[3 + 4]; -REG_END - -REG128_(GIFPacked, NOP) - u32 _PAD1; - u32 _PAD2; - u32 _PAD3; - u32 _PAD4; -REG_END - -REG128_SET(GIFPackedReg) - GIFReg r; - GIFPackedPRIM PRIM; - GIFPackedRGBA RGBA; - GIFPackedSTQ STQ; - GIFPackedUV UV; - GIFPackedXYZF2 XYZF2; - GIFPackedXYZ2 XYZ2; - GIFPackedFOG FOG; - GIFPackedA_D A_D; - GIFPackedNOP NOP; -REG_SET_END - -struct alignas(32) GIFPath -{ - GIFTag tag; - u32 nloop; - u32 nreg; - u32 reg; - u32 type; - GSVector4i regs; - - enum - { - TYPE_UNKNOWN, - TYPE_ADONLY, - TYPE_STQRGBAXYZF2, - TYPE_STQRGBAXYZ2 - }; - - __forceinline void SetTag(const void* mem) - { - const GIFTag* RESTRICT src = (const GIFTag*)mem; - - // the compiler has a hard time not reloading every time a field of src is accessed - - u32 a = src->U32[0]; - u32 b = src->U32[1]; - - tag.U32[0] = a; - tag.U32[1] = b; - - nloop = a & 0x7fff; - - if (nloop == 0) - return; - - GSVector4i v = GSVector4i::loadl(&src->REGS); // REGS not stored to tag.REGS, only into this->regs, restored before saving the state though - - nreg = (b & 0xf0000000) ? (b >> 28) : 16; // src->NREG - regs = v.upl8(v >> 4) & GSVector4i::x0f(nreg); - reg = 0; - - type = TYPE_UNKNOWN; - - if (tag.FLG == GIF_FLG_PACKED) - { - if (regs.eq8(GSVector4i(0x0e0e0e0e)).mask() == (1 << nreg) - 1) - { - type = TYPE_ADONLY; - } - else - { - switch (nreg) - { - case 1: - break; - case 2: - break; - case 3: - // many games, TODO: formats mixed with NOPs (xeno2: 040f010f02, 04010f020f, mgs3: 04010f0f02, 0401020f0f, 04010f020f) - if (regs.U32[0] == 0x00040102) - type = TYPE_STQRGBAXYZF2; - // GoW (has other crazy formats, like ...030503050103) - if (regs.U32[0] == 0x00050102) - type = TYPE_STQRGBAXYZ2; - // TODO: common types with UV instead - break; - case 4: - break; - case 5: - break; - case 6: - break; - case 7: - break; - case 8: - break; - case 9: - // ffx - if (regs.U32[0] == 0x02040102 && regs.U32[1] == 0x01020401 && regs.U32[2] == 0x00000004) - { - type = TYPE_STQRGBAXYZF2; - nreg = 3; - nloop *= 3; - } - break; - case 10: - break; - case 11: - break; - case 12: - // dq8 (not many, mostly 040102) - if (regs.U32[0] == 0x02040102 && regs.U32[1] == 0x01020401 && regs.U32[2] == 0x04010204) - { - type = TYPE_STQRGBAXYZF2; - nreg = 3; - nloop *= 4; - } - break; - case 13: - break; - case 14: - break; - case 15: - break; - case 16: - break; - default: - __assume(0); - } - } - } - } - - __forceinline u8 GetReg() const - { - return regs.U8[reg]; - } - - __forceinline u8 GetReg(u32 index) const - { - return regs.U8[index]; - } - - __forceinline bool StepReg() - { - if (++reg == nreg) - { - reg = 0; - - if (--nloop == 0) - { - return false; - } - } - - return true; - } -}; - -struct GSPrivRegSet -{ - union - { - struct - { - GSRegPMODE PMODE; - u64 _pad1; - GSRegSMODE1 SMODE1; - u64 _pad2; - GSRegSMODE2 SMODE2; - u64 _pad3; - GSRegSRFSH SRFSH; - u64 _pad4; - GSRegSYNCH1 SYNCH1; - u64 _pad5; - GSRegSYNCH2 SYNCH2; - u64 _pad6; - GSRegSYNCV SYNCV; - u64 _pad7; - struct - { - GSRegDISPFB DISPFB; - u64 _pad1; - GSRegDISPLAY DISPLAY; - u64 _pad2; - } DISP[2]; - GSRegEXTBUF EXTBUF; - u64 _pad8; - GSRegEXTDATA EXTDATA; - u64 _pad9; - GSRegEXTWRITE EXTWRITE; - u64 _pad10; - GSRegBGCOLOR BGCOLOR; - u64 _pad11; - }; - - u8 _pad12[0x1000]; - }; - - union - { - struct - { - GSRegCSR CSR; - u64 _pad13; - GSRegIMR IMR; - u64 _pad14; - u64 _unk1[4]; - GSRegBUSDIR BUSDIR; - u64 _pad15; - u64 _unk2[6]; - GSRegSIGLBLID SIGLBLID; - u64 _pad16; - }; - - u8 _pad17[0x1000]; - }; - - void Dump(FILE* fp) - { - for (int i = 0; i < 2; i++) - { - if (!fp) - return; - - if (i == 0 && !PMODE.EN1) - continue; - if (i == 1 && !PMODE.EN2) - continue; - - fprintf(fp, "DISPFB[%d] BP=%05x BW=%u PSM=%u DBX=%u DBY=%u\n", - i, - DISP[i].DISPFB.Block(), - DISP[i].DISPFB.FBW, - DISP[i].DISPFB.PSM, - DISP[i].DISPFB.DBX, - DISP[i].DISPFB.DBY); - - fprintf(fp, "DISPLAY[%d] DX=%u DY=%u DW=%u DH=%u MAGH=%u MAGV=%u\n", - i, - DISP[i].DISPLAY.DX, - DISP[i].DISPLAY.DY, - DISP[i].DISPLAY.DW, - DISP[i].DISPLAY.DH, - DISP[i].DISPLAY.MAGH, - DISP[i].DISPLAY.MAGV); - } - - fprintf(fp, "PMODE EN1=%u EN2=%u CRTMD=%u MMOD=%u AMOD=%u SLBG=%u ALP=%u\n", - PMODE.EN1, - PMODE.EN2, - PMODE.CRTMD, - PMODE.MMOD, - PMODE.AMOD, - PMODE.SLBG, - PMODE.ALP); - - fprintf(fp, "SMODE1 CLKSEL=%u CMOD=%u EX=%u GCONT=%u LC=%u NVCK=%u PCK2=%u PEHS=%u PEVS=%u PHS=%u PRST=%u PVS=%u RC=%u SINT=%u SLCK=%u SLCK2=%u SPML=%u T1248=%u VCKSEL=%u VHP=%u XPCK=%u\n", - SMODE1.CLKSEL, - SMODE1.CMOD, - SMODE1.EX, - SMODE1.GCONT, - SMODE1.LC, - SMODE1.NVCK, - SMODE1.PCK2, - SMODE1.PEHS, - SMODE1.PEVS, - SMODE1.PHS, - SMODE1.PRST, - SMODE1.PVS, - SMODE1.RC, - SMODE1.SINT, - SMODE1.SLCK, - SMODE1.SLCK2, - SMODE1.SPML, - SMODE1.T1248, - SMODE1.VCKSEL, - SMODE1.VHP, - SMODE1.XPCK); - - fprintf(fp, "SMODE2 INT=%u FFMD=%u DPMS=%u\n", - SMODE2.INT, - SMODE2.FFMD, - SMODE2.DPMS); - - fprintf(fp, "SRFSH %08x_%08x\n", - SRFSH.U32[0], - SRFSH.U32[1]); - - fprintf(fp, "SYNCH1 %08x_%08x\n", - SYNCH1.U32[0], - SYNCH1.U32[1]); - - fprintf(fp, "SYNCH2 %08x_%08x\n", - SYNCH2.U32[0], - SYNCH2.U32[1]); - - fprintf(fp, "SYNCV VBP=%u VBPE=%u VDP=%u VFP=%u VFPE=%u VS=%u\n", - SYNCV.VBP, - SYNCV.VBPE, - SYNCV.VDP, - SYNCV.VFP, - SYNCV.VFPE, - SYNCV.VS); - - fprintf(fp, "CSR %08x_%08x\n", - CSR.U32[0], - CSR.U32[1]); - - fprintf(fp, "BGCOLOR B=%u G=%u R=%u\n", - BGCOLOR.B, - BGCOLOR.G, - BGCOLOR.R); - - fprintf(fp, "EXTBUF BP=0x%x BW=%u FBIN=%u WFFMD=%u EMODA=%u EMODC=%u WDX=%u WDY=%u\n", - EXTBUF.EXBP, EXTBUF.EXBW, EXTBUF.FBIN, EXTBUF.WFFMD, - EXTBUF.EMODA, EXTBUF.EMODC, EXTBUF.WDX, EXTBUF.WDY); - - fprintf(fp, "EXTDATA SX=%u SY=%u SMPH=%u SMPV=%u WW=%u WH=%u\n", - EXTDATA.SX, EXTDATA.SY, EXTDATA.SMPH, EXTDATA.SMPV, EXTDATA.WW, EXTDATA.WH); - - fprintf(fp, "EXTWRITE EN=%u\n", EXTWRITE.WRITE); - } - - void Dump(const std::string& filename) - { - FILE* fp = fopen(filename.c_str(), "wt"); - if (fp) - { - Dump(fp); - fclose(fp); - } - } -}; - -#pragma pack(pop) - // ST_WRITE is defined in libc, avoid this enum stateType { @@ -1644,15 +110,6 @@ enum class CRCHackLevel : s8 Aggressive }; -struct HostKeyEvent; -struct WindowInfo; - -#ifdef ENABLE_ACCURATE_BUFFER_EMULATION -const GSVector2i default_rt_size(2048, 2048); -#else -const GSVector2i default_rt_size(1280, 1024); -#endif - void GSsetBaseMem(u8* mem); int GSinit(); void GSshutdown(); diff --git a/pcsx2/GS/GSBlock.h b/pcsx2/GS/GSBlock.h index 049bc0ccf2..f9f548f2b7 100644 --- a/pcsx2/GS/GSBlock.h +++ b/pcsx2/GS/GSBlock.h @@ -15,7 +15,7 @@ #pragma once -#include "GS.h" +#include "GSRegs.h" #include "GSTables.h" #include "GSVector.h" diff --git a/pcsx2/GS/GSCapture.cpp b/pcsx2/GS/GSCapture.cpp index 222a7d911d..c97867bd83 100644 --- a/pcsx2/GS/GSCapture.cpp +++ b/pcsx2/GS/GSCapture.cpp @@ -17,7 +17,7 @@ #include "GSCapture.h" #include "GSPng.h" #include "GSUtil.h" -#include "GS_types.h" +#include "GSExtra.h" #ifdef _WIN32 diff --git a/pcsx2/GS/GSClut.cpp b/pcsx2/GS/GSClut.cpp index 459e69e994..72d9601c6c 100644 --- a/pcsx2/GS/GSClut.cpp +++ b/pcsx2/GS/GSClut.cpp @@ -16,6 +16,7 @@ #include "PrecompiledHeader.h" #include "GSClut.h" #include "GSLocalMemory.h" +#include "GSGL.h" #define CLUT_ALLOC_SIZE (2 * 4096) diff --git a/pcsx2/GS/GSClut.h b/pcsx2/GS/GSClut.h index 808f46d07c..7f1425ab92 100644 --- a/pcsx2/GS/GSClut.h +++ b/pcsx2/GS/GSClut.h @@ -15,7 +15,7 @@ #pragma once -#include "GS.h" +#include "GSRegs.h" #include "GSVector.h" #include "GSTables.h" #include "GSAlignedClass.h" diff --git a/pcsx2/GS/GSCodeBuffer.cpp b/pcsx2/GS/GSCodeBuffer.cpp index 253b7fc19a..d45d1f7dbc 100644 --- a/pcsx2/GS/GSCodeBuffer.cpp +++ b/pcsx2/GS/GSCodeBuffer.cpp @@ -15,7 +15,7 @@ #include "PrecompiledHeader.h" #include "GSCodeBuffer.h" -#include "GS.h" +#include "GSExtra.h" GSCodeBuffer::GSCodeBuffer(size_t blocksize) : m_blocksize(blocksize) diff --git a/pcsx2/GS/GSCrc.cpp b/pcsx2/GS/GSCrc.cpp index 337c2a23d6..7870a32d1b 100644 --- a/pcsx2/GS/GSCrc.cpp +++ b/pcsx2/GS/GSCrc.cpp @@ -14,8 +14,9 @@ */ #include "PrecompiledHeader.h" -#include "GS.h" #include "GSCrc.h" +#include "GSExtra.h" +#include "GS.h" const CRC::Game CRC::m_games[] = { diff --git a/pcsx2/GS/GSCrc.h b/pcsx2/GS/GSCrc.h index 615b05fb6b..973245bafb 100644 --- a/pcsx2/GS/GSCrc.h +++ b/pcsx2/GS/GSCrc.h @@ -15,6 +15,8 @@ #pragma once +#include + class CRC { public: diff --git a/pcsx2/GS/GSDrawingContext.cpp b/pcsx2/GS/GSDrawingContext.cpp index 247821623e..2ef5b49b58 100644 --- a/pcsx2/GS/GSDrawingContext.cpp +++ b/pcsx2/GS/GSDrawingContext.cpp @@ -15,6 +15,7 @@ #include "PrecompiledHeader.h" #include "GSDrawingContext.h" +#include "GSGL.h" #include "GS.h" static int findmax(int tl, int br, int limit, int wm, int minuv, int maxuv) diff --git a/pcsx2/GS/GSDrawingContext.h b/pcsx2/GS/GSDrawingContext.h index bbffd97c05..d2445c96b5 100644 --- a/pcsx2/GS/GSDrawingContext.h +++ b/pcsx2/GS/GSDrawingContext.h @@ -19,7 +19,6 @@ #pragma clang diagnostic ignored "-Wformat" #endif -#include "GS.h" #include "GSLocalMemory.h" class alignas(32) GSDrawingContext diff --git a/pcsx2/GS/GSDrawingEnvironment.h b/pcsx2/GS/GSDrawingEnvironment.h index 6570b3d276..6056eae06b 100644 --- a/pcsx2/GS/GSDrawingEnvironment.h +++ b/pcsx2/GS/GSDrawingEnvironment.h @@ -15,8 +15,6 @@ #pragma once -#include "GS.h" - class alignas(32) GSDrawingEnvironment { public: diff --git a/pcsx2/GS/GSDump.cpp b/pcsx2/GS/GSDump.cpp index 7857b16ec8..981efe4090 100644 --- a/pcsx2/GS/GSDump.cpp +++ b/pcsx2/GS/GSDump.cpp @@ -15,7 +15,7 @@ #include "PrecompiledHeader.h" #include "GSDump.h" -#include "GS_types.h" +#include "GSExtra.h" GSDumpBase::GSDumpBase(const std::string& fn) : m_frames(0) diff --git a/pcsx2/GS/GSDump.h b/pcsx2/GS/GSDump.h index def42d121f..7590e5388f 100644 --- a/pcsx2/GS/GSDump.h +++ b/pcsx2/GS/GSDump.h @@ -15,7 +15,8 @@ #pragma once -#include "GS.h" +#include "SaveState.h" +#include "GSRegs.h" #include "Renderers/SW/GSVertexSW.h" #include diff --git a/pcsx2/GS/GS_types.h b/pcsx2/GS/GSExtra.h similarity index 60% rename from pcsx2/GS/GS_types.h rename to pcsx2/GS/GSExtra.h index c304d88318..c59828f2e4 100644 --- a/pcsx2/GS/GS_types.h +++ b/pcsx2/GS/GSExtra.h @@ -15,7 +15,7 @@ #pragma once -// clang-format off +#include "GSVector.h" #ifdef _WIN32 inline std::string convert_utf16_to_utf8(const std::wstring& utf16_string) @@ -44,3 +44,56 @@ inline FILE* px_fopen(const std::string& filename, const std::string& mode) return fopen(filename.c_str(), mode.c_str()); #endif } + +#ifdef ENABLE_ACCURATE_BUFFER_EMULATION +static const GSVector2i default_rt_size(2048, 2048); +#else +static const GSVector2i default_rt_size(1280, 1024); +#endif + +// Helper path to dump texture +extern const std::string root_sw; +extern const std::string root_hw; + +extern std::string format(const char* fmt, ...); + +extern void* vmalloc(size_t size, bool code); +extern void vmfree(void* ptr, size_t size); + +extern void* fifo_alloc(size_t size, size_t repeat); +extern void fifo_free(void* ptr, size_t size, size_t repeat); + +// clang-format off + +#ifdef __POSIX__ + #include +#else + #include +#endif + +#ifdef _MSC_VER + #define ALIGN_STACK(n) alignas(n) int dummy__; (void)dummy__; +#else + #ifdef __GNUC__ + // 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; + #else + // TODO Check clang behavior + #define ALIGN_STACK(n) alignas(n) int dummy__; + #endif +#endif + +#ifdef ENABLE_VTUNE + #include "jitprofiling.h" + #ifdef _WIN32 + #pragma comment(lib, "jitprofiling.lib") + #endif +#endif + +#ifdef _WIN32 + #define DIRECTORY_SEPARATOR '\\' +#else + #include // mkdir + #define DIRECTORY_SEPARATOR '/' +#endif diff --git a/pcsx2/GS/GSGL.h b/pcsx2/GS/GSGL.h new file mode 100644 index 0000000000..f923102f17 --- /dev/null +++ b/pcsx2/GS/GSGL.h @@ -0,0 +1,67 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2021 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +#pragma once + +#include "Renderers/OpenGL/GLLoader.h" +#include "GSExtra.h" + +// Note: GL messages are present in common code, so in all renderers. + +#define GL_INSERT(type, code, sev, ...) \ + do \ + if (glDebugMessageInsert) glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, type, code, sev, -1, format(__VA_ARGS__).c_str()); \ + while(0); + +#if defined(_DEBUG) + #define GL_CACHE(...) GL_INSERT(GL_DEBUG_TYPE_OTHER, 0xFEAD, GL_DEBUG_SEVERITY_NOTIFICATION, __VA_ARGS__) +#else + #define GL_CACHE(...) (void)(0); +#endif + +#if defined(ENABLE_TRACE_REG) && defined(_DEBUG) + #define GL_REG(...) GL_INSERT(GL_DEBUG_TYPE_OTHER, 0xB0B0, GL_DEBUG_SEVERITY_NOTIFICATION, __VA_ARGS__) +#else + #define GL_REG(...) (void)(0); +#endif + +#if defined(ENABLE_EXTRA_LOG) && defined(_DEBUG) + #define GL_DBG(...) GL_INSERT(GL_DEBUG_TYPE_OTHER, 0xD0D0, GL_DEBUG_SEVERITY_NOTIFICATION, __VA_ARGS__) +#else + #define GL_DBG(...) (void)(0); +#endif + +#if defined(ENABLE_OGL_DEBUG) + struct GLAutoPop + { + ~GLAutoPop() + { + if (glPopDebugGroup) + glPopDebugGroup(); + } + }; + + #define GL_PUSH_(...) do if (glPushDebugGroup) glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0xBAD, -1, format(__VA_ARGS__).c_str()); while(0); + #define GL_PUSH(...) do if (glPushDebugGroup) glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0xBAD, -1, format(__VA_ARGS__).c_str()); while(0); GLAutoPop gl_auto_pop; + #define GL_POP() do if (glPopDebugGroup) glPopDebugGroup(); while(0); + #define GL_INS(...) GL_INSERT(GL_DEBUG_TYPE_ERROR, 0xDEAD, GL_DEBUG_SEVERITY_MEDIUM, __VA_ARGS__) + #define GL_PERF(...) GL_INSERT(GL_DEBUG_TYPE_PERFORMANCE, 0xFEE1, GL_DEBUG_SEVERITY_NOTIFICATION, __VA_ARGS__) +#else + #define GL_PUSH_(...) (void)(0); + #define GL_PUSH(...) (void)(0); + #define GL_POP() (void)(0); + #define GL_INS(...) (void)(0); + #define GL_PERF(...) (void)(0); +#endif diff --git a/pcsx2/GS/GSIntrin.h b/pcsx2/GS/GSIntrin.h new file mode 100644 index 0000000000..6601ee1215 --- /dev/null +++ b/pcsx2/GS/GSIntrin.h @@ -0,0 +1,44 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2021 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +#pragma once + +#include +#include + +#include +#include + +#if _M_SSE >= 0x500 + #include +#endif + +#if !defined(_MSC_VER) +// http://svn.reactos.org/svn/reactos/trunk/reactos/include/crt/mingw32/intrin_x86.h?view=markup + +static int _BitScanForward(unsigned long* const Index, const unsigned long Mask) +{ +#if __has_builtin(__builtin_ctz) + if (Mask == 0) + return 0; + *Index = __builtin_ctz(Mask); + return 1; +#else + __asm__("bsfl %k[Mask], %k[Index]" : [Index] "=r" (*Index) : [Mask] "mr" (Mask) : "cc"); + return Mask ? 1 : 0; +#endif +} + +#endif diff --git a/pcsx2/GS/GSLocalMemory.cpp b/pcsx2/GS/GSLocalMemory.cpp index d399615fc2..d15783aed9 100644 --- a/pcsx2/GS/GSLocalMemory.cpp +++ b/pcsx2/GS/GSLocalMemory.cpp @@ -16,6 +16,7 @@ #include "PrecompiledHeader.h" #include "GSLocalMemory.h" #include "GS.h" +#include "GSExtra.h" #include template diff --git a/pcsx2/GS/GSLocalMemory.h b/pcsx2/GS/GSLocalMemory.h index b855a45c4e..13e3ca9c7f 100644 --- a/pcsx2/GS/GSLocalMemory.h +++ b/pcsx2/GS/GSLocalMemory.h @@ -15,7 +15,6 @@ #pragma once -#include "GS.h" #include "GSTables.h" #include "GSVector.h" #include "GSBlock.h" diff --git a/pcsx2/GS/GSPng.cpp b/pcsx2/GS/GSPng.cpp index f6423dbc02..790adde0c1 100644 --- a/pcsx2/GS/GSPng.cpp +++ b/pcsx2/GS/GSPng.cpp @@ -15,7 +15,7 @@ #include "PrecompiledHeader.h" #include "GSPng.h" -#include "GS_types.h" +#include "GSExtra.h" #include #include diff --git a/pcsx2/GS/GSRegs.h b/pcsx2/GS/GSRegs.h new file mode 100644 index 0000000000..9caeb8f1f2 --- /dev/null +++ b/pcsx2/GS/GSRegs.h @@ -0,0 +1,1411 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2021 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +#pragma once + +// clang-format off + +// MacOS headers define PAGE_SIZE to the size of an x86 page +#ifdef PAGE_SIZE + #undef PAGE_SIZE +#endif + +#define VM_SIZE 4194304u +#define HALF_VM_SIZE (VM_SIZE / 2u) +#define PAGE_SIZE 8192u +#define BLOCK_SIZE 256u +#define COLUMN_SIZE 64u + +#define MAX_PAGES (VM_SIZE / PAGE_SIZE) +#define MAX_BLOCKS (VM_SIZE / BLOCK_SIZE) +#define MAX_COLUMNS (VM_SIZE / COLUMN_SIZE) + +//if defined, will send much info in reply to the API title info queri from PCSX2 +//default should be undefined +//#define GSTITLEINFO_API_FORCE_VERBOSE + +#include "GSVector.h" + +#pragma pack(push, 1) + +enum GS_PRIM +{ + GS_POINTLIST = 0, + GS_LINELIST = 1, + GS_LINESTRIP = 2, + GS_TRIANGLELIST = 3, + GS_TRIANGLESTRIP = 4, + GS_TRIANGLEFAN = 5, + GS_SPRITE = 6, + GS_INVALID = 7, +}; + +enum GS_PRIM_CLASS +{ + GS_POINT_CLASS = 0, + GS_LINE_CLASS = 1, + GS_TRIANGLE_CLASS = 2, + GS_SPRITE_CLASS = 3, + GS_INVALID_CLASS = 7, +}; + +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 GIF_REG_COMPLEX +{ + GIF_REG_STQRGBAXYZF2 = 0x00, + GIF_REG_STQRGBAXYZ2 = 0x01, +}; + +enum GIF_A_D_REG +{ + GIF_A_D_REG_PRIM = 0x00, + GIF_A_D_REG_RGBAQ = 0x01, + GIF_A_D_REG_ST = 0x02, + GIF_A_D_REG_UV = 0x03, + GIF_A_D_REG_XYZF2 = 0x04, + GIF_A_D_REG_XYZ2 = 0x05, + GIF_A_D_REG_TEX0_1 = 0x06, + GIF_A_D_REG_TEX0_2 = 0x07, + GIF_A_D_REG_CLAMP_1 = 0x08, + GIF_A_D_REG_CLAMP_2 = 0x09, + GIF_A_D_REG_FOG = 0x0a, + GIF_A_D_REG_XYZF3 = 0x0c, + GIF_A_D_REG_XYZ3 = 0x0d, + GIF_A_D_REG_NOP = 0x0f, + GIF_A_D_REG_TEX1_1 = 0x14, + GIF_A_D_REG_TEX1_2 = 0x15, + GIF_A_D_REG_TEX2_1 = 0x16, + GIF_A_D_REG_TEX2_2 = 0x17, + GIF_A_D_REG_XYOFFSET_1 = 0x18, + GIF_A_D_REG_XYOFFSET_2 = 0x19, + GIF_A_D_REG_PRMODECONT = 0x1a, + GIF_A_D_REG_PRMODE = 0x1b, + GIF_A_D_REG_TEXCLUT = 0x1c, + GIF_A_D_REG_SCANMSK = 0x22, + GIF_A_D_REG_MIPTBP1_1 = 0x34, + GIF_A_D_REG_MIPTBP1_2 = 0x35, + GIF_A_D_REG_MIPTBP2_1 = 0x36, + GIF_A_D_REG_MIPTBP2_2 = 0x37, + GIF_A_D_REG_TEXA = 0x3b, + GIF_A_D_REG_FOGCOL = 0x3d, + GIF_A_D_REG_TEXFLUSH = 0x3f, + GIF_A_D_REG_SCISSOR_1 = 0x40, + GIF_A_D_REG_SCISSOR_2 = 0x41, + GIF_A_D_REG_ALPHA_1 = 0x42, + GIF_A_D_REG_ALPHA_2 = 0x43, + GIF_A_D_REG_DIMX = 0x44, + GIF_A_D_REG_DTHE = 0x45, + GIF_A_D_REG_COLCLAMP = 0x46, + GIF_A_D_REG_TEST_1 = 0x47, + GIF_A_D_REG_TEST_2 = 0x48, + GIF_A_D_REG_PABE = 0x49, + GIF_A_D_REG_FBA_1 = 0x4a, + GIF_A_D_REG_FBA_2 = 0x4b, + GIF_A_D_REG_FRAME_1 = 0x4c, + GIF_A_D_REG_FRAME_2 = 0x4d, + GIF_A_D_REG_ZBUF_1 = 0x4e, + GIF_A_D_REG_ZBUF_2 = 0x4f, + GIF_A_D_REG_BITBLTBUF = 0x50, + GIF_A_D_REG_TRXPOS = 0x51, + GIF_A_D_REG_TRXREG = 0x52, + GIF_A_D_REG_TRXDIR = 0x53, + GIF_A_D_REG_HWREG = 0x54, + GIF_A_D_REG_SIGNAL = 0x60, + GIF_A_D_REG_FINISH = 0x61, + GIF_A_D_REG_LABEL = 0x62, +}; + +enum GIF_FLG +{ + GIF_FLG_PACKED = 0, + GIF_FLG_REGLIST = 1, + GIF_FLG_IMAGE = 2, + GIF_FLG_IMAGE2 = 3, +}; + +enum GS_PSM +{ + PSM_PSMCT32 = 0, // 0000-0000 + PSM_PSMCT24 = 1, // 0000-0001 + PSM_PSMCT16 = 2, // 0000-0010 + PSM_PSMCT16S = 10, // 0000-1010 + PSM_PSGPU24 = 18, // 0001-0010 + PSM_PSMT8 = 19, // 0001-0011 + PSM_PSMT4 = 20, // 0001-0100 + PSM_PSMT8H = 27, // 0001-1011 + PSM_PSMT4HL = 36, // 0010-0100 + PSM_PSMT4HH = 44, // 0010-1100 + PSM_PSMZ32 = 48, // 0011-0000 + PSM_PSMZ24 = 49, // 0011-0001 + PSM_PSMZ16 = 50, // 0011-0010 + PSM_PSMZ16S = 58, // 0011-1010 +}; + +enum GS_TFX +{ + TFX_MODULATE = 0, + TFX_DECAL = 1, + TFX_HIGHLIGHT = 2, + TFX_HIGHLIGHT2 = 3, + TFX_NONE = 4, +}; + +enum GS_CLAMP +{ + CLAMP_REPEAT = 0, + CLAMP_CLAMP = 1, + CLAMP_REGION_CLAMP = 2, + CLAMP_REGION_REPEAT = 3, +}; + +enum GS_ZTST +{ + ZTST_NEVER = 0, + ZTST_ALWAYS = 1, + ZTST_GEQUAL = 2, + ZTST_GREATER = 3, +}; + +enum GS_ATST +{ + ATST_NEVER = 0, + ATST_ALWAYS = 1, + ATST_LESS = 2, + ATST_LEQUAL = 3, + ATST_EQUAL = 4, + ATST_GEQUAL = 5, + ATST_GREATER = 6, + ATST_NOTEQUAL = 7, +}; + +enum GS_AFAIL +{ + AFAIL_KEEP = 0, + AFAIL_FB_ONLY = 1, + AFAIL_ZB_ONLY = 2, + AFAIL_RGB_ONLY = 3, +}; + +enum class GS_MIN_FILTER : uint8_t +{ + Nearest = 0, + Linear = 1, + Nearest_Mipmap_Nearest = 2, + Nearest_Mipmap_Linear = 3, + Linear_Mipmap_Nearest = 4, + Linear_Mipmap_Linear = 5, +}; + +#define REG32(name) \ + union name \ + { \ + u32 U32; \ + struct { \ + +#define REG64(name) \ + union name \ + { \ + u64 U64; \ + u32 U32[2]; \ + void operator = (const GSVector4i& v) {GSVector4i::storel(this, v);} \ + bool operator == (const union name& r) const {return ((GSVector4i)r).eq(*this);} \ + bool operator != (const union name& r) const {return !((GSVector4i)r).eq(*this);} \ + operator GSVector4i() const {return GSVector4i::loadl(this);} \ + struct { + +#define REG128(name) \ + union name \ + { \ + u64 U64[2]; \ + u32 U32[4]; \ + struct { + +#define REG32_(prefix, name) REG32(prefix##name) +#define REG64_(prefix, name) REG64(prefix##name) +#define REG128_(prefix, name) REG128(prefix##name) + +#define REG_END }; }; +#define REG_END2 }; + +#define REG32_SET(name) \ +union name \ +{ \ + u32 u32; + +#define REG64_SET(name) \ + union name \ + { \ + u64 U64; \ + u32 U32[2]; + +#define REG128_SET(name) \ + union name \ + { \ + __m128i m128; \ + u64 U64[2]; \ + u32 U32[4]; + +#define REG_SET_END }; + +REG64_(GSReg, BGCOLOR) + u8 R; + u8 G; + u8 B; + u8 _PAD1[5]; +REG_END + +REG64_(GSReg, BUSDIR) + u32 DIR : 1; + u32 _PAD1 : 31; + u32 _PAD2 : 32; +REG_END + +REG64_(GSReg, CSR) + u32 rSIGNAL : 1; + u32 rFINISH : 1; + u32 rHSINT : 1; + u32 rVSINT : 1; + u32 rEDWINT : 1; + u32 rZERO1 : 1; + u32 rZERO2 : 1; + u32 r_PAD1 : 1; + u32 rFLUSH : 1; + u32 rRESET : 1; + u32 r_PAD2 : 2; + u32 rNFIELD : 1; + u32 rFIELD : 1; + u32 rFIFO : 2; + u32 rREV : 8; + u32 rID : 8; + u32 wSIGNAL : 1; + u32 wFINISH : 1; + u32 wHSINT : 1; + u32 wVSINT : 1; + u32 wEDWINT : 1; + u32 wZERO1 : 1; + u32 wZERO2 : 1; + u32 w_PAD1 : 1; + u32 wFLUSH : 1; + u32 wRESET : 1; + u32 w_PAD2 : 2; + u32 wNFIELD : 1; + u32 wFIELD : 1; + u32 wFIFO : 2; + u32 wREV : 8; + u32 wID : 8; +REG_END + +REG64_(GSReg, DISPFB) // (-1/2) + u32 FBP : 9; + u32 FBW : 6; + u32 PSM : 5; + u32 _PAD : 12; + u32 DBX : 11; + u32 DBY : 11; + u32 _PAD2 : 10; +REG_END2 + u32 Block() const { return FBP << 5; } +REG_END2 + +REG64_(GSReg, DISPLAY) // (-1/2) + u32 DX : 12; + u32 DY : 11; + u32 MAGH : 4; + u32 MAGV : 2; + u32 _PAD : 3; + u32 DW : 12; + u32 DH : 11; + u32 _PAD2 : 9; +REG_END + +REG64_(GSReg, EXTBUF) + u32 EXBP : 14; + u32 EXBW : 6; + u32 FBIN : 2; + u32 WFFMD : 1; + u32 EMODA : 2; + u32 EMODC : 2; + u32 _PAD1 : 5; + u32 WDX : 11; + u32 WDY : 11; + u32 _PAD2 : 10; +REG_END + +REG64_(GSReg, EXTDATA) + u32 SX : 12; + u32 SY : 11; + u32 SMPH : 4; + u32 SMPV : 2; + u32 _PAD1 : 3; + u32 WW : 12; + u32 WH : 11; + u32 _PAD2 : 9; +REG_END + +REG64_(GSReg, EXTWRITE) + u32 WRITE : 1; + u32 _PAD1 : 31; + u32 _PAD2 : 32; +REG_END + +REG64_(GSReg, IMR) + u32 _PAD1 : 8; + u32 SIGMSK : 1; + u32 FINISHMSK : 1; + u32 HSMSK : 1; + u32 VSMSK : 1; + u32 EDWMSK : 1; + u32 _PAD2 : 19; + u32 _PAD3 : 32; +REG_END + +REG64_(GSReg, PMODE) +union +{ + struct + { + u32 EN1 : 1; + u32 EN2 : 1; + u32 CRTMD : 3; + u32 MMOD : 1; + u32 AMOD : 1; + u32 SLBG : 1; + u32 ALP : 8; + u32 _PAD : 16; + u32 _PAD1 : 32; + }; + + struct + { + u32 EN : 2; + u32 _PAD2 : 30; + u32 _PAD3 : 32; + }; +}; +REG_END + +REG64_(GSReg, SIGLBLID) + u32 SIGID; + u32 LBLID; +REG_END + +REG64_(GSReg, SMODE1) + u32 RC : 3; + u32 LC : 7; + u32 T1248 : 2; + u32 SLCK : 1; + u32 CMOD : 2; + u32 EX : 1; + u32 PRST : 1; + u32 SINT : 1; + u32 XPCK : 1; + u32 PCK2 : 2; + u32 SPML : 4; + u32 GCONT : 1; // YCrCb + u32 PHS : 1; + u32 PVS : 1; + u32 PEHS : 1; + u32 PEVS : 1; + u32 CLKSEL : 2; + u32 NVCK : 1; + u32 SLCK2 : 1; + u32 VCKSEL : 2; + u32 VHP : 1; + u32 _PAD1 : 27; +REG_END + +/* + +// pal + +CLKSEL=1 CMOD=3 EX=0 GCONT=0 LC=32 NVCK=1 PCK2=0 PEHS=0 PEVS=0 PHS=0 PRST=1 PVS=0 RC=4 SINT=0 SLCK=0 SLCK2=1 SPML=4 T1248=1 VCKSEL=1 VHP=0 XPCK=0 + +// ntsc + +CLKSEL=1 CMOD=2 EX=0 GCONT=0 LC=32 NVCK=1 PCK2=0 PEHS=0 PEVS=0 PHS=0 PRST=1 PVS=0 RC=4 SINT=0 SLCK=0 SLCK2=1 SPML=4 T1248=1 VCKSEL=1 VHP=0 XPCK=0 + +// ntsc progressive (SoTC) + +CLKSEL=1 CMOD=0 EX=0 GCONT=0 LC=32 NVCK=1 PCK2=0 PEHS=0 PEVS=0 PHS=0 PRST=1 PVS=0 RC=4 SINT=0 SLCK=0 SLCK2=1 SPML=2 T1248=1 VCKSEL=1 VHP=1 XPCK=0 + +*/ + +REG64_(GSReg, SMODE2) + u32 INT : 1; + u32 FFMD : 1; + u32 DPMS : 2; + u32 _PAD2 : 28; + u32 _PAD3 : 32; +REG_END + +REG64_(GSReg, SRFSH) + u32 _DUMMY; + // TODO +REG_END + +REG64_(GSReg, SYNCH1) + u32 _DUMMY; + // TODO +REG_END + +REG64_(GSReg, SYNCH2) + u32 _DUMMY; + // TODO +REG_END + +REG64_(GSReg, SYNCV) + u32 VFP : 10; // Vertical Front Porchinterval (?s) + u32 VFPE : 10; // Vertical Front Porchinterval End (?s) + u32 VBP : 12; // Vertical Back Porchinterval (?s) + u32 VBPE : 10; // Vertical Back Porchinterval End (?s) + u32 VDP : 11; // Vertical Differential Phase + u32 VS : 11; // Vertical Synchronization Timing +REG_END + +REG64_SET(GSReg) + GSRegBGCOLOR BGCOLOR; + GSRegBUSDIR BUSDIR; + GSRegCSR CSR; + GSRegDISPFB DISPFB; + GSRegDISPLAY DISPLAY; + GSRegEXTBUF EXTBUF; + GSRegEXTDATA EXTDATA; + GSRegEXTWRITE EXTWRITE; + GSRegIMR IMR; + GSRegPMODE PMODE; + GSRegSIGLBLID SIGLBLID; + GSRegSMODE1 SMODE1; + GSRegSMODE2 SMODE2; +REG_SET_END + +// +// GIFTag + +REG128(GIFTag) + u32 NLOOP : 15; + u32 EOP : 1; + u32 _PAD1 : 16; + u32 _PAD2 : 14; + u32 PRE : 1; + u32 PRIM : 11; + u32 FLG : 2; // enum GIF_FLG + u32 NREG : 4; + u64 REGS; +REG_END + +// GIFReg + +REG64_(GIFReg, ALPHA) + u32 A : 2; + u32 B : 2; + u32 C : 2; + u32 D : 2; + u32 _PAD1 : 24; + u8 FIX; + u8 _PAD2[3]; +REG_END2 + // opaque => output will be Cs/As + __forceinline bool IsOpaque() const { return ((A == B || (C == 2 && FIX == 0)) && D == 0) || (A == 0 && B == D && C == 2 && FIX == 0x80); } + __forceinline bool IsOpaque(int amin, int amax) const { return ((A == B || amax == 0) && D == 0) || (A == 0 && B == D && amin == 0x80 && amax == 0x80); } + __forceinline bool IsCd() { return (A == B) && (D == 1); } +REG_END2 + +REG64_(GIFReg, BITBLTBUF) + u32 SBP : 14; + u32 _PAD1 : 2; + u32 SBW : 6; + u32 _PAD2 : 2; + u32 SPSM : 6; + u32 _PAD3 : 2; + u32 DBP : 14; + u32 _PAD4 : 2; + u32 DBW : 6; + u32 _PAD5 : 2; + u32 DPSM : 6; + u32 _PAD6 : 2; +REG_END + +REG64_(GIFReg, CLAMP) +union +{ + struct + { + u32 WMS : 2; + u32 WMT : 2; + u32 MINU : 10; + u32 MAXU : 10; + u32 _PAD1 : 8; + u32 _PAD2 : 2; + u32 MAXV : 10; + u32 _PAD3 : 20; + }; + + struct + { + u64 _PAD4 : 24; + u64 MINV : 10; + u64 _PAD5 : 30; + }; +}; +REG_END + +REG64_(GIFReg, COLCLAMP) + u32 CLAMP : 1; + u32 _PAD1 : 31; + u32 _PAD2 : 32; +REG_END + +REG64_(GIFReg, DIMX) + s32 DM00 : 3; + s32 _PAD00 : 1; + s32 DM01 : 3; + s32 _PAD01 : 1; + s32 DM02 : 3; + s32 _PAD02 : 1; + s32 DM03 : 3; + s32 _PAD03 : 1; + s32 DM10 : 3; + s32 _PAD10 : 1; + s32 DM11 : 3; + s32 _PAD11 : 1; + s32 DM12 : 3; + s32 _PAD12 : 1; + s32 DM13 : 3; + s32 _PAD13 : 1; + s32 DM20 : 3; + s32 _PAD20 : 1; + s32 DM21 : 3; + s32 _PAD21 : 1; + s32 DM22 : 3; + s32 _PAD22 : 1; + s32 DM23 : 3; + s32 _PAD23 : 1; + s32 DM30 : 3; + s32 _PAD30 : 1; + s32 DM31 : 3; + s32 _PAD31 : 1; + s32 DM32 : 3; + s32 _PAD32 : 1; + s32 DM33 : 3; + s32 _PAD33 : 1; +REG_END + +REG64_(GIFReg, DTHE) + u32 DTHE : 1; + u32 _PAD1 : 31; + u32 _PAD2 : 32; +REG_END + +REG64_(GIFReg, FBA) + u32 FBA : 1; + u32 _PAD1 : 31; + u32 _PAD2 : 32; +REG_END + +REG64_(GIFReg, FINISH) + u32 _PAD1[2]; +REG_END + +REG64_(GIFReg, FOG) + u8 _PAD1[7]; + u8 F; +REG_END + +REG64_(GIFReg, FOGCOL) + u8 FCR; + u8 FCG; + u8 FCB; + u8 _PAD1[5]; +REG_END + +REG64_(GIFReg, FRAME) + u32 FBP : 9; + u32 _PAD1 : 7; + u32 FBW : 6; + u32 _PAD2 : 2; + u32 PSM : 6; + u32 _PAD3 : 2; + u32 FBMSK; +REG_END2 + u32 Block() const { return FBP << 5; } +REG_END2 + +REG64_(GIFReg, HWREG) + u32 DATA_LOWER; + u32 DATA_UPPER; +REG_END + +REG64_(GIFReg, LABEL) + u32 ID; + u32 IDMSK; +REG_END + +REG64_(GIFReg, MIPTBP1) + u64 TBP1 : 14; + u64 TBW1 : 6; + u64 TBP2 : 14; + u64 TBW2 : 6; + u64 TBP3 : 14; + u64 TBW3 : 6; + u64 _PAD : 4; +REG_END + +REG64_(GIFReg, MIPTBP2) + u64 TBP4 : 14; + u64 TBW4 : 6; + u64 TBP5 : 14; + u64 TBW5 : 6; + u64 TBP6 : 14; + u64 TBW6 : 6; + u64 _PAD : 4; +REG_END + +REG64_(GIFReg, NOP) + u32 _PAD[2]; +REG_END + +REG64_(GIFReg, PABE) + u32 PABE : 1; + u32 _PAD1 : 31; + u32 _PAD2 : 32; +REG_END + +REG64_(GIFReg, PRIM) + u32 PRIM : 3; + u32 IIP : 1; + u32 TME : 1; + u32 FGE : 1; + u32 ABE : 1; + u32 AA1 : 1; + u32 FST : 1; + u32 CTXT : 1; + u32 FIX : 1; + u32 _PAD1 : 21; + u32 _PAD2 : 32; +REG_END + +REG64_(GIFReg, PRMODE) + u32 _PRIM : 3; + u32 IIP : 1; + u32 TME : 1; + u32 FGE : 1; + u32 ABE : 1; + u32 AA1 : 1; + u32 FST : 1; + u32 CTXT : 1; + u32 FIX : 1; + u32 _PAD2 : 21; + u32 _PAD3 : 32; +REG_END + +REG64_(GIFReg, PRMODECONT) + u32 AC : 1; + u32 _PAD1 : 31; + u32 _PAD2 : 32; +REG_END + +REG64_(GIFReg, RGBAQ) + u8 R; + u8 G; + u8 B; + u8 A; + float Q; +REG_END + +REG64_(GIFReg, SCANMSK) + u32 MSK : 2; + u32 _PAD1 : 30; + u32 _PAD2 : 32; +REG_END + +REG64_(GIFReg, SCISSOR) + u32 SCAX0 : 11; + u32 _PAD1 : 5; + u32 SCAX1 : 11; + u32 _PAD2 : 5; + u32 SCAY0 : 11; + u32 _PAD3 : 5; + u32 SCAY1 : 11; + u32 _PAD4 : 5; +REG_END + +REG64_(GIFReg, SIGNAL) + u32 ID; + u32 IDMSK; +REG_END + +REG64_(GIFReg, ST) + float S; + float T; +REG_END + +REG64_(GIFReg, TEST) + u32 ATE : 1; + u32 ATST : 3; + u32 AREF : 8; + u32 AFAIL : 2; + u32 DATE : 1; + u32 DATM : 1; + u32 ZTE : 1; + u32 ZTST : 2; + u32 _PAD1 : 13; + u32 _PAD2 : 32; +REG_END2 + __forceinline bool DoFirstPass() const { return !ATE || ATST != ATST_NEVER; } // not all pixels fail automatically + __forceinline bool DoSecondPass() const { return ATE && ATST != ATST_ALWAYS && AFAIL != AFAIL_KEEP; } // pixels may fail, write fb/z + __forceinline bool NoSecondPass() const { return ATE && ATST != ATST_ALWAYS && AFAIL == AFAIL_KEEP; } // pixels may fail, no output +REG_END2 + +REG64_(GIFReg, TEX0) +union +{ + struct + { + u32 TBP0 : 14; + u32 TBW : 6; + u32 PSM : 6; + u32 TW : 4; + u32 _PAD1 : 2; + u32 _PAD2 : 2; + u32 TCC : 1; + u32 TFX : 2; + u32 CBP : 14; + u32 CPSM : 4; + u32 CSM : 1; + u32 CSA : 5; + u32 CLD : 3; + }; + + struct + { + u64 _PAD3 : 30; + u64 TH : 4; + u64 _PAD4 : 30; + }; +}; +REG_END2 + __forceinline bool IsRepeating() const + { + if (TBW < 2) + { + if (PSM == PSM_PSMT8) + return TW > 7 || TH > 6; + if (PSM == PSM_PSMT4) + return TW > 7 || TH > 7; + } + + // The recast of TBW seems useless but it avoid tons of warning from GCC... + return ((u32)TBW << 6u) < (1u << TW); + } +REG_END2 + +REG64_(GIFReg, TEX1) + u32 LCM : 1; + u32 _PAD1 : 1; + u32 MXL : 3; + u32 MMAG : 1; + u32 MMIN : 3; + u32 MTBA : 1; + u32 _PAD2 : 9; + u32 L : 2; + u32 _PAD3 : 11; + s32 K : 12; // 1:7:4 + u32 _PAD4 : 20; +REG_END2 + bool IsMinLinear() const { return (MMIN == 1) || (MMIN & 4); } + bool IsMagLinear() const { return MMAG; } +REG_END2 + +REG64_(GIFReg, TEX2) + u32 _PAD1 : 20; + u32 PSM : 6; + u32 _PAD2 : 6; + u32 _PAD3 : 5; + u32 CBP : 14; + u32 CPSM : 4; + u32 CSM : 1; + u32 CSA : 5; + u32 CLD : 3; +REG_END + +REG64_(GIFReg, TEXA) + u8 TA0; + u8 _PAD1 : 7; + u8 AEM : 1; + u16 _PAD2; + u8 TA1 : 8; + u8 _PAD3[3]; +REG_END + +REG64_(GIFReg, TEXCLUT) + u32 CBW : 6; + u32 COU : 6; + u32 COV : 10; + u32 _PAD1 : 10; + u32 _PAD2 : 32; +REG_END + +REG64_(GIFReg, TEXFLUSH) + u32 _PAD1 : 32; + u32 _PAD2 : 32; +REG_END + +REG64_(GIFReg, TRXDIR) + u32 XDIR : 2; + u32 _PAD1 : 30; + u32 _PAD2 : 32; +REG_END + +REG64_(GIFReg, TRXPOS) + u32 SSAX : 11; + u32 _PAD1 : 5; + u32 SSAY : 11; + u32 _PAD2 : 5; + u32 DSAX : 11; + u32 _PAD3 : 5; + u32 DSAY : 11; + u32 DIRY : 1; + u32 DIRX : 1; + u32 _PAD4 : 3; +REG_END + +REG64_(GIFReg, TRXREG) + u32 RRW : 12; + u32 _PAD1 : 20; + u32 RRH : 12; + u32 _PAD2 : 20; +REG_END + +// GSState::GIFPackedRegHandlerUV and GSState::GIFRegHandlerUV will make sure that the _PAD1/2 bits are set to zero + +REG64_(GIFReg, UV) + u16 U; + // u32 _PAD1 : 2; + u16 V; + // u32 _PAD2 : 2; + u32 _PAD3; +REG_END + +// GSState::GIFRegHandlerXYOFFSET will make sure that the _PAD1/2 bits are set to zero + +REG64_(GIFReg, XYOFFSET) + u32 OFX; // : 16; u32 _PAD1 : 16; + u32 OFY; // : 16; u32 _PAD2 : 16; +REG_END + +REG64_(GIFReg, XYZ) + u16 X; + u16 Y; + u32 Z; +REG_END + +REG64_(GIFReg, XYZF) + u16 X; + u16 Y; + u32 Z : 24; + u32 F : 8; +REG_END + +REG64_(GIFReg, ZBUF) + u32 ZBP : 9; + u32 _PAD1 : 15; + // u32 PSM : 4; + // u32 _PAD2 : 4; + u32 PSM : 6; + u32 _PAD2 : 2; + u32 ZMSK : 1; + u32 _PAD3 : 31; +REG_END2 + u32 Block() const { return ZBP << 5; } +REG_END2 + +REG64_SET(GIFReg) + GIFRegALPHA ALPHA; + GIFRegBITBLTBUF BITBLTBUF; + GIFRegCLAMP CLAMP; + GIFRegCOLCLAMP COLCLAMP; + GIFRegDIMX DIMX; + GIFRegDTHE DTHE; + GIFRegFBA FBA; + GIFRegFINISH FINISH; + GIFRegFOG FOG; + GIFRegFOGCOL FOGCOL; + GIFRegFRAME FRAME; + GIFRegHWREG HWREG; + GIFRegLABEL LABEL; + GIFRegMIPTBP1 MIPTBP1; + GIFRegMIPTBP2 MIPTBP2; + GIFRegNOP NOP; + GIFRegPABE PABE; + GIFRegPRIM PRIM; + GIFRegPRMODE PRMODE; + GIFRegPRMODECONT PRMODECONT; + GIFRegRGBAQ RGBAQ; + GIFRegSCANMSK SCANMSK; + GIFRegSCISSOR SCISSOR; + GIFRegSIGNAL SIGNAL; + GIFRegST ST; + GIFRegTEST TEST; + GIFRegTEX0 TEX0; + GIFRegTEX1 TEX1; + GIFRegTEX2 TEX2; + GIFRegTEXA TEXA; + GIFRegTEXCLUT TEXCLUT; + GIFRegTEXFLUSH TEXFLUSH; + GIFRegTRXDIR TRXDIR; + GIFRegTRXPOS TRXPOS; + GIFRegTRXREG TRXREG; + GIFRegUV UV; + GIFRegXYOFFSET XYOFFSET; + GIFRegXYZ XYZ; + GIFRegXYZF XYZF; + GIFRegZBUF ZBUF; +REG_SET_END + +// GIFPacked + +REG128_(GIFPacked, PRIM) + u32 PRIM : 11; + u32 _PAD1 : 21; + u32 _PAD2[3]; +REG_END + +REG128_(GIFPacked, RGBA) + u8 R; + u8 _PAD1[3]; + u8 G; + u8 _PAD2[3]; + u8 B; + u8 _PAD3[3]; + u8 A; + u8 _PAD4[3]; +REG_END + +REG128_(GIFPacked, STQ) + float S; + float T; + float Q; + u32 _PAD1 : 32; +REG_END + +REG128_(GIFPacked, UV) + u32 U : 14; + u32 _PAD1 : 18; + u32 V : 14; + u32 _PAD2 : 18; + u32 _PAD3 : 32; + u32 _PAD4 : 32; +REG_END + +REG128_(GIFPacked, XYZF2) + u16 X; + u16 _PAD1; + u16 Y; + u16 _PAD2; + u32 _PAD3 : 4; + u32 Z : 24; + u32 _PAD4 : 4; + u32 _PAD5 : 4; + u32 F : 8; + u32 _PAD6 : 3; + u32 ADC : 1; + u32 _PAD7 : 16; +REG_END2 +u32 Skip() const { return U32[3] & 0x8000; } +REG_END2 + +REG128_(GIFPacked, XYZ2) + u16 X; + u16 _PAD1; + u16 Y; + u16 _PAD2; + u32 Z; + u32 _PAD3 : 15; + u32 ADC : 1; + u32 _PAD4 : 16; +REG_END2 + u32 Skip() const { return U32[3] & 0x8000; } +REG_END2 + +REG128_(GIFPacked, FOG) + u32 _PAD1; + u32 _PAD2; + u32 _PAD3; + u32 _PAD4 : 4; + u32 F : 8; + u32 _PAD5 : 20; +REG_END + +REG128_(GIFPacked, A_D) + u64 DATA; + u8 ADDR : 8; // enum GIF_A_D_REG + u8 _PAD1[3 + 4]; +REG_END + +REG128_(GIFPacked, NOP) + u32 _PAD1; + u32 _PAD2; + u32 _PAD3; + u32 _PAD4; +REG_END + +REG128_SET(GIFPackedReg) + GIFReg r; + GIFPackedPRIM PRIM; + GIFPackedRGBA RGBA; + GIFPackedSTQ STQ; + GIFPackedUV UV; + GIFPackedXYZF2 XYZF2; + GIFPackedXYZ2 XYZ2; + GIFPackedFOG FOG; + GIFPackedA_D A_D; + GIFPackedNOP NOP; +REG_SET_END + +struct alignas(32) GIFPath +{ + GIFTag tag; + u32 nloop; + u32 nreg; + u32 reg; + u32 type; + GSVector4i regs; + + enum + { + TYPE_UNKNOWN, + TYPE_ADONLY, + TYPE_STQRGBAXYZF2, + TYPE_STQRGBAXYZ2 + }; + + __forceinline void SetTag(const void* mem) + { + const GIFTag* RESTRICT src = (const GIFTag*)mem; + + // the compiler has a hard time not reloading every time a field of src is accessed + + u32 a = src->U32[0]; + u32 b = src->U32[1]; + + tag.U32[0] = a; + tag.U32[1] = b; + + nloop = a & 0x7fff; + + if (nloop == 0) + return; + + GSVector4i v = GSVector4i::loadl(&src->REGS); // REGS not stored to tag.REGS, only into this->regs, restored before saving the state though + + nreg = (b & 0xf0000000) ? (b >> 28) : 16; // src->NREG + regs = v.upl8(v >> 4) & GSVector4i::x0f(nreg); + reg = 0; + + type = TYPE_UNKNOWN; + + if (tag.FLG == GIF_FLG_PACKED) + { + if (regs.eq8(GSVector4i(0x0e0e0e0e)).mask() == (1 << nreg) - 1) + { + type = TYPE_ADONLY; + } + else + { + switch (nreg) + { + case 1: + break; + case 2: + break; + case 3: + // many games, TODO: formats mixed with NOPs (xeno2: 040f010f02, 04010f020f, mgs3: 04010f0f02, 0401020f0f, 04010f020f) + if (regs.U32[0] == 0x00040102) + type = TYPE_STQRGBAXYZF2; + // GoW (has other crazy formats, like ...030503050103) + if (regs.U32[0] == 0x00050102) + type = TYPE_STQRGBAXYZ2; + // TODO: common types with UV instead + break; + case 4: + break; + case 5: + break; + case 6: + break; + case 7: + break; + case 8: + break; + case 9: + // ffx + if (regs.U32[0] == 0x02040102 && regs.U32[1] == 0x01020401 && regs.U32[2] == 0x00000004) + { + type = TYPE_STQRGBAXYZF2; + nreg = 3; + nloop *= 3; + } + break; + case 10: + break; + case 11: + break; + case 12: + // dq8 (not many, mostly 040102) + if (regs.U32[0] == 0x02040102 && regs.U32[1] == 0x01020401 && regs.U32[2] == 0x04010204) + { + type = TYPE_STQRGBAXYZF2; + nreg = 3; + nloop *= 4; + } + break; + case 13: + break; + case 14: + break; + case 15: + break; + case 16: + break; + default: + __assume(0); + } + } + } + } + + __forceinline u8 GetReg() const + { + return regs.U8[reg]; + } + + __forceinline u8 GetReg(u32 index) const + { + return regs.U8[index]; + } + + __forceinline bool StepReg() + { + if (++reg == nreg) + { + reg = 0; + + if (--nloop == 0) + { + return false; + } + } + + return true; + } +}; + +struct GSPrivRegSet +{ + union + { + struct + { + GSRegPMODE PMODE; + u64 _pad1; + GSRegSMODE1 SMODE1; + u64 _pad2; + GSRegSMODE2 SMODE2; + u64 _pad3; + GSRegSRFSH SRFSH; + u64 _pad4; + GSRegSYNCH1 SYNCH1; + u64 _pad5; + GSRegSYNCH2 SYNCH2; + u64 _pad6; + GSRegSYNCV SYNCV; + u64 _pad7; + struct + { + GSRegDISPFB DISPFB; + u64 _pad1; + GSRegDISPLAY DISPLAY; + u64 _pad2; + } DISP[2]; + GSRegEXTBUF EXTBUF; + u64 _pad8; + GSRegEXTDATA EXTDATA; + u64 _pad9; + GSRegEXTWRITE EXTWRITE; + u64 _pad10; + GSRegBGCOLOR BGCOLOR; + u64 _pad11; + }; + + u8 _pad12[0x1000]; + }; + + union + { + struct + { + GSRegCSR CSR; + u64 _pad13; + GSRegIMR IMR; + u64 _pad14; + u64 _unk1[4]; + GSRegBUSDIR BUSDIR; + u64 _pad15; + u64 _unk2[6]; + GSRegSIGLBLID SIGLBLID; + u64 _pad16; + }; + + u8 _pad17[0x1000]; + }; + + void Dump(FILE* fp) + { + for (int i = 0; i < 2; i++) + { + if (!fp) + return; + + if (i == 0 && !PMODE.EN1) + continue; + if (i == 1 && !PMODE.EN2) + continue; + + fprintf(fp, "DISPFB[%d] BP=%05x BW=%u PSM=%u DBX=%u DBY=%u\n", + i, + DISP[i].DISPFB.Block(), + DISP[i].DISPFB.FBW, + DISP[i].DISPFB.PSM, + DISP[i].DISPFB.DBX, + DISP[i].DISPFB.DBY); + + fprintf(fp, "DISPLAY[%d] DX=%u DY=%u DW=%u DH=%u MAGH=%u MAGV=%u\n", + i, + DISP[i].DISPLAY.DX, + DISP[i].DISPLAY.DY, + DISP[i].DISPLAY.DW, + DISP[i].DISPLAY.DH, + DISP[i].DISPLAY.MAGH, + DISP[i].DISPLAY.MAGV); + } + + fprintf(fp, "PMODE EN1=%u EN2=%u CRTMD=%u MMOD=%u AMOD=%u SLBG=%u ALP=%u\n", + PMODE.EN1, + PMODE.EN2, + PMODE.CRTMD, + PMODE.MMOD, + PMODE.AMOD, + PMODE.SLBG, + PMODE.ALP); + + fprintf(fp, "SMODE1 CLKSEL=%u CMOD=%u EX=%u GCONT=%u LC=%u NVCK=%u PCK2=%u PEHS=%u PEVS=%u PHS=%u PRST=%u PVS=%u RC=%u SINT=%u SLCK=%u SLCK2=%u SPML=%u T1248=%u VCKSEL=%u VHP=%u XPCK=%u\n", + SMODE1.CLKSEL, + SMODE1.CMOD, + SMODE1.EX, + SMODE1.GCONT, + SMODE1.LC, + SMODE1.NVCK, + SMODE1.PCK2, + SMODE1.PEHS, + SMODE1.PEVS, + SMODE1.PHS, + SMODE1.PRST, + SMODE1.PVS, + SMODE1.RC, + SMODE1.SINT, + SMODE1.SLCK, + SMODE1.SLCK2, + SMODE1.SPML, + SMODE1.T1248, + SMODE1.VCKSEL, + SMODE1.VHP, + SMODE1.XPCK); + + fprintf(fp, "SMODE2 INT=%u FFMD=%u DPMS=%u\n", + SMODE2.INT, + SMODE2.FFMD, + SMODE2.DPMS); + + fprintf(fp, "SRFSH %08x_%08x\n", + SRFSH.U32[0], + SRFSH.U32[1]); + + fprintf(fp, "SYNCH1 %08x_%08x\n", + SYNCH1.U32[0], + SYNCH1.U32[1]); + + fprintf(fp, "SYNCH2 %08x_%08x\n", + SYNCH2.U32[0], + SYNCH2.U32[1]); + + fprintf(fp, "SYNCV VBP=%u VBPE=%u VDP=%u VFP=%u VFPE=%u VS=%u\n", + SYNCV.VBP, + SYNCV.VBPE, + SYNCV.VDP, + SYNCV.VFP, + SYNCV.VFPE, + SYNCV.VS); + + fprintf(fp, "CSR %08x_%08x\n", + CSR.U32[0], + CSR.U32[1]); + + fprintf(fp, "BGCOLOR B=%u G=%u R=%u\n", + BGCOLOR.B, + BGCOLOR.G, + BGCOLOR.R); + + fprintf(fp, "EXTBUF BP=0x%x BW=%u FBIN=%u WFFMD=%u EMODA=%u EMODC=%u WDX=%u WDY=%u\n", + EXTBUF.EXBP, EXTBUF.EXBW, EXTBUF.FBIN, EXTBUF.WFFMD, + EXTBUF.EMODA, EXTBUF.EMODC, EXTBUF.WDX, EXTBUF.WDY); + + fprintf(fp, "EXTDATA SX=%u SY=%u SMPH=%u SMPV=%u WW=%u WH=%u\n", + EXTDATA.SX, EXTDATA.SY, EXTDATA.SMPH, EXTDATA.SMPV, EXTDATA.WW, EXTDATA.WH); + + fprintf(fp, "EXTWRITE EN=%u\n", EXTWRITE.WRITE); + } + + void Dump(const std::string& filename) + { + FILE* fp = fopen(filename.c_str(), "wt"); + if (fp) + { + Dump(fp); + fclose(fp); + } + } +}; + +#pragma pack(pop) + diff --git a/pcsx2/GS/GSState.cpp b/pcsx2/GS/GSState.cpp index f8fd6f0ec3..fb9d770d8b 100644 --- a/pcsx2/GS/GSState.cpp +++ b/pcsx2/GS/GSState.cpp @@ -15,7 +15,7 @@ #include "PrecompiledHeader.h" #include "GSState.h" -#include "GS.h" +#include "GSGL.h" #include "GSUtil.h" #include // clamp diff --git a/pcsx2/GS/GSUtil.cpp b/pcsx2/GS/GSUtil.cpp index 5ca686a33d..7d6d7b6bf9 100644 --- a/pcsx2/GS/GSUtil.cpp +++ b/pcsx2/GS/GSUtil.cpp @@ -14,6 +14,8 @@ */ #include "PrecompiledHeader.h" +#include "GS.h" +#include "GSExtra.h" #include "GSUtil.h" #include #include diff --git a/pcsx2/GS/GSUtil.h b/pcsx2/GS/GSUtil.h index f341a7d3a5..3692f0b23c 100644 --- a/pcsx2/GS/GSUtil.h +++ b/pcsx2/GS/GSUtil.h @@ -16,6 +16,7 @@ #pragma once #include "GS.h" +#include "GSRegs.h" #include diff --git a/pcsx2/GS/GSVector.cpp b/pcsx2/GS/GSVector.cpp index 6d788a1aac..fb9476d44c 100644 --- a/pcsx2/GS/GSVector.cpp +++ b/pcsx2/GS/GSVector.cpp @@ -14,7 +14,6 @@ */ #include "PrecompiledHeader.h" -#include "GS.h" #include "GSVector.h" #include diff --git a/pcsx2/GS/GSVector.h b/pcsx2/GS/GSVector.h index 66e58e7b73..3a3e42e4bb 100644 --- a/pcsx2/GS/GSVector.h +++ b/pcsx2/GS/GSVector.h @@ -14,6 +14,7 @@ */ #include "PrecompiledHeader.h" +#include "GSIntrin.h" #pragma once diff --git a/pcsx2/GS/Renderers/Common/GSDevice.cpp b/pcsx2/GS/Renderers/Common/GSDevice.cpp index 05e1de1b4f..e424d08221 100644 --- a/pcsx2/GS/Renderers/Common/GSDevice.cpp +++ b/pcsx2/GS/Renderers/Common/GSDevice.cpp @@ -14,8 +14,9 @@ */ #include "PrecompiledHeader.h" -#include "GS/GS.h" #include "GSDevice.h" +#include "GS/GSGL.h" +#include "GS/GS.h" GSDevice::GSDevice() : m_vsync(false) diff --git a/pcsx2/GS/Renderers/Common/GSDevice.h b/pcsx2/GS/Renderers/Common/GSDevice.h index 533a48f98a..0ed745b387 100644 --- a/pcsx2/GS/Renderers/Common/GSDevice.h +++ b/pcsx2/GS/Renderers/Common/GSDevice.h @@ -22,6 +22,9 @@ #include "GS/GSAlignedClass.h" #include "GSOsdManager.h" #include +#ifdef _WIN32 +#include +#endif enum ShaderConvert { diff --git a/pcsx2/GS/Renderers/Common/GSFunctionMap.h b/pcsx2/GS/Renderers/Common/GSFunctionMap.h index 1066bed5f9..34c317ddf0 100644 --- a/pcsx2/GS/Renderers/Common/GSFunctionMap.h +++ b/pcsx2/GS/Renderers/Common/GSFunctionMap.h @@ -15,9 +15,8 @@ #pragma once -#include "GS/GS.h" #include "GS/GSCodeBuffer.h" - +#include "GS/GSExtra.h" #include "GS/Renderers/SW/GSScanlineEnvironment.h" #include "common/emitter/tools.h" diff --git a/pcsx2/GS/Renderers/Common/GSOsdManager.cpp b/pcsx2/GS/Renderers/Common/GSOsdManager.cpp index acaf06a43a..e78f267bb0 100644 --- a/pcsx2/GS/Renderers/Common/GSOsdManager.cpp +++ b/pcsx2/GS/Renderers/Common/GSOsdManager.cpp @@ -14,8 +14,8 @@ */ #include "PrecompiledHeader.h" -#include "GS/GS.h" #include "GSOsdManager.h" +#include "GS/GS.h" #ifdef _WIN32 #include "GS/resource.h" #endif diff --git a/pcsx2/GS/Renderers/Common/GSOsdManager.h b/pcsx2/GS/Renderers/Common/GSOsdManager.h index 2bfa3c4714..c1bb38429c 100644 --- a/pcsx2/GS/Renderers/Common/GSOsdManager.h +++ b/pcsx2/GS/Renderers/Common/GSOsdManager.h @@ -21,6 +21,7 @@ #include "GSTexture.h" #include "ft2build.h" #include FT_FREETYPE_H +#include class GSOsdManager { diff --git a/pcsx2/GS/Renderers/Common/GSRenderer.cpp b/pcsx2/GS/Renderers/Common/GSRenderer.cpp index 1507e1f797..499d440de2 100644 --- a/pcsx2/GS/Renderers/Common/GSRenderer.cpp +++ b/pcsx2/GS/Renderers/Common/GSRenderer.cpp @@ -15,8 +15,8 @@ #include "PrecompiledHeader.h" #include "GSRenderer.h" -#include "Host.h" -#include "pcsx2/Config.h" +#include "gui/AppConfig.h" +#include "GS/GSGL.h" #if defined(__unix__) #include #endif diff --git a/pcsx2/GS/Renderers/Common/GSRenderer.h b/pcsx2/GS/Renderers/Common/GSRenderer.h index 1c0673d2db..19aed66a8e 100644 --- a/pcsx2/GS/Renderers/Common/GSRenderer.h +++ b/pcsx2/GS/Renderers/Common/GSRenderer.h @@ -15,7 +15,6 @@ #pragma once -#include "GS/GS.h" #include "GS/GSState.h" #include "GS/GSCapture.h" diff --git a/pcsx2/GS/Renderers/Common/GSVertex.h b/pcsx2/GS/Renderers/Common/GSVertex.h index e76e1798d4..b26c5f9f68 100644 --- a/pcsx2/GS/Renderers/Common/GSVertex.h +++ b/pcsx2/GS/Renderers/Common/GSVertex.h @@ -15,7 +15,7 @@ #pragma once -#include "GS/GS.h" +#include "GS/GSRegs.h" #include "GS/GSVector.h" #include "GS/Renderers/HW/GSVertexHW.h" #include "GS/Renderers/SW/GSVertexSW.h" diff --git a/pcsx2/GS/Renderers/Common/GSVertexTrace.h b/pcsx2/GS/Renderers/Common/GSVertexTrace.h index 89b6780b4d..750a23a023 100644 --- a/pcsx2/GS/Renderers/Common/GSVertexTrace.h +++ b/pcsx2/GS/Renderers/Common/GSVertexTrace.h @@ -15,6 +15,7 @@ #pragma once +#include "GS/GS.h" #include "GS/GSDrawingContext.h" #include "GSVertex.h" #include "GS/Renderers/SW/GSVertexSW.h" diff --git a/pcsx2/GS/Renderers/DX11/D3D.cpp b/pcsx2/GS/Renderers/DX11/D3D.cpp index 8ccadbf60b..d3674a661a 100644 --- a/pcsx2/GS/Renderers/DX11/D3D.cpp +++ b/pcsx2/GS/Renderers/DX11/D3D.cpp @@ -15,7 +15,7 @@ #include "PrecompiledHeader.h" #include "GS/Renderers/DX11/D3D.h" -#include "GS/GS.h" +#include "GS/GSExtra.h" #include diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp index c11f5958b2..3b5997ee79 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp @@ -17,6 +17,7 @@ #include "GS.h" #include "GSDevice11.h" #include "GS/Renderers/DX11/D3D.h" +#include "GS/GSExtra.h" #include "GS/GSUtil.h" #include "GS/resource.h" #include diff --git a/pcsx2/GS/Renderers/HW/GSHwHack.cpp b/pcsx2/GS/Renderers/HW/GSHwHack.cpp index f229d0558d..5a1e58cbd4 100644 --- a/pcsx2/GS/Renderers/HW/GSHwHack.cpp +++ b/pcsx2/GS/Renderers/HW/GSHwHack.cpp @@ -15,7 +15,6 @@ #include "PrecompiledHeader.h" #include "GS/GSState.h" -#include "GS.h" bool s_nativeres; static CRCHackLevel s_crc_hack_level = CRCHackLevel::Full; diff --git a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp index 9f2382f47e..cc15a7cd7b 100644 --- a/pcsx2/GS/Renderers/HW/GSRendererHW.cpp +++ b/pcsx2/GS/Renderers/HW/GSRendererHW.cpp @@ -15,6 +15,7 @@ #include "PrecompiledHeader.h" #include "GSRendererHW.h" +#include "GS/GSGL.h" const float GSRendererHW::SSR_UV_TOLERANCE = 1e-3f; diff --git a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp index 80995fc916..481fe98d15 100644 --- a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp +++ b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp @@ -16,6 +16,8 @@ #include "PrecompiledHeader.h" #include "GSTextureCache.h" #include "GSRendererHW.h" +#include "GS/GSGL.h" +#include "GS/GSIntrin.h" #include "GS/GSUtil.h" bool GSTextureCache::m_disable_partial_invalidation = false; diff --git a/pcsx2/GS/Renderers/HW/GSVertexHW.h b/pcsx2/GS/Renderers/HW/GSVertexHW.h index 39d17a0403..6a8672dc07 100644 --- a/pcsx2/GS/Renderers/HW/GSVertexHW.h +++ b/pcsx2/GS/Renderers/HW/GSVertexHW.h @@ -15,7 +15,6 @@ #pragma once -#include "GS/GS.h" #include "GS/GSVector.h" #pragma pack(push, 1) diff --git a/pcsx2/GS/Renderers/OpenGL/GLLoader.cpp b/pcsx2/GS/Renderers/OpenGL/GLLoader.cpp index 5cfa0be60f..9deeac62bc 100644 --- a/pcsx2/GS/Renderers/OpenGL/GLLoader.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GLLoader.cpp @@ -15,7 +15,7 @@ #include "PrecompiledHeader.h" #include "GLLoader.h" -#include "GS.h" +#include "GS/GS.h" #include namespace GLExtension diff --git a/pcsx2/GS/Renderers/OpenGL/GLState.h b/pcsx2/GS/Renderers/OpenGL/GLState.h index 57f0fc877e..250dabfa29 100644 --- a/pcsx2/GS/Renderers/OpenGL/GLState.h +++ b/pcsx2/GS/Renderers/OpenGL/GLState.h @@ -15,7 +15,7 @@ #pragma once -#include "GS/GS.h" +#include "GS/GSGL.h" #include "GS/GSVector.h" namespace GLState diff --git a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.h b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.h index 4b3fe6fa94..9a068a93cc 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.h +++ b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.h @@ -19,7 +19,6 @@ #include "common/GL/StreamBuffer.h" #include "GS/Renderers/Common/GSDevice.h" #include "GSTextureOGL.h" -#include "GS/GS.h" #include "GSUniformBufferOGL.h" #include "GSShaderOGL.h" #include "GLState.h" diff --git a/pcsx2/GS/Renderers/OpenGL/GSShaderOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSShaderOGL.cpp index 7c06f0d83a..f77a8d017e 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSShaderOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSShaderOGL.cpp @@ -16,6 +16,7 @@ #include "PrecompiledHeader.h" #include "GSShaderOGL.h" #include "GLState.h" +#include "GS/GS.h" #ifdef _WIN32 #include "GS/resource.h" diff --git a/pcsx2/GS/Renderers/OpenGL/GSShaderOGL.h b/pcsx2/GS/Renderers/OpenGL/GSShaderOGL.h index 5c0cd145ac..4c14fc1e5e 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSShaderOGL.h +++ b/pcsx2/GS/Renderers/OpenGL/GSShaderOGL.h @@ -15,7 +15,7 @@ #pragma once -#include "GS.h" +#include "GS/GSGL.h" #include class GSShaderOGL diff --git a/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.h b/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.h index 18191ca2f7..d057a60e5f 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.h +++ b/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.h @@ -16,7 +16,7 @@ #pragma once #include "GS/Renderers/Common/GSTexture.h" -#include "GS.h" +#include "GS/GSGL.h" namespace PboPool { diff --git a/pcsx2/GS/Renderers/SW/GSNewCodeGenerator.h b/pcsx2/GS/Renderers/SW/GSNewCodeGenerator.h index 538bef7fd0..e5f2f2bde8 100644 --- a/pcsx2/GS/Renderers/SW/GSNewCodeGenerator.h +++ b/pcsx2/GS/Renderers/SW/GSNewCodeGenerator.h @@ -15,7 +15,6 @@ #pragma once -#include "GS/GS_types.h" #include "xbyak/xbyak.h" #include "xbyak/xbyak_util.h" diff --git a/pcsx2/GS/Renderers/SW/GSRasterizer.cpp b/pcsx2/GS/Renderers/SW/GSRasterizer.cpp index c0ca0dd095..78ba755bc0 100644 --- a/pcsx2/GS/Renderers/SW/GSRasterizer.cpp +++ b/pcsx2/GS/Renderers/SW/GSRasterizer.cpp @@ -17,7 +17,7 @@ #include "PrecompiledHeader.h" #include "GSRasterizer.h" -#include "common/General.h" +#include "GS/GSExtra.h" int GSRasterizerData::s_counter = 0; diff --git a/pcsx2/GS/Renderers/SW/GSRasterizer.h b/pcsx2/GS/Renderers/SW/GSRasterizer.h index a6c6ac0870..eca6670c6d 100644 --- a/pcsx2/GS/Renderers/SW/GSRasterizer.h +++ b/pcsx2/GS/Renderers/SW/GSRasterizer.h @@ -15,7 +15,6 @@ #pragma once -#include "GS.h" #include "GSVertexSW.h" #include "GS/Renderers/Common/GSFunctionMap.h" #include "GS/GSAlignedClass.h" diff --git a/pcsx2/GS/Renderers/SW/GSRendererSW.cpp b/pcsx2/GS/Renderers/SW/GSRendererSW.cpp index 8bfdbdb5f9..d039b8a961 100644 --- a/pcsx2/GS/Renderers/SW/GSRendererSW.cpp +++ b/pcsx2/GS/Renderers/SW/GSRendererSW.cpp @@ -15,6 +15,7 @@ #include "PrecompiledHeader.h" #include "GSRendererSW.h" +#include "GS/GSGL.h" #define LOG 0 diff --git a/pcsx2/GS/Renderers/SW/GSSetupPrimCodeGenerator.all.cpp b/pcsx2/GS/Renderers/SW/GSSetupPrimCodeGenerator.all.cpp index fc527550c7..0f67d560bd 100644 --- a/pcsx2/GS/Renderers/SW/GSSetupPrimCodeGenerator.all.cpp +++ b/pcsx2/GS/Renderers/SW/GSSetupPrimCodeGenerator.all.cpp @@ -14,7 +14,6 @@ */ #include "PrecompiledHeader.h" -#include "GS/GS_types.h" #include "GSSetupPrimCodeGenerator.all.h" #include "GSVertexSW.h" diff --git a/pcsx2/GS/Window/GSCaptureDlg.cpp b/pcsx2/GS/Window/GSCaptureDlg.cpp index 3403dab81b..034d4a2187 100644 --- a/pcsx2/GS/Window/GSCaptureDlg.cpp +++ b/pcsx2/GS/Window/GSCaptureDlg.cpp @@ -16,7 +16,7 @@ #include "PrecompiledHeader.h" #include "GS.h" #include "GSCaptureDlg.h" -#include "GS/GS_types.h" +#include "GS/GSExtra.h" // Ideally this belongs in WIL, but CAUUID is used by a *single* COM function in WinAPI. // That's presumably why it's omitted and is unlikely to make it to upstream WIL. diff --git a/pcsx2/GS/Window/GSwxDialog.cpp b/pcsx2/GS/Window/GSwxDialog.cpp index 4032bb916a..6659df4dad 100644 --- a/pcsx2/GS/Window/GSwxDialog.cpp +++ b/pcsx2/GS/Window/GSwxDialog.cpp @@ -18,6 +18,7 @@ #include "gui/AppConfig.h" #ifdef _WIN32 +#include "GS/GSExtra.h" #include "GS/Renderers/DX11/D3D.h" #endif diff --git a/pcsx2/Gif_Unit.cpp b/pcsx2/Gif_Unit.cpp index 74bba29167..b30825b1f5 100644 --- a/pcsx2/Gif_Unit.cpp +++ b/pcsx2/Gif_Unit.cpp @@ -16,7 +16,6 @@ #include "PrecompiledHeader.h" #include "Common.h" -#include "GS.h" #include "Gif_Unit.h" #include "Vif_Dma.h" #include "MTVU.h" diff --git a/pcsx2/Gif_Unit.h b/pcsx2/Gif_Unit.h index 39afa06be4..d556955141 100644 --- a/pcsx2/Gif_Unit.h +++ b/pcsx2/Gif_Unit.h @@ -19,6 +19,7 @@ #include "Gif.h" #include "Vif.h" #include "GS.h" +#include "GS/GSRegs.h" // FIXME common path ? #include "common/boost_spsc_queue.hpp" diff --git a/pcsx2/pcsx2.vcxproj b/pcsx2/pcsx2.vcxproj index 0ed7612d97..b2b4e03738 100644 --- a/pcsx2/pcsx2.vcxproj +++ b/pcsx2/pcsx2.vcxproj @@ -812,7 +812,10 @@ - + + + + diff --git a/pcsx2/pcsx2.vcxproj.filters b/pcsx2/pcsx2.vcxproj.filters index 9d8519ed1d..e2ffa389ef 100644 --- a/pcsx2/pcsx2.vcxproj.filters +++ b/pcsx2/pcsx2.vcxproj.filters @@ -2490,7 +2490,16 @@ System\Ps2\GS - + + System\Ps2\GS + + + System\Ps2\GS + + + System\Ps2\GS + + System\Ps2\GS