mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-03 14:09:33 +03:00
Validate program binaries are the same CPU bit-ness.
ANGLE's program binary serialize/deserialize logic uses size_t and other non-fixed sized integer types. This can cause crashes if the CPU architecture changes between saving and loading of binaries. Bug: chromium:1470074 Bug: angleproject:8223 Change-Id: Ib2529e0e6e66e28a184aa1ec94075e343e1f1d5e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4752265 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
committed by
Angle LUCI CQ
parent
e7eba55905
commit
f4e901b447
@@ -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
|
||||
|
||||
@@ -126,6 +126,8 @@ bool IsWindows8OrLater();
|
||||
bool IsWindows10OrLater();
|
||||
bool IsWindows11OrLater();
|
||||
|
||||
bool Is64Bit();
|
||||
|
||||
} // namespace angle
|
||||
|
||||
#endif // COMMON_PLATFORM_HELPERS_H_
|
||||
|
||||
@@ -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<const unsigned char *>(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<int>();
|
||||
if (angleSHVersion != angle::GetANGLESHVersion())
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -48,7 +48,6 @@ bool IsQualcomm();
|
||||
bool IsSwiftshaderDevice();
|
||||
bool IsIntelUHD630Mobile();
|
||||
|
||||
bool Is64Bit();
|
||||
bool HasMesa();
|
||||
|
||||
bool IsPlatformAvailable(const PlatformParameters ¶m);
|
||||
|
||||
Reference in New Issue
Block a user