Skip to content

Commit

Permalink
GS: Header cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
TellowKrinkle committed Nov 14, 2021
1 parent b74be70 commit ed90e2f
Show file tree
Hide file tree
Showing 29 changed files with 41 additions and 143 deletions.
1 change: 1 addition & 0 deletions pcsx2/GS/GS.cpp
Expand Up @@ -17,6 +17,7 @@
#include "GS/Window/GSwxDialog.h"
#include "GS.h"
#include "GSUtil.h"
#include "GS_types.h"
#include "Renderers/SW/GSRendererSW.h"
#include "Renderers/Null/GSRendererNull.h"
#include "Renderers/Null/GSDeviceNull.h"
Expand Down
117 changes: 7 additions & 110 deletions pcsx2/GS/GS.h
Expand Up @@ -20,8 +20,6 @@

#include "config.h"
#include "common/Pcsx2Types.h"
#include "common/WindowInfo.h"
#include "GS_types.h"
#include "Window/GSSetting.h"
#include "SaveState.h"

Expand All @@ -35,10 +33,6 @@
#include <d3d11_1.h>
#include <dxgi1_3.h>

#else

#include <fcntl.h>

#endif

#include "Renderers/OpenGL/GLLoader.h"
Expand All @@ -55,130 +49,33 @@

#endif

// put these into vc9/common7/ide/usertype.dat to have them highlighted


// stdc

#include <cstddef>
#include <cstdio>
#include <cstdarg>
#include <cstdlib>
#include <cmath>
#include <cfloat>
#include <ctime>
#include <climits>
#include <cstring>
#include <cassert>

#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 4)
#include <codecvt>
#include <locale>
#endif

#include <complex>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <thread>
#include <atomic>
#include <mutex>
#include <condition_variable>
#include <functional>
#include <memory>
#include <bitset>

#ifdef __POSIX__
#include <zlib.h>
#else
#include <zlib/zlib.h>
#endif

#include <unordered_map>
#include <unordered_set>

// Don't un-indent our ifdefs
// clang-format off

#ifdef _MSC_VER

#define EXPORT_C_(type) extern "C" type __stdcall
#define EXPORT_C EXPORT_C_(void)

#define ALIGN_STACK(n) alignas(n) int dummy__; (void)dummy__;

#else

#ifndef __fastcall
#define __fastcall __attribute__((fastcall))
#endif

#define EXPORT_C_(type) extern "C" __attribute__((stdcall, externally_visible, visibility("default"))) type
#define EXPORT_C EXPORT_C_(void)

#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

#ifndef RESTRICT

#ifdef __INTEL_COMPILER

#define RESTRICT restrict

#elif defined(_MSC_VER)

#define RESTRICT __restrict

#elif defined(__GNUC__)

#define RESTRICT __restrict__

#else

#define RESTRICT

#endif

#endif

#include <xmmintrin.h>
#include <emmintrin.h>

#ifndef _MM_DENORMALS_ARE_ZERO
#define _MM_DENORMALS_ARE_ZERO 0x0040
#endif

#define MXCSR (_MM_DENORMALS_ARE_ZERO | _MM_MASK_MASK | _MM_ROUND_NEAREST | _MM_FLUSH_ZERO_ON)

#define _MM_TRANSPOSE4_SI128(row0, row1, row2, row3) \
{ \
__m128 tmp0 = _mm_shuffle_ps(_mm_castsi128_ps(row0), _mm_castsi128_ps(row1), 0x44); \
__m128 tmp2 = _mm_shuffle_ps(_mm_castsi128_ps(row0), _mm_castsi128_ps(row1), 0xEE); \
__m128 tmp1 = _mm_shuffle_ps(_mm_castsi128_ps(row2), _mm_castsi128_ps(row3), 0x44); \
__m128 tmp3 = _mm_shuffle_ps(_mm_castsi128_ps(row2), _mm_castsi128_ps(row3), 0xEE); \
(row0) = _mm_castps_si128(_mm_shuffle_ps(tmp0, tmp1, 0x88)); \
(row1) = _mm_castps_si128(_mm_shuffle_ps(tmp0, tmp1, 0xDD)); \
(row2) = _mm_castps_si128(_mm_shuffle_ps(tmp2, tmp3, 0x88)); \
(row3) = _mm_castps_si128(_mm_shuffle_ps(tmp2, tmp3, 0xDD)); \
}

#include <tmmintrin.h>
#include <smmintrin.h>

Expand Down Expand Up @@ -238,21 +135,21 @@ extern void fifo_free(void* ptr, size_t size, size_t repeat);
while(0);

#if defined(_DEBUG)
# define GL_CACHE(...) GL_INSERT(GL_DEBUG_TYPE_OTHER, 0xFEAD, GL_DEBUG_SEVERITY_NOTIFICATION, __VA_ARGS__)
#define GL_CACHE(...) GL_INSERT(GL_DEBUG_TYPE_OTHER, 0xFEAD, GL_DEBUG_SEVERITY_NOTIFICATION, __VA_ARGS__)
#else
# define GL_CACHE(...) (void)(0);
#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__)
#define GL_REG(...) GL_INSERT(GL_DEBUG_TYPE_OTHER, 0xB0B0, GL_DEBUG_SEVERITY_NOTIFICATION, __VA_ARGS__)
#else
# define GL_REG(...) (void)(0);
#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__)
#define GL_DBG(...) GL_INSERT(GL_DEBUG_TYPE_OTHER, 0xD0D0, GL_DEBUG_SEVERITY_NOTIFICATION, __VA_ARGS__)
#else
# define GL_DBG(...) (void)(0);
#define GL_DBG(...) (void)(0);
#endif

#if defined(ENABLE_OGL_DEBUG)
Expand Down Expand Up @@ -284,7 +181,7 @@ extern const std::string root_hw;

// MacOS headers define PAGE_SIZE to the size of an x86 page
#ifdef PAGE_SIZE
# undef PAGE_SIZE
#undef PAGE_SIZE
#endif

#define VM_SIZE 4194304u
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/GS/GSCodeBuffer.cpp
Expand Up @@ -15,7 +15,7 @@

#include "PrecompiledHeader.h"
#include "GSCodeBuffer.h"
#include "GS_types.h"
#include "GS.h"

GSCodeBuffer::GSCodeBuffer(size_t blocksize)
: m_blocksize(blocksize)
Expand Down
2 changes: 0 additions & 2 deletions pcsx2/GS/GSCodeBuffer.h
Expand Up @@ -15,8 +15,6 @@

#pragma once

#include "GS_types.h"

class GSCodeBuffer
{
std::vector<void*> m_buffers;
Expand Down
1 change: 1 addition & 0 deletions pcsx2/GS/GSDump.cpp
Expand Up @@ -15,6 +15,7 @@

#include "PrecompiledHeader.h"
#include "GSDump.h"
#include "GS_types.h"

GSDumpBase::GSDumpBase(const std::string& fn)
: m_frames(0)
Expand Down
1 change: 1 addition & 0 deletions pcsx2/GS/GSLocalMemory.cpp
Expand Up @@ -16,6 +16,7 @@
#include "PrecompiledHeader.h"
#include "GSLocalMemory.h"
#include "GS.h"
#include <unordered_set>

template <typename Fn>
static void foreachBlock(const GSOffset& off, GSLocalMemory* mem, const GSVector4i& r, u8* dst, int dstpitch, int bpp, Fn&& fn)
Expand Down
2 changes: 2 additions & 0 deletions pcsx2/GS/GSLocalMemory.h
Expand Up @@ -20,6 +20,8 @@
#include "GSVector.h"
#include "GSBlock.h"
#include "GSClut.h"
#include <array>
#include <unordered_map>

struct GSPixelOffset
{
Expand Down
1 change: 0 additions & 1 deletion pcsx2/GS/GSPerfMon.cpp
Expand Up @@ -15,7 +15,6 @@

#include "PrecompiledHeader.h"
#include "GSPerfMon.h"
#include "GS_types.h"

GSPerfMon::GSPerfMon()
: m_frame(0)
Expand Down
2 changes: 0 additions & 2 deletions pcsx2/GS/GSPerfMon.h
Expand Up @@ -15,8 +15,6 @@

#pragma once

#include "GS_types.h"

class GSPerfMon
{
public:
Expand Down
1 change: 1 addition & 0 deletions pcsx2/GS/GSPng.cpp
Expand Up @@ -15,6 +15,7 @@

#include "PrecompiledHeader.h"
#include "GSPng.h"
#include "GS_types.h"
#include <zlib.h>
#include <png.h>

Expand Down
1 change: 0 additions & 1 deletion pcsx2/GS/GSTables.cpp
Expand Up @@ -17,7 +17,6 @@

#include "PrecompiledHeader.h"
#include "GSTables.h"
#include "GS_types.h"

template <int Width, int Height>
static constexpr GSSizedBlockSwizzleTable<Height, Width> makeSwizzleTable(const u8 (&arr)[Height][Width]) {
Expand Down
2 changes: 0 additions & 2 deletions pcsx2/GS/GSTables.h
Expand Up @@ -15,8 +15,6 @@

#pragma once

#include "GS_types.h"

/// Table for storing swizzling of blocks within a page
struct alignas(64) GSBlockSwizzleTable
{
Expand Down
3 changes: 3 additions & 0 deletions pcsx2/GS/GSThread_CXX11.h
Expand Up @@ -18,6 +18,9 @@
#include "GS.h"
#include "common/boost_spsc_queue.hpp"
#include "common/General.h"
#include <condition_variable>
#include <functional>
#include <mutex>

template <class T, int CAPACITY>
class GSJobQueue final
Expand Down
1 change: 1 addition & 0 deletions pcsx2/GS/GSVector.cpp
Expand Up @@ -16,6 +16,7 @@
#include "PrecompiledHeader.h"
#include "GS.h"
#include "GSVector.h"
#include <cfloat>

CONSTINIT const GSVector4i GSVector4i::m_xff[17] =
{
Expand Down
1 change: 0 additions & 1 deletion pcsx2/GS/GSVector.h
Expand Up @@ -14,7 +14,6 @@
*/

#include "PrecompiledHeader.h"
#include "GS_types.h"

#pragma once

Expand Down
11 changes: 8 additions & 3 deletions pcsx2/GS/GSVector4i.h
Expand Up @@ -13,8 +13,6 @@
* If not, see <http://www.gnu.org/licenses/>.
*/

#include "GS_types.h"

class alignas(16) GSVector4i
{
static const GSVector4i m_xff[17];
Expand Down Expand Up @@ -1670,7 +1668,14 @@ class alignas(16) GSVector4i

__forceinline static void transpose(GSVector4i& a, GSVector4i& b, GSVector4i& c, GSVector4i& d)
{
_MM_TRANSPOSE4_SI128(a.m, b.m, c.m, d.m);
__m128 tmp0 = _mm_shuffle_ps(_mm_castsi128_ps(a.m), _mm_castsi128_ps(b.m), 0x44);
__m128 tmp2 = _mm_shuffle_ps(_mm_castsi128_ps(a.m), _mm_castsi128_ps(b.m), 0xEE);
__m128 tmp1 = _mm_shuffle_ps(_mm_castsi128_ps(c.m), _mm_castsi128_ps(d.m), 0x44);
__m128 tmp3 = _mm_shuffle_ps(_mm_castsi128_ps(c.m), _mm_castsi128_ps(d.m), 0xEE);
a = _mm_castps_si128(_mm_shuffle_ps(tmp0, tmp1, 0x88));
b = _mm_castps_si128(_mm_shuffle_ps(tmp0, tmp1, 0xDD));
c = _mm_castps_si128(_mm_shuffle_ps(tmp2, tmp3, 0x88));
d = _mm_castps_si128(_mm_shuffle_ps(tmp2, tmp3, 0xDD));
}

__forceinline static void sw4(GSVector4i& a, GSVector4i& b, GSVector4i& c, GSVector4i& d)
Expand Down
18 changes: 0 additions & 18 deletions pcsx2/GS/GS_types.h
Expand Up @@ -15,8 +15,6 @@

#pragma once

#include <cfloat>

// clang-format off

#ifdef _WIN32
Expand Down Expand Up @@ -46,19 +44,3 @@ inline FILE* px_fopen(const std::string& filename, const std::string& mode)
return fopen(filename.c_str(), mode.c_str());
#endif
}

#define _MM_TRANSPOSE4_SI128(row0, row1, row2, row3) \
{ \
__m128 tmp0 = _mm_shuffle_ps(_mm_castsi128_ps(row0), _mm_castsi128_ps(row1), 0x44); \
__m128 tmp2 = _mm_shuffle_ps(_mm_castsi128_ps(row0), _mm_castsi128_ps(row1), 0xEE); \
__m128 tmp1 = _mm_shuffle_ps(_mm_castsi128_ps(row2), _mm_castsi128_ps(row3), 0x44); \
__m128 tmp3 = _mm_shuffle_ps(_mm_castsi128_ps(row2), _mm_castsi128_ps(row3), 0xEE); \
(row0) = _mm_castps_si128(_mm_shuffle_ps(tmp0, tmp1, 0x88)); \
(row1) = _mm_castps_si128(_mm_shuffle_ps(tmp0, tmp1, 0xDD)); \
(row2) = _mm_castps_si128(_mm_shuffle_ps(tmp2, tmp3, 0x88)); \
(row3) = _mm_castps_si128(_mm_shuffle_ps(tmp2, tmp3, 0xDD)); \
}


extern void* vmalloc(size_t size, bool code);
extern void vmfree(void* ptr, size_t size);
1 change: 1 addition & 0 deletions pcsx2/GS/Renderers/Common/GSDevice.h
Expand Up @@ -21,6 +21,7 @@
#include "GSVertex.h"
#include "GS/GSAlignedClass.h"
#include "GSOsdManager.h"
#include <array>

enum ShaderConvert
{
Expand Down
2 changes: 0 additions & 2 deletions pcsx2/GS/Renderers/Common/GSFastList.h
Expand Up @@ -15,8 +15,6 @@

#pragma once

#include "GS/GS_types.h"

template <class T>
struct Element
{
Expand Down
5 changes: 5 additions & 0 deletions pcsx2/GS/Renderers/Common/GSOsdManager.cpp
Expand Up @@ -20,6 +20,11 @@
#include "GS/resource.h"
#endif

#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 4)
#include <codecvt>
#include <locale>
#endif

void GSOsdManager::LoadFont()
{
FT_Error error = FT_New_Face(m_library, theApp.GetConfigS("osd_fontname").c_str(), 0, &m_face);
Expand Down
1 change: 1 addition & 0 deletions pcsx2/GS/Renderers/Common/GSVertexTrace.cpp
Expand Up @@ -17,6 +17,7 @@
#include "GSVertexTrace.h"
#include "GS/GSUtil.h"
#include "GS/GSState.h"
#include <cfloat>

CONSTINIT const GSVector4 GSVertexTrace::s_minmax = GSVector4::cxpr(FLT_MAX, -FLT_MAX, 0.f, 0.f);

Expand Down

0 comments on commit ed90e2f

Please sign in to comment.