2009-09-03 04:47:49 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
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/. */
|
2009-09-18 10:01:12 +04:00
|
|
|
|
2014-05-13 06:11:40 +04:00
|
|
|
#include "WebGLContext.h"
|
|
|
|
|
2014-05-22 06:03:09 +04:00
|
|
|
#include "GLContext.h"
|
2010-10-16 01:50:15 +04:00
|
|
|
#include "jsapi.h"
|
2014-11-14 07:03:50 +03:00
|
|
|
#include "mozilla/dom/ScriptSettings.h"
|
2014-05-22 06:03:09 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
2014-05-13 06:11:40 +04:00
|
|
|
#include "nsIDOMDataContainerEvent.h"
|
2014-05-22 06:03:09 +04:00
|
|
|
#include "nsIDOMEvent.h"
|
|
|
|
#include "nsIScriptSecurityManager.h"
|
|
|
|
#include "nsIVariant.h"
|
2014-10-27 02:35:02 +03:00
|
|
|
#include "nsPrintfCString.h"
|
2014-05-22 06:03:09 +04:00
|
|
|
#include "nsServiceManagerUtils.h"
|
|
|
|
#include "prprf.h"
|
2014-11-14 07:03:50 +03:00
|
|
|
#include <stdarg.h>
|
2014-05-22 06:03:09 +04:00
|
|
|
#include "WebGLBuffer.h"
|
|
|
|
#include "WebGLExtensions.h"
|
|
|
|
#include "WebGLFramebuffer.h"
|
|
|
|
#include "WebGLProgram.h"
|
|
|
|
#include "WebGLTexture.h"
|
|
|
|
#include "WebGLVertexArray.h"
|
2014-08-21 00:38:42 +04:00
|
|
|
#include "WebGLContextUtils.h"
|
2009-09-03 04:47:49 +04:00
|
|
|
|
2014-01-24 07:53:53 +04:00
|
|
|
namespace mozilla {
|
|
|
|
|
2014-05-02 07:15:58 +04:00
|
|
|
using namespace gl;
|
|
|
|
|
|
|
|
bool
|
2014-10-08 03:52:58 +04:00
|
|
|
IsGLDepthFormat(TexInternalFormat internalformat)
|
2014-05-02 07:15:58 +04:00
|
|
|
{
|
2014-10-08 03:52:58 +04:00
|
|
|
TexInternalFormat unsizedformat = UnsizedInternalFormatFromInternalFormat(internalformat);
|
|
|
|
return unsizedformat == LOCAL_GL_DEPTH_COMPONENT;
|
2014-05-02 07:15:58 +04:00
|
|
|
}
|
|
|
|
|
2014-01-24 07:53:53 +04:00
|
|
|
bool
|
2014-10-08 03:52:58 +04:00
|
|
|
IsGLDepthStencilFormat(TexInternalFormat internalformat)
|
2014-01-24 07:53:53 +04:00
|
|
|
{
|
2014-10-08 03:52:58 +04:00
|
|
|
TexInternalFormat unsizedformat = UnsizedInternalFormatFromInternalFormat(internalformat);
|
|
|
|
return unsizedformat == LOCAL_GL_DEPTH_STENCIL;
|
2014-01-24 07:53:53 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-10-08 03:52:58 +04:00
|
|
|
FormatHasAlpha(TexInternalFormat internalformat)
|
2014-05-02 07:15:58 +04:00
|
|
|
{
|
2014-10-08 03:52:58 +04:00
|
|
|
TexInternalFormat unsizedformat = UnsizedInternalFormatFromInternalFormat(internalformat);
|
|
|
|
return unsizedformat == LOCAL_GL_RGBA ||
|
|
|
|
unsizedformat == LOCAL_GL_LUMINANCE_ALPHA ||
|
|
|
|
unsizedformat == LOCAL_GL_ALPHA ||
|
|
|
|
unsizedformat == LOCAL_GL_SRGB_ALPHA ||
|
|
|
|
unsizedformat == LOCAL_GL_RGBA_INTEGER;
|
2014-05-02 07:15:58 +04:00
|
|
|
}
|
2014-08-21 00:38:42 +04:00
|
|
|
|
2014-09-19 03:14:22 +04:00
|
|
|
TexTarget
|
|
|
|
TexImageTargetToTexTarget(TexImageTarget texImageTarget)
|
2014-09-03 23:17:18 +04:00
|
|
|
{
|
2014-09-19 03:14:22 +04:00
|
|
|
switch (texImageTarget.get()) {
|
2014-09-03 23:17:18 +04:00
|
|
|
case LOCAL_GL_TEXTURE_2D:
|
2014-10-14 03:42:20 +04:00
|
|
|
case LOCAL_GL_TEXTURE_3D:
|
|
|
|
return texImageTarget.get();
|
2014-09-03 23:17:18 +04:00
|
|
|
case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X:
|
|
|
|
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
|
|
|
|
case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
|
|
|
|
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
|
|
|
|
case LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
|
|
|
case LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
|
|
|
return LOCAL_GL_TEXTURE_CUBE_MAP;
|
|
|
|
default:
|
2014-10-14 03:42:20 +04:00
|
|
|
MOZ_ASSERT(false, "Bad texture target");
|
2014-09-19 03:14:22 +04:00
|
|
|
// Should be caught by the constructor for TexTarget
|
2014-09-03 23:17:18 +04:00
|
|
|
return LOCAL_GL_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-08 03:52:58 +04:00
|
|
|
GLComponents::GLComponents(TexInternalFormat internalformat)
|
2014-08-21 00:38:42 +04:00
|
|
|
{
|
2014-10-08 03:52:58 +04:00
|
|
|
TexInternalFormat unsizedformat = UnsizedInternalFormatFromInternalFormat(internalformat);
|
2014-08-21 00:38:42 +04:00
|
|
|
mComponents = 0;
|
|
|
|
|
2014-10-08 03:52:58 +04:00
|
|
|
switch (unsizedformat.get()) {
|
2014-11-14 07:03:50 +03:00
|
|
|
case LOCAL_GL_RGBA:
|
|
|
|
case LOCAL_GL_RGBA4:
|
|
|
|
case LOCAL_GL_RGBA8:
|
|
|
|
case LOCAL_GL_RGB5_A1:
|
|
|
|
// Luminance + Alpha can be converted
|
|
|
|
// to and from RGBA
|
|
|
|
case LOCAL_GL_LUMINANCE_ALPHA:
|
|
|
|
mComponents |= Components::Alpha;
|
|
|
|
// Drops through
|
|
|
|
case LOCAL_GL_RGB:
|
|
|
|
case LOCAL_GL_RGB565:
|
|
|
|
// Luminance can be converted to and from RGB
|
|
|
|
case LOCAL_GL_LUMINANCE:
|
|
|
|
mComponents |= Components::Red | Components::Green | Components::Blue;
|
|
|
|
break;
|
|
|
|
case LOCAL_GL_ALPHA:
|
|
|
|
mComponents |= Components::Alpha;
|
|
|
|
break;
|
|
|
|
case LOCAL_GL_DEPTH_COMPONENT:
|
|
|
|
mComponents |= Components::Depth;
|
|
|
|
break;
|
|
|
|
case LOCAL_GL_DEPTH_STENCIL:
|
|
|
|
mComponents |= Components::Stencil;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT(false, "Unhandled case - GLComponents");
|
|
|
|
break;
|
2014-08-21 00:38:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
GLComponents::IsSubsetOf(const GLComponents& other) const
|
|
|
|
{
|
|
|
|
return (mComponents | other.mComponents) == other.mComponents;
|
|
|
|
}
|
2014-05-02 07:15:58 +04:00
|
|
|
|
2014-10-08 03:52:58 +04:00
|
|
|
TexType
|
|
|
|
TypeFromInternalFormat(TexInternalFormat internalformat)
|
|
|
|
{
|
|
|
|
#define HANDLE_WEBGL_INTERNAL_FORMAT(table_effectiveinternalformat, table_internalformat, table_type) \
|
|
|
|
if (internalformat == table_effectiveinternalformat) { \
|
|
|
|
return table_type; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "WebGLInternalFormatsTable.h"
|
|
|
|
|
|
|
|
// if we're here, then internalformat is not an effective internalformat i.e. is an unsized internalformat.
|
|
|
|
return LOCAL_GL_NONE; // no size, no type
|
|
|
|
}
|
|
|
|
|
|
|
|
TexInternalFormat
|
|
|
|
UnsizedInternalFormatFromInternalFormat(TexInternalFormat internalformat)
|
|
|
|
{
|
|
|
|
#define HANDLE_WEBGL_INTERNAL_FORMAT(table_effectiveinternalformat, table_internalformat, table_type) \
|
|
|
|
if (internalformat == table_effectiveinternalformat) { \
|
|
|
|
return table_internalformat; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "WebGLInternalFormatsTable.h"
|
|
|
|
|
|
|
|
// if we're here, then internalformat is not an effective internalformat i.e. is an unsized internalformat.
|
|
|
|
// so we can just return it.
|
|
|
|
return internalformat;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note that the following two functions are inverse of each other:
|
|
|
|
* EffectiveInternalFormatFromInternalFormatAndType and
|
|
|
|
* InternalFormatAndTypeFromEffectiveInternalFormat both implement OpenGL ES 3.0.3 Table 3.2
|
|
|
|
* but in opposite directions.
|
2014-05-02 07:15:58 +04:00
|
|
|
*/
|
2014-10-08 03:52:58 +04:00
|
|
|
TexInternalFormat
|
|
|
|
EffectiveInternalFormatFromUnsizedInternalFormatAndType(TexInternalFormat internalformat,
|
|
|
|
TexType type)
|
2014-01-24 07:53:53 +04:00
|
|
|
{
|
2014-10-08 03:52:58 +04:00
|
|
|
MOZ_ASSERT(TypeFromInternalFormat(internalformat) == LOCAL_GL_NONE);
|
2014-05-02 07:15:58 +04:00
|
|
|
|
2014-10-08 03:52:58 +04:00
|
|
|
#define HANDLE_WEBGL_INTERNAL_FORMAT(table_effectiveinternalformat, table_internalformat, table_type) \
|
|
|
|
if (internalformat == table_internalformat && type == table_type) { \
|
|
|
|
return table_effectiveinternalformat; \
|
2014-05-02 07:15:58 +04:00
|
|
|
}
|
|
|
|
|
2014-10-08 03:52:58 +04:00
|
|
|
#include "WebGLInternalFormatsTable.h"
|
2014-05-02 07:15:58 +04:00
|
|
|
|
2014-10-08 03:52:58 +04:00
|
|
|
// If we're here, that means that type was incompatible with the given internalformat.
|
|
|
|
return LOCAL_GL_NONE;
|
|
|
|
}
|
2014-05-02 07:15:58 +04:00
|
|
|
|
2014-10-08 03:52:58 +04:00
|
|
|
void
|
|
|
|
UnsizedInternalFormatAndTypeFromEffectiveInternalFormat(TexInternalFormat effectiveinternalformat,
|
2014-11-14 07:03:50 +03:00
|
|
|
TexInternalFormat* const out_internalformat,
|
|
|
|
TexType* const out_type)
|
2014-10-08 03:52:58 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(TypeFromInternalFormat(effectiveinternalformat) != LOCAL_GL_NONE);
|
2014-05-02 07:15:58 +04:00
|
|
|
|
2014-10-08 03:52:58 +04:00
|
|
|
MOZ_ASSERT(out_internalformat);
|
|
|
|
MOZ_ASSERT(out_type);
|
2014-05-02 07:15:58 +04:00
|
|
|
|
2014-10-08 03:52:58 +04:00
|
|
|
GLenum internalformat = LOCAL_GL_NONE;
|
|
|
|
GLenum type = LOCAL_GL_NONE;
|
|
|
|
|
|
|
|
switch (effectiveinternalformat.get()) {
|
|
|
|
|
|
|
|
#define HANDLE_WEBGL_INTERNAL_FORMAT(table_effectiveinternalformat, table_internalformat, table_type) \
|
|
|
|
case table_effectiveinternalformat: \
|
|
|
|
internalformat = table_internalformat; \
|
|
|
|
type = table_type; \
|
|
|
|
break;
|
|
|
|
|
|
|
|
#include "WebGLInternalFormatsTable.h"
|
|
|
|
|
|
|
|
default:
|
|
|
|
MOZ_CRASH(); // impossible to get here
|
2014-05-02 07:15:58 +04:00
|
|
|
}
|
|
|
|
|
2014-10-08 03:52:58 +04:00
|
|
|
*out_internalformat = internalformat;
|
|
|
|
*out_type = type;
|
|
|
|
}
|
2014-05-02 07:15:58 +04:00
|
|
|
|
2014-10-08 03:52:58 +04:00
|
|
|
TexInternalFormat
|
|
|
|
EffectiveInternalFormatFromInternalFormatAndType(TexInternalFormat internalformat,
|
|
|
|
TexType type)
|
|
|
|
{
|
|
|
|
TexType typeOfInternalFormat = TypeFromInternalFormat(internalformat);
|
2014-11-14 07:03:50 +03:00
|
|
|
if (typeOfInternalFormat == LOCAL_GL_NONE)
|
2014-10-08 03:52:58 +04:00
|
|
|
return EffectiveInternalFormatFromUnsizedInternalFormatAndType(internalformat, type);
|
2014-11-14 07:03:50 +03:00
|
|
|
|
|
|
|
if (typeOfInternalFormat == type)
|
2014-10-08 03:52:58 +04:00
|
|
|
return internalformat;
|
2014-11-14 07:03:50 +03:00
|
|
|
|
|
|
|
return LOCAL_GL_NONE;
|
2014-05-02 07:15:58 +04:00
|
|
|
}
|
|
|
|
|
2014-10-08 03:52:58 +04:00
|
|
|
/**
|
|
|
|
* Convert effective internalformat into GL function parameters
|
|
|
|
* valid for underlying driver.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
DriverFormatsFromEffectiveInternalFormat(gl::GLContext* gl,
|
|
|
|
TexInternalFormat effectiveinternalformat,
|
2014-11-14 07:03:50 +03:00
|
|
|
GLenum* const out_driverInternalFormat,
|
|
|
|
GLenum* const out_driverFormat,
|
|
|
|
GLenum* const out_driverType)
|
2014-05-02 07:15:58 +04:00
|
|
|
{
|
2014-10-08 03:52:58 +04:00
|
|
|
MOZ_ASSERT(out_driverInternalFormat);
|
|
|
|
MOZ_ASSERT(out_driverFormat);
|
|
|
|
MOZ_ASSERT(out_driverType);
|
|
|
|
|
|
|
|
TexInternalFormat unsizedinternalformat = LOCAL_GL_NONE;
|
|
|
|
TexType type = LOCAL_GL_NONE;
|
2014-09-23 21:48:27 +04:00
|
|
|
|
2014-10-08 03:52:58 +04:00
|
|
|
UnsizedInternalFormatAndTypeFromEffectiveInternalFormat(effectiveinternalformat,
|
2014-11-14 07:03:50 +03:00
|
|
|
&unsizedinternalformat,
|
|
|
|
&type);
|
2014-10-08 03:52:58 +04:00
|
|
|
|
|
|
|
// driverType: almost always the generic type that we just got, except on ES
|
|
|
|
// we must replace HALF_FLOAT by HALF_FLOAT_OES
|
|
|
|
GLenum driverType = type.get();
|
2014-11-14 07:03:50 +03:00
|
|
|
if (gl->IsGLES() && type == LOCAL_GL_HALF_FLOAT)
|
2014-10-08 03:52:58 +04:00
|
|
|
driverType = LOCAL_GL_HALF_FLOAT_OES;
|
2014-05-02 07:15:58 +04:00
|
|
|
|
2014-10-08 03:52:58 +04:00
|
|
|
// driverFormat: always just the unsized internalformat that we just got
|
|
|
|
GLenum driverFormat = unsizedinternalformat.get();
|
|
|
|
|
|
|
|
// driverInternalFormat: almost always the same as driverFormat, but on desktop GL,
|
|
|
|
// in some cases we must pass a different value. On ES, they are equal by definition
|
|
|
|
// as it is an error to pass internalformat!=format.
|
|
|
|
GLenum driverInternalFormat = driverFormat;
|
|
|
|
if (!gl->IsGLES()) {
|
|
|
|
// Cases where desktop OpenGL requires a tweak to 'format'
|
2014-11-14 07:03:50 +03:00
|
|
|
if (driverFormat == LOCAL_GL_SRGB)
|
2014-10-08 03:52:58 +04:00
|
|
|
driverFormat = LOCAL_GL_RGB;
|
2014-11-14 07:03:50 +03:00
|
|
|
else if (driverFormat == LOCAL_GL_SRGB_ALPHA)
|
2014-10-08 03:52:58 +04:00
|
|
|
driverFormat = LOCAL_GL_RGBA;
|
|
|
|
|
2014-10-10 00:07:07 +04:00
|
|
|
// WebGL2's new formats are not legal values for internalformat,
|
|
|
|
// as using unsized internalformat is deprecated.
|
|
|
|
if (driverFormat == LOCAL_GL_RED ||
|
|
|
|
driverFormat == LOCAL_GL_RG ||
|
|
|
|
driverFormat == LOCAL_GL_RED_INTEGER ||
|
|
|
|
driverFormat == LOCAL_GL_RG_INTEGER ||
|
|
|
|
driverFormat == LOCAL_GL_RGB_INTEGER ||
|
|
|
|
driverFormat == LOCAL_GL_RGBA_INTEGER)
|
|
|
|
{
|
|
|
|
driverInternalFormat = effectiveinternalformat.get();
|
|
|
|
}
|
|
|
|
|
2014-10-08 03:52:58 +04:00
|
|
|
// Cases where desktop OpenGL requires a sized internalformat,
|
|
|
|
// as opposed to the unsized internalformat that had the same
|
|
|
|
// GLenum value as 'format', in order to get the precise
|
|
|
|
// semantics that we want. For example, for floating-point formats,
|
|
|
|
// we seem to need a sized internalformat to get non-clamped floating
|
|
|
|
// point texture sampling. Can't find the spec reference for that,
|
|
|
|
// but that's at least the case on my NVIDIA driver version 331.
|
|
|
|
if (unsizedinternalformat == LOCAL_GL_DEPTH_COMPONENT ||
|
|
|
|
unsizedinternalformat == LOCAL_GL_DEPTH_STENCIL ||
|
|
|
|
type == LOCAL_GL_FLOAT ||
|
|
|
|
type == LOCAL_GL_HALF_FLOAT)
|
|
|
|
{
|
|
|
|
driverInternalFormat = effectiveinternalformat.get();
|
2014-05-02 07:15:58 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-08 03:52:58 +04:00
|
|
|
*out_driverInternalFormat = driverInternalFormat;
|
|
|
|
*out_driverFormat = driverFormat;
|
|
|
|
*out_driverType = driverType;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the bits per texel for format & type combination.
|
|
|
|
* Assumes that format & type are a valid combination as checked with
|
|
|
|
* ValidateTexImageFormatAndType().
|
|
|
|
*/
|
|
|
|
size_t
|
|
|
|
GetBitsPerTexel(TexInternalFormat effectiveinternalformat)
|
|
|
|
{
|
|
|
|
switch (effectiveinternalformat.get()) {
|
|
|
|
case LOCAL_GL_COMPRESSED_RGB_PVRTC_2BPPV1:
|
|
|
|
case LOCAL_GL_COMPRESSED_RGBA_PVRTC_2BPPV1:
|
|
|
|
return 2;
|
|
|
|
|
|
|
|
case LOCAL_GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
|
|
|
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
|
|
|
case LOCAL_GL_ATC_RGB:
|
|
|
|
case LOCAL_GL_COMPRESSED_RGB_PVRTC_4BPPV1:
|
|
|
|
case LOCAL_GL_COMPRESSED_RGBA_PVRTC_4BPPV1:
|
|
|
|
case LOCAL_GL_ETC1_RGB8_OES:
|
|
|
|
return 4;
|
|
|
|
|
|
|
|
case LOCAL_GL_ALPHA8:
|
|
|
|
case LOCAL_GL_LUMINANCE8:
|
|
|
|
case LOCAL_GL_R8:
|
|
|
|
case LOCAL_GL_R8I:
|
|
|
|
case LOCAL_GL_R8UI:
|
|
|
|
case LOCAL_GL_R8_SNORM:
|
|
|
|
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
|
|
|
|
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
|
|
|
case LOCAL_GL_ATC_RGBA_EXPLICIT_ALPHA:
|
|
|
|
case LOCAL_GL_ATC_RGBA_INTERPOLATED_ALPHA:
|
|
|
|
return 8;
|
|
|
|
|
|
|
|
case LOCAL_GL_LUMINANCE8_ALPHA8:
|
|
|
|
case LOCAL_GL_RGBA4:
|
|
|
|
case LOCAL_GL_RGB5_A1:
|
|
|
|
case LOCAL_GL_DEPTH_COMPONENT16:
|
|
|
|
case LOCAL_GL_RG8:
|
|
|
|
case LOCAL_GL_R16I:
|
|
|
|
case LOCAL_GL_R16UI:
|
|
|
|
case LOCAL_GL_RGB565:
|
|
|
|
case LOCAL_GL_R16F:
|
|
|
|
case LOCAL_GL_RG8I:
|
|
|
|
case LOCAL_GL_RG8UI:
|
|
|
|
case LOCAL_GL_RG8_SNORM:
|
|
|
|
case LOCAL_GL_ALPHA16F_EXT:
|
|
|
|
case LOCAL_GL_LUMINANCE16F_EXT:
|
|
|
|
return 16;
|
|
|
|
|
|
|
|
case LOCAL_GL_RGB8:
|
|
|
|
case LOCAL_GL_DEPTH_COMPONENT24:
|
|
|
|
case LOCAL_GL_SRGB8:
|
|
|
|
case LOCAL_GL_RGB8UI:
|
|
|
|
case LOCAL_GL_RGB8I:
|
|
|
|
case LOCAL_GL_RGB8_SNORM:
|
|
|
|
return 24;
|
|
|
|
|
|
|
|
case LOCAL_GL_RGBA8:
|
|
|
|
case LOCAL_GL_RGB10_A2:
|
|
|
|
case LOCAL_GL_R32F:
|
|
|
|
case LOCAL_GL_RG16F:
|
|
|
|
case LOCAL_GL_R32I:
|
|
|
|
case LOCAL_GL_R32UI:
|
|
|
|
case LOCAL_GL_RG16I:
|
|
|
|
case LOCAL_GL_RG16UI:
|
|
|
|
case LOCAL_GL_DEPTH24_STENCIL8:
|
|
|
|
case LOCAL_GL_R11F_G11F_B10F:
|
|
|
|
case LOCAL_GL_RGB9_E5:
|
|
|
|
case LOCAL_GL_SRGB8_ALPHA8:
|
|
|
|
case LOCAL_GL_DEPTH_COMPONENT32F:
|
|
|
|
case LOCAL_GL_RGBA8UI:
|
|
|
|
case LOCAL_GL_RGBA8I:
|
|
|
|
case LOCAL_GL_RGBA8_SNORM:
|
|
|
|
case LOCAL_GL_RGB10_A2UI:
|
|
|
|
case LOCAL_GL_LUMINANCE_ALPHA16F_EXT:
|
|
|
|
case LOCAL_GL_ALPHA32F_EXT:
|
|
|
|
case LOCAL_GL_LUMINANCE32F_EXT:
|
|
|
|
return 32;
|
|
|
|
|
|
|
|
case LOCAL_GL_DEPTH32F_STENCIL8:
|
|
|
|
return 40;
|
|
|
|
|
|
|
|
case LOCAL_GL_RGB16F:
|
|
|
|
case LOCAL_GL_RGB16UI:
|
|
|
|
case LOCAL_GL_RGB16I:
|
|
|
|
return 48;
|
|
|
|
|
|
|
|
case LOCAL_GL_RG32F:
|
|
|
|
case LOCAL_GL_RG32I:
|
|
|
|
case LOCAL_GL_RG32UI:
|
|
|
|
case LOCAL_GL_RGBA16F:
|
|
|
|
case LOCAL_GL_RGBA16UI:
|
|
|
|
case LOCAL_GL_RGBA16I:
|
|
|
|
case LOCAL_GL_LUMINANCE_ALPHA32F_EXT:
|
|
|
|
return 64;
|
|
|
|
|
|
|
|
case LOCAL_GL_RGB32F:
|
|
|
|
case LOCAL_GL_RGB32UI:
|
|
|
|
case LOCAL_GL_RGB32I:
|
|
|
|
return 96;
|
|
|
|
|
|
|
|
case LOCAL_GL_RGBA32F:
|
|
|
|
case LOCAL_GL_RGBA32UI:
|
|
|
|
case LOCAL_GL_RGBA32I:
|
|
|
|
return 128;
|
|
|
|
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT(false, "Unhandled format");
|
|
|
|
return 0;
|
|
|
|
}
|
2014-01-24 07:53:53 +04:00
|
|
|
}
|
|
|
|
|
2009-09-03 04:47:49 +04:00
|
|
|
void
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext::GenerateWarning(const char* fmt, ...)
|
2009-09-03 04:47:49 +04:00
|
|
|
{
|
2010-09-13 19:40:01 +04:00
|
|
|
va_list ap;
|
|
|
|
va_start(ap, fmt);
|
2009-09-03 04:47:49 +04:00
|
|
|
|
2012-05-23 20:07:29 +04:00
|
|
|
GenerateWarning(fmt, ap);
|
2009-09-03 04:47:49 +04:00
|
|
|
|
2010-09-13 19:40:01 +04:00
|
|
|
va_end(ap);
|
2009-09-03 04:47:49 +04:00
|
|
|
}
|
|
|
|
|
2010-05-15 17:55:45 +04:00
|
|
|
void
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext::GenerateWarning(const char* fmt, va_list ap)
|
2009-09-03 04:47:49 +04:00
|
|
|
{
|
2012-05-29 22:44:31 +04:00
|
|
|
if (!ShouldGenerateWarnings())
|
2012-05-23 20:07:10 +04:00
|
|
|
return;
|
|
|
|
|
2012-05-29 22:44:31 +04:00
|
|
|
mAlreadyGeneratedWarnings++;
|
2010-10-16 01:50:15 +04:00
|
|
|
|
2010-09-13 19:40:01 +04:00
|
|
|
char buf[1024];
|
2010-10-16 01:50:15 +04:00
|
|
|
PR_vsnprintf(buf, 1024, fmt, ap);
|
2010-09-13 19:40:01 +04:00
|
|
|
|
2010-10-16 01:50:15 +04:00
|
|
|
// no need to print to stderr, as JS_ReportWarning takes care of this for us.
|
|
|
|
|
2013-04-29 22:16:17 +04:00
|
|
|
AutoJSContext cx;
|
|
|
|
JS_ReportWarning(cx, "WebGL: %s", buf);
|
|
|
|
if (!ShouldGenerateWarnings()) {
|
|
|
|
JS_ReportWarning(cx,
|
2014-11-14 07:03:50 +03:00
|
|
|
"WebGL: No further warnings will be reported for this"
|
|
|
|
" WebGL context. (already reported %d warnings)",
|
|
|
|
mAlreadyGeneratedWarnings);
|
2012-05-23 20:07:10 +04:00
|
|
|
}
|
2010-09-13 19:40:01 +04:00
|
|
|
}
|
|
|
|
|
2013-09-04 16:14:50 +04:00
|
|
|
bool
|
|
|
|
WebGLContext::ShouldGenerateWarnings() const
|
|
|
|
{
|
2014-11-14 07:03:50 +03:00
|
|
|
if (mMaxWarnings == -1)
|
2013-09-04 16:14:50 +04:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return mAlreadyGeneratedWarnings < mMaxWarnings;
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:28:34 +04:00
|
|
|
CheckedUint32
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext::GetImageSize(GLsizei height, GLsizei width, GLsizei depth,
|
|
|
|
uint32_t pixelSize, uint32_t packOrUnpackAlignment)
|
2011-09-01 23:28:34 +04:00
|
|
|
{
|
|
|
|
CheckedUint32 checked_plainRowSize = CheckedUint32(width) * pixelSize;
|
|
|
|
|
|
|
|
// alignedRowSize = row size rounded up to next multiple of packAlignment
|
|
|
|
CheckedUint32 checked_alignedRowSize = RoundedToNextMultipleOf(checked_plainRowSize, packOrUnpackAlignment);
|
|
|
|
|
|
|
|
// if height is 0, we don't need any memory to store this; without this check, we'll get an overflow
|
2014-11-14 07:03:50 +03:00
|
|
|
CheckedUint32 checked_2dImageSize = 0;
|
|
|
|
if (height >= 1) {
|
|
|
|
checked_2dImageSize = (height-1) * checked_alignedRowSize +
|
|
|
|
checked_plainRowSize;
|
|
|
|
}
|
2011-09-01 23:28:34 +04:00
|
|
|
|
2014-10-14 03:42:20 +04:00
|
|
|
// FIXME - we should honor UNPACK_IMAGE_HEIGHT
|
|
|
|
CheckedUint32 checked_imageSize = checked_2dImageSize * depth;
|
|
|
|
return checked_imageSize;
|
2011-09-01 23:28:34 +04:00
|
|
|
}
|
|
|
|
|
2012-05-04 20:38:44 +04:00
|
|
|
void
|
2013-09-04 16:14:43 +04:00
|
|
|
WebGLContext::SynthesizeGLError(GLenum err)
|
2010-05-15 17:55:45 +04:00
|
|
|
{
|
2014-03-08 01:16:34 +04:00
|
|
|
/* ES2 section 2.5 "GL Errors" states that implementations can have
|
|
|
|
* multiple 'flags', as errors might be caught in different parts of
|
|
|
|
* a distributed implementation.
|
|
|
|
* We're signing up as a distributed implementation here, with
|
|
|
|
* separate flags for WebGL and the underlying GLContext.
|
|
|
|
*/
|
2011-07-08 04:01:16 +04:00
|
|
|
if (!mWebGLError)
|
|
|
|
mWebGLError = err;
|
2010-05-15 17:55:45 +04:00
|
|
|
}
|
|
|
|
|
2012-05-04 20:38:44 +04:00
|
|
|
void
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext::SynthesizeGLError(GLenum err, const char* fmt, ...)
|
2010-05-15 17:55:45 +04:00
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
va_start(va, fmt);
|
2012-05-23 20:07:29 +04:00
|
|
|
GenerateWarning(fmt, va);
|
2010-05-15 17:55:45 +04:00
|
|
|
va_end(va);
|
|
|
|
|
|
|
|
return SynthesizeGLError(err);
|
|
|
|
}
|
|
|
|
|
2012-05-04 20:38:44 +04:00
|
|
|
void
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext::ErrorInvalidEnum(const char* fmt, ...)
|
2010-05-15 17:55:45 +04:00
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
va_start(va, fmt);
|
2012-05-23 20:07:29 +04:00
|
|
|
GenerateWarning(fmt, va);
|
2010-05-15 17:55:45 +04:00
|
|
|
va_end(va);
|
|
|
|
|
|
|
|
return SynthesizeGLError(LOCAL_GL_INVALID_ENUM);
|
|
|
|
}
|
|
|
|
|
2013-09-04 16:14:50 +04:00
|
|
|
void
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext::ErrorInvalidEnumInfo(const char* info, GLenum enumvalue)
|
2013-09-04 16:14:50 +04:00
|
|
|
{
|
2014-10-27 02:35:02 +03:00
|
|
|
nsCString name;
|
|
|
|
EnumName(enumvalue, &name);
|
|
|
|
|
|
|
|
return ErrorInvalidEnum("%s: invalid enum value %s", info, name.get());
|
2013-09-04 16:14:50 +04:00
|
|
|
}
|
|
|
|
|
2012-05-04 20:38:44 +04:00
|
|
|
void
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext::ErrorInvalidOperation(const char* fmt, ...)
|
2010-05-15 17:55:45 +04:00
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
va_start(va, fmt);
|
2012-05-23 20:07:29 +04:00
|
|
|
GenerateWarning(fmt, va);
|
2010-05-15 17:55:45 +04:00
|
|
|
va_end(va);
|
|
|
|
|
|
|
|
return SynthesizeGLError(LOCAL_GL_INVALID_OPERATION);
|
|
|
|
}
|
|
|
|
|
2012-05-04 20:38:44 +04:00
|
|
|
void
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext::ErrorInvalidValue(const char* fmt, ...)
|
2010-05-15 17:55:45 +04:00
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
va_start(va, fmt);
|
2012-05-23 20:07:29 +04:00
|
|
|
GenerateWarning(fmt, va);
|
2010-05-15 17:55:45 +04:00
|
|
|
va_end(va);
|
2009-09-03 04:47:49 +04:00
|
|
|
|
2010-05-15 17:55:45 +04:00
|
|
|
return SynthesizeGLError(LOCAL_GL_INVALID_VALUE);
|
2009-09-03 04:47:49 +04:00
|
|
|
}
|
2011-02-25 01:17:34 +03:00
|
|
|
|
2012-05-04 20:38:44 +04:00
|
|
|
void
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext::ErrorInvalidFramebufferOperation(const char* fmt, ...)
|
2012-01-25 01:12:31 +04:00
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
va_start(va, fmt);
|
2012-05-23 20:07:29 +04:00
|
|
|
GenerateWarning(fmt, va);
|
2012-01-25 01:12:31 +04:00
|
|
|
va_end(va);
|
|
|
|
|
|
|
|
return SynthesizeGLError(LOCAL_GL_INVALID_FRAMEBUFFER_OPERATION);
|
|
|
|
}
|
|
|
|
|
2012-05-04 20:38:44 +04:00
|
|
|
void
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLContext::ErrorOutOfMemory(const char* fmt, ...)
|
2011-02-25 01:17:34 +03:00
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
va_start(va, fmt);
|
2012-05-23 20:07:29 +04:00
|
|
|
GenerateWarning(fmt, va);
|
2011-02-25 01:17:34 +03:00
|
|
|
va_end(va);
|
|
|
|
|
|
|
|
return SynthesizeGLError(LOCAL_GL_OUT_OF_MEMORY);
|
|
|
|
}
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
const char*
|
2011-07-08 04:01:16 +04:00
|
|
|
WebGLContext::ErrorName(GLenum error)
|
|
|
|
{
|
|
|
|
switch(error) {
|
2014-11-14 07:03:50 +03:00
|
|
|
case LOCAL_GL_INVALID_ENUM:
|
|
|
|
return "INVALID_ENUM";
|
|
|
|
case LOCAL_GL_INVALID_OPERATION:
|
|
|
|
return "INVALID_OPERATION";
|
|
|
|
case LOCAL_GL_INVALID_VALUE:
|
|
|
|
return "INVALID_VALUE";
|
|
|
|
case LOCAL_GL_OUT_OF_MEMORY:
|
|
|
|
return "OUT_OF_MEMORY";
|
|
|
|
case LOCAL_GL_INVALID_FRAMEBUFFER_OPERATION:
|
|
|
|
return "INVALID_FRAMEBUFFER_OPERATION";
|
|
|
|
case LOCAL_GL_NO_ERROR:
|
|
|
|
return "NO_ERROR";
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT(false);
|
|
|
|
return "[unknown WebGL error]";
|
2011-07-08 04:01:16 +04:00
|
|
|
}
|
2012-04-04 03:42:06 +04:00
|
|
|
}
|
|
|
|
|
2014-10-27 02:35:02 +03:00
|
|
|
// This version is 'fallible' and will return NULL if glenum is not recognized.
|
2014-06-03 00:30:00 +04:00
|
|
|
const char*
|
|
|
|
WebGLContext::EnumName(GLenum glenum)
|
|
|
|
{
|
|
|
|
switch (glenum) {
|
|
|
|
#define XX(x) case LOCAL_GL_##x: return #x
|
|
|
|
XX(ALPHA);
|
|
|
|
XX(ATC_RGB);
|
|
|
|
XX(ATC_RGBA_EXPLICIT_ALPHA);
|
|
|
|
XX(ATC_RGBA_INTERPOLATED_ALPHA);
|
|
|
|
XX(COMPRESSED_RGBA_PVRTC_2BPPV1);
|
|
|
|
XX(COMPRESSED_RGBA_PVRTC_4BPPV1);
|
|
|
|
XX(COMPRESSED_RGBA_S3TC_DXT1_EXT);
|
|
|
|
XX(COMPRESSED_RGBA_S3TC_DXT3_EXT);
|
|
|
|
XX(COMPRESSED_RGBA_S3TC_DXT5_EXT);
|
|
|
|
XX(COMPRESSED_RGB_PVRTC_2BPPV1);
|
|
|
|
XX(COMPRESSED_RGB_PVRTC_4BPPV1);
|
|
|
|
XX(COMPRESSED_RGB_S3TC_DXT1_EXT);
|
|
|
|
XX(DEPTH_COMPONENT);
|
|
|
|
XX(DEPTH_COMPONENT16);
|
|
|
|
XX(DEPTH_COMPONENT32);
|
|
|
|
XX(DEPTH_STENCIL);
|
|
|
|
XX(DEPTH24_STENCIL8);
|
2015-01-13 02:05:21 +03:00
|
|
|
XX(DRAW_FRAMEBUFFER);
|
2014-06-03 00:30:00 +04:00
|
|
|
XX(ETC1_RGB8_OES);
|
|
|
|
XX(FLOAT);
|
2015-01-13 02:05:21 +03:00
|
|
|
XX(FRAMEBUFFER);
|
2014-06-03 00:30:00 +04:00
|
|
|
XX(HALF_FLOAT);
|
|
|
|
XX(LUMINANCE);
|
|
|
|
XX(LUMINANCE_ALPHA);
|
2015-01-13 02:05:21 +03:00
|
|
|
XX(READ_FRAMEBUFFER);
|
2014-06-03 00:30:00 +04:00
|
|
|
XX(RGB);
|
|
|
|
XX(RGB16F);
|
|
|
|
XX(RGB32F);
|
|
|
|
XX(RGBA);
|
|
|
|
XX(RGBA16F);
|
|
|
|
XX(RGBA32F);
|
|
|
|
XX(SRGB);
|
|
|
|
XX(SRGB_ALPHA);
|
|
|
|
XX(TEXTURE_2D);
|
|
|
|
XX(TEXTURE_3D);
|
|
|
|
XX(TEXTURE_CUBE_MAP);
|
|
|
|
XX(TEXTURE_CUBE_MAP_NEGATIVE_X);
|
|
|
|
XX(TEXTURE_CUBE_MAP_NEGATIVE_Y);
|
|
|
|
XX(TEXTURE_CUBE_MAP_NEGATIVE_Z);
|
|
|
|
XX(TEXTURE_CUBE_MAP_POSITIVE_X);
|
|
|
|
XX(TEXTURE_CUBE_MAP_POSITIVE_Y);
|
|
|
|
XX(TEXTURE_CUBE_MAP_POSITIVE_Z);
|
|
|
|
XX(UNSIGNED_BYTE);
|
|
|
|
XX(UNSIGNED_INT);
|
|
|
|
XX(UNSIGNED_INT_24_8);
|
|
|
|
XX(UNSIGNED_SHORT);
|
|
|
|
XX(UNSIGNED_SHORT_4_4_4_4);
|
|
|
|
XX(UNSIGNED_SHORT_5_5_5_1);
|
|
|
|
XX(UNSIGNED_SHORT_5_6_5);
|
2014-10-27 02:35:02 +03:00
|
|
|
XX(READ_BUFFER);
|
|
|
|
XX(UNPACK_ROW_LENGTH);
|
|
|
|
XX(UNPACK_SKIP_ROWS);
|
|
|
|
XX(UNPACK_SKIP_PIXELS);
|
|
|
|
XX(PACK_ROW_LENGTH);
|
|
|
|
XX(PACK_SKIP_ROWS);
|
|
|
|
XX(PACK_SKIP_PIXELS);
|
|
|
|
XX(COLOR);
|
|
|
|
XX(DEPTH);
|
|
|
|
XX(STENCIL);
|
|
|
|
XX(RED);
|
|
|
|
XX(RGB8);
|
|
|
|
XX(RGBA8);
|
|
|
|
XX(RGB10_A2);
|
|
|
|
XX(TEXTURE_BINDING_3D);
|
|
|
|
XX(UNPACK_SKIP_IMAGES);
|
|
|
|
XX(UNPACK_IMAGE_HEIGHT);
|
|
|
|
XX(TEXTURE_WRAP_R);
|
|
|
|
XX(MAX_3D_TEXTURE_SIZE);
|
|
|
|
XX(UNSIGNED_INT_2_10_10_10_REV);
|
|
|
|
XX(MAX_ELEMENTS_VERTICES);
|
|
|
|
XX(MAX_ELEMENTS_INDICES);
|
|
|
|
XX(TEXTURE_MIN_LOD);
|
|
|
|
XX(TEXTURE_MAX_LOD);
|
|
|
|
XX(TEXTURE_BASE_LEVEL);
|
|
|
|
XX(TEXTURE_MAX_LEVEL);
|
|
|
|
XX(MIN);
|
|
|
|
XX(MAX);
|
|
|
|
XX(DEPTH_COMPONENT24);
|
|
|
|
XX(MAX_TEXTURE_LOD_BIAS);
|
|
|
|
XX(TEXTURE_COMPARE_MODE);
|
|
|
|
XX(TEXTURE_COMPARE_FUNC);
|
|
|
|
XX(CURRENT_QUERY);
|
|
|
|
XX(QUERY_RESULT);
|
|
|
|
XX(QUERY_RESULT_AVAILABLE);
|
|
|
|
XX(STREAM_READ);
|
|
|
|
XX(STREAM_COPY);
|
|
|
|
XX(STATIC_READ);
|
|
|
|
XX(STATIC_COPY);
|
|
|
|
XX(DYNAMIC_READ);
|
|
|
|
XX(DYNAMIC_COPY);
|
|
|
|
XX(MAX_DRAW_BUFFERS);
|
|
|
|
XX(DRAW_BUFFER0);
|
|
|
|
XX(DRAW_BUFFER1);
|
|
|
|
XX(DRAW_BUFFER2);
|
|
|
|
XX(DRAW_BUFFER3);
|
|
|
|
XX(DRAW_BUFFER4);
|
|
|
|
XX(DRAW_BUFFER5);
|
|
|
|
XX(DRAW_BUFFER6);
|
|
|
|
XX(DRAW_BUFFER7);
|
|
|
|
XX(DRAW_BUFFER8);
|
|
|
|
XX(DRAW_BUFFER9);
|
|
|
|
XX(DRAW_BUFFER10);
|
|
|
|
XX(DRAW_BUFFER11);
|
|
|
|
XX(DRAW_BUFFER12);
|
|
|
|
XX(DRAW_BUFFER13);
|
|
|
|
XX(DRAW_BUFFER14);
|
|
|
|
XX(DRAW_BUFFER15);
|
|
|
|
XX(MAX_FRAGMENT_UNIFORM_COMPONENTS);
|
|
|
|
XX(MAX_VERTEX_UNIFORM_COMPONENTS);
|
|
|
|
XX(SAMPLER_3D);
|
|
|
|
XX(SAMPLER_2D_SHADOW);
|
|
|
|
XX(FRAGMENT_SHADER_DERIVATIVE_HINT);
|
|
|
|
XX(PIXEL_PACK_BUFFER);
|
|
|
|
XX(PIXEL_UNPACK_BUFFER);
|
|
|
|
XX(PIXEL_PACK_BUFFER_BINDING);
|
|
|
|
XX(PIXEL_UNPACK_BUFFER_BINDING);
|
|
|
|
XX(FLOAT_MAT2x3);
|
|
|
|
XX(FLOAT_MAT2x4);
|
|
|
|
XX(FLOAT_MAT3x2);
|
|
|
|
XX(FLOAT_MAT3x4);
|
|
|
|
XX(FLOAT_MAT4x2);
|
|
|
|
XX(FLOAT_MAT4x3);
|
|
|
|
XX(SRGB8);
|
|
|
|
XX(SRGB8_ALPHA8);
|
|
|
|
XX(COMPARE_REF_TO_TEXTURE);
|
|
|
|
XX(VERTEX_ATTRIB_ARRAY_INTEGER);
|
|
|
|
XX(MAX_ARRAY_TEXTURE_LAYERS);
|
|
|
|
XX(MIN_PROGRAM_TEXEL_OFFSET);
|
|
|
|
XX(MAX_PROGRAM_TEXEL_OFFSET);
|
|
|
|
XX(MAX_VARYING_COMPONENTS);
|
|
|
|
XX(TEXTURE_2D_ARRAY);
|
|
|
|
XX(TEXTURE_BINDING_2D_ARRAY);
|
|
|
|
XX(R11F_G11F_B10F);
|
|
|
|
XX(UNSIGNED_INT_10F_11F_11F_REV);
|
|
|
|
XX(RGB9_E5);
|
|
|
|
XX(UNSIGNED_INT_5_9_9_9_REV);
|
|
|
|
XX(TRANSFORM_FEEDBACK_BUFFER_MODE);
|
|
|
|
XX(MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS);
|
|
|
|
XX(TRANSFORM_FEEDBACK_VARYINGS);
|
|
|
|
XX(TRANSFORM_FEEDBACK_BUFFER_START);
|
|
|
|
XX(TRANSFORM_FEEDBACK_BUFFER_SIZE);
|
|
|
|
XX(TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN);
|
|
|
|
XX(RASTERIZER_DISCARD);
|
|
|
|
XX(MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS);
|
|
|
|
XX(MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS);
|
|
|
|
XX(INTERLEAVED_ATTRIBS);
|
|
|
|
XX(SEPARATE_ATTRIBS);
|
|
|
|
XX(TRANSFORM_FEEDBACK_BUFFER);
|
|
|
|
XX(TRANSFORM_FEEDBACK_BUFFER_BINDING);
|
|
|
|
XX(RGBA32UI);
|
|
|
|
XX(RGB32UI);
|
|
|
|
XX(RGBA16UI);
|
|
|
|
XX(RGB16UI);
|
|
|
|
XX(RGBA8UI);
|
|
|
|
XX(RGB8UI);
|
|
|
|
XX(RGBA32I);
|
|
|
|
XX(RGB32I);
|
|
|
|
XX(RGBA16I);
|
|
|
|
XX(RGB16I);
|
|
|
|
XX(RGBA8I);
|
|
|
|
XX(RGB8I);
|
|
|
|
XX(RED_INTEGER);
|
|
|
|
XX(RGB_INTEGER);
|
|
|
|
XX(RGBA_INTEGER);
|
|
|
|
XX(SAMPLER_2D_ARRAY);
|
|
|
|
XX(SAMPLER_2D_ARRAY_SHADOW);
|
|
|
|
XX(SAMPLER_CUBE_SHADOW);
|
|
|
|
XX(UNSIGNED_INT_VEC2);
|
|
|
|
XX(UNSIGNED_INT_VEC3);
|
|
|
|
XX(UNSIGNED_INT_VEC4);
|
|
|
|
XX(INT_SAMPLER_2D);
|
|
|
|
XX(INT_SAMPLER_3D);
|
|
|
|
XX(INT_SAMPLER_CUBE);
|
|
|
|
XX(INT_SAMPLER_2D_ARRAY);
|
|
|
|
XX(UNSIGNED_INT_SAMPLER_2D);
|
|
|
|
XX(UNSIGNED_INT_SAMPLER_3D);
|
|
|
|
XX(UNSIGNED_INT_SAMPLER_CUBE);
|
|
|
|
XX(UNSIGNED_INT_SAMPLER_2D_ARRAY);
|
|
|
|
XX(DEPTH_COMPONENT32F);
|
|
|
|
XX(DEPTH32F_STENCIL8);
|
|
|
|
XX(FLOAT_32_UNSIGNED_INT_24_8_REV);
|
|
|
|
XX(FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING);
|
|
|
|
XX(FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE);
|
|
|
|
XX(FRAMEBUFFER_ATTACHMENT_RED_SIZE);
|
|
|
|
XX(FRAMEBUFFER_ATTACHMENT_GREEN_SIZE);
|
|
|
|
XX(FRAMEBUFFER_ATTACHMENT_BLUE_SIZE);
|
|
|
|
XX(FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE);
|
|
|
|
XX(FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE);
|
|
|
|
XX(FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE);
|
|
|
|
XX(FRAMEBUFFER_DEFAULT);
|
|
|
|
XX(DEPTH_STENCIL_ATTACHMENT);
|
|
|
|
XX(UNSIGNED_NORMALIZED);
|
|
|
|
XX(DRAW_FRAMEBUFFER_BINDING);
|
|
|
|
XX(READ_FRAMEBUFFER_BINDING);
|
|
|
|
XX(RENDERBUFFER_SAMPLES);
|
|
|
|
XX(FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER);
|
|
|
|
XX(MAX_COLOR_ATTACHMENTS);
|
|
|
|
XX(COLOR_ATTACHMENT1);
|
|
|
|
XX(COLOR_ATTACHMENT2);
|
|
|
|
XX(COLOR_ATTACHMENT3);
|
|
|
|
XX(COLOR_ATTACHMENT4);
|
|
|
|
XX(COLOR_ATTACHMENT5);
|
|
|
|
XX(COLOR_ATTACHMENT6);
|
|
|
|
XX(COLOR_ATTACHMENT7);
|
|
|
|
XX(COLOR_ATTACHMENT8);
|
|
|
|
XX(COLOR_ATTACHMENT9);
|
|
|
|
XX(COLOR_ATTACHMENT10);
|
|
|
|
XX(COLOR_ATTACHMENT11);
|
|
|
|
XX(COLOR_ATTACHMENT12);
|
|
|
|
XX(COLOR_ATTACHMENT13);
|
|
|
|
XX(COLOR_ATTACHMENT14);
|
|
|
|
XX(COLOR_ATTACHMENT15);
|
|
|
|
XX(FRAMEBUFFER_INCOMPLETE_MULTISAMPLE);
|
|
|
|
XX(MAX_SAMPLES);
|
|
|
|
XX(RG);
|
|
|
|
XX(RG_INTEGER);
|
|
|
|
XX(R8);
|
|
|
|
XX(RG8);
|
|
|
|
XX(R16F);
|
|
|
|
XX(R32F);
|
|
|
|
XX(RG16F);
|
|
|
|
XX(RG32F);
|
|
|
|
XX(R8I);
|
|
|
|
XX(R8UI);
|
|
|
|
XX(R16I);
|
|
|
|
XX(R16UI);
|
|
|
|
XX(R32I);
|
|
|
|
XX(R32UI);
|
|
|
|
XX(RG8I);
|
|
|
|
XX(RG8UI);
|
|
|
|
XX(RG16I);
|
|
|
|
XX(RG16UI);
|
|
|
|
XX(RG32I);
|
|
|
|
XX(RG32UI);
|
|
|
|
XX(VERTEX_ARRAY_BINDING);
|
|
|
|
XX(R8_SNORM);
|
|
|
|
XX(RG8_SNORM);
|
|
|
|
XX(RGB8_SNORM);
|
|
|
|
XX(RGBA8_SNORM);
|
|
|
|
XX(SIGNED_NORMALIZED);
|
|
|
|
XX(PRIMITIVE_RESTART_FIXED_INDEX);
|
|
|
|
XX(COPY_READ_BUFFER);
|
|
|
|
XX(COPY_WRITE_BUFFER);
|
|
|
|
XX(UNIFORM_BUFFER);
|
|
|
|
XX(UNIFORM_BUFFER_BINDING);
|
|
|
|
XX(UNIFORM_BUFFER_START);
|
|
|
|
XX(UNIFORM_BUFFER_SIZE);
|
|
|
|
XX(MAX_VERTEX_UNIFORM_BLOCKS);
|
|
|
|
XX(MAX_FRAGMENT_UNIFORM_BLOCKS);
|
|
|
|
XX(MAX_COMBINED_UNIFORM_BLOCKS);
|
|
|
|
XX(MAX_UNIFORM_BUFFER_BINDINGS);
|
|
|
|
XX(MAX_UNIFORM_BLOCK_SIZE);
|
|
|
|
XX(MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS);
|
|
|
|
XX(MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS);
|
|
|
|
XX(UNIFORM_BUFFER_OFFSET_ALIGNMENT);
|
|
|
|
XX(ACTIVE_UNIFORM_BLOCKS);
|
|
|
|
XX(UNIFORM_TYPE);
|
|
|
|
XX(UNIFORM_SIZE);
|
|
|
|
XX(UNIFORM_BLOCK_INDEX);
|
|
|
|
XX(UNIFORM_OFFSET);
|
|
|
|
XX(UNIFORM_ARRAY_STRIDE);
|
|
|
|
XX(UNIFORM_MATRIX_STRIDE);
|
|
|
|
XX(UNIFORM_IS_ROW_MAJOR);
|
|
|
|
XX(UNIFORM_BLOCK_BINDING);
|
|
|
|
XX(UNIFORM_BLOCK_DATA_SIZE);
|
|
|
|
XX(UNIFORM_BLOCK_ACTIVE_UNIFORMS);
|
|
|
|
XX(UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES);
|
|
|
|
XX(UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER);
|
|
|
|
XX(UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER);
|
|
|
|
XX(MAX_VERTEX_OUTPUT_COMPONENTS);
|
|
|
|
XX(MAX_FRAGMENT_INPUT_COMPONENTS);
|
|
|
|
XX(MAX_SERVER_WAIT_TIMEOUT);
|
|
|
|
XX(OBJECT_TYPE);
|
|
|
|
XX(SYNC_CONDITION);
|
|
|
|
XX(SYNC_STATUS);
|
|
|
|
XX(SYNC_FLAGS);
|
|
|
|
XX(SYNC_FENCE);
|
|
|
|
XX(SYNC_GPU_COMMANDS_COMPLETE);
|
|
|
|
XX(UNSIGNALED);
|
|
|
|
XX(SIGNALED);
|
|
|
|
XX(ALREADY_SIGNALED);
|
|
|
|
XX(TIMEOUT_EXPIRED);
|
|
|
|
XX(CONDITION_SATISFIED);
|
|
|
|
XX(WAIT_FAILED);
|
|
|
|
XX(VERTEX_ATTRIB_ARRAY_DIVISOR);
|
|
|
|
XX(ANY_SAMPLES_PASSED);
|
|
|
|
XX(ANY_SAMPLES_PASSED_CONSERVATIVE);
|
|
|
|
XX(SAMPLER_BINDING);
|
|
|
|
XX(RGB10_A2UI);
|
|
|
|
XX(TEXTURE_SWIZZLE_R);
|
|
|
|
XX(TEXTURE_SWIZZLE_G);
|
|
|
|
XX(TEXTURE_SWIZZLE_B);
|
|
|
|
XX(TEXTURE_SWIZZLE_A);
|
|
|
|
XX(GREEN);
|
|
|
|
XX(BLUE);
|
|
|
|
XX(INT_2_10_10_10_REV);
|
|
|
|
XX(TRANSFORM_FEEDBACK);
|
|
|
|
XX(TRANSFORM_FEEDBACK_PAUSED);
|
|
|
|
XX(TRANSFORM_FEEDBACK_ACTIVE);
|
|
|
|
XX(TRANSFORM_FEEDBACK_BINDING);
|
|
|
|
XX(COMPRESSED_R11_EAC);
|
|
|
|
XX(COMPRESSED_SIGNED_R11_EAC);
|
|
|
|
XX(COMPRESSED_RG11_EAC);
|
|
|
|
XX(COMPRESSED_SIGNED_RG11_EAC);
|
|
|
|
XX(COMPRESSED_RGB8_ETC2);
|
|
|
|
XX(COMPRESSED_SRGB8_ETC2);
|
|
|
|
XX(COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2);
|
|
|
|
XX(COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2);
|
|
|
|
XX(COMPRESSED_RGBA8_ETC2_EAC);
|
|
|
|
XX(COMPRESSED_SRGB8_ALPHA8_ETC2_EAC);
|
|
|
|
XX(TEXTURE_IMMUTABLE_FORMAT);
|
|
|
|
XX(MAX_ELEMENT_INDEX);
|
|
|
|
XX(NUM_SAMPLE_COUNTS);
|
|
|
|
XX(TEXTURE_IMMUTABLE_LEVELS);
|
2014-06-03 00:30:00 +04:00
|
|
|
#undef XX
|
|
|
|
}
|
|
|
|
|
2014-10-27 02:35:02 +03:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
WebGLContext::EnumName(GLenum glenum, nsACString* out_name)
|
|
|
|
{
|
|
|
|
const char* name = EnumName(glenum);
|
|
|
|
if (name) {
|
|
|
|
*out_name = nsDependentCString(name);
|
|
|
|
} else {
|
|
|
|
nsPrintfCString enumAsHex("<enum 0x%04x>", glenum);
|
|
|
|
*out_name = enumAsHex;
|
|
|
|
}
|
2014-06-03 00:30:00 +04:00
|
|
|
}
|
|
|
|
|
2012-04-04 03:42:06 +04:00
|
|
|
bool
|
2014-10-05 06:24:24 +04:00
|
|
|
WebGLContext::IsCompressedTextureFormat(GLenum format)
|
2012-04-04 03:42:06 +04:00
|
|
|
{
|
2014-10-05 06:24:24 +04:00
|
|
|
switch (format) {
|
2014-11-14 07:03:50 +03:00
|
|
|
case LOCAL_GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
|
|
|
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
|
|
|
|
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
|
|
|
|
case LOCAL_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
|
|
|
case LOCAL_GL_ATC_RGB:
|
|
|
|
case LOCAL_GL_ATC_RGBA_EXPLICIT_ALPHA:
|
|
|
|
case LOCAL_GL_ATC_RGBA_INTERPOLATED_ALPHA:
|
|
|
|
case LOCAL_GL_COMPRESSED_RGB_PVRTC_4BPPV1:
|
|
|
|
case LOCAL_GL_COMPRESSED_RGB_PVRTC_2BPPV1:
|
|
|
|
case LOCAL_GL_COMPRESSED_RGBA_PVRTC_4BPPV1:
|
|
|
|
case LOCAL_GL_COMPRESSED_RGBA_PVRTC_2BPPV1:
|
|
|
|
case LOCAL_GL_ETC1_RGB8_OES:
|
|
|
|
case LOCAL_GL_COMPRESSED_R11_EAC:
|
|
|
|
case LOCAL_GL_COMPRESSED_SIGNED_R11_EAC:
|
|
|
|
case LOCAL_GL_COMPRESSED_RG11_EAC:
|
|
|
|
case LOCAL_GL_COMPRESSED_SIGNED_RG11_EAC:
|
|
|
|
case LOCAL_GL_COMPRESSED_RGB8_ETC2:
|
|
|
|
case LOCAL_GL_COMPRESSED_SRGB8_ETC2:
|
|
|
|
case LOCAL_GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
|
|
|
|
case LOCAL_GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
|
|
|
|
case LOCAL_GL_COMPRESSED_RGBA8_ETC2_EAC:
|
|
|
|
case LOCAL_GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
2012-04-04 03:42:06 +04:00
|
|
|
}
|
|
|
|
}
|
2013-09-04 16:14:50 +04:00
|
|
|
|
2014-10-05 06:24:24 +04:00
|
|
|
|
|
|
|
bool
|
|
|
|
WebGLContext::IsTextureFormatCompressed(TexInternalFormat format)
|
|
|
|
{
|
|
|
|
return IsCompressedTextureFormat(format.get());
|
|
|
|
}
|
|
|
|
|
2014-03-08 01:16:34 +04:00
|
|
|
GLenum
|
|
|
|
WebGLContext::GetAndFlushUnderlyingGLErrors()
|
2013-09-04 16:14:50 +04:00
|
|
|
{
|
2014-03-08 01:16:34 +04:00
|
|
|
// Get and clear GL error in ALL cases.
|
2014-10-25 03:52:35 +04:00
|
|
|
GLenum error = gl->fGetError();
|
2014-03-08 01:16:34 +04:00
|
|
|
|
|
|
|
// Only store in mUnderlyingGLError if is hasn't already recorded an
|
|
|
|
// error.
|
|
|
|
if (!mUnderlyingGLError)
|
|
|
|
mUnderlyingGLError = error;
|
|
|
|
|
|
|
|
return error;
|
2013-09-04 16:14:50 +04:00
|
|
|
}
|
2014-05-22 06:03:09 +04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
// For NaNs, etc.
|
|
|
|
static bool
|
|
|
|
IsCacheCorrect(float cached, float actual)
|
|
|
|
{
|
|
|
|
if (IsNaN(cached)) {
|
|
|
|
// GL is allowed to do anything it wants for NaNs, so if we're shadowing
|
|
|
|
// a NaN, then whatever `actual` is might be correct.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cached == actual;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AssertUintParamCorrect(gl::GLContext* gl, GLenum pname, GLuint shadow)
|
|
|
|
{
|
|
|
|
GLuint val = 0;
|
|
|
|
gl->GetUIntegerv(pname, &val);
|
|
|
|
if (val != shadow) {
|
|
|
|
printf_stderr("Failed 0x%04x shadow: Cached 0x%x/%u, should be 0x%x/%u.\n",
|
|
|
|
pname, shadow, shadow, val, val);
|
|
|
|
MOZ_ASSERT(false, "Bad cached value.");
|
|
|
|
}
|
|
|
|
}
|
2014-09-27 02:06:38 +04:00
|
|
|
|
|
|
|
void
|
2014-11-14 07:03:50 +03:00
|
|
|
AssertMaskedUintParamCorrect(gl::GLContext* gl, GLenum pname, GLuint mask,
|
|
|
|
GLuint shadow)
|
2014-09-27 02:06:38 +04:00
|
|
|
{
|
|
|
|
GLuint val = 0;
|
|
|
|
gl->GetUIntegerv(pname, &val);
|
|
|
|
|
|
|
|
const GLuint valMasked = val & mask;
|
|
|
|
const GLuint shadowMasked = shadow & mask;
|
|
|
|
|
|
|
|
if (valMasked != shadowMasked) {
|
|
|
|
printf_stderr("Failed 0x%04x shadow: Cached 0x%x/%u, should be 0x%x/%u.\n",
|
|
|
|
pname, shadowMasked, shadowMasked, valMasked, valMasked);
|
|
|
|
MOZ_ASSERT(false, "Bad cached value.");
|
|
|
|
}
|
|
|
|
}
|
2014-05-22 06:03:09 +04:00
|
|
|
#else
|
|
|
|
void
|
|
|
|
AssertUintParamCorrect(gl::GLContext*, GLenum, GLuint)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
|
|
|
WebGLContext::AssertCachedBindings()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
MakeContextCurrent();
|
|
|
|
|
|
|
|
GetAndFlushUnderlyingGLErrors();
|
|
|
|
|
|
|
|
if (IsExtensionEnabled(WebGLExtensionID::OES_vertex_array_object)) {
|
|
|
|
GLuint bound = mBoundVertexArray ? mBoundVertexArray->GLName() : 0;
|
|
|
|
AssertUintParamCorrect(gl, LOCAL_GL_VERTEX_ARRAY_BINDING, bound);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bound object state
|
2015-01-13 02:05:21 +03:00
|
|
|
if (IsWebGL2()) {
|
|
|
|
GLuint bound = mBoundDrawFramebuffer ? mBoundDrawFramebuffer->GLName()
|
|
|
|
: 0;
|
|
|
|
AssertUintParamCorrect(gl, LOCAL_GL_DRAW_FRAMEBUFFER_BINDING, bound);
|
|
|
|
|
|
|
|
bound = mBoundReadFramebuffer ? mBoundReadFramebuffer->GLName() : 0;
|
|
|
|
AssertUintParamCorrect(gl, LOCAL_GL_READ_FRAMEBUFFER_BINDING, bound);
|
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(mBoundDrawFramebuffer == mBoundReadFramebuffer);
|
|
|
|
GLuint bound = mBoundDrawFramebuffer ? mBoundDrawFramebuffer->GLName()
|
|
|
|
: 0;
|
|
|
|
AssertUintParamCorrect(gl, LOCAL_GL_FRAMEBUFFER_BINDING, bound);
|
|
|
|
}
|
2014-05-22 06:03:09 +04:00
|
|
|
|
2015-01-16 02:40:39 +03:00
|
|
|
GLuint bound = mCurrentProgram ? mCurrentProgram->mGLName : 0;
|
2014-05-22 06:03:09 +04:00
|
|
|
AssertUintParamCorrect(gl, LOCAL_GL_CURRENT_PROGRAM, bound);
|
|
|
|
|
|
|
|
// Textures
|
|
|
|
GLenum activeTexture = mActiveTexture + LOCAL_GL_TEXTURE0;
|
|
|
|
AssertUintParamCorrect(gl, LOCAL_GL_ACTIVE_TEXTURE, activeTexture);
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
WebGLTexture* curTex = ActiveBoundTextureForTarget(LOCAL_GL_TEXTURE_2D);
|
2014-05-22 06:03:09 +04:00
|
|
|
bound = curTex ? curTex->GLName() : 0;
|
|
|
|
AssertUintParamCorrect(gl, LOCAL_GL_TEXTURE_BINDING_2D, bound);
|
|
|
|
|
2014-11-14 07:03:50 +03:00
|
|
|
curTex = ActiveBoundTextureForTarget(LOCAL_GL_TEXTURE_CUBE_MAP);
|
2014-05-22 06:03:09 +04:00
|
|
|
bound = curTex ? curTex->GLName() : 0;
|
|
|
|
AssertUintParamCorrect(gl, LOCAL_GL_TEXTURE_BINDING_CUBE_MAP, bound);
|
|
|
|
|
|
|
|
// Buffers
|
|
|
|
bound = mBoundArrayBuffer ? mBoundArrayBuffer->GLName() : 0;
|
|
|
|
AssertUintParamCorrect(gl, LOCAL_GL_ARRAY_BUFFER_BINDING, bound);
|
|
|
|
|
|
|
|
MOZ_ASSERT(mBoundVertexArray);
|
2014-06-06 03:38:27 +04:00
|
|
|
WebGLBuffer* curBuff = mBoundVertexArray->mElementArrayBuffer;
|
2014-05-22 06:03:09 +04:00
|
|
|
bound = curBuff ? curBuff->GLName() : 0;
|
|
|
|
AssertUintParamCorrect(gl, LOCAL_GL_ELEMENT_ARRAY_BUFFER_BINDING, bound);
|
|
|
|
|
|
|
|
MOZ_ASSERT(!GetAndFlushUnderlyingGLErrors());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
WebGLContext::AssertCachedState()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
MakeContextCurrent();
|
|
|
|
|
|
|
|
GetAndFlushUnderlyingGLErrors();
|
|
|
|
|
|
|
|
// extensions
|
|
|
|
if (IsExtensionEnabled(WebGLExtensionID::WEBGL_draw_buffers)) {
|
|
|
|
AssertUintParamCorrect(gl, LOCAL_GL_MAX_COLOR_ATTACHMENTS, mGLMaxColorAttachments);
|
|
|
|
AssertUintParamCorrect(gl, LOCAL_GL_MAX_DRAW_BUFFERS, mGLMaxDrawBuffers);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw state
|
|
|
|
MOZ_ASSERT(gl->fIsEnabled(LOCAL_GL_SCISSOR_TEST) == mScissorTestEnabled);
|
|
|
|
MOZ_ASSERT(gl->fIsEnabled(LOCAL_GL_DITHER) == mDitherEnabled);
|
|
|
|
MOZ_ASSERT_IF(IsWebGL2(),
|
|
|
|
gl->fIsEnabled(LOCAL_GL_RASTERIZER_DISCARD) == mRasterizerDiscardEnabled);
|
|
|
|
|
|
|
|
|
|
|
|
realGLboolean colorWriteMask[4] = {0, 0, 0, 0};
|
|
|
|
gl->fGetBooleanv(LOCAL_GL_COLOR_WRITEMASK, colorWriteMask);
|
|
|
|
MOZ_ASSERT(colorWriteMask[0] == mColorWriteMask[0] &&
|
|
|
|
colorWriteMask[1] == mColorWriteMask[1] &&
|
|
|
|
colorWriteMask[2] == mColorWriteMask[2] &&
|
|
|
|
colorWriteMask[3] == mColorWriteMask[3]);
|
|
|
|
|
|
|
|
GLfloat colorClearValue[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
|
|
|
gl->fGetFloatv(LOCAL_GL_COLOR_CLEAR_VALUE, colorClearValue);
|
|
|
|
MOZ_ASSERT(IsCacheCorrect(mColorClearValue[0], colorClearValue[0]) &&
|
|
|
|
IsCacheCorrect(mColorClearValue[1], colorClearValue[1]) &&
|
|
|
|
IsCacheCorrect(mColorClearValue[2], colorClearValue[2]) &&
|
|
|
|
IsCacheCorrect(mColorClearValue[3], colorClearValue[3]));
|
|
|
|
|
|
|
|
realGLboolean depthWriteMask = 0;
|
|
|
|
gl->fGetBooleanv(LOCAL_GL_DEPTH_WRITEMASK, &depthWriteMask);
|
|
|
|
MOZ_ASSERT(depthWriteMask == mDepthWriteMask);
|
|
|
|
|
|
|
|
GLfloat depthClearValue = 0.0f;
|
|
|
|
gl->fGetFloatv(LOCAL_GL_DEPTH_CLEAR_VALUE, &depthClearValue);
|
|
|
|
MOZ_ASSERT(IsCacheCorrect(mDepthClearValue, depthClearValue));
|
|
|
|
|
|
|
|
AssertUintParamCorrect(gl, LOCAL_GL_STENCIL_CLEAR_VALUE, mStencilClearValue);
|
|
|
|
|
2014-09-27 02:06:38 +04:00
|
|
|
GLint stencilBits = 0;
|
2015-02-06 22:37:04 +03:00
|
|
|
gl->fGetIntegerv(LOCAL_GL_STENCIL_BITS, &stencilBits);
|
|
|
|
const GLuint stencilRefMask = (1 << stencilBits) - 1;
|
2014-09-27 02:06:38 +04:00
|
|
|
|
2015-02-06 22:37:04 +03:00
|
|
|
AssertMaskedUintParamCorrect(gl, LOCAL_GL_STENCIL_REF, stencilRefMask, mStencilRefFront);
|
|
|
|
AssertMaskedUintParamCorrect(gl, LOCAL_GL_STENCIL_BACK_REF, stencilRefMask, mStencilRefBack);
|
2014-05-22 06:03:09 +04:00
|
|
|
|
2015-02-05 02:07:32 +03:00
|
|
|
// GLES 3.0.4, $4.1.4, p177:
|
|
|
|
// [...] the front and back stencil mask are both set to the value `2^s - 1`, where
|
|
|
|
// `s` is greater than or equal to the number of bits in the deepest stencil buffer
|
|
|
|
// supported by the GL implementation.
|
|
|
|
const int maxStencilBits = 8;
|
|
|
|
const GLuint maxStencilBitsMask = (1 << maxStencilBits) - 1;
|
|
|
|
|
|
|
|
AssertMaskedUintParamCorrect(gl, LOCAL_GL_STENCIL_VALUE_MASK, maxStencilBitsMask, mStencilValueMaskFront);
|
|
|
|
AssertMaskedUintParamCorrect(gl, LOCAL_GL_STENCIL_BACK_VALUE_MASK, maxStencilBitsMask, mStencilValueMaskBack);
|
2014-05-22 06:03:09 +04:00
|
|
|
|
|
|
|
AssertUintParamCorrect(gl, LOCAL_GL_STENCIL_WRITEMASK, mStencilWriteMaskFront);
|
|
|
|
AssertUintParamCorrect(gl, LOCAL_GL_STENCIL_BACK_WRITEMASK, mStencilWriteMaskBack);
|
|
|
|
|
|
|
|
// Viewport
|
|
|
|
GLint int4[4] = {0, 0, 0, 0};
|
|
|
|
gl->fGetIntegerv(LOCAL_GL_VIEWPORT, int4);
|
|
|
|
MOZ_ASSERT(int4[0] == mViewportX &&
|
|
|
|
int4[1] == mViewportY &&
|
|
|
|
int4[2] == mViewportWidth &&
|
|
|
|
int4[3] == mViewportHeight);
|
|
|
|
|
|
|
|
AssertUintParamCorrect(gl, LOCAL_GL_PACK_ALIGNMENT, mPixelStorePackAlignment);
|
|
|
|
AssertUintParamCorrect(gl, LOCAL_GL_UNPACK_ALIGNMENT, mPixelStoreUnpackAlignment);
|
|
|
|
|
|
|
|
MOZ_ASSERT(!GetAndFlushUnderlyingGLErrors());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-10-14 03:42:15 +04:00
|
|
|
const char*
|
|
|
|
InfoFrom(WebGLTexImageFunc func, WebGLTexDimensions dims)
|
|
|
|
{
|
|
|
|
switch (dims) {
|
|
|
|
case WebGLTexDimensions::Tex2D:
|
|
|
|
switch (func) {
|
|
|
|
case WebGLTexImageFunc::TexImage: return "texImage2D";
|
|
|
|
case WebGLTexImageFunc::TexSubImage: return "texSubImage2D";
|
|
|
|
case WebGLTexImageFunc::CopyTexImage: return "copyTexImage2D";
|
|
|
|
case WebGLTexImageFunc::CopyTexSubImage: return "copyTexSubImage2D";
|
|
|
|
case WebGLTexImageFunc::CompTexImage: return "compressedTexImage2D";
|
|
|
|
case WebGLTexImageFunc::CompTexSubImage: return "compressedTexSubImage2D";
|
|
|
|
default:
|
|
|
|
MOZ_CRASH();
|
|
|
|
}
|
|
|
|
case WebGLTexDimensions::Tex3D:
|
|
|
|
switch (func) {
|
2014-10-17 06:03:34 +04:00
|
|
|
case WebGLTexImageFunc::TexImage: return "texImage3D";
|
2014-10-14 03:42:15 +04:00
|
|
|
case WebGLTexImageFunc::TexSubImage: return "texSubImage3D";
|
|
|
|
case WebGLTexImageFunc::CopyTexSubImage: return "copyTexSubImage3D";
|
|
|
|
case WebGLTexImageFunc::CompTexSubImage: return "compressedTexSubImage3D";
|
|
|
|
default:
|
|
|
|
MOZ_CRASH();
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
MOZ_CRASH();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-22 06:03:09 +04:00
|
|
|
} // namespace mozilla
|