gs-merge: fix codegen scoping/xbyak misc things for our jit

This commit is contained in:
Gauvain 'GovanifY' Roussel-Tarbouriech 2021-05-12 11:35:43 +02:00 committed by Kojin
parent 3851014634
commit 00ed02f831
23 changed files with 74 additions and 64 deletions

View File

@ -662,6 +662,7 @@ set(pcsx2GSHeaders
GS/GSDump.h GS/GSDump.h
GS/GS_res.h GS/GS_res.h
GS/GS_types.h GS/GS_types.h
GS/GS_codegen.h
GS/GS.h GS/GS.h
GS/GSLocalMemory.h GS/GSLocalMemory.h
GS/GSLzma.h GS/GSLzma.h

View File

@ -53,6 +53,8 @@ extern bool RunLinuxDialog();
#endif #endif
#include <fstream>
// do NOT undefine this/put it above includes, as x11 people love to redefine // do NOT undefine this/put it above includes, as x11 people love to redefine
// things that make obscure compiler bugs, unless you want to run around and // things that make obscure compiler bugs, unless you want to run around and
// debug obscure compiler errors --govanify // debug obscure compiler errors --govanify

View File

@ -188,27 +188,6 @@
#define ASSERT assert #define ASSERT assert
/*
#ifdef _M_AMD64
// Yeah let use mips naming ;)
#ifdef _WIN64
#define a0 rcx
#define a1 rdx
#define a2 r8
#define a3 r9
#define t0 rdi
#define t1 rsi
#else
#define a0 rdi
#define a1 rsi
#define a2 rdx
#define a3 rcx
#define t0 r8
#define t1 r9
#endif
#endif
*/
// sse // sse
#if defined(__GNUC__) #if defined(__GNUC__)

23
pcsx2/GS/GS_codegen.h Normal file
View File

@ -0,0 +1,23 @@
#pragma once
using namespace Xbyak;
#ifdef _M_AMD64
// Yeah let use mips naming ;)
#ifdef _WIN64
#define a0 rcx
#define a1 rdx
#define a2 r8
#define a3 r9
#define t0 rdi
#define t1 rsi
#else
#define a0 rdi
#define a1 rsi
#define a2 rdx
#define a3 rcx
#define t0 r8
#define t1 r9
#endif
#endif

View File

@ -1,13 +1,6 @@
#pragma once #pragma once
#include <xbyak/xbyak.h>
#include <xbyak/xbyak_util.h>
#define MIE_INTEGER_TYPE_DEFINED
#define XBYAK_ENABLE_OMITTED_OPERAND
#include <cfloat>
typedef unsigned char uint8; typedef unsigned char uint8;
typedef signed char int8; typedef signed char int8;
typedef unsigned short uint16; typedef unsigned short uint16;
@ -16,6 +9,14 @@ typedef unsigned int uint32;
typedef signed int int32; typedef signed int int32;
typedef unsigned long long uint64; typedef unsigned long long uint64;
typedef signed long long int64; typedef signed long long int64;
typedef signed long long sint64;
#define MIE_INTEGER_TYPE_DEFINED
#define XBYAK_ENABLE_OMITTED_OPERAND
#include <xbyak/xbyak.h>
#include <xbyak/xbyak_util.h>
#include <cfloat>
#ifndef RESTRICT #ifndef RESTRICT

View File

@ -21,6 +21,7 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GSTexture.h" #include "GSTexture.h"
#include <bitset>
GSTexture::GSTexture() GSTexture::GSTexture()
: m_scale(1, 1) : m_scale(1, 1)
@ -71,8 +72,8 @@ void GSTexture::Uncommit()
void GSTexture::SetGpuPageSize(const GSVector2i& page_size) void GSTexture::SetGpuPageSize(const GSVector2i& page_size)
{ {
ASSERT(std::bitset<32>(page_size.x + 1).count() == 1); pxAssert(std::bitset<32>(page_size.x + 1).count() == 1);
ASSERT(std::bitset<32>(page_size.y + 1).count() == 1); pxAssert(std::bitset<32>(page_size.y + 1).count() == 1);
m_gpu_page_size = page_size; m_gpu_page_size = page_size;
} }

View File

@ -21,8 +21,8 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GSVertexTrace.h" #include "GSVertexTrace.h"
#include "GSUtil.h" #include "../../GSUtil.h"
#include "GSState.h" #include "../../GSState.h"
CONSTINIT const GSVector4 GSVertexTrace::s_minmax = GSVector4::cxpr(FLT_MAX, -FLT_MAX, 0.f, 0.f); CONSTINIT const GSVector4 GSVertexTrace::s_minmax = GSVector4::cxpr(FLT_MAX, -FLT_MAX, 0.f, 0.f);

View File

@ -20,7 +20,7 @@
*/ */
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GSState.h" #include "../../GSState.h"
#include "GS.h" #include "GS.h"
bool s_nativeres; bool s_nativeres;

View File

@ -22,7 +22,7 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GSTextureCache.h" #include "GSTextureCache.h"
#include "GSRendererHW.h" #include "GSRendererHW.h"
#include "GSUtil.h" #include "../../GSUtil.h"
bool GSTextureCache::m_disable_partial_invalidation = false; bool GSTextureCache::m_disable_partial_invalidation = false;
bool GSTextureCache::m_wrap_gs_mem = false; bool GSTextureCache::m_wrap_gs_mem = false;

View File

@ -26,7 +26,7 @@
#else #else
void GSDrawScanlineCodeGenerator::Generate() void GSDrawScanlineCodeGenerator::Generate()
{ {
if (m_cpu.has(util::Cpu::tAVX)) if (m_cpu.has(Xbyak::util::Cpu::tAVX))
Generate_AVX(); Generate_AVX();
else else
Generate_SSE(); Generate_SSE();
@ -55,7 +55,7 @@ GSDrawScanlineCodeGenerator::GSDrawScanlineCodeGenerator(void* param, uint64 key
void GSDrawScanlineCodeGenerator::modulate16(const Xmm& a, const Operand& f, uint8 shift) void GSDrawScanlineCodeGenerator::modulate16(const Xmm& a, const Operand& f, uint8 shift)
{ {
if (m_cpu.has(util::Cpu::tAVX)) if (m_cpu.has(Xbyak::util::Cpu::tAVX))
{ {
if (shift == 0) if (shift == 0)
{ {
@ -69,7 +69,7 @@ void GSDrawScanlineCodeGenerator::modulate16(const Xmm& a, const Operand& f, uin
} }
else else
{ {
if (shift == 0 && m_cpu.has(util::Cpu::tSSSE3)) if (shift == 0 && m_cpu.has(Xbyak::util::Cpu::tSSSE3))
{ {
pmulhrsw(a, f); pmulhrsw(a, f);
} }
@ -83,7 +83,7 @@ void GSDrawScanlineCodeGenerator::modulate16(const Xmm& a, const Operand& f, uin
void GSDrawScanlineCodeGenerator::lerp16(const Xmm& a, const Xmm& b, const Xmm& f, uint8 shift) void GSDrawScanlineCodeGenerator::lerp16(const Xmm& a, const Xmm& b, const Xmm& f, uint8 shift)
{ {
if (m_cpu.has(util::Cpu::tAVX)) if (m_cpu.has(Xbyak::util::Cpu::tAVX))
{ {
vpsubw(a, b); vpsubw(a, b);
modulate16(a, f, shift); modulate16(a, f, shift);
@ -99,7 +99,7 @@ void GSDrawScanlineCodeGenerator::lerp16(const Xmm& a, const Xmm& b, const Xmm&
void GSDrawScanlineCodeGenerator::lerp16_4(const Xmm& a, const Xmm& b, const Xmm& f) void GSDrawScanlineCodeGenerator::lerp16_4(const Xmm& a, const Xmm& b, const Xmm& f)
{ {
if (m_cpu.has(util::Cpu::tAVX)) if (m_cpu.has(Xbyak::util::Cpu::tAVX))
{ {
vpsubw(a, b); vpsubw(a, b);
vpmullw(a, f); vpmullw(a, f);
@ -117,7 +117,7 @@ void GSDrawScanlineCodeGenerator::lerp16_4(const Xmm& a, const Xmm& b, const Xmm
void GSDrawScanlineCodeGenerator::mix16(const Xmm& a, const Xmm& b, const Xmm& temp) void GSDrawScanlineCodeGenerator::mix16(const Xmm& a, const Xmm& b, const Xmm& temp)
{ {
if (m_cpu.has(util::Cpu::tAVX)) if (m_cpu.has(Xbyak::util::Cpu::tAVX))
{ {
vpblendw(a, b, 0xaa); vpblendw(a, b, 0xaa);
} }
@ -129,13 +129,13 @@ void GSDrawScanlineCodeGenerator::mix16(const Xmm& a, const Xmm& b, const Xmm& t
void GSDrawScanlineCodeGenerator::clamp16(const Xmm& a, const Xmm& temp) void GSDrawScanlineCodeGenerator::clamp16(const Xmm& a, const Xmm& temp)
{ {
if (m_cpu.has(util::Cpu::tAVX)) if (m_cpu.has(Xbyak::util::Cpu::tAVX))
{ {
vpackuswb(a, a); vpackuswb(a, a);
#if _M_SSE >= 0x501 #if _M_SSE >= 0x501
// Greg: why ? // Greg: why ?
if (m_cpu.has(util::Cpu::tAVX2)) if (m_cpu.has(Xbyak::util::Cpu::tAVX2))
{ {
ASSERT(a.isYMM()); ASSERT(a.isYMM());
vpermq(Ymm(a.getIdx()), Ymm(a.getIdx()), _MM_SHUFFLE(3, 1, 2, 0)); // this sucks vpermq(Ymm(a.getIdx()), Ymm(a.getIdx()), _MM_SHUFFLE(3, 1, 2, 0)); // this sucks
@ -155,7 +155,7 @@ void GSDrawScanlineCodeGenerator::alltrue(const Xmm& test)
{ {
uint32 mask = test.isYMM() ? 0xffffffff : 0xffff; uint32 mask = test.isYMM() ? 0xffffffff : 0xffff;
if (m_cpu.has(util::Cpu::tAVX)) if (m_cpu.has(Xbyak::util::Cpu::tAVX))
{ {
vpmovmskb(eax, test); vpmovmskb(eax, test);
cmp(eax, mask); cmp(eax, mask);
@ -171,7 +171,7 @@ void GSDrawScanlineCodeGenerator::alltrue(const Xmm& test)
void GSDrawScanlineCodeGenerator::blend(const Xmm& a, const Xmm& b, const Xmm& mask) void GSDrawScanlineCodeGenerator::blend(const Xmm& a, const Xmm& b, const Xmm& mask)
{ {
if (m_cpu.has(util::Cpu::tAVX)) if (m_cpu.has(Xbyak::util::Cpu::tAVX))
{ {
vpand(b, mask); vpand(b, mask);
vpandn(mask, a); vpandn(mask, a);
@ -188,7 +188,7 @@ void GSDrawScanlineCodeGenerator::blend(const Xmm& a, const Xmm& b, const Xmm& m
void GSDrawScanlineCodeGenerator::blendr(const Xmm& b, const Xmm& a, const Xmm& mask) void GSDrawScanlineCodeGenerator::blendr(const Xmm& b, const Xmm& a, const Xmm& mask)
{ {
if (m_cpu.has(util::Cpu::tAVX)) if (m_cpu.has(Xbyak::util::Cpu::tAVX))
{ {
vpand(b, mask); vpand(b, mask);
vpandn(mask, a); vpandn(mask, a);
@ -204,7 +204,7 @@ void GSDrawScanlineCodeGenerator::blendr(const Xmm& b, const Xmm& a, const Xmm&
void GSDrawScanlineCodeGenerator::blend8(const Xmm& a, const Xmm& b) void GSDrawScanlineCodeGenerator::blend8(const Xmm& a, const Xmm& b)
{ {
if (m_cpu.has(util::Cpu::tAVX)) if (m_cpu.has(Xbyak::util::Cpu::tAVX))
vpblendvb(a, a, b, xmm0); vpblendvb(a, a, b, xmm0);
else else
pblendvb(a, b); pblendvb(a, b);
@ -212,7 +212,7 @@ void GSDrawScanlineCodeGenerator::blend8(const Xmm& a, const Xmm& b)
void GSDrawScanlineCodeGenerator::blend8r(const Xmm& b, const Xmm& a) void GSDrawScanlineCodeGenerator::blend8r(const Xmm& b, const Xmm& a)
{ {
if (m_cpu.has(util::Cpu::tAVX)) if (m_cpu.has(Xbyak::util::Cpu::tAVX))
{ {
vpblendvb(b, a, b, xmm0); vpblendvb(b, a, b, xmm0);
} }
@ -228,7 +228,7 @@ void GSDrawScanlineCodeGenerator::split16_2x8(const Xmm& l, const Xmm& h, const
// l = src & 0xFF; (1 left shift + 1 right shift) // l = src & 0xFF; (1 left shift + 1 right shift)
// h = (src >> 8) & 0xFF; (1 right shift) // h = (src >> 8) & 0xFF; (1 right shift)
if (m_cpu.has(util::Cpu::tAVX)) if (m_cpu.has(Xbyak::util::Cpu::tAVX))
{ {
if (src == h) if (src == h)
{ {

View File

@ -22,6 +22,9 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GSDrawScanlineCodeGenerator.h" #include "GSDrawScanlineCodeGenerator.h"
#include "GSVertexSW.h" #include "GSVertexSW.h"
#include "../../GS_codegen.h"
#undef _t
#if _M_SSE < 0x501 && (defined(_M_AMD64) || defined(_WIN64)) #if _M_SSE < 0x501 && (defined(_M_AMD64) || defined(_WIN64))

View File

@ -22,6 +22,9 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GSDrawScanlineCodeGenerator.h" #include "GSDrawScanlineCodeGenerator.h"
#include "GSVertexSW.h" #include "GSVertexSW.h"
#include "../../GS_codegen.h"
#undef _t
#if _M_SSE >= 0x501 && (defined(_M_AMD64) || defined(_WIN64)) #if _M_SSE >= 0x501 && (defined(_M_AMD64) || defined(_WIN64))

View File

@ -99,17 +99,17 @@ void GSDrawScanlineCodeGenerator::WriteFrame_SSE()
{ {
} }
void GSDrawScanlineCodeGenerator::ReadPixel_SSE(const Xmm& dst, const Reg64& addr) void GSDrawScanlineCodeGenerator::ReadPixel_SSE(const Xmm& dst, const RegLong& addr)
{ {
} }
void GSDrawScanlineCodeGenerator::WritePixel_SSE(const Xmm& src, const Reg64& addr, const Reg8& mask, bool fast, int psm, int fz) void GSDrawScanlineCodeGenerator::WritePixel_SSE(const Xmm& src, const RegLong& addr, const Reg8& mask, bool fast, int psm, int fz)
{ {
} }
//static const int s_offsets[4] = {0, 2, 8, 10}; //static const int s_offsets[4] = {0, 2, 8, 10};
void GSDrawScanlineCodeGenerator::WritePixel_SSE(const Xmm& src, const Reg64& addr, uint8 i, int psm) void GSDrawScanlineCodeGenerator::WritePixel_SSE(const Xmm& src, const RegLong& addr, uint8 i, int psm)
{ {
} }

View File

@ -22,6 +22,7 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GSDrawScanlineCodeGenerator.h" #include "GSDrawScanlineCodeGenerator.h"
#include "GSVertexSW.h" #include "GSVertexSW.h"
#include "../../GS_codegen.h"
#if _M_SSE < 0x501 && !(defined(_M_AMD64) || defined(_WIN64)) #if _M_SSE < 0x501 && !(defined(_M_AMD64) || defined(_WIN64))

View File

@ -22,6 +22,7 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GSDrawScanlineCodeGenerator.h" #include "GSDrawScanlineCodeGenerator.h"
#include "GSVertexSW.h" #include "GSVertexSW.h"
#include "../../GS_codegen.h"
#if _M_SSE >= 0x501 && !(defined(_M_AMD64) || defined(_WIN64)) #if _M_SSE >= 0x501 && !(defined(_M_AMD64) || defined(_WIN64))

View File

@ -22,6 +22,7 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GSDrawScanlineCodeGenerator.h" #include "GSDrawScanlineCodeGenerator.h"
#include "GSVertexSW.h" #include "GSVertexSW.h"
#include "../../GS_codegen.h"
#if _M_SSE < 0x501 && !(defined(_M_AMD64) || defined(_WIN64)) #if _M_SSE < 0x501 && !(defined(_M_AMD64) || defined(_WIN64))

View File

@ -23,11 +23,10 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GSSetupPrimCodeGenerator.h" #include "GSSetupPrimCodeGenerator.h"
#include "GSVertexSW.h" #include "GSVertexSW.h"
#include "../../GS_codegen.h"
#if _M_SSE < 0x501 && (defined(_M_AMD64) || defined(_WIN64)) #if _M_SSE < 0x501 && (defined(_M_AMD64) || defined(_WIN64))
using namespace Xbyak;
#define _rip_local(field) (m_rip ? ptr[rip + &m_local.field] : ptr[t0 + offsetof(GSScanlineLocalData, field)]) #define _rip_local(field) (m_rip ? ptr[rip + &m_local.field] : ptr[t0 + offsetof(GSScanlineLocalData, field)])
#define _rip_local_v(field, offset) (m_rip ? ptr[rip + &m_local.field] : ptr[t0 + offset]) #define _rip_local_v(field, offset) (m_rip ? ptr[rip + &m_local.field] : ptr[t0 + offset])

View File

@ -23,11 +23,10 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GSSetupPrimCodeGenerator.h" #include "GSSetupPrimCodeGenerator.h"
#include "GSVertexSW.h" #include "GSVertexSW.h"
#include "../../GS_codegen.h"
#if _M_SSE >= 0x501 && (defined(_M_AMD64) || defined(_WIN64)) #if _M_SSE >= 0x501 && (defined(_M_AMD64) || defined(_WIN64))
using namespace Xbyak;
#define _rip_local(field) (m_rip ? ptr[rip + &m_local.field] : ptr[t0 + offsetof(GSScanlineLocalData, field)]) #define _rip_local(field) (m_rip ? ptr[rip + &m_local.field] : ptr[t0 + offsetof(GSScanlineLocalData, field)])
#define _rip_local_v(field, offset) (m_rip ? ptr[rip + &m_local.field] : ptr[t0 + offset]) #define _rip_local_v(field, offset) (m_rip ? ptr[rip + &m_local.field] : ptr[t0 + offset])

View File

@ -22,11 +22,10 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GSSetupPrimCodeGenerator.h" #include "GSSetupPrimCodeGenerator.h"
#include "GSVertexSW.h" #include "GSVertexSW.h"
#include "../../GS_codegen.h"
#if _M_SSE < 0x501 && (defined(_M_AMD64) || defined(_WIN64)) #if _M_SSE < 0x501 && (defined(_M_AMD64) || defined(_WIN64))
using namespace Xbyak;
void GSSetupPrimCodeGenerator::Generate_SSE() void GSSetupPrimCodeGenerator::Generate_SSE()
{ {
#ifdef _WIN64 #ifdef _WIN64

View File

@ -22,11 +22,10 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GSSetupPrimCodeGenerator.h" #include "GSSetupPrimCodeGenerator.h"
#include "GSVertexSW.h" #include "GSVertexSW.h"
#include "../../GS_codegen.h"
#if _M_SSE < 0x501 && !(defined(_M_AMD64) || defined(_WIN64)) #if _M_SSE < 0x501 && !(defined(_M_AMD64) || defined(_WIN64))
using namespace Xbyak;
static const int _args = 0; static const int _args = 0;
static const int _vertex = _args + 4; static const int _vertex = _args + 4;
static const int _index = _args + 8; static const int _index = _args + 8;

View File

@ -22,11 +22,10 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GSSetupPrimCodeGenerator.h" #include "GSSetupPrimCodeGenerator.h"
#include "GSVertexSW.h" #include "GSVertexSW.h"
#include "../../GS_codegen.h"
#if _M_SSE >= 0x501 && !(defined(_M_AMD64) || defined(_WIN64)) #if _M_SSE >= 0x501 && !(defined(_M_AMD64) || defined(_WIN64))
using namespace Xbyak;
static const int _args = 0; static const int _args = 0;
static const int _vertex = _args + 4; static const int _vertex = _args + 4;
static const int _index = _args + 8; static const int _index = _args + 8;

View File

@ -22,11 +22,10 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GSSetupPrimCodeGenerator.h" #include "GSSetupPrimCodeGenerator.h"
#include "GSVertexSW.h" #include "GSVertexSW.h"
#include "../../GS_codegen.h"
#if _M_SSE < 0x501 && !(defined(_M_AMD64) || defined(_WIN64)) #if _M_SSE < 0x501 && !(defined(_M_AMD64) || defined(_WIN64))
using namespace Xbyak;
static const int _args = 0; static const int _args = 0;
static const int _vertex = _args + 4; static const int _vertex = _args + 4;
static const int _index = _args + 8; static const int _index = _args + 8;

View File

@ -21,7 +21,7 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "GSTextureSW.h" #include "GSTextureSW.h"
#include "GSPng.h" #include "../../GSPng.h"
GSTextureSW::GSTextureSW(int type, int width, int height) GSTextureSW::GSTextureSW(int type, int width, int height)
{ {