Skip to content

Commit

Permalink
feat: 引入 rapidhash,不再使用 wyhash
Browse files Browse the repository at this point in the history
这会使效果缓存失效
  • Loading branch information
Blinue committed Jan 2, 2025
1 parent ca68838 commit 1424ddc
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 106 deletions.
4 changes: 2 additions & 2 deletions src/Magpie.Core/EffectCacheManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "Logger.h"
#include "CommonSharedConstants.h"
#include <d3dcompiler.h>
#include "FastHasher.h"
#include <rapidhash.h>
#include "YasHelper.h"

namespace yas::detail {
Expand Down Expand Up @@ -239,7 +239,7 @@ void EffectCacheManager::Save(std::wstring_view effectName, uint32_t flags, std:
}

static std::wstring HexHash(std::span<const BYTE> data) {
uint64_t hashBytes = FastHasher::HashData(data);
uint64_t hashBytes = rapidhash(data.data(), data.size());

static wchar_t oct2Hex[16] = {
L'0',L'1',L'2',L'3',L'4',L'5',L'6',L'7',
Expand Down
3 changes: 1 addition & 2 deletions src/Magpie.Core/EffectCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,6 @@ static uint32_t GeneratePassSource(
std::string_view cbHlsl,
const SmallVector<std::string_view>& commonBlocks,
std::string_view passBlock,
const phmap::flat_hash_map<std::wstring, float>* inlineParams,
std::string& result,
std::vector<std::pair<std::string, std::string>>& macros
) {
Expand Down Expand Up @@ -1392,7 +1391,7 @@ static uint32_t CompilePasses(
Win32Helper::RunParallel([&](uint32_t id) {
std::string source;
std::vector<std::pair<std::string, std::string>> macros;
if (GeneratePassSource(desc, id + 1, cbHlsl, commonBlocks, passBlocks[id], inlineParams, source, macros)) {
if (GeneratePassSource(desc, id + 1, cbHlsl, commonBlocks, passBlocks[id], source, macros)) {
Logger::Get().Error(fmt::format("生成 Pass{} 失败", id + 1));
return;
}
Expand Down
89 changes: 0 additions & 89 deletions src/Magpie.Core/FastHasher.cpp

This file was deleted.

9 changes: 0 additions & 9 deletions src/Magpie.Core/FastHasher.h

This file was deleted.

2 changes: 0 additions & 2 deletions src/Magpie.Core/Magpie.Core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
<ClInclude Include="EffectHelper.h" />
<ClInclude Include="EffectsProfiler.h" />
<ClInclude Include="ExclModeHelper.h" />
<ClInclude Include="FastHasher.h" />
<ClInclude Include="FrameSourceBase.h" />
<ClInclude Include="GDIFrameSource.h" />
<ClInclude Include="GraphicsCaptureFrameSource.h" />
Expand Down Expand Up @@ -125,7 +124,6 @@
<ClCompile Include="StepTimer.cpp" />
<ClCompile Include="StrHelper.cpp" />
<ClCompile Include="TextureLoader.cpp" />
<ClCompile Include="FastHasher.cpp" />
<ClCompile Include="Version.cpp" />
<ClCompile Include="Win32Helper.cpp" />
<ClCompile Include="WindowHelper.cpp" />
Expand Down
2 changes: 0 additions & 2 deletions src/Magpie.Core/Magpie.Core.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
<ClInclude Include="include\WindowBase.h">
<Filter>Include</Filter>
</ClInclude>
<ClInclude Include="FastHasher.h" />
<ClInclude Include="StepTimer.h" />
<ClInclude Include="include\ScalingError.h">
<Filter>Include</Filter>
Expand Down Expand Up @@ -184,7 +183,6 @@
<ClCompile Include="ExclModeHelper.cpp" />
<ClCompile Include="ScalingOptions.cpp" />
<ClCompile Include="SmallVector.cpp" />
<ClCompile Include="FastHasher.cpp" />
<ClCompile Include="Version.cpp" />
<ClCompile Include="Logger.cpp" />
<ClCompile Include="Win32Helper.cpp">
Expand Down
1 change: 1 addition & 0 deletions src/Magpie/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ kuba-zip/0.3.2
muparser/2.3.4
yas/7.1.0
imgui/1.91.5
rapidhash/1.0

[generators]
MSBuildDeps
Expand Down

0 comments on commit 1424ddc

Please sign in to comment.