Fix shader cache invalidation caused by struct padding memcmp(Fixes #4645) (#4704)

* Fix shader cache invalidation caused by struct padding memcmp

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Harshalj2108 <harshalj.2608@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Harshal Joshi
2026-07-14 12:27:46 +05:30
committed by GitHub
parent 16b708df85
commit 6d37f61a4d
2 changed files with 13 additions and 1 deletions

View File

@@ -52,6 +52,8 @@ struct Profile {
bool needs_unorm_fixup{};
bool needs_clip_distance_emulation{};
bool supports_shader_stencil_export{};
bool operator==(const Profile&) const = default;
};
} // namespace Shader

View File

@@ -313,7 +313,17 @@ void PipelineCache::WarmUp() {
std::move(profile_data));
return;
}
if (std::memcmp(profile_data.data(), &profile, sizeof(profile)) != 0) {
if (profile_data.size() != sizeof(Shader::Profile)) {
LOG_WARNING(Render,
"Pipeline cache profile has unexpected size ({} != {}). Ignoring the cache",
profile_data.size(), sizeof(Shader::Profile));
Storage::DataBase::Instance().Close();
return;
}
Shader::Profile cached_profile{};
std::memcpy(&cached_profile, profile_data.data(), sizeof(cached_profile));
if (cached_profile != profile) {
LOG_WARNING(Render,
"Pipeline cache isn't compatible with current system. Ignoring the cache");
Storage::DataBase::Instance().Close();