2013-01-18 04:45:11 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim: set ts=8 sts=4 et sw=4 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-04-27 06:09:44 +04:00
|
|
|
|
2012-04-25 18:10:43 +04:00
|
|
|
#include <algorithm>
|
2012-12-15 03:58:45 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2013-09-07 06:13:37 +04:00
|
|
|
#include <ctype.h>
|
2012-12-15 03:58:45 +04:00
|
|
|
|
2010-04-27 06:09:44 +04:00
|
|
|
#include "GLContext.h"
|
2013-11-29 00:57:19 +04:00
|
|
|
#include "GLBlitHelper.h"
|
2013-11-29 00:57:19 +04:00
|
|
|
#include "GLBlitTextureImageHelper.h"
|
2014-01-02 19:17:22 +04:00
|
|
|
#include "GLReadTexImageHelper.h"
|
2010-04-27 06:09:44 +04:00
|
|
|
|
2011-03-02 23:50:36 +03:00
|
|
|
#include "gfxCrashReporterUtils.h"
|
2011-07-06 22:00:47 +04:00
|
|
|
#include "gfxUtils.h"
|
2013-02-14 03:26:24 +04:00
|
|
|
#include "GLContextProvider.h"
|
2013-02-21 23:54:25 +04:00
|
|
|
#include "GLTextureImage.h"
|
2013-08-03 01:30:58 +04:00
|
|
|
#include "nsPrintfCString.h"
|
2013-02-14 03:26:24 +04:00
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include "prenv.h"
|
|
|
|
#include "prlink.h"
|
2013-11-26 07:25:25 +04:00
|
|
|
#include "ScopedGLHelpers.h"
|
2014-03-11 06:08:49 +04:00
|
|
|
#include "SharedSurfaceGL.h"
|
2013-02-14 03:26:24 +04:00
|
|
|
#include "SurfaceStream.h"
|
2013-09-07 06:13:37 +04:00
|
|
|
#include "GfxTexturesReporter.h"
|
|
|
|
#include "TextureGarbageBin.h"
|
2013-10-08 03:15:59 +04:00
|
|
|
#include "gfx2DGlue.h"
|
2014-02-23 03:53:04 +04:00
|
|
|
#include "gfxPrefs.h"
|
2014-08-27 01:14:51 +04:00
|
|
|
#include "mozilla/IntegerPrintfMacros.h"
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2013-11-29 08:11:49 +04:00
|
|
|
#include "OGLShaderProgram.h" // for ShaderProgramType
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
#include "mozilla/DebugOnly.h"
|
2013-02-21 23:54:25 +04:00
|
|
|
|
2013-06-17 06:46:53 +04:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
#include <CoreServices/CoreServices.h>
|
2013-10-08 03:15:59 +04:00
|
|
|
#include "gfxColor.h"
|
2013-06-17 06:46:53 +04:00
|
|
|
#endif
|
|
|
|
|
2013-08-23 04:13:59 +04:00
|
|
|
#if defined(MOZ_WIDGET_COCOA)
|
|
|
|
#include "nsCocoaFeatures.h"
|
|
|
|
#endif
|
|
|
|
|
2010-04-27 06:09:44 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
|
2014-05-22 14:11:45 +04:00
|
|
|
using namespace mozilla::gfx;
|
|
|
|
using namespace mozilla::layers;
|
|
|
|
|
2012-05-13 03:23:56 +04:00
|
|
|
#ifdef DEBUG
|
2012-08-22 19:56:38 +04:00
|
|
|
unsigned GLContext::sCurrentGLContextTLS = -1;
|
2012-05-13 03:23:56 +04:00
|
|
|
#endif
|
2010-10-13 01:01:59 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t GLContext::sDebugMode = 0;
|
2012-02-09 23:05:11 +04:00
|
|
|
|
2010-05-18 08:04:22 +04:00
|
|
|
|
2010-04-27 06:09:44 +04:00
|
|
|
#define MAX_SYMBOL_LENGTH 128
|
|
|
|
#define MAX_SYMBOL_NAMES 5
|
2014-05-14 04:18:42 +04:00
|
|
|
#define END_SYMBOLS { nullptr, { nullptr } }
|
2010-04-27 06:09:44 +04:00
|
|
|
|
2012-06-13 01:39:18 +04:00
|
|
|
// should match the order of GLExtensions, and be null-terminated.
|
2011-11-19 07:57:29 +04:00
|
|
|
static const char *sExtensionNames[] = {
|
2014-05-14 04:18:42 +04:00
|
|
|
"NO_EXTENSION",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_AMD_compressed_ATC_texture",
|
|
|
|
"GL_ANGLE_depth_texture",
|
|
|
|
"GL_ANGLE_framebuffer_blit",
|
|
|
|
"GL_ANGLE_framebuffer_multisample",
|
|
|
|
"GL_ANGLE_instanced_arrays",
|
|
|
|
"GL_ANGLE_texture_compression_dxt3",
|
|
|
|
"GL_ANGLE_texture_compression_dxt5",
|
2011-11-19 07:57:29 +04:00
|
|
|
"GL_APPLE_client_storage",
|
2013-12-12 22:27:10 +04:00
|
|
|
"GL_APPLE_texture_range",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_APPLE_vertex_array_object",
|
2011-11-19 07:57:29 +04:00
|
|
|
"GL_ARB_ES2_compatibility",
|
2013-08-15 23:58:20 +04:00
|
|
|
"GL_ARB_ES3_compatibility",
|
2014-03-08 01:26:17 +04:00
|
|
|
"GL_ARB_color_buffer_float",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_ARB_depth_texture",
|
|
|
|
"GL_ARB_draw_buffers",
|
|
|
|
"GL_ARB_draw_instanced",
|
|
|
|
"GL_ARB_framebuffer_object",
|
|
|
|
"GL_ARB_framebuffer_sRGB",
|
|
|
|
"GL_ARB_half_float_pixel",
|
|
|
|
"GL_ARB_instanced_arrays",
|
|
|
|
"GL_ARB_occlusion_query2",
|
|
|
|
"GL_ARB_pixel_buffer_object",
|
2011-11-19 07:57:29 +04:00
|
|
|
"GL_ARB_robustness",
|
2012-04-07 03:57:55 +04:00
|
|
|
"GL_ARB_sync",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_ARB_texture_float",
|
|
|
|
"GL_ARB_texture_non_power_of_two",
|
|
|
|
"GL_ARB_texture_rectangle",
|
2013-06-18 00:17:59 +04:00
|
|
|
"GL_ARB_vertex_array_object",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_EXT_bgra",
|
2013-07-18 19:24:23 +04:00
|
|
|
"GL_EXT_blend_minmax",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_EXT_color_buffer_float",
|
|
|
|
"GL_EXT_color_buffer_half_float",
|
|
|
|
"GL_EXT_draw_buffers",
|
2013-07-26 04:38:58 +04:00
|
|
|
"GL_EXT_draw_instanced",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_EXT_draw_range_elements",
|
|
|
|
"GL_EXT_frag_depth",
|
|
|
|
"GL_EXT_framebuffer_blit",
|
|
|
|
"GL_EXT_framebuffer_multisample",
|
|
|
|
"GL_EXT_framebuffer_object",
|
|
|
|
"GL_EXT_framebuffer_sRGB",
|
|
|
|
"GL_EXT_gpu_shader4",
|
2013-08-07 01:23:46 +04:00
|
|
|
"GL_EXT_occlusion_query_boolean",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_EXT_packed_depth_stencil",
|
|
|
|
"GL_EXT_read_format_bgra",
|
|
|
|
"GL_EXT_robustness",
|
2013-11-05 01:05:04 +04:00
|
|
|
"GL_EXT_sRGB",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_EXT_shader_texture_lod",
|
|
|
|
"GL_EXT_texture_compression_dxt1",
|
|
|
|
"GL_EXT_texture_compression_s3tc",
|
|
|
|
"GL_EXT_texture_filter_anisotropic",
|
|
|
|
"GL_EXT_texture_format_BGRA8888",
|
2013-11-05 01:05:04 +04:00
|
|
|
"GL_EXT_texture_sRGB",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_EXT_transform_feedback",
|
|
|
|
"GL_EXT_unpack_subimage",
|
|
|
|
"GL_IMG_read_format",
|
|
|
|
"GL_IMG_texture_compression_pvrtc",
|
|
|
|
"GL_IMG_texture_npot",
|
2013-10-09 03:20:24 +04:00
|
|
|
"GL_KHR_debug",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_NV_draw_instanced",
|
2014-08-05 09:09:20 +04:00
|
|
|
"GL_NV_fence",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_NV_half_float",
|
|
|
|
"GL_NV_instanced_arrays",
|
|
|
|
"GL_NV_transform_feedback",
|
|
|
|
"GL_OES_EGL_image",
|
|
|
|
"GL_OES_EGL_image_external",
|
|
|
|
"GL_OES_EGL_sync",
|
|
|
|
"GL_OES_compressed_ETC1_RGB8_texture",
|
|
|
|
"GL_OES_depth24",
|
|
|
|
"GL_OES_depth32",
|
|
|
|
"GL_OES_depth_texture",
|
|
|
|
"GL_OES_element_index_uint",
|
|
|
|
"GL_OES_packed_depth_stencil",
|
|
|
|
"GL_OES_rgb8_rgba8",
|
|
|
|
"GL_OES_standard_derivatives",
|
|
|
|
"GL_OES_stencil8",
|
|
|
|
"GL_OES_texture_float",
|
|
|
|
"GL_OES_texture_float_linear",
|
|
|
|
"GL_OES_texture_half_float",
|
|
|
|
"GL_OES_texture_half_float_linear",
|
|
|
|
"GL_OES_texture_npot",
|
|
|
|
"GL_OES_vertex_array_object",
|
2012-07-30 18:20:58 +04:00
|
|
|
nullptr
|
2011-11-19 07:57:29 +04:00
|
|
|
};
|
|
|
|
|
2013-08-29 18:07:58 +04:00
|
|
|
static bool
|
|
|
|
ParseGLVersion(GLContext* gl, unsigned int* version)
|
|
|
|
{
|
|
|
|
GLenum error = gl->fGetError();
|
|
|
|
if (error != 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, has this is a
|
|
|
|
* better way than parsing GL_VERSION.
|
|
|
|
*/
|
|
|
|
GLint majorVersion = 0;
|
|
|
|
GLint minorVersion = 0;
|
|
|
|
|
|
|
|
gl->fGetIntegerv(LOCAL_GL_MAJOR_VERSION, &majorVersion);
|
|
|
|
gl->fGetIntegerv(LOCAL_GL_MINOR_VERSION, &minorVersion);
|
|
|
|
|
|
|
|
// If it's not an OpenGL (ES) 3.0 context, we will have an error
|
|
|
|
error = gl->fGetError();
|
|
|
|
if (error == LOCAL_GL_NO_ERROR &&
|
|
|
|
majorVersion > 0 &&
|
|
|
|
minorVersion >= 0)
|
|
|
|
{
|
|
|
|
*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);
|
|
|
|
|
|
|
|
error = gl->fGetError();
|
|
|
|
if (error != 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;
|
|
|
|
int majorVersion = (int)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;
|
|
|
|
|
|
|
|
int minorVersion = (int)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;
|
|
|
|
}
|
|
|
|
|
|
|
|
*version = (unsigned int)(majorVersion * 100 + minorVersion * 10);
|
|
|
|
return true;
|
|
|
|
}
|
2010-04-27 06:09:44 +04:00
|
|
|
|
2013-09-07 06:13:37 +04:00
|
|
|
GLContext::GLContext(const SurfaceCaps& caps,
|
|
|
|
GLContext* sharedContext,
|
|
|
|
bool isOffscreen)
|
|
|
|
: mInitialized(false),
|
|
|
|
mIsOffscreen(isOffscreen),
|
|
|
|
mContextLost(false),
|
|
|
|
mVersion(0),
|
|
|
|
mProfile(ContextProfile::Unknown),
|
2014-01-10 22:55:23 +04:00
|
|
|
mVendor(GLVendor::Other),
|
|
|
|
mRenderer(GLRenderer::Other),
|
2013-09-07 06:13:37 +04:00
|
|
|
mHasRobustness(false),
|
|
|
|
#ifdef DEBUG
|
2014-08-28 03:18:43 +04:00
|
|
|
mIsInLocalErrorCheck(false),
|
2013-09-07 06:13:37 +04:00
|
|
|
#endif
|
|
|
|
mSharedContext(sharedContext),
|
|
|
|
mCaps(caps),
|
|
|
|
mScreen(nullptr),
|
|
|
|
mLockedSurface(nullptr),
|
|
|
|
mMaxTextureSize(0),
|
|
|
|
mMaxCubeMapTextureSize(0),
|
|
|
|
mMaxTextureImageSize(0),
|
|
|
|
mMaxRenderbufferSize(0),
|
|
|
|
mNeedsTextureSizeChecks(false),
|
2014-09-10 05:40:51 +04:00
|
|
|
mWorkAroundDriverBugs(true),
|
|
|
|
mHeavyGLCallsSinceLastFlush(false)
|
2013-09-07 06:13:37 +04:00
|
|
|
{
|
2014-05-09 08:18:00 +04:00
|
|
|
mOwningThreadId = PlatformThread::CurrentId();
|
2013-09-07 06:13:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GLContext::~GLContext() {
|
|
|
|
NS_ASSERTION(IsDestroyed(), "GLContext implementation must call MarkDestroyed in destructor!");
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (mSharedContext) {
|
|
|
|
GLContext *tip = mSharedContext;
|
|
|
|
while (tip->mSharedContext)
|
|
|
|
tip = tip->mSharedContext;
|
|
|
|
tip->SharedContextDestroyed(this);
|
|
|
|
tip->ReportOutstandingNames();
|
|
|
|
} else {
|
|
|
|
ReportOutstandingNames();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-05-07 00:59:18 +04:00
|
|
|
/*static*/ void
|
|
|
|
GLContext::StaticDebugCallback(GLenum source,
|
|
|
|
GLenum type,
|
|
|
|
GLuint id,
|
|
|
|
GLenum severity,
|
|
|
|
GLsizei length,
|
|
|
|
const GLchar* message,
|
|
|
|
const GLvoid* userParam)
|
|
|
|
{
|
|
|
|
GLContext* gl = (GLContext*)userParam;
|
|
|
|
gl->DebugCallback(source, type, id, severity, length, message);
|
|
|
|
}
|
|
|
|
|
2014-05-14 04:18:42 +04:00
|
|
|
static void
|
|
|
|
ClearSymbols(GLLibraryLoader::SymLoadStruct *symbols)
|
|
|
|
{
|
|
|
|
while (symbols->symPointer) {
|
|
|
|
*symbols->symPointer = nullptr;
|
|
|
|
symbols++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
|
|
|
GLContext::InitWithPrefix(const char *prefix, bool trygl)
|
2010-04-27 06:09:44 +04:00
|
|
|
{
|
2011-03-02 23:50:36 +03:00
|
|
|
ScopedGfxFeatureReporter reporter("GL Context");
|
|
|
|
|
2010-04-27 06:09:44 +04:00
|
|
|
if (mInitialized) {
|
2011-03-02 23:50:36 +03:00
|
|
|
reporter.SetSuccessful();
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2010-04-27 06:09:44 +04:00
|
|
|
}
|
|
|
|
|
2014-02-23 03:53:04 +04:00
|
|
|
mWorkAroundDriverBugs = gfxPrefs::WorkAroundDriverBugs();
|
2012-04-10 19:49:10 +04:00
|
|
|
|
2010-04-27 06:09:44 +04:00
|
|
|
SymLoadStruct symbols[] = {
|
2013-07-20 12:48:55 +04:00
|
|
|
{ (PRFuncPtr*) &mSymbols.fActiveTexture, { "ActiveTexture", "ActiveTextureARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fAttachShader, { "AttachShader", "AttachShaderARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindAttribLocation, { "BindAttribLocation", "BindAttribLocationARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindBuffer, { "BindBuffer", "BindBufferARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindTexture, { "BindTexture", "BindTextureARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBlendColor, { "BlendColor", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBlendEquation, { "BlendEquation", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBlendEquationSeparate, { "BlendEquationSeparate", "BlendEquationSeparateEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBlendFunc, { "BlendFunc", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBlendFuncSeparate, { "BlendFuncSeparate", "BlendFuncSeparateEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBufferData, { "BufferData", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBufferSubData, { "BufferSubData", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fClear, { "Clear", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fClearColor, { "ClearColor", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fClearStencil, { "ClearStencil", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fColorMask, { "ColorMask", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fCompressedTexImage2D, {"CompressedTexImage2D", nullptr} },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fCompressedTexSubImage2D, {"CompressedTexSubImage2D", nullptr} },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fCullFace, { "CullFace", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDetachShader, { "DetachShader", "DetachShaderARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDepthFunc, { "DepthFunc", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDepthMask, { "DepthMask", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDisable, { "Disable", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDisableVertexAttribArray, { "DisableVertexAttribArray", "DisableVertexAttribArrayARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawArrays, { "DrawArrays", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawElements, { "DrawElements", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fEnable, { "Enable", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fEnableVertexAttribArray, { "EnableVertexAttribArray", "EnableVertexAttribArrayARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fFinish, { "Finish", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fFlush, { "Flush", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fFrontFace, { "FrontFace", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetActiveAttrib, { "GetActiveAttrib", "GetActiveAttribARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetActiveUniform, { "GetActiveUniform", "GetActiveUniformARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetAttachedShaders, { "GetAttachedShaders", "GetAttachedShadersARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetAttribLocation, { "GetAttribLocation", "GetAttribLocationARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetIntegerv, { "GetIntegerv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetFloatv, { "GetFloatv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetBooleanv, { "GetBooleanv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetBufferParameteriv, { "GetBufferParameteriv", "GetBufferParameterivARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetError, { "GetError", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetProgramiv, { "GetProgramiv", "GetProgramivARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetProgramInfoLog, { "GetProgramInfoLog", "GetProgramInfoLogARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTexParameteri, { "TexParameteri", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTexParameteriv, { "TexParameteriv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTexParameterf, { "TexParameterf", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetString, { "GetString", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetTexParameterfv, { "GetTexParameterfv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetTexParameteriv, { "GetTexParameteriv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetUniformfv, { "GetUniformfv", "GetUniformfvARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetUniformiv, { "GetUniformiv", "GetUniformivARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetUniformLocation, { "GetUniformLocation", "GetUniformLocationARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetVertexAttribfv, { "GetVertexAttribfv", "GetVertexAttribfvARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetVertexAttribiv, { "GetVertexAttribiv", "GetVertexAttribivARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetVertexAttribPointerv, { "GetVertexAttribPointerv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fHint, { "Hint", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fIsBuffer, { "IsBuffer", "IsBufferARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fIsEnabled, { "IsEnabled", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fIsProgram, { "IsProgram", "IsProgramARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fIsShader, { "IsShader", "IsShaderARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fIsTexture, { "IsTexture", "IsTextureARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fLineWidth, { "LineWidth", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fLinkProgram, { "LinkProgram", "LinkProgramARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fPixelStorei, { "PixelStorei", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fPolygonOffset, { "PolygonOffset", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fReadPixels, { "ReadPixels", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fSampleCoverage, { "SampleCoverage", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fScissor, { "Scissor", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fStencilFunc, { "StencilFunc", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fStencilFuncSeparate, { "StencilFuncSeparate", "StencilFuncSeparateEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fStencilMask, { "StencilMask", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fStencilMaskSeparate, { "StencilMaskSeparate", "StencilMaskSeparateEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fStencilOp, { "StencilOp", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fStencilOpSeparate, { "StencilOpSeparate", "StencilOpSeparateEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTexImage2D, { "TexImage2D", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTexSubImage2D, { "TexSubImage2D", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform1f, { "Uniform1f", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform1fv, { "Uniform1fv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform1i, { "Uniform1i", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform1iv, { "Uniform1iv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform2f, { "Uniform2f", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform2fv, { "Uniform2fv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform2i, { "Uniform2i", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform2iv, { "Uniform2iv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform3f, { "Uniform3f", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform3fv, { "Uniform3fv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform3i, { "Uniform3i", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform3iv, { "Uniform3iv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform4f, { "Uniform4f", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform4fv, { "Uniform4fv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform4i, { "Uniform4i", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform4iv, { "Uniform4iv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniformMatrix2fv, { "UniformMatrix2fv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniformMatrix3fv, { "UniformMatrix3fv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniformMatrix4fv, { "UniformMatrix4fv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUseProgram, { "UseProgram", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fValidateProgram, { "ValidateProgram", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexAttribPointer, { "VertexAttribPointer", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexAttrib1f, { "VertexAttrib1f", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexAttrib2f, { "VertexAttrib2f", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexAttrib3f, { "VertexAttrib3f", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexAttrib4f, { "VertexAttrib4f", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexAttrib1fv, { "VertexAttrib1fv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexAttrib2fv, { "VertexAttrib2fv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexAttrib3fv, { "VertexAttrib3fv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexAttrib4fv, { "VertexAttrib4fv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fViewport, { "Viewport", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fCompileShader, { "CompileShader", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fCopyTexImage2D, { "CopyTexImage2D", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fCopyTexSubImage2D, { "CopyTexSubImage2D", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetShaderiv, { "GetShaderiv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetShaderInfoLog, { "GetShaderInfoLog", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetShaderSource, { "GetShaderSource", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fShaderSource, { "ShaderSource", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexAttribPointer, { "VertexAttribPointer", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindFramebuffer, { "BindFramebuffer", "BindFramebufferEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindRenderbuffer, { "BindRenderbuffer", "BindRenderbufferEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fCheckFramebufferStatus, { "CheckFramebufferStatus", "CheckFramebufferStatusEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fFramebufferRenderbuffer, { "FramebufferRenderbuffer", "FramebufferRenderbufferEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fFramebufferTexture2D, { "FramebufferTexture2D", "FramebufferTexture2DEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGenerateMipmap, { "GenerateMipmap", "GenerateMipmapEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetFramebufferAttachmentParameteriv, { "GetFramebufferAttachmentParameteriv", "GetFramebufferAttachmentParameterivEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetRenderbufferParameteriv, { "GetRenderbufferParameteriv", "GetRenderbufferParameterivEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fIsFramebuffer, { "IsFramebuffer", "IsFramebufferEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fIsRenderbuffer, { "IsRenderbuffer", "IsRenderbufferEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fRenderbufferStorage, { "RenderbufferStorage", "RenderbufferStorageEXT", nullptr } },
|
|
|
|
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGenBuffers, { "GenBuffers", "GenBuffersARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGenTextures, { "GenTextures", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fCreateProgram, { "CreateProgram", "CreateProgramARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fCreateShader, { "CreateShader", "CreateShaderARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGenFramebuffers, { "GenFramebuffers", "GenFramebuffersEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGenRenderbuffers, { "GenRenderbuffers", "GenRenderbuffersEXT", nullptr } },
|
|
|
|
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDeleteBuffers, { "DeleteBuffers", "DeleteBuffersARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDeleteTextures, { "DeleteTextures", "DeleteTexturesARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDeleteProgram, { "DeleteProgram", "DeleteProgramARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDeleteShader, { "DeleteShader", "DeleteShaderARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDeleteFramebuffers, { "DeleteFramebuffers", "DeleteFramebuffersEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDeleteRenderbuffers, { "DeleteRenderbuffers", "DeleteRenderbuffersEXT", nullptr } },
|
|
|
|
|
2014-05-14 04:18:42 +04:00
|
|
|
END_SYMBOLS
|
2010-04-27 06:09:44 +04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
mInitialized = LoadSymbols(&symbols[0], trygl, prefix);
|
2013-12-03 14:44:37 +04:00
|
|
|
MakeCurrent();
|
2013-08-29 18:07:58 +04:00
|
|
|
if (mInitialized) {
|
|
|
|
unsigned int version = 0;
|
|
|
|
|
2014-05-05 23:40:51 +04:00
|
|
|
ParseGLVersion(this, &version);
|
2013-08-29 18:07:58 +04:00
|
|
|
|
2013-12-18 22:09:10 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf_stderr("OpenGL version detected: %u\n", version);
|
|
|
|
printf_stderr("OpenGL vendor: %s\n", fGetString(LOCAL_GL_VENDOR));
|
|
|
|
printf_stderr("OpenGL renderer: %s\n", fGetString(LOCAL_GL_RENDERER));
|
|
|
|
#endif
|
|
|
|
|
2013-08-29 18:07:58 +04:00
|
|
|
if (version >= mVersion) {
|
|
|
|
mVersion = version;
|
|
|
|
}
|
2014-05-05 23:40:51 +04:00
|
|
|
// 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.
|
2013-08-29 18:07:58 +04:00
|
|
|
}
|
|
|
|
|
2011-12-17 01:12:00 +04:00
|
|
|
// Load OpenGL ES 2.0 symbols, or desktop if we aren't using ES 2.
|
|
|
|
if (mInitialized) {
|
2014-03-31 13:10:49 +04:00
|
|
|
if (IsGLES()) {
|
2011-12-17 01:12:00 +04:00
|
|
|
SymLoadStruct symbols_ES2[] = {
|
2013-07-20 12:48:55 +04:00
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetShaderPrecisionFormat, { "GetShaderPrecisionFormat", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fClearDepthf, { "ClearDepthf", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDepthRangef, { "DepthRangef", nullptr } },
|
2014-05-14 04:18:42 +04:00
|
|
|
END_SYMBOLS
|
2011-12-17 01:12:00 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
if (!LoadSymbols(&symbols_ES2[0], trygl, prefix)) {
|
2012-03-30 00:47:20 +04:00
|
|
|
NS_ERROR("OpenGL ES 2.0 supported, but symbols could not be loaded.");
|
2011-12-17 01:12:00 +04:00
|
|
|
mInitialized = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SymLoadStruct symbols_desktop[] = {
|
2013-07-20 12:48:55 +04:00
|
|
|
{ (PRFuncPtr*) &mSymbols.fClearDepth, { "ClearDepth", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDepthRange, { "DepthRange", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fReadBuffer, { "ReadBuffer", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fMapBuffer, { "MapBuffer", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUnmapBuffer, { "UnmapBuffer", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fPointParameterf, { "PointParameterf", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawBuffer, { "DrawBuffer", nullptr } },
|
2013-06-08 07:11:58 +04:00
|
|
|
// These functions are only used by Skia/GL in desktop mode.
|
|
|
|
// Other parts of Gecko should avoid using these
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawBuffers, { "DrawBuffers", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fClientActiveTexture, { "ClientActiveTexture", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDisableClientState, { "DisableClientState", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fEnableClientState, { "EnableClientState", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fLoadIdentity, { "LoadIdentity", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fLoadMatrixf, { "LoadMatrixf", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fMatrixMode, { "MatrixMode", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTexGeni, { "TexGeni", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTexGenf, { "TexGenf", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTexGenfv, { "TexGenfv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexPointer, { "VertexPointer", nullptr } },
|
2014-05-14 04:18:42 +04:00
|
|
|
END_SYMBOLS
|
2011-12-17 01:12:00 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
if (!LoadSymbols(&symbols_desktop[0], trygl, prefix)) {
|
2012-03-30 00:47:20 +04:00
|
|
|
NS_ERROR("Desktop symbols failed to load.");
|
2011-12-17 01:12:00 +04:00
|
|
|
mInitialized = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
const char *glVendorString = nullptr;
|
|
|
|
const char *glRendererString = nullptr;
|
2011-02-12 07:08:16 +03:00
|
|
|
|
2011-02-12 02:11:30 +03:00
|
|
|
if (mInitialized) {
|
2012-02-19 06:23:06 +04:00
|
|
|
// The order of these strings must match up with the order of the enum
|
|
|
|
// defined in GLContext.h for vendor IDs
|
2011-02-12 02:11:30 +03:00
|
|
|
glVendorString = (const char *)fGetString(LOCAL_GL_VENDOR);
|
2013-02-14 03:26:24 +04:00
|
|
|
if (!glVendorString)
|
|
|
|
mInitialized = false;
|
|
|
|
|
2014-01-10 22:55:23 +04:00
|
|
|
const char *vendorMatchStrings[size_t(GLVendor::Other)] = {
|
2010-11-12 23:02:11 +03:00
|
|
|
"Intel",
|
|
|
|
"NVIDIA",
|
|
|
|
"ATI",
|
2012-02-18 01:33:37 +04:00
|
|
|
"Qualcomm",
|
2012-11-27 03:21:39 +04:00
|
|
|
"Imagination",
|
2014-01-10 23:50:25 +04:00
|
|
|
"nouveau",
|
2014-02-28 10:57:03 +04:00
|
|
|
"Vivante",
|
|
|
|
"VMware, Inc."
|
2010-11-12 23:02:11 +03:00
|
|
|
};
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2014-01-10 22:55:23 +04:00
|
|
|
mVendor = GLVendor::Other;
|
|
|
|
for (size_t i = 0; i < size_t(GLVendor::Other); ++i) {
|
2012-01-31 00:09:02 +04:00
|
|
|
if (DoesStringMatch(glVendorString, vendorMatchStrings[i])) {
|
2014-01-10 22:55:23 +04:00
|
|
|
mVendor = GLVendor(i);
|
2010-11-12 23:02:11 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-01-31 00:09:02 +04:00
|
|
|
|
2012-02-19 06:23:06 +04:00
|
|
|
// The order of these strings must match up with the order of the enum
|
|
|
|
// defined in GLContext.h for renderer IDs
|
2012-01-31 00:09:02 +04:00
|
|
|
glRendererString = (const char *)fGetString(LOCAL_GL_RENDERER);
|
2013-02-14 03:26:24 +04:00
|
|
|
if (!glRendererString)
|
|
|
|
mInitialized = false;
|
|
|
|
|
2014-01-10 22:55:23 +04:00
|
|
|
const char *rendererMatchStrings[size_t(GLRenderer::Other)] = {
|
2012-02-18 01:33:37 +04:00
|
|
|
"Adreno 200",
|
2012-02-19 06:23:06 +04:00
|
|
|
"Adreno 205",
|
2014-06-24 19:59:59 +04:00
|
|
|
"Adreno (TM) 200",
|
2013-05-15 19:43:22 +04:00
|
|
|
"Adreno (TM) 205",
|
2013-02-23 21:14:11 +04:00
|
|
|
"Adreno (TM) 320",
|
2012-03-21 03:13:50 +04:00
|
|
|
"PowerVR SGX 530",
|
2013-05-22 11:05:38 +04:00
|
|
|
"PowerVR SGX 540",
|
2013-09-06 16:03:08 +04:00
|
|
|
"NVIDIA Tegra",
|
2014-02-28 10:57:03 +04:00
|
|
|
"Android Emulator",
|
2014-06-16 03:30:04 +04:00
|
|
|
"Gallium 0.4 on llvmpipe",
|
|
|
|
"Intel HD Graphics 3000 OpenGL Engine",
|
2014-07-25 18:35:03 +04:00
|
|
|
"Microsoft Basic Render Driver"
|
2013-02-21 23:54:25 +04:00
|
|
|
};
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2014-01-10 22:55:23 +04:00
|
|
|
mRenderer = GLRenderer::Other;
|
|
|
|
for (size_t i = 0; i < size_t(GLRenderer::Other); ++i) {
|
2012-01-31 00:09:02 +04:00
|
|
|
if (DoesStringMatch(glRendererString, rendererMatchStrings[i])) {
|
2014-01-10 22:55:23 +04:00
|
|
|
mRenderer = GLRenderer(i);
|
2012-01-31 00:09:02 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-02-12 02:11:30 +03:00
|
|
|
}
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2012-06-11 19:25:06 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
if (PR_GetEnv("MOZ_GL_DEBUG"))
|
|
|
|
sDebugMode |= DebugEnabled;
|
|
|
|
|
|
|
|
// enables extra verbose output, informing of the start and finish of every GL call.
|
|
|
|
// useful e.g. to record information to investigate graphics system crashes/lockups
|
|
|
|
if (PR_GetEnv("MOZ_GL_DEBUG_VERBOSE"))
|
|
|
|
sDebugMode |= DebugTrace;
|
|
|
|
|
|
|
|
// aborts on GL error. Can be useful to debug quicker code that is known not to generate any GL error in principle.
|
|
|
|
if (PR_GetEnv("MOZ_GL_DEBUG_ABORT_ON_ERROR"))
|
|
|
|
sDebugMode |= DebugAbortOnError;
|
|
|
|
#endif
|
|
|
|
|
2011-02-12 02:11:30 +03:00
|
|
|
if (mInitialized) {
|
2010-10-07 00:43:14 +04:00
|
|
|
#ifdef DEBUG
|
2012-07-17 19:26:12 +04:00
|
|
|
static bool firstRun = true;
|
|
|
|
if (firstRun && DebugMode()) {
|
2014-01-10 22:55:23 +04:00
|
|
|
const char *vendors[size_t(GLVendor::Other)] = {
|
2010-11-12 23:02:11 +03:00
|
|
|
"Intel",
|
|
|
|
"NVIDIA",
|
|
|
|
"ATI",
|
|
|
|
"Qualcomm"
|
|
|
|
};
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
MOZ_ASSERT(glVendorString);
|
2014-01-10 22:55:23 +04:00
|
|
|
if (mVendor < GLVendor::Other) {
|
2010-11-12 23:02:11 +03:00
|
|
|
printf_stderr("OpenGL vendor ('%s') recognized as: %s\n",
|
2014-01-10 22:55:23 +04:00
|
|
|
glVendorString, vendors[size_t(mVendor)]);
|
2010-11-12 23:02:11 +03:00
|
|
|
} else {
|
|
|
|
printf_stderr("OpenGL vendor ('%s') unrecognized\n", glVendorString);
|
|
|
|
}
|
2010-10-07 00:43:14 +04:00
|
|
|
}
|
2012-07-17 19:26:12 +04:00
|
|
|
firstRun = false;
|
2010-10-07 00:43:14 +04:00
|
|
|
#endif
|
2010-11-17 07:33:03 +03:00
|
|
|
|
2011-02-12 02:11:30 +03:00
|
|
|
InitExtensions();
|
2013-08-24 03:33:42 +04:00
|
|
|
InitFeatures();
|
2011-02-12 02:11:30 +03:00
|
|
|
|
2013-06-05 02:23:40 +04:00
|
|
|
// Disable extensions with partial or incorrect support.
|
|
|
|
if (WorkAroundDriverBugs()) {
|
2014-01-10 22:55:23 +04:00
|
|
|
if (Renderer() == GLRenderer::AdrenoTM320) {
|
2013-08-24 03:33:42 +04:00
|
|
|
MarkUnsupported(GLFeature::standard_derivatives);
|
2013-06-05 02:23:40 +04:00
|
|
|
}
|
2013-11-05 01:05:04 +04:00
|
|
|
|
2014-01-10 23:50:25 +04:00
|
|
|
if (Vendor() == GLVendor::Vivante) {
|
|
|
|
// bug 958256
|
|
|
|
MarkUnsupported(GLFeature::standard_derivatives);
|
|
|
|
}
|
2014-03-06 01:49:55 +04:00
|
|
|
|
|
|
|
if (Vendor() == GLVendor::Imagination &&
|
|
|
|
Renderer() == GLRenderer::SGX540) {
|
|
|
|
// Bug 980048
|
|
|
|
MarkExtensionUnsupported(OES_EGL_sync);
|
|
|
|
}
|
2014-01-10 23:50:25 +04:00
|
|
|
|
2014-07-25 18:35:03 +04:00
|
|
|
if (Renderer() == GLRenderer::MicrosoftBasicRenderDriver) {
|
|
|
|
// Bug 978966: on Microsoft's "Basic Render Driver" (software renderer)
|
|
|
|
// multisampling hardcodes blending with the default blendfunc, which breaks WebGL.
|
|
|
|
MarkUnsupported(GLFeature::framebuffer_multisample);
|
|
|
|
}
|
|
|
|
|
2013-08-28 02:00:16 +04:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
// The Mac Nvidia driver, for versions up to and including 10.8, don't seem
|
|
|
|
// to properly support this. See 814839
|
|
|
|
// this has been fixed in Mac OS X 10.9. See 907946
|
2014-01-10 22:55:23 +04:00
|
|
|
if (Vendor() == gl::GLVendor::NVIDIA &&
|
2013-08-28 02:00:16 +04:00
|
|
|
!nsCocoaFeatures::OnMavericksOrLater())
|
|
|
|
{
|
|
|
|
MarkUnsupported(GLFeature::depth_texture);
|
|
|
|
}
|
|
|
|
#endif
|
2013-06-05 02:23:40 +04:00
|
|
|
}
|
|
|
|
|
2011-02-12 02:11:30 +03:00
|
|
|
NS_ASSERTION(!IsExtensionSupported(GLContext::ARB_pixel_buffer_object) ||
|
|
|
|
(mSymbols.fMapBuffer && mSymbols.fUnmapBuffer),
|
|
|
|
"ARB_pixel_buffer_object supported without glMapBuffer/UnmapBuffer being available!");
|
|
|
|
|
2011-12-15 04:57:09 +04:00
|
|
|
if (SupportsRobustness()) {
|
2013-08-24 03:33:42 +04:00
|
|
|
mHasRobustness = false;
|
|
|
|
|
2011-12-15 04:57:09 +04:00
|
|
|
if (IsExtensionSupported(ARB_robustness)) {
|
|
|
|
SymLoadStruct robustnessSymbols[] = {
|
2012-07-30 18:20:58 +04:00
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetGraphicsResetStatus, { "GetGraphicsResetStatusARB", nullptr } },
|
2014-05-14 04:18:42 +04:00
|
|
|
END_SYMBOLS
|
2011-12-15 04:57:09 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
if (!LoadSymbols(&robustnessSymbols[0], trygl, prefix)) {
|
2012-03-30 00:47:20 +04:00
|
|
|
NS_ERROR("GL supports ARB_robustness without supplying GetGraphicsResetStatusARB.");
|
2012-04-05 05:44:55 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
mSymbols.fGetGraphicsResetStatus = nullptr;
|
2011-12-15 04:57:09 +04:00
|
|
|
} else {
|
|
|
|
mHasRobustness = true;
|
|
|
|
}
|
2012-04-05 05:44:55 +04:00
|
|
|
}
|
|
|
|
if (!IsExtensionSupported(ARB_robustness) &&
|
|
|
|
IsExtensionSupported(EXT_robustness)) {
|
2011-12-15 04:57:09 +04:00
|
|
|
SymLoadStruct robustnessSymbols[] = {
|
2012-07-30 18:20:58 +04:00
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetGraphicsResetStatus, { "GetGraphicsResetStatusEXT", nullptr } },
|
2014-05-14 04:18:42 +04:00
|
|
|
END_SYMBOLS
|
2011-12-15 04:57:09 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
if (!LoadSymbols(&robustnessSymbols[0], trygl, prefix)) {
|
2012-04-05 05:44:55 +04:00
|
|
|
NS_ERROR("GL supports EXT_robustness without supplying GetGraphicsResetStatusEXT.");
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
mSymbols.fGetGraphicsResetStatus = nullptr;
|
2011-12-15 04:57:09 +04:00
|
|
|
} else {
|
|
|
|
mHasRobustness = true;
|
|
|
|
}
|
2011-11-19 07:57:29 +04:00
|
|
|
}
|
2013-08-24 03:33:42 +04:00
|
|
|
|
|
|
|
if (!mHasRobustness) {
|
|
|
|
MarkUnsupported(GLFeature::robustness);
|
|
|
|
}
|
2011-11-19 07:57:29 +04:00
|
|
|
}
|
|
|
|
|
2011-10-19 23:09:57 +04:00
|
|
|
// Check for aux symbols based on extensions
|
2013-08-22 21:42:05 +04:00
|
|
|
if (IsSupported(GLFeature::framebuffer_blit))
|
2012-04-05 05:44:55 +04:00
|
|
|
{
|
2014-05-14 04:18:42 +04:00
|
|
|
SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBlitFramebuffer, { "BlitFramebuffer", nullptr } },
|
|
|
|
END_SYMBOLS
|
2011-10-19 23:09:57 +04:00
|
|
|
};
|
2014-05-14 04:18:42 +04:00
|
|
|
|
|
|
|
SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBlitFramebuffer, { "BlitFramebufferEXT", "BlitFramebufferANGLE", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
|
|
|
|
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::framebuffer_blit);
|
|
|
|
|
|
|
|
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
|
2012-03-30 00:47:20 +04:00
|
|
|
NS_ERROR("GL supports framebuffer_blit without supplying glBlitFramebuffer");
|
2012-04-05 05:44:55 +04:00
|
|
|
|
2013-08-22 21:42:05 +04:00
|
|
|
MarkUnsupported(GLFeature::framebuffer_blit);
|
2014-05-14 04:18:42 +04:00
|
|
|
ClearSymbols(coreSymbols);
|
2011-10-19 23:09:57 +04:00
|
|
|
}
|
|
|
|
}
|
2011-10-19 23:09:57 +04:00
|
|
|
|
2013-08-22 21:42:05 +04:00
|
|
|
if (IsSupported(GLFeature::framebuffer_multisample))
|
2012-04-05 05:44:55 +04:00
|
|
|
{
|
2014-05-14 04:18:42 +04:00
|
|
|
SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fRenderbufferStorageMultisample, { "RenderbufferStorageMultisample", nullptr } },
|
|
|
|
END_SYMBOLS
|
2011-10-19 23:09:57 +04:00
|
|
|
};
|
2014-05-14 04:18:42 +04:00
|
|
|
|
|
|
|
SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fRenderbufferStorageMultisample, { "RenderbufferStorageMultisampleEXT", "RenderbufferStorageMultisampleANGLE", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
|
|
|
|
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::framebuffer_multisample);
|
|
|
|
|
|
|
|
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
|
2012-03-30 00:47:20 +04:00
|
|
|
NS_ERROR("GL supports framebuffer_multisample without supplying glRenderbufferStorageMultisample");
|
2012-04-05 05:44:55 +04:00
|
|
|
|
2013-08-22 21:42:05 +04:00
|
|
|
MarkUnsupported(GLFeature::framebuffer_multisample);
|
2014-05-14 04:18:42 +04:00
|
|
|
ClearSymbols(coreSymbols);
|
2011-10-19 23:09:57 +04:00
|
|
|
}
|
|
|
|
}
|
2012-04-07 03:57:55 +04:00
|
|
|
|
|
|
|
if (IsExtensionSupported(ARB_sync)) {
|
|
|
|
SymLoadStruct syncSymbols[] = {
|
2012-07-30 18:20:58 +04:00
|
|
|
{ (PRFuncPtr*) &mSymbols.fFenceSync, { "FenceSync", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fIsSync, { "IsSync", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDeleteSync, { "DeleteSync", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fClientWaitSync, { "ClientWaitSync", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fWaitSync, { "WaitSync", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetInteger64v, { "GetInteger64v", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetSynciv, { "GetSynciv", nullptr } },
|
2014-05-14 04:18:42 +04:00
|
|
|
END_SYMBOLS
|
2012-04-07 03:57:55 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
if (!LoadSymbols(&syncSymbols[0], trygl, prefix)) {
|
|
|
|
NS_ERROR("GL supports ARB_sync without supplying its functions.");
|
|
|
|
|
|
|
|
MarkExtensionUnsupported(ARB_sync);
|
2014-05-14 04:18:42 +04:00
|
|
|
ClearSymbols(syncSymbols);
|
2012-04-07 03:57:55 +04:00
|
|
|
}
|
|
|
|
}
|
2012-06-13 01:36:10 +04:00
|
|
|
|
|
|
|
if (IsExtensionSupported(OES_EGL_image)) {
|
2014-05-14 04:18:42 +04:00
|
|
|
SymLoadStruct extSymbols[] = {
|
2012-07-30 18:20:58 +04:00
|
|
|
{ (PRFuncPtr*) &mSymbols.fEGLImageTargetTexture2D, { "EGLImageTargetTexture2DOES", nullptr } },
|
2013-02-14 03:26:24 +04:00
|
|
|
{ (PRFuncPtr*) &mSymbols.fEGLImageTargetRenderbufferStorage, { "EGLImageTargetRenderbufferStorageOES", nullptr } },
|
2014-05-14 04:18:42 +04:00
|
|
|
END_SYMBOLS
|
2012-06-13 01:36:10 +04:00
|
|
|
};
|
|
|
|
|
2014-05-14 04:18:42 +04:00
|
|
|
if (!LoadSymbols(extSymbols, trygl, prefix)) {
|
2012-06-15 02:39:57 +04:00
|
|
|
NS_ERROR("GL supports OES_EGL_image without supplying its functions.");
|
2012-06-13 01:36:10 +04:00
|
|
|
|
|
|
|
MarkExtensionUnsupported(OES_EGL_image);
|
2014-05-14 04:18:42 +04:00
|
|
|
ClearSymbols(extSymbols);
|
2012-06-13 01:36:10 +04:00
|
|
|
}
|
|
|
|
}
|
2013-05-22 11:05:38 +04:00
|
|
|
|
2013-12-12 22:27:10 +04:00
|
|
|
if (IsExtensionSupported(APPLE_texture_range)) {
|
2014-05-14 04:18:42 +04:00
|
|
|
SymLoadStruct extSymbols[] = {
|
2013-12-12 22:27:10 +04:00
|
|
|
{ (PRFuncPtr*) &mSymbols.fTextureRangeAPPLE, { "TextureRangeAPPLE", nullptr } },
|
2014-05-14 04:18:42 +04:00
|
|
|
END_SYMBOLS
|
2013-12-12 22:27:10 +04:00
|
|
|
};
|
|
|
|
|
2014-05-14 04:18:42 +04:00
|
|
|
if (!LoadSymbols(extSymbols, trygl, prefix)) {
|
|
|
|
NS_ERROR("GL supports APPLE_texture_range without supplying its functions.");
|
|
|
|
|
|
|
|
ClearSymbols(extSymbols);
|
2013-12-12 22:27:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-14 04:18:42 +04:00
|
|
|
if (IsSupported(GLFeature::vertex_array_object)) {
|
|
|
|
SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fIsVertexArray, { "IsVertexArray", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGenVertexArrays, { "GenVertexArrays", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindVertexArray, { "BindVertexArray", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDeleteVertexArrays, { "DeleteVertexArrays", nullptr } },
|
|
|
|
END_SYMBOLS
|
2013-06-18 00:17:59 +04:00
|
|
|
};
|
|
|
|
|
2014-05-14 04:18:42 +04:00
|
|
|
SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fIsVertexArray, { "IsVertexArrayARB", "IsVertexArrayOES", "IsVertexArrayAPPLE", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGenVertexArrays, { "GenVertexArraysARB", "GenVertexArraysOES", "GenVertexArraysAPPLE", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindVertexArray, { "BindVertexArrayARB", "BindVertexArrayOES", "BindVertexArrayAPPLE", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDeleteVertexArrays, { "DeleteVertexArraysARB", "DeleteVertexArraysOES", "DeleteVertexArraysAPPLE", nullptr } },
|
|
|
|
END_SYMBOLS
|
2013-06-28 01:07:21 +04:00
|
|
|
};
|
|
|
|
|
2014-05-14 04:18:42 +04:00
|
|
|
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::vertex_array_object);
|
|
|
|
|
|
|
|
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
|
2013-06-28 01:07:21 +04:00
|
|
|
NS_ERROR("GL supports Vertex Array Object without supplying its functions.");
|
|
|
|
|
2013-08-22 21:42:05 +04:00
|
|
|
MarkUnsupported(GLFeature::vertex_array_object);
|
2014-05-14 04:18:42 +04:00
|
|
|
ClearSymbols(coreSymbols);
|
2013-06-18 00:17:59 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-22 21:42:05 +04:00
|
|
|
if (IsSupported(GLFeature::draw_instanced)) {
|
2014-05-14 04:18:42 +04:00
|
|
|
SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawArraysInstanced, { "DrawArraysInstanced", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawElementsInstanced, { "DrawElementsInstanced", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
|
|
|
|
SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawArraysInstanced, { "DrawArraysInstancedARB", "DrawArraysInstancedEXT", "DrawArraysInstancedNV", "DrawArraysInstancedANGLE", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawElementsInstanced, { "DrawElementsInstancedARB", "DrawElementsInstancedEXT", "DrawElementsInstancedNV", "DrawElementsInstancedANGLE", nullptr }
|
2013-07-26 04:38:58 +04:00
|
|
|
},
|
2014-05-14 04:18:42 +04:00
|
|
|
END_SYMBOLS
|
2013-07-26 04:38:58 +04:00
|
|
|
};
|
|
|
|
|
2014-05-14 04:18:42 +04:00
|
|
|
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::draw_instanced);
|
|
|
|
|
|
|
|
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
|
2013-07-26 04:38:58 +04:00
|
|
|
NS_ERROR("GL supports instanced draws without supplying its functions.");
|
|
|
|
|
2013-08-22 21:42:05 +04:00
|
|
|
MarkUnsupported(GLFeature::draw_instanced);
|
2014-05-14 04:18:42 +04:00
|
|
|
ClearSymbols(coreSymbols);
|
2013-07-26 04:38:58 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-22 21:42:05 +04:00
|
|
|
if (IsSupported(GLFeature::instanced_arrays)) {
|
2014-05-14 04:18:42 +04:00
|
|
|
SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexAttribDivisor, { "VertexAttribDivisor", nullptr } },
|
|
|
|
END_SYMBOLS
|
2013-08-07 04:05:51 +04:00
|
|
|
};
|
|
|
|
|
2014-05-14 04:18:42 +04:00
|
|
|
SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexAttribDivisor, { "VertexAttribDivisorARB", "VertexAttribDivisorNV", "VertexAttribDivisorANGLE", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
|
|
|
|
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::instanced_arrays);
|
|
|
|
|
|
|
|
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
|
2013-08-07 04:05:51 +04:00
|
|
|
NS_ERROR("GL supports array instanced without supplying it function.");
|
|
|
|
|
2013-08-24 03:33:42 +04:00
|
|
|
MarkUnsupported(GLFeature::instanced_arrays);
|
2014-05-14 04:18:42 +04:00
|
|
|
ClearSymbols(coreSymbols);
|
2013-08-07 04:05:51 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-22 21:42:05 +04:00
|
|
|
if (IsSupported(GLFeature::transform_feedback)) {
|
2014-05-14 04:18:42 +04:00
|
|
|
SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindBufferBase, { "BindBufferBase", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindBufferRange, { "BindBufferRange", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBeginTransformFeedback, { "BeginTransformFeedback", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fEndTransformFeedback, { "EndTransformFeedback", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTransformFeedbackVaryings, { "TransformFeedbackVaryings", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetTransformFeedbackVarying, { "GetTransformFeedbackVarying", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetIntegeri_v, { "GetIntegeri_v", nullptr } },
|
|
|
|
END_SYMBOLS
|
2013-08-20 19:36:20 +04:00
|
|
|
};
|
|
|
|
|
2014-05-14 04:18:42 +04:00
|
|
|
SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindBufferBase, { "BindBufferBaseEXT", "BindBufferBaseNV", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindBufferRange, { "BindBufferRangeEXT", "BindBufferRangeNV", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBeginTransformFeedback, { "BeginTransformFeedbackEXT", "BeginTransformFeedbackNV", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fEndTransformFeedback, { "EndTransformFeedbackEXT", "EndTransformFeedbackNV", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTransformFeedbackVaryings, { "TransformFeedbackVaryingsEXT", "TransformFeedbackVaryingsNV", nullptr }},
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetTransformFeedbackVarying, { "GetTransformFeedbackVaryingEXT", "GetTransformFeedbackVaryingNV", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetIntegeri_v, { "GetIntegerIndexedvEXT", "GetIntegerIndexedvNV", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
|
|
|
|
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::transform_feedback);
|
|
|
|
|
|
|
|
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
|
2013-08-20 19:36:20 +04:00
|
|
|
NS_ERROR("GL supports transform feedback without supplying its functions.");
|
|
|
|
|
2013-08-22 21:42:05 +04:00
|
|
|
MarkUnsupported(GLFeature::transform_feedback);
|
|
|
|
MarkUnsupported(GLFeature::bind_buffer_offset);
|
2014-05-14 04:18:42 +04:00
|
|
|
ClearSymbols(coreSymbols);
|
2013-08-20 19:36:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-22 21:42:05 +04:00
|
|
|
if (IsSupported(GLFeature::bind_buffer_offset)) {
|
2014-05-14 04:18:42 +04:00
|
|
|
SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindBufferOffset, { "BindBufferOffset", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
|
|
|
|
SymLoadStruct extSymbols[] = {
|
2013-08-20 19:36:20 +04:00
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindBufferOffset,
|
2014-05-14 04:18:42 +04:00
|
|
|
{ "BindBufferOffsetEXT", "BindBufferOffsetNV", nullptr }
|
2013-08-20 19:36:20 +04:00
|
|
|
},
|
2014-05-14 04:18:42 +04:00
|
|
|
END_SYMBOLS
|
2013-08-20 19:36:20 +04:00
|
|
|
};
|
|
|
|
|
2014-05-14 04:18:42 +04:00
|
|
|
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::bind_buffer_offset);
|
|
|
|
|
|
|
|
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
|
2013-08-20 19:36:20 +04:00
|
|
|
NS_ERROR("GL supports BindBufferOffset without supplying its function.");
|
|
|
|
|
2013-08-22 21:42:05 +04:00
|
|
|
MarkUnsupported(GLFeature::bind_buffer_offset);
|
2014-05-14 04:18:42 +04:00
|
|
|
ClearSymbols(coreSymbols);
|
2013-08-20 19:36:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-22 21:42:05 +04:00
|
|
|
if (IsSupported(GLFeature::query_objects)) {
|
2014-05-14 04:18:42 +04:00
|
|
|
SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBeginQuery, { "BeginQuery", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGenQueries, { "GenQueries", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDeleteQueries, { "DeleteQueries", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fEndQuery, { "EndQuery", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetQueryiv, { "GetQueryiv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetQueryObjectuiv, { "GetQueryObjectuiv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fIsQuery, { "IsQuery", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
|
|
|
|
SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBeginQuery, { "BeginQueryEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGenQueries, { "GenQueriesEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDeleteQueries, { "DeleteQueriesEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fEndQuery, { "EndQueryEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetQueryiv, { "GetQueryivEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetQueryObjectuiv, { "GetQueryObjectuivEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fIsQuery, { "IsQueryEXT", nullptr } },
|
|
|
|
END_SYMBOLS
|
2013-08-07 01:23:46 +04:00
|
|
|
};
|
|
|
|
|
2014-05-14 04:18:42 +04:00
|
|
|
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::query_objects);
|
|
|
|
|
|
|
|
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
|
2013-08-15 23:58:20 +04:00
|
|
|
NS_ERROR("GL supports query objects without supplying its functions.");
|
2013-08-07 01:23:46 +04:00
|
|
|
|
2013-08-24 03:33:42 +04:00
|
|
|
MarkUnsupported(GLFeature::query_objects);
|
|
|
|
MarkUnsupported(GLFeature::get_query_object_iv);
|
|
|
|
MarkUnsupported(GLFeature::occlusion_query);
|
2013-08-22 21:42:05 +04:00
|
|
|
MarkUnsupported(GLFeature::occlusion_query_boolean);
|
|
|
|
MarkUnsupported(GLFeature::occlusion_query2);
|
2014-05-14 04:18:42 +04:00
|
|
|
ClearSymbols(coreSymbols);
|
2013-08-07 01:23:46 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-22 21:42:05 +04:00
|
|
|
if (IsSupported(GLFeature::get_query_object_iv)) {
|
2014-05-14 04:18:42 +04:00
|
|
|
SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetQueryObjectiv, { "GetQueryObjectiv", nullptr } },
|
|
|
|
END_SYMBOLS
|
2013-08-15 23:58:20 +04:00
|
|
|
};
|
|
|
|
|
2014-05-14 04:18:42 +04:00
|
|
|
SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetQueryObjectiv, { "GetQueryObjectivEXT", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
|
|
|
|
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::get_query_object_iv);
|
|
|
|
|
|
|
|
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
|
2013-08-15 23:58:20 +04:00
|
|
|
NS_ERROR("GL supports query objects iv getter without supplying its function.");
|
|
|
|
|
2013-08-24 03:33:42 +04:00
|
|
|
MarkUnsupported(GLFeature::get_query_object_iv);
|
2014-05-14 04:18:42 +04:00
|
|
|
ClearSymbols(coreSymbols);
|
2013-08-15 23:58:20 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-11 07:14:17 +04:00
|
|
|
if (IsSupported(GLFeature::draw_buffers)) {
|
2014-05-14 04:18:42 +04:00
|
|
|
SymLoadStruct coreSymbols[] = {
|
2014-01-11 07:14:17 +04:00
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawBuffers, { "DrawBuffers", nullptr } },
|
2014-05-14 04:18:42 +04:00
|
|
|
END_SYMBOLS
|
2014-01-11 07:14:17 +04:00
|
|
|
};
|
|
|
|
|
2014-05-14 04:18:42 +04:00
|
|
|
SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawBuffers, { "DrawBuffersARB", "DrawBuffersEXT", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
|
|
|
|
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::draw_buffers);
|
|
|
|
|
|
|
|
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
|
2014-01-11 07:14:17 +04:00
|
|
|
NS_ERROR("GL supports draw_buffers without supplying its functions.");
|
|
|
|
|
|
|
|
MarkUnsupported(GLFeature::draw_buffers);
|
2014-05-14 04:18:42 +04:00
|
|
|
ClearSymbols(coreSymbols);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsSupported(GLFeature::draw_range_elements)) {
|
|
|
|
SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawRangeElements, { "DrawRangeElements", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
|
|
|
|
SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawRangeElements, { "DrawRangeElementsEXT", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
|
|
|
|
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::draw_range_elements);
|
|
|
|
|
|
|
|
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
|
|
|
|
NS_ERROR("GL supports draw_range_elements without supplying its functions.");
|
|
|
|
|
|
|
|
MarkUnsupported(GLFeature::draw_range_elements);
|
|
|
|
ClearSymbols(coreSymbols);
|
2014-01-11 07:14:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-09 03:20:24 +04:00
|
|
|
if (IsExtensionSupported(KHR_debug)) {
|
|
|
|
SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDebugMessageControl, { "DebugMessageControl", "DebugMessageControlKHR", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDebugMessageInsert, { "DebugMessageInsert", "DebugMessageInsertKHR", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDebugMessageCallback, { "DebugMessageCallback", "DebugMessageCallbackKHR", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetDebugMessageLog, { "GetDebugMessageLog", "GetDebugMessageLogKHR", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetPointerv, { "GetPointerv", "GetPointervKHR", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fPushDebugGroup, { "PushDebugGroup", "PushDebugGroupKHR", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fPopDebugGroup, { "PopDebugGroup", "PopDebugGroupKHR", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fObjectLabel, { "ObjectLabel", "ObjectLabelKHR", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetObjectLabel, { "GetObjectLabel", "GetObjectLabelKHR", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fObjectPtrLabel, { "ObjectPtrLabel", "ObjectPtrLabelKHR", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetObjectPtrLabel, { "GetObjectPtrLabel", "GetObjectPtrLabelKHR", nullptr } },
|
2014-05-14 04:18:42 +04:00
|
|
|
END_SYMBOLS
|
2013-10-09 03:20:24 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
if (!LoadSymbols(&extSymbols[0], trygl, prefix)) {
|
|
|
|
NS_ERROR("GL supports KHR_debug without supplying its functions.");
|
|
|
|
|
|
|
|
MarkExtensionUnsupported(KHR_debug);
|
2014-05-14 04:18:42 +04:00
|
|
|
ClearSymbols(extSymbols);
|
2014-03-17 18:50:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-05 09:09:20 +04:00
|
|
|
if (IsExtensionSupported(NV_fence)) {
|
|
|
|
SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGenFences, { "GenFencesNV", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDeleteFences, { "DeleteFencesNV", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fSetFence, { "SetFenceNV", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTestFence, { "TestFenceNV", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fFinishFence, { "FinishFenceNV", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fIsFence, { "IsFenceNV", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetFenceiv, { "GetFenceivNV", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!LoadSymbols(&extSymbols[0], trygl, prefix)) {
|
|
|
|
NS_ERROR("GL supports NV_fence without supplying its functions.");
|
|
|
|
|
|
|
|
MarkExtensionUnsupported(NV_fence);
|
|
|
|
ClearSymbols(extSymbols);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-05 22:09:05 +04:00
|
|
|
// Load developer symbols, don't fail if we can't find them.
|
|
|
|
SymLoadStruct auxSymbols[] = {
|
2012-07-30 18:20:58 +04:00
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetTexImage, { "GetTexImage", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetTexLevelParameteriv, { "GetTexLevelParameteriv", nullptr } },
|
2014-05-14 04:18:42 +04:00
|
|
|
END_SYMBOLS
|
2012-03-05 22:09:05 +04:00
|
|
|
};
|
2012-12-19 11:16:02 +04:00
|
|
|
bool warnOnFailures = DebugMode();
|
|
|
|
LoadSymbols(&auxSymbols[0], trygl, prefix, warnOnFailures);
|
2011-10-19 23:09:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mInitialized) {
|
2014-01-08 00:02:18 +04:00
|
|
|
raw_fGetIntegerv(LOCAL_GL_VIEWPORT, mViewportRect);
|
2014-01-08 00:02:19 +04:00
|
|
|
raw_fGetIntegerv(LOCAL_GL_SCISSOR_BOX, mScissorRect);
|
2012-11-14 02:35:35 +04:00
|
|
|
raw_fGetIntegerv(LOCAL_GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
|
|
|
|
raw_fGetIntegerv(LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE, &mMaxCubeMapTextureSize);
|
|
|
|
raw_fGetIntegerv(LOCAL_GL_MAX_RENDERBUFFER_SIZE, &mMaxRenderbufferSize);
|
2014-08-28 03:16:22 +04:00
|
|
|
raw_fGetIntegerv(LOCAL_GL_MAX_VIEWPORT_DIMS, mMaxViewportDims);
|
2012-03-26 20:15:53 +04:00
|
|
|
|
|
|
|
#ifdef XP_MACOSX
|
2013-06-17 06:46:53 +04:00
|
|
|
if (mWorkAroundDriverBugs) {
|
2014-01-10 22:55:23 +04:00
|
|
|
if (mVendor == GLVendor::Intel) {
|
2013-07-12 01:07:11 +04:00
|
|
|
// see bug 737182 for 2D textures, bug 684882 for cube map textures.
|
|
|
|
mMaxTextureSize = std::min(mMaxTextureSize, 4096);
|
2013-06-17 06:46:53 +04:00
|
|
|
mMaxCubeMapTextureSize = std::min(mMaxCubeMapTextureSize, 512);
|
2013-07-12 01:07:11 +04:00
|
|
|
// for good measure, we align renderbuffers on what we do for 2D textures
|
|
|
|
mMaxRenderbufferSize = std::min(mMaxRenderbufferSize, 4096);
|
2013-06-17 06:46:53 +04:00
|
|
|
mNeedsTextureSizeChecks = true;
|
2014-01-10 22:55:23 +04:00
|
|
|
} else if (mVendor == GLVendor::NVIDIA) {
|
2013-12-19 20:42:19 +04:00
|
|
|
if (nsCocoaFeatures::OnMountainLionOrLater()) {
|
2013-07-10 01:35:32 +04:00
|
|
|
// See bug 879656. 8192 fails, 8191 works.
|
|
|
|
mMaxTextureSize = std::min(mMaxTextureSize, 8191);
|
|
|
|
mMaxRenderbufferSize = std::min(mMaxRenderbufferSize, 8191);
|
2014-08-28 03:16:22 +04:00
|
|
|
} else {
|
2013-12-19 20:42:19 +04:00
|
|
|
// See bug 877949.
|
|
|
|
mMaxTextureSize = std::min(mMaxTextureSize, 4096);
|
|
|
|
mMaxRenderbufferSize = std::min(mMaxRenderbufferSize, 4096);
|
|
|
|
}
|
2014-02-28 10:57:03 +04:00
|
|
|
|
2013-07-10 01:35:32 +04:00
|
|
|
// Part of the bug 879656, but it also doesn't hurt the 877949
|
|
|
|
mNeedsTextureSizeChecks = true;
|
2013-06-17 06:46:53 +04:00
|
|
|
}
|
2012-11-27 03:21:39 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef MOZ_X11
|
|
|
|
if (mWorkAroundDriverBugs &&
|
2014-01-10 22:55:23 +04:00
|
|
|
mVendor == GLVendor::Nouveau) {
|
2012-11-27 03:21:39 +04:00
|
|
|
// see bug 814716. Clamp MaxCubeMapTextureSize at 2K for Nouveau.
|
2013-01-15 16:22:03 +04:00
|
|
|
mMaxCubeMapTextureSize = std::min(mMaxCubeMapTextureSize, 2048);
|
2012-11-27 03:21:39 +04:00
|
|
|
mNeedsTextureSizeChecks = true;
|
2012-03-26 20:15:53 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-10-27 01:36:18 +04:00
|
|
|
mMaxTextureImageSize = mMaxTextureSize;
|
2011-02-12 02:11:30 +03:00
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
mMaxSamples = 0;
|
2013-08-22 21:42:05 +04:00
|
|
|
if (IsSupported(GLFeature::framebuffer_multisample)) {
|
2013-02-14 03:26:24 +04:00
|
|
|
fGetIntegerv(LOCAL_GL_MAX_SAMPLES, (GLint*)&mMaxSamples);
|
|
|
|
}
|
|
|
|
|
|
|
|
// We're ready for final setup.
|
2013-03-05 04:44:31 +04:00
|
|
|
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
|
2013-02-14 03:26:24 +04:00
|
|
|
|
|
|
|
if (mCaps.any)
|
|
|
|
DetermineCaps();
|
|
|
|
|
|
|
|
UpdatePixelFormat();
|
|
|
|
UpdateGLFormats(mCaps);
|
|
|
|
|
|
|
|
mTexGarbageBin = new TextureGarbageBin(this);
|
|
|
|
|
|
|
|
MOZ_ASSERT(IsCurrent());
|
2014-05-07 00:59:18 +04:00
|
|
|
|
|
|
|
if (DebugMode() && IsExtensionSupported(KHR_debug)) {
|
|
|
|
fEnable(LOCAL_GL_DEBUG_OUTPUT);
|
|
|
|
fDisable(LOCAL_GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
|
|
|
fDebugMessageCallback(&StaticDebugCallback, (void*)this);
|
|
|
|
fDebugMessageControl(LOCAL_GL_DONT_CARE,
|
|
|
|
LOCAL_GL_DONT_CARE,
|
|
|
|
LOCAL_GL_DONT_CARE,
|
|
|
|
0, nullptr,
|
|
|
|
true);
|
|
|
|
}
|
2010-08-07 09:09:18 +04:00
|
|
|
|
2011-03-02 23:50:36 +03:00
|
|
|
reporter.SetSuccessful();
|
2014-05-22 06:03:09 +04:00
|
|
|
} else {
|
2011-03-02 23:50:36 +03:00
|
|
|
// if initialization fails, ensure all symbols are zero, to avoid hard-to-understand bugs
|
|
|
|
mSymbols.Zero();
|
2012-03-13 02:10:38 +04:00
|
|
|
NS_WARNING("InitWithPrefix failed!");
|
2011-03-02 23:50:36 +03:00
|
|
|
}
|
2011-01-06 17:59:28 +03:00
|
|
|
|
2013-08-03 01:30:58 +04:00
|
|
|
mVersionString = nsPrintfCString("%u.%u.%u", mVersion / 100, (mVersion / 10) % 10, mVersion % 10);
|
|
|
|
|
2010-04-27 06:09:44 +04:00
|
|
|
return mInitialized;
|
|
|
|
}
|
|
|
|
|
2014-05-07 00:59:18 +04:00
|
|
|
void
|
|
|
|
GLContext::DebugCallback(GLenum source,
|
|
|
|
GLenum type,
|
|
|
|
GLuint id,
|
|
|
|
GLenum severity,
|
|
|
|
GLsizei length,
|
|
|
|
const GLchar* message)
|
|
|
|
{
|
|
|
|
nsAutoCString sourceStr;
|
|
|
|
switch (source) {
|
|
|
|
case LOCAL_GL_DEBUG_SOURCE_API:
|
|
|
|
sourceStr = NS_LITERAL_CSTRING("SOURCE_API");
|
|
|
|
break;
|
|
|
|
case LOCAL_GL_DEBUG_SOURCE_WINDOW_SYSTEM:
|
|
|
|
sourceStr = NS_LITERAL_CSTRING("SOURCE_WINDOW_SYSTEM");
|
|
|
|
break;
|
|
|
|
case LOCAL_GL_DEBUG_SOURCE_SHADER_COMPILER:
|
|
|
|
sourceStr = NS_LITERAL_CSTRING("SOURCE_SHADER_COMPILER");
|
|
|
|
break;
|
|
|
|
case LOCAL_GL_DEBUG_SOURCE_THIRD_PARTY:
|
|
|
|
sourceStr = NS_LITERAL_CSTRING("SOURCE_THIRD_PARTY");
|
|
|
|
break;
|
|
|
|
case LOCAL_GL_DEBUG_SOURCE_APPLICATION:
|
|
|
|
sourceStr = NS_LITERAL_CSTRING("SOURCE_APPLICATION");
|
|
|
|
break;
|
|
|
|
case LOCAL_GL_DEBUG_SOURCE_OTHER:
|
|
|
|
sourceStr = NS_LITERAL_CSTRING("SOURCE_OTHER");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sourceStr = nsPrintfCString("<source 0x%04x>", source);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoCString typeStr;
|
|
|
|
switch (type) {
|
|
|
|
case LOCAL_GL_DEBUG_TYPE_ERROR:
|
|
|
|
typeStr = NS_LITERAL_CSTRING("TYPE_ERROR");
|
|
|
|
break;
|
|
|
|
case LOCAL_GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
|
|
|
|
typeStr = NS_LITERAL_CSTRING("TYPE_DEPRECATED_BEHAVIOR");
|
|
|
|
break;
|
|
|
|
case LOCAL_GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
|
|
|
|
typeStr = NS_LITERAL_CSTRING("TYPE_UNDEFINED_BEHAVIOR");
|
|
|
|
break;
|
|
|
|
case LOCAL_GL_DEBUG_TYPE_PORTABILITY:
|
|
|
|
typeStr = NS_LITERAL_CSTRING("TYPE_PORTABILITY");
|
|
|
|
break;
|
|
|
|
case LOCAL_GL_DEBUG_TYPE_PERFORMANCE:
|
|
|
|
typeStr = NS_LITERAL_CSTRING("TYPE_PERFORMANCE");
|
|
|
|
break;
|
|
|
|
case LOCAL_GL_DEBUG_TYPE_OTHER:
|
|
|
|
typeStr = NS_LITERAL_CSTRING("TYPE_OTHER");
|
|
|
|
break;
|
|
|
|
case LOCAL_GL_DEBUG_TYPE_MARKER:
|
|
|
|
typeStr = NS_LITERAL_CSTRING("TYPE_MARKER");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
typeStr = nsPrintfCString("<type 0x%04x>", type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoCString sevStr;
|
|
|
|
switch (severity) {
|
|
|
|
case LOCAL_GL_DEBUG_SEVERITY_HIGH:
|
|
|
|
sevStr = NS_LITERAL_CSTRING("SEVERITY_HIGH");
|
|
|
|
break;
|
|
|
|
case LOCAL_GL_DEBUG_SEVERITY_MEDIUM:
|
|
|
|
sevStr = NS_LITERAL_CSTRING("SEVERITY_MEDIUM");
|
|
|
|
break;
|
|
|
|
case LOCAL_GL_DEBUG_SEVERITY_LOW:
|
|
|
|
sevStr = NS_LITERAL_CSTRING("SEVERITY_LOW");
|
|
|
|
break;
|
|
|
|
case LOCAL_GL_DEBUG_SEVERITY_NOTIFICATION:
|
|
|
|
sevStr = NS_LITERAL_CSTRING("SEVERITY_NOTIFICATION");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sevStr = nsPrintfCString("<severity 0x%04x>", severity);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-08-27 01:14:51 +04:00
|
|
|
printf_stderr("[KHR_debug: 0x%" PRIxPTR "] ID %u: %s %s %s:\n %s",
|
2014-05-07 00:59:18 +04:00
|
|
|
(uintptr_t)this,
|
|
|
|
id,
|
|
|
|
sourceStr.BeginReading(),
|
|
|
|
typeStr.BeginReading(),
|
|
|
|
sevStr.BeginReading(),
|
|
|
|
message);
|
|
|
|
}
|
|
|
|
|
2010-08-07 09:09:18 +04:00
|
|
|
void
|
|
|
|
GLContext::InitExtensions()
|
|
|
|
{
|
|
|
|
MakeCurrent();
|
2012-06-13 01:39:18 +04:00
|
|
|
const char* extensions = (const char*)fGetString(LOCAL_GL_EXTENSIONS);
|
2012-02-20 11:04:38 +04:00
|
|
|
if (!extensions)
|
|
|
|
return;
|
|
|
|
|
2010-10-02 08:00:36 +04:00
|
|
|
#ifdef DEBUG
|
2012-07-17 19:26:12 +04:00
|
|
|
static bool firstRun = true;
|
2010-10-02 08:00:36 +04:00
|
|
|
#else
|
2012-06-13 01:39:18 +04:00
|
|
|
// Non-DEBUG, so never spew.
|
2012-07-17 19:26:12 +04:00
|
|
|
const bool firstRun = false;
|
2010-10-02 08:00:36 +04:00
|
|
|
#endif
|
2010-09-06 00:37:52 +04:00
|
|
|
|
2013-09-04 16:14:52 +04:00
|
|
|
InitializeExtensionsBitSet(mAvailableExtensions, extensions, sExtensionNames, firstRun && DebugMode());
|
2010-09-06 00:37:52 +04:00
|
|
|
|
2013-02-23 21:14:11 +04:00
|
|
|
if (WorkAroundDriverBugs() &&
|
2014-01-10 22:55:23 +04:00
|
|
|
Vendor() == GLVendor::Qualcomm) {
|
2013-02-23 21:14:11 +04:00
|
|
|
|
|
|
|
// Some Adreno drivers do not report GL_OES_EGL_sync, but they really do support it.
|
|
|
|
MarkExtensionSupported(OES_EGL_sync);
|
|
|
|
}
|
|
|
|
|
2013-09-06 16:03:08 +04:00
|
|
|
if (WorkAroundDriverBugs() &&
|
2014-01-10 22:55:23 +04:00
|
|
|
Renderer() == GLRenderer::AndroidEmulator) {
|
2013-09-06 16:03:08 +04:00
|
|
|
// the Android emulator, which we use to run B2G reftests on,
|
|
|
|
// doesn't expose the OES_rgb8_rgba8 extension, but it seems to
|
|
|
|
// support it (tautologically, as it only runs on desktop GL).
|
|
|
|
MarkExtensionSupported(OES_rgb8_rgba8);
|
|
|
|
}
|
|
|
|
|
2014-02-28 10:57:03 +04:00
|
|
|
if (WorkAroundDriverBugs() &&
|
|
|
|
Vendor() == GLVendor::VMware &&
|
|
|
|
Renderer() == GLRenderer::GalliumLlvmpipe)
|
|
|
|
{
|
|
|
|
// The llvmpipe driver that is used on linux try servers appears to have
|
|
|
|
// buggy support for s3tc/dxt1 compressed textures.
|
|
|
|
// See Bug 975824.
|
|
|
|
MarkExtensionUnsupported(EXT_texture_compression_s3tc);
|
|
|
|
MarkExtensionUnsupported(EXT_texture_compression_dxt1);
|
|
|
|
MarkExtensionUnsupported(ANGLE_texture_compression_dxt3);
|
|
|
|
MarkExtensionUnsupported(ANGLE_texture_compression_dxt5);
|
|
|
|
}
|
|
|
|
|
2014-06-16 03:30:04 +04:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
// Bug 1009642: On OSX Mavericks (10.9), the driver for Intel HD
|
|
|
|
// 3000 appears to be buggy WRT updating sub-images of S3TC
|
|
|
|
// textures with glCompressedTexSubImage2D. Works on Intel HD 4000
|
|
|
|
// and Intel HD 5000/Iris that I tested.
|
|
|
|
if (WorkAroundDriverBugs() &&
|
|
|
|
nsCocoaFeatures::OSXVersionMajor() == 10 &&
|
|
|
|
nsCocoaFeatures::OSXVersionMinor() == 9 &&
|
|
|
|
Renderer() == GLRenderer::IntelHD3000)
|
|
|
|
{
|
|
|
|
MarkExtensionUnsupported(EXT_texture_compression_s3tc);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-10-02 08:00:36 +04:00
|
|
|
#ifdef DEBUG
|
2012-07-17 19:26:12 +04:00
|
|
|
firstRun = false;
|
2010-10-02 08:00:36 +04:00
|
|
|
#endif
|
2010-08-07 09:09:18 +04:00
|
|
|
}
|
|
|
|
|
2012-11-07 02:39:38 +04:00
|
|
|
void
|
|
|
|
GLContext::PlatformStartup()
|
|
|
|
{
|
2013-11-07 09:35:30 +04:00
|
|
|
RegisterStrongMemoryReporter(new GfxTexturesReporter());
|
2012-11-07 02:39:38 +04:00
|
|
|
}
|
|
|
|
|
2010-11-10 18:49:52 +03:00
|
|
|
// Common code for checking for both GL extensions and GLX extensions.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2010-11-10 18:49:52 +03:00
|
|
|
GLContext::ListHasExtension(const GLubyte *extensions, const char *extension)
|
|
|
|
{
|
2010-11-18 17:17:19 +03:00
|
|
|
// fix bug 612572 - we were crashing as we were calling this function with extensions==null
|
2012-07-30 18:20:58 +04:00
|
|
|
if (extensions == nullptr || extension == nullptr)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-11-18 17:17:19 +03:00
|
|
|
|
2010-06-15 10:55:08 +04:00
|
|
|
const GLubyte *start;
|
|
|
|
GLubyte *where, *terminator;
|
|
|
|
|
|
|
|
/* Extension names should not have spaces. */
|
|
|
|
where = (GLubyte *) strchr(extension, ' ');
|
|
|
|
if (where || *extension == '\0')
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-06-15 10:55:08 +04:00
|
|
|
|
2013-05-22 11:05:38 +04:00
|
|
|
/*
|
2010-06-15 10:55:08 +04:00
|
|
|
* It takes a bit of care to be fool-proof about parsing the
|
|
|
|
* OpenGL extensions string. Don't be fooled by sub-strings,
|
2013-05-22 11:05:38 +04:00
|
|
|
* etc.
|
2010-06-15 10:55:08 +04:00
|
|
|
*/
|
|
|
|
start = extensions;
|
|
|
|
for (;;) {
|
|
|
|
where = (GLubyte *) strstr((const char *) start, extension);
|
|
|
|
if (!where) {
|
2010-06-15 10:56:29 +04:00
|
|
|
break;
|
2010-06-15 10:55:08 +04:00
|
|
|
}
|
|
|
|
terminator = where + strlen(extension);
|
|
|
|
if (where == start || *(where - 1) == ' ') {
|
2010-06-15 10:56:29 +04:00
|
|
|
if (*terminator == ' ' || *terminator == '\0') {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2010-06-15 10:56:29 +04:00
|
|
|
}
|
2010-06-15 10:55:08 +04:00
|
|
|
}
|
|
|
|
start = terminator;
|
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-06-15 10:55:08 +04:00
|
|
|
}
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
void
|
|
|
|
GLContext::DetermineCaps()
|
|
|
|
{
|
|
|
|
PixelBufferFormat format = QueryPixelFormat();
|
|
|
|
|
|
|
|
SurfaceCaps caps;
|
|
|
|
caps.color = !!format.red && !!format.green && !!format.blue;
|
|
|
|
caps.bpp16 = caps.color && format.ColorBits() == 16;
|
|
|
|
caps.alpha = !!format.alpha;
|
|
|
|
caps.depth = !!format.depth;
|
|
|
|
caps.stencil = !!format.stencil;
|
|
|
|
caps.antialias = format.samples > 1;
|
|
|
|
caps.preserve = true;
|
|
|
|
|
|
|
|
mCaps = caps;
|
|
|
|
}
|
|
|
|
|
|
|
|
PixelBufferFormat
|
|
|
|
GLContext::QueryPixelFormat()
|
|
|
|
{
|
|
|
|
PixelBufferFormat format;
|
|
|
|
|
|
|
|
ScopedBindFramebuffer autoFB(this, 0);
|
|
|
|
|
|
|
|
fGetIntegerv(LOCAL_GL_RED_BITS , &format.red );
|
|
|
|
fGetIntegerv(LOCAL_GL_GREEN_BITS, &format.green);
|
|
|
|
fGetIntegerv(LOCAL_GL_BLUE_BITS , &format.blue );
|
|
|
|
fGetIntegerv(LOCAL_GL_ALPHA_BITS, &format.alpha);
|
|
|
|
|
|
|
|
fGetIntegerv(LOCAL_GL_DEPTH_BITS, &format.depth);
|
|
|
|
fGetIntegerv(LOCAL_GL_STENCIL_BITS, &format.stencil);
|
|
|
|
|
|
|
|
fGetIntegerv(LOCAL_GL_SAMPLES, &format.samples);
|
|
|
|
|
|
|
|
return format;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::UpdatePixelFormat()
|
|
|
|
{
|
|
|
|
PixelBufferFormat format = QueryPixelFormat();
|
|
|
|
#ifdef DEBUG
|
|
|
|
const SurfaceCaps& caps = Caps();
|
2013-04-25 20:35:50 +04:00
|
|
|
MOZ_ASSERT(!caps.any, "Did you forget to DetermineCaps()?");
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
MOZ_ASSERT(caps.color == !!format.red);
|
|
|
|
MOZ_ASSERT(caps.color == !!format.green);
|
|
|
|
MOZ_ASSERT(caps.color == !!format.blue);
|
2013-04-25 20:35:50 +04:00
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
MOZ_ASSERT(caps.alpha == !!format.alpha);
|
2013-06-21 22:22:18 +04:00
|
|
|
|
|
|
|
// These we either must have if they're requested, or
|
|
|
|
// we can have if they're not.
|
|
|
|
MOZ_ASSERT(caps.depth == !!format.depth || !caps.depth);
|
|
|
|
MOZ_ASSERT(caps.stencil == !!format.stencil || !caps.stencil);
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
MOZ_ASSERT(caps.antialias == (format.samples > 1));
|
|
|
|
#endif
|
|
|
|
mPixelFormat = new PixelBufferFormat(format);
|
|
|
|
}
|
|
|
|
|
|
|
|
GLFormats
|
|
|
|
GLContext::ChooseGLFormats(const SurfaceCaps& caps) const
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
2012-04-25 18:10:43 +04:00
|
|
|
GLFormats formats;
|
2011-05-20 23:53:53 +04:00
|
|
|
|
2012-07-06 17:19:27 +04:00
|
|
|
// If we're on ES2 hardware and we have an explicit request for 16 bits of color or less
|
|
|
|
// OR we don't support full 8-bit color, return a 4444 or 565 format.
|
2013-02-14 03:26:24 +04:00
|
|
|
bool bpp16 = caps.bpp16;
|
2014-03-31 13:10:49 +04:00
|
|
|
if (IsGLES()) {
|
2013-02-14 03:26:24 +04:00
|
|
|
if (!IsExtensionSupported(OES_rgb8_rgba8))
|
|
|
|
bpp16 = true;
|
|
|
|
} else {
|
|
|
|
// RGB565 is uncommon on desktop, requiring ARB_ES2_compatibility.
|
|
|
|
// Since it's also vanishingly useless there, let's not support it.
|
|
|
|
bpp16 = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bpp16) {
|
2014-03-31 13:10:49 +04:00
|
|
|
MOZ_ASSERT(IsGLES());
|
2013-02-14 03:26:24 +04:00
|
|
|
if (caps.alpha) {
|
|
|
|
formats.color_texInternalFormat = LOCAL_GL_RGBA;
|
|
|
|
formats.color_texFormat = LOCAL_GL_RGBA;
|
|
|
|
formats.color_texType = LOCAL_GL_UNSIGNED_SHORT_4_4_4_4;
|
|
|
|
formats.color_rbFormat = LOCAL_GL_RGBA4;
|
2012-04-25 18:10:43 +04:00
|
|
|
} else {
|
2013-02-14 03:26:24 +04:00
|
|
|
formats.color_texInternalFormat = LOCAL_GL_RGB;
|
|
|
|
formats.color_texFormat = LOCAL_GL_RGB;
|
|
|
|
formats.color_texType = LOCAL_GL_UNSIGNED_SHORT_5_6_5;
|
|
|
|
formats.color_rbFormat = LOCAL_GL_RGB565;
|
|
|
|
}
|
2012-07-06 17:19:27 +04:00
|
|
|
} else {
|
2013-02-14 03:26:24 +04:00
|
|
|
formats.color_texType = LOCAL_GL_UNSIGNED_BYTE;
|
2012-07-06 17:19:27 +04:00
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
if (caps.alpha) {
|
2014-03-31 13:10:49 +04:00
|
|
|
formats.color_texInternalFormat = IsGLES() ? LOCAL_GL_RGBA : LOCAL_GL_RGBA8;
|
2013-02-14 03:26:24 +04:00
|
|
|
formats.color_texFormat = LOCAL_GL_RGBA;
|
|
|
|
formats.color_rbFormat = LOCAL_GL_RGBA8;
|
2012-04-25 18:10:43 +04:00
|
|
|
} else {
|
2014-03-31 13:10:49 +04:00
|
|
|
formats.color_texInternalFormat = IsGLES() ? LOCAL_GL_RGB : LOCAL_GL_RGB8;
|
2013-02-14 03:26:24 +04:00
|
|
|
formats.color_texFormat = LOCAL_GL_RGB;
|
|
|
|
formats.color_rbFormat = LOCAL_GL_RGB8;
|
2012-04-25 18:10:43 +04:00
|
|
|
}
|
|
|
|
}
|
2011-10-19 23:09:57 +04:00
|
|
|
|
2014-02-23 03:53:04 +04:00
|
|
|
uint32_t msaaLevel = gfxPrefs::MSAALevel();
|
2013-02-14 03:26:24 +04:00
|
|
|
GLsizei samples = msaaLevel * msaaLevel;
|
|
|
|
samples = std::min(samples, mMaxSamples);
|
2011-11-03 18:50:39 +04:00
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
// Bug 778765.
|
2012-08-03 19:08:11 +04:00
|
|
|
if (WorkAroundDriverBugs() && samples == 1) {
|
|
|
|
samples = 0;
|
|
|
|
}
|
2012-04-25 18:10:43 +04:00
|
|
|
formats.samples = samples;
|
2010-07-19 09:01:14 +04:00
|
|
|
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
// Be clear that these are 0 if unavailable.
|
2012-04-25 18:10:43 +04:00
|
|
|
formats.depthStencil = 0;
|
2014-03-31 13:10:49 +04:00
|
|
|
if (!IsGLES() || IsExtensionSupported(OES_packed_depth_stencil)) {
|
2012-04-25 18:10:43 +04:00
|
|
|
formats.depthStencil = LOCAL_GL_DEPTH24_STENCIL8;
|
2013-02-14 03:26:24 +04:00
|
|
|
}
|
2011-10-19 23:09:57 +04:00
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
formats.depth = 0;
|
2014-03-31 13:10:49 +04:00
|
|
|
if (IsGLES()) {
|
2013-02-14 03:26:24 +04:00
|
|
|
if (IsExtensionSupported(OES_depth24)) {
|
|
|
|
formats.depth = LOCAL_GL_DEPTH_COMPONENT24;
|
|
|
|
} else {
|
|
|
|
formats.depth = LOCAL_GL_DEPTH_COMPONENT16;
|
2011-10-19 23:09:57 +04:00
|
|
|
}
|
2013-02-14 03:26:24 +04:00
|
|
|
} else {
|
|
|
|
formats.depth = LOCAL_GL_DEPTH_COMPONENT24;
|
2010-07-19 09:01:14 +04:00
|
|
|
}
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
formats.stencil = LOCAL_GL_STENCIL_INDEX8;
|
|
|
|
|
2012-04-25 18:10:43 +04:00
|
|
|
return formats;
|
|
|
|
}
|
2010-11-17 07:33:03 +03:00
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
bool
|
|
|
|
GLContext::IsFramebufferComplete(GLuint fb, GLenum* pStatus)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(fb);
|
|
|
|
|
|
|
|
ScopedBindFramebuffer autoFB(this, fb);
|
|
|
|
MOZ_ASSERT(fIsFramebuffer(fb));
|
|
|
|
|
|
|
|
GLenum status = fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
|
|
|
|
if (pStatus)
|
|
|
|
*pStatus = status;
|
2013-02-20 19:01:20 +04:00
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
return status == LOCAL_GL_FRAMEBUFFER_COMPLETE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::AttachBuffersToFB(GLuint colorTex, GLuint colorRB,
|
|
|
|
GLuint depthRB, GLuint stencilRB,
|
2013-07-18 07:24:15 +04:00
|
|
|
GLuint fb, GLenum target)
|
2013-02-14 03:26:24 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(fb);
|
|
|
|
MOZ_ASSERT( !(colorTex && colorRB) );
|
|
|
|
|
|
|
|
ScopedBindFramebuffer autoFB(this, fb);
|
|
|
|
MOZ_ASSERT(fIsFramebuffer(fb)); // It only counts after being bound.
|
|
|
|
|
|
|
|
if (colorTex) {
|
|
|
|
MOZ_ASSERT(fIsTexture(colorTex));
|
2013-07-18 07:24:15 +04:00
|
|
|
MOZ_ASSERT(target == LOCAL_GL_TEXTURE_2D ||
|
|
|
|
target == LOCAL_GL_TEXTURE_RECTANGLE_ARB);
|
2013-02-14 03:26:24 +04:00
|
|
|
fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER,
|
|
|
|
LOCAL_GL_COLOR_ATTACHMENT0,
|
2013-07-18 07:24:15 +04:00
|
|
|
target,
|
2013-02-14 03:26:24 +04:00
|
|
|
colorTex,
|
|
|
|
0);
|
|
|
|
} else if (colorRB) {
|
|
|
|
MOZ_ASSERT(fIsRenderbuffer(colorRB));
|
|
|
|
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
|
|
|
LOCAL_GL_COLOR_ATTACHMENT0,
|
|
|
|
LOCAL_GL_RENDERBUFFER,
|
|
|
|
colorRB);
|
2013-02-14 03:26:24 +04:00
|
|
|
}
|
2013-02-21 23:54:25 +04:00
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
if (depthRB) {
|
|
|
|
MOZ_ASSERT(fIsRenderbuffer(depthRB));
|
|
|
|
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
|
|
|
LOCAL_GL_DEPTH_ATTACHMENT,
|
|
|
|
LOCAL_GL_RENDERBUFFER,
|
|
|
|
depthRB);
|
|
|
|
}
|
2013-02-21 23:54:25 +04:00
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
if (stencilRB) {
|
|
|
|
MOZ_ASSERT(fIsRenderbuffer(stencilRB));
|
|
|
|
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
|
|
|
LOCAL_GL_STENCIL_ATTACHMENT,
|
|
|
|
LOCAL_GL_RENDERBUFFER,
|
|
|
|
stencilRB);
|
|
|
|
}
|
2012-04-25 18:10:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-02-14 03:26:24 +04:00
|
|
|
GLContext::AssembleOffscreenFBs(const GLuint colorMSRB,
|
|
|
|
const GLuint depthRB,
|
|
|
|
const GLuint stencilRB,
|
|
|
|
const GLuint texture,
|
|
|
|
GLuint* drawFB_out,
|
|
|
|
GLuint* readFB_out)
|
2012-04-25 18:10:43 +04:00
|
|
|
{
|
|
|
|
if (!colorMSRB && !texture) {
|
|
|
|
MOZ_ASSERT(!depthRB && !stencilRB);
|
2013-02-14 03:26:24 +04:00
|
|
|
|
|
|
|
if (drawFB_out)
|
|
|
|
*drawFB_out = 0;
|
|
|
|
if (readFB_out)
|
|
|
|
*readFB_out = 0;
|
|
|
|
|
2012-04-25 18:10:43 +04:00
|
|
|
return true;
|
2010-07-19 09:01:14 +04:00
|
|
|
}
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
ScopedBindFramebuffer autoFB(this);
|
|
|
|
|
|
|
|
GLuint drawFB = 0;
|
|
|
|
GLuint readFB = 0;
|
2012-04-25 18:10:43 +04:00
|
|
|
|
|
|
|
if (texture) {
|
2013-02-14 03:26:24 +04:00
|
|
|
readFB = 0;
|
|
|
|
fGenFramebuffers(1, &readFB);
|
|
|
|
BindFB(readFB);
|
2012-04-25 18:10:43 +04:00
|
|
|
fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER,
|
|
|
|
LOCAL_GL_COLOR_ATTACHMENT0,
|
|
|
|
LOCAL_GL_TEXTURE_2D,
|
|
|
|
texture,
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (colorMSRB) {
|
2013-02-14 03:26:24 +04:00
|
|
|
drawFB = 0;
|
|
|
|
fGenFramebuffers(1, &drawFB);
|
|
|
|
BindFB(drawFB);
|
2011-10-19 23:09:57 +04:00
|
|
|
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
|
|
|
LOCAL_GL_COLOR_ATTACHMENT0,
|
|
|
|
LOCAL_GL_RENDERBUFFER,
|
2012-04-25 18:10:43 +04:00
|
|
|
colorMSRB);
|
|
|
|
} else {
|
2013-02-14 03:26:24 +04:00
|
|
|
drawFB = readFB;
|
2011-10-19 23:09:57 +04:00
|
|
|
}
|
2013-02-14 03:26:24 +04:00
|
|
|
MOZ_ASSERT(GetFB() == drawFB);
|
2010-07-29 01:24:09 +04:00
|
|
|
|
2012-04-25 18:10:43 +04:00
|
|
|
if (depthRB) {
|
2011-10-19 23:09:57 +04:00
|
|
|
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
|
|
|
LOCAL_GL_DEPTH_ATTACHMENT,
|
|
|
|
LOCAL_GL_RENDERBUFFER,
|
2012-04-25 18:10:43 +04:00
|
|
|
depthRB);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stencilRB) {
|
2011-10-19 23:09:57 +04:00
|
|
|
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
|
|
|
|
LOCAL_GL_STENCIL_ATTACHMENT,
|
|
|
|
LOCAL_GL_RENDERBUFFER,
|
2012-04-25 18:10:43 +04:00
|
|
|
stencilRB);
|
2011-10-19 23:09:57 +04:00
|
|
|
}
|
|
|
|
|
2010-07-19 09:01:14 +04:00
|
|
|
// We should be all resized. Check for framebuffer completeness.
|
2011-10-19 23:09:57 +04:00
|
|
|
GLenum status;
|
2012-04-25 18:10:43 +04:00
|
|
|
bool isComplete = true;
|
2011-10-19 23:09:57 +04:00
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
if (!IsFramebufferComplete(drawFB, &status)) {
|
2011-10-19 23:09:57 +04:00
|
|
|
NS_WARNING("DrawFBO: Incomplete");
|
2012-04-25 18:10:43 +04:00
|
|
|
#ifdef DEBUG
|
2012-06-11 19:25:06 +04:00
|
|
|
if (DebugMode()) {
|
|
|
|
printf_stderr("Framebuffer status: %X\n", status);
|
|
|
|
}
|
2012-04-25 18:10:43 +04:00
|
|
|
#endif
|
|
|
|
isComplete = false;
|
2011-10-19 23:09:57 +04:00
|
|
|
}
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
if (!IsFramebufferComplete(readFB, &status)) {
|
2011-10-19 23:09:57 +04:00
|
|
|
NS_WARNING("ReadFBO: Incomplete");
|
2012-04-25 18:10:43 +04:00
|
|
|
#ifdef DEBUG
|
2012-06-11 19:25:06 +04:00
|
|
|
if (DebugMode()) {
|
|
|
|
printf_stderr("Framebuffer status: %X\n", status);
|
|
|
|
}
|
2012-04-25 18:10:43 +04:00
|
|
|
#endif
|
|
|
|
isComplete = false;
|
2011-10-19 23:09:57 +04:00
|
|
|
}
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
if (drawFB_out) {
|
|
|
|
*drawFB_out = drawFB;
|
|
|
|
} else if (drawFB) {
|
|
|
|
NS_RUNTIMEABORT("drawFB created when not requested!");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (readFB_out) {
|
|
|
|
*readFB_out = readFB;
|
|
|
|
} else if (readFB) {
|
|
|
|
NS_RUNTIMEABORT("readFB created when not requested!");
|
|
|
|
}
|
2011-10-19 23:09:57 +04:00
|
|
|
|
2012-04-25 18:10:43 +04:00
|
|
|
return isComplete;
|
|
|
|
}
|
2011-10-19 23:09:57 +04:00
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
|
|
|
|
|
2012-04-25 18:10:43 +04:00
|
|
|
bool
|
2013-02-14 03:26:24 +04:00
|
|
|
GLContext::PublishFrame()
|
2012-04-25 18:10:43 +04:00
|
|
|
{
|
2013-02-14 03:26:24 +04:00
|
|
|
MOZ_ASSERT(mScreen);
|
2011-10-19 23:09:57 +04:00
|
|
|
|
2014-07-12 02:10:49 +04:00
|
|
|
return mScreen->PublishFrame(OffscreenSize());
|
2010-07-19 09:01:14 +04:00
|
|
|
}
|
|
|
|
|
2014-07-12 02:10:49 +04:00
|
|
|
SharedSurface*
|
2013-02-14 03:26:24 +04:00
|
|
|
GLContext::RequestFrame()
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
2013-02-14 03:26:24 +04:00
|
|
|
MOZ_ASSERT(mScreen);
|
2010-07-19 09:01:14 +04:00
|
|
|
|
2014-07-12 02:10:49 +04:00
|
|
|
return mScreen->Stream()->SwapConsumer();
|
2010-07-19 09:01:14 +04:00
|
|
|
}
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
|
|
|
|
|
2010-07-19 09:01:14 +04:00
|
|
|
void
|
|
|
|
GLContext::ClearSafely()
|
|
|
|
{
|
2011-05-26 22:24:48 +04:00
|
|
|
// bug 659349 --- we must be very careful here: clearing a GL framebuffer is nontrivial, relies on a lot of state,
|
|
|
|
// and in the case of the backbuffer of a WebGL context, state is exposed to scripts.
|
|
|
|
//
|
|
|
|
// The code here is taken from WebGLContext::ForceClearFramebufferWithDefaultValues, but I didn't find a good way of
|
|
|
|
// sharing code with it. WebGL's code is somewhat performance-critical as it is typically called on every frame, so
|
|
|
|
// WebGL keeps track of GL state to avoid having to query it everytime, and also tries to only do work for actually
|
|
|
|
// present buffers (e.g. stencil buffer). Doing that here seems like premature optimization,
|
|
|
|
// as ClearSafely() is called only when e.g. a canvas is resized, not on every animation frame.
|
|
|
|
|
|
|
|
realGLboolean scissorTestEnabled;
|
|
|
|
realGLboolean ditherEnabled;
|
|
|
|
realGLboolean colorWriteMask[4];
|
|
|
|
realGLboolean depthWriteMask;
|
|
|
|
GLint stencilWriteMaskFront, stencilWriteMaskBack;
|
|
|
|
GLfloat colorClearValue[4];
|
|
|
|
GLfloat depthClearValue;
|
|
|
|
GLint stencilClearValue;
|
|
|
|
|
|
|
|
// save current GL state
|
|
|
|
fGetBooleanv(LOCAL_GL_SCISSOR_TEST, &scissorTestEnabled);
|
|
|
|
fGetBooleanv(LOCAL_GL_DITHER, &ditherEnabled);
|
|
|
|
fGetBooleanv(LOCAL_GL_COLOR_WRITEMASK, colorWriteMask);
|
|
|
|
fGetBooleanv(LOCAL_GL_DEPTH_WRITEMASK, &depthWriteMask);
|
|
|
|
fGetIntegerv(LOCAL_GL_STENCIL_WRITEMASK, &stencilWriteMaskFront);
|
|
|
|
fGetIntegerv(LOCAL_GL_STENCIL_BACK_WRITEMASK, &stencilWriteMaskBack);
|
|
|
|
fGetFloatv(LOCAL_GL_COLOR_CLEAR_VALUE, colorClearValue);
|
|
|
|
fGetFloatv(LOCAL_GL_DEPTH_CLEAR_VALUE, &depthClearValue);
|
|
|
|
fGetIntegerv(LOCAL_GL_STENCIL_CLEAR_VALUE, &stencilClearValue);
|
|
|
|
|
|
|
|
// prepare GL state for clearing
|
|
|
|
fDisable(LOCAL_GL_SCISSOR_TEST);
|
|
|
|
fDisable(LOCAL_GL_DITHER);
|
|
|
|
|
|
|
|
fColorMask(1, 1, 1, 1);
|
|
|
|
fClearColor(0.f, 0.f, 0.f, 0.f);
|
|
|
|
|
|
|
|
fDepthMask(1);
|
|
|
|
fClearDepth(1.0f);
|
2010-07-19 09:01:14 +04:00
|
|
|
|
2011-05-26 22:24:48 +04:00
|
|
|
fStencilMask(0xffffffff);
|
2010-07-19 09:01:14 +04:00
|
|
|
fClearStencil(0);
|
|
|
|
|
2011-05-26 22:24:48 +04:00
|
|
|
// do clear
|
|
|
|
fClear(LOCAL_GL_COLOR_BUFFER_BIT |
|
|
|
|
LOCAL_GL_DEPTH_BUFFER_BIT |
|
|
|
|
LOCAL_GL_STENCIL_BUFFER_BIT);
|
|
|
|
|
|
|
|
// restore GL state after clearing
|
|
|
|
fColorMask(colorWriteMask[0],
|
|
|
|
colorWriteMask[1],
|
|
|
|
colorWriteMask[2],
|
|
|
|
colorWriteMask[3]);
|
|
|
|
fClearColor(colorClearValue[0],
|
|
|
|
colorClearValue[1],
|
|
|
|
colorClearValue[2],
|
|
|
|
colorClearValue[3]);
|
|
|
|
|
|
|
|
fDepthMask(depthWriteMask);
|
|
|
|
fClearDepth(depthClearValue);
|
|
|
|
|
|
|
|
fStencilMaskSeparate(LOCAL_GL_FRONT, stencilWriteMaskFront);
|
|
|
|
fStencilMaskSeparate(LOCAL_GL_BACK, stencilWriteMaskBack);
|
|
|
|
fClearStencil(stencilClearValue);
|
|
|
|
|
|
|
|
if (ditherEnabled)
|
|
|
|
fEnable(LOCAL_GL_DITHER);
|
|
|
|
else
|
|
|
|
fDisable(LOCAL_GL_DITHER);
|
|
|
|
|
|
|
|
if (scissorTestEnabled)
|
|
|
|
fEnable(LOCAL_GL_SCISSOR_TEST);
|
|
|
|
else
|
|
|
|
fDisable(LOCAL_GL_SCISSOR_TEST);
|
2010-07-19 09:01:14 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-08-07 09:09:18 +04:00
|
|
|
void
|
|
|
|
GLContext::MarkDestroyed()
|
|
|
|
{
|
2010-09-21 23:41:24 +04:00
|
|
|
if (IsDestroyed())
|
|
|
|
return;
|
|
|
|
|
2012-05-01 06:05:59 +04:00
|
|
|
if (MakeCurrent()) {
|
2013-02-14 03:26:24 +04:00
|
|
|
DestroyScreenBuffer();
|
|
|
|
|
2013-11-29 00:57:19 +04:00
|
|
|
mBlitHelper = nullptr;
|
2013-11-29 00:57:19 +04:00
|
|
|
mBlitTextureImageHelper = nullptr;
|
2014-01-02 19:17:22 +04:00
|
|
|
mReadTexImageHelper = nullptr;
|
2013-11-29 08:11:49 +04:00
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
mTexGarbageBin->GLContextTeardown();
|
2012-05-01 06:05:59 +04:00
|
|
|
} else {
|
|
|
|
NS_WARNING("MakeCurrent() failed during MarkDestroyed! Skipping GL object teardown.");
|
|
|
|
}
|
2010-09-21 23:41:24 +04:00
|
|
|
|
2010-10-13 01:01:59 +04:00
|
|
|
mSymbols.Zero();
|
2010-08-07 09:09:18 +04:00
|
|
|
}
|
|
|
|
|
2014-05-09 05:03:37 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* static */ void
|
|
|
|
GLContext::AssertNotPassingStackBufferToTheGL(const void* ptr)
|
|
|
|
{
|
|
|
|
int somethingOnTheStack;
|
|
|
|
const void* someStackPtr = &somethingOnTheStack;
|
|
|
|
const int page_bits = 12;
|
|
|
|
intptr_t page = reinterpret_cast<uintptr_t>(ptr) >> page_bits;
|
|
|
|
intptr_t someStackPage = reinterpret_cast<uintptr_t>(someStackPtr) >> page_bits;
|
|
|
|
uintptr_t pageDistance = std::abs(page - someStackPage);
|
|
|
|
|
|
|
|
// Explanation for the "distance <= 1" check here as opposed to just
|
|
|
|
// an equality check.
|
|
|
|
//
|
|
|
|
// Here we assume that pages immediately adjacent to the someStackAddress page,
|
|
|
|
// are also stack pages. That allows to catch the case where the calling frame put
|
|
|
|
// a buffer on the stack, and we just crossed the page boundary. That is likely
|
|
|
|
// to happen, precisely, when using stack arrays. I hit that specifically
|
|
|
|
// with CompositorOGL::Initialize.
|
|
|
|
//
|
|
|
|
// In theory we could be unlucky and wrongly assert here. If that happens,
|
|
|
|
// it will only affect debug builds, and looking at stacks we'll be able to
|
|
|
|
// see that this assert is wrong and revert to the conservative and safe
|
|
|
|
// approach of only asserting when address and someStackAddress are
|
|
|
|
// on the same page.
|
|
|
|
bool isStackAddress = pageDistance <= 1;
|
|
|
|
MOZ_ASSERT(!isStackAddress,
|
|
|
|
"Please don't pass stack arrays to the GL. "
|
|
|
|
"Consider using HeapCopyOfStackArray. "
|
|
|
|
"See bug 1005658.");
|
|
|
|
}
|
|
|
|
|
2010-07-19 09:01:14 +04:00
|
|
|
void
|
|
|
|
GLContext::CreatedProgram(GLContext *aOrigin, GLuint aName)
|
|
|
|
{
|
|
|
|
mTrackedPrograms.AppendElement(NamedResource(aOrigin, aName));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::CreatedShader(GLContext *aOrigin, GLuint aName)
|
|
|
|
{
|
|
|
|
mTrackedShaders.AppendElement(NamedResource(aOrigin, aName));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::CreatedBuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames)
|
|
|
|
{
|
|
|
|
for (GLsizei i = 0; i < aCount; ++i) {
|
|
|
|
mTrackedBuffers.AppendElement(NamedResource(aOrigin, aNames[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-01 20:11:42 +04:00
|
|
|
void
|
|
|
|
GLContext::CreatedQueries(GLContext *aOrigin, GLsizei aCount, GLuint *aNames)
|
|
|
|
{
|
|
|
|
for (GLsizei i = 0; i < aCount; ++i) {
|
|
|
|
mTrackedQueries.AppendElement(NamedResource(aOrigin, aNames[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-19 09:01:14 +04:00
|
|
|
void
|
|
|
|
GLContext::CreatedTextures(GLContext *aOrigin, GLsizei aCount, GLuint *aNames)
|
|
|
|
{
|
|
|
|
for (GLsizei i = 0; i < aCount; ++i) {
|
|
|
|
mTrackedTextures.AppendElement(NamedResource(aOrigin, aNames[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::CreatedFramebuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames)
|
|
|
|
{
|
|
|
|
for (GLsizei i = 0; i < aCount; ++i) {
|
|
|
|
mTrackedFramebuffers.AppendElement(NamedResource(aOrigin, aNames[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::CreatedRenderbuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames)
|
|
|
|
{
|
|
|
|
for (GLsizei i = 0; i < aCount; ++i) {
|
|
|
|
mTrackedRenderbuffers.AppendElement(NamedResource(aOrigin, aNames[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-08-15 23:58:20 +04:00
|
|
|
RemoveNamesFromArray(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames, nsTArray<GLContext::NamedResource>& aArray)
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
|
|
|
for (GLsizei j = 0; j < aCount; ++j) {
|
|
|
|
GLuint name = aNames[j];
|
2010-09-06 00:37:52 +04:00
|
|
|
// name 0 can be ignored
|
|
|
|
if (name == 0)
|
|
|
|
continue;
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < aArray.Length(); ++i) {
|
2010-07-19 09:01:14 +04:00
|
|
|
if (aArray[i].name == name) {
|
|
|
|
aArray.RemoveElementAt(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::DeletedProgram(GLContext *aOrigin, GLuint aName)
|
|
|
|
{
|
|
|
|
RemoveNamesFromArray(aOrigin, 1, &aName, mTrackedPrograms);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::DeletedShader(GLContext *aOrigin, GLuint aName)
|
|
|
|
{
|
|
|
|
RemoveNamesFromArray(aOrigin, 1, &aName, mTrackedShaders);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-02-09 06:06:08 +04:00
|
|
|
GLContext::DeletedBuffers(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames)
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
|
|
|
RemoveNamesFromArray(aOrigin, aCount, aNames, mTrackedBuffers);
|
|
|
|
}
|
|
|
|
|
2012-11-01 20:11:42 +04:00
|
|
|
void
|
2013-08-15 23:58:20 +04:00
|
|
|
GLContext::DeletedQueries(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames)
|
2012-11-01 20:11:42 +04:00
|
|
|
{
|
|
|
|
RemoveNamesFromArray(aOrigin, aCount, aNames, mTrackedQueries);
|
|
|
|
}
|
|
|
|
|
2010-07-19 09:01:14 +04:00
|
|
|
void
|
2014-02-09 06:06:08 +04:00
|
|
|
GLContext::DeletedTextures(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames)
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
|
|
|
RemoveNamesFromArray(aOrigin, aCount, aNames, mTrackedTextures);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-02-09 06:06:08 +04:00
|
|
|
GLContext::DeletedFramebuffers(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames)
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
|
|
|
RemoveNamesFromArray(aOrigin, aCount, aNames, mTrackedFramebuffers);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-02-09 06:06:08 +04:00
|
|
|
GLContext::DeletedRenderbuffers(GLContext *aOrigin, GLsizei aCount, const GLuint *aNames)
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
|
|
|
RemoveNamesFromArray(aOrigin, aCount, aNames, mTrackedRenderbuffers);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
MarkContextDestroyedInArray(GLContext *aContext, nsTArray<GLContext::NamedResource>& aArray)
|
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < aArray.Length(); ++i) {
|
2010-07-19 09:01:14 +04:00
|
|
|
if (aArray[i].origin == aContext)
|
2011-10-17 18:59:28 +04:00
|
|
|
aArray[i].originDeleted = true;
|
2010-07-19 09:01:14 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::SharedContextDestroyed(GLContext *aChild)
|
|
|
|
{
|
|
|
|
MarkContextDestroyedInArray(aChild, mTrackedPrograms);
|
|
|
|
MarkContextDestroyedInArray(aChild, mTrackedShaders);
|
|
|
|
MarkContextDestroyedInArray(aChild, mTrackedTextures);
|
|
|
|
MarkContextDestroyedInArray(aChild, mTrackedFramebuffers);
|
|
|
|
MarkContextDestroyedInArray(aChild, mTrackedRenderbuffers);
|
|
|
|
MarkContextDestroyedInArray(aChild, mTrackedBuffers);
|
2012-11-01 20:11:42 +04:00
|
|
|
MarkContextDestroyedInArray(aChild, mTrackedQueries);
|
2010-07-19 09:01:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-08-01 22:57:54 +04:00
|
|
|
ReportArrayContents(const char *title, const nsTArray<GLContext::NamedResource>& aArray)
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
2012-08-01 22:57:54 +04:00
|
|
|
if (aArray.Length() == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
printf_stderr("%s:\n", title);
|
|
|
|
|
2010-07-19 09:01:14 +04:00
|
|
|
nsTArray<GLContext::NamedResource> copy(aArray);
|
|
|
|
copy.Sort();
|
|
|
|
|
2013-07-20 12:48:55 +04:00
|
|
|
GLContext *lastContext = nullptr;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = 0; i < copy.Length(); ++i) {
|
2010-07-19 09:01:14 +04:00
|
|
|
if (lastContext != copy[i].origin) {
|
|
|
|
if (lastContext)
|
|
|
|
printf_stderr("\n");
|
|
|
|
printf_stderr(" [%p - %s] ", copy[i].origin, copy[i].originDeleted ? "deleted" : "live");
|
|
|
|
lastContext = copy[i].origin;
|
|
|
|
}
|
|
|
|
printf_stderr("%d ", copy[i].name);
|
|
|
|
}
|
|
|
|
printf_stderr("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::ReportOutstandingNames()
|
|
|
|
{
|
2012-08-01 22:57:54 +04:00
|
|
|
if (!DebugMode())
|
|
|
|
return;
|
|
|
|
|
|
|
|
printf_stderr("== GLContext %p Outstanding ==\n", this);
|
|
|
|
|
|
|
|
ReportArrayContents("Outstanding Textures", mTrackedTextures);
|
|
|
|
ReportArrayContents("Outstanding Buffers", mTrackedBuffers);
|
2012-11-01 20:11:42 +04:00
|
|
|
ReportArrayContents("Outstanding Queries", mTrackedQueries);
|
2012-08-01 22:57:54 +04:00
|
|
|
ReportArrayContents("Outstanding Programs", mTrackedPrograms);
|
|
|
|
ReportArrayContents("Outstanding Shaders", mTrackedShaders);
|
|
|
|
ReportArrayContents("Outstanding Framebuffers", mTrackedFramebuffers);
|
|
|
|
ReportArrayContents("Outstanding Renderbuffers", mTrackedRenderbuffers);
|
2010-07-19 09:01:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* DEBUG */
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::GuaranteeResolve()
|
|
|
|
{
|
2013-05-07 10:23:40 +04:00
|
|
|
if (mScreen) {
|
|
|
|
mScreen->AssureBlitted();
|
|
|
|
}
|
|
|
|
fFinish();
|
2013-02-14 03:26:24 +04:00
|
|
|
}
|
|
|
|
|
2013-12-10 20:11:58 +04:00
|
|
|
const gfx::IntSize&
|
2013-02-14 03:26:24 +04:00
|
|
|
GLContext::OffscreenSize() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(IsOffscreen());
|
|
|
|
return mScreen->Size();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-12-10 20:12:42 +04:00
|
|
|
GLContext::CreateScreenBufferImpl(const IntSize& size, const SurfaceCaps& caps)
|
2013-02-14 03:26:24 +04:00
|
|
|
{
|
2014-08-16 04:38:07 +04:00
|
|
|
UniquePtr<GLScreenBuffer> newScreen = GLScreenBuffer::Create(this, size, caps);
|
2013-02-14 03:26:24 +04:00
|
|
|
if (!newScreen)
|
|
|
|
return false;
|
|
|
|
|
2013-03-22 23:22:20 +04:00
|
|
|
if (!newScreen->Resize(size)) {
|
2013-02-14 03:26:24 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
DestroyScreenBuffer();
|
|
|
|
|
|
|
|
// This will rebind to 0 (Screen) if needed when
|
|
|
|
// it falls out of scope.
|
|
|
|
ScopedBindFramebuffer autoFB(this);
|
|
|
|
|
2014-08-16 04:38:07 +04:00
|
|
|
mScreen = Move(newScreen);
|
2013-02-14 03:26:24 +04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-12-10 20:12:42 +04:00
|
|
|
GLContext::ResizeScreenBuffer(const IntSize& size)
|
2013-02-14 03:26:24 +04:00
|
|
|
{
|
|
|
|
if (!IsOffscreenSizeAllowed(size))
|
|
|
|
return false;
|
|
|
|
|
2013-03-22 23:22:20 +04:00
|
|
|
return mScreen->Resize(size);
|
2013-02-14 03:26:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::DestroyScreenBuffer()
|
|
|
|
{
|
|
|
|
mScreen = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::ForceDirtyScreen()
|
|
|
|
{
|
|
|
|
ScopedBindFramebuffer autoFB(0);
|
|
|
|
|
|
|
|
BeforeGLDrawCall();
|
|
|
|
// no-op; just pretend we did something
|
|
|
|
AfterGLDrawCall();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::CleanDirtyScreen()
|
|
|
|
{
|
|
|
|
ScopedBindFramebuffer autoFB(0);
|
|
|
|
|
|
|
|
BeforeGLReadCall();
|
|
|
|
// no-op; we just want to make sure the Read FBO is updated if it needs to be
|
|
|
|
AfterGLReadCall();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::EmptyTexGarbageBin()
|
|
|
|
{
|
|
|
|
TexGarbageBin()->EmptyGarbage();
|
|
|
|
}
|
|
|
|
|
2013-09-07 06:13:37 +04:00
|
|
|
bool
|
2013-12-10 20:12:42 +04:00
|
|
|
GLContext::IsOffscreenSizeAllowed(const IntSize& aSize) const {
|
2013-09-07 06:13:37 +04:00
|
|
|
int32_t biggerDimension = std::max(aSize.width, aSize.height);
|
|
|
|
int32_t maxAllowed = std::min(mMaxRenderbufferSize, mMaxTextureSize);
|
|
|
|
return biggerDimension <= maxAllowed;
|
|
|
|
}
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2013-09-07 06:13:37 +04:00
|
|
|
bool
|
|
|
|
GLContext::IsOwningThreadCurrent()
|
2013-02-14 03:26:24 +04:00
|
|
|
{
|
2014-05-09 08:18:00 +04:00
|
|
|
return PlatformThread::CurrentId() == mOwningThreadId;
|
2013-02-14 03:26:24 +04:00
|
|
|
}
|
|
|
|
|
2013-11-29 00:57:19 +04:00
|
|
|
GLBlitHelper*
|
|
|
|
GLContext::BlitHelper()
|
|
|
|
{
|
|
|
|
if (!mBlitHelper) {
|
2014-01-06 19:49:03 +04:00
|
|
|
mBlitHelper = MakeUnique<GLBlitHelper>(this);
|
2013-11-29 00:57:19 +04:00
|
|
|
}
|
|
|
|
|
2014-01-06 19:49:03 +04:00
|
|
|
return mBlitHelper.get();
|
2013-11-29 00:57:19 +04:00
|
|
|
}
|
|
|
|
|
2013-11-29 00:57:19 +04:00
|
|
|
GLBlitTextureImageHelper*
|
|
|
|
GLContext::BlitTextureImageHelper()
|
|
|
|
{
|
|
|
|
if (!mBlitTextureImageHelper) {
|
2014-01-06 19:49:03 +04:00
|
|
|
mBlitTextureImageHelper = MakeUnique<GLBlitTextureImageHelper>(this);
|
2013-11-29 00:57:19 +04:00
|
|
|
}
|
|
|
|
|
2014-01-06 19:49:03 +04:00
|
|
|
return mBlitTextureImageHelper.get();
|
2013-11-29 00:57:19 +04:00
|
|
|
}
|
|
|
|
|
2014-01-02 19:17:22 +04:00
|
|
|
GLReadTexImageHelper*
|
|
|
|
GLContext::ReadTexImageHelper()
|
|
|
|
{
|
|
|
|
if (!mReadTexImageHelper) {
|
2014-01-06 19:49:03 +04:00
|
|
|
mReadTexImageHelper = MakeUnique<GLReadTexImageHelper>(this);
|
2014-01-02 19:17:22 +04:00
|
|
|
}
|
|
|
|
|
2014-01-06 19:49:03 +04:00
|
|
|
return mReadTexImageHelper.get();
|
2014-01-02 19:17:22 +04:00
|
|
|
}
|
|
|
|
|
2014-09-10 05:40:51 +04:00
|
|
|
void
|
|
|
|
GLContext::FlushIfHeavyGLCallsSinceLastFlush()
|
|
|
|
{
|
|
|
|
if (!mHeavyGLCallsSinceLastFlush) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
MakeCurrent();
|
|
|
|
fFlush();
|
|
|
|
}
|
|
|
|
|
2013-09-07 06:13:37 +04:00
|
|
|
bool
|
|
|
|
DoesStringMatch(const char* aString, const char *aWantedString)
|
2013-02-14 03:26:24 +04:00
|
|
|
{
|
2013-09-07 06:13:37 +04:00
|
|
|
if (!aString || !aWantedString)
|
|
|
|
return false;
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2013-09-07 06:13:37 +04:00
|
|
|
const char *occurrence = strstr(aString, aWantedString);
|
|
|
|
|
|
|
|
// aWanted not found
|
|
|
|
if (!occurrence)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// aWantedString preceded by alpha character
|
|
|
|
if (occurrence != aString && isalpha(*(occurrence-1)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// aWantedVendor followed by alpha character
|
|
|
|
const char *afterOccurrence = occurrence + strlen(aWantedString);
|
|
|
|
if (isalpha(*afterOccurrence))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2013-02-14 03:26:24 +04:00
|
|
|
}
|
|
|
|
|
2010-04-27 06:09:44 +04:00
|
|
|
} /* namespace gl */
|
|
|
|
} /* namespace mozilla */
|