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
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
#include "GLContext.h"
|
|
|
|
|
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>
|
2017-03-15 23:14:03 +03:00
|
|
|
#include <regex>
|
|
|
|
#include <string>
|
2015-02-13 06:00:41 +03:00
|
|
|
#include <vector>
|
2016-07-15 18:58:58 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#endif
|
2012-12-15 03:58:45 +04:00
|
|
|
|
2013-11-29 00:57:19 +04:00
|
|
|
#include "GLBlitHelper.h"
|
2014-01-02 19:17:22 +04:00
|
|
|
#include "GLReadTexImageHelper.h"
|
2015-07-15 03:37:28 +03:00
|
|
|
#include "GLScreenBuffer.h"
|
2010-04-27 06:09:44 +04:00
|
|
|
|
2011-03-02 23:50:36 +03:00
|
|
|
#include "gfxCrashReporterUtils.h"
|
2015-10-28 16:31:00 +03:00
|
|
|
#include "gfxEnv.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-09-07 06:13:37 +04:00
|
|
|
#include "GfxTexturesReporter.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"
|
2016-07-15 18:58:58 +03:00
|
|
|
#include "mozilla/gfx/Logging.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>
|
|
|
|
#endif
|
|
|
|
|
2013-08-23 04:13:59 +04:00
|
|
|
#if defined(MOZ_WIDGET_COCOA)
|
|
|
|
#include "nsCocoaFeatures.h"
|
|
|
|
#endif
|
|
|
|
|
2016-07-15 18:58:58 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
#include "AndroidBridge.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;
|
|
|
|
|
2017-11-28 02:42:16 +03:00
|
|
|
MOZ_THREAD_LOCAL(uintptr_t) GLContext::sCurrentContext;
|
2017-07-07 17:16:00 +03:00
|
|
|
|
2015-07-03 03:14:28 +03:00
|
|
|
// If adding defines, don't forget to undefine symbols. See #undef block below.
|
|
|
|
#define CORE_SYMBOL(x) { (PRFuncPtr*) &mSymbols.f##x, { #x, nullptr } }
|
|
|
|
#define CORE_EXT_SYMBOL2(x,y,z) { (PRFuncPtr*) &mSymbols.f##x, { #x, #x #y, #x #z, nullptr } }
|
|
|
|
#define EXT_SYMBOL2(x,y,z) { (PRFuncPtr*) &mSymbols.f##x, { #x #y, #x #z, nullptr } }
|
|
|
|
#define EXT_SYMBOL3(x,y,z,w) { (PRFuncPtr*) &mSymbols.f##x, { #x #y, #x #z, #x #w, nullptr } }
|
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.
|
2016-04-22 02:32:18 +03:00
|
|
|
static const char* const 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",
|
2015-05-28 14:15:00 +03:00
|
|
|
"GL_ANGLE_timer_query",
|
2011-11-19 07:57:29 +04:00
|
|
|
"GL_APPLE_client_storage",
|
2015-07-03 03:14:28 +03:00
|
|
|
"GL_APPLE_framebuffer_multisample",
|
2015-09-28 17:41:08 +03:00
|
|
|
"GL_APPLE_sync",
|
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",
|
2017-03-15 23:14:03 +03:00
|
|
|
"GL_ARB_compatibility",
|
2014-05-27 14:13:09 +04:00
|
|
|
"GL_ARB_copy_buffer",
|
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",
|
2015-07-03 03:14:28 +03:00
|
|
|
"GL_ARB_geometry_shader4",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_ARB_half_float_pixel",
|
|
|
|
"GL_ARB_instanced_arrays",
|
2015-07-03 03:16:09 +03:00
|
|
|
"GL_ARB_internalformat_query",
|
2014-10-15 01:49:49 +04:00
|
|
|
"GL_ARB_invalidate_subdata",
|
2014-08-08 05:47:13 +04:00
|
|
|
"GL_ARB_map_buffer_range",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_ARB_occlusion_query2",
|
|
|
|
"GL_ARB_pixel_buffer_object",
|
2017-02-10 07:31:36 +03:00
|
|
|
"GL_ARB_robust_buffer_access_behavior",
|
2011-11-19 07:57:29 +04:00
|
|
|
"GL_ARB_robustness",
|
2014-09-23 09:45:34 +04:00
|
|
|
"GL_ARB_sampler_objects",
|
2016-02-12 04:57:25 +03:00
|
|
|
"GL_ARB_seamless_cube_map",
|
2016-06-01 03:22:30 +03:00
|
|
|
"GL_ARB_shader_texture_lod",
|
2012-04-07 03:57:55 +04:00
|
|
|
"GL_ARB_sync",
|
2014-09-23 09:50:10 +04:00
|
|
|
"GL_ARB_texture_compression",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_ARB_texture_float",
|
|
|
|
"GL_ARB_texture_non_power_of_two",
|
|
|
|
"GL_ARB_texture_rectangle",
|
2016-03-30 05:54:09 +03:00
|
|
|
"GL_ARB_texture_rg",
|
2014-09-23 09:49:19 +04:00
|
|
|
"GL_ARB_texture_storage",
|
2015-01-29 08:29:45 +03:00
|
|
|
"GL_ARB_texture_swizzle",
|
2015-05-28 14:15:00 +03:00
|
|
|
"GL_ARB_timer_query",
|
2014-09-23 09:47:28 +04:00
|
|
|
"GL_ARB_transform_feedback2",
|
2014-07-14 08:34:17 +04:00
|
|
|
"GL_ARB_uniform_buffer_object",
|
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",
|
2014-09-23 09:50:10 +04:00
|
|
|
"GL_EXT_copy_texture",
|
2015-05-28 14:15:00 +03:00
|
|
|
"GL_EXT_disjoint_timer_query",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_EXT_draw_buffers",
|
2014-05-27 14:21:30 +04:00
|
|
|
"GL_EXT_draw_buffers2",
|
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",
|
2015-07-03 03:14:28 +03:00
|
|
|
"GL_EXT_multisampled_render_to_texture",
|
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",
|
2015-03-24 10:11:10 +03:00
|
|
|
"GL_EXT_sRGB_write_control",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_EXT_shader_texture_lod",
|
2014-09-23 09:50:10 +04:00
|
|
|
"GL_EXT_texture3D",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_EXT_texture_compression_dxt1",
|
|
|
|
"GL_EXT_texture_compression_s3tc",
|
2017-08-09 02:32:23 +03:00
|
|
|
"GL_EXT_texture_compression_s3tc_srgb",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_EXT_texture_filter_anisotropic",
|
|
|
|
"GL_EXT_texture_format_BGRA8888",
|
2013-11-05 01:05:04 +04:00
|
|
|
"GL_EXT_texture_sRGB",
|
2014-07-15 03:55:56 +04:00
|
|
|
"GL_EXT_texture_storage",
|
2015-05-28 14:15:00 +03:00
|
|
|
"GL_EXT_timer_query",
|
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",
|
2017-02-10 07:31:36 +03:00
|
|
|
"GL_KHR_robust_buffer_access_behavior",
|
|
|
|
"GL_KHR_robustness",
|
2016-11-23 05:59:35 +03:00
|
|
|
"GL_KHR_texture_compression_astc_hdr",
|
|
|
|
"GL_KHR_texture_compression_astc_ldr",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_NV_draw_instanced",
|
2014-08-05 09:09:20 +04:00
|
|
|
"GL_NV_fence",
|
2015-07-03 03:14:28 +03:00
|
|
|
"GL_NV_framebuffer_blit",
|
|
|
|
"GL_NV_geometry_program4",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_NV_half_float",
|
|
|
|
"GL_NV_instanced_arrays",
|
2016-07-29 03:15:32 +03:00
|
|
|
"GL_NV_primitive_restart",
|
2016-05-02 02:37:42 +03:00
|
|
|
"GL_NV_texture_barrier",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_NV_transform_feedback",
|
2014-09-23 09:47:28 +04:00
|
|
|
"GL_NV_transform_feedback2",
|
2014-08-05 11:26:57 +04:00
|
|
|
"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",
|
2015-07-03 03:14:28 +03:00
|
|
|
"GL_OES_framebuffer_object",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_OES_packed_depth_stencil",
|
|
|
|
"GL_OES_rgb8_rgba8",
|
|
|
|
"GL_OES_standard_derivatives",
|
|
|
|
"GL_OES_stencil8",
|
2014-09-23 09:50:10 +04:00
|
|
|
"GL_OES_texture_3D",
|
2014-08-05 11:26:57 +04:00
|
|
|
"GL_OES_texture_float",
|
|
|
|
"GL_OES_texture_float_linear",
|
|
|
|
"GL_OES_texture_half_float",
|
|
|
|
"GL_OES_texture_half_float_linear",
|
|
|
|
"GL_OES_texture_npot",
|
2015-02-13 06:00:41 +03:00
|
|
|
"GL_OES_vertex_array_object"
|
2011-11-19 07:57:29 +04:00
|
|
|
};
|
|
|
|
|
2017-07-07 17:16:00 +03:00
|
|
|
static bool
|
|
|
|
ShouldUseTLSIsCurrent(bool useTLSIsCurrent)
|
|
|
|
{
|
|
|
|
if (gfxPrefs::UseTLSIsCurrent() == 0)
|
|
|
|
return useTLSIsCurrent;
|
|
|
|
|
|
|
|
return gfxPrefs::UseTLSIsCurrent() > 0;
|
|
|
|
}
|
|
|
|
|
2015-11-27 23:54:50 +03:00
|
|
|
static bool
|
2017-03-15 23:14:03 +03:00
|
|
|
ParseVersion(const std::string& versionStr, uint32_t* const out_major,
|
|
|
|
uint32_t* const out_minor)
|
2015-11-27 23:54:50 +03:00
|
|
|
{
|
2017-03-15 23:14:03 +03:00
|
|
|
static const std::regex kVersionRegex("([0-9]+)\\.([0-9]+)");
|
|
|
|
std::smatch match;
|
|
|
|
if (!std::regex_search(versionStr, match, kVersionRegex))
|
2015-11-27 23:54:50 +03:00
|
|
|
return false;
|
2013-08-29 18:07:58 +04:00
|
|
|
|
2017-03-15 23:14:03 +03:00
|
|
|
const auto& majorStr = match.str(1);
|
|
|
|
const auto& minorStr = match.str(2);
|
|
|
|
*out_major = atoi(majorStr.c_str());
|
|
|
|
*out_minor = atoi(minorStr.c_str());
|
2013-08-29 18:07:58 +04:00
|
|
|
return true;
|
|
|
|
}
|
2010-04-27 06:09:44 +04:00
|
|
|
|
2016-06-07 02:29:08 +03:00
|
|
|
static uint8_t
|
|
|
|
ChooseDebugFlags(CreateContextFlags createFlags)
|
|
|
|
{
|
|
|
|
uint8_t debugFlags = 0;
|
|
|
|
|
|
|
|
#ifdef MOZ_GL_DEBUG
|
|
|
|
if (gfxEnv::GlDebug()) {
|
|
|
|
debugFlags |= GLContext::DebugFlagEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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 (gfxEnv::GlDebugVerbose()) {
|
|
|
|
debugFlags |= GLContext::DebugFlagTrace;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Aborts on GL error. Can be useful to debug quicker code that is known not to
|
|
|
|
// generate any GL error in principle.
|
|
|
|
bool abortOnError = false;
|
|
|
|
|
|
|
|
if (createFlags & CreateContextFlags::NO_VALIDATION) {
|
|
|
|
abortOnError = true;
|
|
|
|
|
|
|
|
const auto fnStringsMatch = [](const char* a, const char* b) {
|
|
|
|
return strcmp(a, b) == 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
const char* envAbortOnError = PR_GetEnv("MOZ_GL_DEBUG_ABORT_ON_ERROR");
|
|
|
|
if (envAbortOnError && fnStringsMatch(envAbortOnError, "0")) {
|
|
|
|
abortOnError = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (abortOnError) {
|
|
|
|
debugFlags |= GLContext::DebugFlagAbortOnError;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return debugFlags;
|
|
|
|
}
|
|
|
|
|
2016-06-07 02:27:43 +03:00
|
|
|
GLContext::GLContext(CreateContextFlags flags, const SurfaceCaps& caps,
|
2017-07-07 17:16:00 +03:00
|
|
|
GLContext* sharedContext, bool isOffscreen, bool useTLSIsCurrent)
|
2017-08-11 04:01:04 +03:00
|
|
|
: mImplicitMakeCurrent(false),
|
2017-11-29 04:11:12 +03:00
|
|
|
mUseTLSIsCurrent(ShouldUseTLSIsCurrent(useTLSIsCurrent)),
|
2017-08-11 04:01:04 +03:00
|
|
|
mIsOffscreen(isOffscreen),
|
2013-09-07 06:13:37 +04:00
|
|
|
mContextLost(false),
|
|
|
|
mVersion(0),
|
|
|
|
mProfile(ContextProfile::Unknown),
|
2015-11-27 23:54:50 +03:00
|
|
|
mShadingLanguageVersion(0),
|
2014-01-10 22:55:23 +04:00
|
|
|
mVendor(GLVendor::Other),
|
|
|
|
mRenderer(GLRenderer::Other),
|
2014-10-25 03:52:35 +04:00
|
|
|
mTopError(LOCAL_GL_NO_ERROR),
|
2016-06-07 02:29:08 +03:00
|
|
|
mDebugFlags(ChooseDebugFlags(flags)),
|
2013-09-07 06:13:37 +04:00
|
|
|
mSharedContext(sharedContext),
|
2017-10-27 04:32:35 +03:00
|
|
|
mSymbols{},
|
2013-09-07 06:13:37 +04:00
|
|
|
mCaps(caps),
|
|
|
|
mScreen(nullptr),
|
|
|
|
mLockedSurface(nullptr),
|
|
|
|
mMaxTextureSize(0),
|
|
|
|
mMaxCubeMapTextureSize(0),
|
|
|
|
mMaxTextureImageSize(0),
|
|
|
|
mMaxRenderbufferSize(0),
|
2016-01-19 22:14:27 +03:00
|
|
|
mMaxSamples(0),
|
2013-09-07 06:13:37 +04:00
|
|
|
mNeedsTextureSizeChecks(false),
|
2015-09-17 05:41:00 +03:00
|
|
|
mNeedsFlushBeforeDeleteFB(false),
|
2016-07-15 18:58:58 +03:00
|
|
|
mTextureAllocCrashesOnMapFailure(false),
|
2016-09-08 17:29:44 +03:00
|
|
|
mNeedsCheckAfterAttachTextureToFb(false),
|
2014-09-10 05:40:51 +04:00
|
|
|
mWorkAroundDriverBugs(true),
|
2017-07-13 21:26:00 +03:00
|
|
|
mSyncGLCallCount(0),
|
2014-09-10 05:40:51 +04:00
|
|
|
mHeavyGLCallsSinceLastFlush(false)
|
2013-09-07 06:13:37 +04:00
|
|
|
{
|
2016-01-19 22:14:27 +03:00
|
|
|
mMaxViewportDims[0] = 0;
|
|
|
|
mMaxViewportDims[1] = 0;
|
2014-05-09 08:18:00 +04:00
|
|
|
mOwningThreadId = PlatformThread::CurrentId();
|
2017-07-07 17:16:00 +03:00
|
|
|
MOZ_ALWAYS_TRUE( sCurrentContext.init() );
|
2017-11-28 02:42:16 +03:00
|
|
|
sCurrentContext.set(0);
|
2013-09-07 06:13:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
GLContext::~GLContext() {
|
|
|
|
NS_ASSERTION(IsDestroyed(), "GLContext implementation must call MarkDestroyed in destructor!");
|
2014-10-15 05:24:53 +04:00
|
|
|
#ifdef MOZ_GL_DEBUG
|
2013-09-07 06:13:37 +04:00
|
|
|
if (mSharedContext) {
|
2016-06-11 04:37:07 +03:00
|
|
|
GLContext* tip = mSharedContext;
|
2013-09-07 06:13:37 +04:00
|
|
|
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
|
2016-04-22 02:32:18 +03:00
|
|
|
ClearSymbols(const GLLibraryLoader::SymLoadStruct* symbols)
|
2014-05-14 04:18:42 +04:00
|
|
|
{
|
|
|
|
while (symbols->symPointer) {
|
|
|
|
*symbols->symPointer = nullptr;
|
|
|
|
symbols++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2016-04-22 02:32:18 +03:00
|
|
|
GLContext::InitWithPrefix(const char* prefix, bool trygl)
|
2010-04-27 06:09:44 +04:00
|
|
|
{
|
2016-04-22 02:32:18 +03:00
|
|
|
MOZ_RELEASE_ASSERT(!mSymbols.fBindFramebuffer,
|
2016-06-06 18:17:23 +03:00
|
|
|
"GFX: InitWithPrefix should only be called once.");
|
2016-04-22 02:32:18 +03:00
|
|
|
|
2011-03-02 23:50:36 +03:00
|
|
|
ScopedGfxFeatureReporter reporter("GL Context");
|
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (!InitWithPrefixImpl(prefix, trygl)) {
|
|
|
|
// If initialization fails, zero the symbols to avoid hard-to-understand bugs.
|
2017-10-27 04:32:35 +03:00
|
|
|
mSymbols = {};
|
2016-04-22 02:32:18 +03:00
|
|
|
NS_WARNING("GLContext::InitWithPrefix failed!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
reporter.SetSuccessful();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
LoadGLSymbols(GLContext* gl, const char* prefix, bool trygl,
|
|
|
|
const GLLibraryLoader::SymLoadStruct* list, const char* desc)
|
|
|
|
{
|
|
|
|
if (gl->LoadSymbols(list, trygl, prefix))
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2016-04-22 02:32:18 +03:00
|
|
|
|
|
|
|
ClearSymbols(list);
|
|
|
|
|
|
|
|
if (desc) {
|
|
|
|
const nsPrintfCString err("Failed to load symbols for %s.", desc);
|
|
|
|
NS_ERROR(err.BeginReading());
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
GLContext::LoadExtSymbols(const char* prefix, bool trygl, const SymLoadStruct* list,
|
|
|
|
GLExtensions ext)
|
|
|
|
{
|
|
|
|
const char* extName = sExtensionNames[size_t(ext)];
|
|
|
|
if (!LoadGLSymbols(this, prefix, trygl, list, extName)) {
|
|
|
|
MarkExtensionUnsupported(ext);
|
|
|
|
return false;
|
2010-04-27 06:09:44 +04:00
|
|
|
}
|
2016-04-22 02:32:18 +03:00
|
|
|
return true;
|
|
|
|
};
|
2010-04-27 06:09:44 +04:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
bool
|
|
|
|
GLContext::LoadFeatureSymbols(const char* prefix, bool trygl, const SymLoadStruct* list,
|
|
|
|
GLFeature feature)
|
|
|
|
{
|
|
|
|
const char* featureName = GetFeatureName(feature);
|
|
|
|
if (!LoadGLSymbols(this, prefix, trygl, list, featureName)) {
|
|
|
|
MarkUnsupported(feature);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool
|
|
|
|
GLContext::InitWithPrefixImpl(const char* prefix, bool trygl)
|
|
|
|
{
|
2014-02-23 03:53:04 +04:00
|
|
|
mWorkAroundDriverBugs = gfxPrefs::WorkAroundDriverBugs();
|
2012-04-10 19:49:10 +04:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
const SymLoadStruct coreSymbols[] = {
|
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.fGenBuffers, { "GenBuffers", "GenBuffersARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGenTextures, { "GenTextures", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fCreateProgram, { "CreateProgram", "CreateProgramARB", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fCreateShader, { "CreateShader", "CreateShaderARB", 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 } },
|
|
|
|
|
2014-05-14 04:18:42 +04:00
|
|
|
END_SYMBOLS
|
2016-04-20 04:03:17 +03:00
|
|
|
};
|
2011-12-17 01:12:00 +04:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (!LoadGLSymbols(this, prefix, trygl, coreSymbols, "GL"))
|
|
|
|
return false;
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
////////////////
|
2012-01-31 00:09:02 +04:00
|
|
|
|
2017-07-24 13:24:14 +03:00
|
|
|
if (!MakeCurrent()) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2017-03-15 23:14:03 +03:00
|
|
|
const std::string versionStr = (const char*)fGetString(LOCAL_GL_VERSION);
|
|
|
|
if (versionStr.find("OpenGL ES") == 0) {
|
|
|
|
mProfile = ContextProfile::OpenGLES;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t majorVer, minorVer;
|
|
|
|
if (!ParseVersion(versionStr, &majorVer, &minorVer)) {
|
|
|
|
MOZ_ASSERT(false, "Failed to parse GL_VERSION");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(majorVer < 10);
|
|
|
|
MOZ_ASSERT(minorVer < 10);
|
|
|
|
mVersion = majorVer*100 + minorVer*10;
|
2017-08-31 22:50:18 +03:00
|
|
|
if (mVersion < 200)
|
|
|
|
return false;
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2017-03-15 23:14:03 +03:00
|
|
|
////
|
|
|
|
|
|
|
|
const auto glslVersionStr = (const char*)fGetString(LOCAL_GL_SHADING_LANGUAGE_VERSION);
|
|
|
|
if (!glslVersionStr) {
|
|
|
|
// This happens on the Android emulators. We'll just return 100
|
|
|
|
mShadingLanguageVersion = 100;
|
|
|
|
} else if (ParseVersion(glslVersionStr, &majorVer, &minorVer)) {
|
|
|
|
MOZ_ASSERT(majorVer < 10);
|
|
|
|
MOZ_ASSERT(minorVer < 100);
|
|
|
|
mShadingLanguageVersion = majorVer*100 + minorVer;
|
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(false, "Failed to parse GL_SHADING_LANGUAGE_VERSION");
|
|
|
|
return false;
|
|
|
|
}
|
2015-07-03 03:14:28 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (ShouldSpew()) {
|
2017-03-15 23:14:03 +03:00
|
|
|
printf_stderr("GL version detected: %u\n", mVersion);
|
|
|
|
printf_stderr("GLSL version detected: %u\n", mShadingLanguageVersion);
|
2016-04-22 02:32:18 +03:00
|
|
|
printf_stderr("OpenGL vendor: %s\n", fGetString(LOCAL_GL_VENDOR));
|
|
|
|
printf_stderr("OpenGL renderer: %s\n", fGetString(LOCAL_GL_RENDERER));
|
|
|
|
}
|
2012-04-07 03:57:55 +04:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
////////////////
|
2013-07-26 04:38:58 +04:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
// Load OpenGL ES 2.0 symbols, or desktop if we aren't using ES 2.
|
2017-03-15 23:14:03 +03:00
|
|
|
if (mProfile == ContextProfile::OpenGLES) {
|
2016-04-22 02:32:18 +03:00
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetShaderPrecisionFormat, { "GetShaderPrecisionFormat", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fClearDepthf, { "ClearDepthf", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDepthRangef, { "DepthRangef", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (!LoadGLSymbols(this, prefix, trygl, symbols, "OpenGL ES"))
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (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 } },
|
|
|
|
// The following 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 } },
|
2017-05-10 05:31:07 +03:00
|
|
|
{ (PRFuncPtr*) &mSymbols.fPolygonMode, { "PolygonMode", nullptr } },
|
2016-04-22 02:32:18 +03:00
|
|
|
{ (PRFuncPtr*) &mSymbols.fTexGeni, { "TexGeni", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTexGenf, { "TexGenf", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTexGenfv, { "TexGenfv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexPointer, { "VertexPointer", nullptr } },
|
|
|
|
END_SYMBOLS
|
2016-04-20 04:03:17 +03:00
|
|
|
};
|
2013-08-20 19:36:20 +04:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (!LoadGLSymbols(this, prefix, trygl, symbols, "Desktop OpenGL"))
|
|
|
|
return false;
|
2016-04-12 01:01:35 +03:00
|
|
|
}
|
2013-08-20 19:36:20 +04:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
////////////////
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
const char* glVendorString = (const char*)fGetString(LOCAL_GL_VENDOR);
|
|
|
|
const char* glRendererString = (const char*)fGetString(LOCAL_GL_RENDERER);
|
|
|
|
if (!glVendorString || !glRendererString)
|
|
|
|
return false;
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
// The order of these strings must match up with the order of the enum
|
|
|
|
// defined in GLContext.h for vendor IDs.
|
2016-08-02 05:31:39 +03:00
|
|
|
const char* vendorMatchStrings[size_t(GLVendor::Other) + 1] = {
|
2016-04-22 02:32:18 +03:00
|
|
|
"Intel",
|
|
|
|
"NVIDIA",
|
|
|
|
"ATI",
|
|
|
|
"Qualcomm",
|
|
|
|
"Imagination",
|
|
|
|
"nouveau",
|
|
|
|
"Vivante",
|
|
|
|
"VMware, Inc.",
|
2016-08-02 05:31:39 +03:00
|
|
|
"ARM",
|
|
|
|
"Unknown"
|
2016-04-22 02:32:18 +03:00
|
|
|
};
|
2014-05-27 14:21:30 +04:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
mVendor = GLVendor::Other;
|
|
|
|
for (size_t i = 0; i < size_t(GLVendor::Other); ++i) {
|
|
|
|
if (DoesStringMatch(glVendorString, vendorMatchStrings[i])) {
|
|
|
|
mVendor = GLVendor(i);
|
|
|
|
break;
|
2016-04-12 01:42:37 +03:00
|
|
|
}
|
2016-04-20 02:19:31 +03:00
|
|
|
}
|
2014-08-08 05:47:13 +04:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
// The order of these strings must match up with the order of the enum
|
|
|
|
// defined in GLContext.h for renderer IDs.
|
2016-08-02 05:31:39 +03:00
|
|
|
const char* rendererMatchStrings[size_t(GLRenderer::Other) + 1] = {
|
2016-04-22 02:32:18 +03:00
|
|
|
"Adreno 200",
|
|
|
|
"Adreno 205",
|
|
|
|
"Adreno (TM) 200",
|
|
|
|
"Adreno (TM) 205",
|
2016-07-15 18:58:58 +03:00
|
|
|
"Adreno (TM) 305",
|
2016-04-22 02:32:18 +03:00
|
|
|
"Adreno (TM) 320",
|
2016-07-15 18:58:58 +03:00
|
|
|
"Adreno (TM) 330",
|
2016-04-22 02:32:18 +03:00
|
|
|
"Adreno (TM) 420",
|
2016-07-13 13:16:54 +03:00
|
|
|
"Mali-400 MP",
|
2016-09-21 13:12:52 +03:00
|
|
|
"Mali-450 MP",
|
2016-04-22 02:32:18 +03:00
|
|
|
"PowerVR SGX 530",
|
|
|
|
"PowerVR SGX 540",
|
2016-10-26 17:28:08 +03:00
|
|
|
"PowerVR SGX 544MP",
|
2016-04-22 02:32:18 +03:00
|
|
|
"NVIDIA Tegra",
|
|
|
|
"Android Emulator",
|
|
|
|
"Gallium 0.4 on llvmpipe",
|
|
|
|
"Intel HD Graphics 3000 OpenGL Engine",
|
2016-08-02 05:31:39 +03:00
|
|
|
"Microsoft Basic Render Driver",
|
|
|
|
"Unknown"
|
2016-04-22 02:32:18 +03:00
|
|
|
};
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
mRenderer = GLRenderer::Other;
|
|
|
|
for (size_t i = 0; i < size_t(GLRenderer::Other); ++i) {
|
|
|
|
if (DoesStringMatch(glRendererString, rendererMatchStrings[i])) {
|
|
|
|
mRenderer = GLRenderer(i);
|
|
|
|
break;
|
2014-09-23 09:50:10 +04:00
|
|
|
}
|
2016-04-22 02:32:18 +03:00
|
|
|
}
|
2014-09-23 09:50:10 +04:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (ShouldSpew()) {
|
2016-08-02 05:31:39 +03:00
|
|
|
printf_stderr("GL_VENDOR: %s\n", glVendorString);
|
|
|
|
printf_stderr("mVendor: %s\n", vendorMatchStrings[size_t(mVendor)]);
|
|
|
|
printf_stderr("GL_RENDERER: %s\n", glRendererString);
|
|
|
|
printf_stderr("mRenderer: %s\n", rendererMatchStrings[size_t(mRenderer)]);
|
2016-04-22 02:32:18 +03:00
|
|
|
}
|
2014-07-14 08:34:17 +04:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
////////////////
|
2015-07-03 03:16:09 +03:00
|
|
|
|
2017-03-15 23:14:03 +03:00
|
|
|
if (mVersion >= 300) { // Both GL3 and ES3.
|
2016-04-22 02:32:18 +03:00
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetStringi, { "GetStringi", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
2015-07-03 03:16:09 +03:00
|
|
|
|
2017-03-15 23:14:03 +03:00
|
|
|
if (!LoadGLSymbols(this, prefix, trygl, symbols, "GetStringi")) {
|
|
|
|
MOZ_RELEASE_ASSERT(false, "GFX: GetStringi is required!");
|
2016-04-22 02:32:18 +03:00
|
|
|
return false;
|
2016-04-20 04:03:17 +03:00
|
|
|
}
|
2016-04-22 02:32:18 +03:00
|
|
|
}
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
InitExtensions();
|
2017-03-15 23:14:03 +03:00
|
|
|
if (mProfile != ContextProfile::OpenGLES) {
|
|
|
|
if (mVersion >= 310 && !IsExtensionSupported(ARB_compatibility)) {
|
|
|
|
mProfile = ContextProfile::OpenGLCore;
|
|
|
|
} else {
|
|
|
|
mProfile = ContextProfile::OpenGLCompatibility;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(mProfile != ContextProfile::Unknown);
|
|
|
|
|
|
|
|
if (ShouldSpew()) {
|
|
|
|
const char* profileStr = "";
|
|
|
|
if (mProfile == ContextProfile::OpenGLES) {
|
|
|
|
profileStr = " es";
|
|
|
|
} else if (mProfile == ContextProfile::OpenGLCore) {
|
|
|
|
profileStr = " core";
|
|
|
|
}
|
|
|
|
printf_stderr("Detected profile: %u%s\n", mVersion, profileStr);
|
|
|
|
}
|
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
InitFeatures();
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2017-03-15 23:14:03 +03:00
|
|
|
////
|
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
// Disable extensions with partial or incorrect support.
|
|
|
|
if (WorkAroundDriverBugs()) {
|
|
|
|
if (Renderer() == GLRenderer::AdrenoTM320) {
|
|
|
|
MarkUnsupported(GLFeature::standard_derivatives);
|
2016-04-20 04:03:17 +03:00
|
|
|
}
|
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (Vendor() == GLVendor::Vivante) {
|
|
|
|
// bug 958256
|
|
|
|
MarkUnsupported(GLFeature::standard_derivatives);
|
2014-10-15 01:49:49 +04:00
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03: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);
|
2014-03-17 18:50:15 +04:00
|
|
|
}
|
|
|
|
|
2016-04-22 02:32:18 +03: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
|
|
|
|
// and it also works in 10.8.3 and higher. See 1094338.
|
|
|
|
if (Vendor() == gl::GLVendor::NVIDIA &&
|
|
|
|
!nsCocoaFeatures::IsAtLeastVersion(10,8,3))
|
|
|
|
{
|
|
|
|
MarkUnsupported(GLFeature::depth_texture);
|
2016-04-20 04:03:17 +03:00
|
|
|
}
|
2016-04-22 02:32:18 +03:00
|
|
|
#endif
|
2018-01-12 05:26:46 +03:00
|
|
|
|
|
|
|
const auto versionStr = (const char*)fGetString(LOCAL_GL_VERSION);
|
|
|
|
if (strstr(versionStr, "Mesa")) {
|
|
|
|
// DrawElementsInstanced hangs the driver.
|
|
|
|
MarkUnsupported(GLFeature::robust_buffer_access_behavior);
|
|
|
|
}
|
2016-04-22 02:32:18 +03:00
|
|
|
}
|
2015-09-25 17:29:53 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsExtensionSupported(GLContext::ARB_pixel_buffer_object)) {
|
|
|
|
MOZ_ASSERT((mSymbols.fMapBuffer && mSymbols.fUnmapBuffer),
|
|
|
|
"ARB_pixel_buffer_object supported without glMapBuffer/UnmapBuffer"
|
|
|
|
" being available!");
|
|
|
|
}
|
2012-03-26 20:15:53 +04:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
2012-03-26 20:15:53 +04:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
const auto fnLoadForFeature = [this, prefix, trygl](const SymLoadStruct* list,
|
|
|
|
GLFeature feature)
|
|
|
|
{
|
|
|
|
return this->LoadFeatureSymbols(prefix, trygl, list, feature);
|
|
|
|
};
|
2011-02-12 02:11:30 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
// Check for ARB_framebuffer_objects
|
|
|
|
if (IsSupported(GLFeature::framebuffer_object)) {
|
|
|
|
// https://www.opengl.org/registry/specs/ARB/framebuffer_object.txt
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
CORE_SYMBOL(IsRenderbuffer),
|
|
|
|
CORE_SYMBOL(BindRenderbuffer),
|
|
|
|
CORE_SYMBOL(DeleteRenderbuffers),
|
|
|
|
CORE_SYMBOL(GenRenderbuffers),
|
|
|
|
CORE_SYMBOL(RenderbufferStorage),
|
|
|
|
CORE_SYMBOL(RenderbufferStorageMultisample),
|
|
|
|
CORE_SYMBOL(GetRenderbufferParameteriv),
|
|
|
|
CORE_SYMBOL(IsFramebuffer),
|
|
|
|
CORE_SYMBOL(BindFramebuffer),
|
|
|
|
CORE_SYMBOL(DeleteFramebuffers),
|
|
|
|
CORE_SYMBOL(GenFramebuffers),
|
|
|
|
CORE_SYMBOL(CheckFramebufferStatus),
|
|
|
|
CORE_SYMBOL(FramebufferTexture2D),
|
|
|
|
CORE_SYMBOL(FramebufferTextureLayer),
|
|
|
|
CORE_SYMBOL(FramebufferRenderbuffer),
|
|
|
|
CORE_SYMBOL(GetFramebufferAttachmentParameteriv),
|
|
|
|
CORE_SYMBOL(BlitFramebuffer),
|
|
|
|
CORE_SYMBOL(GenerateMipmap),
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadForFeature(symbols, GLFeature::framebuffer_object);
|
|
|
|
}
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (!IsSupported(GLFeature::framebuffer_object)) {
|
|
|
|
// Check for aux symbols based on extensions
|
|
|
|
if (IsSupported(GLFeature::framebuffer_object_EXT_OES)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
CORE_EXT_SYMBOL2(IsRenderbuffer, EXT, OES),
|
|
|
|
CORE_EXT_SYMBOL2(BindRenderbuffer, EXT, OES),
|
|
|
|
CORE_EXT_SYMBOL2(DeleteRenderbuffers, EXT, OES),
|
|
|
|
CORE_EXT_SYMBOL2(GenRenderbuffers, EXT, OES),
|
|
|
|
CORE_EXT_SYMBOL2(RenderbufferStorage, EXT, OES),
|
|
|
|
CORE_EXT_SYMBOL2(GetRenderbufferParameteriv, EXT, OES),
|
|
|
|
CORE_EXT_SYMBOL2(IsFramebuffer, EXT, OES),
|
|
|
|
CORE_EXT_SYMBOL2(BindFramebuffer, EXT, OES),
|
|
|
|
CORE_EXT_SYMBOL2(DeleteFramebuffers, EXT, OES),
|
|
|
|
CORE_EXT_SYMBOL2(GenFramebuffers, EXT, OES),
|
|
|
|
CORE_EXT_SYMBOL2(CheckFramebufferStatus, EXT, OES),
|
|
|
|
CORE_EXT_SYMBOL2(FramebufferTexture2D, EXT, OES),
|
|
|
|
CORE_EXT_SYMBOL2(FramebufferRenderbuffer, EXT, OES),
|
|
|
|
CORE_EXT_SYMBOL2(GetFramebufferAttachmentParameteriv, EXT, OES),
|
|
|
|
CORE_EXT_SYMBOL2(GenerateMipmap, EXT, OES),
|
2016-04-20 04:03:17 +03:00
|
|
|
END_SYMBOLS
|
|
|
|
};
|
2016-04-22 02:32:18 +03:00
|
|
|
fnLoadForFeature(symbols, GLFeature::framebuffer_object_EXT_OES);
|
2016-04-20 04:03:17 +03:00
|
|
|
}
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::framebuffer_blit)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
EXT_SYMBOL3(BlitFramebuffer, ANGLE, EXT, NV),
|
2016-04-12 01:42:37 +03:00
|
|
|
END_SYMBOLS
|
|
|
|
};
|
2016-04-22 02:32:18 +03:00
|
|
|
fnLoadForFeature(symbols, GLFeature::framebuffer_blit);
|
2016-04-12 01:42:37 +03:00
|
|
|
}
|
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::framebuffer_multisample)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
EXT_SYMBOL3(RenderbufferStorageMultisample, ANGLE, APPLE, EXT),
|
2016-04-20 04:03:17 +03:00
|
|
|
END_SYMBOLS
|
|
|
|
};
|
2016-04-22 02:32:18 +03:00
|
|
|
fnLoadForFeature(symbols, GLFeature::framebuffer_multisample);
|
2016-04-12 01:42:37 +03:00
|
|
|
}
|
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsExtensionSupported(GLContext::ARB_geometry_shader4) ||
|
|
|
|
IsExtensionSupported(GLContext::NV_geometry_program4))
|
|
|
|
{
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
EXT_SYMBOL2(FramebufferTextureLayer, ARB, EXT),
|
2016-04-20 04:03:17 +03:00
|
|
|
END_SYMBOLS
|
|
|
|
};
|
2016-04-22 02:32:18 +03:00
|
|
|
if (!LoadGLSymbols(this, prefix, trygl, symbols,
|
|
|
|
"ARB_geometry_shader4/NV_geometry_program4"))
|
|
|
|
{
|
|
|
|
MarkExtensionUnsupported(GLContext::ARB_geometry_shader4);
|
|
|
|
MarkExtensionUnsupported(GLContext::NV_geometry_program4);
|
2016-04-20 04:03:17 +03:00
|
|
|
}
|
|
|
|
}
|
2016-04-22 02:32:18 +03:00
|
|
|
}
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (!IsSupported(GLFeature::framebuffer_object) &&
|
|
|
|
!IsSupported(GLFeature::framebuffer_object_EXT_OES))
|
|
|
|
{
|
|
|
|
NS_ERROR("GLContext requires support for framebuffer objects.");
|
|
|
|
return false;
|
|
|
|
}
|
2016-06-06 18:17:23 +03:00
|
|
|
MOZ_RELEASE_ASSERT(mSymbols.fBindFramebuffer, "GFX: mSymbols.fBindFramebuffer zero or not set.");
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
////////////////
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2017-03-08 01:10:09 +03:00
|
|
|
const auto err = mSymbols.fGetError();
|
|
|
|
MOZ_RELEASE_ASSERT(!err);
|
|
|
|
if (err)
|
|
|
|
return false;
|
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
LoadMoreSymbols(prefix, trygl);
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
raw_fGetIntegerv(LOCAL_GL_VIEWPORT, mViewportRect);
|
|
|
|
raw_fGetIntegerv(LOCAL_GL_SCISSOR_BOX, mScissorRect);
|
|
|
|
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);
|
|
|
|
raw_fGetIntegerv(LOCAL_GL_MAX_VIEWPORT_DIMS, mMaxViewportDims);
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
#ifdef XP_MACOSX
|
2017-05-09 05:23:34 +03:00
|
|
|
if (mWorkAroundDriverBugs &&
|
|
|
|
nsCocoaFeatures::OSXVersionMajor() == 10 &&
|
|
|
|
nsCocoaFeatures::OSXVersionMinor() < 12)
|
|
|
|
{
|
2016-04-22 02:32:18 +03:00
|
|
|
if (mVendor == GLVendor::Intel) {
|
|
|
|
// see bug 737182 for 2D textures, bug 684882 for cube map textures.
|
|
|
|
mMaxTextureSize = std::min(mMaxTextureSize, 4096);
|
|
|
|
mMaxCubeMapTextureSize = std::min(mMaxCubeMapTextureSize, 512);
|
|
|
|
// for good measure, we align renderbuffers on what we do for 2D textures
|
|
|
|
mMaxRenderbufferSize = std::min(mMaxRenderbufferSize, 4096);
|
|
|
|
mNeedsTextureSizeChecks = true;
|
|
|
|
} else if (mVendor == GLVendor::NVIDIA) {
|
2016-07-10 14:11:33 +03:00
|
|
|
// See bug 879656. 8192 fails, 8191 works.
|
|
|
|
mMaxTextureSize = std::min(mMaxTextureSize, 8191);
|
|
|
|
mMaxRenderbufferSize = std::min(mMaxRenderbufferSize, 8191);
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
// Part of the bug 879656, but it also doesn't hurt the 877949
|
|
|
|
mNeedsTextureSizeChecks = true;
|
2016-04-12 01:42:37 +03:00
|
|
|
}
|
2016-04-22 02:32:18 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef MOZ_X11
|
|
|
|
if (mWorkAroundDriverBugs) {
|
|
|
|
if (mVendor == GLVendor::Nouveau) {
|
|
|
|
// see bug 814716. Clamp MaxCubeMapTextureSize at 2K for Nouveau.
|
|
|
|
mMaxCubeMapTextureSize = std::min(mMaxCubeMapTextureSize, 2048);
|
|
|
|
mNeedsTextureSizeChecks = true;
|
|
|
|
} else if (mVendor == GLVendor::Intel) {
|
|
|
|
// Bug 1199923. Driver seems to report a larger max size than
|
|
|
|
// actually supported.
|
|
|
|
mMaxTextureSize /= 2;
|
|
|
|
mMaxRenderbufferSize /= 2;
|
|
|
|
mNeedsTextureSizeChecks = true;
|
2016-04-12 01:42:37 +03:00
|
|
|
}
|
2017-05-24 17:28:21 +03:00
|
|
|
// Bug 1367570. Explicitly set vertex attributes [1,3] to opaque
|
|
|
|
// black because Nvidia doesn't do it for us.
|
|
|
|
if (mVendor == GLVendor::NVIDIA) {
|
|
|
|
for (size_t i = 1; i <= 3; ++i) {
|
|
|
|
mSymbols.fVertexAttrib4f(i, 0, 0, 0, 1);
|
|
|
|
}
|
|
|
|
}
|
2016-04-22 02:32:18 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (mWorkAroundDriverBugs &&
|
|
|
|
Renderer() == GLRenderer::AdrenoTM420) {
|
|
|
|
// see bug 1194923. Calling glFlush before glDeleteFramebuffers
|
|
|
|
// prevents occasional driver crash.
|
|
|
|
mNeedsFlushBeforeDeleteFB = true;
|
|
|
|
}
|
2016-07-15 18:58:58 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
if (mWorkAroundDriverBugs &&
|
|
|
|
(Renderer() == GLRenderer::AdrenoTM305 ||
|
|
|
|
Renderer() == GLRenderer::AdrenoTM320 ||
|
|
|
|
Renderer() == GLRenderer::AdrenoTM330) &&
|
|
|
|
AndroidBridge::Bridge()->GetAPIVersion() < 21) {
|
|
|
|
// Bug 1164027. Driver crashes when functions such as
|
|
|
|
// glTexImage2D fail due to virtual memory exhaustion.
|
|
|
|
mTextureAllocCrashesOnMapFailure = true;
|
|
|
|
}
|
|
|
|
#endif
|
2016-09-08 17:29:44 +03:00
|
|
|
#if MOZ_WIDGET_ANDROID
|
|
|
|
if (mWorkAroundDriverBugs &&
|
|
|
|
Renderer() == GLRenderer::SGX540 &&
|
|
|
|
AndroidBridge::Bridge()->GetAPIVersion() <= 15) {
|
|
|
|
// Bug 1288446. Driver sometimes crashes when uploading data to a
|
|
|
|
// texture if the render target has changed since the texture was
|
|
|
|
// rendered from. Calling glCheckFramebufferStatus after
|
|
|
|
// glFramebufferTexture2D prevents the crash.
|
|
|
|
mNeedsCheckAfterAttachTextureToFb = true;
|
|
|
|
}
|
|
|
|
#endif
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
mMaxTextureImageSize = mMaxTextureSize;
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::framebuffer_multisample)) {
|
|
|
|
fGetIntegerv(LOCAL_GL_MAX_SAMPLES, (GLint*)&mMaxSamples);
|
|
|
|
}
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2017-12-21 06:39:58 +03:00
|
|
|
mMaxTexOrRbSize = std::min(mMaxTextureSize, mMaxRenderbufferSize);
|
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
// We're ready for final setup.
|
|
|
|
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
// TODO: Remove SurfaceCaps::any.
|
|
|
|
if (mCaps.any) {
|
|
|
|
mCaps.any = false;
|
|
|
|
mCaps.color = true;
|
|
|
|
mCaps.alpha = false;
|
|
|
|
}
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
MOZ_ASSERT(IsCurrent());
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2016-06-07 02:29:08 +03:00
|
|
|
if (ShouldSpew() && IsExtensionSupported(KHR_debug)) {
|
2016-04-22 02:32:18 +03:00
|
|
|
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);
|
|
|
|
}
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
return true;
|
|
|
|
}
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
void
|
|
|
|
GLContext::LoadMoreSymbols(const char* prefix, bool trygl)
|
|
|
|
{
|
|
|
|
const auto fnLoadForExt = [this, prefix, trygl](const SymLoadStruct* list,
|
|
|
|
GLExtensions ext)
|
|
|
|
{
|
|
|
|
return this->LoadExtSymbols(prefix, trygl, list, ext);
|
|
|
|
};
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
const auto fnLoadForFeature = [this, prefix, trygl](const SymLoadStruct* list,
|
|
|
|
GLFeature feature)
|
|
|
|
{
|
|
|
|
return this->LoadFeatureSymbols(prefix, trygl, list, feature);
|
|
|
|
};
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
const auto fnLoadFeatureByCore = [this, fnLoadForFeature](const SymLoadStruct* coreList,
|
|
|
|
const SymLoadStruct* extList,
|
|
|
|
GLFeature feature)
|
|
|
|
{
|
|
|
|
const bool useCore = this->IsFeatureProvidedByCoreSymbols(feature);
|
|
|
|
const auto list = useCore ? coreList : extList;
|
|
|
|
return fnLoadForFeature(list, feature);
|
|
|
|
};
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2017-03-08 01:10:09 +03:00
|
|
|
if (IsSupported(GLFeature::robustness)) {
|
|
|
|
const auto resetStrategy = GetIntAs<GLuint>(LOCAL_GL_RESET_NOTIFICATION_STRATEGY);
|
|
|
|
if (resetStrategy != LOCAL_GL_LOSE_CONTEXT_ON_RESET) {
|
2017-03-10 02:03:31 +03:00
|
|
|
NS_WARNING("Robustness supported, strategy is not LOSE_CONTEXT_ON_RESET!");
|
|
|
|
if (ShouldSpew()) {
|
|
|
|
const bool isDisabled = (resetStrategy == LOCAL_GL_NO_RESET_NOTIFICATION);
|
|
|
|
printf_stderr("Strategy: %s (0x%04x)",
|
|
|
|
(isDisabled ? "disabled" : "unrecognized"),
|
|
|
|
resetStrategy);
|
|
|
|
}
|
2017-03-08 01:10:09 +03:00
|
|
|
MarkUnsupported(GLFeature::robustness);
|
|
|
|
}
|
|
|
|
}
|
2016-06-11 03:44:49 +03:00
|
|
|
if (IsSupported(GLFeature::robustness)) {
|
2017-02-10 07:31:36 +03:00
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetGraphicsResetStatus, { "GetGraphicsResetStatus",
|
|
|
|
"GetGraphicsResetStatusARB",
|
|
|
|
"GetGraphicsResetStatusKHR",
|
|
|
|
"GetGraphicsResetStatusEXT",
|
|
|
|
nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
2017-03-08 01:10:09 +03:00
|
|
|
if (fnLoadForFeature(symbols, GLFeature::robustness)) {
|
|
|
|
const auto status = mSymbols.fGetGraphicsResetStatus();
|
|
|
|
MOZ_ALWAYS_TRUE(!status);
|
|
|
|
|
|
|
|
const auto err = mSymbols.fGetError();
|
|
|
|
MOZ_ALWAYS_TRUE(!err);
|
|
|
|
}
|
2016-04-22 02:32:18 +03:00
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::sync)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (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 } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadForFeature(symbols, GLFeature::sync);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsExtensionSupported(OES_EGL_image)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fEGLImageTargetTexture2D, { "EGLImageTargetTexture2DOES", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fEGLImageTargetRenderbufferStorage, { "EGLImageTargetRenderbufferStorageOES", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadForExt(symbols, OES_EGL_image);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsExtensionSupported(APPLE_texture_range)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTextureRangeAPPLE, { "TextureRangeAPPLE", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadForExt(symbols, APPLE_texture_range);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::vertex_array_object)) {
|
|
|
|
const SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fIsVertexArray, { "IsVertexArray", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGenVertexArrays, { "GenVertexArrays", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindVertexArray, { "BindVertexArray", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDeleteVertexArrays, { "DeleteVertexArrays", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
const 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
|
|
|
|
};
|
|
|
|
fnLoadFeatureByCore(coreSymbols, extSymbols, GLFeature::vertex_array_object);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::draw_instanced)) {
|
|
|
|
const SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawArraysInstanced, { "DrawArraysInstanced", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawElementsInstanced, { "DrawElementsInstanced", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
const SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawArraysInstanced, { "DrawArraysInstancedARB", "DrawArraysInstancedEXT", "DrawArraysInstancedNV", "DrawArraysInstancedANGLE", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawElementsInstanced, { "DrawElementsInstancedARB", "DrawElementsInstancedEXT", "DrawElementsInstancedNV", "DrawElementsInstancedANGLE", nullptr }
|
|
|
|
},
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadFeatureByCore(coreSymbols, extSymbols, GLFeature::draw_instanced);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::instanced_arrays)) {
|
|
|
|
const SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexAttribDivisor, { "VertexAttribDivisor", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
const SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexAttribDivisor, { "VertexAttribDivisorARB", "VertexAttribDivisorNV", "VertexAttribDivisorANGLE", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadFeatureByCore(coreSymbols, extSymbols, GLFeature::instanced_arrays);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::texture_storage)) {
|
|
|
|
const SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTexStorage2D, { "TexStorage2D", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTexStorage3D, { "TexStorage3D", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
const SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTexStorage2D, { "TexStorage2DEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTexStorage3D, { "TexStorage3DEXT", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadFeatureByCore(coreSymbols, extSymbols, GLFeature::texture_storage);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::sampler_objects)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGenSamplers, { "GenSamplers", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDeleteSamplers, { "DeleteSamplers", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fIsSampler, { "IsSampler", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindSampler, { "BindSampler", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fSamplerParameteri, { "SamplerParameteri", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fSamplerParameteriv, { "SamplerParameteriv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fSamplerParameterf, { "SamplerParameterf", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fSamplerParameterfv, { "SamplerParameterfv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetSamplerParameteriv, { "GetSamplerParameteriv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetSamplerParameterfv, { "GetSamplerParameterfv", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadForFeature(symbols, GLFeature::sampler_objects);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
// ARB_transform_feedback2/NV_transform_feedback2 is a
|
|
|
|
// superset of EXT_transform_feedback/NV_transform_feedback
|
|
|
|
// and adds glPauseTransformFeedback &
|
|
|
|
// glResumeTransformFeedback, which are required for WebGL2.
|
|
|
|
if (IsSupported(GLFeature::transform_feedback2)) {
|
|
|
|
const SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindBufferBase, { "BindBufferBase", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindBufferRange, { "BindBufferRange", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGenTransformFeedbacks, { "GenTransformFeedbacks", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindTransformFeedback, { "BindTransformFeedback", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDeleteTransformFeedbacks, { "DeleteTransformFeedbacks", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fIsTransformFeedback, { "IsTransformFeedback", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBeginTransformFeedback, { "BeginTransformFeedback", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fEndTransformFeedback, { "EndTransformFeedback", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTransformFeedbackVaryings, { "TransformFeedbackVaryings", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetTransformFeedbackVarying, { "GetTransformFeedbackVarying", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fPauseTransformFeedback, { "PauseTransformFeedback", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fResumeTransformFeedback, { "ResumeTransformFeedback", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
const SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindBufferBase, { "BindBufferBaseEXT", "BindBufferBaseNV", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindBufferRange, { "BindBufferRangeEXT", "BindBufferRangeNV", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGenTransformFeedbacks, { "GenTransformFeedbacksNV", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindTransformFeedback, { "BindTransformFeedbackNV", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDeleteTransformFeedbacks, { "DeleteTransformFeedbacksNV", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fIsTransformFeedback, { "IsTransformFeedbackNV", 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.fPauseTransformFeedback, { "PauseTransformFeedbackNV", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fResumeTransformFeedback, { "ResumeTransformFeedbackNV", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
if (!fnLoadFeatureByCore(coreSymbols, extSymbols, GLFeature::texture_storage)) {
|
|
|
|
// Also mark bind_buffer_offset as unsupported.
|
|
|
|
MarkUnsupported(GLFeature::bind_buffer_offset);
|
2016-04-20 04:03:17 +03:00
|
|
|
}
|
2016-04-22 02:32:18 +03:00
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::bind_buffer_offset)) {
|
|
|
|
const SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindBufferOffset, { "BindBufferOffset", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
const SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBindBufferOffset,
|
|
|
|
{ "BindBufferOffsetEXT", "BindBufferOffsetNV", nullptr }
|
|
|
|
},
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadFeatureByCore(coreSymbols, extSymbols, GLFeature::bind_buffer_offset);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::query_counter)) {
|
|
|
|
const SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fQueryCounter, { "QueryCounter", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
const SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fQueryCounter, { "QueryCounterEXT", "QueryCounterANGLE", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadFeatureByCore(coreSymbols, extSymbols, GLFeature::query_counter);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::query_objects)) {
|
|
|
|
const 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
|
|
|
|
};
|
|
|
|
const SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fBeginQuery, { "BeginQueryEXT", "BeginQueryANGLE", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGenQueries, { "GenQueriesEXT", "GenQueriesANGLE", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDeleteQueries, { "DeleteQueriesEXT", "DeleteQueriesANGLE", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fEndQuery, { "EndQueryEXT", "EndQueryANGLE", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetQueryiv, { "GetQueryivEXT", "GetQueryivANGLE", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetQueryObjectuiv, { "GetQueryObjectuivEXT", "GetQueryObjectuivANGLE", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fIsQuery, { "IsQueryEXT", "IsQueryANGLE", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
if (!fnLoadFeatureByCore(coreSymbols, extSymbols, GLFeature::query_objects)) {
|
|
|
|
MarkUnsupported(GLFeature::get_query_object_i64v);
|
|
|
|
MarkUnsupported(GLFeature::get_query_object_iv);
|
|
|
|
MarkUnsupported(GLFeature::occlusion_query);
|
|
|
|
MarkUnsupported(GLFeature::occlusion_query_boolean);
|
|
|
|
MarkUnsupported(GLFeature::occlusion_query2);
|
2016-04-20 04:03:17 +03:00
|
|
|
}
|
2016-04-22 02:32:18 +03:00
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::get_query_object_i64v)) {
|
|
|
|
const SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetQueryObjecti64v, { "GetQueryObjecti64v", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetQueryObjectui64v, { "GetQueryObjectui64v", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
const SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetQueryObjecti64v, { "GetQueryObjecti64vEXT", "GetQueryObjecti64vANGLE", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetQueryObjectui64v, { "GetQueryObjectui64vEXT", "GetQueryObjectui64vANGLE", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
if (!fnLoadFeatureByCore(coreSymbols, extSymbols, GLFeature::get_query_object_i64v)) {
|
|
|
|
MarkUnsupported(GLFeature::query_counter);
|
2016-04-20 04:03:17 +03:00
|
|
|
}
|
2016-04-22 02:32:18 +03:00
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::get_query_object_iv)) {
|
|
|
|
const SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetQueryObjectiv, { "GetQueryObjectiv", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
const SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetQueryObjectiv, { "GetQueryObjectivEXT", "GetQueryObjectivANGLE", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadFeatureByCore(coreSymbols, extSymbols, GLFeature::get_query_object_iv);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::clear_buffers)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fClearBufferfi, { "ClearBufferfi", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fClearBufferfv, { "ClearBufferfv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fClearBufferiv, { "ClearBufferiv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fClearBufferuiv, { "ClearBufferuiv", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadForFeature(symbols, GLFeature::clear_buffers);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::copy_buffer)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fCopyBufferSubData, { "CopyBufferSubData", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadForFeature(symbols, GLFeature::copy_buffer);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::draw_buffers)) {
|
|
|
|
const SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawBuffers, { "DrawBuffers", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
const SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawBuffers, { "DrawBuffersARB", "DrawBuffersEXT", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadFeatureByCore(coreSymbols, extSymbols, GLFeature::draw_buffers);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::draw_range_elements)) {
|
|
|
|
const SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawRangeElements, { "DrawRangeElements", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
const SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fDrawRangeElements, { "DrawRangeElementsEXT", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadFeatureByCore(coreSymbols, extSymbols, GLFeature::draw_range_elements);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::get_integer_indexed)) {
|
|
|
|
const SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetIntegeri_v, { "GetIntegeri_v", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
const SymLoadStruct extSymbols[] ={
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetIntegeri_v, { "GetIntegerIndexedvEXT", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadFeatureByCore(coreSymbols, extSymbols, GLFeature::get_integer_indexed);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::get_integer64_indexed)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetInteger64i_v, { "GetInteger64i_v", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadForFeature(symbols, GLFeature::get_integer64_indexed);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::gpu_shader4)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetVertexAttribIiv, { "GetVertexAttribIiv", "GetVertexAttribIivEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetVertexAttribIuiv, { "GetVertexAttribIuiv", "GetVertexAttribIuivEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexAttribI4i, { "VertexAttribI4i", "VertexAttribI4iEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexAttribI4iv, { "VertexAttribI4iv","VertexAttribI4ivEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexAttribI4ui, { "VertexAttribI4ui", "VertexAttribI4uiEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexAttribI4uiv, { "VertexAttribI4uiv", "VertexAttribI4uivEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fVertexAttribIPointer, { "VertexAttribIPointer", "VertexAttribIPointerEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform1ui, { "Uniform1ui", "Uniform1uiEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform2ui, { "Uniform2ui", "Uniform2uiEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform3ui, { "Uniform3ui", "Uniform3uiEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform4ui, { "Uniform4ui", "Uniform4uiEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform1uiv, { "Uniform1uiv", "Uniform1uivEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform2uiv, { "Uniform2uiv", "Uniform2uivEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform3uiv, { "Uniform3uiv", "Uniform3uivEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniform4uiv, { "Uniform4uiv", "Uniform4uivEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetFragDataLocation, { "GetFragDataLocation", "GetFragDataLocationEXT", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetUniformuiv, { "GetUniformuiv", "GetUniformuivEXT", nullptr } },
|
|
|
|
END_SYMBOLS
|
2016-04-20 02:19:31 +03:00
|
|
|
};
|
2016-04-22 02:32:18 +03:00
|
|
|
fnLoadForFeature(symbols, GLFeature::gpu_shader4);
|
2016-04-12 01:01:35 +03:00
|
|
|
}
|
2013-08-03 01:30:58 +04:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::map_buffer_range)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fMapBufferRange, { "MapBufferRange", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fFlushMappedBufferRange, { "FlushMappedBufferRange", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUnmapBuffer, { "UnmapBuffer", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadForFeature(symbols, GLFeature::map_buffer_range);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::texture_3D)) {
|
|
|
|
const SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTexImage3D, { "TexImage3D", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTexSubImage3D, { "TexSubImage3D", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
const SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTexSubImage3D, { "TexSubImage3DEXT", "TexSubImage3DOES", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadFeatureByCore(coreSymbols, extSymbols, GLFeature::texture_3D);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::texture_3D_compressed)) {
|
|
|
|
const SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fCompressedTexImage3D, { "CompressedTexImage3D", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fCompressedTexSubImage3D, { "CompressedTexSubImage3D", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
const SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fCompressedTexImage3D, { "CompressedTexImage3DARB", "CompressedTexImage3DOES", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fCompressedTexSubImage3D, { "CompressedTexSubImage3DARB", "CompressedTexSubImage3DOES", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadFeatureByCore(coreSymbols, extSymbols, GLFeature::texture_3D_compressed);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::texture_3D_copy)) {
|
|
|
|
const SymLoadStruct coreSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fCopyTexSubImage3D, { "CopyTexSubImage3D", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
const SymLoadStruct extSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fCopyTexSubImage3D, { "CopyTexSubImage3DEXT", "CopyTexSubImage3DOES", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadFeatureByCore(coreSymbols, extSymbols, GLFeature::texture_3D_copy);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::uniform_buffer_object)) {
|
|
|
|
// Note: Don't query for glGetActiveUniformName because it is not
|
|
|
|
// supported by GL ES 3.
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetUniformIndices, { "GetUniformIndices", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetActiveUniformsiv, { "GetActiveUniformsiv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetUniformBlockIndex, { "GetUniformBlockIndex", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetActiveUniformBlockiv, { "GetActiveUniformBlockiv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetActiveUniformBlockName, { "GetActiveUniformBlockName", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniformBlockBinding, { "UniformBlockBinding", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadForFeature(symbols, GLFeature::uniform_buffer_object);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::uniform_matrix_nonsquare)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniformMatrix2x3fv, { "UniformMatrix2x3fv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniformMatrix2x4fv, { "UniformMatrix2x4fv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniformMatrix3x2fv, { "UniformMatrix3x2fv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniformMatrix3x4fv, { "UniformMatrix3x4fv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniformMatrix4x2fv, { "UniformMatrix4x2fv", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fUniformMatrix4x3fv, { "UniformMatrix4x3fv", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadForFeature(symbols, GLFeature::uniform_matrix_nonsquare);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::internalformat_query)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
CORE_SYMBOL(GetInternalformativ),
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadForFeature(symbols, GLFeature::internalformat_query);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::invalidate_framebuffer)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
2016-06-11 04:37:07 +03:00
|
|
|
{ (PRFuncPtr*) &mSymbols.fInvalidateFramebuffer, { "InvalidateFramebuffer", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fInvalidateSubFramebuffer, { "InvalidateSubFramebuffer", nullptr } },
|
2016-04-22 02:32:18 +03:00
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadForFeature(symbols, GLFeature::invalidate_framebuffer);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-07-29 03:15:32 +03:00
|
|
|
if (IsSupported(GLFeature::prim_restart)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fPrimitiveRestartIndex, { "PrimitiveRestartIndex", "PrimitiveRestartIndexNV", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadForFeature(symbols, GLFeature::prim_restart);
|
|
|
|
}
|
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsExtensionSupported(KHR_debug)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (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 } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadForExt(symbols, KHR_debug);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsExtensionSupported(NV_fence)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (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
|
|
|
|
};
|
|
|
|
fnLoadForExt(symbols, NV_fence);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-05-02 02:37:42 +03:00
|
|
|
if (IsExtensionSupported(NV_texture_barrier)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fTextureBarrier, { "TextureBarrierNV", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadForExt(symbols, NV_texture_barrier);
|
|
|
|
}
|
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsSupported(GLFeature::read_buffer)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fReadBuffer, { "ReadBuffer", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadForFeature(symbols, GLFeature::read_buffer);
|
2016-04-20 02:19:31 +03:00
|
|
|
}
|
2016-04-12 01:42:37 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
if (IsExtensionSupported(APPLE_framebuffer_multisample)) {
|
|
|
|
const SymLoadStruct symbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fResolveMultisampleFramebufferAPPLE, { "ResolveMultisampleFramebufferAPPLE", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
|
|
|
fnLoadForExt(symbols, APPLE_framebuffer_multisample);
|
|
|
|
}
|
2016-04-20 04:03:17 +03:00
|
|
|
|
2016-04-22 02:32:18 +03:00
|
|
|
// Load developer symbols, don't fail if we can't find them.
|
|
|
|
const SymLoadStruct devSymbols[] = {
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetTexImage, { "GetTexImage", nullptr } },
|
|
|
|
{ (PRFuncPtr*) &mSymbols.fGetTexLevelParameteriv, { "GetTexLevelParameteriv", nullptr } },
|
|
|
|
END_SYMBOLS
|
|
|
|
};
|
2016-06-07 02:29:08 +03:00
|
|
|
const bool warnOnFailures = ShouldSpew();
|
2016-04-22 02:32:18 +03:00
|
|
|
LoadSymbols(devSymbols, trygl, prefix, warnOnFailures);
|
2010-04-27 06:09:44 +04:00
|
|
|
}
|
|
|
|
|
2015-07-03 03:14:28 +03:00
|
|
|
#undef CORE_SYMBOL
|
|
|
|
#undef CORE_EXT_SYMBOL2
|
|
|
|
#undef EXT_SYMBOL2
|
|
|
|
#undef EXT_SYMBOL3
|
|
|
|
#undef END_SYMBOLS
|
|
|
|
|
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-10-28 04:58:03 +03:00
|
|
|
printf_stderr("[KHR_debug: 0x%" PRIxPTR "] ID %u: %s, %s, %s:\n %s\n",
|
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()
|
|
|
|
{
|
2015-02-13 06:00:41 +03:00
|
|
|
MOZ_ASSERT(IsCurrent());
|
2015-01-29 11:44:19 +03:00
|
|
|
|
2015-02-13 06:00:41 +03:00
|
|
|
std::vector<nsCString> driverExtensionList;
|
2014-02-28 10:57:03 +04:00
|
|
|
|
2018-01-08 23:35:04 +03:00
|
|
|
[&]() {
|
|
|
|
if (mSymbols.fGetStringi) {
|
|
|
|
GLuint count = 0;
|
|
|
|
if (GetPotentialInteger(LOCAL_GL_NUM_EXTENSIONS, (GLint*)&count)) {
|
|
|
|
for (GLuint i = 0; i < count; i++) {
|
|
|
|
// This is UTF-8.
|
|
|
|
const char* rawExt = (const char*)fGetStringi(LOCAL_GL_EXTENSIONS, i);
|
|
|
|
|
|
|
|
// We CANNOT use nsDependentCString here, because the spec doesn't guarantee
|
|
|
|
// that the pointers returned are different, only that their contents are.
|
|
|
|
// On Flame, each of these index string queries returns the same address.
|
|
|
|
driverExtensionList.push_back(nsCString(rawExt));
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2015-02-13 06:00:41 +03:00
|
|
|
}
|
2015-01-29 11:44:19 +03:00
|
|
|
|
2018-01-08 23:35:04 +03:00
|
|
|
const char* rawExts = (const char*)fGetString(LOCAL_GL_EXTENSIONS);
|
2015-02-13 06:00:41 +03:00
|
|
|
if (rawExts) {
|
|
|
|
nsDependentCString exts(rawExts);
|
|
|
|
SplitByChar(exts, ' ', &driverExtensionList);
|
|
|
|
}
|
2018-01-08 23:35:04 +03:00
|
|
|
}();
|
|
|
|
const auto err = fGetError();
|
|
|
|
MOZ_ALWAYS_TRUE(!err);
|
2015-01-29 11:44:19 +03:00
|
|
|
|
2015-02-13 06:00:41 +03:00
|
|
|
const bool shouldDumpExts = ShouldDumpExts();
|
|
|
|
if (shouldDumpExts) {
|
|
|
|
printf_stderr("%i GL driver extensions: (*: recognized)\n",
|
|
|
|
(uint32_t)driverExtensionList.size());
|
2015-02-05 03:34:55 +03:00
|
|
|
}
|
|
|
|
|
2015-02-13 06:00:41 +03:00
|
|
|
MarkBitfieldByStrings(driverExtensionList, shouldDumpExts, sExtensionNames,
|
|
|
|
&mAvailableExtensions);
|
|
|
|
|
|
|
|
if (WorkAroundDriverBugs()) {
|
|
|
|
if (Vendor() == GLVendor::Qualcomm) {
|
|
|
|
// Some Adreno drivers do not report GL_OES_EGL_sync, but they really do support it.
|
|
|
|
MarkExtensionSupported(OES_EGL_sync);
|
|
|
|
}
|
|
|
|
|
2016-11-02 01:35:51 +03:00
|
|
|
if (Vendor() == GLVendor::ATI) {
|
|
|
|
// ATI drivers say this extension exists, but we can't
|
|
|
|
// actually find the EGLImageTargetRenderbufferStorageOES
|
|
|
|
// extension function pointer in the drivers.
|
|
|
|
MarkExtensionUnsupported(OES_EGL_image);
|
|
|
|
}
|
|
|
|
|
2015-02-13 06:00:41 +03:00
|
|
|
if (Vendor() == GLVendor::Imagination &&
|
|
|
|
Renderer() == GLRenderer::SGX540)
|
|
|
|
{
|
|
|
|
// Bug 980048
|
|
|
|
MarkExtensionUnsupported(OES_EGL_sync);
|
|
|
|
}
|
|
|
|
|
2016-10-26 17:28:08 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
if (Vendor() == GLVendor::Imagination &&
|
|
|
|
Renderer() == GLRenderer::SGX544MP &&
|
|
|
|
AndroidBridge::Bridge()->GetAPIVersion() < 21)
|
|
|
|
{
|
|
|
|
// Bug 1026404
|
|
|
|
MarkExtensionUnsupported(OES_EGL_image);
|
|
|
|
MarkExtensionUnsupported(OES_EGL_image_external);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-07-13 13:16:54 +03:00
|
|
|
if (Vendor() == GLVendor::ARM &&
|
2016-09-21 13:12:52 +03:00
|
|
|
(Renderer() == GLRenderer::Mali400MP ||
|
|
|
|
Renderer() == GLRenderer::Mali450MP))
|
2016-07-13 13:16:54 +03:00
|
|
|
{
|
|
|
|
// Bug 1264505
|
|
|
|
MarkExtensionUnsupported(OES_EGL_image_external);
|
|
|
|
}
|
|
|
|
|
2015-02-13 06:00:41 +03:00
|
|
|
if (Renderer() == GLRenderer::AndroidEmulator) {
|
|
|
|
// 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);
|
2015-04-23 17:09:35 +03:00
|
|
|
// there seems to be a similar issue for EXT_texture_format_BGRA8888
|
|
|
|
// on the Android 4.3 emulator
|
|
|
|
MarkExtensionSupported(EXT_texture_format_BGRA8888);
|
2015-02-13 06:00:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (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);
|
|
|
|
}
|
|
|
|
|
2015-02-06 22:37:04 +03:00
|
|
|
#ifdef XP_MACOSX
|
2015-02-13 06:00:41 +03:00
|
|
|
// 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.
|
2015-02-18 07:34:28 +03:00
|
|
|
// Bug 1124996: Appears to be the same on OSX Yosemite (10.10)
|
2015-02-13 06:00:41 +03:00
|
|
|
if (nsCocoaFeatures::OSXVersionMajor() == 10 &&
|
2015-02-18 07:34:28 +03:00
|
|
|
nsCocoaFeatures::OSXVersionMinor() >= 9 &&
|
2015-02-13 06:00:41 +03:00
|
|
|
Renderer() == GLRenderer::IntelHD3000)
|
|
|
|
{
|
|
|
|
MarkExtensionUnsupported(EXT_texture_compression_s3tc);
|
|
|
|
}
|
2017-08-09 02:32:23 +03:00
|
|
|
|
|
|
|
// OSX supports EXT_texture_sRGB in Legacy contexts, but not in Core contexts.
|
|
|
|
// Though EXT_texture_sRGB was included into GL2.1, it *excludes* the interactions
|
|
|
|
// with s3tc. Strictly speaking, you must advertize support for EXT_texture_sRGB
|
|
|
|
// in order to allow for srgb+s3tc on desktop GL. The omission of EXT_texture_sRGB
|
|
|
|
// in OSX Core contexts appears to be a bug.
|
|
|
|
MarkExtensionSupported(EXT_texture_sRGB);
|
2015-02-06 22:37:04 +03:00
|
|
|
#endif
|
2015-02-13 06:00:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (shouldDumpExts) {
|
|
|
|
printf_stderr("\nActivated extensions:\n");
|
|
|
|
|
|
|
|
for (size_t i = 0; i < mAvailableExtensions.size(); i++) {
|
|
|
|
if (!mAvailableExtensions[i])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
const char* ext = sExtensionNames[i];
|
|
|
|
printf_stderr("[%i] %s\n", (uint32_t)i, ext);
|
|
|
|
}
|
|
|
|
}
|
2010-08-07 09:09:18 +04:00
|
|
|
}
|
|
|
|
|
2012-11-07 02:39:38 +04:00
|
|
|
void
|
|
|
|
GLContext::PlatformStartup()
|
|
|
|
{
|
2015-02-13 06:00:41 +03: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
|
2016-06-11 04:37:07 +03:00
|
|
|
GLContext::ListHasExtension(const GLubyte* extensions, const char* extension)
|
2010-11-10 18:49:52 +03:00
|
|
|
{
|
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
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
const GLubyte* start;
|
|
|
|
GLubyte* where;
|
|
|
|
GLubyte* terminator;
|
2010-06-15 10:55:08 +04:00
|
|
|
|
|
|
|
/* Extension names should not have spaces. */
|
2016-06-11 04:37:07 +03:00
|
|
|
where = (GLubyte*) strchr(extension, ' ');
|
2010-06-15 10:55:08 +04:00
|
|
|
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 (;;) {
|
2016-06-11 04:37:07 +03:00
|
|
|
where = (GLubyte*) strstr((const char*) start, extension);
|
2010-06-15 10:55:08 +04:00
|
|
|
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
|
|
|
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;
|
2016-01-22 01:18:44 +03:00
|
|
|
if (IsSupported(GLFeature::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) {
|
2015-05-08 03:49:14 +03:00
|
|
|
// On the Android 4.3 emulator, IsRenderbuffer may return false incorrectly.
|
|
|
|
MOZ_ASSERT_IF(Renderer() != GLRenderer::AndroidEmulator, fIsRenderbuffer(colorRB));
|
2013-02-14 03:26:24 +04:00
|
|
|
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) {
|
2015-05-08 03:49:14 +03:00
|
|
|
MOZ_ASSERT_IF(Renderer() != GLRenderer::AndroidEmulator, fIsRenderbuffer(depthRB));
|
2013-02-14 03:26:24 +04:00
|
|
|
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) {
|
2015-05-08 03:49:14 +03:00
|
|
|
MOZ_ASSERT_IF(Renderer() != GLRenderer::AndroidEmulator, fIsRenderbuffer(stencilRB));
|
2013-02-14 03:26:24 +04:00
|
|
|
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");
|
2014-10-15 05:24:53 +04:00
|
|
|
#ifdef MOZ_GL_DEBUG
|
2016-06-07 02:29:08 +03:00
|
|
|
if (ShouldSpew()) {
|
2012-06-11 19:25:06 +04:00
|
|
|
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");
|
2014-10-15 05:24:53 +04:00
|
|
|
#ifdef MOZ_GL_DEBUG
|
2016-06-07 02:29:08 +03:00
|
|
|
if (ShouldSpew()) {
|
2012-06-11 19:25:06 +04:00
|
|
|
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) {
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("drawFB created when not requested!");
|
2013-02-14 03:26:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (readFB_out) {
|
|
|
|
*readFB_out = readFB;
|
|
|
|
} else if (readFB) {
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("readFB created when not requested!");
|
2013-02-14 03:26:24 +04:00
|
|
|
}
|
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
|
|
|
|
2010-08-07 09:09:18 +04:00
|
|
|
void
|
|
|
|
GLContext::MarkDestroyed()
|
|
|
|
{
|
2010-09-21 23:41:24 +04:00
|
|
|
if (IsDestroyed())
|
|
|
|
return;
|
|
|
|
|
2016-04-14 23:50:04 +03:00
|
|
|
// Null these before they're naturally nulled after dtor, as we want GLContext to
|
|
|
|
// still be alive in *their* dtors.
|
|
|
|
mScreen = nullptr;
|
|
|
|
mBlitHelper = nullptr;
|
|
|
|
mReadTexImageHelper = nullptr;
|
2013-11-29 08:11:49 +04:00
|
|
|
|
2017-04-06 01:51:49 +03:00
|
|
|
if (!MakeCurrent()) {
|
2012-05-01 06:05:59 +04:00
|
|
|
NS_WARNING("MakeCurrent() failed during MarkDestroyed! Skipping GL object teardown.");
|
|
|
|
}
|
2010-09-21 23:41:24 +04:00
|
|
|
|
2017-10-27 04:32:35 +03:00
|
|
|
mSymbols = {};
|
2010-08-07 09:09:18 +04:00
|
|
|
}
|
|
|
|
|
2014-10-15 05:24:53 +04:00
|
|
|
#ifdef MOZ_GL_DEBUG
|
2014-05-09 05:03:37 +04:00
|
|
|
/* 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
|
2016-06-11 04:37:07 +03:00
|
|
|
GLContext::CreatedProgram(GLContext* aOrigin, GLuint aName)
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
|
|
|
mTrackedPrograms.AppendElement(NamedResource(aOrigin, aName));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-06-11 04:37:07 +03:00
|
|
|
GLContext::CreatedShader(GLContext* aOrigin, GLuint aName)
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
|
|
|
mTrackedShaders.AppendElement(NamedResource(aOrigin, aName));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-06-11 04:37:07 +03:00
|
|
|
GLContext::CreatedBuffers(GLContext* aOrigin, GLsizei aCount, GLuint* aNames)
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
|
|
|
for (GLsizei i = 0; i < aCount; ++i) {
|
|
|
|
mTrackedBuffers.AppendElement(NamedResource(aOrigin, aNames[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-01 20:11:42 +04:00
|
|
|
void
|
2016-06-11 04:37:07 +03:00
|
|
|
GLContext::CreatedQueries(GLContext* aOrigin, GLsizei aCount, GLuint* aNames)
|
2012-11-01 20:11:42 +04:00
|
|
|
{
|
|
|
|
for (GLsizei i = 0; i < aCount; ++i) {
|
|
|
|
mTrackedQueries.AppendElement(NamedResource(aOrigin, aNames[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-19 09:01:14 +04:00
|
|
|
void
|
2016-06-11 04:37:07 +03:00
|
|
|
GLContext::CreatedTextures(GLContext* aOrigin, GLsizei aCount, GLuint* aNames)
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
|
|
|
for (GLsizei i = 0; i < aCount; ++i) {
|
|
|
|
mTrackedTextures.AppendElement(NamedResource(aOrigin, aNames[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-06-11 04:37:07 +03:00
|
|
|
GLContext::CreatedFramebuffers(GLContext* aOrigin, GLsizei aCount, GLuint* aNames)
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
|
|
|
for (GLsizei i = 0; i < aCount; ++i) {
|
|
|
|
mTrackedFramebuffers.AppendElement(NamedResource(aOrigin, aNames[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-06-11 04:37:07 +03:00
|
|
|
GLContext::CreatedRenderbuffers(GLContext* aOrigin, GLsizei aCount, GLuint* aNames)
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
|
|
|
for (GLsizei i = 0; i < aCount; ++i) {
|
|
|
|
mTrackedRenderbuffers.AppendElement(NamedResource(aOrigin, aNames[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-06-11 04:37:07 +03: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
|
2016-06-11 04:37:07 +03:00
|
|
|
GLContext::DeletedProgram(GLContext* aOrigin, GLuint aName)
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
|
|
|
RemoveNamesFromArray(aOrigin, 1, &aName, mTrackedPrograms);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-06-11 04:37:07 +03:00
|
|
|
GLContext::DeletedShader(GLContext* aOrigin, GLuint aName)
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
|
|
|
RemoveNamesFromArray(aOrigin, 1, &aName, mTrackedShaders);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-06-11 04:37:07 +03: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
|
2016-06-11 04:37:07 +03: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
|
2016-06-11 04:37:07 +03:00
|
|
|
GLContext::DeletedTextures(GLContext* aOrigin, GLsizei aCount, const GLuint* aNames)
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
|
|
|
RemoveNamesFromArray(aOrigin, aCount, aNames, mTrackedTextures);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-06-11 04:37:07 +03:00
|
|
|
GLContext::DeletedFramebuffers(GLContext* aOrigin, GLsizei aCount, const GLuint* aNames)
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
|
|
|
RemoveNamesFromArray(aOrigin, aCount, aNames, mTrackedFramebuffers);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-06-11 04:37:07 +03: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
|
2016-06-11 04:37:07 +03:00
|
|
|
MarkContextDestroyedInArray(GLContext* aContext, nsTArray<GLContext::NamedResource>& aArray)
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
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
|
2016-06-11 04:37:07 +03:00
|
|
|
GLContext::SharedContextDestroyed(GLContext* aChild)
|
2010-07-19 09:01:14 +04:00
|
|
|
{
|
|
|
|
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
|
2016-06-11 04:37:07 +03: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();
|
|
|
|
|
2016-06-11 04:37:07 +03: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()
|
|
|
|
{
|
2014-10-25 05:26:41 +04:00
|
|
|
if (!ShouldSpew())
|
2012-08-01 22:57:54 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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::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();
|
|
|
|
}
|
|
|
|
|
2013-09-07 06:13:37 +04:00
|
|
|
bool
|
2014-10-28 04:58:03 +03:00
|
|
|
GLContext::IsOffscreenSizeAllowed(const IntSize& aSize) const
|
|
|
|
{
|
|
|
|
int32_t biggerDimension = std::max(aSize.width, aSize.height);
|
|
|
|
int32_t maxAllowed = std::min(mMaxRenderbufferSize, mMaxTextureSize);
|
|
|
|
return biggerDimension <= maxAllowed;
|
2013-09-07 06:13:37 +04:00
|
|
|
}
|
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-10-28 04:58:03 +03: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) {
|
2015-04-21 03:49:25 +03:00
|
|
|
mBlitHelper.reset(new 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
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
2017-07-24 13:24:14 +03:00
|
|
|
if (MakeCurrent()) {
|
|
|
|
fFlush();
|
|
|
|
}
|
2014-09-10 05:40:51 +04:00
|
|
|
}
|
|
|
|
|
2015-02-13 06:00:41 +03:00
|
|
|
/*static*/ bool
|
|
|
|
GLContext::ShouldDumpExts()
|
|
|
|
{
|
2015-10-28 16:31:00 +03:00
|
|
|
return gfxEnv::GlDumpExtensions();
|
2015-02-13 06:00:41 +03:00
|
|
|
}
|
|
|
|
|
2013-09-07 06:13:37 +04:00
|
|
|
bool
|
2016-06-11 04:37:07 +03:00
|
|
|
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
|
|
|
|
2016-06-11 04:37:07 +03:00
|
|
|
const char* occurrence = strstr(aString, aWantedString);
|
2013-09-07 06:13:37 +04:00
|
|
|
|
|
|
|
// 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
|
2016-06-11 04:37:07 +03:00
|
|
|
const char* afterOccurrence = occurrence + strlen(aWantedString);
|
2013-09-07 06:13:37 +04:00
|
|
|
if (isalpha(*afterOccurrence))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2013-02-14 03:26:24 +04:00
|
|
|
}
|
|
|
|
|
2014-10-25 05:26:41 +04:00
|
|
|
/*static*/ bool
|
|
|
|
GLContext::ShouldSpew()
|
|
|
|
{
|
2015-10-28 16:31:00 +03:00
|
|
|
return gfxEnv::GlSpew();
|
2015-02-13 06:00:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SplitByChar(const nsACString& str, const char delim, std::vector<nsCString>* const out)
|
|
|
|
{
|
|
|
|
uint32_t start = 0;
|
|
|
|
while (true) {
|
|
|
|
int32_t end = str.FindChar(' ', start);
|
|
|
|
if (end == -1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
uint32_t len = (uint32_t)end - start;
|
|
|
|
nsDependentCSubstring substr(str, start, len);
|
|
|
|
out->push_back(nsCString(substr));
|
|
|
|
|
|
|
|
start = end + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsDependentCSubstring substr(str, start);
|
|
|
|
out->push_back(nsCString(substr));
|
|
|
|
}
|
|
|
|
|
2017-07-24 13:24:18 +03:00
|
|
|
bool
|
2015-02-13 06:00:41 +03:00
|
|
|
GLContext::Readback(SharedSurface* src, gfx::DataSourceSurface* dest)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(src && dest);
|
|
|
|
MOZ_ASSERT(dest->GetSize() == src->mSize);
|
|
|
|
|
2017-07-24 13:24:14 +03:00
|
|
|
if (!MakeCurrent()) {
|
2017-07-24 13:24:18 +03:00
|
|
|
return false;
|
2017-07-24 13:24:14 +03:00
|
|
|
}
|
2015-02-13 06:00:41 +03:00
|
|
|
|
|
|
|
SharedSurface* prev = GetLockedSurface();
|
|
|
|
|
|
|
|
const bool needsSwap = src != prev;
|
|
|
|
if (needsSwap) {
|
|
|
|
if (prev)
|
|
|
|
prev->UnlockProd();
|
|
|
|
src->LockProd();
|
|
|
|
}
|
|
|
|
|
|
|
|
GLuint tempFB = 0;
|
2015-10-12 06:21:03 +03:00
|
|
|
GLuint tempTex = 0;
|
2015-02-13 06:00:41 +03:00
|
|
|
|
|
|
|
{
|
|
|
|
ScopedBindFramebuffer autoFB(this);
|
|
|
|
|
2015-06-05 03:15:38 +03:00
|
|
|
// We're consuming from the producer side, so which do we use?
|
|
|
|
// Really, we just want a read-only lock, so ConsumerAcquire is the best match.
|
|
|
|
src->ProducerReadAcquire();
|
2015-02-13 06:00:41 +03:00
|
|
|
|
|
|
|
if (src->mAttachType == AttachmentType::Screen) {
|
|
|
|
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
|
|
|
|
} else {
|
|
|
|
fGenFramebuffers(1, &tempFB);
|
|
|
|
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, tempFB);
|
|
|
|
|
|
|
|
switch (src->mAttachType) {
|
|
|
|
case AttachmentType::GLTexture:
|
|
|
|
fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_COLOR_ATTACHMENT0,
|
|
|
|
src->ProdTextureTarget(), src->ProdTexture(), 0);
|
|
|
|
break;
|
|
|
|
case AttachmentType::GLRenderbuffer:
|
|
|
|
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_COLOR_ATTACHMENT0,
|
|
|
|
LOCAL_GL_RENDERBUFFER, src->ProdRenderbuffer());
|
|
|
|
break;
|
|
|
|
default:
|
2015-12-10 15:01:00 +03:00
|
|
|
MOZ_CRASH("GFX: bad `src->mAttachType`.");
|
2015-02-13 06:00:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
DebugOnly<GLenum> status = fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
|
|
|
|
MOZ_ASSERT(status == LOCAL_GL_FRAMEBUFFER_COMPLETE);
|
|
|
|
}
|
|
|
|
|
2015-10-12 06:21:03 +03:00
|
|
|
if (src->NeedsIndirectReads()) {
|
|
|
|
fGenTextures(1, &tempTex);
|
|
|
|
{
|
|
|
|
ScopedBindTexture autoTex(this, tempTex);
|
|
|
|
|
|
|
|
GLenum format = src->mHasAlpha ? LOCAL_GL_RGBA
|
|
|
|
: LOCAL_GL_RGB;
|
|
|
|
auto width = src->mSize.width;
|
|
|
|
auto height = src->mSize.height;
|
|
|
|
fCopyTexImage2D(LOCAL_GL_TEXTURE_2D, 0, format, 0, 0, width,
|
|
|
|
height, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER,
|
|
|
|
LOCAL_GL_COLOR_ATTACHMENT0,
|
|
|
|
LOCAL_GL_TEXTURE_2D, tempTex, 0);
|
|
|
|
}
|
|
|
|
|
2015-02-13 06:00:41 +03:00
|
|
|
ReadPixelsIntoDataSurface(this, dest);
|
|
|
|
|
2015-06-05 03:15:38 +03:00
|
|
|
src->ProducerReadRelease();
|
2015-02-13 06:00:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tempFB)
|
|
|
|
fDeleteFramebuffers(1, &tempFB);
|
|
|
|
|
2015-10-12 06:21:03 +03:00
|
|
|
if (tempTex) {
|
|
|
|
fDeleteTextures(1, &tempTex);
|
|
|
|
}
|
|
|
|
|
2015-02-13 06:00:41 +03:00
|
|
|
if (needsSwap) {
|
|
|
|
src->UnlockProd();
|
|
|
|
if (prev)
|
|
|
|
prev->LockProd();
|
|
|
|
}
|
2017-07-24 13:24:18 +03:00
|
|
|
|
|
|
|
return true;
|
2014-10-25 05:26:41 +04:00
|
|
|
}
|
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
// Do whatever tear-down is necessary after drawing to our offscreen FBO,
|
|
|
|
// if it's bound.
|
|
|
|
void
|
|
|
|
GLContext::AfterGLDrawCall()
|
|
|
|
{
|
|
|
|
if (mScreen) {
|
|
|
|
mScreen->AfterDrawCall();
|
|
|
|
}
|
|
|
|
mHeavyGLCallsSinceLastFlush = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do whatever setup is necessary to read from our offscreen FBO, if it's
|
|
|
|
// bound.
|
|
|
|
void
|
|
|
|
GLContext::BeforeGLReadCall()
|
|
|
|
{
|
|
|
|
if (mScreen)
|
|
|
|
mScreen->BeforeReadCall();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::fBindFramebuffer(GLenum target, GLuint framebuffer)
|
|
|
|
{
|
|
|
|
if (!mScreen) {
|
|
|
|
raw_fBindFramebuffer(target, framebuffer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (target) {
|
|
|
|
case LOCAL_GL_DRAW_FRAMEBUFFER_EXT:
|
|
|
|
mScreen->BindDrawFB(framebuffer);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case LOCAL_GL_READ_FRAMEBUFFER_EXT:
|
|
|
|
mScreen->BindReadFB(framebuffer);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case LOCAL_GL_FRAMEBUFFER:
|
|
|
|
mScreen->BindFB(framebuffer);
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
|
|
|
// Nothing we care about, likely an error.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
raw_fBindFramebuffer(target, framebuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::fCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x,
|
|
|
|
GLint y, GLsizei width, GLsizei height, GLint border)
|
|
|
|
{
|
|
|
|
if (!IsTextureSizeSafeToPassToDriver(target, width, height)) {
|
|
|
|
// pass wrong values to cause the GL to generate GL_INVALID_VALUE.
|
|
|
|
// See bug 737182 and the comment in IsTextureSizeSafeToPassToDriver.
|
|
|
|
level = -1;
|
|
|
|
width = -1;
|
|
|
|
height = -1;
|
|
|
|
border = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
BeforeGLReadCall();
|
|
|
|
bool didCopyTexImage2D = false;
|
|
|
|
if (mScreen) {
|
|
|
|
didCopyTexImage2D = mScreen->CopyTexImage2D(target, level, internalformat, x,
|
|
|
|
y, width, height, border);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!didCopyTexImage2D) {
|
|
|
|
raw_fCopyTexImage2D(target, level, internalformat, x, y, width, height,
|
|
|
|
border);
|
|
|
|
}
|
|
|
|
AfterGLReadCall();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::fGetIntegerv(GLenum pname, GLint* params)
|
|
|
|
{
|
|
|
|
switch (pname) {
|
|
|
|
// LOCAL_GL_FRAMEBUFFER_BINDING is equal to
|
|
|
|
// LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT,
|
|
|
|
// so we don't need two cases.
|
|
|
|
case LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT:
|
|
|
|
if (mScreen) {
|
|
|
|
*params = mScreen->GetDrawFB();
|
|
|
|
} else {
|
|
|
|
raw_fGetIntegerv(pname, params);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LOCAL_GL_READ_FRAMEBUFFER_BINDING_EXT:
|
|
|
|
if (mScreen) {
|
|
|
|
*params = mScreen->GetReadFB();
|
|
|
|
} else {
|
|
|
|
raw_fGetIntegerv(pname, params);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LOCAL_GL_MAX_TEXTURE_SIZE:
|
|
|
|
MOZ_ASSERT(mMaxTextureSize>0);
|
|
|
|
*params = mMaxTextureSize;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LOCAL_GL_MAX_CUBE_MAP_TEXTURE_SIZE:
|
|
|
|
MOZ_ASSERT(mMaxCubeMapTextureSize>0);
|
|
|
|
*params = mMaxCubeMapTextureSize;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LOCAL_GL_MAX_RENDERBUFFER_SIZE:
|
|
|
|
MOZ_ASSERT(mMaxRenderbufferSize>0);
|
|
|
|
*params = mMaxRenderbufferSize;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LOCAL_GL_VIEWPORT:
|
|
|
|
for (size_t i = 0; i < 4; i++) {
|
|
|
|
params[i] = mViewportRect[i];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LOCAL_GL_SCISSOR_BOX:
|
|
|
|
for (size_t i = 0; i < 4; i++) {
|
|
|
|
params[i] = mScissorRect[i];
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
raw_fGetIntegerv(pname, params);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::fReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
|
|
|
|
GLenum type, GLvoid* pixels)
|
|
|
|
{
|
|
|
|
BeforeGLReadCall();
|
|
|
|
|
|
|
|
bool didReadPixels = false;
|
|
|
|
if (mScreen) {
|
|
|
|
didReadPixels = mScreen->ReadPixels(x, y, width, height, format, type, pixels);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!didReadPixels) {
|
|
|
|
raw_fReadPixels(x, y, width, height, format, type, pixels);
|
|
|
|
}
|
|
|
|
|
|
|
|
AfterGLReadCall();
|
2016-10-28 06:23:00 +03:00
|
|
|
|
|
|
|
// Check if GL is giving back 1.0 alpha for
|
|
|
|
// RGBA reads to RGBA images from no-alpha buffers.
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
if (WorkAroundDriverBugs() &&
|
|
|
|
Vendor() == gl::GLVendor::NVIDIA &&
|
|
|
|
format == LOCAL_GL_RGBA &&
|
|
|
|
type == LOCAL_GL_UNSIGNED_BYTE &&
|
|
|
|
!IsCoreProfile() &&
|
|
|
|
width && height)
|
|
|
|
{
|
|
|
|
GLint alphaBits = 0;
|
|
|
|
fGetIntegerv(LOCAL_GL_ALPHA_BITS, &alphaBits);
|
|
|
|
if (!alphaBits) {
|
|
|
|
const uint32_t alphaMask = 0xff000000;
|
|
|
|
|
|
|
|
uint32_t* itr = (uint32_t*)pixels;
|
|
|
|
uint32_t testPixel = *itr;
|
|
|
|
if ((testPixel & alphaMask) != alphaMask) {
|
|
|
|
// We need to set the alpha channel to 1.0 manually.
|
|
|
|
uint32_t* itrEnd = itr + width*height; // Stride is guaranteed to be width*4.
|
|
|
|
|
|
|
|
for (; itr != itrEnd; itr++) {
|
|
|
|
*itr |= alphaMask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2015-07-15 03:37:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::fDeleteFramebuffers(GLsizei n, const GLuint* names)
|
|
|
|
{
|
|
|
|
if (mScreen) {
|
|
|
|
// Notify mScreen which framebuffers we're deleting.
|
|
|
|
// Otherwise, we will get framebuffer binding mispredictions.
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
mScreen->DeletingFB(names[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-17 05:41:00 +03:00
|
|
|
// Avoid crash by flushing before glDeleteFramebuffers. See bug 1194923.
|
|
|
|
if (mNeedsFlushBeforeDeleteFB) {
|
|
|
|
fFlush();
|
|
|
|
}
|
|
|
|
|
2015-07-15 03:37:28 +03:00
|
|
|
if (n == 1 && *names == 0) {
|
|
|
|
// Deleting framebuffer 0 causes hangs on the DROID. See bug 623228.
|
|
|
|
} else {
|
|
|
|
raw_fDeleteFramebuffers(n, names);
|
|
|
|
}
|
|
|
|
TRACKING_CONTEXT(DeletedFramebuffers(this, n, names));
|
|
|
|
}
|
|
|
|
|
2016-07-15 18:58:58 +03:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
/**
|
|
|
|
* Conservatively estimate whether there is enough available
|
|
|
|
* contiguous virtual address space to map a newly allocated texture.
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
WillTextureMapSucceed(GLsizei width, GLsizei height, GLenum format, GLenum type)
|
|
|
|
{
|
|
|
|
bool willSucceed = false;
|
|
|
|
// Some drivers leave large gaps between textures, so require
|
|
|
|
// there to be double the actual size of the texture available.
|
|
|
|
size_t size = width * height * GetBytesPerTexel(format, type) * 2;
|
|
|
|
|
2016-07-22 16:16:22 +03:00
|
|
|
void *p = mmap(nullptr, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
2016-07-15 18:58:58 +03:00
|
|
|
if (p != MAP_FAILED) {
|
|
|
|
willSucceed = true;
|
|
|
|
munmap(p, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
return willSucceed;
|
|
|
|
}
|
|
|
|
#endif // MOZ_WIDGET_ANDROID
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::fTexImage2D(GLenum target, GLint level, GLint internalformat,
|
|
|
|
GLsizei width, GLsizei height, GLint border,
|
|
|
|
GLenum format, GLenum type, const GLvoid* pixels) {
|
|
|
|
if (!IsTextureSizeSafeToPassToDriver(target, width, height)) {
|
|
|
|
// pass wrong values to cause the GL to generate GL_INVALID_VALUE.
|
|
|
|
// See bug 737182 and the comment in IsTextureSizeSafeToPassToDriver.
|
|
|
|
level = -1;
|
|
|
|
width = -1;
|
|
|
|
height = -1;
|
|
|
|
border = -1;
|
|
|
|
}
|
|
|
|
#if MOZ_WIDGET_ANDROID
|
|
|
|
if (mTextureAllocCrashesOnMapFailure) {
|
|
|
|
// We have no way of knowing whether this texture already has
|
|
|
|
// storage allocated for it, and therefore whether this check
|
|
|
|
// is necessary. We must therefore assume it does not and
|
|
|
|
// always perform the check.
|
|
|
|
if (!WillTextureMapSucceed(width, height, internalformat, type)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
raw_fTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
|
|
|
}
|
2015-07-15 03:37:28 +03:00
|
|
|
|
|
|
|
GLuint
|
|
|
|
GLContext::GetDrawFB()
|
|
|
|
{
|
|
|
|
if (mScreen)
|
|
|
|
return mScreen->GetDrawFB();
|
|
|
|
|
|
|
|
GLuint ret = 0;
|
|
|
|
GetUIntegerv(LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT, &ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLuint
|
|
|
|
GLContext::GetReadFB()
|
|
|
|
{
|
|
|
|
if (mScreen)
|
|
|
|
return mScreen->GetReadFB();
|
|
|
|
|
2015-09-25 17:29:53 +03:00
|
|
|
GLenum bindEnum = IsSupported(GLFeature::split_framebuffer)
|
2015-07-15 03:37:28 +03:00
|
|
|
? LOCAL_GL_READ_FRAMEBUFFER_BINDING_EXT
|
|
|
|
: LOCAL_GL_FRAMEBUFFER_BINDING;
|
|
|
|
|
|
|
|
GLuint ret = 0;
|
|
|
|
GetUIntegerv(bindEnum, &ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLuint
|
|
|
|
GLContext::GetFB()
|
|
|
|
{
|
|
|
|
if (mScreen) {
|
|
|
|
// This has a very important extra assert that checks that we're
|
|
|
|
// not accidentally ignoring a situation where the draw and read
|
|
|
|
// FBs differ.
|
|
|
|
return mScreen->GetFB();
|
|
|
|
}
|
|
|
|
|
|
|
|
GLuint ret = 0;
|
|
|
|
GetUIntegerv(LOCAL_GL_FRAMEBUFFER_BINDING, &ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
GLContext::InitOffscreen(const gfx::IntSize& size, const SurfaceCaps& caps)
|
|
|
|
{
|
|
|
|
if (!CreateScreenBuffer(size, caps))
|
|
|
|
return false;
|
|
|
|
|
2017-07-24 13:24:14 +03:00
|
|
|
if (!MakeCurrent()) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-07-15 03:37:28 +03:00
|
|
|
fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, 0);
|
|
|
|
fScissor(0, 0, size.width, size.height);
|
|
|
|
fViewport(0, 0, size.width, size.height);
|
|
|
|
|
|
|
|
mCaps = mScreen->mCaps;
|
|
|
|
MOZ_ASSERT(!mCaps.any);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
GLContext::IsDrawingToDefaultFramebuffer()
|
|
|
|
{
|
|
|
|
return Screen()->IsDrawFramebufferDefault();
|
|
|
|
}
|
|
|
|
|
2015-09-29 06:35:46 +03:00
|
|
|
GLuint
|
|
|
|
CreateTexture(GLContext* aGL, GLenum aInternalFormat, GLenum aFormat,
|
|
|
|
GLenum aType, const gfx::IntSize& aSize, bool linear)
|
|
|
|
{
|
|
|
|
GLuint tex = 0;
|
|
|
|
aGL->fGenTextures(1, &tex);
|
|
|
|
ScopedBindTexture autoTex(aGL, tex);
|
|
|
|
|
|
|
|
aGL->fTexParameteri(LOCAL_GL_TEXTURE_2D,
|
|
|
|
LOCAL_GL_TEXTURE_MIN_FILTER, linear ? LOCAL_GL_LINEAR
|
|
|
|
: LOCAL_GL_NEAREST);
|
|
|
|
aGL->fTexParameteri(LOCAL_GL_TEXTURE_2D,
|
|
|
|
LOCAL_GL_TEXTURE_MAG_FILTER, linear ? LOCAL_GL_LINEAR
|
|
|
|
: LOCAL_GL_NEAREST);
|
|
|
|
aGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_S,
|
|
|
|
LOCAL_GL_CLAMP_TO_EDGE);
|
|
|
|
aGL->fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_T,
|
|
|
|
LOCAL_GL_CLAMP_TO_EDGE);
|
|
|
|
|
|
|
|
aGL->fTexImage2D(LOCAL_GL_TEXTURE_2D,
|
|
|
|
0,
|
|
|
|
aInternalFormat,
|
|
|
|
aSize.width, aSize.height,
|
|
|
|
0,
|
|
|
|
aFormat,
|
|
|
|
aType,
|
|
|
|
nullptr);
|
|
|
|
|
|
|
|
return tex;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLuint
|
|
|
|
CreateTextureForOffscreen(GLContext* aGL, const GLFormats& aFormats,
|
|
|
|
const gfx::IntSize& aSize)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aFormats.color_texInternalFormat);
|
|
|
|
MOZ_ASSERT(aFormats.color_texFormat);
|
|
|
|
MOZ_ASSERT(aFormats.color_texType);
|
|
|
|
|
2015-09-30 02:04:17 +03:00
|
|
|
GLenum internalFormat = aFormats.color_texInternalFormat;
|
|
|
|
GLenum unpackFormat = aFormats.color_texFormat;
|
|
|
|
GLenum unpackType = aFormats.color_texType;
|
|
|
|
if (aGL->IsANGLE()) {
|
|
|
|
MOZ_ASSERT(internalFormat == LOCAL_GL_RGBA);
|
|
|
|
MOZ_ASSERT(unpackFormat == LOCAL_GL_RGBA);
|
|
|
|
MOZ_ASSERT(unpackType == LOCAL_GL_UNSIGNED_BYTE);
|
|
|
|
internalFormat = LOCAL_GL_BGRA_EXT;
|
|
|
|
unpackFormat = LOCAL_GL_BGRA_EXT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CreateTexture(aGL, internalFormat, unpackFormat, unpackType, aSize);
|
2015-09-29 06:35:46 +03:00
|
|
|
}
|
|
|
|
|
2016-07-15 18:58:58 +03:00
|
|
|
uint32_t
|
|
|
|
GetBytesPerTexel(GLenum format, GLenum type)
|
|
|
|
{
|
|
|
|
// If there is no defined format or type, we're not taking up any memory
|
|
|
|
if (!format || !type) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (format == LOCAL_GL_DEPTH_COMPONENT) {
|
|
|
|
if (type == LOCAL_GL_UNSIGNED_SHORT)
|
|
|
|
return 2;
|
|
|
|
else if (type == LOCAL_GL_UNSIGNED_INT)
|
|
|
|
return 4;
|
|
|
|
} else if (format == LOCAL_GL_DEPTH_STENCIL) {
|
|
|
|
if (type == LOCAL_GL_UNSIGNED_INT_24_8_EXT)
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == LOCAL_GL_UNSIGNED_BYTE || type == LOCAL_GL_FLOAT || type == LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV) {
|
|
|
|
uint32_t multiplier = type == LOCAL_GL_UNSIGNED_BYTE ? 1 : 4;
|
|
|
|
switch (format) {
|
|
|
|
case LOCAL_GL_ALPHA:
|
|
|
|
case LOCAL_GL_LUMINANCE:
|
|
|
|
return 1 * multiplier;
|
|
|
|
case LOCAL_GL_LUMINANCE_ALPHA:
|
|
|
|
return 2 * multiplier;
|
|
|
|
case LOCAL_GL_RGB:
|
|
|
|
return 3 * multiplier;
|
|
|
|
case LOCAL_GL_RGBA:
|
2016-07-25 16:24:34 +03:00
|
|
|
case LOCAL_GL_BGRA_EXT:
|
2016-07-15 18:58:58 +03:00
|
|
|
return 4 * multiplier;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (type == LOCAL_GL_UNSIGNED_SHORT_4_4_4_4 ||
|
|
|
|
type == LOCAL_GL_UNSIGNED_SHORT_5_5_5_1 ||
|
2017-09-29 22:51:29 +03:00
|
|
|
type == LOCAL_GL_UNSIGNED_SHORT_5_6_5 ||
|
|
|
|
type == LOCAL_GL_UNSIGNED_SHORT)
|
2016-07-15 18:58:58 +03:00
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfxCriticalError() << "Unknown texture type " << type << " or format " << format;
|
|
|
|
return 0;
|
|
|
|
}
|
2015-09-29 06:35:46 +03:00
|
|
|
|
2017-08-11 04:00:02 +03:00
|
|
|
bool
|
|
|
|
GLContext::MakeCurrent(bool aForce) const
|
2017-07-07 17:16:00 +03:00
|
|
|
{
|
2017-08-11 04:00:02 +03:00
|
|
|
if (MOZ_UNLIKELY( IsDestroyed() ))
|
2017-07-07 17:16:00 +03:00
|
|
|
return false;
|
|
|
|
|
2017-08-15 23:21:37 +03:00
|
|
|
if (MOZ_LIKELY( !aForce )) {
|
|
|
|
bool isCurrent;
|
|
|
|
if (mUseTLSIsCurrent) {
|
2017-11-28 02:42:16 +03:00
|
|
|
isCurrent = (sCurrentContext.get() == reinterpret_cast<uintptr_t>(this));
|
2017-08-15 23:21:37 +03:00
|
|
|
} else {
|
|
|
|
isCurrent = IsCurrentImpl();
|
|
|
|
}
|
|
|
|
if (MOZ_LIKELY( isCurrent )) {
|
|
|
|
MOZ_ASSERT(IsCurrentImpl());
|
|
|
|
return true;
|
|
|
|
}
|
2017-07-07 17:16:00 +03:00
|
|
|
}
|
|
|
|
|
2017-08-15 23:21:37 +03:00
|
|
|
if (!MakeCurrentImpl())
|
2017-07-07 17:16:00 +03:00
|
|
|
return false;
|
|
|
|
|
2017-11-29 04:11:12 +03:00
|
|
|
sCurrentContext.set(reinterpret_cast<uintptr_t>(this));
|
2017-07-07 17:16:00 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-07-13 21:26:00 +03:00
|
|
|
void
|
|
|
|
GLContext::ResetSyncCallCount(const char* resetReason) const
|
|
|
|
{
|
|
|
|
if (ShouldSpew()) {
|
|
|
|
printf_stderr("On %s, mSyncGLCallCount = %" PRIu64 "\n",
|
|
|
|
resetReason, mSyncGLCallCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
mSyncGLCallCount = 0;
|
|
|
|
}
|
2017-07-07 17:16:00 +03:00
|
|
|
|
2017-08-11 04:01:04 +03:00
|
|
|
// --
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::BeforeGLCall_Debug(const char* const funcName) const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mDebugFlags);
|
|
|
|
|
|
|
|
FlushErrors();
|
|
|
|
|
|
|
|
if (mDebugFlags & DebugFlagTrace) {
|
|
|
|
printf_stderr("[gl:%p] > %s\n", this, funcName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GLContext::AfterGLCall_Debug(const char* const funcName) const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mDebugFlags);
|
|
|
|
|
|
|
|
// calling fFinish() immediately after every GL call makes sure that if this GL command crashes,
|
|
|
|
// the stack trace will actually point to it. Otherwise, OpenGL being an asynchronous API, stack traces
|
|
|
|
// tend to be meaningless
|
|
|
|
mSymbols.fFinish();
|
|
|
|
GLenum err = FlushErrors();
|
|
|
|
|
|
|
|
if (mDebugFlags & DebugFlagTrace) {
|
|
|
|
printf_stderr("[gl:%p] < %s [%s (0x%04x)]\n", this, funcName,
|
|
|
|
GLErrorToString(err), err);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (err != LOCAL_GL_NO_ERROR &&
|
|
|
|
!mLocalErrorScopeStack.size())
|
|
|
|
{
|
|
|
|
printf_stderr("[gl:%p] %s: Generated unexpected %s error."
|
|
|
|
" (0x%04x)\n", this, funcName,
|
|
|
|
GLErrorToString(err), err);
|
|
|
|
|
|
|
|
if (mDebugFlags & DebugFlagAbortOnError) {
|
|
|
|
MOZ_CRASH("Unexpected error with MOZ_GL_DEBUG_ABORT_ON_ERROR. (Run"
|
|
|
|
" with MOZ_GL_DEBUG_ABORT_ON_ERROR=0 to disable)");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*static*/ void
|
|
|
|
GLContext::OnImplicitMakeCurrentFailure(const char* const funcName)
|
|
|
|
{
|
|
|
|
gfxCriticalError() << "Ignoring call to " << funcName << " with failed"
|
|
|
|
<< " mImplicitMakeCurrent.";
|
|
|
|
}
|
|
|
|
|
2010-04-27 06:09:44 +04:00
|
|
|
} /* namespace gl */
|
|
|
|
} /* namespace mozilla */
|