From 01aff16aac946d77187213de193fa86322930915 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Fri, 1 Jan 2010 05:18:32 +0000 Subject: [PATCH] GSdx: A few minor cleanups to nudge GSdx a little closer to being cross-platform compatible, git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2405 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GPU.cpp | 4 ++++ plugins/GSdx/GPUDrawScanlineCodeGenerator.cpp | 2 +- plugins/GSdx/GPUDrawingEnvironment.h | 2 +- plugins/GSdx/GPUScanlineEnvironment.h | 4 ++-- plugins/GSdx/GPUVertex.h | 2 +- plugins/GSdx/GS.h | 2 +- plugins/GSdx/GSBlock.h | 14 +++++++------- plugins/GSdx/GSClut.h | 6 +++--- plugins/GSdx/GSDeviceDX.h | 4 ++-- plugins/GSdx/GSDrawingContext.h | 4 ++-- plugins/GSdx/GSDrawingEnvironment.h | 2 +- plugins/GSdx/GSLocalMemory.cpp | 18 +++++++++--------- plugins/GSdx/GSRasterizer.h | 2 +- plugins/GSdx/GSScanlineEnvironment.h | 4 ++-- plugins/GSdx/GSVector.h | 17 ++++++++++------- plugins/GSdx/GSVertex.h | 2 +- plugins/GSdx/GSVertexHW.h | 4 ++-- plugins/GSdx/GSVertexSW.h | 2 +- plugins/GSdx/GSVertexTrace.h | 2 +- plugins/GSdx/GSdx.h | 6 +++++- plugins/GSdx/stdafx.h | 16 +++++++++++----- 21 files changed, 68 insertions(+), 51 deletions(-) diff --git a/plugins/GSdx/GPU.cpp b/plugins/GSdx/GPU.cpp index 44ef8df348..7763fb8de2 100644 --- a/plugins/GSdx/GPU.cpp +++ b/plugins/GSdx/GPU.cpp @@ -23,9 +23,13 @@ #include "GSdx.h" #include "GSUtil.h" #include "GPURendererSW.h" + +#ifdef _WINDOWS #include "GSDevice7.h" #include "GSDevice9.h" #include "GSDevice10.h" +#endif + #include "GPUSettingsDlg.h" #define PSE_LT_GPU 2 diff --git a/plugins/GSdx/GPUDrawScanlineCodeGenerator.cpp b/plugins/GSdx/GPUDrawScanlineCodeGenerator.cpp index 1a7699658d..f359e777cd 100644 --- a/plugins/GSdx/GPUDrawScanlineCodeGenerator.cpp +++ b/plugins/GSdx/GPUDrawScanlineCodeGenerator.cpp @@ -1020,7 +1020,7 @@ const GSVector4i GPUDrawScanlineCodeGenerator::m_test[8] = GSVector4i::zero(), }; -__declspec(align(16)) const uint16 GPUDrawScanlineCodeGenerator::m_dither[4][16] = +__aligned16 const uint16 GPUDrawScanlineCodeGenerator::m_dither[4][16] = { {7, 0, 6, 1, 7, 0, 6, 1, 7, 0, 6, 1, 7, 0, 6, 1}, {2, 5, 3, 4, 2, 5, 3, 4, 2, 5, 3, 4, 2, 5, 3, 4}, diff --git a/plugins/GSdx/GPUDrawingEnvironment.h b/plugins/GSdx/GPUDrawingEnvironment.h index c89ea4920a..bfa4c77df5 100644 --- a/plugins/GSdx/GPUDrawingEnvironment.h +++ b/plugins/GSdx/GPUDrawingEnvironment.h @@ -25,7 +25,7 @@ #pragma pack(push, 1) -__declspec(align(16)) class GPUDrawingEnvironment +__aligned16 class GPUDrawingEnvironment { public: GPURegSTATUS STATUS; diff --git a/plugins/GSdx/GPUScanlineEnvironment.h b/plugins/GSdx/GPUScanlineEnvironment.h index 189341e7f8..230c3cab00 100644 --- a/plugins/GSdx/GPUScanlineEnvironment.h +++ b/plugins/GSdx/GPUScanlineEnvironment.h @@ -56,7 +56,7 @@ union GPUScanlineSelector operator uint32() {return key;} }; -__declspec(align(16)) struct GPUScanlineParam +__aligned16 struct GPUScanlineParam { GPUScanlineSelector sel; @@ -64,7 +64,7 @@ __declspec(align(16)) struct GPUScanlineParam const uint16* clut; }; -__declspec(align(16)) struct GPUScanlineEnvironment +__aligned16 struct GPUScanlineEnvironment { GPUScanlineSelector sel; diff --git a/plugins/GSdx/GPUVertex.h b/plugins/GSdx/GPUVertex.h index cb0c4a3049..b96b8c551f 100644 --- a/plugins/GSdx/GPUVertex.h +++ b/plugins/GSdx/GPUVertex.h @@ -26,7 +26,7 @@ #pragma pack(push, 1) -__declspec(align(16)) struct GPUVertex +__aligned16 struct GPUVertex { union { diff --git a/plugins/GSdx/GS.h b/plugins/GSdx/GS.h index 39d54c43d2..134c1c5601 100644 --- a/plugins/GSdx/GS.h +++ b/plugins/GSdx/GS.h @@ -1080,7 +1080,7 @@ REG128_SET(GIFPackedReg) GIFPackedNOP NOP; REG_SET_END -__declspec(align(16)) struct GIFPath +__aligned16 struct GIFPath { GIFTag tag; uint32 reg; diff --git a/plugins/GSdx/GSBlock.h b/plugins/GSdx/GSBlock.h index 7b548bf3bf..e637f70f63 100644 --- a/plugins/GSdx/GSBlock.h +++ b/plugins/GSdx/GSBlock.h @@ -1201,7 +1201,7 @@ public: #else /* - __declspec(align(16)) uint32 block[8 * 8]; + __aligned16 uint32 block[8 * 8]; UnpackBlock4HL(src, srcpitch, block); @@ -1316,7 +1316,7 @@ public: #else /* - __declspec(align(16)) uint32 block[8 * 8]; + __aligned16 uint32 block[8 * 8]; UnpackBlock4HH(src, srcpitch, block); @@ -1467,7 +1467,7 @@ public: #else - __declspec(align(16)) uint8 block[16 * 16]; + __aligned16 uint8 block[16 * 16]; ReadBlock8(src, (uint8*)block, sizeof(block) / 16); @@ -1542,7 +1542,7 @@ public: #else - __declspec(align(16)) uint8 block[(32 / 2) * 16]; + __aligned16 uint8 block[(32 / 2) * 16]; ReadBlock4(src, (uint8*)block, sizeof(block) / 16); @@ -1583,7 +1583,7 @@ public: #else - __declspec(align(16)) uint32 block[8 * 8]; + __aligned16 uint32 block[8 * 8]; ReadBlock32(src, (uint8*)block, sizeof(block) / 8); @@ -1624,7 +1624,7 @@ public: #else - __declspec(align(16)) uint32 block[8 * 8]; + __aligned16 uint32 block[8 * 8]; ReadBlock32(src, (uint8*)block, sizeof(block) / 8); @@ -1665,7 +1665,7 @@ public: #else - __declspec(align(16)) uint32 block[8 * 8]; + __aligned16 uint32 block[8 * 8]; ReadBlock32(src, (uint8*)block, sizeof(block) / 8); diff --git a/plugins/GSdx/GSClut.h b/plugins/GSdx/GSClut.h index 1ac00ba328..9c658fad96 100644 --- a/plugins/GSdx/GSClut.h +++ b/plugins/GSdx/GSClut.h @@ -28,7 +28,7 @@ class GSLocalMemory; -__declspec(align(16)) class GSClut : public GSAlignedClass<16> +__aligned16 class GSClut : public GSAlignedClass<16> { GSLocalMemory* m_mem; @@ -37,7 +37,7 @@ __declspec(align(16)) class GSClut : public GSAlignedClass<16> uint32* m_buff32; uint64* m_buff64; - __declspec(align(16)) struct WriteState + __aligned16 struct WriteState { GIFRegTEX0 TEX0; GIFRegTEXCLUT TEXCLUT; @@ -45,7 +45,7 @@ __declspec(align(16)) class GSClut : public GSAlignedClass<16> bool IsDirty(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT); } m_write; - __declspec(align(16)) struct ReadState + __aligned16 struct ReadState { GIFRegTEX0 TEX0; GIFRegTEXA TEXA; diff --git a/plugins/GSdx/GSDeviceDX.h b/plugins/GSdx/GSDeviceDX.h index 78a478f038..a9aedb82b0 100644 --- a/plugins/GSdx/GSDeviceDX.h +++ b/plugins/GSdx/GSDeviceDX.h @@ -30,7 +30,7 @@ class GSDeviceDX : public GSDevice public: #pragma pack(push, 1) - __declspec(align(16)) struct VSConstantBuffer + __aligned16 struct VSConstantBuffer { GSVector4 VertexScale; GSVector4 VertexOffset; @@ -85,7 +85,7 @@ public: VSSelector() : key(0) {} }; - __declspec(align(16)) struct PSConstantBuffer + __aligned16 struct PSConstantBuffer { GSVector4 FogColor_AREF; GSVector4 HalfTexel; diff --git a/plugins/GSdx/GSDrawingContext.h b/plugins/GSdx/GSDrawingContext.h index 91f9e4ec92..0129292ff8 100644 --- a/plugins/GSdx/GSDrawingContext.h +++ b/plugins/GSdx/GSDrawingContext.h @@ -26,7 +26,7 @@ #pragma pack(push, 1) -__declspec(align(16)) class GSDrawingContext +__aligned16 class GSDrawingContext { public: GIFRegXYOFFSET XYOFFSET; @@ -43,7 +43,7 @@ public: GIFRegFRAME FRAME; GIFRegZBUF ZBUF; - __declspec(align(16)) struct + __aligned16 struct { GSVector4i dx10; GSVector4 dx9; diff --git a/plugins/GSdx/GSDrawingEnvironment.h b/plugins/GSdx/GSDrawingEnvironment.h index dfca1aa953..63b28e8090 100644 --- a/plugins/GSdx/GSDrawingEnvironment.h +++ b/plugins/GSdx/GSDrawingEnvironment.h @@ -25,7 +25,7 @@ #pragma pack(push, 1) -__declspec(align(16)) class GSDrawingEnvironment +__aligned16 class GSDrawingEnvironment { public: GIFRegPRIM PRIM; diff --git a/plugins/GSdx/GSLocalMemory.cpp b/plugins/GSdx/GSLocalMemory.cpp index 411c214c04..dbfd5908e4 100644 --- a/plugins/GSdx/GSLocalMemory.cpp +++ b/plugins/GSdx/GSLocalMemory.cpp @@ -628,7 +628,7 @@ void GSLocalMemory::WriteImageLeftRight(int l, int r, int y, int h, uint8* src, template void GSLocalMemory::WriteImageTopBottom(int l, int r, int y, int h, uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF) { - __declspec(align(16)) uint8 buff[64]; // merge buffer for one column + __aligned16 uint8 buff[64]; // merge buffer for one column uint32 bp = BITBLTBUF.DBP; uint32 bw = BITBLTBUF.DBW; @@ -1438,7 +1438,7 @@ void GSLocalMemory::ReadTexture24(const GSOffset* RESTRICT o, const GSVector4i& void GSLocalMemory::ReadTexture16(const GSOffset* RESTRICT o, const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) { - __declspec(align(16)) uint16 block[16 * 8]; + __aligned16 uint16 block[16 * 8]; FOREACH_BLOCK_START(r, 16, 8, 32) { @@ -1451,7 +1451,7 @@ void GSLocalMemory::ReadTexture16(const GSOffset* RESTRICT o, const GSVector4i& void GSLocalMemory::ReadTexture16S(const GSOffset* RESTRICT o, const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) { - __declspec(align(16)) uint16 block[16 * 8]; + __aligned16 uint16 block[16 * 8]; FOREACH_BLOCK_START(r, 16, 8, 32) { @@ -1548,7 +1548,7 @@ void GSLocalMemory::ReadTexture24Z(const GSOffset* RESTRICT o, const GSVector4i& void GSLocalMemory::ReadTexture16Z(const GSOffset* RESTRICT o, const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) { - __declspec(align(16)) uint16 block[16 * 8]; + __aligned16 uint16 block[16 * 8]; FOREACH_BLOCK_START(r, 16, 8, 32) { @@ -1561,7 +1561,7 @@ void GSLocalMemory::ReadTexture16Z(const GSOffset* RESTRICT o, const GSVector4i& void GSLocalMemory::ReadTexture16SZ(const GSOffset* RESTRICT o, const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) { - __declspec(align(16)) uint16 block[16 * 8]; + __aligned16 uint16 block[16 * 8]; FOREACH_BLOCK_START(r, 16, 8, 32) { @@ -1597,7 +1597,7 @@ void GSLocalMemory::ReadTextureBlock24(uint32 bp, uint8* dst, int dstpitch, cons void GSLocalMemory::ReadTextureBlock16(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { - __declspec(align(16)) uint16 block[16 * 8]; + __aligned16 uint16 block[16 * 8]; ReadBlock16(BlockPtr(bp), (uint8*)block, sizeof(block) / 8); @@ -1606,7 +1606,7 @@ void GSLocalMemory::ReadTextureBlock16(uint32 bp, uint8* dst, int dstpitch, cons void GSLocalMemory::ReadTextureBlock16S(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { - __declspec(align(16)) uint16 block[16 * 8]; + __aligned16 uint16 block[16 * 8]; ReadBlock16(BlockPtr(bp), (uint8*)block, sizeof(block) / 8); @@ -1671,7 +1671,7 @@ void GSLocalMemory::ReadTextureBlock24Z(uint32 bp, uint8* dst, int dstpitch, con void GSLocalMemory::ReadTextureBlock16Z(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { - __declspec(align(16)) uint16 block[16 * 8]; + __aligned16 uint16 block[16 * 8]; ReadBlock16(BlockPtr(bp), (uint8*)block, sizeof(block) / 8); @@ -1680,7 +1680,7 @@ void GSLocalMemory::ReadTextureBlock16Z(uint32 bp, uint8* dst, int dstpitch, con void GSLocalMemory::ReadTextureBlock16SZ(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { - __declspec(align(16)) uint16 block[16 * 8]; + __aligned16 uint16 block[16 * 8]; ReadBlock16(BlockPtr(bp), (uint8*)block, sizeof(block) / 8); diff --git a/plugins/GSdx/GSRasterizer.h b/plugins/GSdx/GSRasterizer.h index d3aec94779..36dc693340 100644 --- a/plugins/GSdx/GSRasterizer.h +++ b/plugins/GSdx/GSRasterizer.h @@ -30,7 +30,7 @@ #include "pthread.h" #include "semaphore.h" -__declspec(align(16)) class GSRasterizerData +__aligned16 class GSRasterizerData { public: GSVector4i scissor; diff --git a/plugins/GSdx/GSScanlineEnvironment.h b/plugins/GSdx/GSScanlineEnvironment.h index 48abcc707c..0775b083ba 100644 --- a/plugins/GSdx/GSScanlineEnvironment.h +++ b/plugins/GSdx/GSScanlineEnvironment.h @@ -99,7 +99,7 @@ union GSScanlineSelector } }; -__declspec(align(16)) struct GSScanlineParam +__aligned16 struct GSScanlineParam { GSScanlineSelector sel; @@ -115,7 +115,7 @@ __declspec(align(16)) struct GSScanlineParam uint32 fm, zm; }; -__declspec(align(16)) struct GSScanlineEnvironment +__aligned16 struct GSScanlineEnvironment { void* vm; const void* tex; diff --git a/plugins/GSdx/GSVector.h b/plugins/GSdx/GSVector.h index 8ffed0801b..e653a18146 100644 --- a/plugins/GSdx/GSVector.h +++ b/plugins/GSdx/GSVector.h @@ -1,3 +1,6 @@ + +#include "stdafx.h" + #pragma once // NOTE: x64 version of the _mm_set_* functions are terrible, first they store components into memory then reload in one piece (VS2008 SP1) @@ -40,7 +43,7 @@ typedef GSVector2T GSVector2i; class GSVector4; -__declspec(align(16)) class GSVector4i +__aligned16 class GSVector4i { public: union @@ -2038,9 +2041,9 @@ public: VECTOR4i_SHUFFLE_3(xs, xn, ys, yn, w, 3) \ #define VECTOR4i_SHUFFLE_1(xs, xn) \ - GSVector4i xs##4##() const {return GSVector4i(_mm_shuffle_epi32(m, _MM_SHUFFLE(xn, xn, xn, xn)));} \ - GSVector4i xs##4##l() const {return GSVector4i(_mm_shufflelo_epi16(m, _MM_SHUFFLE(xn, xn, xn, xn)));} \ - GSVector4i xs##4##h() const {return GSVector4i(_mm_shufflehi_epi16(m, _MM_SHUFFLE(xn, xn, xn, xn)));} \ + GSVector4i xs##4() const {return GSVector4i(_mm_shuffle_epi32(m, _MM_SHUFFLE(xn, xn, xn, xn)));} \ + GSVector4i xs##4l() const {return GSVector4i(_mm_shufflelo_epi16(m, _MM_SHUFFLE(xn, xn, xn, xn)));} \ + GSVector4i xs##4h() const {return GSVector4i(_mm_shufflehi_epi16(m, _MM_SHUFFLE(xn, xn, xn, xn)));} \ VECTOR4i_SHUFFLE_2(xs, xn, x, 0) \ VECTOR4i_SHUFFLE_2(xs, xn, y, 1) \ VECTOR4i_SHUFFLE_2(xs, xn, z, 2) \ @@ -2250,7 +2253,7 @@ public: static GSVector4i xfffe(const GSVector4i& v) {return xffffffff(v).sll16( 1);} }; -__declspec(align(16)) class GSVector4 +__aligned16 class GSVector4 { public: union @@ -2860,8 +2863,8 @@ public: VECTOR4_SHUFFLE_3(xs, xn, ys, yn, w, 3) \ #define VECTOR4_SHUFFLE_1(xs, xn) \ - GSVector4 xs##4##() const {return GSVector4(_mm_shuffle_ps(m, m, _MM_SHUFFLE(xn, xn, xn, xn)));} \ - GSVector4 xs##4##(const GSVector4& v) const {return GSVector4(_mm_shuffle_ps(m, v.m, _MM_SHUFFLE(xn, xn, xn, xn)));} \ + GSVector4 xs##4() const {return GSVector4(_mm_shuffle_ps(m, m, _MM_SHUFFLE(xn, xn, xn, xn)));} \ + GSVector4 xs##4(const GSVector4& v) const {return GSVector4(_mm_shuffle_ps(m, v.m, _MM_SHUFFLE(xn, xn, xn, xn)));} \ VECTOR4_SHUFFLE_2(xs, xn, x, 0) \ VECTOR4_SHUFFLE_2(xs, xn, y, 1) \ VECTOR4_SHUFFLE_2(xs, xn, z, 2) \ diff --git a/plugins/GSdx/GSVertex.h b/plugins/GSdx/GSVertex.h index 18d854be04..9032351680 100644 --- a/plugins/GSdx/GSVertex.h +++ b/plugins/GSdx/GSVertex.h @@ -28,7 +28,7 @@ #pragma pack(push, 1) -__declspec(align(16)) struct GSVertex +__aligned16 struct GSVertex { union { diff --git a/plugins/GSdx/GSVertexHW.h b/plugins/GSdx/GSVertexHW.h index 6314d31f39..22fc5c9e65 100644 --- a/plugins/GSdx/GSVertexHW.h +++ b/plugins/GSdx/GSVertexHW.h @@ -26,7 +26,7 @@ #pragma pack(push, 1) -__declspec(align(16)) union GSVertexHW9 +__aligned16 union GSVertexHW9 { struct { @@ -56,7 +56,7 @@ __declspec(align(16)) union GSVertexHW9 float GetQ() {return p.w;} }; -__declspec(align(16)) union GSVertexHW10 +__aligned16 union GSVertexHW10 { struct { diff --git a/plugins/GSdx/GSVertexSW.h b/plugins/GSdx/GSVertexSW.h index e3e181d0ef..28e4644b2a 100644 --- a/plugins/GSdx/GSVertexSW.h +++ b/plugins/GSdx/GSVertexSW.h @@ -23,7 +23,7 @@ #include "GSVector.h" -__declspec(align(16)) union GSVertexSW +__aligned16 union GSVertexSW { struct {GSVector4 c, p, t;}; struct {GSVector4 v[3];}; diff --git a/plugins/GSdx/GSVertexTrace.h b/plugins/GSdx/GSVertexTrace.h index eaed4bf267..ac52af71a3 100644 --- a/plugins/GSdx/GSVertexTrace.h +++ b/plugins/GSdx/GSVertexTrace.h @@ -31,7 +31,7 @@ class GSState; -__declspec(align(16)) class GSVertexTrace +__aligned16 class GSVertexTrace { struct Vertex {GSVector4i c; GSVector4 p, t;}; struct VertexAlpha {int min, max; bool valid;}; diff --git a/plugins/GSdx/GSdx.h b/plugins/GSdx/GSdx.h index 93fc2c38db..0ebdfc281c 100644 --- a/plugins/GSdx/GSdx.h +++ b/plugins/GSdx/GSdx.h @@ -29,7 +29,11 @@ class GSdxApp public: GSdxApp(); - HMODULE GetModuleHandle(); +#ifdef _WINDOWS + HMODULE GetModuleHandle(); +#else + void *GetModuleHandle(); +#endif string GetConfig(const char* entry, const char* value); void SetConfig(const char* entry, const char* value); diff --git a/plugins/GSdx/stdafx.h b/plugins/GSdx/stdafx.h index bcaf3afd33..5e0d062aaa 100644 --- a/plugins/GSdx/stdafx.h +++ b/plugins/GSdx/stdafx.h @@ -46,8 +46,8 @@ #include #include -#include +#include #include #include #include @@ -56,8 +56,14 @@ #include #include +// Let's take advantage of the work that's already been done on making things cross-platform by bringing this in. +#include "Pcsx2Defs.h" + using namespace std; + +#ifdef _WINDOWS using namespace stdext; +#endif extern string format(const char* fmt, ...); @@ -86,7 +92,7 @@ typedef signed long long int64; #define EXPORT_C extern "C" __declspec(dllexport) void __stdcall #define EXPORT_C_(type) extern "C" __declspec(dllexport) type __stdcall -#define ALIGN_STACK(n) __declspec(align(n)) int __dummy; +#define ALIGN_STACK(n) __aligned(n) int __dummy; #ifndef RESTRICT #ifdef __INTEL_COMPILER @@ -135,8 +141,8 @@ typedef signed long long int64; #include #include -#include -#include +#include +#include #ifdef _WINDOWS #include @@ -144,7 +150,7 @@ typedef signed long long int64; // sse -#if !defined(_M_SSE) && (defined(_M_AMD64) || defined(_M_IX86_FP) && _M_IX86_FP >= 2) +#if !defined(_M_SSE) && (!defined(_WINDOWS) || defined(_M_AMD64) || defined(_M_IX86_FP) && _M_IX86_FP >= 2) #define _M_SSE 0x200