mirror of
https://github.com/blawar/GLideN64.git
synced 2024-06-30 08:24:05 +00:00
Update to XXH3 for CRC_OPT
This commit is contained in:
parent
3f55f30ea2
commit
85a8635952
|
@ -352,7 +352,6 @@ copy /Y "$(OutDir)$(TargetName).*" "$(Mupen64PluginsDir_x64)")</Command>
|
|||
<ClCompile Include="..\..\src\windows\ZilmarAPIImpl_windows.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)'=='Debug_mupenplus' Or '$(Configuration)'=='Release_mupenplus'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\xxHash\xxhash.c" />
|
||||
<ClCompile Include="..\..\src\ZilmarPluginAPI.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)'=='Debug_mupenplus' Or '$(Configuration)'=='Release_mupenplus'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
|
|
|
@ -305,9 +305,6 @@
|
|||
<ClCompile Include="..\..\src\CRC_OPT.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\xxHash\xxhash.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\DebugDump.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
|
|
@ -346,7 +346,6 @@ elseif(CRC_OPT)
|
|||
)
|
||||
list(APPEND GLideN64_SOURCES
|
||||
CRC_OPT.cpp
|
||||
xxHash/xxhash.c
|
||||
)
|
||||
elseif(CRC_NEON)
|
||||
list(REMOVE_ITEM GLideN64_SOURCES
|
||||
|
@ -354,7 +353,6 @@ elseif(CRC_NEON)
|
|||
)
|
||||
list(APPEND GLideN64_SOURCES
|
||||
Neon/CRC_OPT_NEON.cpp
|
||||
xxHash/xxhash.c
|
||||
)
|
||||
endif(CRC_ARMV8)
|
||||
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
void CRC_Init();
|
||||
|
||||
u32 CRC_Calculate_Strict( u32 crc, const void *buffer, u32 count );
|
||||
u32 CRC_Calculate( u32 crc, const void *buffer, u32 count );
|
||||
u32 CRC_CalculatePalette( u32 crc, const void *buffer, u32 count );
|
||||
u64 CRC_Calculate( u64 crc, const void *buffer, u32 count );
|
||||
u64 CRC_CalculatePalette( u64 crc, const void *buffer, u32 count );
|
||||
|
|
|
@ -32,16 +32,17 @@ void CRC_Init()
|
|||
}
|
||||
}
|
||||
|
||||
u32 CRC_Calculate( u32 crc, const void * buffer, u32 count )
|
||||
u64 CRC_Calculate( u64 crc, const void * buffer, u32 count )
|
||||
{
|
||||
u8 *p;
|
||||
u32 orig = crc;
|
||||
u32 crc32 = static_cast<u32>(crc);
|
||||
u32 orig = crc32;
|
||||
|
||||
p = (u8*) buffer;
|
||||
while (count--)
|
||||
crc = (crc >> 8) ^ CRCTable[(crc & 0xFF) ^ *p++];
|
||||
crc32 = (crc32 >> 8) ^ CRCTable[(crc32 & 0xFF) ^ *p++];
|
||||
|
||||
return crc ^ orig;
|
||||
return crc32 ^ orig;
|
||||
}
|
||||
|
||||
u32 CRC_Calculate_Strict( u32 crc, const void * buffer, u32 count )
|
||||
|
@ -49,18 +50,19 @@ u32 CRC_Calculate_Strict( u32 crc, const void * buffer, u32 count )
|
|||
return CRC_Calculate(crc, buffer, count);
|
||||
}
|
||||
|
||||
u32 CRC_CalculatePalette(u32 crc, const void * buffer, u32 count )
|
||||
u64 CRC_CalculatePalette(u64 crc, const void * buffer, u32 count )
|
||||
{
|
||||
u8 *p;
|
||||
u32 orig = crc;
|
||||
u32 crc32 = static_cast<u32>(crc);
|
||||
u32 orig = crc32;
|
||||
|
||||
p = (u8*) buffer;
|
||||
while (count--) {
|
||||
crc = (crc >> 8) ^ CRCTable[(crc & 0xFF) ^ *p++];
|
||||
crc = (crc >> 8) ^ CRCTable[(crc & 0xFF) ^ *p++];
|
||||
crc32 = (crc32 >> 8) ^ CRCTable[(crc32 & 0xFF) ^ *p++];
|
||||
crc32 = (crc32 >> 8) ^ CRCTable[(crc32 & 0xFF) ^ *p++];
|
||||
|
||||
p += 6;
|
||||
}
|
||||
|
||||
return crc ^ orig;
|
||||
return crc32 ^ orig;
|
||||
}
|
||||
|
|
|
@ -17,34 +17,35 @@ void CRC_Init()
|
|||
{
|
||||
}
|
||||
|
||||
u32 CRC_Calculate( u32 crc, const void * buffer, u32 count )
|
||||
u64 CRC_Calculate( u64 crc, const void * buffer, u32 count )
|
||||
{
|
||||
u8 *p;
|
||||
u32 orig = crc;
|
||||
u32 crc32 = static_cast<u32>(crc);
|
||||
u32 orig = crc32;
|
||||
|
||||
p = (u8*) buffer;
|
||||
|
||||
// use eight byte crc intrinsic __crc32d if count is high enough.
|
||||
// __crc32d, __crc32w, __crc32h and __crc32b use polynomial 0x04C11DB7
|
||||
while (count >= 8) {
|
||||
crc = __crc32d(crc, *((u64*)p));
|
||||
crc32 = __crc32d(crc32, *((u64*)p));
|
||||
p += 8;
|
||||
count -= 8;
|
||||
}
|
||||
if (count >= 4) {
|
||||
crc = __crc32w(crc, *((u32*)p));
|
||||
crc32 = __crc32w(crc32, *((u32*)p));
|
||||
p += 4;
|
||||
count -= 4;
|
||||
}
|
||||
if (count >= 2) {
|
||||
crc = __crc32h(crc, *((u16*)p));
|
||||
crc32 = __crc32h(crc32, *((u16*)p));
|
||||
p += 2;
|
||||
count -= 2;
|
||||
}
|
||||
if (count == 1)
|
||||
crc = __crc32b(crc, *p);
|
||||
crc32 = __crc32b(crc32, *p);
|
||||
|
||||
return crc ^ orig;
|
||||
return crc32 ^ orig;
|
||||
}
|
||||
|
||||
u32 CRC_Calculate_Strict( u32 crc, const void * buffer, u32 count )
|
||||
|
@ -52,17 +53,18 @@ u32 CRC_Calculate_Strict( u32 crc, const void * buffer, u32 count )
|
|||
return CRC_Calculate(crc, buffer, count);
|
||||
}
|
||||
|
||||
u32 CRC_CalculatePalette(u32 crc, const void * buffer, u32 count )
|
||||
u64 CRC_CalculatePalette(u64 crc, const void * buffer, u32 count )
|
||||
{
|
||||
u8 *p;
|
||||
u32 orig = crc;
|
||||
u32 crc32 = static_cast<u32>(crc);
|
||||
u32 orig = crc32;
|
||||
|
||||
p = (u8*) buffer;
|
||||
while (count--) {
|
||||
// use two byte intrinsic __crc32h
|
||||
crc = __crc32h(crc, *((u16*)p));
|
||||
crc32 = __crc32h(crc32, *((u16*)p));
|
||||
p += 8;
|
||||
}
|
||||
|
||||
return crc ^ orig;
|
||||
return crc32 ^ orig;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "CRC.h"
|
||||
#include "xxHash/xxhash.h"
|
||||
#include "xxHash/xxh3.h"
|
||||
|
||||
#define CRC32_POLYNOMIAL 0x04C11DB7
|
||||
|
||||
|
@ -45,16 +45,16 @@ u32 CRC_Calculate_Strict( u32 crc, const void * buffer, u32 count )
|
|||
return crc ^ orig;
|
||||
}
|
||||
|
||||
u32 CRC_Calculate( u32 crc, const void * buffer, u32 count )
|
||||
u64 CRC_Calculate( u64 crc, const void * buffer, u32 count )
|
||||
{
|
||||
return XXH32(buffer, count, crc);
|
||||
return XXH3_64bits_withSeed(buffer, count, crc);
|
||||
}
|
||||
|
||||
u32 CRC_CalculatePalette(u32 crc, const void * buffer, u32 count )
|
||||
u64 CRC_CalculatePalette( u64 crc, const void * buffer, u32 count )
|
||||
{
|
||||
u8 *p = (u8*) buffer;
|
||||
while (count--) {
|
||||
crc = XXH32(p, 2, crc);
|
||||
crc = XXH3_64bits_withSeed(p, 2, crc);
|
||||
p += 8;
|
||||
}
|
||||
return crc;
|
||||
|
|
|
@ -109,7 +109,7 @@ void BufferedDrawer::_updateRectBuffer(const graphics::Context::DrawRectParamete
|
|||
return;
|
||||
}
|
||||
|
||||
const u32 crc = CRC_Calculate(0xFFFFFFFF, _params.vertices, dataSize);
|
||||
const u64 crc = CRC_Calculate(UINT64_MAX, _params.vertices, dataSize);
|
||||
auto iter = m_rectBufferOffsets.find(crc);
|
||||
if (iter != m_rectBufferOffsets.end()) {
|
||||
buffer.pos = iter->second;
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace opengl {
|
|||
|
||||
std::vector<Vertex> m_vertices;
|
||||
|
||||
typedef std::unordered_map<u32, u32> BufferOffsets;
|
||||
typedef std::unordered_map<u64, u32> BufferOffsets;
|
||||
BufferOffsets m_rectBufferOffsets;
|
||||
|
||||
static const u32 m_bufMaxSize;
|
||||
|
|
|
@ -119,11 +119,11 @@ u32 ReliableHash32NEON(const void *input, size_t len, u32 seed) {
|
|||
return h32;
|
||||
}
|
||||
|
||||
u32 CRC_Calculate(u32 crc, const void *buffer, u32 count) {
|
||||
u64 CRC_Calculate(u64 crc, const void *buffer, u32 count) {
|
||||
return ReliableHash32NEON(buffer, count, crc);
|
||||
}
|
||||
|
||||
u32 CRC_CalculatePalette(u32 crc, const void *buffer, u32 count) {
|
||||
u64 CRC_CalculatePalette(u64 crc, const void *buffer, u32 count) {
|
||||
u8 *p = (u8 *) buffer;
|
||||
while (count--) {
|
||||
crc = ReliableHash32NEON(p, 2, crc);
|
||||
|
|
|
@ -15,7 +15,7 @@ public:
|
|||
private:
|
||||
CachedTexture * m_pTexture;
|
||||
u8* m_pbuf;
|
||||
u32 m_paletteCRC256;
|
||||
u64 m_paletteCRC256;
|
||||
};
|
||||
|
||||
extern PaletteTexture g_paletteTexture;
|
||||
|
|
|
@ -525,15 +525,15 @@ void TextureCache::_checkCacheSize()
|
|||
}
|
||||
}
|
||||
|
||||
CachedTexture * TextureCache::_addTexture(u32 _crc32)
|
||||
CachedTexture * TextureCache::_addTexture(u64 _crc64)
|
||||
{
|
||||
if (m_curUnpackAlignment == 0)
|
||||
m_curUnpackAlignment = gfxContext.getTextureUnpackAlignment();
|
||||
_checkCacheSize();
|
||||
m_textures.emplace_front(gfxContext.createTexture(textureTarget::TEXTURE_2D));
|
||||
Textures::iterator new_iter = m_textures.begin();
|
||||
new_iter->crc = _crc32;
|
||||
m_lruTextureLocations.insert(std::pair<u32, Textures::iterator>(_crc32, new_iter));
|
||||
new_iter->crc = _crc64;
|
||||
m_lruTextureLocations.insert(std::pair<u64, Textures::iterator>(_crc64, new_iter));
|
||||
return &(*new_iter);
|
||||
}
|
||||
|
||||
|
@ -1241,7 +1241,7 @@ struct TextureParams
|
|||
};
|
||||
|
||||
static
|
||||
u32 _calculateCRC(u32 _t, const TextureParams & _params, u32 _bytes)
|
||||
u64 _calculateCRC(u32 _t, const TextureParams & _params, u32 _bytes)
|
||||
{
|
||||
const bool rgba32 = gSP.textureTile[_t]->size == G_IM_SIZ_32b;
|
||||
if (_bytes == 0) {
|
||||
|
@ -1252,7 +1252,7 @@ u32 _calculateCRC(u32 _t, const TextureParams & _params, u32 _bytes)
|
|||
_bytes >>= 1;
|
||||
const u32 tMemMask = (gDP.otherMode.textureLUT == G_TT_NONE && !rgba32) ? 0x1FF : 0xFF;
|
||||
const u64 *src = (u64*)&TMEM[gSP.textureTile[_t]->tmem & tMemMask];
|
||||
u32 crc = 0xFFFFFFFF;
|
||||
u64 crc = UINT64_MAX;
|
||||
crc = CRC_Calculate(crc, src, _bytes);
|
||||
|
||||
if (rgba32) {
|
||||
|
@ -1350,9 +1350,9 @@ void TextureCache::activateMSDummy(u32 _t)
|
|||
void TextureCache::_updateBackground()
|
||||
{
|
||||
u32 numBytes = gSP.bgImage.width * gSP.bgImage.height << gSP.bgImage.size >> 1;
|
||||
u32 crc;
|
||||
u64 crc;
|
||||
|
||||
crc = CRC_Calculate( 0xFFFFFFFF, &RDRAM[gSP.bgImage.address], numBytes );
|
||||
crc = CRC_Calculate( UINT64_MAX, &RDRAM[gSP.bgImage.address], numBytes );
|
||||
|
||||
if (gDP.otherMode.textureLUT != G_TT_NONE || gSP.bgImage.format == G_IM_FMT_CI) {
|
||||
if (gSP.bgImage.size == G_IM_SIZ_4b)
|
||||
|
@ -1502,7 +1502,7 @@ void TextureCache::update(u32 _t)
|
|||
params.width = sizes.width;
|
||||
params.height = sizes.height;
|
||||
|
||||
const u32 crc = _calculateCRC(_t, params, sizes.bytes);
|
||||
const u64 crc = _calculateCRC(_t, params, sizes.bytes);
|
||||
|
||||
if (current[_t] != nullptr && current[_t]->crc == crc) {
|
||||
activateTexture(_t, current[_t]);
|
||||
|
|
|
@ -18,7 +18,7 @@ struct CachedTexture
|
|||
CachedTexture(graphics::ObjectHandle _name) : name(_name), max_level(0), frameBufferTexture(fbNone), bHDTexture(false) {}
|
||||
|
||||
graphics::ObjectHandle name;
|
||||
u32 crc = 0;
|
||||
u64 crc = 0;
|
||||
// float fulS, fulT;
|
||||
// WORD ulS, ulT, lrS, lrT;
|
||||
float offsetS, offsetT;
|
||||
|
@ -78,7 +78,7 @@ private:
|
|||
TextureCache(const TextureCache &) = delete;
|
||||
|
||||
void _checkCacheSize();
|
||||
CachedTexture * _addTexture(u32 _crc32);
|
||||
CachedTexture * _addTexture(u64 _crc64);
|
||||
void _load(u32 _tile, CachedTexture *_pTexture);
|
||||
bool _loadHiresTexture(u32 _tile, CachedTexture *_pTexture, u64 & _ricecrc);
|
||||
void _loadBackground(CachedTexture *pTexture);
|
||||
|
@ -90,7 +90,7 @@ private:
|
|||
void _getTextureDestData(CachedTexture& tmptex, u32* pDest, graphics::Parameter glInternalFormat, GetTexelFunc GetTexel, u16* pLine);
|
||||
|
||||
typedef std::list<CachedTexture> Textures;
|
||||
typedef std::unordered_map<u32, Textures::iterator> Texture_Locations;
|
||||
typedef std::unordered_map<u64, Textures::iterator> Texture_Locations;
|
||||
typedef std::unordered_map<u32, CachedTexture> FBTextures;
|
||||
Textures m_textures;
|
||||
Texture_Locations m_lruTextureLocations;
|
||||
|
|
|
@ -708,11 +708,11 @@ void gDPLoadTLUT( u32 tile, u32 uls, u32 ult, u32 lrs, u32 lrt )
|
|||
destIdx += 4;
|
||||
}
|
||||
|
||||
gDP.paletteCRC16[pal] = CRC_CalculatePalette(0xFFFFFFFF, &TMEM[256 + (pal << 4)], 16);
|
||||
gDP.paletteCRC16[pal] = CRC_CalculatePalette(UINT64_MAX, &TMEM[256 + (pal << 4)], 16);
|
||||
pal = (pal + 1) & 0x0F;
|
||||
}
|
||||
|
||||
gDP.paletteCRC256 = CRC_Calculate(0xFFFFFFFF, gDP.paletteCRC16, 64);
|
||||
gDP.paletteCRC256 = CRC_Calculate(UINT64_MAX, gDP.paletteCRC16, 64);
|
||||
|
||||
if (TFH.isInited()) {
|
||||
const u16 start = gDP.tiles[tile].tmem - 256; // starting location in the palettes
|
||||
|
|
|
@ -251,8 +251,8 @@ struct gDPInfo
|
|||
u32 changed;
|
||||
|
||||
u16 TexFilterPalette[512];
|
||||
u32 paletteCRC16[16];
|
||||
u32 paletteCRC256;
|
||||
u64 paletteCRC16[16];
|
||||
u64 paletteCRC256;
|
||||
u32 half_1, half_2;
|
||||
|
||||
gDPLoadTileInfo loadInfo[512];
|
||||
|
|
2047
src/xxHash/xxh3.h
2047
src/xxHash/xxh3.h
File diff suppressed because it is too large
Load Diff
1110
src/xxHash/xxhash.c
1110
src/xxHash/xxhash.c
File diff suppressed because it is too large
Load Diff
1792
src/xxHash/xxhash.h
1792
src/xxHash/xxhash.h
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user