Bug 1347679 - Determine ContextProfile from driver and simplify version parsing. - r=daoshengmu

MozReview-Commit-ID: 4mBdJmsxQvD
This commit is contained in:
Jeff Gilbert 2017-03-15 13:14:03 -07:00
Родитель 31f241c6ca
Коммит a0ef36e101
11 изменённых файлов: 105 добавлений и 383 удалений

Просмотреть файл

@ -10,6 +10,8 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <regex>
#include <string>
#include <vector>
#ifdef MOZ_WIDGET_ANDROID
#include <sys/mman.h>
@ -89,6 +91,7 @@ static const char* const sExtensionNames[] = {
"GL_ARB_ES2_compatibility",
"GL_ARB_ES3_compatibility",
"GL_ARB_color_buffer_float",
"GL_ARB_compatibility",
"GL_ARB_copy_buffer",
"GL_ARB_depth_texture",
"GL_ARB_draw_buffers",
@ -195,220 +198,18 @@ static const char* const sExtensionNames[] = {
};
static bool
ParseGLSLVersion(GLContext* gl, uint32_t* out_version)
ParseVersion(const std::string& versionStr, uint32_t* const out_major,
uint32_t* const out_minor)
{
if (gl->fGetError() != LOCAL_GL_NO_ERROR) {
MOZ_ASSERT(false, "An OpenGL error has been triggered before.");
static const std::regex kVersionRegex("([0-9]+)\\.([0-9]+)");
std::smatch match;
if (!std::regex_search(versionStr, match, kVersionRegex))
return false;
}
/**
* OpenGL 2.x, 3.x, 4.x specifications:
* The VERSION and SHADING_LANGUAGE_VERSION strings are laid out as follows:
*
* <version number><space><vendor-specific information>
*
* The version number is either of the form major_number.minor_number or
* major_number.minor_number.release_number, where the numbers all have
* one or more digits.
*
* SHADING_LANGUAGE_VERSION is *almost* identical to VERSION. The
* difference is that the minor version always has two digits and the
* prefix has an additional 'GLSL ES'
*
*
* OpenGL ES 2.0, 3.0 specifications:
* The VERSION string is laid out as follows:
*
* "OpenGL ES N.M vendor-specific information"
*
* The version number is either of the form major_number.minor_number or
* major_number.minor_number.release_number, where the numbers all have
* one or more digits.
*
*
* Note:
* We don't care about release_number.
*/
const char* versionString = (const char*) gl->fGetString(LOCAL_GL_SHADING_LANGUAGE_VERSION);
if (gl->fGetError() != LOCAL_GL_NO_ERROR) {
MOZ_ASSERT(false, "glGetString(GL_SHADING_LANGUAGE_VERSION) has generated an error");
return false;
}
if (!versionString) {
// This happens on the Android emulators. We'll just return 100
*out_version = 100;
return true;
}
const auto fnSkipPrefix = [&versionString](const char* prefix) {
const auto len = strlen(prefix);
if (strncmp(versionString, prefix, len) == 0)
versionString += len;
};
const char kGLESVersionPrefix[] = "OpenGL ES GLSL ES";
fnSkipPrefix(kGLESVersionPrefix);
if (gl->WorkAroundDriverBugs()) {
// Nexus 7 2013 (bug 1234441)
const char kBadGLESVersionPrefix[] = "OpenGL ES GLSL";
fnSkipPrefix(kBadGLESVersionPrefix);
}
const char* itr = versionString;
char* end = nullptr;
auto majorVersion = strtol(itr, &end, 10);
if (!end) {
MOZ_ASSERT(false, "Failed to parse the GL major version number.");
return false;
}
if (*end != '.') {
MOZ_ASSERT(false, "Failed to parse GL's major-minor version number separator.");
return false;
}
// we skip the '.' between the major and the minor version
itr = end + 1;
end = nullptr;
auto minorVersion = strtol(itr, &end, 10);
if (!end) {
MOZ_ASSERT(false, "Failed to parse GL's minor version number.");
return false;
}
if (majorVersion <= 0 || majorVersion >= 100) {
MOZ_ASSERT(false, "Invalid major version.");
return false;
}
if (minorVersion < 0 || minorVersion >= 100) {
MOZ_ASSERT(false, "Invalid minor version.");
return false;
}
*out_version = (uint32_t) majorVersion * 100 + (uint32_t) minorVersion;
return true;
}
static bool
ParseGLVersion(GLContext* gl, uint32_t* out_version)
{
if (gl->fGetError() != LOCAL_GL_NO_ERROR) {
MOZ_ASSERT(false, "An OpenGL error has been triggered before.");
return false;
}
/**
* B2G emulator bug work around: The emulator implements OpenGL ES 2.0 on
* OpenGL 3.2. The bug is that GetIntegerv(LOCAL_GL_{MAJOR,MINOR}_VERSION)
* returns OpenGL 3.2 instead of generating an error.
*/
if (!gl->IsGLES()) {
/**
* OpenGL 3.1 and OpenGL ES 3.0 both introduce GL_{MAJOR,MINOR}_VERSION
* with GetIntegerv. So we first try those constants even though we
* might not have an OpenGL context supporting them, as this is a
* better way than parsing GL_VERSION.
*/
GLint majorVersion = 0;
GLint minorVersion = 0;
const bool ok = (gl->GetPotentialInteger(LOCAL_GL_MAJOR_VERSION,
&majorVersion) &&
gl->GetPotentialInteger(LOCAL_GL_MINOR_VERSION,
&minorVersion));
// If it's not an OpenGL (ES) 3.0 context, we will have an error
if (ok &&
majorVersion > 0 &&
minorVersion >= 0)
{
*out_version = majorVersion * 100 + minorVersion * 10;
return true;
}
}
/**
* We were not able to use GL_{MAJOR,MINOR}_VERSION, so we parse
* GL_VERSION.
*
*
* OpenGL 2.x, 3.x, 4.x specifications:
* The VERSION and SHADING_LANGUAGE_VERSION strings are laid out as follows:
*
* <version number><space><vendor-specific information>
*
* The version number is either of the form major_number.minor_number or
* major_number.minor_number.release_number, where the numbers all have
* one or more digits.
*
*
* OpenGL ES 2.0, 3.0 specifications:
* The VERSION string is laid out as follows:
*
* "OpenGL ES N.M vendor-specific information"
*
* The version number is either of the form major_number.minor_number or
* major_number.minor_number.release_number, where the numbers all have
* one or more digits.
*
*
* Note:
* We don't care about release_number.
*/
const char* versionString = (const char*)gl->fGetString(LOCAL_GL_VERSION);
if (gl->fGetError() != LOCAL_GL_NO_ERROR) {
MOZ_ASSERT(false, "glGetString(GL_VERSION) has generated an error");
return false;
} else if (!versionString) {
MOZ_ASSERT(false, "glGetString(GL_VERSION) has returned 0");
return false;
}
const char kGLESVersionPrefix[] = "OpenGL ES ";
if (strncmp(versionString, kGLESVersionPrefix, strlen(kGLESVersionPrefix)) == 0) {
versionString += strlen(kGLESVersionPrefix);
}
const char* itr = versionString;
char* end = nullptr;
auto majorVersion = strtol(itr, &end, 10);
if (!end) {
MOZ_ASSERT(false, "Failed to parse the GL major version number.");
return false;
} else if (*end != '.') {
MOZ_ASSERT(false, "Failed to parse GL's major-minor version number separator.");
return false;
}
// we skip the '.' between the major and the minor version
itr = end + 1;
end = nullptr;
auto minorVersion = strtol(itr, &end, 10);
if (!end) {
MOZ_ASSERT(false, "Failed to parse GL's minor version number.");
return false;
}
if (majorVersion <= 0 || majorVersion >= 100) {
MOZ_ASSERT(false, "Invalid major version.");
return false;
} else if (minorVersion < 0 || minorVersion >= 10) {
MOZ_ASSERT(false, "Invalid minor version.");
return false;
}
*out_version = (uint32_t)majorVersion * 100 + (uint32_t)minorVersion * 10;
const auto& majorStr = match.str(1);
const auto& minorStr = match.str(2);
*out_major = atoi(majorStr.c_str());
*out_minor = atoi(minorStr.c_str());
return true;
}
@ -721,32 +522,52 @@ GLContext::InitWithPrefixImpl(const char* prefix, bool trygl)
////////////////
MakeCurrent();
MOZ_ASSERT(mProfile != ContextProfile::Unknown);
uint32_t version = 0;
ParseGLVersion(this, &version);
const std::string versionStr = (const char*)fGetString(LOCAL_GL_VERSION);
if (versionStr.find("OpenGL ES") == 0) {
mProfile = ContextProfile::OpenGLES;
}
mShadingLanguageVersion = 100;
ParseGLSLVersion(this, &mShadingLanguageVersion);
uint32_t majorVer, minorVer;
if (!ParseVersion(versionStr, &majorVer, &minorVer)) {
MOZ_ASSERT(false, "Failed to parse GL_VERSION");
return false;
}
MOZ_ASSERT(majorVer < 10);
MOZ_ASSERT(minorVer < 10);
mVersion = majorVer*100 + minorVer*10;
if (mVersion < 200) {
// Mac OSX 10.6/10.7 machines with Intel GPUs claim only OpenGL 1.4 but
// have all the GL2+ extensions that we need.
mVersion = 200;
}
////
const auto glslVersionStr = (const char*)fGetString(LOCAL_GL_SHADING_LANGUAGE_VERSION);
if (!glslVersionStr) {
// This happens on the Android emulators. We'll just return 100
mShadingLanguageVersion = 100;
} else if (ParseVersion(glslVersionStr, &majorVer, &minorVer)) {
MOZ_ASSERT(majorVer < 10);
MOZ_ASSERT(minorVer < 100);
mShadingLanguageVersion = majorVer*100 + minorVer;
} else {
MOZ_ASSERT(false, "Failed to parse GL_SHADING_LANGUAGE_VERSION");
return false;
}
if (ShouldSpew()) {
printf_stderr("OpenGL version detected: %u\n", version);
printf_stderr("OpenGL shading language version detected: %u\n", mShadingLanguageVersion);
printf_stderr("GL version detected: %u\n", mVersion);
printf_stderr("GLSL version detected: %u\n", mShadingLanguageVersion);
printf_stderr("OpenGL vendor: %s\n", fGetString(LOCAL_GL_VENDOR));
printf_stderr("OpenGL renderer: %s\n", fGetString(LOCAL_GL_RENDERER));
}
if (version >= mVersion) {
mVersion = version;
}
// Don't fail if version < mVersion, see bug 999445,
// Mac OSX 10.6/10.7 machines with Intel GPUs claim only OpenGL 1.4 but
// have all the GL2+ extensions that we need.
////////////////
// Load OpenGL ES 2.0 symbols, or desktop if we aren't using ES 2.
if (IsGLES()) {
if (mProfile == ContextProfile::OpenGLES) {
const SymLoadStruct symbols[] = {
{ (PRFuncPtr*) &mSymbols.fGetShaderPrecisionFormat, { "GetShaderPrecisionFormat", nullptr } },
{ (PRFuncPtr*) &mSymbols.fClearDepthf, { "ClearDepthf", nullptr } },
@ -856,22 +677,42 @@ GLContext::InitWithPrefixImpl(const char* prefix, bool trygl)
////////////////
// We need this for retrieving the list of extensions on Core profiles.
if (IsFeatureProvidedByCoreSymbols(GLFeature::get_string_indexed)) {
if (mVersion >= 300) { // Both GL3 and ES3.
const SymLoadStruct symbols[] = {
{ (PRFuncPtr*) &mSymbols.fGetStringi, { "GetStringi", nullptr } },
END_SYMBOLS
};
if (!LoadGLSymbols(this, prefix, trygl, symbols, "get_string_indexed")) {
MOZ_RELEASE_ASSERT(false, "GFX: get_string_indexed is required!");
if (!LoadGLSymbols(this, prefix, trygl, symbols, "GetStringi")) {
MOZ_RELEASE_ASSERT(false, "GFX: GetStringi is required!");
return false;
}
}
InitExtensions();
if (mProfile != ContextProfile::OpenGLES) {
if (mVersion >= 310 && !IsExtensionSupported(ARB_compatibility)) {
mProfile = ContextProfile::OpenGLCore;
} else {
mProfile = ContextProfile::OpenGLCompatibility;
}
}
MOZ_ASSERT(mProfile != ContextProfile::Unknown);
if (ShouldSpew()) {
const char* profileStr = "";
if (mProfile == ContextProfile::OpenGLES) {
profileStr = " es";
} else if (mProfile == ContextProfile::OpenGLCore) {
profileStr = " core";
}
printf_stderr("Detected profile: %u%s\n", mVersion, profileStr);
}
InitFeatures();
////
// Disable extensions with partial or incorrect support.
if (WorkAroundDriverBugs()) {
if (Renderer() == GLRenderer::AdrenoTM320) {
@ -1121,8 +962,6 @@ GLContext::InitWithPrefixImpl(const char* prefix, bool trygl)
true);
}
mVersionString = nsPrintfCString("%u.%u.%u", mVersion / 100, (mVersion / 10) % 10,
mVersion % 10);
return true;
}
@ -1770,7 +1609,7 @@ GLContext::InitExtensions()
std::vector<nsCString> driverExtensionList;
if (IsFeatureProvidedByCoreSymbols(GLFeature::get_string_indexed)) {
if (mSymbols.fGetStringi) {
GLuint count = 0;
GetUIntegerv(LOCAL_GL_NUM_EXTENSIONS, &count);
for (GLuint i = 0; i < count; i++) {

Просмотреть файл

@ -102,7 +102,6 @@ enum class GLFeature {
get_integer64_indexed,
get_query_object_i64v,
get_query_object_iv,
get_string_indexed,
gpu_shader4,
instanced_arrays,
instanced_non_arrays,
@ -151,7 +150,6 @@ enum class GLFeature {
enum class ContextProfile : uint8_t {
Unknown = 0,
OpenGL, // only for IsAtLeast's <profile> parameter
OpenGLCore,
OpenGLCompatibility,
OpenGLES
@ -241,48 +239,12 @@ public:
return mProfile == ContextProfile::OpenGLCompatibility;
}
/**
* Return true if the context is a true OpenGL ES context or an ANGLE context
*/
inline bool IsGLES() const {
MOZ_ASSERT(mProfile != ContextProfile::Unknown, "unknown context profile");
return mProfile == ContextProfile::OpenGLES;
}
static const char* GetProfileName(ContextProfile profile)
{
switch (profile)
{
case ContextProfile::OpenGL:
return "OpenGL";
case ContextProfile::OpenGLCore:
return "OpenGL Core";
case ContextProfile::OpenGLCompatibility:
return "OpenGL Compatibility";
case ContextProfile::OpenGLES:
return "OpenGL ES";
default:
break;
}
MOZ_ASSERT(profile != ContextProfile::Unknown, "unknown context profile");
return "OpenGL unknown profile";
}
/**
* Return true if we are running on a OpenGL core profile context
*/
const char* ProfileString() const {
return GetProfileName(mProfile);
}
/**
* Return true if the context is compatible with given parameters
*
* IsAtLeast(ContextProfile::OpenGL, N) is exactly same as
* IsAtLeast(ContextProfile::OpenGLCore, N) || IsAtLeast(ContextProfile::OpenGLCompatibility, N)
*/
inline bool IsAtLeast(ContextProfile profile, unsigned int version) const
{
MOZ_ASSERT(profile != ContextProfile::Unknown, "IsAtLeast: bad <profile> parameter");
@ -293,11 +255,6 @@ public:
return false;
}
if (profile == ContextProfile::OpenGL) {
return mProfile == ContextProfile::OpenGLCore ||
mProfile == ContextProfile::OpenGLCompatibility;
}
return profile == mProfile;
}
@ -310,10 +267,6 @@ public:
return mVersion;
}
const char* VersionString() const {
return mVersionString.get();
}
inline uint32_t ShadingLanguageVersion() const {
return mShadingLanguageVersion;
}
@ -361,7 +314,6 @@ protected:
* the context is an OpenGL 2.1 context, mVersion value will be 210.
*/
uint32_t mVersion;
nsCString mVersionString;
ContextProfile mProfile;
uint32_t mShadingLanguageVersion;
@ -369,19 +321,6 @@ protected:
GLVendor mVendor;
GLRenderer mRenderer;
void SetProfileVersion(ContextProfile profile, uint32_t version) {
MOZ_ASSERT(!mSymbols.fBindFramebuffer,
"SetProfileVersion can only be called before initialization!");
MOZ_ASSERT(profile != ContextProfile::Unknown &&
profile != ContextProfile::OpenGL,
"Invalid `profile` for SetProfileVersion");
MOZ_ASSERT(version >= 100, "Invalid `version` for SetProfileVersion");
mVersion = version;
mProfile = profile;
}
// -----------------------------------------------------------------------------
// Extensions management
/**
@ -417,6 +356,7 @@ public:
ARB_ES2_compatibility,
ARB_ES3_compatibility,
ARB_color_buffer_float,
ARB_compatibility,
ARB_copy_buffer,
ARB_depth_texture,
ARB_draw_buffers,
@ -3179,7 +3119,7 @@ public:
}
// -----------------------------------------------------------------------------
// get_string_indexed
// GL3+, ES3+
const GLubyte* fGetStringi(GLenum name, GLuint index) {
BEFORE_GL_CALL;

Просмотреть файл

@ -29,7 +29,7 @@ class GLContextCGL : public GLContext
public:
MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextCGL, override)
GLContextCGL(CreateContextFlags flags, const SurfaceCaps& caps,
NSOpenGLContext* context, bool isOffscreen, ContextProfile profile);
NSOpenGLContext* context, bool isOffscreen);
~GLContextCGL();

Просмотреть файл

@ -311,16 +311,6 @@ static const FeatureInfo sFeatureInfoArr[] = {
* ARB_occlusion_query (added by OpenGL 2.0).
*/
},
{
"get_string_indexed",
GLVersion::GL3,
GLESVersion::ES3,
GLContext::Extension_None,
{
GLContext::Extensions_End
}
// glGetStringi
},
{
"gpu_shader4",
GLVersion::GL3,

Просмотреть файл

@ -26,8 +26,7 @@ public:
GLXDrawable drawable,
GLXFBConfig cfg,
bool deleteDrawable,
gfxXlibSurface* pixmap = nullptr,
ContextProfile profile = ContextProfile::OpenGLCompatibility);
gfxXlibSurface* pixmap);
// Finds a GLXFBConfig compatible with the provided window.
static bool
@ -77,8 +76,7 @@ private:
GLXContext aContext,
bool aDeleteDrawable,
bool aDoubleBuffered,
gfxXlibSurface* aPixmap,
ContextProfile profile);
gfxXlibSurface* aPixmap);
GLXContext mContext;
Display* mDisplay;

Просмотреть файл

@ -73,12 +73,10 @@ private:
CGLLibrary sCGLLibrary;
GLContextCGL::GLContextCGL(CreateContextFlags flags, const SurfaceCaps& caps,
NSOpenGLContext* context, bool isOffscreen,
ContextProfile profile)
NSOpenGLContext* context, bool isOffscreen)
: GLContext(flags, caps, nullptr, isOffscreen)
, mContext(context)
{
SetProfileVersion(profile, 210);
}
GLContextCGL::~GLContextCGL()
@ -292,10 +290,9 @@ GLContextProviderCGL::CreateForWindow(nsIWidget* aWidget,
GLint opaque = 0;
[context setValues:&opaque forParameter:NSOpenGLCPSurfaceOpacity];
SurfaceCaps caps = SurfaceCaps::ForRGBA();
ContextProfile profile = ContextProfile::OpenGLCompatibility;
RefPtr<GLContextCGL> glContext = new GLContextCGL(CreateContextFlags::NONE, caps,
context, false, profile);
RefPtr<GLContextCGL> glContext = new GLContextCGL(CreateContextFlags::NONE,
SurfaceCaps::ForRGBA(), context,
false);
if (!glContext->Init()) {
glContext = nullptr;
@ -313,16 +310,12 @@ CreateOffscreenFBOContext(CreateContextFlags flags)
return nullptr;
}
ContextProfile profile;
NSOpenGLContext* context = nullptr;
if (!(flags & CreateContextFlags::REQUIRE_COMPAT_PROFILE)) {
profile = ContextProfile::OpenGLCore;
context = CreateWithFormat(kAttribs_offscreen_coreProfile);
}
if (!context) {
profile = ContextProfile::OpenGLCompatibility;
if (flags & CreateContextFlags::ALLOW_OFFLINE_RENDERER) {
if (gfxPrefs::RequireHardwareGL())
context = CreateWithFormat(kAttribs_singleBuffered);
@ -341,9 +334,8 @@ CreateOffscreenFBOContext(CreateContextFlags flags)
return nullptr;
}
SurfaceCaps dummyCaps = SurfaceCaps::Any();
RefPtr<GLContextCGL> glContext = new GLContextCGL(flags, dummyCaps, context, true,
profile);
RefPtr<GLContextCGL> glContext = new GLContextCGL(flags, SurfaceCaps::Any(), context,
true);
if (gfxPrefs::GLMultithreaded()) {
CGLEnable(glContext->GetCGLContext(), kCGLCEMPEngine);

Просмотреть файл

@ -24,15 +24,13 @@ using namespace mozilla::widget;
GLContextEAGL::GLContextEAGL(CreateContextFlags flags, const SurfaceCaps& caps,
EAGLContext* context, GLContext* sharedContext,
bool isOffscreen, ContextProfile profile)
bool isOffscreen)
: GLContext(flags, caps, sharedContext, isOffscreen)
, mContext(context)
, mBackbufferRB(0)
, mBackbufferFB(0)
, mLayer(nil)
{
SetProfileVersion(ContextProfile::OpenGLES,
[context API] == kEAGLRenderingAPIOpenGLES3 ? 300 : 200);
}
GLContextEAGL::~GLContextEAGL()
@ -198,13 +196,9 @@ CreateEAGLContext(CreateContextFlags flags, bool aOffscreen, GLContextEAGL* shar
return nullptr;
}
SurfaceCaps caps = SurfaceCaps::ForRGBA();
ContextProfile profile = ContextProfile::OpenGLES;
RefPtr<GLContextEAGL> glContext = new GLContextEAGL(flags, caps, context,
sharedContext,
aOffscreen,
profile);
RefPtr<GLContextEAGL> glContext = new GLContextEAGL(flags, SurfaceCaps::ForRGBA(),
context, sharedContext,
aOffscreen);
if (!glContext->Init()) {
glContext = nullptr;
return nullptr;

Просмотреть файл

@ -218,9 +218,6 @@ GLContextEGL::GLContextEGL(CreateContextFlags flags, const SurfaceCaps& caps,
, mShareWithEGLImage(false)
, mOwnsContext(true)
{
// any EGL contexts will always be GLESv2
SetProfileVersion(ContextProfile::OpenGLES, 200);
#ifdef DEBUG
printf_stderr("Initializing context %p surface %p on display %p\n", mContext, mSurface, EGL_DISPLAY());
#endif

Просмотреть файл

@ -484,7 +484,7 @@ already_AddRefed<GLContextGLX>
GLContextGLX::CreateGLContext(CreateContextFlags flags, const SurfaceCaps& caps,
bool isOffscreen, Display* display, GLXDrawable drawable,
GLXFBConfig cfg, bool deleteDrawable,
gfxXlibSurface* pixmap, ContextProfile profile)
gfxXlibSurface* pixmap)
{
GLXLibrary& glx = sGLXLibrary;
@ -517,7 +517,7 @@ GLContextGLX::CreateGLContext(CreateContextFlags flags, const SurfaceCaps& caps,
};
attrib_list.AppendElements(robust_attribs, MOZ_ARRAY_LENGTH(robust_attribs));
}
if (profile == ContextProfile::OpenGLCore) {
if (!(flags & CreateContextFlags::REQUIRE_COMPAT_PROFILE)) {
int core_attribs[] = {
LOCAL_GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
LOCAL_GLX_CONTEXT_MINOR_VERSION_ARB, 2,
@ -544,7 +544,7 @@ GLContextGLX::CreateGLContext(CreateContextFlags flags, const SurfaceCaps& caps,
if (context) {
glContext = new GLContextGLX(flags, caps, isOffscreen, display, drawable,
context, deleteDrawable, db, pixmap, profile);
context, deleteDrawable, db, pixmap);
if (!glContext->Init())
error = true;
} else {
@ -710,8 +710,7 @@ GLContextGLX::GLContextGLX(
GLXContext aContext,
bool aDeleteDrawable,
bool aDoubleBuffered,
gfxXlibSurface* aPixmap,
ContextProfile profile)
gfxXlibSurface* aPixmap)
: GLContext(flags, caps, nullptr, isOffscreen),
mContext(aContext),
mDisplay(aDisplay),
@ -722,9 +721,6 @@ GLContextGLX::GLContextGLX(
mPixmap(aPixmap),
mOwnsContext(true)
{
MOZ_ASSERT(mGLX);
// See 899855
SetProfileVersion(profile, 200);
}
static bool
@ -763,8 +759,7 @@ GLContextProviderGLX::CreateWrappingExisting(void* aContext, void* aSurface)
(GLXDrawable)aSurface, (GLXContext)aContext,
false, // aDeleteDrawable,
true,
(gfxXlibSurface*)nullptr,
ContextProfile::OpenGLCompatibility);
(gfxXlibSurface*)nullptr);
glContext->mOwnsContext = false;
return glContext.forget();
@ -805,22 +800,14 @@ CreateForWidget(Display* aXDisplay, Window aXWindow,
return nullptr;
}
SurfaceCaps caps = SurfaceCaps::Any();
RefPtr<GLContextGLX> gl;
CreateContextFlags flags;
if (aWebRender) {
gl = GLContextGLX::CreateGLContext(CreateContextFlags::NONE,
caps, false,
aXDisplay, aXWindow, config,
//TODO: we might want to pass an additional bool to select GL core/compat
false, nullptr, ContextProfile::OpenGLCore); //WR: required GL 3.2+
flags = CreateContextFlags::NONE; // WR needs GL3.2+
} else {
gl = GLContextGLX::CreateGLContext(CreateContextFlags::NONE,
caps, false,
aXDisplay, aXWindow, config,
false);
flags = CreateContextFlags::REQUIRE_COMPAT_PROFILE;
}
return gl.forget();
return GLContextGLX::CreateGLContext(flags, SurfaceCaps::Any(), false, aXDisplay,
aXWindow, config, false, nullptr);
}
already_AddRefed<GLContext>
@ -1001,8 +988,7 @@ GLContextGLX::FindFBConfigForWindow(Display* display, int screen, Window window,
static already_AddRefed<GLContextGLX>
CreateOffscreenPixmapContext(CreateContextFlags flags, const IntSize& size,
const SurfaceCaps& minCaps, nsACString* const out_failureId,
ContextProfile profile = ContextProfile::OpenGLCompatibility)
const SurfaceCaps& minCaps, nsACString* const out_failureId)
{
GLXLibrary* glx = &sGLXLibrary;
if (!glx->EnsureInitialized())
@ -1048,8 +1034,8 @@ CreateOffscreenPixmapContext(CreateContextFlags flags, const IntSize& size,
if (error || serverError)
return nullptr;
return GLContextGLX::CreateGLContext(flags, minCaps, true, display,
pixmap, config, true, surface, profile);
return GLContextGLX::CreateGLContext(flags, minCaps, true, display, pixmap, config,
true, surface);
}
/*static*/ already_AddRefed<GLContext>
@ -1074,14 +1060,8 @@ GLContextProviderGLX::CreateOffscreen(const IntSize& size,
minBackbufferCaps.stencil = false;
}
ContextProfile profile = ContextProfile::OpenGLCore;
if (flags & CreateContextFlags::REQUIRE_COMPAT_PROFILE) {
profile = ContextProfile::OpenGLCompatibility;
}
RefPtr<GLContext> gl;
gl = CreateOffscreenPixmapContext(flags, size, minBackbufferCaps, out_failureId,
profile);
gl = CreateOffscreenPixmapContext(flags, size, minBackbufferCaps, out_failureId);
if (!gl)
return nullptr;

Просмотреть файл

@ -278,8 +278,6 @@ GLContextWGL::GLContextWGL(CreateContextFlags flags, const SurfaceCaps& caps,
mPixelFormat(0),
mIsDoubleBuffered(false)
{
// See 899855
SetProfileVersion(ContextProfile::OpenGLCompatibility, 200);
}
GLContextWGL::GLContextWGL(CreateContextFlags flags, const SurfaceCaps& caps,
@ -293,8 +291,6 @@ GLContextWGL::GLContextWGL(CreateContextFlags flags, const SurfaceCaps& caps,
mPixelFormat(aPixelFormat),
mIsDoubleBuffered(false)
{
// See 899855
SetProfileVersion(ContextProfile::OpenGLCompatibility, 200);
}
GLContextWGL::~GLContextWGL()

Просмотреть файл

@ -744,14 +744,10 @@ public:
return;
}
mGLContext = gl::GLContextGLX::CreateGLContext(
gl::CreateContextFlags::NONE,
gl::SurfaceCaps::Any(),
false,
mXDisplay,
root,
config,
false);
mGLContext = gl::GLContextGLX::CreateGLContext(gl::CreateContextFlags::NONE,
gl::SurfaceCaps::Any(), false,
mXDisplay, root, config, false,
nullptr);
if (!mGLContext) {
lock.NotifyAll();