Fix compilation on GCC and other Linux fixes (#80)

This commit is contained in:
Tom Lally
2022-08-28 15:29:15 +02:00
committed by GitHub
parent 96dcc7c82e
commit 454b587e36
43 changed files with 339 additions and 292 deletions
+1
View File
@@ -17,6 +17,7 @@
build/
out/
.cache/
bin/Cemu
# Cemu bin files
bin/otp.bin
+1 -1
View File
@@ -77,7 +77,7 @@ void ih264d_init_function_ptr(dec_struct_t *ps_codec)
}
}
#ifdef __clang__
#ifdef __GNUC__
#include <cpuid.h>
void __cpuid2(signed int* cpuInfo, unsigned int level)
+6 -3
View File
@@ -25,11 +25,14 @@ elseif(UNIX)
add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
endif()
add_definitions(-fms-extensions)
add_definitions(-fms-compatibility-version=19.14)
add_definitions(-fdelayed-template-parsing)
add_definitions(-fpermissive)
add_definitions(-maes)
# warnings
add_compile_options(-Wno-switch -Wno-ignored-attributes -Wno-deprecated-enum-enum-conversion -Wno-ambiguous-reversed-operator)
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-ambiguous-reversed-operator)
endif()
add_compile_options(-Wno-switch -Wno-ignored-attributes -Wno-deprecated-enum-enum-conversion)
endif()
add_definitions(-DVK_NO_PROTOTYPES)
+1 -1
View File
@@ -417,7 +417,7 @@ fs::path Account::GetFileName(uint32 persistent_id)
if (persistent_id < kMinPersistendId)
throw std::invalid_argument(fmt::format("persistent id {:#x} is invalid", persistent_id));
return CemuApp::GetMLCPath(fmt::format(L"usr\\save\\system\\act\\{:08x}\\account.dat", persistent_id)).ToStdWstring();
return CemuApp::GetMLCPath(fmt::format(L"usr/save/system/act/{:08x}/account.dat", persistent_id)).ToStdWstring();
}
OnlineValidator Account::ValidateOnlineFiles() const
+5 -1
View File
@@ -1,6 +1,11 @@
project(CemuCafe)
include_directories(".")
if((CMAKE_C_COMPILER_ID STREQUAL "GNU") OR (CMAKE_C_COMPILER_ID STREQUAL "Clang"))
add_compile_options(-mssse3 -mavx2)
endif()
file(GLOB_RECURSE CPP_FILES *.cpp)
file(GLOB_RECURSE H_FILES *.h)
add_library(CemuCafe ${CPP_FILES} ${H_FILES})
@@ -23,7 +28,6 @@ target_link_libraries(CemuCafe glslang SPIRV)
target_link_libraries(CemuCafe ih264d zarchive)
#target_link_libraries(CemuCafe zstd::libzstd_static)
IF(WIN32)
target_link_libraries(CemuCafe iphlpapi)
ENDIF()
@@ -34,7 +34,7 @@ PPCInterpreter_t* PPCInterpreter_getCurrentInstance()
return ppcInterpreterCurrentInstance;
}
__declspec(noinline) uint64 PPCInterpreter_getMainCoreCycleCounter()
uint64 PPCInterpreter_getMainCoreCycleCounter()
{
return PPCTimer_getFromRDTSC();
}
+2 -9
View File
@@ -5,13 +5,6 @@
#include "util/helpers/fspinlock.h"
#include "util/highresolutiontimer/HighResolutionTimer.h"
#if BOOST_OS_LINUX || BOOST_OS_MACOS
static __inline__
unsigned __int64 _umul128(unsigned __int64,
unsigned __int64,
unsigned __int64*);
#endif
uint64 _rdtscLastMeasure = 0;
uint64 _rdtscFrequency = 0;
@@ -49,7 +42,7 @@ uint64 PPCTimer_estimateRDTSCFrequency()
forceLog_printf("Invariant TSC not supported");
_mm_mfence();
unsigned __int64 tscStart = __rdtsc();
uint64 tscStart = __rdtsc();
unsigned int startTime = GetTickCount();
HRTick startTick = HighResolutionTimer::now().getTick();
// wait roughly 3 seconds
@@ -61,7 +54,7 @@ uint64 PPCTimer_estimateRDTSCFrequency()
}
_mm_mfence();
HRTick stopTick = HighResolutionTimer::now().getTick();
unsigned __int64 tscEnd = __rdtsc();
uint64 tscEnd = __rdtsc();
// derive frequency approximation from measured time difference
uint64 tsc_diff = tscEnd - tscStart;
uint64 hrtFreq = 0;
+15 -15
View File
@@ -345,20 +345,20 @@ typedef struct
PPCRecFunction_t* ppcRecompilerFuncTable[PPC_REC_ALIGN_TO_4MB(PPC_REC_CODE_AREA_SIZE/4)]; // one virtual-function pointer for each potential ppc instruction
PPCREC_JUMP_ENTRY ppcRecompilerDirectJumpTable[PPC_REC_ALIGN_TO_4MB(PPC_REC_CODE_AREA_SIZE/4)]; // lookup table for ppc offset to native code function
// x64 data
uint64 __declspec(align(16)) _x64XMM_xorNegateMaskBottom[2];
uint64 __declspec(align(16)) _x64XMM_xorNegateMaskPair[2];
uint64 __declspec(align(16)) _x64XMM_xorNOTMask[2];
uint64 __declspec(align(16)) _x64XMM_andAbsMaskBottom[2];
uint64 __declspec(align(16)) _x64XMM_andAbsMaskPair[2];
uint32 __declspec(align(16)) _x64XMM_andFloatAbsMaskBottom[4];
uint64 __declspec(align(16)) _x64XMM_singleWordMask[2];
double __declspec(align(16)) _x64XMM_constDouble1_1[2];
double __declspec(align(16)) _x64XMM_constDouble0_0[2];
float __declspec(align(16)) _x64XMM_constFloat0_0[2];
float __declspec(align(16)) _x64XMM_constFloat1_1[2];
float __declspec(align(16)) _x64XMM_constFloatMin[2];
uint32 __declspec(align(16)) _x64XMM_flushDenormalMask1[4];
uint32 __declspec(align(16)) _x64XMM_flushDenormalMaskResetSignBits[4];
alignas(16) uint64 _x64XMM_xorNegateMaskBottom[2];
alignas(16) uint64 _x64XMM_xorNegateMaskPair[2];
alignas(16) uint64 _x64XMM_xorNOTMask[2];
alignas(16) uint64 _x64XMM_andAbsMaskBottom[2];
alignas(16) uint64 _x64XMM_andAbsMaskPair[2];
alignas(16) uint32 _x64XMM_andFloatAbsMaskBottom[4];
alignas(16) uint64 _x64XMM_singleWordMask[2];
alignas(16) double _x64XMM_constDouble1_1[2];
alignas(16) double _x64XMM_constDouble0_0[2];
alignas(16) float _x64XMM_constFloat0_0[2];
alignas(16) float _x64XMM_constFloat1_1[2];
alignas(16) float _x64XMM_constFloatMin[2];
alignas(16) uint32 _x64XMM_flushDenormalMask1[4];
alignas(16) uint32 _x64XMM_flushDenormalMaskResetSignBits[4];
// PSQ load/store scale tables
double _psq_ld_scale_ps0_ps1[64 * 2];
double _psq_ld_scale_ps0_1[64 * 2];
@@ -396,4 +396,4 @@ extern bool hasAVXSupport;
void PPCRecompiler_recompileIfUnvisited(uint32 enterAddress);
void PPCRecompiler_attemptEnter(struct PPCInterpreter_t* hCPU, uint32 enterAddress);
void PPCRecompiler_attemptEnterWithoutRecompile(struct PPCInterpreter_t* hCPU, uint32 enterAddress);
void PPCRecompiler_attemptEnterWithoutRecompile(struct PPCInterpreter_t* hCPU, uint32 enterAddress);
@@ -2221,7 +2221,10 @@ void PPCRecompilerX64Gen_imlInstruction_r_name(PPCRecFunction_t* PPCRecFunction,
else if (sprIndex == SPR_XER)
x64Emit_mov_reg64_mem32(x64GenContext, tempToRealRegister(imlInstruction->op_r_name.registerIndex), REG_RSP, offsetof(PPCInterpreter_t, spr.XER));
else if (sprIndex >= SPR_UGQR0 && sprIndex <= SPR_UGQR7)
x64Emit_mov_reg64_mem32(x64GenContext, tempToRealRegister(imlInstruction->op_r_name.registerIndex), REG_RSP, offsetof(PPCInterpreter_t, spr.UGQR[sprIndex - SPR_UGQR0]));
{
sint32 memOffset = offsetof(PPCInterpreter_t, spr.UGQR) + sizeof(PPCInterpreter_t::spr.UGQR[0]) * (sprIndex - SPR_UGQR0);
x64Emit_mov_reg64_mem32(x64GenContext, tempToRealRegister(imlInstruction->op_r_name.registerIndex), REG_RSP, memOffset);
}
else
assert_dbg();
//x64Emit_mov_reg64_mem32(x64GenContext, tempToRealRegister(imlInstruction->op_r_name.registerIndex), REG_RSP, offsetof(PPCInterpreter_t, spr)+sizeof(uint32)*(name-PPCREC_NAME_SPR0));
@@ -2247,7 +2250,10 @@ void PPCRecompilerX64Gen_imlInstruction_name_r(PPCRecFunction_t* PPCRecFunction,
else if (sprIndex == SPR_XER)
x64Emit_mov_mem32_reg64(x64GenContext, REG_RSP, offsetof(PPCInterpreter_t, spr.XER), tempToRealRegister(imlInstruction->op_r_name.registerIndex));
else if (sprIndex >= SPR_UGQR0 && sprIndex <= SPR_UGQR7)
x64Emit_mov_mem32_reg64(x64GenContext, REG_RSP, offsetof(PPCInterpreter_t, spr.UGQR[sprIndex-SPR_UGQR0]), tempToRealRegister(imlInstruction->op_r_name.registerIndex));
{
sint32 memOffset = offsetof(PPCInterpreter_t, spr.UGQR) + sizeof(PPCInterpreter_t::spr.UGQR[0]) * (sprIndex - SPR_UGQR0);
x64Emit_mov_mem32_reg64(x64GenContext, REG_RSP, memOffset, tempToRealRegister(imlInstruction->op_r_name.registerIndex));
}
else
assert_dbg();
}
+13 -13
View File
@@ -80,31 +80,31 @@ void LatteShader_calculateFSKey(LatteFetchShader* fetchShader)
{
LatteParsedFetchShaderAttribute_t* attrib = group.attrib + f;
key += (uint64)attrib->endianSwap;
key = _rotl64(key, 3);
key = std::rotl(key, 3);
key += (uint64)attrib->nfa;
key = _rotl64(key, 3);
key = std::rotl(key, 3);
key += (uint64)(attrib->isSigned?1:0);
key = _rotl64(key, 1);
key = std::rotl(key, 1);
key += (uint64)attrib->format;
key = _rotl64(key, 7);
key = std::rotl(key, 7);
key += (uint64)attrib->fetchType;
key = _rotl64(key, 8);
key = std::rotl(key, 8);
key += (uint64)attrib->ds[0];
key = _rotl64(key, 2);
key = std::rotl(key, 2);
key += (uint64)attrib->ds[1];
key = _rotl64(key, 2);
key = std::rotl(key, 2);
key += (uint64)attrib->ds[2];
key = _rotl64(key, 2);
key = std::rotl(key, 2);
key += (uint64)attrib->ds[3];
key = _rotl64(key, 2);
key = std::rotl(key, 2);
key += (uint64)(attrib->aluDivisor+1);
key = _rotl64(key, 2);
key = std::rotl(key, 2);
key += (uint64)attrib->attributeBufferIndex;
key = _rotl64(key, 8);
key = std::rotl(key, 8);
key += (uint64)attrib->semanticId;
key = _rotl64(key, 8);
key = std::rotl(key, 8);
key += (uint64)(attrib->offset & 3);
key = _rotl64(key, 2);
key = std::rotl(key, 2);
}
}
// todo - also hash invalid buffer groups?
+1 -1
View File
@@ -743,7 +743,7 @@ private:
//h ^= *memU64;
//memU64++;
h = _rotr64(h, 7);
h = std::rotr(h, 7);
h += (*memU64 + (uint64)i);
memU64++;
}
+1 -1
View File
@@ -518,7 +518,7 @@ void LatteOverlay_translateScreenPosition(ScreenPosition pos, const Vector2f& wi
direction = -1;
break;
default:
__assume(false);
UNREACHABLE;
}
}
+3 -3
View File
@@ -158,15 +158,15 @@ void LatteMRT::ApplyCurrentState()
if (colorView)
{
key += ((uint64)colorView);
key = _rotl64(key, 5);
key = std::rotl(key, 5);
fboLookupView = colorView;
}
key = _rotl64(key, 7);
key = std::rotl(key, 7);
}
if (sLatteCurrentRendertargets.depthBuffer.view)
{
key += ((uint64)sLatteCurrentRendertargets.depthBuffer.view);
key = _rotl64(key, 5);
key = std::rotl(key, 5);
key += (sLatteCurrentRendertargets.depthBuffer.hasStencil);
if (fboLookupView == NULL)
{
+5 -5
View File
@@ -225,8 +225,8 @@ void LatteShader_UpdatePSInputs(uint32* contextRegisters)
// parameter gen
if (spi0_paramGen != 0)
{
key += _rotr64(spi0_paramGen, 7);
key += _rotr64(spi0_paramGenAddr, 3);
key += std::rotr<uint64>(spi0_paramGen, 7);
key += std::rotr<uint64>(spi0_paramGenAddr, 3);
_activePSImportTable.paramGen = spi0_paramGen;
_activePSImportTable.paramGenGPR = spi0_paramGenAddr;
}
@@ -263,7 +263,7 @@ void LatteShader_UpdatePSInputs(uint32* contextRegisters)
cemu_assert_debug(psSemanticId != 0xFF);
key += (uint64)psInputControl;
key = _rotl64(key, 7);
key = std::rotl(key, 7);
if (spi0_positionEnable && f == spi0_positionAddr)
{
_activePSImportTable.import[f].semanticId = LATTE_ANALYZER_IMPORT_INDEX_SPIPOSITION;
@@ -546,7 +546,7 @@ uint64 LatteSHRC_CalcVSAuxHash(LatteDecompilerShader* vertexShader, uint32* cont
if(!vertexShader->streamoutBufferWriteMask2[i])
continue;
uint32 bufferStride = contextRegisters[mmVGT_STRMOUT_VTX_STRIDE_0 + i * 4];
auxHash = _rotl64(auxHash, 7);
auxHash = std::rotl(auxHash, 7);
auxHash += (uint64)bufferStride;
}
}
@@ -559,7 +559,7 @@ uint64 LatteSHRC_CalcVSAuxHash(LatteDecompilerShader* vertexShader, uint32* cont
if ((word4 & 0x300) == 0x100)
{
// integer format
auxHashTex = _rotl64(auxHashTex, 7);
auxHashTex = std::rotl(auxHashTex, 7);
auxHashTex += 0x333;
}
}
@@ -124,8 +124,9 @@ struct LatteDecompilerCFInstruction
LatteDecompilerCFInstruction(LatteDecompilerCFInstruction&& mE) = default;
#else
LatteDecompilerCFInstruction(const LatteDecompilerCFInstruction& mE) = default;
LatteDecompilerCFInstruction(const LatteDecompilerCFInstruction&& mE) = default;
LatteDecompilerCFInstruction(LatteDecompilerCFInstruction&& mE) = default;
#endif
LatteDecompilerCFInstruction& operator=(LatteDecompilerCFInstruction&& mE) = default;
};
@@ -1463,7 +1463,7 @@ void OpenGLRenderer::shader_bind(RendererShader* shader)
prevGeometryShaderProgram = program;
break;
default:
__assume(false);
UNREACHABLE;
}
catchOpenGLError();
@@ -1494,7 +1494,7 @@ void OpenGLRenderer::shader_unbind(RendererShader::ShaderType shaderType)
prevGeometryShaderProgram = -1;
break;
default:
__assume(false);
UNREACHABLE;
}
}
@@ -44,9 +44,9 @@ void OpenGLRenderer::uniformData_update()
for (sint32 f = 0; f < remappedArraySize; f++)
{
uniformDataHash[0] ^= remappedUniformData64[0];
uniformDataHash[0] = _rotl64(uniformDataHash[0], 11);
uniformDataHash[0] = std::rotl(uniformDataHash[0], 11);
uniformDataHash[1] ^= remappedUniformData64[1];
uniformDataHash[1] = _rotl64(uniformDataHash[1], 11);
uniformDataHash[1] = std::rotl(uniformDataHash[1], 11);
remappedUniformData64 += 2;
}
if (shader->uniformDataHash64[0] != uniformDataHash[0] || shader->uniformDataHash64[1] != uniformDataHash[1])
@@ -270,7 +270,7 @@ void RendererShaderGL::ShaderCacheLoading_begin(uint64 cacheTitleId)
usePrecompiled = false;
break;
default:
__assume(false);
UNREACHABLE;
}
forceLog_printf("Using precompiled shaders: %s", usePrecompiled ? "true" : "false");
@@ -1,7 +1,7 @@
#pragma once
#include "Cafe/HW/Latte/Renderer/RendererShader.h"
#include "Common\GLInclude\GLInclude.h"
#include "Common/GLInclude/GLInclude.h"
class RendererShaderGL : public RendererShader
{
@@ -140,8 +140,8 @@ const TBuiltInResource DefaultTBuiltInResource = {
/* .generalVaryingIndexing = */ 1,
/* .generalSamplerIndexing = */ 1,
/* .generalVariableIndexing = */ 1,
/* .generalConstantMatrixVectorIndexing = */ 1,
}
/* .generalConstantMatrixVectorIndexing = */ 1
}
};
class _ShaderVkThreadPool

Some files were not shown because too many files have changed in this diff Show More