mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-03 14:09:33 +03:00
Reject program binaries when the renderer string changes
If the underlying driver changes, reject program binaries from the old versions. The driver is supposed to do this for us (on OpenGL, at least) but this adds some extra protection. Bug: angleproject:4981 Change-Id: Id9486d8e6f9136970c0d7c37d59dea5d43b0a50e Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4685317 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
committed by
Angle LUCI CQ
parent
c0cd00e835
commit
972f810767
@@ -249,6 +249,13 @@ class BinaryOutputStream : angle::NonCopyable
|
||||
write(v.c_str(), v.length());
|
||||
}
|
||||
|
||||
void writeString(const char *v)
|
||||
{
|
||||
size_t len = strlen(v);
|
||||
writeInt(len);
|
||||
write(v, len);
|
||||
}
|
||||
|
||||
void writeBytes(const unsigned char *bytes, size_t count) { write(bytes, count); }
|
||||
|
||||
void writeBool(bool value)
|
||||
|
||||
@@ -670,6 +670,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
|
||||
|
||||
bool isWebGL() const { return mState.isWebGL(); }
|
||||
bool isWebGL1() const { return mState.isWebGL1(); }
|
||||
const char *getRendererString() const { return mRendererString; }
|
||||
|
||||
bool isValidBufferBinding(BufferBinding binding) const { return mValidBufferBindings[binding]; }
|
||||
|
||||
|
||||
@@ -3522,6 +3522,8 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi
|
||||
|
||||
stream.writeInt(angle::GetANGLESHVersion());
|
||||
|
||||
stream.writeString(context->getRendererString());
|
||||
|
||||
// nullptr context is supported when computing binary length.
|
||||
if (context)
|
||||
{
|
||||
@@ -3632,6 +3634,13 @@ angle::Result Program::deserialize(const Context *context,
|
||||
return angle::Result::Stop;
|
||||
}
|
||||
|
||||
std::string rendererString = stream.readString();
|
||||
if (rendererString != context->getRendererString())
|
||||
{
|
||||
infoLog << "Cannot load program binary due to changed renderer string.";
|
||||
return angle::Result::Stop;
|
||||
}
|
||||
|
||||
int majorVersion = stream.readInt<int>();
|
||||
int minorVersion = stream.readInt<int>();
|
||||
if (majorVersion != context->getClientMajorVersion() ||
|
||||
|
||||
Reference in New Issue
Block a user