Commit 27906e9c by Jonah Ryan-Davis Committed by Commit Bot

GL: Cache the results of glGetString

To reduce the amount of queries to the driver, we can cache the results of glGetString. On Mac, we need to invalidate this cache on GPU switch. Bug: chromium:1173672 Change-Id: I039172068aec35034a87881a8804f52c080ce4ce Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2676882 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent a8a2a71b
...@@ -22,7 +22,9 @@ ...@@ -22,7 +22,9 @@
namespace rx namespace rx
{ {
DisplayGL::DisplayGL(const egl::DisplayState &state) : DisplayImpl(state) {} DisplayGL::DisplayGL(const egl::DisplayState &state)
: DisplayImpl(state), mRendererDescription(""), mVendorString(""), mVersionString("")
{}
DisplayGL::~DisplayGL() {} DisplayGL::~DisplayGL() {}
...@@ -102,17 +104,36 @@ egl::Error DisplayGL::makeCurrentSurfaceless(gl::Context *context) ...@@ -102,17 +104,36 @@ egl::Error DisplayGL::makeCurrentSurfaceless(gl::Context *context)
std::string DisplayGL::getRendererDescription() std::string DisplayGL::getRendererDescription()
{ {
return GetRendererString(getRenderer()->getFunctions()); if (mRendererDescription.empty())
{
mRendererDescription = GetRendererString(getRenderer()->getFunctions());
}
return mRendererDescription;
} }
std::string DisplayGL::getVendorString() std::string DisplayGL::getVendorString()
{ {
return GetVendorString(getRenderer()->getFunctions()); if (mVendorString.empty())
{
mVendorString = GetVendorString(getRenderer()->getFunctions());
}
return mVendorString;
} }
std::string DisplayGL::getVersionString() std::string DisplayGL::getVersionString()
{ {
return GetVersionString(getRenderer()->getFunctions()); if (mVersionString.empty())
{
mVersionString = GetVersionString(getRenderer()->getFunctions());
}
return mVersionString;
}
void DisplayGL::resetCachedGLStrings()
{
mRendererDescription = "";
mVendorString = "";
mVersionString = "";
} }
} // namespace rx } // namespace rx
...@@ -56,11 +56,17 @@ class DisplayGL : public DisplayImpl ...@@ -56,11 +56,17 @@ class DisplayGL : public DisplayImpl
std::string getVendorString() override; std::string getVendorString() override;
std::string getVersionString() override; std::string getVersionString() override;
void resetCachedGLStrings();
protected: protected:
void generateExtensions(egl::DisplayExtensions *outExtensions) const override; void generateExtensions(egl::DisplayExtensions *outExtensions) const override;
private: private:
virtual egl::Error makeCurrentSurfaceless(gl::Context *context); virtual egl::Error makeCurrentSurfaceless(gl::Context *context);
std::string mRendererDescription;
std::string mVendorString;
std::string mVersionString;
}; };
} // namespace rx } // namespace rx
......
...@@ -658,6 +658,8 @@ egl::Error DisplayCGL::handleGPUSwitch() ...@@ -658,6 +658,8 @@ egl::Error DisplayCGL::handleGPUSwitch()
CGLSetCurrentContext(mContext); CGLSetCurrentContext(mContext);
onStateChange(angle::SubjectMessage::SubjectChanged); onStateChange(angle::SubjectMessage::SubjectChanged);
mCurrentGPUID = gpuID; mCurrentGPUID = gpuID;
// Dirty the cache of the GL strings because we are on a new driver
resetCachedGLStrings();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment