diff --git a/src/common/platform_helpers.cpp b/src/common/platform_helpers.cpp index 2775bbe3b..dd232bfd4 100644 --- a/src/common/platform_helpers.cpp +++ b/src/common/platform_helpers.cpp @@ -162,4 +162,13 @@ bool IsWindows11OrLater() return IsWindowsVersionOrLater(kVersionWindows11); } +bool Is64Bit() +{ +#if defined(ANGLE_IS_64_BIT_CPU) + return true; +#else + return false; +#endif // defined(ANGLE_IS_64_BIT_CPU) +} + } // namespace angle diff --git a/src/common/platform_helpers.h b/src/common/platform_helpers.h index 8535360a5..d078be136 100644 --- a/src/common/platform_helpers.h +++ b/src/common/platform_helpers.h @@ -126,6 +126,8 @@ bool IsWindows8OrLater(); bool IsWindows10OrLater(); bool IsWindows11OrLater(); +bool Is64Bit(); + } // namespace angle #endif // COMMON_PLATFORM_HELPERS_H_ diff --git a/src/libANGLE/Program.cpp b/src/libANGLE/Program.cpp index b7fe4f6d4..61e825a9d 100644 --- a/src/libANGLE/Program.cpp +++ b/src/libANGLE/Program.cpp @@ -16,6 +16,7 @@ #include "common/bitset_utils.h" #include "common/debug.h" #include "common/platform.h" +#include "common/platform_helpers.h" #include "common/string_utils.h" #include "common/utilities.h" #include "compiler/translator/blocklayout.h" @@ -3533,6 +3534,8 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi reinterpret_cast(angle::GetANGLEShaderProgramVersion()), angle::GetANGLEShaderProgramVersionHashSize()); + stream.writeBool(angle::Is64Bit()); + stream.writeInt(angle::GetANGLESHVersion()); stream.writeString(context->getRendererString()); @@ -3640,6 +3643,13 @@ angle::Result Program::deserialize(const Context *context, return angle::Result::Stop; } + bool binaryIs64Bit = stream.readBool(); + if (binaryIs64Bit != angle::Is64Bit()) + { + infoLog << "cannot load program binaries across CPU architectures."; + return angle::Result::Stop; + } + int angleSHVersion = stream.readInt(); if (angleSHVersion != angle::GetANGLESHVersion()) { diff --git a/src/tests/test_utils/angle_test_instantiate.cpp b/src/tests/test_utils/angle_test_instantiate.cpp index c6e7e301e..535a1e0d8 100644 --- a/src/tests/test_utils/angle_test_instantiate.cpp +++ b/src/tests/test_utils/angle_test_instantiate.cpp @@ -362,15 +362,6 @@ bool IsQualcomm() IsPixel4XL(); } -bool Is64Bit() -{ -#if defined(ANGLE_IS_64_BIT_CPU) - return true; -#else - return false; -#endif // defined(ANGLE_IS_64_BIT_CPU) -} - bool HasMesa() { #if defined(ANGLE_HAS_MESA) diff --git a/src/tests/test_utils/angle_test_instantiate.h b/src/tests/test_utils/angle_test_instantiate.h index 2314a8612..ca7412d4f 100644 --- a/src/tests/test_utils/angle_test_instantiate.h +++ b/src/tests/test_utils/angle_test_instantiate.h @@ -48,7 +48,6 @@ bool IsQualcomm(); bool IsSwiftshaderDevice(); bool IsIntelUHD630Mobile(); -bool Is64Bit(); bool HasMesa(); bool IsPlatformAvailable(const PlatformParameters ¶m);