Skip to content

Commit

Permalink
Merge branch 'smem_cache'
Browse files Browse the repository at this point in the history
  • Loading branch information
ePi5131 committed Jun 26, 2023
2 parents 988914c + 63d0960 commit ca8d3a5
Show file tree
Hide file tree
Showing 11 changed files with 342 additions and 184 deletions.
3 changes: 3 additions & 0 deletions patch.aul.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ https://scrapbox.io/ePi5131/patch.aul
・シーン画像生成に時間がかかった時にキャッシュを作成する機能の追加
・スクリプト並び替え管理プラグインとの競合を解消
・ファイル名が同じプラグインファイルが複数フォルダに存在するときに警告を出す
・一部キャッシュは共有メモリ(システムの設定のキャッシュサイズの部分)を使用するように変更

追加
・コンソールの表示
Expand Down Expand Up @@ -227,6 +228,7 @@ https://scrapbox.io/ePi5131/patch.aul
"scene_cache" : boolean, ; シーン画像生成に時間がかかった時にキャッシュを作成する機能の追加 (既定値: true)
"patch_script_sort" : boolean, ; スクリプト並び替え管理プラグインとの競合を解消 (既定値: true)
"warning_duplicate" : boolean, ; ファイル名が同じプラグインファイルが複数フォルダに存在するときに警告を出す (既定値: true)
"shared_cache" : boolean, ; 一部キャッシュは共有メモリ(システムの設定のキャッシュサイズの部分)を使用するように変更 (既定値: true)
"undo" : boolean, ; 元に戻す 関連のバグ修正 (既定値: true)
"undo.redo" : boolean, ; やり直す を追加 (既定値: true)
"console" : boolean, ; コンソール (既定値: true)
Expand Down Expand Up @@ -479,3 +481,4 @@ Lua追加要素詳細
読み込もうとしたファイルパスが長くて失敗するときにメッセージを出す/エラーが発生するのを修正
ドロップ処理で最終的に何も行われなかったときにメッセージを出力する
ファイル名が同じプラグインファイルが複数フォルダに存在するときに警告を出す
一部キャッシュは共有メモリ(システムの設定のキャッシュサイズの部分)を使用するように変更
6 changes: 6 additions & 0 deletions patch/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ class Config2 {
#ifdef PATCH_SWITCH_WARNING_DUPLICATE_PLUGINS
patch::WarningDuplicate.switch_load(cr);
#endif
#ifdef PATCH_SWITCH_SHARED_CACHE
patch::SharedCache.switch_load(cr);
#endif

#ifdef PATCH_SWITCH_UNDO
patch::undo.switch_load(cr);
Expand Down Expand Up @@ -557,6 +560,9 @@ class Config2 {
#ifdef PATCH_SWITCH_WARNING_DUPLICATE_PLUGINS
patch::WarningDuplicate.switch_store(switch_);
#endif
#ifdef PATCH_SWITCH_SHARED_CACHE
patch::SharedCache.switch_store(switch_);
#endif

#ifdef PATCH_SWITCH_UNDO
patch::undo.switch_store(switch_);
Expand Down
40 changes: 40 additions & 0 deletions patch/hash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,43 @@ struct SHA256 {
inline bool operator==(const SHA256& a, const SHA256& b) {
return std::equal(std::begin(a.data), std::end(a.data), std::begin(b.data));
}

struct FNV1_32 {
uint32_t hash;

static constexpr uint32_t basis = 0x811c9dc5;

constexpr FNV1_32() : hash(basis) {}

constexpr FNV1_32(const uint8_t* ptr, size_t len) : hash(basis) {
const uint8_t* end = ptr + len;
for (; ptr != end; ++ptr) step(*ptr);
}

constexpr void step(uint8_t x) {
// hash *= 0x01000193
hash +=
(hash << 1) +
(hash << 4) +
(hash << 7) +
(hash << 8) +
(hash << 24);
hash ^= x;
}

template<class T>
requires(sizeof(T) > 1 && std::is_trivial_v<T>)
constexpr void step(T x) {
uint8_t ax[sizeof(T)];
std::memcpy(ax, std::addressof(x), sizeof(T));
step(ax[0]);
step(ax[1]);
step(ax[2]);
step(ax[3]);
}

constexpr operator uint32_t() const {
return hash;
}
};

3 changes: 3 additions & 0 deletions patch/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ void init_t::InitAtExeditLoad() {
#ifdef PATCH_SWITCH_SCENE_CACHE
patch::scene_cache.init();
#endif
#ifdef PATCH_SWITCH_SHARED_CACHE
patch::SharedCache.init();
#endif

patch::setting_dialog();

Expand Down
3 changes: 1 addition & 2 deletions patch/macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
#define PATCH_SWITCH_SETTING_NEW_PROJECT setting_newproject
#define PATCH_SWITCH_SCENE_CACHE scenecache
#define PATCH_SWITCH_SCRIPT_SORT_PATCH script_sort_patch
#define PATCH_SWITCH_SHARED_CACHE shared_cache

#define PATCH_SWITCH_UNDO undo
#ifdef PATCH_SWITCH_UNDO
Expand All @@ -163,8 +164,6 @@
#define PATCH_SWITCH_LUA_RANDEX lua_randex
#define PATCH_SWITCH_LUA_PATH lua_path

//#define PATCH_SWITCH_LUA_COPYBUFFER_SMEM lua_copybuffer_smem

#endif // ifdef PATCH_SWITCH_LUA

#define PATCH_SWITCH_FAST fast
Expand Down
3 changes: 3 additions & 0 deletions patch/offset_address.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ namespace OFS {
constexpr i32 get_scene_image = 0x04ce20;
constexpr i32 get_scene_size = 0x02b980;
constexpr i32 scene_has_alpha = 0x02ba00;
constexpr i32 GetCache = 0x00cff0;
constexpr i32 CreateCache = 0x00cd00;
constexpr i32 GetOrCreateCache = 0x04d7d0;

constexpr i32 exedit_edit_open = 0x03ac30;

Expand Down
1 change: 1 addition & 0 deletions patch/patch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@
#include "patch_scene_cache.hpp"
#include "patch_script_sort.hpp"
#include "patch_warning_duplicate_plugins.hpp"
#include "patch_shared_cache.hpp"
2 changes: 2 additions & 0 deletions patch/patch.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<ClInclude Include="patch_setting_dialog_wndproc_override.hpp" />
<ClInclude Include="patch_setting_gui.hpp" />
<ClInclude Include="patch_setting_new_project.hpp" />
<ClInclude Include="patch_shared_cache.hpp" />
<ClInclude Include="patch_splash.hpp" />
<ClInclude Include="patch_susie_load.hpp" />
<ClInclude Include="patch_sysinfo_write.hpp" />
Expand Down Expand Up @@ -165,6 +166,7 @@
<ClCompile Include="patch_setting_dialog_excolorconfig.cpp" />
<ClCompile Include="patch_setting_dialog_wndproc_override.cpp" />
<ClCompile Include="patch_setting_new_project.cpp" />
<ClCompile Include="patch_shared_cache.cpp" />
<ClCompile Include="patch_splash.cpp" />
<ClCompile Include="patch_susie_load.cpp" />
<ClCompile Include="patch_tra_change_drawfilter.cpp" />
Expand Down
182 changes: 0 additions & 182 deletions patch/patch_copybuffer_smem.hpp

This file was deleted.

Loading

0 comments on commit ca8d3a5

Please sign in to comment.