mirror of https://github.com/PCSX2/pcsx2.git
GS: MultiISA XXH3
This commit is contained in:
parent
a45f674bc1
commit
4e09f903ca
|
@ -657,6 +657,7 @@ endif()
|
|||
set(pcsx2GSSourcesUnshared
|
||||
GS/GSBlock.cpp
|
||||
GS/GSLocalMemoryMultiISA.cpp
|
||||
GS/GSXXH.cpp
|
||||
GS/Renderers/Common/GSVertexTraceFMM.cpp
|
||||
GS/Renderers/HW/GSRendererHWMultiISA.cpp
|
||||
GS/Renderers/SW/GSDrawScanline.cpp
|
||||
|
@ -739,6 +740,7 @@ set(pcsx2GSHeaders
|
|||
GS/GSVector4i.h
|
||||
GS/GSVector8.h
|
||||
GS/GSVector8i.h
|
||||
GS/GSXXH.h
|
||||
GS/MultiISA.h
|
||||
GS/Renderers/Common/GSDevice.h
|
||||
GS/Renderers/Common/GSDirtyRect.h
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "MultiISA.h"
|
||||
|
||||
#define XXH_STATIC_LINKING_ONLY 1
|
||||
#define XXH_INLINE_ALL 1
|
||||
namespace CURRENT_ISA // XXH doesn't seem to use symbols that allow the compiler to deduplicate, but just in case...
|
||||
{
|
||||
#include <xxhash.h>
|
||||
}
|
||||
|
||||
MULTI_ISA_UNSHARED_IMPL;
|
||||
|
||||
// Include this after xxhash so we can add namespaces (GSXXH is set up to not include xxhash header if it's already been included)
|
||||
#include "GSXXH.h"
|
||||
|
||||
u64 __noinline CURRENT_ISA::GSXXH3_64_Long(const void* data, size_t len)
|
||||
{
|
||||
// XXH marks its function that calls this noinline, and it would be silly to stack noinline functions, so call the internal function directly
|
||||
return XXH3_hashLong_64b_internal(data, len, XXH3_kSecret, sizeof(XXH3_kSecret), XXH3_accumulate_512, XXH3_scrambleAcc);
|
||||
}
|
||||
|
||||
u32 CURRENT_ISA::GSXXH3_64_Update(void* state, const void* data, size_t len)
|
||||
{
|
||||
return XXH3_64bits_update(static_cast<XXH3_state_t*>(state), static_cast<const xxh_u8*>(data), len);
|
||||
}
|
||||
|
||||
u64 CURRENT_ISA::GSXXH3_64_Digest(void* state)
|
||||
{
|
||||
return XXH3_64bits_digest(static_cast<XXH3_state_t*>(state));
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "MultiISA.h"
|
||||
|
||||
#ifndef XXH_versionNumber
|
||||
#define XXH_STATIC_LINKING_ONLY 1
|
||||
#define XXH_INLINE_ALL 1
|
||||
#include <xxhash.h>
|
||||
#endif
|
||||
|
||||
MULTI_ISA_DEF(u64 GSXXH3_64_Long(const void* data, size_t len);)
|
||||
MULTI_ISA_DEF(u32 GSXXH3_64_Update(void* state, const void* data, size_t len);)
|
||||
MULTI_ISA_DEF(u64 GSXXH3_64_Digest(void* state);)
|
||||
|
||||
static inline u64 __forceinline GSXXH3_64bits(const void* data, size_t len)
|
||||
{
|
||||
// XXH3 has optimized functions for small inputs and they aren't vectorized
|
||||
if (len <= XXH3_MIDSIZE_MAX)
|
||||
return XXH3_64bits(data, len);
|
||||
return MultiISAFunctions::GSXXH3_64_Long(data, len);
|
||||
}
|
||||
|
||||
static inline XXH_errorcode __forceinline GSXXH3_64bits_update(XXH3_state_t* state, const void* input, size_t len)
|
||||
{
|
||||
// XXH3 update has no optimized functions for small inputs
|
||||
return static_cast<XXH_errorcode>(MultiISAFunctions::GSXXH3_64_Update(static_cast<void*>(state), input, len));
|
||||
}
|
||||
|
||||
static inline u64 __forceinline GSXXH3_64bits_digest(XXH3_state_t* state)
|
||||
{
|
||||
return MultiISAFunctions::GSXXH3_64_Digest(static_cast<void*>(state));
|
||||
}
|
|
@ -90,3 +90,11 @@ static ProcessorFeatures getProcessorFeatures()
|
|||
}
|
||||
|
||||
const ProcessorFeatures g_cpu = getProcessorFeatures();
|
||||
|
||||
// Keep init order by defining these here
|
||||
|
||||
#include "GSXXH.h"
|
||||
|
||||
u64 (&MultiISAFunctions::GSXXH3_64_Long)(const void* data, size_t len) = MULTI_ISA_SELECT(GSXXH3_64_Long);
|
||||
u32 (&MultiISAFunctions::GSXXH3_64_Update)(void* state, const void* data, size_t len) = MULTI_ISA_SELECT(GSXXH3_64_Update);
|
||||
u64 (&MultiISAFunctions::GSXXH3_64_Digest)(void* state) = MULTI_ISA_SELECT(GSXXH3_64_Digest);
|
||||
|
|
|
@ -86,3 +86,10 @@ extern const ProcessorFeatures g_cpu;
|
|||
|
||||
class GSRenderer;
|
||||
MULTI_ISA_DEF(GSRenderer* makeGSRendererSW(int threads);)
|
||||
|
||||
namespace MultiISAFunctions
|
||||
{
|
||||
extern u64 (&GSXXH3_64_Long)(const void* data, size_t len);
|
||||
extern u32 (&GSXXH3_64_Update)(void* state, const void* data, size_t len);
|
||||
extern u64 (&GSXXH3_64_Digest)(void* state);
|
||||
}
|
||||
|
|
|
@ -20,15 +20,10 @@
|
|||
#include "GS/GSGL.h"
|
||||
#include "GS/GSIntrin.h"
|
||||
#include "GS/GSUtil.h"
|
||||
#include "GS/GSXXH.h"
|
||||
#include "common/Align.h"
|
||||
#include "common/HashCombine.h"
|
||||
|
||||
//#define DISABLE_HW_TEXTURE_CACHE 1
|
||||
|
||||
#define XXH_STATIC_LINKING_ONLY 1
|
||||
#define XXH_INLINE_ALL 1
|
||||
#include "xxhash.h"
|
||||
|
||||
u8* GSTextureCache::m_temp;
|
||||
|
||||
GSTextureCache::GSTextureCache()
|
||||
|
@ -3239,8 +3234,8 @@ u64 GSTextureCache::PaletteKeyHash::operator()(const PaletteKey& key) const
|
|||
{
|
||||
ASSERT(key.pal == 16 || key.pal == 256);
|
||||
return key.pal == 16 ?
|
||||
XXH3_64bits(key.clut, sizeof(key.clut[0]) * 16) :
|
||||
XXH3_64bits(key.clut, sizeof(key.clut[0]) * 256);
|
||||
GSXXH3_64bits(key.clut, sizeof(key.clut[0]) * 16) :
|
||||
GSXXH3_64bits(key.clut, sizeof(key.clut[0]) * 256);
|
||||
};
|
||||
|
||||
// GSTextureCache::PaletteKeyEqual
|
||||
|
@ -3391,17 +3386,17 @@ __fi static void BlockHashReset(BlockHashState& st)
|
|||
|
||||
__fi static void BlockHashAccumulate(BlockHashState& st, const u8* bp)
|
||||
{
|
||||
XXH3_64bits_update(&st, bp, BLOCK_SIZE);
|
||||
GSXXH3_64bits_update(&st, bp, BLOCK_SIZE);
|
||||
}
|
||||
|
||||
__fi static void BlockHashAccumulate(BlockHashState& st, const u8* bp, u32 size)
|
||||
{
|
||||
XXH3_64bits_update(&st, bp, size);
|
||||
GSXXH3_64bits_update(&st, bp, size);
|
||||
}
|
||||
|
||||
__fi static GSTextureCache::HashType FinishBlockHash(BlockHashState& st)
|
||||
{
|
||||
return XXH3_64bits_digest(&st);
|
||||
return GSXXH3_64bits_digest(&st);
|
||||
}
|
||||
|
||||
static void HashTextureLevel(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, BlockHashState& hash_st, u8* temp)
|
||||
|
|
|
@ -474,6 +474,7 @@
|
|||
<ClCompile Include="GS\Renderers\SW\GSTextureSW.cpp" />
|
||||
<ClCompile Include="GS\GSUtil.cpp" />
|
||||
<ClCompile Include="GS\GSVector.cpp" />
|
||||
<ClCompile Include="GS\GSXXH.cpp" />
|
||||
<ClCompile Include="GS\Renderers\Common\GSVertexList.cpp" />
|
||||
<ClCompile Include="GS\Renderers\SW\GSVertexSW.cpp" />
|
||||
<ClCompile Include="GS\Renderers\Common\GSVertexTrace.cpp" />
|
||||
|
@ -873,6 +874,7 @@
|
|||
<ClInclude Include="GS\GSVector4.h" />
|
||||
<ClInclude Include="GS\GSVector8i.h" />
|
||||
<ClInclude Include="GS\GSVector8.h" />
|
||||
<ClInclude Include="GS\GSXXH.h" />
|
||||
<ClInclude Include="GS\Renderers\Common\GSVertex.h" />
|
||||
<ClInclude Include="GS\Renderers\HW\GSVertexHW.h" />
|
||||
<ClInclude Include="GS\Renderers\Common\GSVertexList.h" />
|
||||
|
|
|
@ -1514,6 +1514,9 @@
|
|||
<ClCompile Include="GS\GSVector.cpp">
|
||||
<Filter>System\Ps2\GS</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GS\GSXXH.cpp">
|
||||
<Filter>System\Ps2\GS</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GS\GSPng.cpp">
|
||||
<Filter>System\Ps2\GS</Filter>
|
||||
</ClCompile>
|
||||
|
@ -2719,6 +2722,9 @@
|
|||
<ClInclude Include="GS\GSVector8.h">
|
||||
<Filter>System\Ps2\GS</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GS\GSXXH.h">
|
||||
<Filter>System\Ps2\GS</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GS\config.h">
|
||||
<Filter>System\Ps2\GS</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -331,6 +331,7 @@
|
|||
<ClCompile Include="GS\Renderers\SW\GSVertexSW.cpp" />
|
||||
<ClCompile Include="GS\Renderers\Common\GSVertexTrace.cpp" />
|
||||
<ClCompile Include="GS\Renderers\Common\GSVertexTraceFMM.cpp" />
|
||||
<ClCompile Include="GS\GSXXH.cpp" />
|
||||
<ClCompile Include="GS\MultiISA.cpp" />
|
||||
<ClCompile Include="SPU2\Windows\SndOut_XAudio2.cpp" />
|
||||
<ClCompile Include="USB\USBNull.cpp" />
|
||||
|
@ -655,6 +656,7 @@
|
|||
<ClInclude Include="GS\Renderers\Common\GSVertexList.h" />
|
||||
<ClInclude Include="GS\Renderers\SW\GSVertexSW.h" />
|
||||
<ClInclude Include="GS\Renderers\Common\GSVertexTrace.h" />
|
||||
<ClInclude Include="GS\GSXXH.h" />
|
||||
<ClInclude Include="GS\MultiISA.h" />
|
||||
<ClInclude Include="GS\resource.h" />
|
||||
<ClInclude Include="IPU\IPUdma.h" />
|
||||
|
|
|
@ -1016,6 +1016,9 @@
|
|||
<ClCompile Include="GS\GSVector.cpp">
|
||||
<Filter>System\Ps2\GS</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GS\GSXXH.cpp">
|
||||
<Filter>System\Ps2\GS</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="GS\MultiISA.cpp">
|
||||
<Filter>System\Ps2\GS</Filter>
|
||||
</ClCompile>
|
||||
|
@ -1883,6 +1886,9 @@
|
|||
<ClInclude Include="GS\GSVector8.h">
|
||||
<Filter>System\Ps2\GS</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GS\GSXXH.h">
|
||||
<Filter>System\Ps2\GS</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="GS\MultiISA.h">
|
||||
<Filter>System\Ps2\GS</Filter>
|
||||
</ClInclude>
|
||||
|
|
Loading…
Reference in New Issue