зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1478909 - Make funcName implicit for WebGL calls. - r=kvark
MozReview-Commit-ID: Gv77SnHZcGb
This commit is contained in:
Родитель
14af3949fc
Коммит
8e0436b208
|
@ -67,12 +67,10 @@ IsPIValidForDOM(const webgl::PackingInfo& pi)
|
|||
}
|
||||
|
||||
static bool
|
||||
ValidatePIForDOM(WebGLContext* webgl, const char* funcName,
|
||||
const webgl::PackingInfo& pi)
|
||||
ValidatePIForDOM(WebGLContext* webgl, const webgl::PackingInfo& pi)
|
||||
{
|
||||
if (!IsPIValidForDOM(pi)) {
|
||||
webgl->ErrorInvalidOperation("%s: Format or type is invalid for DOM sources.",
|
||||
funcName);
|
||||
webgl->ErrorInvalidOperation("Format or type is invalid for DOM sources.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -179,7 +177,7 @@ FormatForPackingInfo(const PackingInfo& pi)
|
|||
////////////////////
|
||||
|
||||
static bool
|
||||
ValidateUnpackPixels(WebGLContext* webgl, const char* funcName, uint32_t fullRows,
|
||||
ValidateUnpackPixels(WebGLContext* webgl, uint32_t fullRows,
|
||||
uint32_t tailPixels, webgl::TexUnpackBlob* blob)
|
||||
{
|
||||
if (!blob->mWidth || !blob->mHeight || !blob->mDepth)
|
||||
|
@ -187,14 +185,13 @@ ValidateUnpackPixels(WebGLContext* webgl, const char* funcName, uint32_t fullRow
|
|||
|
||||
const auto usedPixelsPerRow = CheckedUint32(blob->mSkipPixels) + blob->mWidth;
|
||||
if (!usedPixelsPerRow.isValid() || usedPixelsPerRow.value() > blob->mRowLength) {
|
||||
webgl->ErrorInvalidOperation("%s: UNPACK_SKIP_PIXELS + width >"
|
||||
" UNPACK_ROW_LENGTH.",
|
||||
funcName);
|
||||
webgl->ErrorInvalidOperation("UNPACK_SKIP_PIXELS + width >"
|
||||
" UNPACK_ROW_LENGTH.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (blob->mHeight > blob->mImageHeight) {
|
||||
webgl->ErrorInvalidOperation("%s: height > UNPACK_IMAGE_HEIGHT.", funcName);
|
||||
webgl->ErrorInvalidOperation("height > UNPACK_IMAGE_HEIGHT.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -211,8 +208,7 @@ ValidateUnpackPixels(WebGLContext* webgl, const char* funcName, uint32_t fullRow
|
|||
|
||||
const auto fullRowsNeeded = skipFullRows + usedFullRows;
|
||||
if (!fullRowsNeeded.isValid()) {
|
||||
webgl->ErrorOutOfMemory("%s: Invalid calculation for required row count.",
|
||||
funcName);
|
||||
webgl->ErrorOutOfMemory("Invalid calculation for required row count.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -224,16 +220,16 @@ ValidateUnpackPixels(WebGLContext* webgl, const char* funcName, uint32_t fullRow
|
|||
return true;
|
||||
}
|
||||
|
||||
webgl->ErrorInvalidOperation("%s: Desired upload requires more data than is"
|
||||
webgl->ErrorInvalidOperation("Desired upload requires more data than is"
|
||||
" available: (%u rows plus %u pixels needed, %u rows"
|
||||
" plus %u pixels available)",
|
||||
funcName, fullRowsNeeded.value(),
|
||||
fullRowsNeeded.value(),
|
||||
usedPixelsPerRow.value(), fullRows, tailPixels);
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
ValidateUnpackBytes(WebGLContext* webgl, const char* funcName,
|
||||
ValidateUnpackBytes(WebGLContext* webgl,
|
||||
const webgl::PackingInfo& pi, size_t availByteCount,
|
||||
webgl::TexUnpackBlob* blob)
|
||||
{
|
||||
|
@ -246,14 +242,14 @@ ValidateUnpackBytes(WebGLContext* webgl, const char* funcName,
|
|||
|
||||
const auto fullRows = availByteCount / rowStride;
|
||||
if (!fullRows.isValid()) {
|
||||
webgl->ErrorOutOfMemory("%s: Unacceptable upload size calculated.", funcName);
|
||||
webgl->ErrorOutOfMemory("Unacceptable upload size calculated.");
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto bodyBytes = fullRows.value() * rowStride.value();
|
||||
const auto tailPixels = (availByteCount - bodyBytes) / bytesPerPixel;
|
||||
|
||||
return ValidateUnpackPixels(webgl, funcName, fullRows.value(), tailPixels, blob);
|
||||
return ValidateUnpackPixels(webgl, fullRows.value(), tailPixels, blob);
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
@ -313,7 +309,7 @@ HasColorAndAlpha(const WebGLTexelFormat format)
|
|||
}
|
||||
|
||||
bool
|
||||
TexUnpackBlob::ConvertIfNeeded(WebGLContext* webgl, const char* funcName,
|
||||
TexUnpackBlob::ConvertIfNeeded(WebGLContext* webgl,
|
||||
const uint32_t rowLength, const uint32_t rowCount,
|
||||
WebGLTexelFormat srcFormat,
|
||||
const uint8_t* const srcBegin, const ptrdiff_t srcStride,
|
||||
|
@ -346,18 +342,17 @@ TexUnpackBlob::ConvertIfNeeded(WebGLContext* webgl, const char* funcName,
|
|||
const auto dstOrigin = gl::OriginPos::BottomLeft;
|
||||
|
||||
if (srcFormat != dstFormat) {
|
||||
webgl->GeneratePerfWarning("%s: Conversion requires pixel reformatting. (%u->%u)",
|
||||
funcName, uint32_t(srcFormat),
|
||||
webgl->GeneratePerfWarning("Conversion requires pixel reformatting. (%u->%u)",
|
||||
uint32_t(srcFormat),
|
||||
uint32_t(dstFormat));
|
||||
} else if (fnHasPremultMismatch()) {
|
||||
webgl->GeneratePerfWarning("%s: Conversion requires change in"
|
||||
" alpha-premultiplication.",
|
||||
funcName);
|
||||
webgl->GeneratePerfWarning("Conversion requires change in"
|
||||
" alpha-premultiplication.");
|
||||
} else if (srcOrigin != dstOrigin) {
|
||||
webgl->GeneratePerfWarning("%s: Conversion requires y-flip.", funcName);
|
||||
webgl->GeneratePerfWarning("Conversion requires y-flip.");
|
||||
} else if (srcStride != dstStride) {
|
||||
webgl->GeneratePerfWarning("%s: Conversion requires change in stride. (%u->%u)",
|
||||
funcName, uint32_t(srcStride), uint32_t(dstStride));
|
||||
webgl->GeneratePerfWarning("Conversion requires change in stride. (%u->%u)",
|
||||
uint32_t(srcStride), uint32_t(dstStride));
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
@ -366,13 +361,13 @@ TexUnpackBlob::ConvertIfNeeded(WebGLContext* webgl, const char* funcName,
|
|||
|
||||
const auto dstTotalBytes = CheckedUint32(rowCount) * dstStride;
|
||||
if (!dstTotalBytes.isValid()) {
|
||||
webgl->ErrorOutOfMemory("%s: Calculation failed.", funcName);
|
||||
webgl->ErrorOutOfMemory("Calculation failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
UniqueBuffer dstBuffer = calloc(1, dstTotalBytes.value());
|
||||
if (!dstBuffer.get()) {
|
||||
webgl->ErrorOutOfMemory("%s: Failed to allocate dest buffer.", funcName);
|
||||
webgl->ErrorOutOfMemory("Failed to allocate dest buffer.");
|
||||
return false;
|
||||
}
|
||||
const auto dstBegin = static_cast<uint8_t*>(dstBuffer.get());
|
||||
|
@ -386,7 +381,7 @@ TexUnpackBlob::ConvertIfNeeded(WebGLContext* webgl, const char* funcName,
|
|||
dstBegin, dstStride, dstOrigin, dstFormat, dstIsPremult,
|
||||
&wasTrivial))
|
||||
{
|
||||
webgl->ErrorImplementationBug("%s: ConvertImage failed.", funcName);
|
||||
webgl->ErrorImplementationBug("ConvertImage failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -423,17 +418,16 @@ TexUnpackBytes::TexUnpackBytes(const WebGLContext* webgl, TexImageTarget target,
|
|||
{ }
|
||||
|
||||
bool
|
||||
TexUnpackBytes::Validate(WebGLContext* webgl, const char* funcName,
|
||||
const webgl::PackingInfo& pi)
|
||||
TexUnpackBytes::Validate(WebGLContext* webgl, const webgl::PackingInfo& pi)
|
||||
{
|
||||
if (mIsClientData && !mPtr)
|
||||
return true;
|
||||
|
||||
return ValidateUnpackBytes(webgl, funcName, pi, mAvailBytes, this);
|
||||
return ValidateUnpackBytes(webgl, pi, mAvailBytes, this);
|
||||
}
|
||||
|
||||
bool
|
||||
TexUnpackBytes::TexOrSubImage(bool isSubImage, bool needsRespec, const char* funcName,
|
||||
TexUnpackBytes::TexOrSubImage(bool isSubImage, bool needsRespec,
|
||||
WebGLTexture* tex, TexImageTarget target, GLint level,
|
||||
const webgl::DriverUnpackInfo* dui, GLint xOffset,
|
||||
GLint yOffset, GLint zOffset, const webgl::PackingInfo& pi,
|
||||
|
@ -463,20 +457,18 @@ TexUnpackBytes::TexOrSubImage(bool isSubImage, bool needsRespec, const char* fun
|
|||
webgl->mPixelStore_UnpackSkipRows ||
|
||||
webgl->mPixelStore_UnpackSkipPixels)
|
||||
{
|
||||
webgl->ErrorInvalidOperation("%s: Non-DOM-Element uploads with alpha-premult"
|
||||
" or y-flip do not support subrect selection.",
|
||||
funcName);
|
||||
webgl->ErrorInvalidOperation("Non-DOM-Element uploads with alpha-premult"
|
||||
" or y-flip do not support subrect selection.");
|
||||
return false;
|
||||
}
|
||||
|
||||
webgl->GenerateWarning("%s: Alpha-premult and y-flip are deprecated for"
|
||||
" non-DOM-Element uploads.",
|
||||
funcName);
|
||||
webgl->GenerateWarning("Alpha-premult and y-flip are deprecated for"
|
||||
" non-DOM-Element uploads.");
|
||||
|
||||
const uint32_t rowLength = mWidth;
|
||||
const uint32_t rowCount = mHeight * mDepth;
|
||||
const auto stride = RoundUpToMultipleOf(rowLength * bytesPerPixel, mAlignment);
|
||||
if (!ConvertIfNeeded(webgl, funcName, rowLength, rowCount, format, mPtr, stride,
|
||||
if (!ConvertIfNeeded(webgl, rowLength, rowCount, format, mPtr, stride,
|
||||
format, stride, &uploadPtr, &tempBuffer))
|
||||
{
|
||||
return false;
|
||||
|
@ -489,10 +481,9 @@ TexUnpackBytes::TexOrSubImage(bool isSubImage, bool needsRespec, const char* fun
|
|||
|
||||
bool useParanoidHandling = false;
|
||||
if (mNeedsExactUpload && webgl->mBoundPixelUnpackBuffer) {
|
||||
webgl->GenerateWarning("%s: Uploads from a buffer with a final row with a byte"
|
||||
webgl->GenerateWarning("Uploads from a buffer with a final row with a byte"
|
||||
" count smaller than the row stride can incur extra"
|
||||
" overhead.",
|
||||
funcName);
|
||||
" overhead.");
|
||||
|
||||
if (gl->WorkAroundDriverBugs()) {
|
||||
useParanoidHandling |= (gl->Vendor() == gl::GLVendor::NVIDIA);
|
||||
|
@ -601,18 +592,17 @@ TexUnpackImage::~TexUnpackImage()
|
|||
{ }
|
||||
|
||||
bool
|
||||
TexUnpackImage::Validate(WebGLContext* webgl, const char* funcName,
|
||||
const webgl::PackingInfo& pi)
|
||||
TexUnpackImage::Validate(WebGLContext* webgl, const webgl::PackingInfo& pi)
|
||||
{
|
||||
if (!ValidatePIForDOM(webgl, funcName, pi))
|
||||
if (!ValidatePIForDOM(webgl, pi))
|
||||
return false;
|
||||
|
||||
const auto fullRows = mImage->GetSize().height;
|
||||
return ValidateUnpackPixels(webgl, funcName, fullRows, 0, this);
|
||||
return ValidateUnpackPixels(webgl, fullRows, 0, this);
|
||||
}
|
||||
|
||||
bool
|
||||
TexUnpackImage::TexOrSubImage(bool isSubImage, bool needsRespec, const char* funcName,
|
||||
TexUnpackImage::TexOrSubImage(bool isSubImage, bool needsRespec,
|
||||
WebGLTexture* tex, TexImageTarget target, GLint level,
|
||||
const webgl::DriverUnpackInfo* dui, GLint xOffset,
|
||||
GLint yOffset, GLint zOffset, const webgl::PackingInfo& pi,
|
||||
|
@ -714,8 +704,8 @@ TexUnpackImage::TexOrSubImage(bool isSubImage, bool needsRespec, const char* fun
|
|||
return true;
|
||||
} while (false);
|
||||
|
||||
const nsPrintfCString perfMsg("%s: Failed to hit GPU-copy fast-path: %s (src type %u)",
|
||||
funcName, fallbackReason, uint32_t(mImage->GetFormat()));
|
||||
const nsPrintfCString perfMsg("Failed to hit GPU-copy fast-path: %s (src type %u)",
|
||||
fallbackReason, uint32_t(mImage->GetFormat()));
|
||||
|
||||
if (webgl->mPixelStore_RequireFastPath) {
|
||||
webgl->ErrorInvalidOperation("%s", perfMsg.BeginReading());
|
||||
|
@ -733,16 +723,15 @@ TexUnpackImage::TexOrSubImage(bool isSubImage, bool needsRespec, const char* fun
|
|||
dataSurf = surf->GetDataSurface();
|
||||
}
|
||||
if (!dataSurf) {
|
||||
webgl->ErrorOutOfMemory("%s: GetAsSourceSurface or GetDataSurface failed after"
|
||||
" blit failed for TexUnpackImage.",
|
||||
funcName);
|
||||
webgl->ErrorOutOfMemory("GetAsSourceSurface or GetDataSurface failed after"
|
||||
" blit failed for TexUnpackImage.");
|
||||
return false;
|
||||
}
|
||||
|
||||
const TexUnpackSurface surfBlob(webgl, target, mWidth, mHeight, mDepth, dataSurf,
|
||||
mSrcAlphaType);
|
||||
|
||||
return surfBlob.TexOrSubImage(isSubImage, needsRespec, funcName, tex, target, level,
|
||||
return surfBlob.TexOrSubImage(isSubImage, needsRespec, tex, target, level,
|
||||
dui, xOffset, yOffset, zOffset, pi, out_error);
|
||||
}
|
||||
|
||||
|
@ -812,18 +801,17 @@ GetFormatForSurf(gfx::SourceSurface* surf, WebGLTexelFormat* const out_texelForm
|
|||
//////////
|
||||
|
||||
bool
|
||||
TexUnpackSurface::Validate(WebGLContext* webgl, const char* funcName,
|
||||
const webgl::PackingInfo& pi)
|
||||
TexUnpackSurface::Validate(WebGLContext* webgl, const webgl::PackingInfo& pi)
|
||||
{
|
||||
if (!ValidatePIForDOM(webgl, funcName, pi))
|
||||
if (!ValidatePIForDOM(webgl, pi))
|
||||
return false;
|
||||
|
||||
const auto fullRows = mSurf->GetSize().height;
|
||||
return ValidateUnpackPixels(webgl, funcName, fullRows, 0, this);
|
||||
return ValidateUnpackPixels(webgl, fullRows, 0, this);
|
||||
}
|
||||
|
||||
bool
|
||||
TexUnpackSurface::TexOrSubImage(bool isSubImage, bool needsRespec, const char* funcName,
|
||||
TexUnpackSurface::TexOrSubImage(bool isSubImage, bool needsRespec,
|
||||
WebGLTexture* tex, TexImageTarget target, GLint level,
|
||||
const webgl::DriverUnpackInfo* dui, GLint xOffset,
|
||||
GLint yOffset, GLint zOffset, const webgl::PackingInfo& dstPI,
|
||||
|
@ -844,15 +832,15 @@ TexUnpackSurface::TexOrSubImage(bool isSubImage, bool needsRespec, const char* f
|
|||
WebGLTexelFormat srcFormat;
|
||||
uint8_t srcBPP;
|
||||
if (!GetFormatForSurf(mSurf, &srcFormat, &srcBPP)) {
|
||||
webgl->ErrorImplementationBug("%s: GetFormatForSurf failed for"
|
||||
webgl->ErrorImplementationBug("GetFormatForSurf failed for"
|
||||
" WebGLTexelFormat::%u.",
|
||||
funcName, uint32_t(mSurf->GetFormat()));
|
||||
uint32_t(mSurf->GetFormat()));
|
||||
return false;
|
||||
}
|
||||
|
||||
gfx::DataSourceSurface::ScopedMap map(mSurf, gfx::DataSourceSurface::MapType::READ);
|
||||
if (!map.IsMapped()) {
|
||||
webgl->ErrorOutOfMemory("%s: Failed to map source surface for upload.", funcName);
|
||||
webgl->ErrorOutOfMemory("Failed to map source surface for upload.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -879,7 +867,7 @@ TexUnpackSurface::TexOrSubImage(bool isSubImage, bool needsRespec, const char* f
|
|||
|
||||
const uint8_t* dstBegin = srcBegin;
|
||||
UniqueBuffer tempBuffer;
|
||||
if (!ConvertIfNeeded(webgl, funcName, rowLength, rowCount, srcFormat, srcBegin,
|
||||
if (!ConvertIfNeeded(webgl, rowLength, rowCount, srcFormat, srcBegin,
|
||||
srcStride, dstFormat, dstStride, &dstBegin, &tempBuffer))
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
virtual ~TexUnpackBlob() { }
|
||||
|
||||
protected:
|
||||
bool ConvertIfNeeded(WebGLContext* webgl, const char* funcName,
|
||||
bool ConvertIfNeeded(WebGLContext* webgl,
|
||||
const uint32_t rowLength, const uint32_t rowCount,
|
||||
WebGLTexelFormat srcFormat,
|
||||
const uint8_t* const srcBegin, const ptrdiff_t srcStride,
|
||||
|
@ -76,13 +76,12 @@ protected:
|
|||
public:
|
||||
virtual bool HasData() const { return true; }
|
||||
|
||||
virtual bool Validate(WebGLContext* webgl, const char* funcName,
|
||||
const webgl::PackingInfo& pi) = 0;
|
||||
virtual bool Validate(WebGLContext* webgl, const webgl::PackingInfo& pi) = 0;
|
||||
|
||||
// Returns false when we've generated a WebGL error.
|
||||
// Returns true but with a non-zero *out_error if we still need to generate a WebGL
|
||||
// error.
|
||||
virtual bool TexOrSubImage(bool isSubImage, bool needsRespec, const char* funcName,
|
||||
virtual bool TexOrSubImage(bool isSubImage, bool needsRespec,
|
||||
WebGLTexture* tex, TexImageTarget target, GLint level,
|
||||
const webgl::DriverUnpackInfo* dui, GLint xOffset,
|
||||
GLint yOffset, GLint zOffset,
|
||||
|
@ -102,9 +101,9 @@ public:
|
|||
|
||||
virtual bool HasData() const override { return !mIsClientData || bool(mPtr); }
|
||||
|
||||
virtual bool Validate(WebGLContext* webgl, const char* funcName,
|
||||
virtual bool Validate(WebGLContext* webgl,
|
||||
const webgl::PackingInfo& pi) override;
|
||||
virtual bool TexOrSubImage(bool isSubImage, bool needsRespec, const char* funcName,
|
||||
virtual bool TexOrSubImage(bool isSubImage, bool needsRespec,
|
||||
WebGLTexture* tex, TexImageTarget target, GLint level,
|
||||
const webgl::DriverUnpackInfo* dui, GLint xOffset,
|
||||
GLint yOffset, GLint zOffset,
|
||||
|
@ -122,9 +121,9 @@ public:
|
|||
|
||||
~TexUnpackImage(); // Prevent needing to define layers::Image in the header.
|
||||
|
||||
virtual bool Validate(WebGLContext* webgl, const char* funcName,
|
||||
virtual bool Validate(WebGLContext* webgl,
|
||||
const webgl::PackingInfo& pi) override;
|
||||
virtual bool TexOrSubImage(bool isSubImage, bool needsRespec, const char* funcName,
|
||||
virtual bool TexOrSubImage(bool isSubImage, bool needsRespec,
|
||||
WebGLTexture* tex, TexImageTarget target, GLint level,
|
||||
const webgl::DriverUnpackInfo* dui, GLint xOffset,
|
||||
GLint yOffset, GLint zOffset,
|
||||
|
@ -140,9 +139,9 @@ public:
|
|||
uint32_t height, uint32_t depth, gfx::DataSourceSurface* surf,
|
||||
gfxAlphaType srcAlphaType);
|
||||
|
||||
virtual bool Validate(WebGLContext* webgl, const char* funcName,
|
||||
virtual bool Validate(WebGLContext* webgl,
|
||||
const webgl::PackingInfo& pi) override;
|
||||
virtual bool TexOrSubImage(bool isSubImage, bool needsRespec, const char* funcName,
|
||||
virtual bool TexOrSubImage(bool isSubImage, bool needsRespec,
|
||||
WebGLTexture* tex, TexImageTarget target, GLint level,
|
||||
const webgl::DriverUnpackInfo* dui, GLint xOffset,
|
||||
GLint yOffset, GLint zOffset,
|
||||
|
|
|
@ -82,8 +82,12 @@ public:
|
|||
void GetInternalformatParameter(JSContext*, GLenum target, GLenum internalformat,
|
||||
GLenum pname, JS::MutableHandleValue retval,
|
||||
ErrorResult& rv);
|
||||
void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat,
|
||||
GLsizei width, GLsizei height);
|
||||
void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalFormat,
|
||||
GLsizei width, GLsizei height)
|
||||
{
|
||||
const FuncScope funcScope(*this, "renderbufferStorageMultisample");
|
||||
RenderbufferStorage_base(target, samples, internalFormat, width, height);
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
@ -92,24 +96,22 @@ public:
|
|||
void TexStorage2D(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width,
|
||||
GLsizei height)
|
||||
{
|
||||
const char funcName[] = "TexStorage2D";
|
||||
const FuncScope funcScope(*this, "TexStorage2D");
|
||||
const uint8_t funcDims = 2;
|
||||
const GLsizei depth = 1;
|
||||
TexStorage(funcName, funcDims, target, levels, internalFormat, width, height,
|
||||
depth);
|
||||
TexStorage(funcDims, target, levels, internalFormat, width, height, depth);
|
||||
}
|
||||
|
||||
void TexStorage3D(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width,
|
||||
GLsizei height, GLsizei depth)
|
||||
{
|
||||
const char funcName[] = "TexStorage3D";
|
||||
const FuncScope funcScope(*this, "TexStorage3D");
|
||||
const uint8_t funcDims = 3;
|
||||
TexStorage(funcName, funcDims, target, levels, internalFormat, width, height,
|
||||
depth);
|
||||
TexStorage(funcDims, target, levels, internalFormat, width, height, depth);
|
||||
}
|
||||
|
||||
protected:
|
||||
void TexStorage(const char* funcName, uint8_t funcDims, GLenum target, GLsizei levels,
|
||||
void TexStorage(uint8_t funcDims, GLenum target, GLsizei levels,
|
||||
GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth);
|
||||
|
||||
////////////////////////////////////
|
||||
|
@ -119,10 +121,10 @@ public:
|
|||
GLsizei width, GLsizei height, GLsizei depth, GLint border,
|
||||
GLsizei imageSize, WebGLintptr offset)
|
||||
{
|
||||
const char funcName[] = "compressedTexImage3D";
|
||||
const FuncScope funcScope(*this, "compressedTexImage3D");
|
||||
const uint8_t funcDims = 3;
|
||||
const TexImageSourceAdapter src(&offset, 0, 0);
|
||||
CompressedTexImage(funcName, funcDims, target, level, internalFormat, width,
|
||||
CompressedTexImage(funcDims, target, level, internalFormat, width,
|
||||
height, depth, border, src, Some(imageSize));
|
||||
}
|
||||
|
||||
|
@ -132,10 +134,10 @@ public:
|
|||
const T& anySrc, GLuint viewElemOffset = 0,
|
||||
GLuint viewElemLengthOverride = 0)
|
||||
{
|
||||
const char funcName[] = "compressedTexImage3D";
|
||||
const FuncScope funcScope(*this, "compressedTexImage3D");
|
||||
const uint8_t funcDims = 3;
|
||||
const TexImageSourceAdapter src(&anySrc, viewElemOffset, viewElemLengthOverride);
|
||||
CompressedTexImage(funcName, funcDims, target, level, internalFormat, width,
|
||||
CompressedTexImage(funcDims, target, level, internalFormat, width,
|
||||
height, depth, border, src, Nothing());
|
||||
}
|
||||
|
||||
|
@ -144,10 +146,10 @@ public:
|
|||
GLsizei depth, GLenum unpackFormat,
|
||||
GLsizei imageSize, WebGLintptr offset)
|
||||
{
|
||||
const char funcName[] = "compressedTexSubImage3D";
|
||||
const FuncScope funcScope(*this, "compressedTexSubImage3D");
|
||||
const uint8_t funcDims = 3;
|
||||
const TexImageSourceAdapter src(&offset, 0, 0);
|
||||
CompressedTexSubImage(funcName, funcDims, target, level, xOffset, yOffset,
|
||||
CompressedTexSubImage(funcDims, target, level, xOffset, yOffset,
|
||||
zOffset, width, height, depth, unpackFormat, src, Some(imageSize));
|
||||
}
|
||||
|
||||
|
@ -158,10 +160,10 @@ public:
|
|||
GLuint viewElemOffset = 0,
|
||||
GLuint viewElemLengthOverride = 0)
|
||||
{
|
||||
const char funcName[] = "compressedTexSubImage3D";
|
||||
const FuncScope funcScope(*this, "compressedTexSubImage3D");
|
||||
const uint8_t funcDims = 3;
|
||||
const TexImageSourceAdapter src(&anySrc, viewElemOffset, viewElemLengthOverride);
|
||||
CompressedTexSubImage(funcName, funcDims, target, level, xOffset, yOffset,
|
||||
CompressedTexSubImage(funcDims, target, level, xOffset, yOffset,
|
||||
zOffset, width, height, depth, unpackFormat, src, Nothing());
|
||||
}
|
||||
|
||||
|
@ -171,9 +173,9 @@ public:
|
|||
GLint zOffset, GLint x, GLint y, GLsizei width,
|
||||
GLsizei height)
|
||||
{
|
||||
const char funcName[] = "copyTexSubImage3D";
|
||||
const FuncScope funcScope(*this, "copyTexSubImage3D");
|
||||
const uint8_t funcDims = 3;
|
||||
CopyTexSubImage(funcName, funcDims, target, level, xOffset, yOffset, zOffset,
|
||||
CopyTexSubImage(funcDims, target, level, xOffset, yOffset, zOffset,
|
||||
x, y, width, height);
|
||||
}
|
||||
|
||||
|
@ -204,9 +206,9 @@ protected:
|
|||
GLsizei height, GLsizei depth, GLint border, GLenum unpackFormat,
|
||||
GLenum unpackType, const TexImageSource& src)
|
||||
{
|
||||
const char funcName[] = "texImage3D";
|
||||
const FuncScope funcScope(*this, "texImage3D");
|
||||
const uint8_t funcDims = 3;
|
||||
TexImage(funcName, funcDims, target, level, internalFormat, width, height, depth,
|
||||
TexImage(funcDims, target, level, internalFormat, width, height, depth,
|
||||
border, unpackFormat, unpackType, src);
|
||||
}
|
||||
|
||||
|
@ -230,10 +232,11 @@ public:
|
|||
const dom::Nullable<dom::ArrayBufferView>& maybeSrcView,
|
||||
GLuint srcElemOffset, ErrorResult&)
|
||||
{
|
||||
const FuncScope funcScope(*this, "texSubImage3D");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateNonNull("texSubImage3D", maybeSrcView))
|
||||
if (!ValidateNonNull("src", maybeSrcView))
|
||||
return;
|
||||
const auto& srcView = maybeSrcView.Value();
|
||||
|
||||
|
@ -247,9 +250,9 @@ protected:
|
|||
GLint zOffset, GLsizei width, GLsizei height, GLsizei depth,
|
||||
GLenum unpackFormat, GLenum unpackType, const TexImageSource& src)
|
||||
{
|
||||
const char funcName[] = "texSubImage3D";
|
||||
const FuncScope funcScope(*this, "texSubImage3D");
|
||||
const uint8_t funcDims = 3;
|
||||
TexSubImage(funcName, funcDims, target, level, xOffset, yOffset, zOffset, width,
|
||||
TexSubImage(funcDims, target, level, xOffset, yOffset, zOffset, width,
|
||||
height, depth, unpackFormat, unpackType, src);
|
||||
}
|
||||
|
||||
|
@ -265,24 +268,23 @@ public:
|
|||
void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride,
|
||||
WebGLintptr byteOffset)
|
||||
{
|
||||
const char funcName[] = "vertexAttribIPointer";
|
||||
const FuncScope funcScope(*this, "vertexAttribIPointer");
|
||||
const bool isFuncInt = true;
|
||||
const bool normalized = false;
|
||||
VertexAttribAnyPointer(funcName, isFuncInt, index, size, type, normalized, stride,
|
||||
VertexAttribAnyPointer(isFuncInt, index, size, type, normalized, stride,
|
||||
byteOffset);
|
||||
}
|
||||
|
||||
////////////////
|
||||
|
||||
// GL 3.0 & ES 3.0
|
||||
void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w,
|
||||
const char* funcName = nullptr);
|
||||
void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w,
|
||||
const char* funcName = nullptr);
|
||||
void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w);
|
||||
void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
|
||||
|
||||
void VertexAttribI4iv(GLuint index, const Int32ListU& list) {
|
||||
const FuncScope funcScope(*this, "VertexAttribI4iv");
|
||||
const auto& arr = Int32Arr::From(list);
|
||||
if (!ValidateAttribArraySetter("vertexAttribI4iv", 4, arr.elemCount))
|
||||
if (!ValidateAttribArraySetter(4, arr.elemCount))
|
||||
return;
|
||||
|
||||
const auto& itr = arr.elemBytes;
|
||||
|
@ -290,8 +292,9 @@ public:
|
|||
}
|
||||
|
||||
void VertexAttribI4uiv(GLuint index, const Uint32ListU& list) {
|
||||
const FuncScope funcScope(*this, "vertexAttribI4uiv");
|
||||
const auto& arr = Uint32Arr::From(list);
|
||||
if (!ValidateAttribArraySetter("vertexAttribI4uiv", 4, arr.elemCount))
|
||||
if (!ValidateAttribArraySetter(4, arr.elemCount))
|
||||
return;
|
||||
|
||||
const auto& itr = arr.elemBytes;
|
||||
|
@ -310,16 +313,16 @@ public:
|
|||
void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count,
|
||||
GLenum type, WebGLintptr byteOffset)
|
||||
{
|
||||
const char funcName[] = "drawRangeElements";
|
||||
const FuncScope funcScope(*this, "drawRangeElements");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (end < start) {
|
||||
ErrorInvalidValue("%s: end must be >= start.", funcName);
|
||||
ErrorInvalidValue("end must be >= start.");
|
||||
return;
|
||||
}
|
||||
|
||||
DrawElements(mode, count, type, byteOffset, funcName);
|
||||
DrawElements(mode, count, type, byteOffset);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -329,7 +332,7 @@ public:
|
|||
*/
|
||||
|
||||
private:
|
||||
bool ValidateClearBuffer(const char* funcName, GLenum buffer, GLint drawBuffer,
|
||||
bool ValidateClearBuffer(GLenum buffer, GLint drawBuffer,
|
||||
size_t availElemCount, GLuint elemOffset, GLenum funcType);
|
||||
|
||||
void ClearBufferfv(GLenum buffer, GLint drawBuffer, const Float32Arr& src,
|
||||
|
|
|
@ -19,21 +19,21 @@ WebGL2Context::CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
|
|||
GLintptr readOffset, GLintptr writeOffset,
|
||||
GLsizeiptr size)
|
||||
{
|
||||
const char funcName[] = "copyBufferSubData";
|
||||
const FuncScope funcScope(*this, "copyBufferSubData");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
const auto& readBuffer = ValidateBufferSelection(funcName, readTarget);
|
||||
const auto& readBuffer = ValidateBufferSelection(readTarget);
|
||||
if (!readBuffer)
|
||||
return;
|
||||
|
||||
const auto& writeBuffer = ValidateBufferSelection(funcName, writeTarget);
|
||||
const auto& writeBuffer = ValidateBufferSelection(writeTarget);
|
||||
if (!writeBuffer)
|
||||
return;
|
||||
|
||||
if (!ValidateNonNegative(funcName, "readOffset", readOffset) ||
|
||||
!ValidateNonNegative(funcName, "writeOffset", writeOffset) ||
|
||||
!ValidateNonNegative(funcName, "size", size))
|
||||
if (!ValidateNonNegative("readOffset", readOffset) ||
|
||||
!ValidateNonNegative("writeOffset", writeOffset) ||
|
||||
!ValidateNonNegative("size", size))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ WebGL2Context::CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
|
|||
{
|
||||
const auto neededBytes = CheckedInt<size_t>(offset) + size;
|
||||
if (!neededBytes.isValid() || neededBytes.value() > buffer->ByteLength()) {
|
||||
ErrorInvalidValue("%s: Invalid %s range.", funcName, info);
|
||||
ErrorInvalidValue("Invalid %s range.", info);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -62,9 +62,8 @@ WebGL2Context::CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
|
|||
const bool separate = (readOffset + size <= writeOffset ||
|
||||
writeOffset + size <= readOffset);
|
||||
if (!separate) {
|
||||
ErrorInvalidValue("%s: ranges [readOffset, readOffset + size) and"
|
||||
" [writeOffset, writeOffset + size) overlap",
|
||||
funcName);
|
||||
ErrorInvalidValue("Ranges [readOffset, readOffset + size) and"
|
||||
" [writeOffset, writeOffset + size) overlap.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -74,8 +73,7 @@ WebGL2Context::CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
|
|||
MOZ_ASSERT(readType != WebGLBuffer::Kind::Undefined);
|
||||
MOZ_ASSERT(writeType != WebGLBuffer::Kind::Undefined);
|
||||
if (writeType != readType) {
|
||||
ErrorInvalidOperation("%s: Can't copy %s data to %s data.",
|
||||
funcName,
|
||||
ErrorInvalidOperation("Can't copy %s data to %s data.",
|
||||
(readType == WebGLBuffer::Kind::OtherData) ? "other"
|
||||
: "element",
|
||||
(writeType == WebGLBuffer::Kind::OtherData) ? "other"
|
||||
|
@ -95,16 +93,16 @@ WebGL2Context::GetBufferSubData(GLenum target, GLintptr srcByteOffset,
|
|||
const dom::ArrayBufferView& dstData, GLuint dstElemOffset,
|
||||
GLuint dstElemCountOverride)
|
||||
{
|
||||
const char funcName[] = "getBufferSubData";
|
||||
const FuncScope funcScope(*this, "getBufferSubData");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateNonNegative(funcName, "srcByteOffset", srcByteOffset))
|
||||
if (!ValidateNonNegative("srcByteOffset", srcByteOffset))
|
||||
return;
|
||||
|
||||
uint8_t* bytes;
|
||||
size_t byteLen;
|
||||
if (!ValidateArrayBufferView(funcName, dstData, dstElemOffset, dstElemCountOverride,
|
||||
if (!ValidateArrayBufferView(dstData, dstElemOffset, dstElemCountOverride,
|
||||
&bytes, &byteLen))
|
||||
{
|
||||
return;
|
||||
|
@ -112,17 +110,17 @@ WebGL2Context::GetBufferSubData(GLenum target, GLintptr srcByteOffset,
|
|||
|
||||
////
|
||||
|
||||
const auto& buffer = ValidateBufferSelection(funcName, target);
|
||||
const auto& buffer = ValidateBufferSelection(target);
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
if (!buffer->ValidateRange(funcName, srcByteOffset, byteLen))
|
||||
if (!buffer->ValidateRange(srcByteOffset, byteLen))
|
||||
return;
|
||||
|
||||
////
|
||||
|
||||
if (!CheckedInt<GLsizeiptr>(byteLen).isValid()) {
|
||||
ErrorOutOfMemory("%s: Size too large.", funcName);
|
||||
ErrorOutOfMemory("Size too large.");
|
||||
return;
|
||||
}
|
||||
const GLsizeiptr glByteLen(byteLen);
|
||||
|
@ -134,16 +132,14 @@ WebGL2Context::GetBufferSubData(GLenum target, GLintptr srcByteOffset,
|
|||
case LOCAL_GL_STREAM_READ:
|
||||
case LOCAL_GL_DYNAMIC_READ:
|
||||
if (mCompletedFenceId < buffer->mLastUpdateFenceId) {
|
||||
GenerateWarning("%s: Reading from a buffer without checking for previous"
|
||||
GenerateWarning("Reading from a buffer without checking for previous"
|
||||
" command completion likely causes pipeline stalls."
|
||||
" Please use FenceSync.",
|
||||
funcName);
|
||||
" Please use FenceSync.");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
GenerateWarning("%s: Reading from a buffer with usage other than *_READ"
|
||||
" causes pipeline stalls. Copy through a STREAM_READ buffer.",
|
||||
funcName);
|
||||
GenerateWarning("Reading from a buffer with usage other than *_READ"
|
||||
" causes pipeline stalls. Copy through a STREAM_READ buffer.");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ WebGL2Context::BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY
|
|||
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
|
||||
GLbitfield mask, GLenum filter)
|
||||
{
|
||||
const FuncScope funcScope(*this, "blitFramebuffer");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
|
@ -26,7 +27,7 @@ WebGL2Context::BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY
|
|||
LOCAL_GL_DEPTH_BUFFER_BIT |
|
||||
LOCAL_GL_STENCIL_BUFFER_BIT;
|
||||
if ((mask | validBits) != validBits) {
|
||||
ErrorInvalidValue("blitFramebuffer: Invalid bit set in mask.");
|
||||
ErrorInvalidValue("Invalid bit set in mask.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -35,7 +36,7 @@ WebGL2Context::BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY
|
|||
case LOCAL_GL_LINEAR:
|
||||
break;
|
||||
default:
|
||||
ErrorInvalidEnumInfo("blitFramebuffer: Bad `filter`:", filter);
|
||||
ErrorInvalidEnumInfo("filter", filter);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -50,15 +51,14 @@ WebGL2Context::BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY
|
|||
if (fnLikelyOverflow(srcX0, srcX1) || fnLikelyOverflow(srcY0, srcY1) ||
|
||||
fnLikelyOverflow(dstX0, dstX1) || fnLikelyOverflow(dstY0, dstY1))
|
||||
{
|
||||
ErrorInvalidValue("blitFramebuffer: Likely-to-overflow large ranges are"
|
||||
" forbidden.");
|
||||
ErrorInvalidValue("Likely-to-overflow large ranges are forbidden.");
|
||||
return;
|
||||
}
|
||||
|
||||
// --
|
||||
|
||||
if (!ValidateAndInitFB("blitFramebuffer: READ_FRAMEBUFFER", mBoundReadFramebuffer) ||
|
||||
!ValidateAndInitFB("blitFramebuffer: DRAW_FRAMEBUFFER", mBoundDrawFramebuffer))
|
||||
if (!ValidateAndInitFB(mBoundReadFramebuffer) ||
|
||||
!ValidateAndInitFB(mBoundDrawFramebuffer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -76,11 +76,11 @@ void
|
|||
WebGL2Context::FramebufferTextureLayer(GLenum target, GLenum attachment,
|
||||
WebGLTexture* texture, GLint level, GLint layer)
|
||||
{
|
||||
const char funcName[] = "framebufferTextureLayer";
|
||||
const FuncScope funcScope(*this, "framebufferTextureLayer");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateFramebufferTarget(target, funcName))
|
||||
if (!ValidateFramebufferTarget(target))
|
||||
return;
|
||||
|
||||
WebGLFramebuffer* fb;
|
||||
|
@ -99,9 +99,9 @@ WebGL2Context::FramebufferTextureLayer(GLenum target, GLenum attachment,
|
|||
}
|
||||
|
||||
if (!fb)
|
||||
return ErrorInvalidOperation("%s: Cannot modify framebuffer 0.", funcName);
|
||||
return ErrorInvalidOperation("Cannot modify framebuffer 0.");
|
||||
|
||||
fb->FramebufferTextureLayer(funcName, attachment, texture, level, layer);
|
||||
fb->FramebufferTextureLayer(attachment, texture, level, layer);
|
||||
}
|
||||
|
||||
JS::Value
|
||||
|
@ -118,8 +118,7 @@ WebGL2Context::GetFramebufferAttachmentParameter(JSContext* cx,
|
|||
////
|
||||
|
||||
static bool
|
||||
ValidateBackbufferAttachmentEnum(WebGLContext* webgl, const char* funcName,
|
||||
GLenum attachment)
|
||||
ValidateBackbufferAttachmentEnum(WebGLContext* webgl, GLenum attachment)
|
||||
{
|
||||
switch (attachment) {
|
||||
case LOCAL_GL_COLOR:
|
||||
|
@ -128,14 +127,13 @@ ValidateBackbufferAttachmentEnum(WebGLContext* webgl, const char* funcName,
|
|||
return true;
|
||||
|
||||
default:
|
||||
webgl->ErrorInvalidEnum("%s: attachment: invalid enum value 0x%x.",
|
||||
funcName, attachment);
|
||||
webgl->ErrorInvalidEnumInfo("attachment", attachment);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
ValidateFramebufferAttachmentEnum(WebGLContext* webgl, const char* funcName,
|
||||
ValidateFramebufferAttachmentEnum(WebGLContext* webgl,
|
||||
GLenum attachment)
|
||||
{
|
||||
switch (attachment) {
|
||||
|
@ -146,15 +144,13 @@ ValidateFramebufferAttachmentEnum(WebGLContext* webgl, const char* funcName,
|
|||
}
|
||||
|
||||
if (attachment < LOCAL_GL_COLOR_ATTACHMENT0) {
|
||||
webgl->ErrorInvalidEnum("%s: attachment: invalid enum value 0x%x.",
|
||||
funcName, attachment);
|
||||
webgl->ErrorInvalidEnumInfo("attachment", attachment);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (attachment > webgl->LastColorAttachmentEnum()) {
|
||||
// That these errors have different types is ridiculous.
|
||||
webgl->ErrorInvalidOperation("%s: Too-large LOCAL_GL_COLOR_ATTACHMENTn.",
|
||||
funcName);
|
||||
webgl->ErrorInvalidOperation("Too-large LOCAL_GL_COLOR_ATTACHMENTn.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -162,7 +158,7 @@ ValidateFramebufferAttachmentEnum(WebGLContext* webgl, const char* funcName,
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateInvalidateFramebuffer(const char* funcName, GLenum target,
|
||||
WebGLContext::ValidateInvalidateFramebuffer(GLenum target,
|
||||
const dom::Sequence<GLenum>& attachments,
|
||||
ErrorResult* const out_rv,
|
||||
std::vector<GLenum>* const scopedVector,
|
||||
|
@ -172,7 +168,7 @@ WebGLContext::ValidateInvalidateFramebuffer(const char* funcName, GLenum target,
|
|||
if (IsContextLost())
|
||||
return false;
|
||||
|
||||
if (!ValidateFramebufferTarget(target, funcName))
|
||||
if (!ValidateFramebufferTarget(target))
|
||||
return false;
|
||||
|
||||
const WebGLFramebuffer* fb;
|
||||
|
@ -192,11 +188,11 @@ WebGLContext::ValidateInvalidateFramebuffer(const char* funcName, GLenum target,
|
|||
}
|
||||
|
||||
if (fb) {
|
||||
const auto fbStatus = fb->CheckFramebufferStatus(funcName);
|
||||
const auto fbStatus = fb->CheckFramebufferStatus();
|
||||
if (fbStatus != LOCAL_GL_FRAMEBUFFER_COMPLETE)
|
||||
return false; // Not an error, but don't run forward to driver either.
|
||||
} else {
|
||||
if (!EnsureDefaultFB(funcName))
|
||||
if (!EnsureDefaultFB())
|
||||
return false;
|
||||
}
|
||||
DoBindFB(fb, target);
|
||||
|
@ -206,12 +202,12 @@ WebGLContext::ValidateInvalidateFramebuffer(const char* funcName, GLenum target,
|
|||
|
||||
if (fb) {
|
||||
for (const auto& attachment : attachments) {
|
||||
if (!ValidateFramebufferAttachmentEnum(this, funcName, attachment))
|
||||
if (!ValidateFramebufferAttachmentEnum(this, attachment))
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
for (const auto& attachment : attachments) {
|
||||
if (!ValidateBackbufferAttachmentEnum(this, funcName, attachment))
|
||||
if (!ValidateBackbufferAttachmentEnum(this, attachment))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -255,12 +251,12 @@ WebGL2Context::InvalidateFramebuffer(GLenum target,
|
|||
const dom::Sequence<GLenum>& attachments,
|
||||
ErrorResult& rv)
|
||||
{
|
||||
const char funcName[] = "invalidateSubFramebuffer";
|
||||
const FuncScope funcScope(*this, "invalidateFramebuffer");
|
||||
|
||||
std::vector<GLenum> scopedVector;
|
||||
GLsizei glNumAttachments;
|
||||
const GLenum* glAttachments;
|
||||
if (!ValidateInvalidateFramebuffer(funcName, target, attachments, &rv, &scopedVector,
|
||||
if (!ValidateInvalidateFramebuffer(target, attachments, &rv, &scopedVector,
|
||||
&glNumAttachments, &glAttachments))
|
||||
{
|
||||
return;
|
||||
|
@ -285,23 +281,23 @@ WebGL2Context::InvalidateSubFramebuffer(GLenum target, const dom::Sequence<GLenu
|
|||
GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
ErrorResult& rv)
|
||||
{
|
||||
const char funcName[] = "invalidateSubFramebuffer";
|
||||
|
||||
if (!ValidateNonNegative(funcName, "width", width) ||
|
||||
!ValidateNonNegative(funcName, "height", height))
|
||||
{
|
||||
return;
|
||||
}
|
||||
const FuncScope funcScope(*this, "invalidateSubFramebuffer");
|
||||
|
||||
std::vector<GLenum> scopedVector;
|
||||
GLsizei glNumAttachments;
|
||||
const GLenum* glAttachments;
|
||||
if (!ValidateInvalidateFramebuffer(funcName, target, attachments, &rv, &scopedVector,
|
||||
if (!ValidateInvalidateFramebuffer(target, attachments, &rv, &scopedVector,
|
||||
&glNumAttachments, &glAttachments))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ValidateNonNegative("width", width) ||
|
||||
!ValidateNonNegative("height", height))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
// Some drivers (like OSX 10.9 GL) just don't support invalidate_framebuffer.
|
||||
|
@ -320,12 +316,12 @@ WebGL2Context::InvalidateSubFramebuffer(GLenum target, const dom::Sequence<GLenu
|
|||
void
|
||||
WebGL2Context::ReadBuffer(GLenum mode)
|
||||
{
|
||||
const char funcName[] = "readBuffer";
|
||||
const FuncScope funcScope(*this, "readBuffer");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (mBoundReadFramebuffer) {
|
||||
mBoundReadFramebuffer->ReadBuffer(funcName, mode);
|
||||
mBoundReadFramebuffer->ReadBuffer(mode);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -335,9 +331,9 @@ WebGL2Context::ReadBuffer(GLenum mode)
|
|||
{
|
||||
nsCString enumName;
|
||||
EnumName(mode, &enumName);
|
||||
ErrorInvalidOperation("%s: If READ_FRAMEBUFFER is null, `mode` must be BACK or"
|
||||
ErrorInvalidOperation("If READ_FRAMEBUFFER is null, `mode` must be BACK or"
|
||||
" NONE. Was %s.",
|
||||
funcName, enumName.BeginReading());
|
||||
enumName.BeginReading());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
namespace mozilla {
|
||||
|
||||
bool
|
||||
WebGL2Context::ValidateClearBuffer(const char* funcName, GLenum buffer, GLint drawBuffer,
|
||||
WebGL2Context::ValidateClearBuffer(GLenum buffer, GLint drawBuffer,
|
||||
size_t availElemCount, GLuint elemOffset,
|
||||
GLenum funcType)
|
||||
{
|
||||
if (elemOffset > availElemCount) {
|
||||
ErrorInvalidValue("%s: Offset too big for list.", funcName);
|
||||
ErrorInvalidValue("Offset too big for list.");
|
||||
return false;
|
||||
}
|
||||
availElemCount -= elemOffset;
|
||||
|
@ -43,31 +43,31 @@ WebGL2Context::ValidateClearBuffer(const char* funcName, GLenum buffer, GLint dr
|
|||
break;
|
||||
|
||||
default:
|
||||
ErrorInvalidEnumInfo(funcName, buffer);
|
||||
ErrorInvalidEnumInfo("buffer", buffer);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (drawBuffer < 0 || drawBuffer > maxDrawBuffer) {
|
||||
ErrorInvalidValue("%s: Invalid drawbuffer %d. This buffer only supports"
|
||||
ErrorInvalidValue("Invalid drawbuffer %d. This buffer only supports"
|
||||
" `drawbuffer` values between 0 and %u.",
|
||||
funcName, drawBuffer, maxDrawBuffer);
|
||||
drawBuffer, maxDrawBuffer);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (availElemCount < requiredElements) {
|
||||
ErrorInvalidValue("%s: Not enough elements. Require %zu. Given %zu.",
|
||||
funcName, requiredElements, availElemCount);
|
||||
ErrorInvalidValue("Not enough elements. Require %zu. Given %zu.",
|
||||
requiredElements, availElemCount);
|
||||
return false;
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
if (!BindCurFBForDraw(funcName))
|
||||
if (!BindCurFBForDraw())
|
||||
return false;
|
||||
|
||||
const auto& fb = mBoundDrawFramebuffer;
|
||||
if (fb) {
|
||||
if (!fb->ValidateClearBufferType(funcName, buffer, drawBuffer, funcType))
|
||||
if (!fb->ValidateClearBufferType(buffer, drawBuffer, funcType))
|
||||
return false;
|
||||
} else if (buffer == LOCAL_GL_COLOR) {
|
||||
if (drawBuffer != 0)
|
||||
|
@ -77,9 +77,8 @@ WebGL2Context::ValidateClearBuffer(const char* funcName, GLenum buffer, GLint dr
|
|||
return true;
|
||||
|
||||
if (funcType != LOCAL_GL_FLOAT) {
|
||||
ErrorInvalidOperation("%s: For default framebuffer, COLOR is always of type"
|
||||
" FLOAT.",
|
||||
funcName);
|
||||
ErrorInvalidOperation("For default framebuffer, COLOR is always of type"
|
||||
" FLOAT.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -93,18 +92,18 @@ void
|
|||
WebGL2Context::ClearBufferfv(GLenum buffer, GLint drawBuffer, const Float32Arr& src,
|
||||
GLuint srcElemOffset)
|
||||
{
|
||||
const char funcName[] = "clearBufferfv";
|
||||
const FuncScope funcScope(*this, "clearBufferfv");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (buffer != LOCAL_GL_COLOR &&
|
||||
buffer != LOCAL_GL_DEPTH)
|
||||
{
|
||||
ErrorInvalidEnum("%s: buffer must be COLOR or DEPTH.", funcName);
|
||||
ErrorInvalidEnum("`buffer` must be COLOR or DEPTH.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ValidateClearBuffer(funcName, buffer, drawBuffer, src.elemCount, srcElemOffset,
|
||||
if (!ValidateClearBuffer(buffer, drawBuffer, src.elemCount, srcElemOffset,
|
||||
LOCAL_GL_FLOAT))
|
||||
{
|
||||
return;
|
||||
|
@ -126,18 +125,18 @@ void
|
|||
WebGL2Context::ClearBufferiv(GLenum buffer, GLint drawBuffer, const Int32Arr& src,
|
||||
GLuint srcElemOffset)
|
||||
{
|
||||
const char funcName[] = "clearBufferiv";
|
||||
const FuncScope funcScope(*this, "clearBufferiv");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (buffer != LOCAL_GL_COLOR &&
|
||||
buffer != LOCAL_GL_STENCIL)
|
||||
{
|
||||
ErrorInvalidEnum("%s: buffer must be COLOR or STENCIL.", funcName);
|
||||
ErrorInvalidEnum("`buffer` must be COLOR or STENCIL.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ValidateClearBuffer(funcName, buffer, drawBuffer, src.elemCount, srcElemOffset,
|
||||
if (!ValidateClearBuffer(buffer, drawBuffer, src.elemCount, srcElemOffset,
|
||||
LOCAL_GL_INT))
|
||||
{
|
||||
return;
|
||||
|
@ -159,14 +158,14 @@ void
|
|||
WebGL2Context::ClearBufferuiv(GLenum buffer, GLint drawBuffer, const Uint32Arr& src,
|
||||
GLuint srcElemOffset)
|
||||
{
|
||||
const char funcName[] = "clearBufferuiv";
|
||||
const FuncScope funcScope(*this, "clearBufferuiv");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (buffer != LOCAL_GL_COLOR)
|
||||
return ErrorInvalidEnum("%s: buffer must be COLOR.", funcName);
|
||||
return ErrorInvalidEnum("`buffer` must be COLOR.");
|
||||
|
||||
if (!ValidateClearBuffer(funcName, buffer, drawBuffer, src.elemCount, srcElemOffset,
|
||||
if (!ValidateClearBuffer(buffer, drawBuffer, src.elemCount, srcElemOffset,
|
||||
LOCAL_GL_UNSIGNED_INT))
|
||||
{
|
||||
return;
|
||||
|
@ -183,14 +182,14 @@ void
|
|||
WebGL2Context::ClearBufferfi(GLenum buffer, GLint drawBuffer, GLfloat depth,
|
||||
GLint stencil)
|
||||
{
|
||||
const char funcName[] = "clearBufferfi";
|
||||
const FuncScope funcScope(*this, "clearBufferfi");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (buffer != LOCAL_GL_DEPTH_STENCIL)
|
||||
return ErrorInvalidEnum("%s: buffer must be DEPTH_STENCIL.", funcName);
|
||||
return ErrorInvalidEnum("`buffer` must be DEPTH_STENCIL.");
|
||||
|
||||
if (!ValidateClearBuffer(funcName, buffer, drawBuffer, 2, 0, 0))
|
||||
if (!ValidateClearBuffer(buffer, drawBuffer, 2, 0, 0))
|
||||
return;
|
||||
|
||||
auto driverDepth = depth;
|
||||
|
|
|
@ -16,10 +16,11 @@ namespace mozilla {
|
|||
GLint
|
||||
WebGL2Context::GetFragDataLocation(const WebGLProgram& prog, const nsAString& name)
|
||||
{
|
||||
const FuncScope funcScope(*this, "getFragDataLocation");
|
||||
if (IsContextLost())
|
||||
return -1;
|
||||
|
||||
if (!ValidateObject("getFragDataLocation: program", prog))
|
||||
if (!ValidateObject("program", prog))
|
||||
return -1;
|
||||
|
||||
return prog.GetFragDataLocation(name);
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace mozilla {
|
|||
*/
|
||||
|
||||
WebGLRefPtr<WebGLQuery>*
|
||||
WebGLContext::ValidateQuerySlotByTarget(const char* funcName, GLenum target)
|
||||
WebGLContext::ValidateQuerySlotByTarget(GLenum target)
|
||||
{
|
||||
if (IsWebGL2()) {
|
||||
switch (target) {
|
||||
|
@ -49,7 +49,7 @@ WebGLContext::ValidateQuerySlotByTarget(const char* funcName, GLenum target)
|
|||
}
|
||||
}
|
||||
|
||||
ErrorInvalidEnum("%s: Bad `target`.", funcName);
|
||||
ErrorInvalidEnumInfo("target", target);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -58,12 +58,9 @@ WebGLContext::ValidateQuerySlotByTarget(const char* funcName, GLenum target)
|
|||
// Query Objects
|
||||
|
||||
already_AddRefed<WebGLQuery>
|
||||
WebGLContext::CreateQuery(const char* funcName)
|
||||
WebGLContext::CreateQuery()
|
||||
{
|
||||
if (!funcName) {
|
||||
funcName = "createQuery";
|
||||
}
|
||||
|
||||
const FuncScope funcScope(*this, "createQuery");
|
||||
if (IsContextLost())
|
||||
return nullptr;
|
||||
|
||||
|
@ -72,50 +69,31 @@ WebGLContext::CreateQuery(const char* funcName)
|
|||
}
|
||||
|
||||
void
|
||||
WebGLContext::DeleteQuery(WebGLQuery* query, const char* funcName)
|
||||
WebGLContext::DeleteQuery(WebGLQuery* query)
|
||||
{
|
||||
if (!funcName) {
|
||||
funcName = "deleteQuery";
|
||||
}
|
||||
|
||||
if (!ValidateDeleteObject(funcName, query))
|
||||
const FuncScope funcScope(*this, "deleteQuery");
|
||||
if (!ValidateDeleteObject(query))
|
||||
return;
|
||||
|
||||
query->DeleteQuery();
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::IsQuery(const WebGLQuery* query, const char* funcName)
|
||||
{
|
||||
if (!funcName) {
|
||||
funcName = "isQuery";
|
||||
}
|
||||
|
||||
if (!ValidateIsObject(funcName, query))
|
||||
return false;
|
||||
|
||||
return query->IsQuery();
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::BeginQuery(GLenum target, WebGLQuery& query, const char* funcName)
|
||||
WebGLContext::BeginQuery(GLenum target, WebGLQuery& query)
|
||||
{
|
||||
if (!funcName) {
|
||||
funcName = "beginQuery";
|
||||
}
|
||||
|
||||
const FuncScope funcScope(*this, "beginQuery");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject(funcName, query))
|
||||
if (!ValidateObject("query", query))
|
||||
return;
|
||||
|
||||
const auto& slot = ValidateQuerySlotByTarget(funcName, target);
|
||||
const auto& slot = ValidateQuerySlotByTarget(target);
|
||||
if (!slot)
|
||||
return;
|
||||
|
||||
if (*slot)
|
||||
return ErrorInvalidOperation("%s: Query target already active.", funcName);
|
||||
return ErrorInvalidOperation("Query target already active.");
|
||||
|
||||
////
|
||||
|
||||
|
@ -123,33 +101,28 @@ WebGLContext::BeginQuery(GLenum target, WebGLQuery& query, const char* funcName)
|
|||
}
|
||||
|
||||
void
|
||||
WebGLContext::EndQuery(GLenum target, const char* funcName)
|
||||
WebGLContext::EndQuery(GLenum target)
|
||||
{
|
||||
if (!funcName) {
|
||||
funcName = "endQuery";
|
||||
}
|
||||
|
||||
const FuncScope funcScope(*this, "endQuery");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
const auto& slot = ValidateQuerySlotByTarget(funcName, target);
|
||||
const auto& slot = ValidateQuerySlotByTarget(target);
|
||||
if (!slot)
|
||||
return;
|
||||
|
||||
const auto& query = *slot;
|
||||
if (!query)
|
||||
return ErrorInvalidOperation("%s: Query target not active.", funcName);
|
||||
return ErrorInvalidOperation("Query target not active.");
|
||||
|
||||
query->EndQuery();
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::GetQuery(JSContext* cx, GLenum target, GLenum pname,
|
||||
JS::MutableHandleValue retval, const char* funcName)
|
||||
JS::MutableHandleValue retval)
|
||||
{
|
||||
if (!funcName) {
|
||||
funcName = "getQuery";
|
||||
}
|
||||
const FuncScope funcScope(*this, "getQuery");
|
||||
|
||||
retval.setNull();
|
||||
if (IsContextLost())
|
||||
|
@ -167,7 +140,7 @@ WebGLContext::GetQuery(JSContext* cx, GLenum target, GLenum pname,
|
|||
return;
|
||||
}
|
||||
|
||||
const auto& slot = ValidateQuerySlotByTarget(funcName, target);
|
||||
const auto& slot = ValidateQuerySlotByTarget(target);
|
||||
if (!slot || !*slot)
|
||||
return;
|
||||
|
||||
|
@ -188,7 +161,7 @@ WebGLContext::GetQuery(JSContext* cx, GLenum target, GLenum pname,
|
|||
if (target != LOCAL_GL_TIME_ELAPSED_EXT &&
|
||||
target != LOCAL_GL_TIMESTAMP_EXT)
|
||||
{
|
||||
ErrorInvalidEnum("%s: Bad pname for target.", funcName);
|
||||
ErrorInvalidEnumInfo("target", target);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -207,22 +180,19 @@ WebGLContext::GetQuery(JSContext* cx, GLenum target, GLenum pname,
|
|||
break;
|
||||
}
|
||||
|
||||
ErrorInvalidEnum("%s: Bad pname.", funcName);
|
||||
ErrorInvalidEnumInfo("pname", pname);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::GetQueryParameter(JSContext*, const WebGLQuery& query, GLenum pname,
|
||||
JS::MutableHandleValue retval, const char* funcName)
|
||||
JS::MutableHandleValue retval)
|
||||
{
|
||||
if (!funcName) {
|
||||
funcName = "getQueryParameter";
|
||||
}
|
||||
|
||||
const FuncScope funcScope(*this, "getQueryParameter");
|
||||
retval.setNull();
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject(funcName, query))
|
||||
if (!ValidateObject("query", query))
|
||||
return;
|
||||
|
||||
query.GetQueryParameter(pname, retval);
|
||||
|
|
|
@ -17,15 +17,14 @@ WebGL2Context::GetInternalformatParameter(JSContext* cx, GLenum target,
|
|||
JS::MutableHandleValue retval,
|
||||
ErrorResult& out_rv)
|
||||
{
|
||||
const char funcName[] = "getInternalfomratParameter";
|
||||
const FuncScope funcScope(*this, "getInternalfomratParameter");
|
||||
retval.setObjectOrNull(nullptr);
|
||||
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (target != LOCAL_GL_RENDERBUFFER) {
|
||||
ErrorInvalidEnum("%s: `target` must be RENDERBUFFER, was: 0x%04x.", funcName,
|
||||
target);
|
||||
ErrorInvalidEnum("`target` must be RENDERBUFFER.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -51,13 +50,13 @@ WebGL2Context::GetInternalformatParameter(JSContext* cx, GLenum target,
|
|||
|
||||
const auto usage = mFormatUsage->GetRBUsage(sizedFormat);
|
||||
if (!usage) {
|
||||
ErrorInvalidEnum("%s: `internalformat` must be color-, depth-, or stencil-renderable, was: 0x%04x.",
|
||||
funcName, internalformat);
|
||||
ErrorInvalidEnum("`internalformat` must be color-, depth-, or stencil-renderable, was: 0x%04x.",
|
||||
internalformat);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pname != LOCAL_GL_SAMPLES) {
|
||||
ErrorInvalidEnumInfo("%s: `pname` must be SAMPLES, was 0x%04x.", funcName, pname);
|
||||
ErrorInvalidEnum("`pname` must be SAMPLES.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -81,16 +80,4 @@ WebGL2Context::GetInternalformatParameter(JSContext* cx, GLenum target,
|
|||
retval.setObjectOrNull(obj);
|
||||
}
|
||||
|
||||
void
|
||||
WebGL2Context::RenderbufferStorageMultisample(GLenum target, GLsizei samples,
|
||||
GLenum internalFormat,
|
||||
GLsizei width, GLsizei height)
|
||||
{
|
||||
const char funcName[] = "renderbufferStorageMultisample";
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
RenderbufferStorage_base(funcName, target, samples, internalFormat, width, height);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace mozilla {
|
|||
already_AddRefed<WebGLSampler>
|
||||
WebGL2Context::CreateSampler()
|
||||
{
|
||||
const FuncScope funcScope(*this, "createSampler");
|
||||
if (IsContextLost())
|
||||
return nullptr;
|
||||
|
||||
|
@ -22,7 +23,8 @@ WebGL2Context::CreateSampler()
|
|||
void
|
||||
WebGL2Context::DeleteSampler(WebGLSampler* sampler)
|
||||
{
|
||||
if (!ValidateDeleteObject("deleteSampler", sampler))
|
||||
const FuncScope funcScope(*this, "deleteSampler");
|
||||
if (!ValidateDeleteObject(sampler))
|
||||
return;
|
||||
|
||||
for (uint32_t n = 0; n < mGLMaxTextureUnits; n++) {
|
||||
|
@ -37,25 +39,27 @@ WebGL2Context::DeleteSampler(WebGLSampler* sampler)
|
|||
}
|
||||
|
||||
bool
|
||||
WebGL2Context::IsSampler(const WebGLSampler* sampler)
|
||||
WebGL2Context::IsSampler(const WebGLSampler* const obj)
|
||||
{
|
||||
if (!ValidateIsObject("isSampler", sampler))
|
||||
const FuncScope funcScope(*this, "isSampler");
|
||||
if (!ValidateIsObject(obj))
|
||||
return false;
|
||||
|
||||
return gl->fIsSampler(sampler->mGLName);
|
||||
return gl->fIsSampler(obj->mGLName);
|
||||
}
|
||||
|
||||
void
|
||||
WebGL2Context::BindSampler(GLuint unit, WebGLSampler* sampler)
|
||||
{
|
||||
const FuncScope funcScope(*this, "bindSampler");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (sampler && !ValidateObject("bindSampler", *sampler))
|
||||
if (sampler && !ValidateObject("sampler", *sampler))
|
||||
return;
|
||||
|
||||
if (unit >= mGLMaxTextureUnits)
|
||||
return ErrorInvalidValue("bindSampler: unit must be < %u", mGLMaxTextureUnits);
|
||||
return ErrorInvalidValue("unit must be < %u", mGLMaxTextureUnits);
|
||||
|
||||
////
|
||||
|
||||
|
@ -68,40 +72,40 @@ WebGL2Context::BindSampler(GLuint unit, WebGLSampler* sampler)
|
|||
void
|
||||
WebGL2Context::SamplerParameteri(WebGLSampler& sampler, GLenum pname, GLint param)
|
||||
{
|
||||
const char funcName[] = "samplerParameteri";
|
||||
const FuncScope funcScope(*this, "samplerParameteri");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject(funcName, sampler))
|
||||
if (!ValidateObject("sampler", sampler))
|
||||
return;
|
||||
|
||||
sampler.SamplerParameter(funcName, pname, FloatOrInt(param));
|
||||
sampler.SamplerParameter(pname, FloatOrInt(param));
|
||||
}
|
||||
|
||||
void
|
||||
WebGL2Context::SamplerParameterf(WebGLSampler& sampler, GLenum pname, GLfloat param)
|
||||
{
|
||||
const char funcName[] = "samplerParameterf";
|
||||
const FuncScope funcScope(*this, "samplerParameterf");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject(funcName, sampler))
|
||||
if (!ValidateObject("sampler", sampler))
|
||||
return;
|
||||
|
||||
sampler.SamplerParameter(funcName, pname, FloatOrInt(param));
|
||||
sampler.SamplerParameter(pname, FloatOrInt(param));
|
||||
}
|
||||
|
||||
void
|
||||
WebGL2Context::GetSamplerParameter(JSContext*, const WebGLSampler& sampler, GLenum pname,
|
||||
JS::MutableHandleValue retval)
|
||||
{
|
||||
const char funcName[] = "getSamplerParameter";
|
||||
const FuncScope funcScope(*this, "getSamplerParameter");
|
||||
retval.setNull();
|
||||
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject(funcName, sampler))
|
||||
if (!ValidateObject("sampler", sampler))
|
||||
return;
|
||||
|
||||
////
|
||||
|
@ -131,7 +135,7 @@ WebGL2Context::GetSamplerParameter(JSContext*, const WebGLSampler& sampler, GLen
|
|||
return;
|
||||
|
||||
default:
|
||||
ErrorInvalidEnumArg(funcName, "pname", pname);
|
||||
ErrorInvalidEnumInfo("pname", pname);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace mozilla {
|
|||
JS::Value
|
||||
WebGL2Context::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
|
||||
{
|
||||
const FuncScope funcScope(*this, "getParameter");
|
||||
// The following cases are handled in WebGLContext::GetParameter():
|
||||
// case LOCAL_GL_MAX_COLOR_ATTACHMENTS:
|
||||
// case LOCAL_GL_MAX_DRAW_BUFFERS:
|
||||
|
|
|
@ -16,16 +16,17 @@ namespace mozilla {
|
|||
already_AddRefed<WebGLSync>
|
||||
WebGL2Context::FenceSync(GLenum condition, GLbitfield flags)
|
||||
{
|
||||
const FuncScope funcScope(*this, "fenceSync");
|
||||
if (IsContextLost())
|
||||
return nullptr;
|
||||
|
||||
if (condition != LOCAL_GL_SYNC_GPU_COMMANDS_COMPLETE) {
|
||||
ErrorInvalidEnum("fenceSync: condition must be SYNC_GPU_COMMANDS_COMPLETE");
|
||||
ErrorInvalidEnum("condition must be SYNC_GPU_COMMANDS_COMPLETE");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (flags != 0) {
|
||||
ErrorInvalidValue("fenceSync: flags must be 0");
|
||||
ErrorInvalidValue("flags must be 0");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -38,18 +39,17 @@ WebGL2Context::FenceSync(GLenum condition, GLbitfield flags)
|
|||
}
|
||||
|
||||
bool
|
||||
WebGL2Context::IsSync(const WebGLSync* sync)
|
||||
WebGL2Context::IsSync(const WebGLSync* const sync)
|
||||
{
|
||||
if (!ValidateIsObject("isSync", sync))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
const FuncScope funcScope(*this, "isSync");
|
||||
return ValidateIsObject(sync);
|
||||
}
|
||||
|
||||
void
|
||||
WebGL2Context::DeleteSync(WebGLSync* sync)
|
||||
{
|
||||
if (!ValidateDeleteObject("deleteSync", sync))
|
||||
const FuncScope funcScope(*this, "deleteSync");
|
||||
if (!ValidateDeleteObject(sync))
|
||||
return;
|
||||
|
||||
sync->RequestDelete();
|
||||
|
@ -58,20 +58,20 @@ WebGL2Context::DeleteSync(WebGLSync* sync)
|
|||
GLenum
|
||||
WebGL2Context::ClientWaitSync(const WebGLSync& sync, GLbitfield flags, GLuint64 timeout)
|
||||
{
|
||||
const char funcName[] = "clientWaitSync";
|
||||
const FuncScope funcScope(*this, "clientWaitSync");
|
||||
if (IsContextLost())
|
||||
return LOCAL_GL_WAIT_FAILED;
|
||||
|
||||
if (!ValidateObject(funcName, sync))
|
||||
if (!ValidateObject("sync", sync))
|
||||
return LOCAL_GL_WAIT_FAILED;
|
||||
|
||||
if (flags != 0 && flags != LOCAL_GL_SYNC_FLUSH_COMMANDS_BIT) {
|
||||
ErrorInvalidValue("%s: `flags` must be SYNC_FLUSH_COMMANDS_BIT or 0.", funcName);
|
||||
ErrorInvalidValue("`flags` must be SYNC_FLUSH_COMMANDS_BIT or 0.");
|
||||
return LOCAL_GL_WAIT_FAILED;
|
||||
}
|
||||
|
||||
if (timeout > kMaxClientWaitSyncTimeoutNS) {
|
||||
ErrorInvalidOperation("%s: `timeout` must not exceed %s nanoseconds.", funcName,
|
||||
ErrorInvalidOperation("`timeout` must not exceed %s nanoseconds.",
|
||||
"MAX_CLIENT_WAIT_TIMEOUT_WEBGL");
|
||||
return LOCAL_GL_WAIT_FAILED;
|
||||
}
|
||||
|
@ -80,9 +80,8 @@ WebGL2Context::ClientWaitSync(const WebGLSync& sync, GLbitfield flags, GLuint64
|
|||
gfxPrefs::WebGLImmediateQueries());
|
||||
if (!canBeAvailable) {
|
||||
if (timeout) {
|
||||
GenerateWarning("%s: Sync object not yet queryable. Please wait for the event"
|
||||
" loop.",
|
||||
funcName);
|
||||
GenerateWarning("Sync object not yet queryable. Please wait for the event"
|
||||
" loop.");
|
||||
}
|
||||
return LOCAL_GL_WAIT_FAILED;
|
||||
}
|
||||
|
@ -101,20 +100,20 @@ WebGL2Context::ClientWaitSync(const WebGLSync& sync, GLbitfield flags, GLuint64
|
|||
void
|
||||
WebGL2Context::WaitSync(const WebGLSync& sync, GLbitfield flags, GLint64 timeout)
|
||||
{
|
||||
const char funcName[] = "waitSync";
|
||||
const FuncScope funcScope(*this, "waitSync");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject(funcName, sync))
|
||||
if (!ValidateObject("sync", sync))
|
||||
return;
|
||||
|
||||
if (flags != 0) {
|
||||
ErrorInvalidValue("%s: `flags` must be 0.", funcName);
|
||||
ErrorInvalidValue("`flags` must be 0.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (timeout != -1) {
|
||||
ErrorInvalidValue("%s: `timeout` must be TIMEOUT_IGNORED.", funcName);
|
||||
ErrorInvalidValue("`timeout` must be TIMEOUT_IGNORED.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -125,12 +124,12 @@ void
|
|||
WebGL2Context::GetSyncParameter(JSContext*, const WebGLSync& sync, GLenum pname,
|
||||
JS::MutableHandleValue retval)
|
||||
{
|
||||
const char funcName[] = "getSyncParameter";
|
||||
const FuncScope funcScope(*this, "getSyncParameter");
|
||||
retval.setNull();
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject(funcName, sync))
|
||||
if (!ValidateObject("sync", sync))
|
||||
return;
|
||||
|
||||
////
|
||||
|
@ -160,7 +159,7 @@ WebGL2Context::GetSyncParameter(JSContext*, const WebGLSync& sync, GLenum pname,
|
|||
return;
|
||||
|
||||
default:
|
||||
ErrorInvalidEnum("%s: Invalid pname 0x%04x", funcName, pname);
|
||||
ErrorInvalidEnumInfo("pname", pname);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,16 +11,18 @@
|
|||
namespace mozilla {
|
||||
|
||||
void
|
||||
WebGL2Context::TexStorage(const char* funcName, uint8_t funcDims, GLenum rawTarget,
|
||||
WebGL2Context::TexStorage(uint8_t funcDims, GLenum rawTarget,
|
||||
GLsizei levels, GLenum internalFormat, GLsizei width,
|
||||
GLsizei height, GLsizei depth)
|
||||
{
|
||||
const FuncScope funcScope(*this, "texStorage");
|
||||
|
||||
TexTarget target;
|
||||
WebGLTexture* tex;
|
||||
if (!ValidateTexTarget(this, funcName, funcDims, rawTarget, &target, &tex))
|
||||
if (!ValidateTexTarget(this, funcDims, rawTarget, &target, &tex))
|
||||
return;
|
||||
|
||||
tex->TexStorage(funcName, target, levels, internalFormat, width, height, depth);
|
||||
tex->TexStorage(target, levels, internalFormat, width, height, depth);
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace mozilla {
|
|||
already_AddRefed<WebGLTransformFeedback>
|
||||
WebGL2Context::CreateTransformFeedback()
|
||||
{
|
||||
const FuncScope funcScope(*this, "createTransformFeedback");
|
||||
if (IsContextLost())
|
||||
return nullptr;
|
||||
|
||||
|
@ -30,12 +31,12 @@ WebGL2Context::CreateTransformFeedback()
|
|||
void
|
||||
WebGL2Context::DeleteTransformFeedback(WebGLTransformFeedback* tf)
|
||||
{
|
||||
const char funcName[] = "deleteTransformFeedback";
|
||||
if (!ValidateDeleteObject(funcName, tf))
|
||||
const FuncScope funcScope(*this, "deleteTransformFeedback");
|
||||
if (!ValidateDeleteObject(tf))
|
||||
return;
|
||||
|
||||
if (tf->mIsActive) {
|
||||
ErrorInvalidOperation("%s: Cannot delete active transform feedbacks.", funcName);
|
||||
ErrorInvalidOperation("Cannot delete active transform feedbacks.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -47,33 +48,33 @@ WebGL2Context::DeleteTransformFeedback(WebGLTransformFeedback* tf)
|
|||
}
|
||||
|
||||
bool
|
||||
WebGL2Context::IsTransformFeedback(const WebGLTransformFeedback* tf)
|
||||
WebGL2Context::IsTransformFeedback(const WebGLTransformFeedback* const obj)
|
||||
{
|
||||
if (!ValidateIsObject("isTransformFeedback", tf))
|
||||
const FuncScope funcScope(*this, "isTransformFeedback");
|
||||
if (!ValidateIsObject(obj))
|
||||
return false;
|
||||
|
||||
return gl->fIsTransformFeedback(tf->mGLName);
|
||||
return gl->fIsTransformFeedback(obj->mGLName);
|
||||
}
|
||||
|
||||
void
|
||||
WebGL2Context::BindTransformFeedback(GLenum target, WebGLTransformFeedback* tf)
|
||||
{
|
||||
const char funcName[] = "bindTransformFeedback";
|
||||
const FuncScope funcScope(*this, "bindTransformFeedback");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (target != LOCAL_GL_TRANSFORM_FEEDBACK)
|
||||
return ErrorInvalidEnum("%s: `target` must be TRANSFORM_FEEDBACK.", funcName);
|
||||
return ErrorInvalidEnum("`target` must be TRANSFORM_FEEDBACK.");
|
||||
|
||||
if (tf && !ValidateObject(funcName, *tf))
|
||||
if (tf && !ValidateObject("tf", *tf))
|
||||
return;
|
||||
|
||||
if (mBoundTransformFeedback->mIsActive &&
|
||||
!mBoundTransformFeedback->mIsPaused)
|
||||
{
|
||||
ErrorInvalidOperation("%s: Currently bound transform feedback is active and not"
|
||||
" paused.",
|
||||
funcName);
|
||||
ErrorInvalidOperation("Currently bound transform feedback is active and not"
|
||||
" paused.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -95,6 +96,7 @@ WebGL2Context::BindTransformFeedback(GLenum target, WebGLTransformFeedback* tf)
|
|||
void
|
||||
WebGL2Context::BeginTransformFeedback(GLenum primMode)
|
||||
{
|
||||
const FuncScope funcScope(*this, "beginTransformFeedback");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
|
@ -104,6 +106,7 @@ WebGL2Context::BeginTransformFeedback(GLenum primMode)
|
|||
void
|
||||
WebGL2Context::EndTransformFeedback()
|
||||
{
|
||||
const FuncScope funcScope(*this, "endTransformFeedback");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
|
@ -113,6 +116,7 @@ WebGL2Context::EndTransformFeedback()
|
|||
void
|
||||
WebGL2Context::PauseTransformFeedback()
|
||||
{
|
||||
const FuncScope funcScope(*this, "pauseTransformFeedback");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
|
@ -122,6 +126,7 @@ WebGL2Context::PauseTransformFeedback()
|
|||
void
|
||||
WebGL2Context::ResumeTransformFeedback()
|
||||
{
|
||||
const FuncScope funcScope(*this, "resumeTransformFeedback");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
|
@ -133,10 +138,11 @@ WebGL2Context::TransformFeedbackVaryings(WebGLProgram& program,
|
|||
const dom::Sequence<nsString>& varyings,
|
||||
GLenum bufferMode)
|
||||
{
|
||||
const FuncScope funcScope(*this, "transformFeedbackVaryings");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("transformFeedbackVaryings: program", program))
|
||||
if (!ValidateObject("program", program))
|
||||
return;
|
||||
|
||||
program.TransformFeedbackVaryings(varyings, bufferMode);
|
||||
|
@ -145,10 +151,11 @@ WebGL2Context::TransformFeedbackVaryings(WebGLProgram& program,
|
|||
already_AddRefed<WebGLActiveInfo>
|
||||
WebGL2Context::GetTransformFeedbackVarying(const WebGLProgram& program, GLuint index)
|
||||
{
|
||||
const FuncScope funcScope(*this, "getTransformFeedbackVarying");
|
||||
if (IsContextLost())
|
||||
return nullptr;
|
||||
|
||||
if (!ValidateObject("getTransformFeedbackVarying: program", program))
|
||||
if (!ValidateObject("program", program))
|
||||
return nullptr;
|
||||
|
||||
return program.GetTransformFeedbackVarying(index);
|
||||
|
|
|
@ -23,7 +23,8 @@ namespace mozilla {
|
|||
void
|
||||
WebGLContext::Uniform1ui(WebGLUniformLocation* loc, GLuint v0)
|
||||
{
|
||||
if (!ValidateUniformSetter(loc, 1, LOCAL_GL_UNSIGNED_INT, "uniform1ui"))
|
||||
const FuncScope funcScope(*this, "uniform1ui");
|
||||
if (!ValidateUniformSetter(loc, 1, LOCAL_GL_UNSIGNED_INT))
|
||||
return;
|
||||
|
||||
gl->fUniform1ui(loc->mLoc, v0);
|
||||
|
@ -32,7 +33,8 @@ WebGLContext::Uniform1ui(WebGLUniformLocation* loc, GLuint v0)
|
|||
void
|
||||
WebGLContext::Uniform2ui(WebGLUniformLocation* loc, GLuint v0, GLuint v1)
|
||||
{
|
||||
if (!ValidateUniformSetter(loc, 2, LOCAL_GL_UNSIGNED_INT, "uniform2ui"))
|
||||
const FuncScope funcScope(*this, "uniform2ui");
|
||||
if (!ValidateUniformSetter(loc, 2, LOCAL_GL_UNSIGNED_INT))
|
||||
return;
|
||||
|
||||
gl->fUniform2ui(loc->mLoc, v0, v1);
|
||||
|
@ -41,7 +43,8 @@ WebGLContext::Uniform2ui(WebGLUniformLocation* loc, GLuint v0, GLuint v1)
|
|||
void
|
||||
WebGLContext::Uniform3ui(WebGLUniformLocation* loc, GLuint v0, GLuint v1, GLuint v2)
|
||||
{
|
||||
if (!ValidateUniformSetter(loc, 3, LOCAL_GL_UNSIGNED_INT, "uniform3ui"))
|
||||
const FuncScope funcScope(*this, "uniform3ui");
|
||||
if (!ValidateUniformSetter(loc, 3, LOCAL_GL_UNSIGNED_INT))
|
||||
return;
|
||||
|
||||
gl->fUniform3ui(loc->mLoc, v0, v1, v2);
|
||||
|
@ -51,7 +54,8 @@ void
|
|||
WebGLContext::Uniform4ui(WebGLUniformLocation* loc, GLuint v0, GLuint v1, GLuint v2,
|
||||
GLuint v3)
|
||||
{
|
||||
if (!ValidateUniformSetter(loc, 4, LOCAL_GL_UNSIGNED_INT, "uniform4ui"))
|
||||
const FuncScope funcScope(*this, "uniform4ui");
|
||||
if (!ValidateUniformSetter(loc, 4, LOCAL_GL_UNSIGNED_INT))
|
||||
return;
|
||||
|
||||
gl->fUniform4ui(loc->mLoc, v0, v1, v2, v3);
|
||||
|
@ -64,7 +68,7 @@ void
|
|||
WebGL2Context::GetIndexedParameter(JSContext* cx, GLenum target, GLuint index,
|
||||
JS::MutableHandleValue retval, ErrorResult& out_error)
|
||||
{
|
||||
const char funcName[] = "getIndexedParameter";
|
||||
const FuncScope funcScope(*this, "getIndexedParameter");
|
||||
retval.set(JS::NullValue());
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
@ -84,12 +88,12 @@ WebGL2Context::GetIndexedParameter(JSContext* cx, GLenum target, GLuint index,
|
|||
break;
|
||||
|
||||
default:
|
||||
ErrorInvalidEnumInfo("getIndexedParameter: target", target);
|
||||
ErrorInvalidEnumInfo("target", target);
|
||||
return;
|
||||
}
|
||||
|
||||
if (index >= bindings->size()) {
|
||||
ErrorInvalidValue("%s: `index` must be < %s.", funcName,
|
||||
ErrorInvalidValue("`index` must be < %s.",
|
||||
"MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS");
|
||||
return;
|
||||
}
|
||||
|
@ -124,11 +128,12 @@ WebGL2Context::GetUniformIndices(const WebGLProgram& program,
|
|||
const dom::Sequence<nsString>& uniformNames,
|
||||
dom::Nullable< nsTArray<GLuint> >& retval)
|
||||
{
|
||||
const FuncScope funcScope(*this, "getUniformIndices");
|
||||
retval.SetNull();
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("getUniformIndices: program", program))
|
||||
if (!ValidateObject("program", program))
|
||||
return;
|
||||
|
||||
if (!uniformNames.Length())
|
||||
|
@ -137,9 +142,16 @@ WebGL2Context::GetUniformIndices(const WebGLProgram& program,
|
|||
program.GetUniformIndices(uniformNames, retval);
|
||||
}
|
||||
|
||||
static bool
|
||||
ValidateUniformEnum(WebGLContext* webgl, GLenum pname, const char* info)
|
||||
void
|
||||
WebGL2Context::GetActiveUniforms(JSContext* cx, const WebGLProgram& program,
|
||||
const dom::Sequence<GLuint>& uniformIndices,
|
||||
GLenum pname, JS::MutableHandleValue retval)
|
||||
{
|
||||
const FuncScope funcScope(*this, "getActiveUniforms");
|
||||
retval.setNull();
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
switch (pname) {
|
||||
case LOCAL_GL_UNIFORM_TYPE:
|
||||
case LOCAL_GL_UNIFORM_SIZE:
|
||||
|
@ -148,39 +160,25 @@ ValidateUniformEnum(WebGLContext* webgl, GLenum pname, const char* info)
|
|||
case LOCAL_GL_UNIFORM_ARRAY_STRIDE:
|
||||
case LOCAL_GL_UNIFORM_MATRIX_STRIDE:
|
||||
case LOCAL_GL_UNIFORM_IS_ROW_MAJOR:
|
||||
return true;
|
||||
break;
|
||||
|
||||
default:
|
||||
webgl->ErrorInvalidEnumArg(info, "pname", pname);
|
||||
return false;
|
||||
ErrorInvalidEnumInfo("pname", pname);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WebGL2Context::GetActiveUniforms(JSContext* cx, const WebGLProgram& program,
|
||||
const dom::Sequence<GLuint>& uniformIndices,
|
||||
GLenum pname, JS::MutableHandleValue retval)
|
||||
{
|
||||
const char funcName[] = "getActiveUniforms";
|
||||
retval.setNull();
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateUniformEnum(this, pname, funcName))
|
||||
return;
|
||||
|
||||
if (!ValidateObject("getActiveUniforms: program", program))
|
||||
if (!ValidateObject("program", program))
|
||||
return;
|
||||
|
||||
if (!program.IsLinked()) {
|
||||
ErrorInvalidOperation("%s: `program` must be linked.", funcName);
|
||||
ErrorInvalidOperation("`program` must be linked.");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& numActiveUniforms = program.LinkInfo()->uniforms.size();
|
||||
for (const auto& curIndex : uniformIndices) {
|
||||
if (curIndex >= numActiveUniforms) {
|
||||
ErrorInvalidValue("%s: Too-large active uniform index queried.", funcName);
|
||||
ErrorInvalidValue("Too-large active uniform index queried.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -190,7 +188,7 @@ WebGL2Context::GetActiveUniforms(JSContext* cx, const WebGLProgram& program,
|
|||
JS::Rooted<JSObject*> array(cx, JS_NewArrayObject(cx, count));
|
||||
UniquePtr<GLint[]> samples(new GLint[count]);
|
||||
if (!array || !samples) {
|
||||
ErrorOutOfMemory("%s: Failed to allocate buffers.", funcName);
|
||||
ErrorOutOfMemory("Failed to allocate buffers.");
|
||||
return;
|
||||
}
|
||||
retval.setObject(*array);
|
||||
|
@ -230,10 +228,11 @@ GLuint
|
|||
WebGL2Context::GetUniformBlockIndex(const WebGLProgram& program,
|
||||
const nsAString& uniformBlockName)
|
||||
{
|
||||
const FuncScope funcScope(*this, "getUniformBlockIndex");
|
||||
if (IsContextLost())
|
||||
return 0;
|
||||
|
||||
if (!ValidateObject("getUniformBlockIndex: program", program))
|
||||
if (!ValidateObject("program", program))
|
||||
return 0;
|
||||
|
||||
return program.GetUniformBlockIndex(uniformBlockName);
|
||||
|
@ -245,11 +244,12 @@ WebGL2Context::GetActiveUniformBlockParameter(JSContext* cx, const WebGLProgram&
|
|||
JS::MutableHandleValue out_retval,
|
||||
ErrorResult& out_error)
|
||||
{
|
||||
const FuncScope funcScope(*this, "getActiveUniformBlockParameter");
|
||||
out_retval.setNull();
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("getActiveUniformBlockParameter: program", program))
|
||||
if (!ValidateObject("program", program))
|
||||
return;
|
||||
|
||||
switch(pname) {
|
||||
|
@ -267,18 +267,19 @@ WebGL2Context::GetActiveUniformBlockParameter(JSContext* cx, const WebGLProgram&
|
|||
return;
|
||||
}
|
||||
|
||||
ErrorInvalidEnumInfo("getActiveUniformBlockParameter: parameter", pname);
|
||||
ErrorInvalidEnumInfo("parameter", pname);
|
||||
}
|
||||
|
||||
void
|
||||
WebGL2Context::GetActiveUniformBlockName(const WebGLProgram& program,
|
||||
GLuint uniformBlockIndex, nsAString& retval)
|
||||
{
|
||||
const FuncScope funcScope(*this, "getActiveUniformBlockName");
|
||||
retval.SetIsVoid(true);
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("getActiveUniformBlockName: program", program))
|
||||
if (!ValidateObject("program", program))
|
||||
return;
|
||||
|
||||
program.GetActiveUniformBlockName(uniformBlockIndex, retval);
|
||||
|
@ -288,10 +289,11 @@ void
|
|||
WebGL2Context::UniformBlockBinding(WebGLProgram& program, GLuint uniformBlockIndex,
|
||||
GLuint uniformBlockBinding)
|
||||
{
|
||||
const FuncScope funcScope(*this, "uniformBlockBinding");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateObject("uniformBlockBinding: program", program))
|
||||
if (!ValidateObject("program", program))
|
||||
return;
|
||||
|
||||
program.UniformBlockBinding(uniformBlockIndex, uniformBlockBinding);
|
||||
|
|
|
@ -70,7 +70,7 @@ WebGLBuffer::Delete()
|
|||
////////////////////////////////////////
|
||||
|
||||
static bool
|
||||
ValidateBufferUsageEnum(WebGLContext* webgl, const char* funcName, GLenum usage)
|
||||
ValidateBufferUsageEnum(WebGLContext* webgl, GLenum usage)
|
||||
{
|
||||
switch (usage) {
|
||||
case LOCAL_GL_STREAM_DRAW:
|
||||
|
@ -92,21 +92,19 @@ ValidateBufferUsageEnum(WebGLContext* webgl, const char* funcName, GLenum usage)
|
|||
break;
|
||||
}
|
||||
|
||||
webgl->ErrorInvalidEnum("%s: Invalid `usage`: 0x%04x", funcName, usage);
|
||||
webgl->ErrorInvalidEnumInfo("usage", usage);
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
WebGLBuffer::BufferData(GLenum target, size_t size, const void* data, GLenum usage)
|
||||
{
|
||||
const char funcName[] = "bufferData";
|
||||
|
||||
// Careful: data.Length() could conceivably be any uint32_t, but GLsizeiptr
|
||||
// is like intptr_t.
|
||||
if (!CheckedInt<GLsizeiptr>(size).isValid())
|
||||
return mContext->ErrorOutOfMemory("%s: bad size", funcName);
|
||||
return mContext->ErrorOutOfMemory("bad size");
|
||||
|
||||
if (!ValidateBufferUsageEnum(mContext, funcName, usage))
|
||||
if (!ValidateBufferUsageEnum(mContext, usage))
|
||||
return;
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
|
@ -114,7 +112,7 @@ WebGLBuffer::BufferData(GLenum target, size_t size, const void* data, GLenum usa
|
|||
if (mContext->gl->WorkAroundDriverBugs() &&
|
||||
size > INT32_MAX)
|
||||
{
|
||||
mContext->ErrorOutOfMemory("%s: Allocation size too large.", funcName);
|
||||
mContext->ErrorOutOfMemory("Allocation size too large.");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -127,7 +125,7 @@ WebGLBuffer::BufferData(GLenum target, size_t size, const void* data, GLenum usa
|
|||
{
|
||||
newIndexCache = malloc(size);
|
||||
if (!newIndexCache) {
|
||||
mContext->ErrorOutOfMemory("%s: Failed to alloc index cache.", funcName);
|
||||
mContext->ErrorOutOfMemory("Failed to alloc index cache.");
|
||||
return;
|
||||
}
|
||||
memcpy(newIndexCache.get(), data, size);
|
||||
|
@ -145,7 +143,7 @@ WebGLBuffer::BufferData(GLenum target, size_t size, const void* data, GLenum usa
|
|||
|
||||
if (error) {
|
||||
MOZ_ASSERT(error == LOCAL_GL_OUT_OF_MEMORY);
|
||||
mContext->ErrorOutOfMemory("%s: Error from driver: 0x%04x", funcName, error);
|
||||
mContext->ErrorOutOfMemory("Error from driver: 0x%04x", error);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -174,13 +172,11 @@ void
|
|||
WebGLBuffer::BufferSubData(GLenum target, size_t dstByteOffset, size_t dataLen,
|
||||
const void* data) const
|
||||
{
|
||||
const char funcName[] = "bufferSubData";
|
||||
|
||||
if (!ValidateRange(funcName, dstByteOffset, dataLen))
|
||||
if (!ValidateRange(dstByteOffset, dataLen))
|
||||
return;
|
||||
|
||||
if (!CheckedInt<GLintptr>(dataLen).isValid())
|
||||
return mContext->ErrorOutOfMemory("%s: Size too large.", funcName);
|
||||
return mContext->ErrorOutOfMemory("Size too large.");
|
||||
|
||||
////
|
||||
|
||||
|
@ -204,18 +200,17 @@ WebGLBuffer::BufferSubData(GLenum target, size_t dstByteOffset, size_t dataLen,
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLBuffer::ValidateRange(const char* funcName, size_t byteOffset, size_t byteLen) const
|
||||
WebGLBuffer::ValidateRange(size_t byteOffset, size_t byteLen) const
|
||||
{
|
||||
auto availLength = mByteLength;
|
||||
if (byteOffset > availLength) {
|
||||
mContext->ErrorInvalidValue("%s: Offset passes the end of the buffer.", funcName);
|
||||
mContext->ErrorInvalidValue("Offset passes the end of the buffer.");
|
||||
return false;
|
||||
}
|
||||
availLength -= byteOffset;
|
||||
|
||||
if (byteLen > availLength) {
|
||||
mContext->ErrorInvalidValue("%s: Offset+size passes the end of the buffer.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidValue("Offset+size passes the end of the buffer.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -361,7 +356,7 @@ WebGLBuffer::GetIndexedFetchMaxVert(const GLenum type, const uint64_t byteOffset
|
|||
////
|
||||
|
||||
bool
|
||||
WebGLBuffer::ValidateCanBindToTarget(const char* funcName, GLenum target)
|
||||
WebGLBuffer::ValidateCanBindToTarget(GLenum target)
|
||||
{
|
||||
/* https://www.khronos.org/registry/webgl/specs/latest/2.0/#5.1
|
||||
*
|
||||
|
@ -408,7 +403,7 @@ WebGLBuffer::ValidateCanBindToTarget(const char* funcName, GLenum target)
|
|||
|
||||
const auto dataType = (mContent == WebGLBuffer::Kind::OtherData) ? "other"
|
||||
: "element";
|
||||
mContext->ErrorInvalidOperation("%s: Buffer already contains %s data.", funcName,
|
||||
mContext->ErrorInvalidOperation("Buffer already contains %s data.",
|
||||
dataType);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
|
||||
Maybe<uint32_t> GetIndexedFetchMaxVert(GLenum type, uint64_t byteOffset,
|
||||
uint32_t indexCount) const;
|
||||
bool ValidateRange(const char* funcName, size_t byteOffset, size_t byteLen) const;
|
||||
bool ValidateRange(size_t byteOffset, size_t byteLen) const;
|
||||
|
||||
WebGLContext* GetParentObject() const {
|
||||
return mContext;
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
|
||||
|
||||
bool ValidateCanBindToTarget(const char* funcName, GLenum target);
|
||||
bool ValidateCanBindToTarget(GLenum target);
|
||||
void BufferData(GLenum target, size_t size, const void* data, GLenum usage);
|
||||
void BufferSubData(GLenum target, size_t dstByteOffset, size_t dataLen,
|
||||
const void* data) const;
|
||||
|
|
|
@ -165,7 +165,6 @@ WebGLContext::WebGLContext()
|
|||
|
||||
mAllowContextRestore = true;
|
||||
mLastLossWasSimulated = false;
|
||||
mContextStatus = ContextNotLost;
|
||||
mLoseContextOnMemoryPressure = false;
|
||||
mCanLoseContextInForeground = true;
|
||||
mRestoreWhenVisible = false;
|
||||
|
@ -329,9 +328,8 @@ WebGLContext::Invalidate()
|
|||
void
|
||||
WebGLContext::OnVisibilityChange()
|
||||
{
|
||||
if (!IsContextLost()) {
|
||||
if (gl) // Context not lost.
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mRestoreWhenVisible || mLastLossWasSimulated) {
|
||||
return;
|
||||
|
@ -661,7 +659,7 @@ WebGLContext::CreateAndInitGL(bool forceEnabled,
|
|||
// Fallback for resizes:
|
||||
|
||||
bool
|
||||
WebGLContext::EnsureDefaultFB(const char* const funcName)
|
||||
WebGLContext::EnsureDefaultFB()
|
||||
{
|
||||
if (mDefaultFB) {
|
||||
MOZ_ASSERT(mDefaultFB->mSize == mRequestedSize);
|
||||
|
@ -698,7 +696,7 @@ WebGLContext::EnsureDefaultFB(const char* const funcName)
|
|||
}
|
||||
|
||||
if (!mDefaultFB) {
|
||||
GenerateWarning("%s: Backbuffer resize failed. Losing context.", funcName);
|
||||
GenerateWarning("Backbuffer resize failed. Losing context.");
|
||||
ForceLoseContext();
|
||||
return false;
|
||||
}
|
||||
|
@ -747,6 +745,9 @@ WebGLContext::ThrowEvent_WebGLContextCreationError(const nsACString& text)
|
|||
NS_IMETHODIMP
|
||||
WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight)
|
||||
{
|
||||
const FuncScope funcScope(*this, "<SetDimensions>");
|
||||
(void)IsContextLost(); // We handle this ourselves.
|
||||
|
||||
if (signedWidth < 0 || signedHeight < 0) {
|
||||
if (!gl) {
|
||||
Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_FAILURE_ID,
|
||||
|
@ -923,7 +924,7 @@ WebGLContext::SetDimensions(int32_t signedWidth, int32_t signedHeight)
|
|||
|
||||
MOZ_ASSERT(!mDefaultFB);
|
||||
mRequestedSize = {width, height};
|
||||
if (!EnsureDefaultFB("context initialization")) {
|
||||
if (!EnsureDefaultFB()) {
|
||||
MOZ_ASSERT(!gl);
|
||||
|
||||
failureId = NS_LITERAL_CSTRING("FEATURE_FAILURE_WEBGL_BACKBUFFER");
|
||||
|
@ -1041,7 +1042,7 @@ WebGLContext::LoseOldestWebGLContextIfLimitExceeded()
|
|||
if (contexts[i] == this)
|
||||
continue;
|
||||
|
||||
if (contexts[i]->IsContextLost())
|
||||
if (!contexts[i]->gl)
|
||||
continue;
|
||||
|
||||
if (!contexts[i]->GetCanvas()) {
|
||||
|
@ -1231,6 +1232,7 @@ bool
|
|||
WebGLContext::InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder,
|
||||
CanvasRenderer* aRenderer)
|
||||
{
|
||||
const FuncScope funcScope(*this, "<InitializeCanvasRenderer>");
|
||||
if (IsContextLost())
|
||||
return false;
|
||||
|
||||
|
@ -1255,7 +1257,7 @@ WebGLContext::InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder,
|
|||
}
|
||||
|
||||
data.mGLContext = gl;
|
||||
data.mSize = DrawingBufferSize("InitializeCanvasRenderer");
|
||||
data.mSize = DrawingBufferSize();
|
||||
data.mHasAlpha = mOptions.alpha;
|
||||
data.mIsGLAlphaPremult = IsPremultAlpha() || !data.mHasAlpha;
|
||||
|
||||
|
@ -1316,6 +1318,7 @@ void
|
|||
WebGLContext::GetContextAttributes(dom::Nullable<dom::WebGLContextAttributes>& retval)
|
||||
{
|
||||
retval.SetNull();
|
||||
const FuncScope funcScope(*this, "getContextAttributes");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
|
@ -1459,13 +1462,14 @@ WebGLContext::BlitBackbufferToCurDriverFB() const
|
|||
bool
|
||||
WebGLContext::PresentScreenBuffer()
|
||||
{
|
||||
const FuncScope funcScope(*this, "<PresentScreenBuffer>");
|
||||
if (IsContextLost())
|
||||
return false;
|
||||
|
||||
if (!mShouldPresent)
|
||||
return false;
|
||||
|
||||
if (!ValidateAndInitFB("Present", nullptr))
|
||||
if (!ValidateAndInitFB(nullptr))
|
||||
return false;
|
||||
|
||||
const auto& screen = gl->Screen();
|
||||
|
@ -1530,16 +1534,14 @@ WebGLContext::EndComposition()
|
|||
}
|
||||
|
||||
void
|
||||
WebGLContext::DummyReadFramebufferOperation(const char* funcName)
|
||||
WebGLContext::DummyReadFramebufferOperation()
|
||||
{
|
||||
if (!mBoundReadFramebuffer)
|
||||
return; // Infallible.
|
||||
|
||||
const auto status = mBoundReadFramebuffer->CheckFramebufferStatus(funcName);
|
||||
|
||||
const auto status = mBoundReadFramebuffer->CheckFramebufferStatus();
|
||||
if (status != LOCAL_GL_FRAMEBUFFER_COMPLETE) {
|
||||
ErrorInvalidFramebufferOperation("%s: Framebuffer must be complete.",
|
||||
funcName);
|
||||
ErrorInvalidFramebufferOperation("Framebuffer must be complete.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1675,7 +1677,7 @@ WebGLContext::UpdateContextLossStatus()
|
|||
// this timer event. In this case, there's nothing to do here, just don't crash.
|
||||
return;
|
||||
}
|
||||
if (mContextStatus == ContextNotLost) {
|
||||
if (mContextStatus == ContextStatus::NotLost) {
|
||||
// We don't know that we're lost, but we might be, so we need to
|
||||
// check. If we're guilty, don't allow restores, though.
|
||||
|
||||
|
@ -1693,7 +1695,7 @@ WebGLContext::UpdateContextLossStatus()
|
|||
// Fall through.
|
||||
}
|
||||
|
||||
if (mContextStatus == ContextLostAwaitingEvent) {
|
||||
if (mContextStatus == ContextStatus::LostAwaitingEvent) {
|
||||
// The context has been lost and we haven't yet triggered the
|
||||
// callback, so do that now.
|
||||
const auto kEventName = NS_LITERAL_STRING("webglcontextlost");
|
||||
|
@ -1720,7 +1722,7 @@ WebGLContext::UpdateContextLossStatus()
|
|||
}
|
||||
|
||||
// We sent the callback, so we're just 'regular lost' now.
|
||||
mContextStatus = ContextLost;
|
||||
mContextStatus = ContextStatus::Lost;
|
||||
// If we're told to use the default handler, it means the script
|
||||
// didn't bother to handle the event. In this case, we shouldn't
|
||||
// auto-restore the context.
|
||||
|
@ -1730,7 +1732,7 @@ WebGLContext::UpdateContextLossStatus()
|
|||
// Fall through.
|
||||
}
|
||||
|
||||
if (mContextStatus == ContextLost) {
|
||||
if (mContextStatus == ContextStatus::Lost) {
|
||||
// Context is lost, and we've already sent the callback. We
|
||||
// should try to restore the context if we're both allowed to,
|
||||
// and supposed to.
|
||||
|
@ -1752,13 +1754,13 @@ WebGLContext::UpdateContextLossStatus()
|
|||
return;
|
||||
}
|
||||
|
||||
if (mContextStatus == ContextLostAwaitingRestore) {
|
||||
if (mContextStatus == ContextStatus::LostAwaitingRestore) {
|
||||
// Context is lost, but we should try to restore it.
|
||||
|
||||
if (!mAllowContextRestore) {
|
||||
// We might decide this after thinking we'd be OK restoring
|
||||
// the context, so downgrade.
|
||||
mContextStatus = ContextLost;
|
||||
mContextStatus = ContextStatus::Lost;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1769,7 +1771,7 @@ WebGLContext::UpdateContextLossStatus()
|
|||
}
|
||||
|
||||
// Revival!
|
||||
mContextStatus = ContextNotLost;
|
||||
mContextStatus = ContextStatus::NotLost;
|
||||
|
||||
if (mCanvasElement) {
|
||||
nsContentUtils::DispatchTrustedEvent(
|
||||
|
@ -1796,8 +1798,8 @@ void
|
|||
WebGLContext::ForceLoseContext(bool simulateLosing)
|
||||
{
|
||||
printf_stderr("WebGL(%p)::ForceLoseContext\n", this);
|
||||
MOZ_ASSERT(!IsContextLost());
|
||||
mContextStatus = ContextLostAwaitingEvent;
|
||||
MOZ_ASSERT(gl);
|
||||
mContextStatus = ContextStatus::LostAwaitingEvent;
|
||||
mContextLostErrorSet = false;
|
||||
|
||||
// Burn it all!
|
||||
|
@ -1812,7 +1814,7 @@ void
|
|||
WebGLContext::ForceRestoreContext()
|
||||
{
|
||||
printf_stderr("WebGL(%p)::ForceRestoreContext\n", this);
|
||||
mContextStatus = ContextLostAwaitingRestore;
|
||||
mContextStatus = ContextStatus::LostAwaitingRestore;
|
||||
mAllowContextRestore = true; // Hey, you did say 'force'.
|
||||
|
||||
// Queue up a task, since we know the status changed.
|
||||
|
@ -1822,10 +1824,11 @@ WebGLContext::ForceRestoreContext()
|
|||
already_AddRefed<mozilla::gfx::SourceSurface>
|
||||
WebGLContext::GetSurfaceSnapshot(gfxAlphaType* const out_alphaType)
|
||||
{
|
||||
if (!gl)
|
||||
const FuncScope funcScope(*this, "<GetSurfaceSnapshot>");
|
||||
if (IsContextLost())
|
||||
return nullptr;
|
||||
|
||||
if (!BindDefaultFBForRead("GetSurfaceSnapshot"))
|
||||
if (!BindDefaultFBForRead())
|
||||
return nullptr;
|
||||
|
||||
const auto surfFormat = mOptions.alpha ? SurfaceFormat::B8G8R8A8
|
||||
|
@ -1882,26 +1885,25 @@ WebGLContext::DidRefresh()
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
gfx::IntSize
|
||||
WebGLContext::DrawingBufferSize(const char* const funcName)
|
||||
WebGLContext::DrawingBufferSize()
|
||||
{
|
||||
const gfx::IntSize zeros{0, 0};
|
||||
if (IsContextLost())
|
||||
return zeros;
|
||||
|
||||
if (!EnsureDefaultFB(funcName))
|
||||
if (!EnsureDefaultFB())
|
||||
return zeros;
|
||||
|
||||
return mDefaultFB->mSize;
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateAndInitFB(const char* const funcName,
|
||||
const WebGLFramebuffer* const fb)
|
||||
WebGLContext::ValidateAndInitFB(const WebGLFramebuffer* const fb)
|
||||
{
|
||||
if (fb)
|
||||
return fb->ValidateAndInitAttachments(funcName);
|
||||
return fb->ValidateAndInitAttachments();
|
||||
|
||||
if (!EnsureDefaultFB(funcName))
|
||||
if (!EnsureDefaultFB())
|
||||
return false;
|
||||
|
||||
if (mDefaultFB_IsInvalid) {
|
||||
|
@ -1924,10 +1926,10 @@ WebGLContext::DoBindFB(const WebGLFramebuffer* const fb, const GLenum target) co
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLContext::BindCurFBForDraw(const char* const funcName)
|
||||
WebGLContext::BindCurFBForDraw()
|
||||
{
|
||||
const auto& fb = mBoundDrawFramebuffer;
|
||||
if (!ValidateAndInitFB(funcName, fb))
|
||||
if (!ValidateAndInitFB(fb))
|
||||
return false;
|
||||
|
||||
DoBindFB(fb);
|
||||
|
@ -1935,30 +1937,27 @@ WebGLContext::BindCurFBForDraw(const char* const funcName)
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLContext::BindCurFBForColorRead(const char* const funcName,
|
||||
const webgl::FormatUsageInfo** const out_format,
|
||||
WebGLContext::BindCurFBForColorRead(const webgl::FormatUsageInfo** const out_format,
|
||||
uint32_t* const out_width,
|
||||
uint32_t* const out_height)
|
||||
{
|
||||
const auto& fb = mBoundReadFramebuffer;
|
||||
|
||||
if (fb) {
|
||||
if (!ValidateAndInitFB(funcName, fb))
|
||||
if (!ValidateAndInitFB(fb))
|
||||
return false;
|
||||
if (!fb->ValidateForColorRead(funcName, out_format, out_width, out_height))
|
||||
if (!fb->ValidateForColorRead(out_format, out_width, out_height))
|
||||
return false;
|
||||
|
||||
gl->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, fb->mGLName);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!BindDefaultFBForRead(funcName))
|
||||
if (!BindDefaultFBForRead())
|
||||
return false;
|
||||
|
||||
if (mDefaultFB_ReadBuffer == LOCAL_GL_NONE) {
|
||||
ErrorInvalidOperation("%s: Can't read from backbuffer when readBuffer mode is"
|
||||
" NONE.",
|
||||
funcName);
|
||||
ErrorInvalidOperation("Can't read from backbuffer when readBuffer mode is NONE.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1974,9 +1973,9 @@ WebGLContext::BindCurFBForColorRead(const char* const funcName,
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLContext::BindDefaultFBForRead(const char* const funcName)
|
||||
WebGLContext::BindDefaultFBForRead()
|
||||
{
|
||||
if (!ValidateAndInitFB(funcName, nullptr))
|
||||
if (!ValidateAndInitFB(nullptr))
|
||||
return false;
|
||||
|
||||
if (!mDefaultFB->mSamples) {
|
||||
|
@ -1987,7 +1986,7 @@ WebGLContext::BindDefaultFBForRead(const char* const funcName)
|
|||
if (!mResolvedDefaultFB) {
|
||||
mResolvedDefaultFB = MozFramebuffer::Create(gl, mDefaultFB->mSize, 0, false);
|
||||
if (!mResolvedDefaultFB) {
|
||||
gfxCriticalNote << funcName << ": Failed to create mResolvedDefaultFB.";
|
||||
gfxCriticalNote << FuncName() << ": Failed to create mResolvedDefaultFB.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -2299,9 +2298,8 @@ WebGLContext::GetUnpackSize(bool isFunc3D, uint32_t width, uint32_t height,
|
|||
already_AddRefed<layers::SharedSurfaceTextureClient>
|
||||
WebGLContext::GetVRFrame()
|
||||
{
|
||||
if (IsContextLost()) {
|
||||
ForceRestoreContext();
|
||||
}
|
||||
if (!gl)
|
||||
return nullptr;
|
||||
|
||||
int frameId = gfx::impl::VRDisplayExternal::sPushIndex;
|
||||
static int lastFrameId = -1;
|
||||
|
@ -2317,7 +2315,7 @@ WebGLContext::GetVRFrame()
|
|||
EndComposition();
|
||||
}
|
||||
|
||||
if (IsContextLost()) {
|
||||
if (!gl) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -2334,7 +2332,7 @@ WebGLContext::GetVRFrame()
|
|||
/**
|
||||
* Make sure that the WebGL buffer is committed to the attached SurfaceTexture on Android.
|
||||
*/
|
||||
if (!ignoreFrame && !IsContextLost()) {
|
||||
if (!ignoreFrame) {
|
||||
sharedSurface->Surf()->ProducerAcquire();
|
||||
sharedSurface->Surf()->Commit();
|
||||
sharedSurface->Surf()->ProducerRelease();
|
||||
|
@ -2354,7 +2352,7 @@ WebGLContext::GetVRFrame()
|
|||
BeginComposition();
|
||||
EndComposition();
|
||||
|
||||
if (IsContextLost())
|
||||
if (!gl)
|
||||
return nullptr;
|
||||
|
||||
gl::GLScreenBuffer* screen = gl->Screen();
|
||||
|
@ -2383,8 +2381,7 @@ SizeOfViewElem(const dom::ArrayBufferView& view)
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateArrayBufferView(const char* funcName,
|
||||
const dom::ArrayBufferView& view, GLuint elemOffset,
|
||||
WebGLContext::ValidateArrayBufferView(const dom::ArrayBufferView& view, GLuint elemOffset,
|
||||
GLuint elemCountOverride, uint8_t** const out_bytes,
|
||||
size_t* const out_byteLen)
|
||||
{
|
||||
|
@ -2396,14 +2393,14 @@ WebGLContext::ValidateArrayBufferView(const char* funcName,
|
|||
|
||||
size_t elemCount = byteLen / elemSize;
|
||||
if (elemOffset > elemCount) {
|
||||
ErrorInvalidValue("%s: Invalid offset into ArrayBufferView.", funcName);
|
||||
ErrorInvalidValue("Invalid offset into ArrayBufferView.");
|
||||
return false;
|
||||
}
|
||||
elemCount -= elemOffset;
|
||||
|
||||
if (elemCountOverride) {
|
||||
if (elemCountOverride > elemCount) {
|
||||
ErrorInvalidValue("%s: Invalid sub-length for ArrayBufferView.", funcName);
|
||||
ErrorInvalidValue("Invalid sub-length for ArrayBufferView.");
|
||||
return false;
|
||||
}
|
||||
elemCount = elemCountOverride;
|
||||
|
@ -2430,6 +2427,90 @@ WebGLContext::UpdateMaxDrawBuffers()
|
|||
|
||||
// --
|
||||
|
||||
const char*
|
||||
WebGLContext::FuncName() const
|
||||
{
|
||||
const char* ret;
|
||||
if (MOZ_LIKELY( mFuncScope )) {
|
||||
ret = mFuncScope->mFuncName;
|
||||
} else {
|
||||
MOZ_ASSERT(false);
|
||||
ret = "<funcName unknown>";
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// -
|
||||
|
||||
WebGLContext::FuncScope::FuncScope(const WebGLContext& webgl, const char* const funcName)
|
||||
: mWebGL(webgl)
|
||||
, mFuncName(bool(mWebGL.mFuncScope) ? nullptr : funcName)
|
||||
{
|
||||
if (MOZ_UNLIKELY( !mFuncName )) {
|
||||
#ifdef DEBUG
|
||||
mStillNeedsToCheckContextLost = false;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
mWebGL.mFuncScope = this;
|
||||
}
|
||||
|
||||
WebGLContext::FuncScope::~FuncScope()
|
||||
{
|
||||
if (MOZ_UNLIKELY( !mFuncName ))
|
||||
return;
|
||||
|
||||
MOZ_ASSERT(!mStillNeedsToCheckContextLost);
|
||||
mWebGL.mFuncScope = nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::IsContextLost() const
|
||||
{
|
||||
if (MOZ_LIKELY( mFuncScope )) {
|
||||
mFuncScope->OnCheckContextLost();
|
||||
}
|
||||
return mContextStatus != ContextStatus::NotLost;
|
||||
}
|
||||
|
||||
// --
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateIsObject(const WebGLDeletableObject* const object) const
|
||||
{
|
||||
if (IsContextLost())
|
||||
return false;
|
||||
|
||||
if (!object)
|
||||
return false;
|
||||
|
||||
if (!object->IsCompatibleWithContext(this))
|
||||
return false;
|
||||
|
||||
return !object->IsDeleted();
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateDeleteObject(const WebGLDeletableObject* const object)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return false;
|
||||
|
||||
if (!object)
|
||||
return false;
|
||||
|
||||
if (!ValidateObjectAllowDeleted("obj", *object))
|
||||
return false;
|
||||
|
||||
if (object->IsDeleteRequested())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// --
|
||||
|
||||
webgl::AvailabilityRunnable*
|
||||
WebGLContext::EnsureAvailabilityRunnable()
|
||||
{
|
||||
|
|
|
@ -305,7 +305,7 @@ class WebGLContext
|
|||
friend struct webgl::UniformBlockInfo;
|
||||
|
||||
friend const webgl::CachedDrawFetchLimits*
|
||||
ValidateDraw(WebGLContext*, const char*, GLenum, uint32_t);
|
||||
ValidateDraw(WebGLContext*, GLenum, uint32_t);
|
||||
|
||||
enum {
|
||||
UNPACK_FLIP_Y_WEBGL = 0x9240,
|
||||
|
@ -327,6 +327,11 @@ class WebGLContext
|
|||
uint64_t mNextFenceId = 1;
|
||||
uint64_t mCompletedFenceId = 0;
|
||||
|
||||
public:
|
||||
class FuncScope;
|
||||
private:
|
||||
mutable FuncScope* mFuncScope = nullptr;
|
||||
|
||||
public:
|
||||
WebGLContext();
|
||||
|
||||
|
@ -345,8 +350,8 @@ public:
|
|||
virtual void OnMemoryPressure() override;
|
||||
|
||||
// nsICanvasRenderingContextInternal
|
||||
virtual int32_t GetWidth() override { return DrawingBufferWidth("get width"); }
|
||||
virtual int32_t GetHeight() override { return DrawingBufferHeight("get height"); }
|
||||
virtual int32_t GetWidth() override { return DrawingBufferWidth(); }
|
||||
virtual int32_t GetHeight() override { return DrawingBufferHeight(); }
|
||||
|
||||
NS_IMETHOD SetDimensions(int32_t width, int32_t height) override;
|
||||
NS_IMETHOD InitializeWithDrawTarget(nsIDocShell*,
|
||||
|
@ -389,6 +394,31 @@ public:
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
// -
|
||||
|
||||
const auto& CurFuncScope() const { return *mFuncScope; }
|
||||
const char* FuncName() const;
|
||||
|
||||
class FuncScope final {
|
||||
public:
|
||||
const WebGLContext& mWebGL;
|
||||
const char* const mFuncName;
|
||||
private:
|
||||
#ifdef DEBUG
|
||||
mutable bool mStillNeedsToCheckContextLost = true;
|
||||
#endif
|
||||
|
||||
public:
|
||||
FuncScope(const WebGLContext& webgl, const char* funcName);
|
||||
~FuncScope();
|
||||
|
||||
void OnCheckContextLost() const {
|
||||
#ifdef DEBUG
|
||||
mStillNeedsToCheckContextLost = false;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
void SynthesizeGLError(GLenum err) const;
|
||||
void SynthesizeGLError(GLenum err, const char* fmt, ...) const MOZ_FORMAT_PRINTF(3, 4);
|
||||
|
||||
|
@ -397,12 +427,10 @@ public:
|
|||
void ErrorInvalidValue(const char* fmt = 0, ...) const MOZ_FORMAT_PRINTF(2, 3);
|
||||
void ErrorInvalidFramebufferOperation(const char* fmt = 0, ...) const MOZ_FORMAT_PRINTF(2, 3);
|
||||
void ErrorInvalidEnumInfo(const char* info, GLenum enumValue) const;
|
||||
void ErrorInvalidEnumInfo(const char* info, const char* funcName,
|
||||
GLenum enumValue) const;
|
||||
void ErrorOutOfMemory(const char* fmt = 0, ...) const MOZ_FORMAT_PRINTF(2, 3);
|
||||
void ErrorImplementationBug(const char* fmt = 0, ...) const MOZ_FORMAT_PRINTF(2, 3);
|
||||
|
||||
void ErrorInvalidEnumArg(const char* funcName, const char* argName, GLenum val) const;
|
||||
void ErrorInvalidEnumArg(const char* argName, GLenum val) const;
|
||||
|
||||
static const char* ErrorName(GLenum error);
|
||||
|
||||
|
@ -414,7 +442,7 @@ public:
|
|||
*/
|
||||
static void EnumName(GLenum val, nsCString* out_name);
|
||||
|
||||
void DummyReadFramebufferOperation(const char* funcName);
|
||||
void DummyReadFramebufferOperation();
|
||||
|
||||
WebGLTexture* ActiveBoundTextureForTarget(const TexTarget texTarget) const {
|
||||
switch (texTarget.get()) {
|
||||
|
@ -504,13 +532,15 @@ public:
|
|||
void Commit();
|
||||
void GetCanvas(dom::Nullable<dom::OwningHTMLCanvasElementOrOffscreenCanvas>& retval);
|
||||
private:
|
||||
gfx::IntSize DrawingBufferSize(const char* funcName);
|
||||
gfx::IntSize DrawingBufferSize();
|
||||
public:
|
||||
GLsizei DrawingBufferWidth(const char* const funcName = "drawingBufferWidth") {
|
||||
return DrawingBufferSize(funcName).width;
|
||||
GLsizei DrawingBufferWidth() {
|
||||
const FuncScope funcScope(*this, "drawingBufferWidth");
|
||||
return DrawingBufferSize().width;
|
||||
}
|
||||
GLsizei DrawingBufferHeight(const char* const funcName = "drawingBufferHeight") {
|
||||
return DrawingBufferSize(funcName).height;
|
||||
GLsizei DrawingBufferHeight() {
|
||||
const FuncScope funcScope(*this, "drawingBufferHeight");
|
||||
return DrawingBufferSize().height;
|
||||
}
|
||||
|
||||
layers::LayersBackend GetCompositorBackendType() const;
|
||||
|
@ -518,7 +548,9 @@ public:
|
|||
void
|
||||
GetContextAttributes(dom::Nullable<dom::WebGLContextAttributes>& retval);
|
||||
|
||||
bool IsContextLost() const { return mContextStatus != ContextNotLost; }
|
||||
// This is the entrypoint. Don't test against it directly.
|
||||
bool IsContextLost() const;
|
||||
|
||||
void GetSupportedExtensions(dom::Nullable< nsTArray<nsString> >& retval,
|
||||
dom::CallerType callerType);
|
||||
void GetExtension(JSContext* cx, const nsAString& name,
|
||||
|
@ -649,11 +681,15 @@ public:
|
|||
GetUniformLocation(const WebGLProgram& prog, const nsAString& name);
|
||||
|
||||
void Hint(GLenum target, GLenum mode);
|
||||
bool IsFramebuffer(const WebGLFramebuffer* fb);
|
||||
bool IsProgram(const WebGLProgram* prog);
|
||||
bool IsRenderbuffer(const WebGLRenderbuffer* rb);
|
||||
bool IsShader(const WebGLShader* shader);
|
||||
bool IsVertexArray(const WebGLVertexArray* vao);
|
||||
|
||||
bool IsBuffer(const WebGLBuffer* obj);
|
||||
bool IsFramebuffer(const WebGLFramebuffer* obj);
|
||||
bool IsProgram(const WebGLProgram* obj);
|
||||
bool IsRenderbuffer(const WebGLRenderbuffer* obj);
|
||||
bool IsShader(const WebGLShader* obj);
|
||||
bool IsTexture(const WebGLTexture* obj);
|
||||
bool IsVertexArray(const WebGLVertexArray* obj);
|
||||
|
||||
void LineWidth(GLfloat width);
|
||||
void LinkProgram(WebGLProgram& prog);
|
||||
void PixelStorei(GLenum pname, GLint param);
|
||||
|
@ -680,11 +716,9 @@ public:
|
|||
GLenum type, const dom::Nullable<dom::ArrayBufferView>& maybeView,
|
||||
dom::CallerType aCallerType, ErrorResult& rv)
|
||||
{
|
||||
const char funcName[] = "readPixels";
|
||||
if (maybeView.IsNull()) {
|
||||
ErrorInvalidValue("%s: `pixels` must not be null.", funcName);
|
||||
const FuncScope funcScope(*this, "readPixels");
|
||||
if (!ValidateNonNull("pixels", maybeView))
|
||||
return;
|
||||
}
|
||||
ReadPixels(x, y, width, height, format, type, maybeView.Value(), 0,
|
||||
aCallerType, rv);
|
||||
}
|
||||
|
@ -700,10 +734,13 @@ public:
|
|||
////
|
||||
|
||||
void RenderbufferStorage(GLenum target, GLenum internalFormat,
|
||||
GLsizei width, GLsizei height);
|
||||
GLsizei width, GLsizei height)
|
||||
{
|
||||
const FuncScope funcScope(*this, "renderbufferStorage");
|
||||
RenderbufferStorage_base(target, 0, internalFormat, width, height);
|
||||
}
|
||||
protected:
|
||||
void RenderbufferStorage_base(const char* funcName, GLenum target,
|
||||
GLsizei samples, GLenum internalformat,
|
||||
void RenderbufferStorage_base(GLenum target, GLsizei samples, GLenum internalformat,
|
||||
GLsizei width, GLsizei height);
|
||||
public:
|
||||
void SampleCoverage(GLclampf value, WebGLboolean invert);
|
||||
|
@ -892,14 +929,13 @@ public:
|
|||
|
||||
void UseProgram(WebGLProgram* prog);
|
||||
|
||||
bool ValidateAttribArraySetter(const char* name, uint32_t count,
|
||||
uint32_t arrayLength);
|
||||
bool ValidateUniformLocation(WebGLUniformLocation* loc, const char* funcName);
|
||||
bool ValidateAttribArraySetter(uint32_t count, uint32_t arrayLength);
|
||||
bool ValidateUniformLocation(WebGLUniformLocation* loc);
|
||||
bool ValidateUniformSetter(WebGLUniformLocation* loc, uint8_t setterSize,
|
||||
GLenum setterType, const char* funcName);
|
||||
GLenum setterType);
|
||||
bool ValidateUniformArraySetter(WebGLUniformLocation* loc,
|
||||
uint8_t setterElemSize, GLenum setterType,
|
||||
uint32_t setterArraySize, const char* funcName,
|
||||
uint32_t setterArraySize,
|
||||
uint32_t* out_numElementsToUpload);
|
||||
bool ValidateUniformMatrixArraySetter(WebGLUniformLocation* loc,
|
||||
uint8_t setterCols,
|
||||
|
@ -907,7 +943,6 @@ public:
|
|||
GLenum setterType,
|
||||
uint32_t setterArraySize,
|
||||
bool setterTranspose,
|
||||
const char* funcName,
|
||||
uint32_t* out_numElementsToUpload);
|
||||
void ValidateProgram(const WebGLProgram& prog);
|
||||
bool ValidateUniformLocation(const char* info, WebGLUniformLocation* loc);
|
||||
|
@ -952,7 +987,6 @@ public:
|
|||
|
||||
already_AddRefed<WebGLBuffer> CreateBuffer();
|
||||
void DeleteBuffer(WebGLBuffer* buf);
|
||||
bool IsBuffer(WebGLBuffer* buf);
|
||||
|
||||
protected:
|
||||
// bound buffer state
|
||||
|
@ -978,18 +1012,18 @@ protected:
|
|||
WebGLRefPtr<WebGLQuery> mQuerySlot_TimeElapsed;
|
||||
|
||||
WebGLRefPtr<WebGLQuery>*
|
||||
ValidateQuerySlotByTarget(const char* funcName, GLenum target);
|
||||
ValidateQuerySlotByTarget(GLenum target);
|
||||
|
||||
public:
|
||||
already_AddRefed<WebGLQuery> CreateQuery(const char* funcName = nullptr);
|
||||
void DeleteQuery(WebGLQuery* query, const char* funcName = nullptr);
|
||||
bool IsQuery(const WebGLQuery* query, const char* funcName = nullptr);
|
||||
void BeginQuery(GLenum target, WebGLQuery& query, const char* funcName = nullptr);
|
||||
void EndQuery(GLenum target, const char* funcName = nullptr);
|
||||
already_AddRefed<WebGLQuery> CreateQuery();
|
||||
void DeleteQuery(WebGLQuery* query);
|
||||
bool IsQuery(const WebGLQuery* query);
|
||||
void BeginQuery(GLenum target, WebGLQuery& query);
|
||||
void EndQuery(GLenum target);
|
||||
void GetQuery(JSContext* cx, GLenum target, GLenum pname,
|
||||
JS::MutableHandleValue retval, const char* funcName = nullptr);
|
||||
JS::MutableHandleValue retval);
|
||||
void GetQueryParameter(JSContext* cx, const WebGLQuery& query, GLenum pname,
|
||||
JS::MutableHandleValue retval, const char* funcName = nullptr);
|
||||
JS::MutableHandleValue retval);
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -1021,7 +1055,7 @@ private:
|
|||
realGLboolean mStencilTestEnabled;
|
||||
GLenum mGenerateMipmapHint = 0;
|
||||
|
||||
bool ValidateCapabilityEnum(GLenum cap, const char* info);
|
||||
bool ValidateCapabilityEnum(GLenum cap);
|
||||
realGLboolean* GetStateTrackingSlot(GLenum cap);
|
||||
|
||||
// Allocation debugging variables
|
||||
|
@ -1052,8 +1086,6 @@ public:
|
|||
retval.set(GetTexParameter(texTarget, pname));
|
||||
}
|
||||
|
||||
bool IsTexture(WebGLTexture* tex);
|
||||
|
||||
void TexParameterf(GLenum texTarget, GLenum pname, GLfloat param) {
|
||||
TexParameter_base(texTarget, pname, FloatOrInt(param));
|
||||
}
|
||||
|
@ -1075,11 +1107,11 @@ public:
|
|||
GLsizei width, GLsizei height, GLint border,
|
||||
GLsizei imageSize, WebGLsizeiptr offset)
|
||||
{
|
||||
const char funcName[] = "compressedTexImage2D";
|
||||
const FuncScope funcScope(*this, "compressedTexImage2D");
|
||||
const uint8_t funcDims = 2;
|
||||
const GLsizei depth = 1;
|
||||
const TexImageSourceAdapter src(&offset, 0, 0);
|
||||
CompressedTexImage(funcName, funcDims, target, level, internalFormat, width,
|
||||
CompressedTexImage(funcDims, target, level, internalFormat, width,
|
||||
height, depth, border, src, Some(imageSize));
|
||||
}
|
||||
|
||||
|
@ -1089,11 +1121,11 @@ public:
|
|||
const T& anySrc, GLuint viewElemOffset = 0,
|
||||
GLuint viewElemLengthOverride = 0)
|
||||
{
|
||||
const char funcName[] = "compressedTexImage2D";
|
||||
const FuncScope funcScope(*this, "compressedTexImage2D");
|
||||
const uint8_t funcDims = 2;
|
||||
const GLsizei depth = 1;
|
||||
const TexImageSourceAdapter src(&anySrc, viewElemOffset, viewElemLengthOverride);
|
||||
CompressedTexImage(funcName, funcDims, target, level, internalFormat, width,
|
||||
CompressedTexImage(funcDims, target, level, internalFormat, width,
|
||||
height, depth, border, src, Nothing());
|
||||
}
|
||||
|
||||
|
@ -1101,12 +1133,12 @@ public:
|
|||
GLsizei width, GLsizei height, GLenum unpackFormat,
|
||||
GLsizei imageSize, WebGLsizeiptr offset)
|
||||
{
|
||||
const char funcName[] = "compressedTexSubImage2D";
|
||||
const FuncScope funcScope(*this, "compressedTexSubImage2D");
|
||||
const uint8_t funcDims = 2;
|
||||
const GLint zOffset = 0;
|
||||
const GLsizei depth = 1;
|
||||
const TexImageSourceAdapter src(&offset, 0, 0);
|
||||
CompressedTexSubImage(funcName, funcDims, target, level, xOffset, yOffset,
|
||||
CompressedTexSubImage(funcDims, target, level, xOffset, yOffset,
|
||||
zOffset, width, height, depth, unpackFormat, src, Some(imageSize));
|
||||
}
|
||||
|
||||
|
@ -1116,25 +1148,26 @@ public:
|
|||
const T& anySrc, GLuint viewElemOffset = 0,
|
||||
GLuint viewElemLengthOverride = 0)
|
||||
{
|
||||
const char funcName[] = "compressedTexSubImage2D";
|
||||
const FuncScope funcScope(*this, "compressedTexSubImage2D");
|
||||
const uint8_t funcDims = 2;
|
||||
const GLint zOffset = 0;
|
||||
const GLsizei depth = 1;
|
||||
const TexImageSourceAdapter src(&anySrc, viewElemOffset, viewElemLengthOverride);
|
||||
CompressedTexSubImage(funcName, funcDims, target, level, xOffset, yOffset,
|
||||
CompressedTexSubImage(funcDims, target, level, xOffset, yOffset,
|
||||
zOffset, width, height, depth, unpackFormat, src, Nothing());
|
||||
}
|
||||
|
||||
protected:
|
||||
void CompressedTexImage(const char* funcName, uint8_t funcDims, GLenum target,
|
||||
void CompressedTexImage(uint8_t funcDims, GLenum target,
|
||||
GLint level, GLenum internalFormat, GLsizei width,
|
||||
GLsizei height, GLsizei depth, GLint border,
|
||||
const TexImageSource& src, const Maybe<GLsizei>& expectedImageSize);
|
||||
void CompressedTexSubImage(const char* funcName, uint8_t funcDims, GLenum target,
|
||||
void CompressedTexSubImage(uint8_t funcDims, GLenum target,
|
||||
GLint level, GLint xOffset, GLint yOffset, GLint zOffset,
|
||||
GLsizei width, GLsizei height, GLsizei depth,
|
||||
GLenum unpackFormat, const TexImageSource& src,
|
||||
const Maybe<GLsizei>& expectedImageSize);
|
||||
|
||||
////////////////////////////////////
|
||||
|
||||
public:
|
||||
|
@ -1145,15 +1178,15 @@ public:
|
|||
GLint yOffset, GLint x, GLint y, GLsizei width,
|
||||
GLsizei height)
|
||||
{
|
||||
const char funcName[] = "copyTexSubImage2D";
|
||||
const FuncScope funcScope(*this, "copyTexSubImage2D");
|
||||
const uint8_t funcDims = 2;
|
||||
const GLint zOffset = 0;
|
||||
CopyTexSubImage(funcName, funcDims, target, level, xOffset, yOffset, zOffset,
|
||||
CopyTexSubImage(funcDims, target, level, xOffset, yOffset, zOffset,
|
||||
x, y, width, height);
|
||||
}
|
||||
|
||||
protected:
|
||||
void CopyTexSubImage(const char* funcName, uint8_t funcDims, GLenum target,
|
||||
void CopyTexSubImage(uint8_t funcDims, GLenum target,
|
||||
GLint level, GLint xOffset, GLint yOffset, GLint zOffset,
|
||||
GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
|
||||
|
@ -1213,14 +1246,14 @@ protected:
|
|||
GLsizei height, GLint border, GLenum unpackFormat,
|
||||
GLenum unpackType, const TexImageSource& src)
|
||||
{
|
||||
const char funcName[] = "texImage2D";
|
||||
const FuncScope funcScope(*this, "texImage2D");
|
||||
const uint8_t funcDims = 2;
|
||||
const GLsizei depth = 1;
|
||||
TexImage(funcName, funcDims, target, level, internalFormat, width, height, depth,
|
||||
TexImage(funcDims, target, level, internalFormat, width, height, depth,
|
||||
border, unpackFormat, unpackType, src);
|
||||
}
|
||||
|
||||
void TexImage(const char* funcName, uint8_t funcDims, GLenum target, GLint level,
|
||||
void TexImage(uint8_t funcDims, GLenum target, GLint level,
|
||||
GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth,
|
||||
GLint border, GLenum unpackFormat, GLenum unpackType,
|
||||
const TexImageSource& src);
|
||||
|
@ -1253,15 +1286,15 @@ protected:
|
|||
GLsizei width, GLsizei height, GLenum unpackFormat,
|
||||
GLenum unpackType, const TexImageSource& src)
|
||||
{
|
||||
const char funcName[] = "texSubImage2D";
|
||||
const FuncScope funcScope(*this, "texSubImage2D");
|
||||
const uint8_t funcDims = 2;
|
||||
const GLint zOffset = 0;
|
||||
const GLsizei depth = 1;
|
||||
TexSubImage(funcName, funcDims, target, level, xOffset, yOffset, zOffset, width,
|
||||
TexSubImage(funcDims, target, level, xOffset, yOffset, zOffset, width,
|
||||
height, depth, unpackFormat, unpackType, src);
|
||||
}
|
||||
|
||||
void TexSubImage(const char* funcName, uint8_t funcDims, GLenum target, GLint level,
|
||||
void TexSubImage(uint8_t funcDims, GLenum target, GLint level,
|
||||
GLint xOffset, GLint yOffset, GLint zOffset, GLsizei width,
|
||||
GLsizei height, GLsizei depth, GLenum unpackFormat,
|
||||
GLenum unpackType, const TexImageSource& src);
|
||||
|
@ -1270,35 +1303,35 @@ protected:
|
|||
// WebGLTextureUpload.cpp
|
||||
public:
|
||||
UniquePtr<webgl::TexUnpackBlob>
|
||||
From(const char* funcName, TexImageTarget target, GLsizei rawWidth, GLsizei rawHeight,
|
||||
From(TexImageTarget target, GLsizei rawWidth, GLsizei rawHeight,
|
||||
GLsizei rawDepth, GLint border, const TexImageSource& src,
|
||||
dom::Uint8ClampedArray* const scopedArr);
|
||||
|
||||
protected:
|
||||
bool ValidateTexImageSpecification(const char* funcName, uint8_t funcDims,
|
||||
bool ValidateTexImageSpecification(uint8_t funcDims,
|
||||
GLenum texImageTarget, GLint level,
|
||||
GLsizei width, GLsizei height, GLsizei depth,
|
||||
GLint border,
|
||||
TexImageTarget* const out_target,
|
||||
WebGLTexture** const out_texture,
|
||||
WebGLTexture::ImageInfo** const out_imageInfo);
|
||||
bool ValidateTexImageSelection(const char* funcName, uint8_t funcDims,
|
||||
bool ValidateTexImageSelection(uint8_t funcDims,
|
||||
GLenum texImageTarget, GLint level, GLint xOffset,
|
||||
GLint yOffset, GLint zOffset, GLsizei width,
|
||||
GLsizei height, GLsizei depth,
|
||||
TexImageTarget* const out_target,
|
||||
WebGLTexture** const out_texture,
|
||||
WebGLTexture::ImageInfo** const out_imageInfo);
|
||||
bool ValidateUnpackInfo(const char* funcName, bool usePBOs, GLenum format,
|
||||
bool ValidateUnpackInfo(bool usePBOs, GLenum format,
|
||||
GLenum type, webgl::PackingInfo* const out);
|
||||
|
||||
UniquePtr<webgl::TexUnpackBlob>
|
||||
FromDomElem(const char* funcName, TexImageTarget target, uint32_t width,
|
||||
FromDomElem(TexImageTarget target, uint32_t width,
|
||||
uint32_t height, uint32_t depth, const dom::Element& elem,
|
||||
ErrorResult* const out_error);
|
||||
|
||||
UniquePtr<webgl::TexUnpackBytes>
|
||||
FromCompressed(const char* funcName, TexImageTarget target, GLsizei rawWidth,
|
||||
FromCompressed(TexImageTarget target, GLsizei rawWidth,
|
||||
GLsizei rawHeight, GLsizei rawDepth, GLint border,
|
||||
const TexImageSource& src, const Maybe<GLsizei>& expectedImageSize);
|
||||
|
||||
|
@ -1308,21 +1341,21 @@ protected:
|
|||
|
||||
public:
|
||||
void DrawArrays(GLenum mode, GLint first, GLsizei count) {
|
||||
DrawArraysInstanced(mode, first, count, 1, "drawArrays");
|
||||
const FuncScope funcScope(*this, "drawArrays");
|
||||
DrawArraysInstanced(mode, first, count, 1);
|
||||
}
|
||||
|
||||
void DrawElements(GLenum mode, GLsizei count, GLenum type,
|
||||
WebGLintptr byteOffset, const char* funcName = "drawElements")
|
||||
WebGLintptr byteOffset)
|
||||
{
|
||||
DrawElementsInstanced(mode, count, type, byteOffset, 1, funcName);
|
||||
const FuncScope funcScope(*this, "drawElements");
|
||||
DrawElementsInstanced(mode, count, type, byteOffset, 1);
|
||||
}
|
||||
|
||||
void DrawArraysInstanced(GLenum mode, GLint first, GLsizei vertexCount,
|
||||
GLsizei instanceCount,
|
||||
const char* funcName = "drawArraysInstanced");
|
||||
GLsizei instanceCount);
|
||||
void DrawElementsInstanced(GLenum mode, GLsizei vertexCount, GLenum type,
|
||||
WebGLintptr byteOffset, GLsizei instanceCount,
|
||||
const char* funcName = "drawElementsInstanced");
|
||||
WebGLintptr byteOffset, GLsizei instanceCount);
|
||||
|
||||
void EnableVertexAttribArray(GLuint index);
|
||||
void DisableVertexAttribArray(GLuint index);
|
||||
|
@ -1340,65 +1373,66 @@ public:
|
|||
|
||||
////
|
||||
|
||||
void VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w,
|
||||
const char* funcName = nullptr);
|
||||
void VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
|
||||
|
||||
////
|
||||
|
||||
void VertexAttrib1f(GLuint index, GLfloat x) {
|
||||
VertexAttrib4f(index, x, 0, 0, 1, "vertexAttrib1f");
|
||||
const FuncScope funcScope(*this, "vertexAttrib1f");
|
||||
VertexAttrib4f(index, x, 0, 0, 1);
|
||||
}
|
||||
void VertexAttrib2f(GLuint index, GLfloat x, GLfloat y) {
|
||||
VertexAttrib4f(index, x, y, 0, 1, "vertexAttrib2f");
|
||||
const FuncScope funcScope(*this, "vertexAttrib2f");
|
||||
VertexAttrib4f(index, x, y, 0, 1);
|
||||
}
|
||||
void VertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z) {
|
||||
VertexAttrib4f(index, x, y, z, 1, "vertexAttrib3f");
|
||||
const FuncScope funcScope(*this, "vertexAttrib3f");
|
||||
VertexAttrib4f(index, x, y, z, 1);
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
void VertexAttrib1fv(GLuint index, const Float32ListU& list) {
|
||||
const char funcName[] = "vertexAttrib1fv";
|
||||
const FuncScope funcScope(*this, "vertexAttrib1fv");
|
||||
const auto& arr = Float32Arr::From(list);
|
||||
if (!ValidateAttribArraySetter(funcName, 1, arr.elemCount))
|
||||
if (!ValidateAttribArraySetter(1, arr.elemCount))
|
||||
return;
|
||||
|
||||
VertexAttrib4f(index, arr.elemBytes[0], 0, 0, 1, funcName);
|
||||
VertexAttrib4f(index, arr.elemBytes[0], 0, 0, 1);
|
||||
}
|
||||
|
||||
void VertexAttrib2fv(GLuint index, const Float32ListU& list) {
|
||||
const char funcName[] = "vertexAttrib2fv";
|
||||
const FuncScope funcScope(*this, "vertexAttrib2fv");
|
||||
const auto& arr = Float32Arr::From(list);
|
||||
if (!ValidateAttribArraySetter(funcName, 2, arr.elemCount))
|
||||
if (!ValidateAttribArraySetter(2, arr.elemCount))
|
||||
return;
|
||||
|
||||
VertexAttrib4f(index, arr.elemBytes[0], arr.elemBytes[1], 0, 1, funcName);
|
||||
VertexAttrib4f(index, arr.elemBytes[0], arr.elemBytes[1], 0, 1);
|
||||
}
|
||||
|
||||
void VertexAttrib3fv(GLuint index, const Float32ListU& list) {
|
||||
const char funcName[] = "vertexAttrib3fv";
|
||||
const FuncScope funcScope(*this, "vertexAttrib3fv");
|
||||
const auto& arr = Float32Arr::From(list);
|
||||
if (!ValidateAttribArraySetter(funcName, 3, arr.elemCount))
|
||||
if (!ValidateAttribArraySetter(3, arr.elemCount))
|
||||
return;
|
||||
|
||||
VertexAttrib4f(index, arr.elemBytes[0], arr.elemBytes[1], arr.elemBytes[2], 1,
|
||||
funcName);
|
||||
VertexAttrib4f(index, arr.elemBytes[0], arr.elemBytes[1], arr.elemBytes[2], 1);
|
||||
}
|
||||
|
||||
void VertexAttrib4fv(GLuint index, const Float32ListU& list) {
|
||||
const char funcName[] = "vertexAttrib4fv";
|
||||
const FuncScope funcScope(*this, "vertexAttrib4fv");
|
||||
const auto& arr = Float32Arr::From(list);
|
||||
if (!ValidateAttribArraySetter(funcName, 4, arr.elemCount))
|
||||
if (!ValidateAttribArraySetter(4, arr.elemCount))
|
||||
return;
|
||||
|
||||
VertexAttrib4f(index, arr.elemBytes[0], arr.elemBytes[1], arr.elemBytes[2],
|
||||
arr.elemBytes[3], funcName);
|
||||
arr.elemBytes[3]);
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
protected:
|
||||
void VertexAttribAnyPointer(const char* funcName, bool isFuncInt, GLuint index,
|
||||
void VertexAttribAnyPointer(bool isFuncInt, GLuint index,
|
||||
GLint size, GLenum type, bool normalized, GLsizei stride,
|
||||
WebGLintptr byteOffset);
|
||||
|
||||
|
@ -1407,18 +1441,18 @@ public:
|
|||
WebGLboolean normalized, GLsizei stride,
|
||||
WebGLintptr byteOffset)
|
||||
{
|
||||
const char funcName[] = "vertexAttribPointer";
|
||||
const FuncScope funcScope(*this, "vertexAttribPointer");
|
||||
const bool isFuncInt = false;
|
||||
VertexAttribAnyPointer(funcName, isFuncInt, index, size, type, normalized, stride,
|
||||
VertexAttribAnyPointer(isFuncInt, index, size, type, normalized, stride,
|
||||
byteOffset);
|
||||
}
|
||||
|
||||
void VertexAttribDivisor(GLuint index, GLuint divisor);
|
||||
|
||||
private:
|
||||
WebGLBuffer* DrawElements_check(const char* funcName, GLsizei indexCount, GLenum type,
|
||||
WebGLBuffer* DrawElements_check(GLsizei indexCount, GLenum type,
|
||||
WebGLintptr byteOffset, GLsizei instanceCount);
|
||||
void Draw_cleanup(const char* funcName);
|
||||
void Draw_cleanup();
|
||||
|
||||
void VertexAttrib1fv_base(GLuint index, uint32_t arrayLength,
|
||||
const GLfloat* ptr);
|
||||
|
@ -1435,7 +1469,7 @@ private:
|
|||
// PROTECTED
|
||||
protected:
|
||||
WebGLVertexAttrib0Status WhatDoesVertexAttrib0Need() const;
|
||||
bool DoFakeVertexAttrib0(const char* funcName, uint64_t vertexCount);
|
||||
bool DoFakeVertexAttrib0(uint64_t vertexCount);
|
||||
void UndoFakeVertexAttrib0();
|
||||
|
||||
CheckedUint32 mGeneration;
|
||||
|
@ -1528,19 +1562,19 @@ protected:
|
|||
// process we currently are at.
|
||||
// This is used to support the WebGL spec's asyncronous nature in handling
|
||||
// context loss.
|
||||
enum ContextStatus {
|
||||
enum class ContextStatus {
|
||||
// The context is stable; there either are none or we don't know of any.
|
||||
ContextNotLost,
|
||||
NotLost,
|
||||
// The context has been lost, but we have not yet sent an event to the
|
||||
// script informing it of this.
|
||||
ContextLostAwaitingEvent,
|
||||
LostAwaitingEvent,
|
||||
// The context has been lost, and we have sent the script an event
|
||||
// informing it of this.
|
||||
ContextLost,
|
||||
Lost,
|
||||
// The context is lost, an event has been sent to the script, and the
|
||||
// script correctly handled the event. We are waiting for the context to
|
||||
// be restored.
|
||||
ContextLostAwaitingRestore
|
||||
LostAwaitingRestore
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
@ -1603,17 +1637,14 @@ protected:
|
|||
bool ValidateBlendEquationEnum(GLenum cap, const char* info);
|
||||
bool ValidateBlendFuncEnumsCompatibility(GLenum sfactor, GLenum dfactor,
|
||||
const char* info);
|
||||
bool ValidateComparisonEnum(GLenum target, const char* info);
|
||||
bool ValidateStencilOpEnum(GLenum action, const char* info);
|
||||
bool ValidateFaceEnum(GLenum face, const char* info);
|
||||
bool ValidateFaceEnum(GLenum face);
|
||||
bool ValidateTexInputData(GLenum type, js::Scalar::Type jsArrayType,
|
||||
WebGLTexImageFunc func, WebGLTexDimensions dims);
|
||||
bool ValidateDrawModeEnum(GLenum mode, const char* info);
|
||||
bool ValidateAttribIndex(GLuint index, const char* info);
|
||||
bool ValidateAttribPointer(bool integerMode, GLuint index, GLint size, GLenum type,
|
||||
WebGLboolean normalized, GLsizei stride,
|
||||
WebGLintptr byteOffset, const char* info);
|
||||
bool ValidateStencilParamsForDrawCall(const char* funcName) const;
|
||||
bool ValidateStencilParamsForDrawCall() const;
|
||||
|
||||
bool ValidateCopyTexImage(TexInternalFormat srcFormat, TexInternalFormat dstformat,
|
||||
WebGLTexImageFunc func, WebGLTexDimensions dims);
|
||||
|
@ -1657,28 +1688,26 @@ protected:
|
|||
WebGLTexDimensions dims);
|
||||
|
||||
bool ValidateUniformLocationForProgram(WebGLUniformLocation* location,
|
||||
WebGLProgram* program,
|
||||
const char* funcName);
|
||||
WebGLProgram* program);
|
||||
|
||||
bool HasDrawBuffers() const {
|
||||
return IsWebGL2() ||
|
||||
IsExtensionEnabled(WebGLExtensionID::WEBGL_draw_buffers);
|
||||
}
|
||||
|
||||
WebGLRefPtr<WebGLBuffer>* ValidateBufferSlot(const char* funcName, GLenum target);
|
||||
WebGLRefPtr<WebGLBuffer>* ValidateBufferSlot(GLenum target);
|
||||
public:
|
||||
WebGLBuffer* ValidateBufferSelection(const char* funcName, GLenum target);
|
||||
WebGLBuffer* ValidateBufferSelection(GLenum target);
|
||||
protected:
|
||||
IndexedBufferBinding* ValidateIndexedBufferSlot(const char* funcName, GLenum target,
|
||||
GLuint index);
|
||||
IndexedBufferBinding* ValidateIndexedBufferSlot(GLenum target, GLuint index);
|
||||
|
||||
bool ValidateIndexedBufferBinding(const char* funcName, GLenum target, GLuint index,
|
||||
bool ValidateIndexedBufferBinding(GLenum target, GLuint index,
|
||||
WebGLRefPtr<WebGLBuffer>** const out_genericBinding,
|
||||
IndexedBufferBinding** const out_indexedBinding);
|
||||
|
||||
bool ValidateNonNegative(const char* funcName, const char* argName, int64_t val) {
|
||||
bool ValidateNonNegative(const char* argName, int64_t val) {
|
||||
if (MOZ_UNLIKELY(val < 0)) {
|
||||
ErrorInvalidValue("%s: `%s` must be non-negative.", funcName, argName);
|
||||
ErrorInvalidValue("`%s` must be non-negative.", argName);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -1686,15 +1715,15 @@ protected:
|
|||
|
||||
public:
|
||||
template<typename T>
|
||||
bool ValidateNonNull(const char* funcName, const dom::Nullable<T>& maybe) {
|
||||
bool ValidateNonNull(const char* const argName, const dom::Nullable<T>& maybe) {
|
||||
if (maybe.IsNull()) {
|
||||
ErrorInvalidValue("%s: `null` is invalid.", funcName);
|
||||
ErrorInvalidValue("%s: Cannot be null.", argName);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ValidateArrayBufferView(const char* funcName, const dom::ArrayBufferView& view,
|
||||
bool ValidateArrayBufferView(const dom::ArrayBufferView& view,
|
||||
GLuint elemOffset, GLuint elemCountOverride,
|
||||
uint8_t** const out_bytes, size_t* const out_byteLen);
|
||||
|
||||
|
@ -1714,23 +1743,23 @@ protected:
|
|||
|
||||
//////
|
||||
public:
|
||||
bool ValidateObjectAllowDeleted(const char* funcName,
|
||||
bool ValidateObjectAllowDeleted(const char* const argName,
|
||||
const WebGLContextBoundObject& object)
|
||||
{
|
||||
if (!object.IsCompatibleWithContext(this)) {
|
||||
ErrorInvalidOperation("%s: Object from different WebGL context (or older"
|
||||
" generation of this one) passed as argument.",
|
||||
funcName);
|
||||
argName);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ValidateObject(const char* funcName, const WebGLDeletableObject& object,
|
||||
bool isShaderOrProgram = false)
|
||||
bool ValidateObject(const char* const argName, const WebGLDeletableObject& object,
|
||||
const bool isShaderOrProgram = false)
|
||||
{
|
||||
if (!ValidateObjectAllowDeleted(funcName, object))
|
||||
if (!ValidateObjectAllowDeleted(argName, object))
|
||||
return false;
|
||||
|
||||
if (isShaderOrProgram) {
|
||||
|
@ -1746,14 +1775,14 @@ public:
|
|||
if (object.IsDeleted()) {
|
||||
ErrorInvalidValue("%s: Shader or program object argument cannot have been"
|
||||
" deleted.",
|
||||
funcName);
|
||||
argName);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (object.IsDeleteRequested()) {
|
||||
ErrorInvalidOperation("%s: Object argument cannot have been marked for"
|
||||
" deletion.",
|
||||
funcName);
|
||||
argName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1763,44 +1792,15 @@ public:
|
|||
|
||||
////
|
||||
|
||||
bool ValidateObject(const char* funcName, const WebGLProgram& object);
|
||||
bool ValidateObject(const char* funcName, const WebGLShader& object);
|
||||
// Program and Shader are incomplete, so we can't inline the conversion to
|
||||
// WebGLDeletableObject here.
|
||||
bool ValidateObject(const char* const argName, const WebGLProgram& object);
|
||||
bool ValidateObject(const char* const argName, const WebGLShader& object);
|
||||
|
||||
////
|
||||
|
||||
bool ValidateIsObject(const char* funcName,
|
||||
const WebGLDeletableObject* object) const
|
||||
{
|
||||
if (IsContextLost())
|
||||
return false;
|
||||
|
||||
if (!object)
|
||||
return false;
|
||||
|
||||
if (!object->IsCompatibleWithContext(this))
|
||||
return false;
|
||||
|
||||
if (object->IsDeleted())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ValidateDeleteObject(const char* funcName, const WebGLDeletableObject* object) {
|
||||
if (IsContextLost())
|
||||
return false;
|
||||
|
||||
if (!object)
|
||||
return false;
|
||||
|
||||
if (!ValidateObjectAllowDeleted(funcName, *object))
|
||||
return false;
|
||||
|
||||
if (object->IsDeleteRequested())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
bool ValidateIsObject(const WebGLDeletableObject* object) const;
|
||||
bool ValidateDeleteObject(const WebGLDeletableObject* object);
|
||||
|
||||
////
|
||||
|
||||
|
@ -1826,8 +1826,8 @@ protected:
|
|||
WebGLRefPtr<WebGLProgram> mCurrentProgram;
|
||||
RefPtr<const webgl::LinkedProgramInfo> mActiveProgramLinkInfo;
|
||||
|
||||
bool ValidateFramebufferTarget(GLenum target, const char* const info);
|
||||
bool ValidateInvalidateFramebuffer(const char* funcName, GLenum target,
|
||||
bool ValidateFramebufferTarget(GLenum target);
|
||||
bool ValidateInvalidateFramebuffer(GLenum target,
|
||||
const dom::Sequence<GLenum>& attachments,
|
||||
ErrorResult* const out_rv,
|
||||
std::vector<GLenum>* const scopedVector,
|
||||
|
@ -1870,7 +1870,7 @@ protected:
|
|||
CheckedUint32 GetUnpackSize(bool isFunc3D, uint32_t width, uint32_t height,
|
||||
uint32_t depth, uint8_t bytesPerPixel);
|
||||
|
||||
bool ValidatePackSize(const char* funcName, uint32_t width, uint32_t height,
|
||||
bool ValidatePackSize(uint32_t width, uint32_t height,
|
||||
uint8_t bytesPerPixel, uint32_t* const out_rowStride,
|
||||
uint32_t* const out_endOffset);
|
||||
|
||||
|
@ -1949,7 +1949,7 @@ protected:
|
|||
WebGLContextLossHandler mContextLossHandler;
|
||||
bool mAllowContextRestore;
|
||||
bool mLastLossWasSimulated;
|
||||
ContextStatus mContextStatus;
|
||||
ContextStatus mContextStatus = ContextStatus::NotLost;
|
||||
bool mContextLostErrorSet;
|
||||
|
||||
// Used for some hardware (particularly Tegra 2 and 4) that likes to
|
||||
|
@ -1993,17 +1993,16 @@ protected:
|
|||
|
||||
// --
|
||||
|
||||
bool EnsureDefaultFB(const char* funcName);
|
||||
bool ValidateAndInitFB(const char* funcName, const WebGLFramebuffer* fb);
|
||||
bool EnsureDefaultFB();
|
||||
bool ValidateAndInitFB(const WebGLFramebuffer* fb);
|
||||
void DoBindFB(const WebGLFramebuffer* fb, GLenum target = LOCAL_GL_FRAMEBUFFER) const;
|
||||
|
||||
bool BindCurFBForDraw(const char* funcName);
|
||||
bool BindCurFBForColorRead(const char* funcName,
|
||||
const webgl::FormatUsageInfo** out_format,
|
||||
bool BindCurFBForDraw();
|
||||
bool BindCurFBForColorRead(const webgl::FormatUsageInfo** out_format,
|
||||
uint32_t* out_width, uint32_t* out_height);
|
||||
void DoColorMask(uint8_t bitmask) const;
|
||||
void BlitBackbufferToCurDriverFB() const;
|
||||
bool BindDefaultFBForRead(const char* funcName);
|
||||
bool BindDefaultFBForRead();
|
||||
|
||||
// --
|
||||
|
||||
|
@ -2083,12 +2082,15 @@ RoundUpToMultipleOf(const V& value, const M& multiple)
|
|||
return ((value + multiple - 1) / multiple) * multiple;
|
||||
}
|
||||
|
||||
const char* GetEnumName(GLenum val, const char* defaultRet = "<unknown>");
|
||||
std::string EnumString(GLenum val);
|
||||
|
||||
bool
|
||||
ValidateTexTarget(WebGLContext* webgl, const char* funcName, uint8_t funcDims,
|
||||
ValidateTexTarget(WebGLContext* webgl, uint8_t funcDims,
|
||||
GLenum rawTexTarget, TexTarget* const out_texTarget,
|
||||
WebGLTexture** const out_tex);
|
||||
bool
|
||||
ValidateTexImageTarget(WebGLContext* webgl, const char* funcName, uint8_t funcDims,
|
||||
ValidateTexImageTarget(WebGLContext* webgl, uint8_t funcDims,
|
||||
GLenum rawTexImageTarget, TexImageTarget* const out_texImageTarget,
|
||||
WebGLTexture** const out_tex);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
namespace mozilla {
|
||||
|
||||
WebGLRefPtr<WebGLBuffer>*
|
||||
WebGLContext::ValidateBufferSlot(const char* funcName, GLenum target)
|
||||
WebGLContext::ValidateBufferSlot(GLenum target)
|
||||
{
|
||||
WebGLRefPtr<WebGLBuffer>* slot = nullptr;
|
||||
|
||||
|
@ -56,7 +56,7 @@ WebGLContext::ValidateBufferSlot(const char* funcName, GLenum target)
|
|||
}
|
||||
|
||||
if (!slot) {
|
||||
ErrorInvalidEnum("%s: Bad `target`: 0x%04x", funcName, target);
|
||||
ErrorInvalidEnumInfo("target", target);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -64,36 +64,33 @@ WebGLContext::ValidateBufferSlot(const char* funcName, GLenum target)
|
|||
}
|
||||
|
||||
WebGLBuffer*
|
||||
WebGLContext::ValidateBufferSelection(const char* funcName, GLenum target)
|
||||
WebGLContext::ValidateBufferSelection(GLenum target)
|
||||
{
|
||||
const auto& slot = ValidateBufferSlot(funcName, target);
|
||||
const auto& slot = ValidateBufferSlot(target);
|
||||
if (!slot)
|
||||
return nullptr;
|
||||
const auto& buffer = *slot;
|
||||
|
||||
if (!buffer) {
|
||||
ErrorInvalidOperation("%s: Buffer for `target` is null.", funcName);
|
||||
ErrorInvalidOperation("Buffer for `target` is null.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (target == LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER) {
|
||||
if (mBoundTransformFeedback->IsActiveAndNotPaused()) {
|
||||
ErrorInvalidOperation("%s: Cannot select TRANSFORM_FEEDBACK_BUFFER when"
|
||||
" transform feedback is active and unpaused.",
|
||||
funcName);
|
||||
ErrorInvalidOperation("Cannot select TRANSFORM_FEEDBACK_BUFFER when"
|
||||
" transform feedback is active and unpaused.");
|
||||
return nullptr;
|
||||
}
|
||||
if (buffer->IsBoundForNonTF()) {
|
||||
ErrorInvalidOperation("%s: Specified WebGLBuffer is currently bound for"
|
||||
" non-transform-feedback.",
|
||||
funcName);
|
||||
ErrorInvalidOperation("Specified WebGLBuffer is currently bound for"
|
||||
" non-transform-feedback.");
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
if (buffer->IsBoundForTF()) {
|
||||
ErrorInvalidOperation("%s: Specified WebGLBuffer is currently bound for"
|
||||
" transform feedback.",
|
||||
funcName);
|
||||
ErrorInvalidOperation("Specified WebGLBuffer is currently bound for"
|
||||
" transform feedback.");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +99,7 @@ WebGLContext::ValidateBufferSelection(const char* funcName, GLenum target)
|
|||
}
|
||||
|
||||
IndexedBufferBinding*
|
||||
WebGLContext::ValidateIndexedBufferSlot(const char* funcName, GLenum target, GLuint index)
|
||||
WebGLContext::ValidateIndexedBufferSlot(GLenum target, GLuint index)
|
||||
{
|
||||
decltype(mIndexedUniformBufferBindings)* bindings;
|
||||
const char* maxIndexEnum;
|
||||
|
@ -118,12 +115,12 @@ WebGLContext::ValidateIndexedBufferSlot(const char* funcName, GLenum target, GLu
|
|||
break;
|
||||
|
||||
default:
|
||||
ErrorInvalidEnum("%s: Bad `target`: 0x%04x", funcName, target);
|
||||
ErrorInvalidEnumInfo("target", target);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (index >= bindings->size()) {
|
||||
ErrorInvalidValue("%s: `index` >= %s.", funcName, maxIndexEnum);
|
||||
ErrorInvalidValue("`index` >= %s.", maxIndexEnum);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -135,18 +132,18 @@ WebGLContext::ValidateIndexedBufferSlot(const char* funcName, GLenum target, GLu
|
|||
void
|
||||
WebGLContext::BindBuffer(GLenum target, WebGLBuffer* buffer)
|
||||
{
|
||||
const char funcName[] = "bindBuffer";
|
||||
const FuncScope funcScope(*this, "bindBuffer");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (buffer && !ValidateObject(funcName, *buffer))
|
||||
if (buffer && !ValidateObject("buffer", *buffer))
|
||||
return;
|
||||
|
||||
const auto& slot = ValidateBufferSlot(funcName, target);
|
||||
const auto& slot = ValidateBufferSlot(target);
|
||||
if (!slot)
|
||||
return;
|
||||
|
||||
if (buffer && !buffer->ValidateCanBindToTarget(funcName, target))
|
||||
if (buffer && !buffer->ValidateCanBindToTarget(target))
|
||||
return;
|
||||
|
||||
gl->fBindBuffer(target, buffer ? buffer->mGLName : 0);
|
||||
|
@ -167,25 +164,23 @@ WebGLContext::BindBuffer(GLenum target, WebGLBuffer* buffer)
|
|||
////////////////////////////////////////
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateIndexedBufferBinding(const char* funcName, GLenum target,
|
||||
GLuint index,
|
||||
WebGLContext::ValidateIndexedBufferBinding(GLenum target, GLuint index,
|
||||
WebGLRefPtr<WebGLBuffer>** const out_genericBinding,
|
||||
IndexedBufferBinding** const out_indexedBinding)
|
||||
{
|
||||
*out_genericBinding = ValidateBufferSlot(funcName, target);
|
||||
*out_genericBinding = ValidateBufferSlot(target);
|
||||
if (!*out_genericBinding)
|
||||
return false;
|
||||
|
||||
*out_indexedBinding = ValidateIndexedBufferSlot(funcName, target, index);
|
||||
*out_indexedBinding = ValidateIndexedBufferSlot(target, index);
|
||||
if (!*out_indexedBinding)
|
||||
return false;
|
||||
|
||||
if (target == LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER &&
|
||||
mBoundTransformFeedback->mIsActive)
|
||||
{
|
||||
ErrorInvalidOperation("%s: Cannot update indexed buffer bindings on active"
|
||||
" transform feedback objects.",
|
||||
funcName);
|
||||
ErrorInvalidOperation("Cannot update indexed buffer bindings on active"
|
||||
" transform feedback objects.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -195,22 +190,22 @@ WebGLContext::ValidateIndexedBufferBinding(const char* funcName, GLenum target,
|
|||
void
|
||||
WebGLContext::BindBufferBase(GLenum target, GLuint index, WebGLBuffer* buffer)
|
||||
{
|
||||
const char funcName[] = "bindBufferBase";
|
||||
const FuncScope funcScope(*this, "bindBufferBase");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (buffer && !ValidateObject(funcName, *buffer))
|
||||
if (buffer && !ValidateObject("buffer", *buffer))
|
||||
return;
|
||||
|
||||
WebGLRefPtr<WebGLBuffer>* genericBinding;
|
||||
IndexedBufferBinding* indexedBinding;
|
||||
if (!ValidateIndexedBufferBinding(funcName, target, index, &genericBinding,
|
||||
if (!ValidateIndexedBufferBinding(target, index, &genericBinding,
|
||||
&indexedBinding))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (buffer && !buffer->ValidateCanBindToTarget(funcName, target))
|
||||
if (buffer && !buffer->ValidateCanBindToTarget(target))
|
||||
return;
|
||||
|
||||
////
|
||||
|
@ -233,32 +228,32 @@ void
|
|||
WebGLContext::BindBufferRange(GLenum target, GLuint index, WebGLBuffer* buffer,
|
||||
WebGLintptr offset, WebGLsizeiptr size)
|
||||
{
|
||||
const char funcName[] = "bindBufferRange";
|
||||
const FuncScope funcScope(*this, "bindBufferRange");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (buffer && !ValidateObject(funcName, *buffer))
|
||||
if (buffer && !ValidateObject("buffer", *buffer))
|
||||
return;
|
||||
|
||||
if (!ValidateNonNegative(funcName, "offset", offset) ||
|
||||
!ValidateNonNegative(funcName, "size", size))
|
||||
if (!ValidateNonNegative("offset", offset) ||
|
||||
!ValidateNonNegative("size", size))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
WebGLRefPtr<WebGLBuffer>* genericBinding;
|
||||
IndexedBufferBinding* indexedBinding;
|
||||
if (!ValidateIndexedBufferBinding(funcName, target, index, &genericBinding,
|
||||
if (!ValidateIndexedBufferBinding(target, index, &genericBinding,
|
||||
&indexedBinding))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (buffer && !buffer->ValidateCanBindToTarget(funcName, target))
|
||||
if (buffer && !buffer->ValidateCanBindToTarget(target))
|
||||
return;
|
||||
|
||||
if (buffer && !size) {
|
||||
ErrorInvalidValue("%s: size must be non-zero for non-null buffer.", funcName);
|
||||
ErrorInvalidValue("Size must be non-zero for non-null buffer.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -267,8 +262,8 @@ WebGLContext::BindBufferRange(GLenum target, GLuint index, WebGLBuffer* buffer,
|
|||
switch (target) {
|
||||
case LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER:
|
||||
if (offset % 4 != 0 || size % 4 != 0) {
|
||||
ErrorInvalidValue("%s: For %s, `offset` and `size` must be multiples of 4.",
|
||||
funcName, "TRANSFORM_FEEDBACK_BUFFER");
|
||||
ErrorInvalidValue("For %s, `offset` and `size` must be multiples of 4.",
|
||||
"TRANSFORM_FEEDBACK_BUFFER");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
@ -278,8 +273,8 @@ WebGLContext::BindBufferRange(GLenum target, GLuint index, WebGLBuffer* buffer,
|
|||
GLuint offsetAlignment = 0;
|
||||
gl->GetUIntegerv(LOCAL_GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &offsetAlignment);
|
||||
if (offset % offsetAlignment != 0) {
|
||||
ErrorInvalidValue("%s: For %s, `offset` must be a multiple of %s.",
|
||||
funcName, "UNIFORM_BUFFER",
|
||||
ErrorInvalidValue("For %s, `offset` must be a multiple of %s.",
|
||||
"UNIFORM_BUFFER",
|
||||
"UNIFORM_BUFFER_OFFSET_ALIGNMENT");
|
||||
return;
|
||||
}
|
||||
|
@ -319,9 +314,8 @@ void
|
|||
WebGLContext::BufferDataImpl(GLenum target, size_t dataLen, const uint8_t* data,
|
||||
GLenum usage)
|
||||
{
|
||||
const char funcName[] = "bufferData";
|
||||
|
||||
const auto& buffer = ValidateBufferSelection(funcName, target);
|
||||
const auto& buffer = ValidateBufferSelection(target);
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
|
@ -333,18 +327,18 @@ WebGLContext::BufferDataImpl(GLenum target, size_t dataLen, const uint8_t* data,
|
|||
void
|
||||
WebGLContext::BufferData(GLenum target, WebGLsizeiptr size, GLenum usage)
|
||||
{
|
||||
const char funcName[] = "bufferData";
|
||||
const FuncScope funcScope(*this, "bufferData");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateNonNegative(funcName, "size", size))
|
||||
if (!ValidateNonNegative("size", size))
|
||||
return;
|
||||
|
||||
////
|
||||
|
||||
const UniqueBuffer zeroBuffer(calloc(size, 1));
|
||||
if (!zeroBuffer)
|
||||
return ErrorOutOfMemory("%s: Failed to allocate zeros.", funcName);
|
||||
return ErrorOutOfMemory("Failed to allocate zeros.");
|
||||
|
||||
BufferDataImpl(target, size_t(size), (const uint8_t*)zeroBuffer.get(), usage);
|
||||
}
|
||||
|
@ -353,10 +347,11 @@ void
|
|||
WebGLContext::BufferData(GLenum target, const dom::Nullable<dom::ArrayBuffer>& maybeSrc,
|
||||
GLenum usage)
|
||||
{
|
||||
const FuncScope funcScope(*this, "bufferData");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateNonNull("bufferData", maybeSrc))
|
||||
if (!ValidateNonNull("src", maybeSrc))
|
||||
return;
|
||||
const auto& src = maybeSrc.Value();
|
||||
|
||||
|
@ -368,13 +363,13 @@ void
|
|||
WebGLContext::BufferData(GLenum target, const dom::ArrayBufferView& src, GLenum usage,
|
||||
GLuint srcElemOffset, GLuint srcElemCountOverride)
|
||||
{
|
||||
const char funcName[] = "bufferData";
|
||||
const FuncScope funcScope(*this, "bufferData");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
uint8_t* bytes;
|
||||
size_t byteLen;
|
||||
if (!ValidateArrayBufferView(funcName, src, srcElemOffset, srcElemCountOverride,
|
||||
if (!ValidateArrayBufferView(src, srcElemOffset, srcElemCountOverride,
|
||||
&bytes, &byteLen))
|
||||
{
|
||||
return;
|
||||
|
@ -389,12 +384,12 @@ void
|
|||
WebGLContext::BufferSubDataImpl(GLenum target, WebGLsizeiptr dstByteOffset,
|
||||
size_t dataLen, const uint8_t* data)
|
||||
{
|
||||
const char funcName[] = "bufferSubData";
|
||||
const FuncScope funcScope(*this, "bufferSubData");
|
||||
|
||||
if (!ValidateNonNegative(funcName, "byteOffset", dstByteOffset))
|
||||
if (!ValidateNonNegative("byteOffset", dstByteOffset))
|
||||
return;
|
||||
|
||||
const auto& buffer = ValidateBufferSelection(funcName, target);
|
||||
const auto& buffer = ValidateBufferSelection(target);
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
|
@ -407,6 +402,7 @@ void
|
|||
WebGLContext::BufferSubData(GLenum target, WebGLsizeiptr dstByteOffset,
|
||||
const dom::ArrayBuffer& src)
|
||||
{
|
||||
const FuncScope funcScope(*this, "bufferSubData");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
|
@ -420,13 +416,13 @@ WebGLContext::BufferSubData(GLenum target, WebGLsizeiptr dstByteOffset,
|
|||
const dom::ArrayBufferView& src, GLuint srcElemOffset,
|
||||
GLuint srcElemCountOverride)
|
||||
{
|
||||
const char funcName[] = "bufferSubData";
|
||||
const FuncScope funcScope(*this, "bufferSubData");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
uint8_t* bytes;
|
||||
size_t byteLen;
|
||||
if (!ValidateArrayBufferView(funcName, src, srcElemOffset, srcElemCountOverride,
|
||||
if (!ValidateArrayBufferView(src, srcElemOffset, srcElemCountOverride,
|
||||
&bytes, &byteLen))
|
||||
{
|
||||
return;
|
||||
|
@ -440,6 +436,7 @@ WebGLContext::BufferSubData(GLenum target, WebGLsizeiptr dstByteOffset,
|
|||
already_AddRefed<WebGLBuffer>
|
||||
WebGLContext::CreateBuffer()
|
||||
{
|
||||
const FuncScope funcScope(*this, "createBuffer");
|
||||
if (IsContextLost())
|
||||
return nullptr;
|
||||
|
||||
|
@ -453,7 +450,8 @@ WebGLContext::CreateBuffer()
|
|||
void
|
||||
WebGLContext::DeleteBuffer(WebGLBuffer* buffer)
|
||||
{
|
||||
if (!ValidateDeleteObject("deleteBuffer", buffer))
|
||||
const FuncScope funcScope(*this, "deleteBuffer");
|
||||
if (!ValidateDeleteObject(buffer))
|
||||
return;
|
||||
|
||||
////
|
||||
|
@ -498,13 +496,4 @@ WebGLContext::DeleteBuffer(WebGLBuffer* buffer)
|
|||
buffer->RequestDelete();
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::IsBuffer(WebGLBuffer* buffer)
|
||||
{
|
||||
if (!ValidateIsObject("isBuffer", buffer))
|
||||
return false;
|
||||
|
||||
return gl->fIsBuffer(buffer->mGLName);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -43,13 +43,12 @@ class ScopedResolveTexturesForDraw
|
|||
std::vector<TexRebindRequest> mRebindRequests;
|
||||
|
||||
public:
|
||||
ScopedResolveTexturesForDraw(WebGLContext* webgl, const char* funcName,
|
||||
bool* const out_error);
|
||||
ScopedResolveTexturesForDraw(WebGLContext* webgl, bool* const out_error);
|
||||
~ScopedResolveTexturesForDraw();
|
||||
};
|
||||
|
||||
bool
|
||||
WebGLTexture::IsFeedback(WebGLContext* webgl, const char* funcName, uint32_t texUnit,
|
||||
WebGLTexture::IsFeedback(WebGLContext* webgl, uint32_t texUnit,
|
||||
const std::vector<const WebGLFBAttachPoint*>& fbAttachments) const
|
||||
{
|
||||
auto itr = fbAttachments.cbegin();
|
||||
|
@ -81,10 +80,10 @@ WebGLTexture::IsFeedback(WebGLContext* webgl, const char* funcName, uint32_t tex
|
|||
const auto dstLevel = attach->MipLevel();
|
||||
|
||||
if (minLevel <= dstLevel && dstLevel <= maxLevel) {
|
||||
webgl->ErrorInvalidOperation("%s: Feedback loop detected between tex target"
|
||||
webgl->ErrorInvalidOperation("Feedback loop detected between tex target"
|
||||
" 0x%04x, tex unit %u, levels %u-%u; and"
|
||||
" framebuffer attachment 0x%04x, level %u.",
|
||||
funcName, mTarget.get(), texUnit, minLevel,
|
||||
mTarget.get(), texUnit, minLevel,
|
||||
maxLevel, attach->mAttachmentPoint, dstLevel);
|
||||
return true;
|
||||
}
|
||||
|
@ -94,7 +93,6 @@ WebGLTexture::IsFeedback(WebGLContext* webgl, const char* funcName, uint32_t tex
|
|||
}
|
||||
|
||||
ScopedResolveTexturesForDraw::ScopedResolveTexturesForDraw(WebGLContext* webgl,
|
||||
const char* funcName,
|
||||
bool* const out_error)
|
||||
: mWebGL(webgl)
|
||||
{
|
||||
|
@ -120,16 +118,15 @@ ScopedResolveTexturesForDraw::ScopedResolveTexturesForDraw(WebGLContext* webgl,
|
|||
continue;
|
||||
|
||||
if (attachList &&
|
||||
tex->IsFeedback(mWebGL, funcName, texUnit, *attachList))
|
||||
tex->IsFeedback(mWebGL, texUnit, *attachList))
|
||||
{
|
||||
*out_error = true;
|
||||
return;
|
||||
}
|
||||
|
||||
FakeBlackType fakeBlack;
|
||||
if (!tex->ResolveForDraw(funcName, texUnit, &fakeBlack)) {
|
||||
mWebGL->ErrorOutOfMemory("%s: Failed to resolve textures for draw.",
|
||||
funcName);
|
||||
if (!tex->ResolveForDraw(texUnit, &fakeBlack)) {
|
||||
mWebGL->ErrorOutOfMemory("Failed to resolve textures for draw.");
|
||||
*out_error = true;
|
||||
return;
|
||||
}
|
||||
|
@ -138,8 +135,7 @@ ScopedResolveTexturesForDraw::ScopedResolveTexturesForDraw(WebGLContext* webgl,
|
|||
continue;
|
||||
|
||||
if (!mWebGL->BindFakeBlack(texUnit, tex->Target(), fakeBlack)) {
|
||||
mWebGL->ErrorOutOfMemory("%s: Failed to create fake black texture.",
|
||||
funcName);
|
||||
mWebGL->ErrorOutOfMemory("Failed to create fake black texture.");
|
||||
*out_error = true;
|
||||
return;
|
||||
}
|
||||
|
@ -234,7 +230,7 @@ WebGLContext::BindFakeBlack(uint32_t texUnit, TexTarget target, FakeBlackType fa
|
|||
////////////////////////////////////////
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateStencilParamsForDrawCall(const char* const funcName) const
|
||||
WebGLContext::ValidateStencilParamsForDrawCall() const
|
||||
{
|
||||
const auto stencilBits = [&]() -> uint8_t {
|
||||
if (!mStencilTestEnabled)
|
||||
|
@ -264,12 +260,11 @@ WebGLContext::ValidateStencilParamsForDrawCall(const char* const funcName) const
|
|||
ok &= (fnClamp(mStencilRefFront) == fnClamp(mStencilRefBack));
|
||||
|
||||
if (!ok) {
|
||||
ErrorInvalidOperation("%s: Stencil front/back state must effectively match."
|
||||
ErrorInvalidOperation("Stencil front/back state must effectively match."
|
||||
" (before front/back comparison, WRITEMASK and VALUE_MASK"
|
||||
" are masked with (2^s)-1, and REF is clamped to"
|
||||
" [0, (2^s)-1], where `s` is the number of enabled stencil"
|
||||
" bits in the draw framebuffer)",
|
||||
funcName);
|
||||
" bits in the draw framebuffer)");
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
@ -287,22 +282,33 @@ DoSetsIntersect(const std::set<T>& a, const std::set<T>& b)
|
|||
}
|
||||
|
||||
const webgl::CachedDrawFetchLimits*
|
||||
ValidateDraw(WebGLContext* const webgl, const char* const funcName, const GLenum mode,
|
||||
ValidateDraw(WebGLContext* const webgl, const GLenum mode,
|
||||
const uint32_t instanceCount)
|
||||
{
|
||||
MOZ_ASSERT(webgl->gl->IsCurrent());
|
||||
|
||||
if (!webgl->BindCurFBForDraw(funcName))
|
||||
if (!webgl->BindCurFBForDraw())
|
||||
return nullptr;
|
||||
|
||||
if (!webgl->ValidateDrawModeEnum(mode, funcName))
|
||||
switch (mode) {
|
||||
case LOCAL_GL_TRIANGLES:
|
||||
case LOCAL_GL_TRIANGLE_STRIP:
|
||||
case LOCAL_GL_TRIANGLE_FAN:
|
||||
case LOCAL_GL_POINTS:
|
||||
case LOCAL_GL_LINE_STRIP:
|
||||
case LOCAL_GL_LINE_LOOP:
|
||||
case LOCAL_GL_LINES:
|
||||
break;
|
||||
default:
|
||||
webgl->ErrorInvalidEnumInfo("mode", mode);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!webgl->ValidateStencilParamsForDrawCall(funcName))
|
||||
if (!webgl->ValidateStencilParamsForDrawCall())
|
||||
return nullptr;
|
||||
|
||||
if (!webgl->mActiveProgramLinkInfo) {
|
||||
webgl->ErrorInvalidOperation("%s: The current program is not linked.", funcName);
|
||||
webgl->ErrorInvalidOperation("The current program is not linked.");
|
||||
return nullptr;
|
||||
}
|
||||
const auto& linkInfo = webgl->mActiveProgramLinkInfo;
|
||||
|
@ -314,23 +320,20 @@ ValidateDraw(WebGLContext* const webgl, const char* const funcName, const GLenum
|
|||
const auto& dataSize = cur->mDataSize;
|
||||
const auto& binding = cur->mBinding;
|
||||
if (!binding) {
|
||||
webgl->ErrorInvalidOperation("%s: Buffer for uniform block is null.",
|
||||
funcName);
|
||||
webgl->ErrorInvalidOperation("Buffer for uniform block is null.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const auto availByteCount = binding->ByteCount();
|
||||
if (dataSize > availByteCount) {
|
||||
webgl->ErrorInvalidOperation("%s: Buffer for uniform block is smaller"
|
||||
" than UNIFORM_BLOCK_DATA_SIZE.",
|
||||
funcName);
|
||||
webgl->ErrorInvalidOperation("Buffer for uniform block is smaller"
|
||||
" than UNIFORM_BLOCK_DATA_SIZE.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (binding->mBufferBinding->IsBoundForTF()) {
|
||||
webgl->ErrorInvalidOperation("%s: Buffer for uniform block is bound or"
|
||||
" in use for transform feedback.",
|
||||
funcName);
|
||||
webgl->ErrorInvalidOperation("Buffer for uniform block is bound or"
|
||||
" in use for transform feedback.");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -356,9 +359,9 @@ ValidateDraw(WebGLContext* const webgl, const char* const funcName, const GLenum
|
|||
for (uint32_t i = 0; i < numUsed; ++i) {
|
||||
const auto& buffer = tfo->mIndexedBindings[i].mBufferBinding;
|
||||
if (buffer->IsBoundForNonTF()) {
|
||||
webgl->ErrorInvalidOperation("%s: Transform feedback varying %u's buffer"
|
||||
webgl->ErrorInvalidOperation("Transform feedback varying %u's buffer"
|
||||
" is bound for non-transform-feedback.",
|
||||
funcName, i);
|
||||
i);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -370,14 +373,14 @@ ValidateDraw(WebGLContext* const webgl, const char* const funcName, const GLenum
|
|||
|
||||
// -
|
||||
|
||||
const auto fetchLimits = linkInfo->GetDrawFetchLimits(funcName);
|
||||
const auto fetchLimits = linkInfo->GetDrawFetchLimits();
|
||||
if (!fetchLimits)
|
||||
return nullptr;
|
||||
|
||||
if (instanceCount > fetchLimits->maxInstances) {
|
||||
webgl->ErrorInvalidOperation("%s: Instance fetch requires %u, but attribs only"
|
||||
webgl->ErrorInvalidOperation("Instance fetch requires %u, but attribs only"
|
||||
" supply %u.",
|
||||
funcName, instanceCount,
|
||||
instanceCount,
|
||||
uint32_t(fetchLimits->maxInstances));
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -397,13 +400,13 @@ class ScopedFakeVertexAttrib0 final
|
|||
bool mDidFake = false;
|
||||
|
||||
public:
|
||||
ScopedFakeVertexAttrib0(WebGLContext* const webgl, const char* const funcName,
|
||||
ScopedFakeVertexAttrib0(WebGLContext* const webgl,
|
||||
const uint64_t vertexCount, bool* const out_error)
|
||||
: mWebGL(webgl)
|
||||
{
|
||||
*out_error = false;
|
||||
|
||||
if (!mWebGL->DoFakeVertexAttrib0(funcName, vertexCount)) {
|
||||
if (!mWebGL->DoFakeVertexAttrib0(vertexCount)) {
|
||||
*out_error = true;
|
||||
return;
|
||||
}
|
||||
|
@ -450,7 +453,7 @@ class ScopedDrawWithTransformFeedback final
|
|||
uint32_t mUsedVerts;
|
||||
|
||||
public:
|
||||
ScopedDrawWithTransformFeedback(WebGLContext* webgl, const char* funcName,
|
||||
ScopedDrawWithTransformFeedback(WebGLContext* webgl,
|
||||
GLenum mode, uint32_t vertCount,
|
||||
uint32_t instanceCount, bool* const out_error)
|
||||
: mWebGL(webgl)
|
||||
|
@ -465,10 +468,9 @@ public:
|
|||
return;
|
||||
|
||||
if (mode != mTFO->mActive_PrimMode) {
|
||||
mWebGL->ErrorInvalidOperation("%s: Drawing with transform feedback requires"
|
||||
mWebGL->ErrorInvalidOperation("Drawing with transform feedback requires"
|
||||
" `mode` to match BeginTransformFeedback's"
|
||||
" `primitiveMode`.",
|
||||
funcName);
|
||||
" `primitiveMode`.");
|
||||
*out_error = true;
|
||||
return;
|
||||
}
|
||||
|
@ -480,9 +482,8 @@ public:
|
|||
if (!usedVerts.isValid() ||
|
||||
usedVerts.value() > remainingCapacity)
|
||||
{
|
||||
mWebGL->ErrorInvalidOperation("%s: Insufficient buffer capacity remaining for"
|
||||
" transform feedback.",
|
||||
funcName);
|
||||
mWebGL->ErrorInvalidOperation("Insufficient buffer capacity remaining for"
|
||||
" transform feedback.");
|
||||
*out_error = true;
|
||||
return;
|
||||
}
|
||||
|
@ -509,7 +510,7 @@ HasInstancedDrawing(const WebGLContext& webgl)
|
|||
|
||||
void
|
||||
WebGLContext::DrawArraysInstanced(GLenum mode, GLint first, GLsizei vertCount,
|
||||
GLsizei instanceCount, const char* const funcName)
|
||||
GLsizei instanceCount)
|
||||
{
|
||||
AUTO_PROFILER_LABEL("WebGLContext::DrawArraysInstanced", GRAPHICS);
|
||||
if (IsContextLost())
|
||||
|
@ -518,9 +519,9 @@ WebGLContext::DrawArraysInstanced(GLenum mode, GLint first, GLsizei vertCount,
|
|||
|
||||
// -
|
||||
|
||||
if (!ValidateNonNegative(funcName, "first", first) ||
|
||||
!ValidateNonNegative(funcName, "vertCount", vertCount) ||
|
||||
!ValidateNonNegative(funcName, "instanceCount", instanceCount))
|
||||
if (!ValidateNonNegative("first", first) ||
|
||||
!ValidateNonNegative("vertCount", vertCount) ||
|
||||
!ValidateNonNegative("instanceCount", instanceCount))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -537,7 +538,7 @@ WebGLContext::DrawArraysInstanced(GLenum mode, GLint first, GLsizei vertCount,
|
|||
|
||||
// -
|
||||
|
||||
const auto fetchLimits = ValidateDraw(this, funcName, mode, instanceCount);
|
||||
const auto fetchLimits = ValidateDraw(this, mode, instanceCount);
|
||||
if (!fetchLimits)
|
||||
return;
|
||||
|
||||
|
@ -545,7 +546,7 @@ WebGLContext::DrawArraysInstanced(GLenum mode, GLint first, GLsizei vertCount,
|
|||
|
||||
const auto totalVertCount_safe = CheckedInt<uint32_t>(first) + vertCount;
|
||||
if (!totalVertCount_safe.isValid()) {
|
||||
ErrorOutOfMemory("%s: `first+vertCount` out of range.", funcName);
|
||||
ErrorOutOfMemory("`first+vertCount` out of range.");
|
||||
return;
|
||||
}
|
||||
auto totalVertCount = totalVertCount_safe.value();
|
||||
|
@ -553,23 +554,23 @@ WebGLContext::DrawArraysInstanced(GLenum mode, GLint first, GLsizei vertCount,
|
|||
if (vertCount && instanceCount &&
|
||||
totalVertCount > fetchLimits->maxVerts)
|
||||
{
|
||||
ErrorInvalidOperation("%s: Vertex fetch requires %u, but attribs only supply %u.",
|
||||
funcName, totalVertCount, uint32_t(fetchLimits->maxVerts));
|
||||
ErrorInvalidOperation("Vertex fetch requires %u, but attribs only supply %u.",
|
||||
totalVertCount, uint32_t(fetchLimits->maxVerts));
|
||||
return;
|
||||
}
|
||||
|
||||
// -
|
||||
|
||||
bool error = false;
|
||||
const ScopedFakeVertexAttrib0 attrib0(this, funcName, totalVertCount, &error);
|
||||
const ScopedFakeVertexAttrib0 attrib0(this, totalVertCount, &error);
|
||||
if (error)
|
||||
return;
|
||||
|
||||
const ScopedResolveTexturesForDraw scopedResolve(this, funcName, &error);
|
||||
const ScopedResolveTexturesForDraw scopedResolve(this, &error);
|
||||
if (error)
|
||||
return;
|
||||
|
||||
const ScopedDrawWithTransformFeedback scopedTF(this, funcName, mode, vertCount,
|
||||
const ScopedDrawWithTransformFeedback scopedTF(this, mode, vertCount,
|
||||
instanceCount, &error);
|
||||
if (error)
|
||||
return;
|
||||
|
@ -587,14 +588,14 @@ WebGLContext::DrawArraysInstanced(GLenum mode, GLint first, GLsizei vertCount,
|
|||
}
|
||||
}
|
||||
|
||||
Draw_cleanup(funcName);
|
||||
Draw_cleanup();
|
||||
scopedTF.Advance();
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
|
||||
WebGLBuffer*
|
||||
WebGLContext::DrawElements_check(const char* const funcName, const GLsizei rawIndexCount,
|
||||
WebGLContext::DrawElements_check(const GLsizei rawIndexCount,
|
||||
const GLenum type, const WebGLintptr byteOffset,
|
||||
const GLsizei instanceCount)
|
||||
{
|
||||
|
@ -602,15 +603,14 @@ WebGLContext::DrawElements_check(const char* const funcName, const GLsizei rawIn
|
|||
mBoundTransformFeedback->mIsActive &&
|
||||
!mBoundTransformFeedback->mIsPaused)
|
||||
{
|
||||
ErrorInvalidOperation("%s: DrawElements* functions are incompatible with"
|
||||
" transform feedback.",
|
||||
funcName);
|
||||
ErrorInvalidOperation("DrawElements* functions are incompatible with"
|
||||
" transform feedback.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!ValidateNonNegative(funcName, "vertCount", rawIndexCount) ||
|
||||
!ValidateNonNegative(funcName, "byteOffset", byteOffset) ||
|
||||
!ValidateNonNegative(funcName, "instanceCount", instanceCount))
|
||||
if (!ValidateNonNegative("vertCount", rawIndexCount) ||
|
||||
!ValidateNonNegative("byteOffset", byteOffset) ||
|
||||
!ValidateNonNegative("instanceCount", instanceCount))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -633,12 +633,11 @@ WebGLContext::DrawElements_check(const char* const funcName, const GLsizei rawIn
|
|||
break;
|
||||
}
|
||||
if (!bytesPerIndex) {
|
||||
ErrorInvalidEnum("%s: Invalid `type`: 0x%04x", funcName, type);
|
||||
ErrorInvalidEnumInfo("type", type);
|
||||
return nullptr;
|
||||
}
|
||||
if (byteOffset % bytesPerIndex != 0) {
|
||||
ErrorInvalidOperation("%s: `byteOffset` must be a multiple of the size of `type`",
|
||||
funcName);
|
||||
ErrorInvalidOperation("`byteOffset` must be a multiple of the size of `type`");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -660,7 +659,7 @@ WebGLContext::DrawElements_check(const char* const funcName, const GLsizei rawIn
|
|||
|
||||
const auto& indexBuffer = mBoundVertexArray->mElementArrayBuffer;
|
||||
if (!indexBuffer) {
|
||||
ErrorInvalidOperation("%s: Index buffer not bound.", funcName);
|
||||
ErrorInvalidOperation("Index buffer not bound.");
|
||||
return nullptr;
|
||||
}
|
||||
MOZ_ASSERT(!indexBuffer->IsBoundForTF(), "This should be impossible.");
|
||||
|
@ -669,7 +668,7 @@ WebGLContext::DrawElements_check(const char* const funcName, const GLsizei rawIn
|
|||
const auto availIndices = AvailGroups(availBytes, byteOffset, bytesPerIndex,
|
||||
bytesPerIndex);
|
||||
if (instanceCount && indexCount > availIndices) {
|
||||
ErrorInvalidOperation("%s: Index buffer too small.", funcName);
|
||||
ErrorInvalidOperation("Index buffer too small.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -677,44 +676,43 @@ WebGLContext::DrawElements_check(const char* const funcName, const GLsizei rawIn
|
|||
}
|
||||
|
||||
static void
|
||||
HandleDrawElementsErrors(WebGLContext* webgl, const char* funcName,
|
||||
HandleDrawElementsErrors(WebGLContext* webgl,
|
||||
gl::GLContext::LocalErrorScope& errorScope)
|
||||
{
|
||||
const auto err = errorScope.GetError();
|
||||
if (err == LOCAL_GL_INVALID_OPERATION) {
|
||||
webgl->ErrorInvalidOperation("%s: Driver rejected indexed draw call, possibly"
|
||||
" due to out-of-bounds indices.", funcName);
|
||||
webgl->ErrorInvalidOperation("Driver rejected indexed draw call, possibly"
|
||||
" due to out-of-bounds indices.");
|
||||
return;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!err);
|
||||
if (err) {
|
||||
webgl->ErrorImplementationBug("%s: Unexpected driver error during indexed draw"
|
||||
" call. Please file a bug.",
|
||||
funcName);
|
||||
webgl->ErrorImplementationBug("Unexpected driver error during indexed draw"
|
||||
" call. Please file a bug.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::DrawElementsInstanced(GLenum mode, GLsizei indexCount, GLenum type,
|
||||
WebGLintptr byteOffset, GLsizei instanceCount,
|
||||
const char* const funcName)
|
||||
WebGLintptr byteOffset, GLsizei instanceCount)
|
||||
{
|
||||
const FuncScope funcScope(*this, "drawElementsInstanced");
|
||||
AUTO_PROFILER_LABEL("WebGLContext::DrawElementsInstanced", GRAPHICS);
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
const gl::GLContext::TlsScope inTls(gl);
|
||||
|
||||
const auto indexBuffer = DrawElements_check(funcName, indexCount, type, byteOffset,
|
||||
const auto indexBuffer = DrawElements_check(indexCount, type, byteOffset,
|
||||
instanceCount);
|
||||
if (!indexBuffer)
|
||||
return;
|
||||
|
||||
// -
|
||||
|
||||
const auto fetchLimits = ValidateDraw(this, funcName, mode, instanceCount);
|
||||
const auto fetchLimits = ValidateDraw(this, mode, instanceCount);
|
||||
if (!fetchLimits)
|
||||
return;
|
||||
|
||||
|
@ -760,9 +758,9 @@ WebGLContext::DrawElementsInstanced(GLenum mode, GLsizei indexCount, GLenum type
|
|||
return maxVertId < fetchLimits->maxVerts;
|
||||
}();
|
||||
if (!isFetchValid) {
|
||||
ErrorInvalidOperation("%s: Indexed vertex fetch requires %u vertices, but"
|
||||
ErrorInvalidOperation("Indexed vertex fetch requires %u vertices, but"
|
||||
" attribs only supply %u.",
|
||||
funcName, maxVertId+1, uint32_t(fetchLimits->maxVerts));
|
||||
maxVertId+1, uint32_t(fetchLimits->maxVerts));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -770,11 +768,11 @@ WebGLContext::DrawElementsInstanced(GLenum mode, GLsizei indexCount, GLenum type
|
|||
// -
|
||||
|
||||
bool error = false;
|
||||
const ScopedFakeVertexAttrib0 attrib0(this, funcName, fakeVertCount, &error);
|
||||
const ScopedFakeVertexAttrib0 attrib0(this, fakeVertCount, &error);
|
||||
if (error)
|
||||
return;
|
||||
|
||||
const ScopedResolveTexturesForDraw scopedResolve(this, funcName, &error);
|
||||
const ScopedResolveTexturesForDraw scopedResolve(this, &error);
|
||||
if (error)
|
||||
return;
|
||||
|
||||
|
@ -812,18 +810,18 @@ WebGLContext::DrawElementsInstanced(GLenum mode, GLsizei indexCount, GLenum type
|
|||
}
|
||||
|
||||
if (errorScope) {
|
||||
HandleDrawElementsErrors(this, funcName, *errorScope);
|
||||
HandleDrawElementsErrors(this, *errorScope);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Draw_cleanup(funcName);
|
||||
Draw_cleanup();
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
|
||||
void
|
||||
WebGLContext::Draw_cleanup(const char* funcName)
|
||||
WebGLContext::Draw_cleanup()
|
||||
{
|
||||
if (gl->WorkAroundDriverBugs()) {
|
||||
if (gl->Renderer() == gl::GLRenderer::Tegra) {
|
||||
|
@ -858,9 +856,8 @@ WebGLContext::Draw_cleanup(const char* funcName)
|
|||
mViewportHeight > int32_t(destHeight))
|
||||
{
|
||||
if (!mAlreadyWarnedAboutViewportLargerThanDest) {
|
||||
GenerateWarning("%s: Drawing to a destination rect smaller than the viewport"
|
||||
" rect. (This warning will only be given once)",
|
||||
funcName);
|
||||
GenerateWarning("Drawing to a destination rect smaller than the viewport"
|
||||
" rect. (This warning will only be given once)");
|
||||
mAlreadyWarnedAboutViewportLargerThanDest = true;
|
||||
}
|
||||
}
|
||||
|
@ -895,7 +892,7 @@ WebGLContext::WhatDoesVertexAttrib0Need() const
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLContext::DoFakeVertexAttrib0(const char* const funcName, const uint64_t vertexCount)
|
||||
WebGLContext::DoFakeVertexAttrib0(const uint64_t vertexCount)
|
||||
{
|
||||
const auto whatDoesAttrib0Need = WhatDoesVertexAttrib0Need();
|
||||
if (MOZ_LIKELY(whatDoesAttrib0Need == WebGLVertexAttrib0Status::Default))
|
||||
|
@ -971,8 +968,7 @@ WebGLContext::DoFakeVertexAttrib0(const char* const funcName, const uint64_t ver
|
|||
|
||||
const UniqueBuffer data(malloc(dataSize));
|
||||
if (!data) {
|
||||
ErrorOutOfMemory("%s: Failed to allocate fake vertex attrib 0 array.",
|
||||
funcName);
|
||||
ErrorOutOfMemory("Failed to allocate fake vertex attrib 0 array.");
|
||||
return false;
|
||||
}
|
||||
auto itr = (uint8_t*)data.get();
|
||||
|
@ -989,7 +985,7 @@ WebGLContext::DoFakeVertexAttrib0(const char* const funcName, const uint64_t ver
|
|||
|
||||
const auto err = errorScope.GetError();
|
||||
if (err) {
|
||||
ErrorOutOfMemory("%s: Failed to upload fake vertex attrib 0 data.", funcName);
|
||||
ErrorOutOfMemory("Failed to upload fake vertex attrib 0 data.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -262,7 +262,7 @@ WebGLContext::GetExtension(JSContext* cx,
|
|||
ErrorResult& rv)
|
||||
{
|
||||
retval.set(nullptr);
|
||||
|
||||
const FuncScope funcScope(*this, "getExtension");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
|
@ -430,6 +430,7 @@ WebGLContext::GetSupportedExtensions(dom::Nullable< nsTArray<nsString> >& retval
|
|||
dom::CallerType callerType)
|
||||
{
|
||||
retval.SetNull();
|
||||
const FuncScope funcScope(*this, "getSupportedExtensions");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
|
|
|
@ -15,14 +15,13 @@ namespace mozilla {
|
|||
void
|
||||
WebGLContext::Clear(GLbitfield mask)
|
||||
{
|
||||
const char funcName[] = "clear";
|
||||
|
||||
const FuncScope funcScope(*this, "clear");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
uint32_t m = mask & (LOCAL_GL_COLOR_BUFFER_BIT | LOCAL_GL_DEPTH_BUFFER_BIT | LOCAL_GL_STENCIL_BUFFER_BIT);
|
||||
if (mask != m)
|
||||
return ErrorInvalidValue("%s: invalid mask bits", funcName);
|
||||
return ErrorInvalidValue("Invalid mask bits.");
|
||||
|
||||
if (mask == 0) {
|
||||
GenerateWarning("Calling gl.clear(0) has no effect.");
|
||||
|
@ -43,16 +42,15 @@ WebGLContext::Clear(GLbitfield mask)
|
|||
break;
|
||||
|
||||
default:
|
||||
ErrorInvalidOperation("%s: Color draw buffers must be floating-point"
|
||||
" or fixed-point. (normalized (u)ints)",
|
||||
funcName);
|
||||
ErrorInvalidOperation("Color draw buffers must be floating-point"
|
||||
" or fixed-point. (normalized (u)ints)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!BindCurFBForDraw(funcName))
|
||||
if (!BindCurFBForDraw())
|
||||
return;
|
||||
|
||||
auto driverMask = mask;
|
||||
|
@ -84,6 +82,7 @@ GLClampFloat(GLfloat val)
|
|||
void
|
||||
WebGLContext::ClearColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
|
||||
{
|
||||
const FuncScope funcScope(*this, "clearColor");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
|
@ -108,6 +107,7 @@ WebGLContext::ClearColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
|
|||
void
|
||||
WebGLContext::ClearDepth(GLclampf v)
|
||||
{
|
||||
const FuncScope funcScope(*this, "clearDepth");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
|
@ -118,6 +118,7 @@ WebGLContext::ClearDepth(GLclampf v)
|
|||
void
|
||||
WebGLContext::ClearStencil(GLint v)
|
||||
{
|
||||
const FuncScope funcScope(*this, "clearStencil");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
|
@ -128,6 +129,7 @@ WebGLContext::ClearStencil(GLint v)
|
|||
void
|
||||
WebGLContext::ColorMask(WebGLboolean r, WebGLboolean g, WebGLboolean b, WebGLboolean a)
|
||||
{
|
||||
const FuncScope funcScope(*this, "colorMask");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
|
@ -140,6 +142,7 @@ WebGLContext::ColorMask(WebGLboolean r, WebGLboolean g, WebGLboolean b, WebGLboo
|
|||
void
|
||||
WebGLContext::DepthMask(WebGLboolean b)
|
||||
{
|
||||
const FuncScope funcScope(*this, "depthMask");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
|
@ -150,12 +153,12 @@ WebGLContext::DepthMask(WebGLboolean b)
|
|||
void
|
||||
WebGLContext::DrawBuffers(const dom::Sequence<GLenum>& buffers)
|
||||
{
|
||||
const char funcName[] = "drawBuffers";
|
||||
const FuncScope funcScope(*this, "drawBuffers");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (mBoundDrawFramebuffer) {
|
||||
mBoundDrawFramebuffer->DrawBuffers(funcName, buffers);
|
||||
mBoundDrawFramebuffer->DrawBuffers(buffers);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -165,9 +168,8 @@ WebGLContext::DrawBuffers(const dom::Sequence<GLenum>& buffers)
|
|||
// constant other than BACK and NONE, or with a value of `n` other than 1, the
|
||||
// error INVALID_OPERATION is generated."
|
||||
if (buffers.Length() != 1) {
|
||||
ErrorInvalidOperation("%s: For the default framebuffer, `buffers` must have a"
|
||||
" length of 1.",
|
||||
funcName);
|
||||
ErrorInvalidOperation("For the default framebuffer, `buffers` must have a"
|
||||
" length of 1.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -177,9 +179,8 @@ WebGLContext::DrawBuffers(const dom::Sequence<GLenum>& buffers)
|
|||
break;
|
||||
|
||||
default:
|
||||
ErrorInvalidOperation("%s: For the default framebuffer, `buffers[0]` must be"
|
||||
" BACK or NONE.",
|
||||
funcName);
|
||||
ErrorInvalidOperation("For the default framebuffer, `buffers[0]` must be"
|
||||
" BACK or NONE.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -190,6 +191,7 @@ WebGLContext::DrawBuffers(const dom::Sequence<GLenum>& buffers)
|
|||
void
|
||||
WebGLContext::StencilMask(GLuint mask)
|
||||
{
|
||||
const FuncScope funcScope(*this, "stencilMask");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
|
@ -202,10 +204,11 @@ WebGLContext::StencilMask(GLuint mask)
|
|||
void
|
||||
WebGLContext::StencilMaskSeparate(GLenum face, GLuint mask)
|
||||
{
|
||||
const FuncScope funcScope(*this, "stencilMaskSeparate");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateFaceEnum(face, "stencilMaskSeparate: face"))
|
||||
if (!ValidateFaceEnum(face))
|
||||
return;
|
||||
|
||||
switch (face) {
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -26,10 +26,11 @@ namespace mozilla {
|
|||
void
|
||||
WebGLContext::SetEnabled(const char* const funcName, const GLenum cap, const bool enabled)
|
||||
{
|
||||
const FuncScope funcScope(*this, funcName);
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateCapabilityEnum(cap, funcName))
|
||||
if (!ValidateCapabilityEnum(cap))
|
||||
return;
|
||||
|
||||
const auto& slot = GetStateTrackingSlot(cap);
|
||||
|
@ -77,7 +78,7 @@ WebGLContext::GetStencilBits(GLint* const out_stencilBits) const
|
|||
JS::Value
|
||||
WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
|
||||
{
|
||||
const char funcName[] = "getParameter";
|
||||
const FuncScope funcScope(*this, "getParameter");
|
||||
|
||||
if (IsContextLost())
|
||||
return JS::NullValue();
|
||||
|
@ -247,7 +248,7 @@ WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
|
|||
case LOCAL_GL_IMPLEMENTATION_COLOR_READ_TYPE: {
|
||||
const webgl::FormatUsageInfo* usage;
|
||||
uint32_t width, height;
|
||||
if (!BindCurFBForColorRead(funcName, &usage, &width, &height))
|
||||
if (!BindCurFBForColorRead(&usage, &width, &height))
|
||||
return JS::NullValue();
|
||||
|
||||
const auto implPI = ValidImplementationColorReadPI(usage);
|
||||
|
@ -282,12 +283,12 @@ WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
|
|||
const auto& fb = mBoundDrawFramebuffer;
|
||||
auto samples = [&]() -> Maybe<uint32_t> {
|
||||
if (!fb) {
|
||||
if (!EnsureDefaultFB(funcName))
|
||||
if (!EnsureDefaultFB())
|
||||
return Nothing();
|
||||
return Some(mDefaultFB->mSamples);
|
||||
}
|
||||
|
||||
if (!fb->IsCheckFramebufferStatusComplete(funcName))
|
||||
if (!fb->IsCheckFramebufferStatusComplete())
|
||||
return Some(0);
|
||||
|
||||
DoBindFB(fb, LOCAL_GL_FRAMEBUFFER);
|
||||
|
@ -590,7 +591,7 @@ WebGLContext::GetParameter(JSContext* cx, GLenum pname, ErrorResult& rv)
|
|||
break;
|
||||
}
|
||||
|
||||
ErrorInvalidEnumInfo("getParameter: parameter", pname);
|
||||
ErrorInvalidEnumInfo("pname", pname);
|
||||
return JS::NullValue();
|
||||
}
|
||||
|
||||
|
@ -598,6 +599,7 @@ void
|
|||
WebGLContext::GetParameterIndexed(JSContext* cx, GLenum pname, GLuint index,
|
||||
JS::MutableHandle<JS::Value> retval)
|
||||
{
|
||||
const FuncScope funcScope(*this, "getParameterIndexed");
|
||||
if (IsContextLost()) {
|
||||
retval.setNull();
|
||||
return;
|
||||
|
@ -607,7 +609,7 @@ WebGLContext::GetParameterIndexed(JSContext* cx, GLenum pname, GLuint index,
|
|||
case LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
|
||||
{
|
||||
if (index >= mGLMaxTransformFeedbackSeparateAttribs) {
|
||||
ErrorInvalidValue("getParameterIndexed: index should be less than MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS");
|
||||
ErrorInvalidValue("`index` should be less than MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS");
|
||||
retval.setNull();
|
||||
return;
|
||||
}
|
||||
|
@ -619,17 +621,18 @@ WebGLContext::GetParameterIndexed(JSContext* cx, GLenum pname, GLuint index,
|
|||
break;
|
||||
}
|
||||
|
||||
ErrorInvalidEnumInfo("getParameterIndexed: parameter", pname);
|
||||
ErrorInvalidEnumInfo("pname", pname);
|
||||
retval.setNull();
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::IsEnabled(GLenum cap)
|
||||
{
|
||||
const FuncScope funcScope(*this, "isEnabled");
|
||||
if (IsContextLost())
|
||||
return false;
|
||||
|
||||
if (!ValidateCapabilityEnum(cap, "isEnabled"))
|
||||
if (!ValidateCapabilityEnum(cap))
|
||||
return false;
|
||||
|
||||
const auto& slot = GetStateTrackingSlot(cap);
|
||||
|
@ -640,7 +643,7 @@ WebGLContext::IsEnabled(GLenum cap)
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateCapabilityEnum(GLenum cap, const char* info)
|
||||
WebGLContext::ValidateCapabilityEnum(GLenum cap)
|
||||
{
|
||||
switch (cap) {
|
||||
case LOCAL_GL_BLEND:
|
||||
|
@ -656,7 +659,7 @@ WebGLContext::ValidateCapabilityEnum(GLenum cap, const char* info)
|
|||
case LOCAL_GL_RASTERIZER_DISCARD:
|
||||
return IsWebGL2();
|
||||
default:
|
||||
ErrorInvalidEnumInfo(info, cap);
|
||||
ErrorInvalidEnumInfo("cap", cap);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ IsValidTexImageTarget(WebGLContext* webgl, uint8_t funcDims, GLenum rawTexImageT
|
|||
}
|
||||
|
||||
bool
|
||||
ValidateTexTarget(WebGLContext* webgl, const char* funcName, uint8_t funcDims,
|
||||
ValidateTexTarget(WebGLContext* webgl, uint8_t funcDims,
|
||||
GLenum rawTexTarget, TexTarget* const out_texTarget,
|
||||
WebGLTexture** const out_tex)
|
||||
{
|
||||
|
@ -129,13 +129,13 @@ ValidateTexTarget(WebGLContext* webgl, const char* funcName, uint8_t funcDims,
|
|||
|
||||
TexTarget texTarget;
|
||||
if (!IsValidTexTarget(webgl, funcDims, rawTexTarget, &texTarget)) {
|
||||
webgl->ErrorInvalidEnum("%s: Invalid texTarget.", funcName);
|
||||
webgl->ErrorInvalidEnumInfo("texTarget", rawTexTarget);
|
||||
return false;
|
||||
}
|
||||
|
||||
WebGLTexture* tex = webgl->ActiveBoundTextureForTarget(texTarget);
|
||||
if (!tex) {
|
||||
webgl->ErrorInvalidOperation("%s: No texture is bound to this target.", funcName);
|
||||
webgl->ErrorInvalidOperation("No texture is bound to this target.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ ValidateTexTarget(WebGLContext* webgl, const char* funcName, uint8_t funcDims,
|
|||
}
|
||||
|
||||
bool
|
||||
ValidateTexImageTarget(WebGLContext* webgl, const char* funcName, uint8_t funcDims,
|
||||
ValidateTexImageTarget(WebGLContext* webgl, uint8_t funcDims,
|
||||
GLenum rawTexImageTarget, TexImageTarget* const out_texImageTarget,
|
||||
WebGLTexture** const out_tex)
|
||||
{
|
||||
|
@ -154,13 +154,13 @@ ValidateTexImageTarget(WebGLContext* webgl, const char* funcName, uint8_t funcDi
|
|||
|
||||
TexImageTarget texImageTarget;
|
||||
if (!IsValidTexImageTarget(webgl, funcDims, rawTexImageTarget, &texImageTarget)) {
|
||||
webgl->ErrorInvalidEnum("%s: Invalid texImageTarget.", funcName);
|
||||
webgl->ErrorInvalidEnumInfo("texImageTarget", rawTexImageTarget);
|
||||
return false;
|
||||
}
|
||||
|
||||
WebGLTexture* tex = webgl->ActiveBoundTextureForTexImageTarget(texImageTarget);
|
||||
if (!tex) {
|
||||
webgl->ErrorInvalidOperation("%s: No texture is bound to this target.", funcName);
|
||||
webgl->ErrorInvalidOperation("No texture is bound to this target.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -206,10 +206,11 @@ WebGLContext::InvalidateResolveCacheForTextureWithTexUnit(const GLuint texUnit)
|
|||
void
|
||||
WebGLContext::BindTexture(GLenum rawTarget, WebGLTexture* newTex)
|
||||
{
|
||||
const FuncScope funcScope(*this, "bindTexture");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (newTex && !ValidateObject("bindTexture", *newTex))
|
||||
if (newTex && !ValidateObject("tex", *newTex))
|
||||
return;
|
||||
|
||||
// Need to check rawTarget first before comparing against newTex->Target() as
|
||||
|
@ -236,7 +237,7 @@ WebGLContext::BindTexture(GLenum rawTarget, WebGLTexture* newTex)
|
|||
}
|
||||
|
||||
if (!currentTexPtr) {
|
||||
ErrorInvalidEnumInfo("bindTexture: target", rawTarget);
|
||||
ErrorInvalidEnumInfo("target", rawTarget);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -254,12 +255,12 @@ WebGLContext::BindTexture(GLenum rawTarget, WebGLTexture* newTex)
|
|||
void
|
||||
WebGLContext::GenerateMipmap(GLenum rawTexTarget)
|
||||
{
|
||||
const char funcName[] = "generateMipmap";
|
||||
const FuncScope funcScope(*this, "generateMipmap");
|
||||
const uint8_t funcDims = 0;
|
||||
|
||||
TexTarget texTarget;
|
||||
WebGLTexture* tex;
|
||||
if (!ValidateTexTarget(this, funcName, funcDims, rawTexTarget, &texTarget, &tex))
|
||||
if (!ValidateTexTarget(this, funcDims, rawTexTarget, &texTarget, &tex))
|
||||
return;
|
||||
|
||||
tex->GenerateMipmap(texTarget);
|
||||
|
@ -268,41 +269,32 @@ WebGLContext::GenerateMipmap(GLenum rawTexTarget)
|
|||
JS::Value
|
||||
WebGLContext::GetTexParameter(GLenum rawTexTarget, GLenum pname)
|
||||
{
|
||||
const char funcName[] = "getTexParameter";
|
||||
const FuncScope funcScope(*this, "getTexParameter");
|
||||
const uint8_t funcDims = 0;
|
||||
|
||||
TexTarget texTarget;
|
||||
WebGLTexture* tex;
|
||||
if (!ValidateTexTarget(this, funcName, funcDims, rawTexTarget, &texTarget, &tex))
|
||||
if (!ValidateTexTarget(this, funcDims, rawTexTarget, &texTarget, &tex))
|
||||
return JS::NullValue();
|
||||
|
||||
if (!IsTexParamValid(pname)) {
|
||||
ErrorInvalidEnumInfo("getTexParameter: pname", pname);
|
||||
ErrorInvalidEnumInfo("pname", pname);
|
||||
return JS::NullValue();
|
||||
}
|
||||
|
||||
return tex->GetTexParameter(texTarget, pname);
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::IsTexture(WebGLTexture* tex)
|
||||
{
|
||||
if (!ValidateIsObject("isTexture", tex))
|
||||
return false;
|
||||
|
||||
return tex->IsTexture();
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::TexParameter_base(GLenum rawTexTarget, GLenum pname,
|
||||
const FloatOrInt& param)
|
||||
{
|
||||
const char funcName[] = "texParameter";
|
||||
const FuncScope funcScope(*this, "texParameter");
|
||||
const uint8_t funcDims = 0;
|
||||
|
||||
TexTarget texTarget;
|
||||
WebGLTexture* tex;
|
||||
if (!ValidateTexTarget(this, funcName, funcDims, rawTexTarget, &texTarget, &tex))
|
||||
if (!ValidateTexTarget(this, funcDims, rawTexTarget, &texTarget, &tex))
|
||||
return;
|
||||
|
||||
tex->TexParameter(texTarget, pname, param);
|
||||
|
@ -312,22 +304,22 @@ WebGLContext::TexParameter_base(GLenum rawTexTarget, GLenum pname,
|
|||
// Uploads
|
||||
|
||||
void
|
||||
WebGLContext::CompressedTexImage(const char* funcName, uint8_t funcDims, GLenum rawTarget,
|
||||
WebGLContext::CompressedTexImage(uint8_t funcDims, GLenum rawTarget,
|
||||
GLint level, GLenum internalFormat, GLsizei width,
|
||||
GLsizei height, GLsizei depth, GLint border,
|
||||
const TexImageSource& src, const Maybe<GLsizei>& expectedImageSize)
|
||||
{
|
||||
TexImageTarget target;
|
||||
WebGLTexture* tex;
|
||||
if (!ValidateTexImageTarget(this, funcName, funcDims, rawTarget, &target, &tex))
|
||||
if (!ValidateTexImageTarget(this, funcDims, rawTarget, &target, &tex))
|
||||
return;
|
||||
|
||||
tex->CompressedTexImage(funcName, target, level, internalFormat, width, height, depth,
|
||||
tex->CompressedTexImage(target, level, internalFormat, width, height, depth,
|
||||
border, src, expectedImageSize);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::CompressedTexSubImage(const char* funcName, uint8_t funcDims,
|
||||
WebGLContext::CompressedTexSubImage(uint8_t funcDims,
|
||||
GLenum rawTarget, GLint level, GLint xOffset,
|
||||
GLint yOffset, GLint zOffset, GLsizei width,
|
||||
GLsizei height, GLsizei depth, GLenum unpackFormat,
|
||||
|
@ -335,10 +327,10 @@ WebGLContext::CompressedTexSubImage(const char* funcName, uint8_t funcDims,
|
|||
{
|
||||
TexImageTarget target;
|
||||
WebGLTexture* tex;
|
||||
if (!ValidateTexImageTarget(this, funcName, funcDims, rawTarget, &target, &tex))
|
||||
if (!ValidateTexImageTarget(this, funcDims, rawTarget, &target, &tex))
|
||||
return;
|
||||
|
||||
tex->CompressedTexSubImage(funcName, target, level, xOffset, yOffset, zOffset, width,
|
||||
tex->CompressedTexSubImage(target, level, xOffset, yOffset, zOffset, width,
|
||||
height, depth, unpackFormat, src, expectedImageSize);
|
||||
}
|
||||
|
||||
|
@ -349,51 +341,51 @@ WebGLContext::CopyTexImage2D(GLenum rawTarget, GLint level, GLenum internalForma
|
|||
GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
GLint border)
|
||||
{
|
||||
const char funcName[] = "copyTexImage2D";
|
||||
const FuncScope funcScope(*this, "copyTexImage2D");
|
||||
const uint8_t funcDims = 2;
|
||||
|
||||
TexImageTarget target;
|
||||
WebGLTexture* tex;
|
||||
if (!ValidateTexImageTarget(this, funcName, funcDims, rawTarget, &target, &tex))
|
||||
if (!ValidateTexImageTarget(this, funcDims, rawTarget, &target, &tex))
|
||||
return;
|
||||
|
||||
tex->CopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::CopyTexSubImage(const char* funcName, uint8_t funcDims, GLenum rawTarget,
|
||||
WebGLContext::CopyTexSubImage(uint8_t funcDims, GLenum rawTarget,
|
||||
GLint level, GLint xOffset, GLint yOffset, GLint zOffset,
|
||||
GLint x, GLint y, GLsizei width, GLsizei height)
|
||||
{
|
||||
TexImageTarget target;
|
||||
WebGLTexture* tex;
|
||||
if (!ValidateTexImageTarget(this, funcName, funcDims, rawTarget, &target, &tex))
|
||||
if (!ValidateTexImageTarget(this, funcDims, rawTarget, &target, &tex))
|
||||
return;
|
||||
|
||||
tex->CopyTexSubImage(funcName, target, level, xOffset, yOffset, zOffset, x, y, width,
|
||||
tex->CopyTexSubImage(target, level, xOffset, yOffset, zOffset, x, y, width,
|
||||
height);
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
void
|
||||
WebGLContext::TexImage(const char* funcName, uint8_t funcDims, GLenum rawTarget,
|
||||
WebGLContext::TexImage(uint8_t funcDims, GLenum rawTarget,
|
||||
GLint level, GLenum internalFormat, GLsizei width, GLsizei height,
|
||||
GLsizei depth, GLint border, GLenum unpackFormat,
|
||||
GLenum unpackType, const TexImageSource& src)
|
||||
{
|
||||
TexImageTarget target;
|
||||
WebGLTexture* tex;
|
||||
if (!ValidateTexImageTarget(this, funcName, funcDims, rawTarget, &target, &tex))
|
||||
if (!ValidateTexImageTarget(this, funcDims, rawTarget, &target, &tex))
|
||||
return;
|
||||
|
||||
const webgl::PackingInfo pi = {unpackFormat, unpackType};
|
||||
tex->TexImage(funcName, target, level, internalFormat, width, height, depth, border,
|
||||
tex->TexImage(target, level, internalFormat, width, height, depth, border,
|
||||
pi, src);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::TexSubImage(const char* funcName, uint8_t funcDims, GLenum rawTarget,
|
||||
WebGLContext::TexSubImage(uint8_t funcDims, GLenum rawTarget,
|
||||
GLint level, GLint xOffset, GLint yOffset, GLint zOffset,
|
||||
GLsizei width, GLsizei height, GLsizei depth,
|
||||
GLenum unpackFormat, GLenum unpackType,
|
||||
|
@ -401,11 +393,11 @@ WebGLContext::TexSubImage(const char* funcName, uint8_t funcDims, GLenum rawTarg
|
|||
{
|
||||
TexImageTarget target;
|
||||
WebGLTexture* tex;
|
||||
if (!ValidateTexImageTarget(this, funcName, funcDims, rawTarget, &target, &tex))
|
||||
if (!ValidateTexImageTarget(this, funcDims, rawTarget, &target, &tex))
|
||||
return;
|
||||
|
||||
const webgl::PackingInfo pi = {unpackFormat, unpackType};
|
||||
tex->TexSubImage(funcName, target, level, xOffset, yOffset, zOffset, width, height,
|
||||
tex->TexSubImage(target, level, xOffset, yOffset, zOffset, width, height,
|
||||
depth, pi, src);
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,8 @@ WebGLContext::GenerateWarning(const char* fmt, va_list ap) const
|
|||
}
|
||||
|
||||
JSContext* cx = api.cx();
|
||||
JS_ReportWarningASCII(cx, "WebGL warning: %s", buf);
|
||||
const auto funcName = FuncName();
|
||||
JS_ReportWarningASCII(cx, "WebGL warning: %s: %s", funcName, buf);
|
||||
if (!ShouldGenerateWarnings()) {
|
||||
JS_ReportWarningASCII(cx,
|
||||
"WebGL: No further warnings will be reported for"
|
||||
|
@ -134,7 +135,8 @@ WebGLContext::GeneratePerfWarning(const char* fmt, ...) const
|
|||
|
||||
////
|
||||
|
||||
JS_ReportWarningASCII(cx, "WebGL perf warning: %s", buf);
|
||||
const auto funcName = FuncName();
|
||||
JS_ReportWarningASCII(cx, "WebGL perf warning: %s: %s", funcName, buf);
|
||||
mNumPerfWarnings++;
|
||||
|
||||
if (!ShouldGeneratePerfWarnings()) {
|
||||
|
@ -189,17 +191,6 @@ WebGLContext::ErrorInvalidEnumInfo(const char* info, GLenum enumValue) const
|
|||
return ErrorInvalidEnum("%s: invalid enum value %s", info, name.BeginReading());
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::ErrorInvalidEnumInfo(const char* info, const char* funcName,
|
||||
GLenum enumValue) const
|
||||
{
|
||||
nsCString name;
|
||||
EnumName(enumValue, &name);
|
||||
|
||||
ErrorInvalidEnum("%s: %s: Invalid enum: 0x%04x (%s).", funcName, info,
|
||||
enumValue, name.BeginReading());
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::ErrorInvalidOperation(const char* fmt, ...) const
|
||||
{
|
||||
|
@ -283,8 +274,8 @@ WebGLContext::ErrorName(GLenum error)
|
|||
}
|
||||
|
||||
// This version is fallible and will return nullptr if unrecognized.
|
||||
static const char*
|
||||
GetEnumName(GLenum val)
|
||||
const char*
|
||||
GetEnumName(const GLenum val, const char* const defaultRet)
|
||||
{
|
||||
switch (val) {
|
||||
#define XX(x) case LOCAL_GL_##x: return #x
|
||||
|
@ -609,13 +600,13 @@ GetEnumName(GLenum val)
|
|||
#undef XX
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return defaultRet;
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
WebGLContext::EnumName(GLenum val, nsCString* out_name)
|
||||
{
|
||||
const char* name = GetEnumName(val);
|
||||
const char* name = GetEnumName(val, nullptr);
|
||||
if (name) {
|
||||
*out_name = name;
|
||||
return;
|
||||
|
@ -624,13 +615,24 @@ WebGLContext::EnumName(GLenum val, nsCString* out_name)
|
|||
*out_name = nsPrintfCString("<enum 0x%04x>", val);
|
||||
}
|
||||
|
||||
std::string
|
||||
EnumString(const GLenum val)
|
||||
{
|
||||
const char* name = GetEnumName(val, nullptr);
|
||||
if (name) {
|
||||
return name;
|
||||
}
|
||||
|
||||
const nsPrintfCString hex("<enum 0x%04x>", val);
|
||||
return hex.BeginReading();
|
||||
}
|
||||
|
||||
void
|
||||
WebGLContext::ErrorInvalidEnumArg(const char* funcName, const char* argName,
|
||||
GLenum val) const
|
||||
WebGLContext::ErrorInvalidEnumArg(const char* argName, GLenum val) const
|
||||
{
|
||||
nsCString enumName;
|
||||
EnumName(val, &enumName);
|
||||
ErrorInvalidEnum("%s: Bad `%s`: %s", funcName, argName, enumName.BeginReading());
|
||||
ErrorInvalidEnum("Bad `%s`: %s", argName, enumName.BeginReading());
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -147,26 +147,6 @@ WebGLContext::ValidateBlendFuncEnumsCompatibility(GLenum sfactor,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateComparisonEnum(GLenum target, const char* info)
|
||||
{
|
||||
switch (target) {
|
||||
case LOCAL_GL_NEVER:
|
||||
case LOCAL_GL_LESS:
|
||||
case LOCAL_GL_LEQUAL:
|
||||
case LOCAL_GL_GREATER:
|
||||
case LOCAL_GL_GEQUAL:
|
||||
case LOCAL_GL_EQUAL:
|
||||
case LOCAL_GL_NOTEQUAL:
|
||||
case LOCAL_GL_ALWAYS:
|
||||
return true;
|
||||
|
||||
default:
|
||||
ErrorInvalidEnumInfo(info, target);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateStencilOpEnum(GLenum action, const char* info)
|
||||
{
|
||||
|
@ -188,7 +168,7 @@ WebGLContext::ValidateStencilOpEnum(GLenum action, const char* info)
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateFaceEnum(GLenum face, const char* info)
|
||||
WebGLContext::ValidateFaceEnum(const GLenum face)
|
||||
{
|
||||
switch (face) {
|
||||
case LOCAL_GL_FRONT:
|
||||
|
@ -197,32 +177,13 @@ WebGLContext::ValidateFaceEnum(GLenum face, const char* info)
|
|||
return true;
|
||||
|
||||
default:
|
||||
ErrorInvalidEnumInfo(info, face);
|
||||
ErrorInvalidEnumInfo("face", face);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateDrawModeEnum(GLenum mode, const char* info)
|
||||
{
|
||||
switch (mode) {
|
||||
case LOCAL_GL_TRIANGLES:
|
||||
case LOCAL_GL_TRIANGLE_STRIP:
|
||||
case LOCAL_GL_TRIANGLE_FAN:
|
||||
case LOCAL_GL_POINTS:
|
||||
case LOCAL_GL_LINE_STRIP:
|
||||
case LOCAL_GL_LINE_LOOP:
|
||||
case LOCAL_GL_LINES:
|
||||
return true;
|
||||
|
||||
default:
|
||||
ErrorInvalidEnumInfo(info, mode);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateUniformLocation(WebGLUniformLocation* loc, const char* funcName)
|
||||
WebGLContext::ValidateUniformLocation(WebGLUniformLocation* loc)
|
||||
{
|
||||
/* GLES 2.0.25, p38:
|
||||
* If the value of location is -1, the Uniform* commands will silently
|
||||
|
@ -232,27 +193,25 @@ WebGLContext::ValidateUniformLocation(WebGLUniformLocation* loc, const char* fun
|
|||
if (!loc)
|
||||
return false;
|
||||
|
||||
if (!ValidateObjectAllowDeleted(funcName, *loc))
|
||||
if (!ValidateObjectAllowDeleted("loc", *loc))
|
||||
return false;
|
||||
|
||||
if (!mCurrentProgram) {
|
||||
ErrorInvalidOperation("%s: No program is currently bound.", funcName);
|
||||
ErrorInvalidOperation("No program is currently bound.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return loc->ValidateForProgram(mCurrentProgram, funcName);
|
||||
return loc->ValidateForProgram(mCurrentProgram);
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateAttribArraySetter(const char* name, uint32_t setterElemSize,
|
||||
uint32_t arrayLength)
|
||||
WebGLContext::ValidateAttribArraySetter(uint32_t setterElemSize, uint32_t arrayLength)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return false;
|
||||
|
||||
if (arrayLength < setterElemSize) {
|
||||
ErrorInvalidValue("%s: Array must have >= %d elements.", name,
|
||||
setterElemSize);
|
||||
ErrorInvalidValue("Array must have >= %d elements.", setterElemSize);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -261,16 +220,15 @@ WebGLContext::ValidateAttribArraySetter(const char* name, uint32_t setterElemSiz
|
|||
|
||||
bool
|
||||
WebGLContext::ValidateUniformSetter(WebGLUniformLocation* loc,
|
||||
uint8_t setterElemSize, GLenum setterType,
|
||||
const char* funcName)
|
||||
uint8_t setterElemSize, GLenum setterType)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return false;
|
||||
|
||||
if (!ValidateUniformLocation(loc, funcName))
|
||||
if (!ValidateUniformLocation(loc))
|
||||
return false;
|
||||
|
||||
if (!loc->ValidateSizeAndType(setterElemSize, setterType, funcName))
|
||||
if (!loc->ValidateSizeAndType(setterElemSize, setterType))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
@ -281,19 +239,18 @@ WebGLContext::ValidateUniformArraySetter(WebGLUniformLocation* loc,
|
|||
uint8_t setterElemSize,
|
||||
GLenum setterType,
|
||||
uint32_t setterArraySize,
|
||||
const char* funcName,
|
||||
uint32_t* const out_numElementsToUpload)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return false;
|
||||
|
||||
if (!ValidateUniformLocation(loc, funcName))
|
||||
if (!ValidateUniformLocation(loc))
|
||||
return false;
|
||||
|
||||
if (!loc->ValidateSizeAndType(setterElemSize, setterType, funcName))
|
||||
if (!loc->ValidateSizeAndType(setterElemSize, setterType))
|
||||
return false;
|
||||
|
||||
if (!loc->ValidateArrayLength(setterElemSize, setterArraySize, funcName))
|
||||
if (!loc->ValidateArrayLength(setterElemSize, setterArraySize))
|
||||
return false;
|
||||
|
||||
const auto& elemCount = loc->mInfo->mActiveInfo->mElemCount;
|
||||
|
@ -312,7 +269,6 @@ WebGLContext::ValidateUniformMatrixArraySetter(WebGLUniformLocation* loc,
|
|||
GLenum setterType,
|
||||
uint32_t setterArraySize,
|
||||
bool setterTranspose,
|
||||
const char* funcName,
|
||||
uint32_t* const out_numElementsToUpload)
|
||||
{
|
||||
const uint8_t setterElemSize = setterCols * setterRows;
|
||||
|
@ -320,17 +276,17 @@ WebGLContext::ValidateUniformMatrixArraySetter(WebGLUniformLocation* loc,
|
|||
if (IsContextLost())
|
||||
return false;
|
||||
|
||||
if (!ValidateUniformLocation(loc, funcName))
|
||||
if (!ValidateUniformLocation(loc))
|
||||
return false;
|
||||
|
||||
if (!loc->ValidateSizeAndType(setterElemSize, setterType, funcName))
|
||||
if (!loc->ValidateSizeAndType(setterElemSize, setterType))
|
||||
return false;
|
||||
|
||||
if (!loc->ValidateArrayLength(setterElemSize, setterArraySize, funcName))
|
||||
if (!loc->ValidateArrayLength(setterElemSize, setterArraySize))
|
||||
return false;
|
||||
|
||||
if (setterTranspose && !IsWebGL2()) {
|
||||
ErrorInvalidValue("%s: `transpose` must be false.", funcName);
|
||||
ErrorInvalidValue("`transpose` must be false.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -343,28 +299,6 @@ WebGLContext::ValidateUniformMatrixArraySetter(WebGLUniformLocation* loc,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateAttribIndex(GLuint index, const char* info)
|
||||
{
|
||||
bool valid = (index < MaxVertexAttribs());
|
||||
|
||||
if (!valid) {
|
||||
if (index == GLuint(-1)) {
|
||||
ErrorInvalidValue("%s: -1 is not a valid `index`. This value"
|
||||
" probably comes from a getAttribLocation()"
|
||||
" call, where this return value -1 means"
|
||||
" that the passed name didn't correspond to"
|
||||
" an active attribute in the specified"
|
||||
" program.", info);
|
||||
} else {
|
||||
ErrorInvalidValue("%s: `index` must be less than"
|
||||
" MAX_VERTEX_ATTRIBS.", info);
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::InitAndValidateGL(FailureReason* const out_failReason)
|
||||
{
|
||||
|
@ -755,8 +689,7 @@ WebGLContext::InitAndValidateGL(FailureReason* const out_failReason)
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLContext::ValidateFramebufferTarget(GLenum target,
|
||||
const char* const info)
|
||||
WebGLContext::ValidateFramebufferTarget(GLenum target)
|
||||
{
|
||||
bool isValid = true;
|
||||
switch (target) {
|
||||
|
@ -777,7 +710,7 @@ WebGLContext::ValidateFramebufferTarget(GLenum target,
|
|||
return true;
|
||||
}
|
||||
|
||||
ErrorInvalidEnumArg(info, "target", target);
|
||||
ErrorInvalidEnumArg("target", target);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,10 +15,11 @@ namespace mozilla {
|
|||
void
|
||||
WebGLContext::BindVertexArray(WebGLVertexArray* array)
|
||||
{
|
||||
const FuncScope funcScope(*this, "bindVertexArray");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (array && !ValidateObject("bindVertexArrayObject", *array))
|
||||
if (array && !ValidateObject("array", *array))
|
||||
return;
|
||||
|
||||
if (mBoundVertexArray) {
|
||||
|
@ -40,6 +41,7 @@ WebGLContext::BindVertexArray(WebGLVertexArray* array)
|
|||
already_AddRefed<WebGLVertexArray>
|
||||
WebGLContext::CreateVertexArray()
|
||||
{
|
||||
const FuncScope funcScope(*this, "createVertexArray");
|
||||
if (IsContextLost())
|
||||
return nullptr;
|
||||
|
||||
|
@ -59,7 +61,8 @@ WebGLContext::CreateVertexArrayImpl()
|
|||
void
|
||||
WebGLContext::DeleteVertexArray(WebGLVertexArray* array)
|
||||
{
|
||||
if (!ValidateDeleteObject("deleteVertexArray", array))
|
||||
const FuncScope funcScope(*this, "deleteVertexArray");
|
||||
if (!ValidateDeleteObject(array))
|
||||
return;
|
||||
|
||||
if (mBoundVertexArray == array)
|
||||
|
@ -68,13 +71,4 @@ WebGLContext::DeleteVertexArray(WebGLVertexArray* array)
|
|||
array->RequestDelete();
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLContext::IsVertexArray(const WebGLVertexArray* array)
|
||||
{
|
||||
if (!ValidateIsObject("isVertexArray", array))
|
||||
return false;
|
||||
|
||||
return array->IsVertexArray();
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -20,6 +20,28 @@
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
static bool
|
||||
ValidateAttribIndex(WebGLContext& webgl, GLuint index)
|
||||
{
|
||||
bool valid = (index < webgl.MaxVertexAttribs());
|
||||
|
||||
if (!valid) {
|
||||
if (index == GLuint(-1)) {
|
||||
webgl.ErrorInvalidValue("-1 is not a valid `index`. This value"
|
||||
" probably comes from a getAttribLocation()"
|
||||
" call, where this return value -1 means"
|
||||
" that the passed name didn't correspond to"
|
||||
" an active attribute in the specified"
|
||||
" program.");
|
||||
} else {
|
||||
webgl.ErrorInvalidValue("`index` must be less than"
|
||||
" MAX_VERTEX_ATTRIBS.");
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
WebGLContext::GetVertexAttribFloat32Array(JSContext* cx, GLuint index)
|
||||
{
|
||||
|
@ -59,17 +81,13 @@ WebGLContext::GetVertexAttribUint32Array(JSContext* cx, GLuint index)
|
|||
////////////////////////////////////////
|
||||
|
||||
void
|
||||
WebGLContext::VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w,
|
||||
const char* funcName)
|
||||
WebGLContext::VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
|
||||
{
|
||||
if (!funcName) {
|
||||
funcName = "vertexAttrib4f";
|
||||
}
|
||||
|
||||
const FuncScope funcScope(*this, "vertexAttrib4f");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateAttribIndex(index, funcName))
|
||||
if (!ValidateAttribIndex(*this, index))
|
||||
return;
|
||||
|
||||
////
|
||||
|
@ -90,17 +108,13 @@ WebGLContext::VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfl
|
|||
}
|
||||
|
||||
void
|
||||
WebGL2Context::VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w,
|
||||
const char* funcName)
|
||||
WebGL2Context::VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w)
|
||||
{
|
||||
if (!funcName) {
|
||||
funcName = "vertexAttribI4i";
|
||||
}
|
||||
|
||||
const FuncScope funcScope(*this, "vertexAttribI4i");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateAttribIndex(index, funcName))
|
||||
if (!ValidateAttribIndex(*this, index))
|
||||
return;
|
||||
|
||||
////
|
||||
|
@ -121,17 +135,13 @@ WebGL2Context::VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w,
|
|||
}
|
||||
|
||||
void
|
||||
WebGL2Context::VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w,
|
||||
const char* funcName)
|
||||
WebGL2Context::VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w)
|
||||
{
|
||||
if (!funcName) {
|
||||
funcName = "vertexAttribI4ui";
|
||||
}
|
||||
|
||||
const FuncScope funcScope(*this, "vertexAttribI4ui");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateAttribIndex(index, funcName))
|
||||
if (!ValidateAttribIndex(*this, index))
|
||||
return;
|
||||
|
||||
////
|
||||
|
@ -156,10 +166,11 @@ WebGL2Context::VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLui
|
|||
void
|
||||
WebGLContext::EnableVertexAttribArray(GLuint index)
|
||||
{
|
||||
const FuncScope funcScope(*this, "enableVertexAttribArray");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateAttribIndex(index, "enableVertexAttribArray"))
|
||||
if (!ValidateAttribIndex(*this, index))
|
||||
return;
|
||||
|
||||
gl->fEnableVertexAttribArray(index);
|
||||
|
@ -172,10 +183,11 @@ WebGLContext::EnableVertexAttribArray(GLuint index)
|
|||
void
|
||||
WebGLContext::DisableVertexAttribArray(GLuint index)
|
||||
{
|
||||
const FuncScope funcScope(*this, "disableVertexAttribArray");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateAttribIndex(index, "disableVertexAttribArray"))
|
||||
if (!ValidateAttribIndex(*this, index))
|
||||
return;
|
||||
|
||||
if (index || !gl->IsCompatibilityProfile()) {
|
||||
|
@ -191,11 +203,11 @@ JS::Value
|
|||
WebGLContext::GetVertexAttrib(JSContext* cx, GLuint index, GLenum pname,
|
||||
ErrorResult& rv)
|
||||
{
|
||||
const char funcName[] = "getVertexAttrib";
|
||||
const FuncScope funcScope(*this, "getVertexAttrib");
|
||||
if (IsContextLost())
|
||||
return JS::NullValue();
|
||||
|
||||
if (!ValidateAttribIndex(index, funcName))
|
||||
if (!ValidateAttribIndex(*this, index))
|
||||
return JS::NullValue();
|
||||
|
||||
MOZ_ASSERT(mBoundVertexArray);
|
||||
|
@ -261,21 +273,22 @@ WebGLContext::GetVertexAttrib(JSContext* cx, GLuint index, GLenum pname,
|
|||
break;
|
||||
}
|
||||
|
||||
ErrorInvalidEnumInfo("getVertexAttrib: parameter", pname);
|
||||
ErrorInvalidEnumInfo("pname", pname);
|
||||
return JS::NullValue();
|
||||
}
|
||||
|
||||
WebGLsizeiptr
|
||||
WebGLContext::GetVertexAttribOffset(GLuint index, GLenum pname)
|
||||
{
|
||||
const FuncScope funcScope(*this, "getVertexAttribOffset");
|
||||
if (IsContextLost())
|
||||
return 0;
|
||||
|
||||
if (!ValidateAttribIndex(index, "getVertexAttribOffset"))
|
||||
if (!ValidateAttribIndex(*this, index))
|
||||
return 0;
|
||||
|
||||
if (pname != LOCAL_GL_VERTEX_ATTRIB_ARRAY_POINTER) {
|
||||
ErrorInvalidEnum("getVertexAttribOffset: bad parameter");
|
||||
ErrorInvalidEnum("`pname` must be VERTEX_ATTRIB_ARRAY_POINTER.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -286,31 +299,31 @@ WebGLContext::GetVertexAttribOffset(GLuint index, GLenum pname)
|
|||
////////////////////////////////////////
|
||||
|
||||
void
|
||||
WebGLContext::VertexAttribAnyPointer(const char* funcName, bool isFuncInt, GLuint index,
|
||||
WebGLContext::VertexAttribAnyPointer(bool isFuncInt, GLuint index,
|
||||
GLint size, GLenum type, bool normalized,
|
||||
GLsizei stride, WebGLintptr byteOffset)
|
||||
{
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateAttribIndex(index, funcName))
|
||||
if (!ValidateAttribIndex(*this, index))
|
||||
return;
|
||||
|
||||
////
|
||||
|
||||
if (size < 1 || size > 4) {
|
||||
ErrorInvalidValue("%s: invalid element size", funcName);
|
||||
ErrorInvalidValue("Invalid element size.");
|
||||
return;
|
||||
}
|
||||
|
||||
// see WebGL spec section 6.6 "Vertex Attribute Data Stride"
|
||||
if (stride < 0 || stride > 255) {
|
||||
ErrorInvalidValue("%s: negative or too large stride", funcName);
|
||||
ErrorInvalidValue("Negative or too large stride.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (byteOffset < 0) {
|
||||
ErrorInvalidValue("%s: negative offset", funcName);
|
||||
ErrorInvalidValue("Negative offset.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -367,7 +380,7 @@ WebGLContext::VertexAttribAnyPointer(const char* funcName, bool isFuncInt, GLuin
|
|||
break;
|
||||
}
|
||||
if (size != 4) {
|
||||
ErrorInvalidOperation("%s: size must be 4 for this type.", funcName);
|
||||
ErrorInvalidOperation("Size must be 4 for this type.");
|
||||
return;
|
||||
}
|
||||
typeAlignment = 4;
|
||||
|
@ -378,7 +391,7 @@ WebGLContext::VertexAttribAnyPointer(const char* funcName, bool isFuncInt, GLuin
|
|||
break;
|
||||
}
|
||||
if (!isTypeValid) {
|
||||
ErrorInvalidEnumArg(funcName, "type", type);
|
||||
ErrorInvalidEnumInfo("type", type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -391,9 +404,8 @@ WebGLContext::VertexAttribAnyPointer(const char* funcName, bool isFuncInt, GLuin
|
|||
if (stride & typeAlignmentMask ||
|
||||
byteOffset & typeAlignmentMask)
|
||||
{
|
||||
ErrorInvalidOperation("%s: `stride` and `byteOffset` must satisfy the alignment"
|
||||
" requirement of `type`.",
|
||||
funcName);
|
||||
ErrorInvalidOperation("`stride` and `byteOffset` must satisfy the alignment"
|
||||
" requirement of `type`.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -401,8 +413,7 @@ WebGLContext::VertexAttribAnyPointer(const char* funcName, bool isFuncInt, GLuin
|
|||
|
||||
const auto& buffer = mBoundArrayBuffer;
|
||||
if (!buffer && byteOffset) {
|
||||
ErrorInvalidOperation("%s: If ARRAY_BUFFER is null, byteOffset must be zero.",
|
||||
funcName);
|
||||
ErrorInvalidOperation("If ARRAY_BUFFER is null, byteOffset must be zero.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -426,10 +437,11 @@ WebGLContext::VertexAttribAnyPointer(const char* funcName, bool isFuncInt, GLuin
|
|||
void
|
||||
WebGLContext::VertexAttribDivisor(GLuint index, GLuint divisor)
|
||||
{
|
||||
const FuncScope funcScope(*this, "vertexAttribDivisor");
|
||||
if (IsContextLost())
|
||||
return;
|
||||
|
||||
if (!ValidateAttribIndex(index, "vertexAttribDivisor"))
|
||||
if (!ValidateAttribIndex(*this, index))
|
||||
return;
|
||||
|
||||
MOZ_ASSERT(mBoundVertexArray);
|
||||
|
|
|
@ -28,17 +28,13 @@ WebGLExtensionDebugShaders::GetTranslatedShaderSource(const WebGLShader& shader,
|
|||
nsAString& retval) const
|
||||
{
|
||||
retval.SetIsVoid(true);
|
||||
|
||||
if (mIsLost) {
|
||||
mContext->ErrorInvalidOperation("%s: Extension is lost.",
|
||||
"getTranslatedShaderSource");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mContext->IsContextLost())
|
||||
if (mIsLost)
|
||||
return;
|
||||
|
||||
if (!mContext->ValidateObject("getShaderTranslatedSource: shader", shader))
|
||||
const WebGLContext::FuncScope funcScope(*mContext, "getShaderTranslatedSource");
|
||||
MOZ_ASSERT(!mContext->IsContextLost());
|
||||
|
||||
if (!mContext->ValidateObject("shader", shader))
|
||||
return;
|
||||
|
||||
shader.GetShaderTranslatedSource(&retval);
|
||||
|
|
|
@ -29,76 +29,83 @@ WebGLExtensionDisjointTimerQuery::~WebGLExtensionDisjointTimerQuery()
|
|||
already_AddRefed<WebGLQuery>
|
||||
WebGLExtensionDisjointTimerQuery::CreateQueryEXT() const
|
||||
{
|
||||
const char funcName[] = "createQueryEXT";
|
||||
if (mIsLost)
|
||||
return nullptr;
|
||||
const WebGLContext::FuncScope funcScope(*mContext, "createQueryEXT");
|
||||
MOZ_ASSERT(!mContext->IsContextLost());
|
||||
|
||||
return mContext->CreateQuery(funcName);
|
||||
return mContext->CreateQuery();
|
||||
}
|
||||
|
||||
void
|
||||
WebGLExtensionDisjointTimerQuery::DeleteQueryEXT(WebGLQuery* query) const
|
||||
{
|
||||
const char funcName[] = "deleteQueryEXT";
|
||||
if (mIsLost)
|
||||
return;
|
||||
const WebGLContext::FuncScope funcScope(*mContext, "deleteQueryEXT");
|
||||
MOZ_ASSERT(!mContext->IsContextLost());
|
||||
|
||||
mContext->DeleteQuery(query, funcName);
|
||||
mContext->DeleteQuery(query);
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLExtensionDisjointTimerQuery::IsQueryEXT(const WebGLQuery* query) const
|
||||
{
|
||||
const char funcName[] = "isQueryEXT";
|
||||
if (mIsLost)
|
||||
return false;
|
||||
const WebGLContext::FuncScope funcScope(*mContext, "isQueryEXT");
|
||||
MOZ_ASSERT(!mContext->IsContextLost());
|
||||
|
||||
return mContext->IsQuery(query, funcName);
|
||||
return mContext->IsQuery(query);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLExtensionDisjointTimerQuery::BeginQueryEXT(GLenum target, WebGLQuery& query) const
|
||||
{
|
||||
const char funcName[] = "beginQueryEXT";
|
||||
if (mIsLost)
|
||||
return;
|
||||
const WebGLContext::FuncScope funcScope(*mContext, "beginQueryEXT");
|
||||
MOZ_ASSERT(!mContext->IsContextLost());
|
||||
|
||||
mContext->BeginQuery(target, query, funcName);
|
||||
mContext->BeginQuery(target, query);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLExtensionDisjointTimerQuery::EndQueryEXT(GLenum target) const
|
||||
{
|
||||
const char funcName[] = "endQueryEXT";
|
||||
if (mIsLost)
|
||||
return;
|
||||
const WebGLContext::FuncScope funcScope(*mContext, "endQueryEXT");
|
||||
MOZ_ASSERT(!mContext->IsContextLost());
|
||||
|
||||
mContext->EndQuery(target, funcName);
|
||||
mContext->EndQuery(target);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLExtensionDisjointTimerQuery::QueryCounterEXT(WebGLQuery& query, GLenum target) const
|
||||
{
|
||||
const char funcName[] = "queryCounterEXT";
|
||||
if (mIsLost)
|
||||
return;
|
||||
const WebGLContext::FuncScope funcScope(*mContext, "queryCounterEXT");
|
||||
MOZ_ASSERT(!mContext->IsContextLost());
|
||||
|
||||
if (!mContext->ValidateObject(funcName, query))
|
||||
if (!mContext->ValidateObject("query", query))
|
||||
return;
|
||||
|
||||
query.QueryCounter(funcName, target);
|
||||
query.QueryCounter(target);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLExtensionDisjointTimerQuery::GetQueryEXT(JSContext* cx, GLenum target, GLenum pname,
|
||||
JS::MutableHandleValue retval) const
|
||||
{
|
||||
const char funcName[] = "getQueryEXT";
|
||||
retval.setNull();
|
||||
if (mIsLost)
|
||||
return;
|
||||
const WebGLContext::FuncScope funcScope(*mContext, "getQueryEXT");
|
||||
MOZ_ASSERT(!mContext->IsContextLost());
|
||||
|
||||
mContext->GetQuery(cx, target, pname, retval, funcName);
|
||||
mContext->GetQuery(cx, target, pname, retval);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -106,12 +113,13 @@ WebGLExtensionDisjointTimerQuery::GetQueryObjectEXT(JSContext* cx,
|
|||
const WebGLQuery& query, GLenum pname,
|
||||
JS::MutableHandleValue retval) const
|
||||
{
|
||||
const char funcName[] = "getQueryObjectEXT";
|
||||
retval.setNull();
|
||||
if (mIsLost)
|
||||
return;
|
||||
const WebGLContext::FuncScope funcScope(*mContext, "getQueryObjectEXT");
|
||||
MOZ_ASSERT(!mContext->IsContextLost());
|
||||
|
||||
mContext->GetQueryParameter(cx, query, pname, retval, funcName);
|
||||
mContext->GetQueryParameter(cx, query, pname, retval);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -26,6 +26,11 @@ WebGLExtensionMOZDebug::GetParameter(JSContext* cx, GLenum pname,
|
|||
JS::MutableHandle<JS::Value> retval,
|
||||
ErrorResult& er) const
|
||||
{
|
||||
if (mIsLost)
|
||||
return;
|
||||
const WebGLContext::FuncScope funcScope(*mContext, "MOZ_debug.getParameter");
|
||||
MOZ_ASSERT(!mContext->IsContextLost());
|
||||
|
||||
const auto& gl = mContext->gl;
|
||||
|
||||
switch (pname) {
|
||||
|
@ -72,7 +77,7 @@ WebGLExtensionMOZDebug::GetParameter(JSContext* cx, GLenum pname,
|
|||
return;
|
||||
|
||||
default:
|
||||
mContext->ErrorInvalidEnumArg("MOZ_debug.getParameter", "pname", pname);
|
||||
mContext->ErrorInvalidEnumInfo("pname", pname);
|
||||
retval.set(JS::NullValue());
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -47,8 +47,7 @@ WebGLFBAttachPoint::~WebGLFBAttachPoint()
|
|||
void
|
||||
WebGLFBAttachPoint::Unlink()
|
||||
{
|
||||
const char funcName[] = "WebGLFramebuffer::GC";
|
||||
Clear(funcName);
|
||||
Clear();
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -115,7 +114,7 @@ WebGLFBAttachPoint::IsReadableFloat() const
|
|||
}
|
||||
|
||||
void
|
||||
WebGLFBAttachPoint::Clear(const char* funcName)
|
||||
WebGLFBAttachPoint::Clear()
|
||||
{
|
||||
if (mRenderbufferPtr) {
|
||||
MOZ_ASSERT(!mTexturePtr);
|
||||
|
@ -127,14 +126,14 @@ WebGLFBAttachPoint::Clear(const char* funcName)
|
|||
mTexturePtr = nullptr;
|
||||
mRenderbufferPtr = nullptr;
|
||||
|
||||
OnBackingStoreRespecified(funcName);
|
||||
OnBackingStoreRespecified();
|
||||
}
|
||||
|
||||
void
|
||||
WebGLFBAttachPoint::SetTexImage(const char* funcName, WebGLTexture* tex,
|
||||
WebGLFBAttachPoint::SetTexImage(WebGLTexture* tex,
|
||||
TexImageTarget target, GLint level, GLint layer)
|
||||
{
|
||||
Clear(funcName);
|
||||
Clear();
|
||||
|
||||
mTexturePtr = tex;
|
||||
mTexImageTarget = target;
|
||||
|
@ -147,9 +146,9 @@ WebGLFBAttachPoint::SetTexImage(const char* funcName, WebGLTexture* tex,
|
|||
}
|
||||
|
||||
void
|
||||
WebGLFBAttachPoint::SetRenderbuffer(const char* funcName, WebGLRenderbuffer* rb)
|
||||
WebGLFBAttachPoint::SetRenderbuffer(WebGLRenderbuffer* rb)
|
||||
{
|
||||
Clear(funcName);
|
||||
Clear();
|
||||
|
||||
mRenderbufferPtr = rb;
|
||||
|
||||
|
@ -227,9 +226,9 @@ WebGLFBAttachPoint::Size(uint32_t* const out_width, uint32_t* const out_height)
|
|||
}
|
||||
|
||||
void
|
||||
WebGLFBAttachPoint::OnBackingStoreRespecified(const char* funcName) const
|
||||
WebGLFBAttachPoint::OnBackingStoreRespecified() const
|
||||
{
|
||||
mFB->InvalidateFramebufferStatus(funcName);
|
||||
mFB->InvalidateFramebufferStatus();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -402,7 +401,7 @@ WebGLFBAttachPoint::Resolve(gl::GLContext* gl) const
|
|||
}
|
||||
|
||||
JS::Value
|
||||
WebGLFBAttachPoint::GetParameter(const char* funcName, WebGLContext* webgl, JSContext* cx,
|
||||
WebGLFBAttachPoint::GetParameter(WebGLContext* webgl, JSContext* cx,
|
||||
GLenum target, GLenum attachment, GLenum pname,
|
||||
ErrorResult* const out_error) const
|
||||
{
|
||||
|
@ -435,10 +434,10 @@ WebGLFBAttachPoint::GetParameter(const char* funcName, WebGLContext* webgl, JSCo
|
|||
nsCString attachmentName;
|
||||
WebGLContext::EnumName(attachment, &attachmentName);
|
||||
if (webgl->IsWebGL2()) {
|
||||
webgl->ErrorInvalidOperation("%s: No attachment at %s.", funcName,
|
||||
webgl->ErrorInvalidOperation("No attachment at %s.",
|
||||
attachmentName.BeginReading());
|
||||
} else {
|
||||
webgl->ErrorInvalidEnum("%s: No attachment at %s.", funcName,
|
||||
webgl->ErrorInvalidEnum("No attachment at %s.",
|
||||
attachmentName.BeginReading());
|
||||
}
|
||||
return JS::NullValue();
|
||||
|
@ -506,7 +505,7 @@ WebGLFBAttachPoint::GetParameter(const char* funcName, WebGLContext* webgl, JSCo
|
|||
}
|
||||
|
||||
if (!isPNameValid) {
|
||||
webgl->ErrorInvalidEnum("%s: Invalid pname: 0x%04x", funcName, pname);
|
||||
webgl->ErrorInvalidEnum("Invalid pname: 0x%04x", pname);
|
||||
return JS::NullValue();
|
||||
}
|
||||
|
||||
|
@ -643,16 +642,14 @@ WebGLFramebuffer::WebGLFramebuffer(WebGLContext* webgl, GLuint fbo)
|
|||
void
|
||||
WebGLFramebuffer::Delete()
|
||||
{
|
||||
const char funcName[] = "WebGLFramebuffer::Delete";
|
||||
InvalidateFramebufferStatus();
|
||||
|
||||
InvalidateFramebufferStatus(funcName);
|
||||
|
||||
mDepthAttachment.Clear(funcName);
|
||||
mStencilAttachment.Clear(funcName);
|
||||
mDepthStencilAttachment.Clear(funcName);
|
||||
mDepthAttachment.Clear();
|
||||
mStencilAttachment.Clear();
|
||||
mDepthStencilAttachment.Clear();
|
||||
|
||||
for (auto& cur : mColorAttachments) {
|
||||
cur.Clear(funcName);
|
||||
cur.Clear();
|
||||
}
|
||||
|
||||
mContext->gl->fDeleteFramebuffers(1, &mGLName);
|
||||
|
@ -712,11 +709,11 @@ WebGLFramebuffer::GetAttachPoint(GLenum attachPoint)
|
|||
}
|
||||
|
||||
void
|
||||
WebGLFramebuffer::DetachTexture(const char* funcName, const WebGLTexture* tex)
|
||||
WebGLFramebuffer::DetachTexture(const WebGLTexture* tex)
|
||||
{
|
||||
const auto fnDetach = [&](WebGLFBAttachPoint& attach) {
|
||||
if (attach.Texture() == tex) {
|
||||
attach.Clear(funcName);
|
||||
attach.Clear();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -724,11 +721,11 @@ WebGLFramebuffer::DetachTexture(const char* funcName, const WebGLTexture* tex)
|
|||
}
|
||||
|
||||
void
|
||||
WebGLFramebuffer::DetachRenderbuffer(const char* funcName, const WebGLRenderbuffer* rb)
|
||||
WebGLFramebuffer::DetachRenderbuffer(const WebGLRenderbuffer* rb)
|
||||
{
|
||||
const auto fnDetach = [&](WebGLFBAttachPoint& attach) {
|
||||
if (attach.Renderbuffer() == rb) {
|
||||
attach.Clear(funcName);
|
||||
attach.Clear();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -889,23 +886,21 @@ WebGLFramebuffer::PrecheckFramebufferStatus(nsCString* const out_info) const
|
|||
// Validation
|
||||
|
||||
bool
|
||||
WebGLFramebuffer::ValidateAndInitAttachments(const char* funcName) const
|
||||
WebGLFramebuffer::ValidateAndInitAttachments() const
|
||||
{
|
||||
MOZ_ASSERT(mContext->mBoundDrawFramebuffer == this ||
|
||||
mContext->mBoundReadFramebuffer == this);
|
||||
|
||||
const auto fbStatus = CheckFramebufferStatus(funcName);
|
||||
const auto fbStatus = CheckFramebufferStatus();
|
||||
if (fbStatus == LOCAL_GL_FRAMEBUFFER_COMPLETE)
|
||||
return true;
|
||||
|
||||
mContext->ErrorInvalidFramebufferOperation("%s: Framebuffer must be"
|
||||
" complete.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidFramebufferOperation("Framebuffer must be complete.");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLFramebuffer::ValidateClearBufferType(const char* funcName, GLenum buffer,
|
||||
WebGLFramebuffer::ValidateClearBufferType(GLenum buffer,
|
||||
uint32_t drawBuffer, GLenum funcType) const
|
||||
{
|
||||
if (buffer != LOCAL_GL_COLOR)
|
||||
|
@ -932,9 +927,9 @@ WebGLFramebuffer::ValidateClearBufferType(const char* funcName, GLenum buffer,
|
|||
}
|
||||
|
||||
if (attachType != funcType) {
|
||||
mContext->ErrorInvalidOperation("%s: This attachment is of type 0x%04x, but"
|
||||
mContext->ErrorInvalidOperation("This attachment is of type 0x%04x, but"
|
||||
" this function is of type 0x%04x.",
|
||||
funcName, attachType, funcType);
|
||||
attachType, funcType);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -942,25 +937,22 @@ WebGLFramebuffer::ValidateClearBufferType(const char* funcName, GLenum buffer,
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLFramebuffer::ValidateForColorRead(const char* funcName,
|
||||
const webgl::FormatUsageInfo** const out_format,
|
||||
WebGLFramebuffer::ValidateForColorRead(const webgl::FormatUsageInfo** const out_format,
|
||||
uint32_t* const out_width,
|
||||
uint32_t* const out_height) const
|
||||
{
|
||||
if (!mColorReadBuffer) {
|
||||
mContext->ErrorInvalidOperation("%s: READ_BUFFER must not be NONE.", funcName);
|
||||
mContext->ErrorInvalidOperation("READ_BUFFER must not be NONE.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mColorReadBuffer->IsDefined()) {
|
||||
mContext->ErrorInvalidOperation("%s: The READ_BUFFER attachment is not defined.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("The READ_BUFFER attachment is not defined.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mColorReadBuffer->Samples()) {
|
||||
mContext->ErrorInvalidOperation("%s: The READ_BUFFER attachment is multisampled.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("The READ_BUFFER attachment is multisampled.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1003,7 +995,7 @@ WebGLFramebuffer::ResolveAttachments() const
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLFramebuffer::ResolveAttachmentData(const char* funcName) const
|
||||
WebGLFramebuffer::ResolveAttachmentData() const
|
||||
{
|
||||
//////
|
||||
// Check if we need to initialize anything
|
||||
|
@ -1056,7 +1048,7 @@ WebGLFramebuffer::ResolveAttachmentData(const char* funcName) const
|
|||
|
||||
for (const auto& attach : tex3DAttachmentsToInit) {
|
||||
const auto& tex = attach->Texture();
|
||||
if (!tex->InitializeImageData(funcName, attach->ImageTarget(),
|
||||
if (!tex->InitializeImageData(attach->ImageTarget(),
|
||||
attach->MipLevel()))
|
||||
{
|
||||
return false;
|
||||
|
@ -1157,14 +1149,14 @@ WebGLFramebuffer::ResolvedData::ResolvedData(const WebGLFramebuffer& parent)
|
|||
}
|
||||
|
||||
void
|
||||
WebGLFramebuffer::InvalidateFramebufferStatus(const char* funcName)
|
||||
WebGLFramebuffer::InvalidateFramebufferStatus()
|
||||
{
|
||||
if (mResolvedCompleteData) {
|
||||
mNumFBStatusInvals++;
|
||||
if (mNumFBStatusInvals > mContext->mMaxAcceptableFBStatusInvals) {
|
||||
mContext->GeneratePerfWarning("%s: FB was invalidated after being complete %u"
|
||||
mContext->GeneratePerfWarning("FB was invalidated after being complete %u"
|
||||
" times.",
|
||||
funcName, uint32_t(mNumFBStatusInvals));
|
||||
uint32_t(mNumFBStatusInvals));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1183,7 +1175,7 @@ WebGLFramebuffer::RefreshResolvedData()
|
|||
// Entrypoints
|
||||
|
||||
FBStatus
|
||||
WebGLFramebuffer::CheckFramebufferStatus(const char* const funcName) const
|
||||
WebGLFramebuffer::CheckFramebufferStatus() const
|
||||
{
|
||||
if (IsResolvedComplete())
|
||||
return LOCAL_GL_FRAMEBUFFER_COMPLETE;
|
||||
|
@ -1219,7 +1211,7 @@ WebGLFramebuffer::CheckFramebufferStatus(const char* const funcName) const
|
|||
break;
|
||||
}
|
||||
|
||||
if (!ResolveAttachmentData(funcName)) {
|
||||
if (!ResolveAttachmentData()) {
|
||||
ret = LOCAL_GL_FRAMEBUFFER_UNSUPPORTED;
|
||||
statusInfo.AssignLiteral("Failed to lazily-initialize attachment data.");
|
||||
break;
|
||||
|
@ -1230,8 +1222,8 @@ WebGLFramebuffer::CheckFramebufferStatus(const char* const funcName) const
|
|||
} while (false);
|
||||
|
||||
MOZ_ASSERT(ret != LOCAL_GL_FRAMEBUFFER_COMPLETE);
|
||||
mContext->GenerateWarning("%s: Framebuffer not complete. (status: 0x%04x) %s",
|
||||
funcName, ret.get(), statusInfo.BeginReading());
|
||||
mContext->GenerateWarning("Framebuffer not complete. (status: 0x%04x) %s",
|
||||
ret.get(), statusInfo.BeginReading());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1281,12 +1273,12 @@ WebGLFramebuffer::RefreshReadBuffer() const
|
|||
////
|
||||
|
||||
void
|
||||
WebGLFramebuffer::DrawBuffers(const char* funcName, const dom::Sequence<GLenum>& buffers)
|
||||
WebGLFramebuffer::DrawBuffers(const dom::Sequence<GLenum>& buffers)
|
||||
{
|
||||
if (buffers.Length() > mContext->mGLMaxDrawBuffers) {
|
||||
// "An INVALID_VALUE error is generated if `n` is greater than MAX_DRAW_BUFFERS."
|
||||
mContext->ErrorInvalidValue("%s: `buffers` must have a length <="
|
||||
" MAX_DRAW_BUFFERS.", funcName);
|
||||
mContext->ErrorInvalidValue("`buffers` must have a length <="
|
||||
" MAX_DRAW_BUFFERS.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1314,13 +1306,12 @@ WebGLFramebuffer::DrawBuffers(const char* funcName, const dom::Sequence<GLenum>&
|
|||
if (cur != LOCAL_GL_BACK &&
|
||||
!isColorEnum)
|
||||
{
|
||||
mContext->ErrorInvalidEnum("%s: Unexpected enum in buffers.", funcName);
|
||||
mContext->ErrorInvalidEnum("Unexpected enum in buffers.");
|
||||
return;
|
||||
}
|
||||
|
||||
mContext->ErrorInvalidOperation("%s: `buffers[i]` must be NONE or"
|
||||
" COLOR_ATTACHMENTi.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("`buffers[i]` must be NONE or"
|
||||
" COLOR_ATTACHMENTi.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1333,16 +1324,16 @@ WebGLFramebuffer::DrawBuffers(const char* funcName, const dom::Sequence<GLenum>&
|
|||
}
|
||||
|
||||
void
|
||||
WebGLFramebuffer::ReadBuffer(const char* funcName, GLenum attachPoint)
|
||||
WebGLFramebuffer::ReadBuffer(GLenum attachPoint)
|
||||
{
|
||||
const auto& maybeAttach = GetColorAttachPoint(attachPoint);
|
||||
if (!maybeAttach) {
|
||||
const char text[] = "%s: `mode` must be a COLOR_ATTACHMENTi, for 0 <= i <"
|
||||
const char text[] = "`mode` must be a COLOR_ATTACHMENTi, for 0 <= i <"
|
||||
" MAX_DRAW_BUFFERS.";
|
||||
if (attachPoint == LOCAL_GL_BACK) {
|
||||
mContext->ErrorInvalidOperation(text, funcName);
|
||||
mContext->ErrorInvalidOperation(text);
|
||||
} else {
|
||||
mContext->ErrorInvalidEnum(text, funcName);
|
||||
mContext->ErrorInvalidEnum(text);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1358,7 +1349,7 @@ WebGLFramebuffer::ReadBuffer(const char* funcName, GLenum attachPoint)
|
|||
////
|
||||
|
||||
void
|
||||
WebGLFramebuffer::FramebufferRenderbuffer(const char* funcName, GLenum attachEnum,
|
||||
WebGLFramebuffer::FramebufferRenderbuffer(GLenum attachEnum,
|
||||
GLenum rbtarget, WebGLRenderbuffer* rb)
|
||||
{
|
||||
MOZ_ASSERT(mContext->mBoundDrawFramebuffer == this ||
|
||||
|
@ -1367,26 +1358,26 @@ WebGLFramebuffer::FramebufferRenderbuffer(const char* funcName, GLenum attachEnu
|
|||
// `attachment`
|
||||
const auto maybeAttach = GetAttachPoint(attachEnum);
|
||||
if (!maybeAttach || !maybeAttach.value()) {
|
||||
mContext->ErrorInvalidEnum("%s: Bad `attachment`: 0x%x.", funcName, attachEnum);
|
||||
mContext->ErrorInvalidEnum("Bad `attachment`: 0x%x.", attachEnum);
|
||||
return;
|
||||
}
|
||||
const auto& attach = maybeAttach.value();
|
||||
|
||||
// `rbTarget`
|
||||
if (rbtarget != LOCAL_GL_RENDERBUFFER) {
|
||||
mContext->ErrorInvalidEnumInfo("framebufferRenderbuffer: rbtarget:", rbtarget);
|
||||
mContext->ErrorInvalidEnumInfo("rbtarget", rbtarget);
|
||||
return;
|
||||
}
|
||||
|
||||
// `rb`
|
||||
if (rb) {
|
||||
if (!mContext->ValidateObject("framebufferRenderbuffer: rb", *rb))
|
||||
if (!mContext->ValidateObject("rb", *rb))
|
||||
return;
|
||||
|
||||
if (!rb->mHasBeenBound) {
|
||||
mContext->ErrorInvalidOperation("%s: bindRenderbuffer must be called before"
|
||||
mContext->ErrorInvalidOperation("bindRenderbuffer must be called before"
|
||||
" attachment to %04x",
|
||||
funcName, attachEnum);
|
||||
attachEnum);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1394,17 +1385,17 @@ WebGLFramebuffer::FramebufferRenderbuffer(const char* funcName, GLenum attachEnu
|
|||
// End of validation.
|
||||
|
||||
if (mContext->IsWebGL2() && attachEnum == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) {
|
||||
mDepthAttachment.SetRenderbuffer(funcName, rb);
|
||||
mStencilAttachment.SetRenderbuffer(funcName, rb);
|
||||
mDepthAttachment.SetRenderbuffer(rb);
|
||||
mStencilAttachment.SetRenderbuffer(rb);
|
||||
} else {
|
||||
attach->SetRenderbuffer(funcName, rb);
|
||||
attach->SetRenderbuffer(rb);
|
||||
}
|
||||
|
||||
InvalidateFramebufferStatus(funcName);
|
||||
InvalidateFramebufferStatus();
|
||||
}
|
||||
|
||||
void
|
||||
WebGLFramebuffer::FramebufferTexture2D(const char* funcName, GLenum attachEnum,
|
||||
WebGLFramebuffer::FramebufferTexture2D(GLenum attachEnum,
|
||||
GLenum texImageTarget, WebGLTexture* tex,
|
||||
GLint level)
|
||||
{
|
||||
|
@ -1414,7 +1405,7 @@ WebGLFramebuffer::FramebufferTexture2D(const char* funcName, GLenum attachEnum,
|
|||
// `attachment`
|
||||
const auto maybeAttach = GetAttachPoint(attachEnum);
|
||||
if (!maybeAttach || !maybeAttach.value()) {
|
||||
mContext->ErrorInvalidEnum("%s: Bad `attachment`: 0x%x.", funcName, attachEnum);
|
||||
mContext->ErrorInvalidEnum("Bad `attachment`: 0x%x.", attachEnum);
|
||||
return;
|
||||
}
|
||||
const auto& attach = maybeAttach.value();
|
||||
|
@ -1424,33 +1415,31 @@ WebGLFramebuffer::FramebufferTexture2D(const char* funcName, GLenum attachEnum,
|
|||
(texImageTarget < LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X ||
|
||||
texImageTarget > LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))
|
||||
{
|
||||
mContext->ErrorInvalidEnumInfo("framebufferTexture2D: texImageTarget:",
|
||||
mContext->ErrorInvalidEnumInfo("texImageTarget",
|
||||
texImageTarget);
|
||||
return;
|
||||
}
|
||||
|
||||
// `texture`
|
||||
if (tex) {
|
||||
if (!mContext->ValidateObject("framebufferTexture2D: texture", *tex))
|
||||
if (!mContext->ValidateObject("texture", *tex))
|
||||
return;
|
||||
|
||||
if (!tex->HasEverBeenBound()) {
|
||||
mContext->ErrorInvalidOperation("%s: `texture` has never been bound.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("`texture` has never been bound.");
|
||||
return;
|
||||
}
|
||||
|
||||
const TexTarget destTexTarget = TexImageTargetToTexTarget(texImageTarget);
|
||||
if (tex->Target() != destTexTarget) {
|
||||
mContext->ErrorInvalidOperation("%s: Mismatched texture and texture target.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("Mismatched texture and texture target.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// `level`
|
||||
if (level < 0)
|
||||
return mContext->ErrorInvalidValue("%s: `level` must not be negative.", funcName);
|
||||
return mContext->ErrorInvalidValue("`level` must not be negative.");
|
||||
|
||||
if (mContext->IsWebGL2()) {
|
||||
/* GLES 3.0.4 p208:
|
||||
|
@ -1467,32 +1456,32 @@ WebGLFramebuffer::FramebufferTexture2D(const char* funcName, GLenum attachEnum,
|
|||
|
||||
if (texImageTarget == LOCAL_GL_TEXTURE_2D) {
|
||||
if (uint32_t(level) > FloorLog2(mContext->mGLMaxTextureSize))
|
||||
return mContext->ErrorInvalidValue("%s: `level` is too large.", funcName);
|
||||
return mContext->ErrorInvalidValue("`level` is too large.");
|
||||
} else {
|
||||
MOZ_ASSERT(texImageTarget >= LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X &&
|
||||
texImageTarget <= LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
|
||||
|
||||
if (uint32_t(level) > FloorLog2(mContext->mGLMaxCubeMapTextureSize))
|
||||
return mContext->ErrorInvalidValue("%s: `level` is too large.", funcName);
|
||||
return mContext->ErrorInvalidValue("`level` is too large.");
|
||||
}
|
||||
} else if (level != 0) {
|
||||
return mContext->ErrorInvalidValue("%s: `level` must be 0.", funcName);
|
||||
return mContext->ErrorInvalidValue("`level` must be 0.");
|
||||
}
|
||||
|
||||
// End of validation.
|
||||
|
||||
if (mContext->IsWebGL2() && attachEnum == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) {
|
||||
mDepthAttachment.SetTexImage(funcName, tex, texImageTarget, level);
|
||||
mStencilAttachment.SetTexImage(funcName, tex, texImageTarget, level);
|
||||
mDepthAttachment.SetTexImage(tex, texImageTarget, level);
|
||||
mStencilAttachment.SetTexImage(tex, texImageTarget, level);
|
||||
} else {
|
||||
attach->SetTexImage(funcName, tex, texImageTarget, level);
|
||||
attach->SetTexImage(tex, texImageTarget, level);
|
||||
}
|
||||
|
||||
InvalidateFramebufferStatus(funcName);
|
||||
InvalidateFramebufferStatus();
|
||||
}
|
||||
|
||||
void
|
||||
WebGLFramebuffer::FramebufferTextureLayer(const char* funcName, GLenum attachEnum,
|
||||
WebGLFramebuffer::FramebufferTextureLayer(GLenum attachEnum,
|
||||
WebGLTexture* tex, GLint level, GLint layer)
|
||||
{
|
||||
MOZ_ASSERT(mContext->mBoundDrawFramebuffer == this ||
|
||||
|
@ -1501,27 +1490,26 @@ WebGLFramebuffer::FramebufferTextureLayer(const char* funcName, GLenum attachEnu
|
|||
// `attachment`
|
||||
const auto maybeAttach = GetAttachPoint(attachEnum);
|
||||
if (!maybeAttach || !maybeAttach.value()) {
|
||||
mContext->ErrorInvalidEnum("%s: Bad `attachment`: 0x%x.", funcName, attachEnum);
|
||||
mContext->ErrorInvalidEnum("Bad `attachment`: 0x%x.", attachEnum);
|
||||
return;
|
||||
}
|
||||
const auto& attach = maybeAttach.value();
|
||||
|
||||
// `level`, `layer`
|
||||
if (layer < 0)
|
||||
return mContext->ErrorInvalidValue("%s: `layer` must be >= 0.", funcName);
|
||||
return mContext->ErrorInvalidValue("`layer` must be >= 0.");
|
||||
|
||||
if (level < 0)
|
||||
return mContext->ErrorInvalidValue("%s: `level` must be >= 0.", funcName);
|
||||
return mContext->ErrorInvalidValue("`level` must be >= 0.");
|
||||
|
||||
// `texture`
|
||||
GLenum texImageTarget = LOCAL_GL_TEXTURE_3D;
|
||||
if (tex) {
|
||||
if (!mContext->ValidateObject("framebufferTextureLayer: texture", *tex))
|
||||
if (!mContext->ValidateObject("texture", *tex))
|
||||
return;
|
||||
|
||||
if (!tex->HasEverBeenBound()) {
|
||||
mContext->ErrorInvalidOperation("%s: `texture` has never been bound.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("`texture` has never been bound.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1529,13 +1517,13 @@ WebGLFramebuffer::FramebufferTextureLayer(const char* funcName, GLenum attachEnu
|
|||
switch (texImageTarget) {
|
||||
case LOCAL_GL_TEXTURE_3D:
|
||||
if (uint32_t(layer) >= mContext->mGLMax3DTextureSize) {
|
||||
mContext->ErrorInvalidValue("%s: `layer` must be < %s.", funcName,
|
||||
mContext->ErrorInvalidValue("`layer` must be < %s.",
|
||||
"MAX_3D_TEXTURE_SIZE");
|
||||
return;
|
||||
}
|
||||
|
||||
if (uint32_t(level) > FloorLog2(mContext->mGLMax3DTextureSize)) {
|
||||
mContext->ErrorInvalidValue("%s: `level` must be <= log2(%s).", funcName,
|
||||
mContext->ErrorInvalidValue("`level` must be <= log2(%s).",
|
||||
"MAX_3D_TEXTURE_SIZE");
|
||||
return;
|
||||
}
|
||||
|
@ -1543,22 +1531,21 @@ WebGLFramebuffer::FramebufferTextureLayer(const char* funcName, GLenum attachEnu
|
|||
|
||||
case LOCAL_GL_TEXTURE_2D_ARRAY:
|
||||
if (uint32_t(layer) >= mContext->mGLMaxArrayTextureLayers) {
|
||||
mContext->ErrorInvalidValue("%s: `layer` must be < %s.", funcName,
|
||||
mContext->ErrorInvalidValue("`layer` must be < %s.",
|
||||
"MAX_ARRAY_TEXTURE_LAYERS");
|
||||
return;
|
||||
}
|
||||
|
||||
if (uint32_t(level) > FloorLog2(mContext->mGLMaxTextureSize)) {
|
||||
mContext->ErrorInvalidValue("%s: `level` must be <= log2(%s).", funcName,
|
||||
mContext->ErrorInvalidValue("`level` must be <= log2(%s).",
|
||||
"MAX_TEXTURE_SIZE");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
mContext->ErrorInvalidOperation("%s: `texture` must be a TEXTURE_3D or"
|
||||
" TEXTURE_2D_ARRAY.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("`texture` must be a TEXTURE_3D or"
|
||||
" TEXTURE_2D_ARRAY.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1566,26 +1553,25 @@ WebGLFramebuffer::FramebufferTextureLayer(const char* funcName, GLenum attachEnu
|
|||
// End of validation.
|
||||
|
||||
if (mContext->IsWebGL2() && attachEnum == LOCAL_GL_DEPTH_STENCIL_ATTACHMENT) {
|
||||
mDepthAttachment.SetTexImage(funcName, tex, texImageTarget, level, layer);
|
||||
mStencilAttachment.SetTexImage(funcName, tex, texImageTarget, level, layer);
|
||||
mDepthAttachment.SetTexImage(tex, texImageTarget, level, layer);
|
||||
mStencilAttachment.SetTexImage(tex, texImageTarget, level, layer);
|
||||
} else {
|
||||
attach->SetTexImage(funcName, tex, texImageTarget, level, layer);
|
||||
attach->SetTexImage(tex, texImageTarget, level, layer);
|
||||
}
|
||||
|
||||
InvalidateFramebufferStatus(funcName);
|
||||
InvalidateFramebufferStatus();
|
||||
}
|
||||
|
||||
JS::Value
|
||||
WebGLFramebuffer::GetAttachmentParameter(const char* funcName, JSContext* cx,
|
||||
WebGLFramebuffer::GetAttachmentParameter(JSContext* cx,
|
||||
GLenum target, GLenum attachEnum, GLenum pname,
|
||||
ErrorResult* const out_error)
|
||||
{
|
||||
const auto maybeAttach = GetAttachPoint(attachEnum);
|
||||
if (!maybeAttach || attachEnum == LOCAL_GL_NONE) {
|
||||
mContext->ErrorInvalidEnum("%s: Can only query COLOR_ATTACHMENTi,"
|
||||
mContext->ErrorInvalidEnum("Can only query COLOR_ATTACHMENTi,"
|
||||
" DEPTH_ATTACHMENT, DEPTH_STENCIL_ATTACHMENT, or"
|
||||
" STENCIL_ATTACHMENT for a framebuffer.",
|
||||
funcName);
|
||||
" STENCIL_ATTACHMENT for a framebuffer.");
|
||||
return JS::NullValue();
|
||||
}
|
||||
auto attach = maybeAttach.value();
|
||||
|
@ -1594,27 +1580,25 @@ WebGLFramebuffer::GetAttachmentParameter(const char* funcName, JSContext* cx,
|
|||
// There are a couple special rules for this one.
|
||||
|
||||
if (pname == LOCAL_GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE) {
|
||||
mContext->ErrorInvalidOperation("%s: Querying"
|
||||
mContext->ErrorInvalidOperation("Querying"
|
||||
" FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE"
|
||||
" against DEPTH_STENCIL_ATTACHMENT is an"
|
||||
" error.",
|
||||
funcName);
|
||||
" error.");
|
||||
return JS::NullValue();
|
||||
}
|
||||
|
||||
if (mDepthAttachment.Renderbuffer() != mStencilAttachment.Renderbuffer() ||
|
||||
mDepthAttachment.Texture() != mStencilAttachment.Texture())
|
||||
{
|
||||
mContext->ErrorInvalidOperation("%s: DEPTH_ATTACHMENT and STENCIL_ATTACHMENT"
|
||||
" have different objects bound.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("DEPTH_ATTACHMENT and STENCIL_ATTACHMENT"
|
||||
" have different objects bound.");
|
||||
return JS::NullValue();
|
||||
}
|
||||
|
||||
attach = &mDepthAttachment;
|
||||
}
|
||||
|
||||
return attach->GetParameter(funcName, mContext, cx, target, attachEnum, pname,
|
||||
return attach->GetParameter(mContext, cx, target, attachEnum, pname,
|
||||
out_error);
|
||||
}
|
||||
|
||||
|
@ -1653,7 +1637,6 @@ WebGLFramebuffer::BlitFramebuffer(WebGLContext* webgl,
|
|||
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
|
||||
GLbitfield mask, GLenum filter)
|
||||
{
|
||||
const char funcName[] = "blitFramebuffer";
|
||||
const auto& gl = webgl->gl;
|
||||
|
||||
const auto& srcFB = webgl->mBoundReadFramebuffer;
|
||||
|
@ -1803,17 +1786,15 @@ WebGLFramebuffer::BlitFramebuffer(WebGLContext* webgl,
|
|||
if (type == webgl::ComponentType::Int ||
|
||||
type == webgl::ComponentType::UInt)
|
||||
{
|
||||
webgl->ErrorInvalidOperation("%s: `filter` is LINEAR and READ_BUFFER"
|
||||
" contains integer data.",
|
||||
funcName);
|
||||
webgl->ErrorInvalidOperation("`filter` is LINEAR and READ_BUFFER"
|
||||
" contains integer data.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!colorTypesMatch) {
|
||||
webgl->ErrorInvalidOperation("%s: Color component types (fixed/float/uint/"
|
||||
"int) must match.",
|
||||
funcName);
|
||||
webgl->ErrorInvalidOperation("Color component types (fixed/float/uint/"
|
||||
"int) must match.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1823,9 +1804,8 @@ WebGLFramebuffer::BlitFramebuffer(WebGLContext* webgl,
|
|||
if (bool(mask & depthAndStencilBits) &&
|
||||
filter != LOCAL_GL_NEAREST)
|
||||
{
|
||||
webgl->ErrorInvalidOperation("%s: DEPTH_BUFFER_BIT and STENCIL_BUFFER_BIT can"
|
||||
" only be used with NEAREST filtering.",
|
||||
funcName);
|
||||
webgl->ErrorInvalidOperation("DEPTH_BUFFER_BIT and STENCIL_BUFFER_BIT can"
|
||||
" only be used with NEAREST filtering.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1841,25 +1821,22 @@ WebGLFramebuffer::BlitFramebuffer(WebGLContext* webgl,
|
|||
if (mask & LOCAL_GL_DEPTH_BUFFER_BIT &&
|
||||
dstDepthFormat && dstDepthFormat != srcDepthFormat)
|
||||
{
|
||||
webgl->ErrorInvalidOperation("%s: Depth buffer formats must match if selected.",
|
||||
funcName);
|
||||
webgl->ErrorInvalidOperation("Depth buffer formats must match if selected.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mask & LOCAL_GL_STENCIL_BUFFER_BIT &&
|
||||
dstStencilFormat && dstStencilFormat != srcStencilFormat)
|
||||
{
|
||||
webgl->ErrorInvalidOperation("%s: Stencil buffer formats must match if selected.",
|
||||
funcName);
|
||||
webgl->ErrorInvalidOperation("Stencil buffer formats must match if selected.");
|
||||
return;
|
||||
}
|
||||
|
||||
////
|
||||
|
||||
if (dstHasSamples) {
|
||||
webgl->ErrorInvalidOperation("%s: DRAW_FRAMEBUFFER may not have multiple"
|
||||
" samples.",
|
||||
funcName);
|
||||
webgl->ErrorInvalidOperation("DRAW_FRAMEBUFFER may not have multiple"
|
||||
" samples.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1867,10 +1844,9 @@ WebGLFramebuffer::BlitFramebuffer(WebGLContext* webgl,
|
|||
if (mask & LOCAL_GL_COLOR_BUFFER_BIT &&
|
||||
dstHasColor && !colorFormatsMatch)
|
||||
{
|
||||
webgl->ErrorInvalidOperation("%s: Color buffer formats must match if"
|
||||
webgl->ErrorInvalidOperation("Color buffer formats must match if"
|
||||
" selected, when reading from a multisampled"
|
||||
" source.",
|
||||
funcName);
|
||||
" source.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1879,9 +1855,8 @@ WebGLFramebuffer::BlitFramebuffer(WebGLContext* webgl,
|
|||
dstY0 != srcY0 ||
|
||||
dstY1 != srcY1)
|
||||
{
|
||||
webgl->ErrorInvalidOperation("%s: If the source is multisampled, then the"
|
||||
" source and dest regions must match exactly.",
|
||||
funcName);
|
||||
webgl->ErrorInvalidOperation("If the source is multisampled, then the"
|
||||
" source and dest regions must match exactly.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1915,13 +1890,13 @@ WebGLFramebuffer::BlitFramebuffer(WebGLContext* webgl,
|
|||
}
|
||||
|
||||
if (feedback) {
|
||||
webgl->ErrorInvalidOperation("%s: Feedback detected into DRAW_FRAMEBUFFER's"
|
||||
webgl->ErrorInvalidOperation("Feedback detected into DRAW_FRAMEBUFFER's"
|
||||
" 0x%04x attachment.",
|
||||
funcName, feedback->mAttachmentPoint);
|
||||
feedback->mAttachmentPoint);
|
||||
return;
|
||||
}
|
||||
} else if (!srcFB && !dstFB) {
|
||||
webgl->ErrorInvalidOperation("%s: Feedback with default framebuffer.", funcName);
|
||||
webgl->ErrorInvalidOperation("Feedback with default framebuffer.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,11 +67,11 @@ public:
|
|||
bool HasAlpha() const;
|
||||
bool IsReadableFloat() const;
|
||||
|
||||
void Clear(const char* funcName);
|
||||
void Clear();
|
||||
|
||||
void SetTexImage(const char* funcName, WebGLTexture* tex, TexImageTarget target,
|
||||
void SetTexImage(WebGLTexture* tex, TexImageTarget target,
|
||||
GLint level, GLint layer = 0);
|
||||
void SetRenderbuffer(const char* funcName, WebGLRenderbuffer* rb);
|
||||
void SetRenderbuffer(WebGLRenderbuffer* rb);
|
||||
|
||||
WebGLTexture* Texture() const { return mTexturePtr; }
|
||||
WebGLRenderbuffer* Renderbuffer() const { return mRenderbufferPtr; }
|
||||
|
@ -97,11 +97,11 @@ public:
|
|||
|
||||
void Resolve(gl::GLContext* gl) const;
|
||||
|
||||
JS::Value GetParameter(const char* funcName, WebGLContext* webgl, JSContext* cx,
|
||||
JS::Value GetParameter(WebGLContext* webgl, JSContext* cx,
|
||||
GLenum target, GLenum attachment, GLenum pname,
|
||||
ErrorResult* const out_error) const;
|
||||
|
||||
void OnBackingStoreRespecified(const char* funcName) const;
|
||||
void OnBackingStoreRespecified() const;
|
||||
|
||||
bool IsEquivalentForFeedback(const WebGLFBAttachPoint& other) const {
|
||||
if (!IsDefined() || !other.IsDefined())
|
||||
|
@ -232,17 +232,16 @@ protected:
|
|||
void ResolveAttachments() const;
|
||||
void RefreshDrawBuffers() const;
|
||||
void RefreshReadBuffer() const;
|
||||
bool ResolveAttachmentData(const char* funcName) const;
|
||||
bool ResolveAttachmentData() const;
|
||||
|
||||
public:
|
||||
void DetachTexture(const char* funcName, const WebGLTexture* tex);
|
||||
void DetachRenderbuffer(const char* funcName, const WebGLRenderbuffer* rb);
|
||||
bool ValidateAndInitAttachments(const char* funcName) const;
|
||||
bool ValidateClearBufferType(const char* funcName, GLenum buffer, uint32_t drawBuffer,
|
||||
void DetachTexture(const WebGLTexture* tex);
|
||||
void DetachRenderbuffer(const WebGLRenderbuffer* rb);
|
||||
bool ValidateAndInitAttachments() const;
|
||||
bool ValidateClearBufferType(GLenum buffer, uint32_t drawBuffer,
|
||||
GLenum funcType) const;
|
||||
|
||||
bool ValidateForColorRead(const char* funcName,
|
||||
const webgl::FormatUsageInfo** out_format,
|
||||
bool ValidateForColorRead(const webgl::FormatUsageInfo** out_format,
|
||||
uint32_t* out_width, uint32_t* out_height) const;
|
||||
|
||||
////////////////
|
||||
|
@ -279,27 +278,27 @@ public:
|
|||
// Invalidation
|
||||
|
||||
bool IsResolvedComplete() const { return bool(mResolvedCompleteData); }
|
||||
void InvalidateFramebufferStatus(const char* funcName);
|
||||
void InvalidateFramebufferStatus();
|
||||
void RefreshResolvedData();
|
||||
|
||||
////////////////
|
||||
// WebGL funcs
|
||||
|
||||
bool IsCheckFramebufferStatusComplete(const char* const funcName) const {
|
||||
return CheckFramebufferStatus(funcName) == LOCAL_GL_FRAMEBUFFER_COMPLETE;
|
||||
bool IsCheckFramebufferStatusComplete() const {
|
||||
return CheckFramebufferStatus() == LOCAL_GL_FRAMEBUFFER_COMPLETE;
|
||||
}
|
||||
|
||||
FBStatus CheckFramebufferStatus(const char* funcName) const;
|
||||
void FramebufferRenderbuffer(const char* funcName, GLenum attachment, GLenum rbtarget,
|
||||
FBStatus CheckFramebufferStatus() const;
|
||||
void FramebufferRenderbuffer(GLenum attachment, GLenum rbtarget,
|
||||
WebGLRenderbuffer* rb);
|
||||
void FramebufferTexture2D(const char* funcName, GLenum attachment,
|
||||
void FramebufferTexture2D(GLenum attachment,
|
||||
GLenum texImageTarget, WebGLTexture* tex, GLint level);
|
||||
void FramebufferTextureLayer(const char* funcName, GLenum attachment,
|
||||
void FramebufferTextureLayer(GLenum attachment,
|
||||
WebGLTexture* tex, GLint level, GLint layer);
|
||||
void DrawBuffers(const char* funcName, const dom::Sequence<GLenum>& buffers);
|
||||
void ReadBuffer(const char* funcName, GLenum attachPoint);
|
||||
void DrawBuffers(const dom::Sequence<GLenum>& buffers);
|
||||
void ReadBuffer(GLenum attachPoint);
|
||||
|
||||
JS::Value GetAttachmentParameter(const char* funcName, JSContext* cx, GLenum target,
|
||||
JS::Value GetAttachmentParameter(JSContext* cx, GLenum target,
|
||||
GLenum attachment, GLenum pname,
|
||||
ErrorResult* const out_error);
|
||||
|
||||
|
|
|
@ -31,12 +31,12 @@ WebGLFramebufferAttachable::UnmarkAttachment(const WebGLFBAttachPoint& attachmen
|
|||
}
|
||||
|
||||
void
|
||||
WebGLFramebufferAttachable::InvalidateStatusOfAttachedFBs(const char* funcName) const
|
||||
WebGLFramebufferAttachable::InvalidateStatusOfAttachedFBs() const
|
||||
{
|
||||
const size_t count = mAttachmentPoints.Length();
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
MOZ_ASSERT(mAttachmentPoints[i]->mFB);
|
||||
mAttachmentPoints[i]->mFB->InvalidateFramebufferStatus(funcName);
|
||||
mAttachmentPoints[i]->mFB->InvalidateFramebufferStatus();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
// Track FBO/Attachment combinations
|
||||
void MarkAttachment(const WebGLFBAttachPoint& attachment);
|
||||
void UnmarkAttachment(const WebGLFBAttachPoint& attachment);
|
||||
void InvalidateStatusOfAttachedFBs(const char* funcName) const;
|
||||
void InvalidateStatusOfAttachedFBs() const;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -463,7 +463,7 @@ webgl::LinkedProgramInfo::~LinkedProgramInfo()
|
|||
}
|
||||
|
||||
const webgl::CachedDrawFetchLimits*
|
||||
webgl::LinkedProgramInfo::GetDrawFetchLimits(const char* const funcName) const
|
||||
webgl::LinkedProgramInfo::GetDrawFetchLimits() const
|
||||
{
|
||||
const auto& webgl = prog->mContext;
|
||||
const auto& vao = webgl->mBoundVertexArray;
|
||||
|
@ -482,9 +482,9 @@ webgl::LinkedProgramInfo::GetDrawFetchLimits(const char* const funcName) const
|
|||
uint32_t i = 0;
|
||||
for (const auto& cur : vao->mAttribs) {
|
||||
if (cur.mEnabled && !cur.mBuf) {
|
||||
webgl->ErrorInvalidOperation("%s: Vertex attrib array %u is enabled but"
|
||||
webgl->ErrorInvalidOperation("Vertex attrib array %u is enabled but"
|
||||
" has no buffer bound.",
|
||||
funcName, i);
|
||||
i);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -507,9 +507,9 @@ webgl::LinkedProgramInfo::GetDrawFetchLimits(const char* const funcName) const
|
|||
if (attribData.mEnabled) {
|
||||
MOZ_ASSERT(attribData.mBuf);
|
||||
if (attribData.mBuf->IsBoundForTF()) {
|
||||
webgl->ErrorInvalidOperation("%s: Vertex attrib %u's buffer is bound for"
|
||||
webgl->ErrorInvalidOperation("Vertex attrib %u's buffer is bound for"
|
||||
" transform feedback.",
|
||||
funcName, loc);
|
||||
loc);
|
||||
return nullptr;
|
||||
}
|
||||
cacheDeps.push_back(&attribData.mBuf->mFetchInvalidator);
|
||||
|
@ -537,18 +537,17 @@ webgl::LinkedProgramInfo::GetDrawFetchLimits(const char* const funcName) const
|
|||
nsCString progType, dataType;
|
||||
WebGLContext::EnumName(progAttrib.mBaseType, &progType);
|
||||
WebGLContext::EnumName(attribDataBaseType, &dataType);
|
||||
webgl->ErrorInvalidOperation("%s: Vertex attrib %u requires data of type %s,"
|
||||
webgl->ErrorInvalidOperation("Vertex attrib %u requires data of type %s,"
|
||||
" but is being supplied with type %s.",
|
||||
funcName, loc, progType.BeginReading(),
|
||||
loc, progType.BeginReading(),
|
||||
dataType.BeginReading());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasActiveAttrib && !hasActiveDivisor0) {
|
||||
webgl->ErrorInvalidOperation("%s: One active vertex attrib (if any are active)"
|
||||
" must have a divisor of 0.",
|
||||
funcName);
|
||||
webgl->ErrorInvalidOperation("One active vertex attrib (if any are active)"
|
||||
" must have a divisor of 0.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -625,17 +624,17 @@ WebGLProgram::AttachShader(WebGLShader* shader)
|
|||
void
|
||||
WebGLProgram::BindAttribLocation(GLuint loc, const nsAString& name)
|
||||
{
|
||||
if (!ValidateGLSLVariableName(name, mContext, "bindAttribLocation"))
|
||||
if (!ValidateGLSLVariableName(name, mContext))
|
||||
return;
|
||||
|
||||
if (loc >= mContext->MaxVertexAttribs()) {
|
||||
mContext->ErrorInvalidValue("bindAttribLocation: `location` must be less than"
|
||||
mContext->ErrorInvalidValue("`location` must be less than"
|
||||
" MAX_VERTEX_ATTRIBS.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (StringBeginsWith(name, NS_LITERAL_STRING("gl_"))) {
|
||||
mContext->ErrorInvalidOperation("bindAttribLocation: Can't set the location of a"
|
||||
mContext->ErrorInvalidOperation("Can't set the location of a"
|
||||
" name that starts with 'gl_'.");
|
||||
return;
|
||||
}
|
||||
|
@ -735,11 +734,11 @@ WebGLProgram::GetAttachedShaders(nsTArray<RefPtr<WebGLShader>>* const out) const
|
|||
GLint
|
||||
WebGLProgram::GetAttribLocation(const nsAString& userName_wide) const
|
||||
{
|
||||
if (!ValidateGLSLVariableName(userName_wide, mContext, "getAttribLocation"))
|
||||
if (!ValidateGLSLVariableName(userName_wide, mContext))
|
||||
return -1;
|
||||
|
||||
if (!IsLinked()) {
|
||||
mContext->ErrorInvalidOperation("getAttribLocation: `program` must be linked.");
|
||||
mContext->ErrorInvalidOperation("`program` must be linked.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -766,11 +765,11 @@ GetFragDataByUserName(const WebGLProgram* prog,
|
|||
GLint
|
||||
WebGLProgram::GetFragDataLocation(const nsAString& userName_wide) const
|
||||
{
|
||||
if (!ValidateGLSLVariableName(userName_wide, mContext, "getFragDataLocation"))
|
||||
if (!ValidateGLSLVariableName(userName_wide, mContext))
|
||||
return -1;
|
||||
|
||||
if (!IsLinked()) {
|
||||
mContext->ErrorInvalidOperation("getFragDataLocation: `program` must be linked.");
|
||||
mContext->ErrorInvalidOperation("`program` must be linked.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -865,8 +864,7 @@ WebGLProgram::GetProgramParameter(GLenum pname) const
|
|||
return JS::BooleanValue(bool(GetProgramiv(gl, mGLName, pname)));
|
||||
|
||||
default:
|
||||
mContext->ErrorInvalidEnumInfo("getProgramParameter: `pname`",
|
||||
pname);
|
||||
mContext->ErrorInvalidEnumInfo("pname", pname);
|
||||
return JS::NullValue();
|
||||
}
|
||||
}
|
||||
|
@ -874,11 +872,11 @@ WebGLProgram::GetProgramParameter(GLenum pname) const
|
|||
GLuint
|
||||
WebGLProgram::GetUniformBlockIndex(const nsAString& userName_wide) const
|
||||
{
|
||||
if (!ValidateGLSLVariableName(userName_wide, mContext, "getUniformBlockIndex"))
|
||||
if (!ValidateGLSLVariableName(userName_wide, mContext))
|
||||
return LOCAL_GL_INVALID_INDEX;
|
||||
|
||||
if (!IsLinked()) {
|
||||
mContext->ErrorInvalidOperation("getUniformBlockIndex: `program` must be linked.");
|
||||
mContext->ErrorInvalidOperation("`program` must be linked.");
|
||||
return LOCAL_GL_INVALID_INDEX;
|
||||
}
|
||||
|
||||
|
@ -904,14 +902,14 @@ void
|
|||
WebGLProgram::GetActiveUniformBlockName(GLuint uniformBlockIndex, nsAString& retval) const
|
||||
{
|
||||
if (!IsLinked()) {
|
||||
mContext->ErrorInvalidOperation("getActiveUniformBlockName: `program` must be linked.");
|
||||
mContext->ErrorInvalidOperation("`program` must be linked.");
|
||||
return;
|
||||
}
|
||||
|
||||
const webgl::LinkedProgramInfo* linkInfo = LinkInfo();
|
||||
GLuint uniformBlockCount = (GLuint) linkInfo->uniformBlocks.size();
|
||||
if (uniformBlockIndex >= uniformBlockCount) {
|
||||
mContext->ErrorInvalidValue("getActiveUniformBlockName: index %u invalid.", uniformBlockIndex);
|
||||
mContext->ErrorInvalidValue("index %u invalid.", uniformBlockIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -923,14 +921,14 @@ JS::Value
|
|||
WebGLProgram::GetActiveUniformBlockParam(GLuint uniformBlockIndex, GLenum pname) const
|
||||
{
|
||||
if (!IsLinked()) {
|
||||
mContext->ErrorInvalidOperation("getActiveUniformBlockParameter: `program` must be linked.");
|
||||
mContext->ErrorInvalidOperation("`program` must be linked.");
|
||||
return JS::NullValue();
|
||||
}
|
||||
|
||||
const webgl::LinkedProgramInfo* linkInfo = LinkInfo();
|
||||
GLuint uniformBlockCount = (GLuint)linkInfo->uniformBlocks.size();
|
||||
if (uniformBlockIndex >= uniformBlockCount) {
|
||||
mContext->ErrorInvalidValue("getActiveUniformBlockParameter: index %u invalid.", uniformBlockIndex);
|
||||
mContext->ErrorInvalidValue("Index %u invalid.", uniformBlockIndex);
|
||||
return JS::NullValue();
|
||||
}
|
||||
|
||||
|
@ -958,16 +956,15 @@ JS::Value
|
|||
WebGLProgram::GetActiveUniformBlockActiveUniforms(JSContext* cx, GLuint uniformBlockIndex,
|
||||
ErrorResult* const out_error) const
|
||||
{
|
||||
const char funcName[] = "getActiveUniformBlockParameter";
|
||||
if (!IsLinked()) {
|
||||
mContext->ErrorInvalidOperation("%s: `program` must be linked.", funcName);
|
||||
mContext->ErrorInvalidOperation("`program` must be linked.");
|
||||
return JS::NullValue();
|
||||
}
|
||||
|
||||
const webgl::LinkedProgramInfo* linkInfo = LinkInfo();
|
||||
GLuint uniformBlockCount = (GLuint)linkInfo->uniformBlocks.size();
|
||||
if (uniformBlockIndex >= uniformBlockCount) {
|
||||
mContext->ErrorInvalidValue("%s: Index %u invalid.", funcName, uniformBlockIndex);
|
||||
mContext->ErrorInvalidValue("Index %u invalid.", uniformBlockIndex);
|
||||
return JS::NullValue();
|
||||
}
|
||||
|
||||
|
@ -997,11 +994,11 @@ WebGLProgram::GetActiveUniformBlockActiveUniforms(JSContext* cx, GLuint uniformB
|
|||
already_AddRefed<WebGLUniformLocation>
|
||||
WebGLProgram::GetUniformLocation(const nsAString& userName_wide) const
|
||||
{
|
||||
if (!ValidateGLSLVariableName(userName_wide, mContext, "getUniformLocation"))
|
||||
if (!ValidateGLSLVariableName(userName_wide, mContext))
|
||||
return nullptr;
|
||||
|
||||
if (!IsLinked()) {
|
||||
mContext->ErrorInvalidOperation("getUniformLocation: `program` must be linked.");
|
||||
mContext->ErrorInvalidOperation("`program` must be linked.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -1032,9 +1029,8 @@ void
|
|||
WebGLProgram::GetUniformIndices(const dom::Sequence<nsString>& uniformNames,
|
||||
dom::Nullable< nsTArray<GLuint> >& retval) const
|
||||
{
|
||||
const char funcName[] = "getUniformIndices";
|
||||
if (!IsLinked()) {
|
||||
mContext->ErrorInvalidOperation("%s: `program` must be linked.", funcName);
|
||||
mContext->ErrorInvalidOperation("`program` must be linked.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1066,23 +1062,21 @@ void
|
|||
WebGLProgram::UniformBlockBinding(GLuint uniformBlockIndex,
|
||||
GLuint uniformBlockBinding) const
|
||||
{
|
||||
const char funcName[] = "getActiveUniformBlockName";
|
||||
if (!IsLinked()) {
|
||||
mContext->ErrorInvalidOperation("%s: `program` must be linked.", funcName);
|
||||
mContext->ErrorInvalidOperation("`program` must be linked.");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& uniformBlocks = LinkInfo()->uniformBlocks;
|
||||
if (uniformBlockIndex >= uniformBlocks.size()) {
|
||||
mContext->ErrorInvalidValue("%s: Index %u invalid.", funcName, uniformBlockIndex);
|
||||
mContext->ErrorInvalidValue("Index %u invalid.", uniformBlockIndex);
|
||||
return;
|
||||
}
|
||||
const auto& uniformBlock = uniformBlocks[uniformBlockIndex];
|
||||
|
||||
const auto& indexedBindings = mContext->mIndexedUniformBufferBindings;
|
||||
if (uniformBlockBinding >= indexedBindings.size()) {
|
||||
mContext->ErrorInvalidValue("%s: Binding %u invalid.", funcName,
|
||||
uniformBlockBinding);
|
||||
mContext->ErrorInvalidValue("Binding %u invalid.", uniformBlockBinding);
|
||||
return;
|
||||
}
|
||||
const auto& indexedBinding = indexedBindings[uniformBlockBinding];
|
||||
|
@ -1142,12 +1136,9 @@ WebGLProgram::ValidateForLink()
|
|||
void
|
||||
WebGLProgram::LinkProgram()
|
||||
{
|
||||
const char funcName[] = "linkProgram";
|
||||
|
||||
if (mNumActiveTFOs) {
|
||||
mContext->ErrorInvalidOperation("%s: Program is in-use by one or more active"
|
||||
" transform feedback objects.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("Program is in-use by one or more active"
|
||||
" transform feedback objects.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1157,7 +1148,7 @@ WebGLProgram::LinkProgram()
|
|||
mMostRecentLinkInfo = nullptr;
|
||||
|
||||
if (!ValidateForLink()) {
|
||||
mContext->GenerateWarning("%s: %s", funcName, mLinkLog.BeginReading());
|
||||
mContext->GenerateWarning("%s", mLinkLog.BeginReading());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1208,7 +1199,7 @@ WebGLProgram::LinkProgram()
|
|||
// report in compileShader the translation errors generated by ANGLE,
|
||||
// but it seems saner to keep a single way of obtaining shader infologs.
|
||||
if (!mLinkLog.IsEmpty()) {
|
||||
mContext->GenerateWarning("linkProgram: Failed to link, leaving the following"
|
||||
mContext->GenerateWarning("Failed to link, leaving the following"
|
||||
" log:\n%s\n",
|
||||
mLinkLog.BeginReading());
|
||||
}
|
||||
|
@ -1427,11 +1418,8 @@ WebGLProgram::ValidateAfterTentativeLink(nsCString* const out_linkLog) const
|
|||
bool
|
||||
WebGLProgram::UseProgram() const
|
||||
{
|
||||
const char funcName[] = "useProgram";
|
||||
|
||||
if (!mMostRecentLinkInfo) {
|
||||
mContext->ErrorInvalidOperation("%s: Program has not been successfully linked.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("Program has not been successfully linked.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1439,8 +1427,7 @@ WebGLProgram::UseProgram() const
|
|||
mContext->mBoundTransformFeedback->mIsActive &&
|
||||
!mContext->mBoundTransformFeedback->mIsPaused)
|
||||
{
|
||||
mContext->ErrorInvalidOperation("%s: Transform feedback active and not paused.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("Transform feedback active and not paused.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1457,7 +1444,7 @@ WebGLProgram::ValidateProgram() const
|
|||
// See bug 593867 for NVIDIA and bug 657201 for ATI. The latter is confirmed
|
||||
// with Mac OS 10.6.7.
|
||||
if (gl->WorkAroundDriverBugs()) {
|
||||
mContext->GenerateWarning("validateProgram: Implemented as a no-op on"
|
||||
mContext->GenerateWarning("Implemented as a no-op on"
|
||||
" Mac to work around crashes.");
|
||||
return;
|
||||
}
|
||||
|
@ -1536,8 +1523,6 @@ void
|
|||
WebGLProgram::TransformFeedbackVaryings(const dom::Sequence<nsString>& varyings,
|
||||
GLenum bufferMode)
|
||||
{
|
||||
const char funcName[] = "transformFeedbackVaryings";
|
||||
|
||||
const auto& gl = mContext->gl;
|
||||
|
||||
switch (bufferMode) {
|
||||
|
@ -1550,8 +1535,7 @@ WebGLProgram::TransformFeedbackVaryings(const dom::Sequence<nsString>& varyings,
|
|||
gl->GetUIntegerv(LOCAL_GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS,
|
||||
&maxAttribs);
|
||||
if (varyings.Length() > maxAttribs) {
|
||||
mContext->ErrorInvalidValue("%s: Length of `varyings` exceeds %s.",
|
||||
funcName,
|
||||
mContext->ErrorInvalidValue("Length of `varyings` exceeds %s.",
|
||||
"TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS");
|
||||
return;
|
||||
}
|
||||
|
@ -1559,7 +1543,7 @@ WebGLProgram::TransformFeedbackVaryings(const dom::Sequence<nsString>& varyings,
|
|||
break;
|
||||
|
||||
default:
|
||||
mContext->ErrorInvalidEnum("%s: Bad `bufferMode`: 0x%04x.", funcName, bufferMode);
|
||||
mContext->ErrorInvalidEnumInfo("bufferMode", bufferMode);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1576,13 +1560,12 @@ WebGLProgram::GetTransformFeedbackVarying(GLuint index) const
|
|||
// No docs in the WebGL 2 spec for this function. Taking the language for
|
||||
// getActiveAttrib, which states that the function returns null on any error.
|
||||
if (!IsLinked()) {
|
||||
mContext->ErrorInvalidOperation("getTransformFeedbackVarying: `program` must be "
|
||||
"linked.");
|
||||
mContext->ErrorInvalidOperation("`program` must be linked.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (index >= LinkInfo()->transformFeedbackVaryings.size()) {
|
||||
mContext->ErrorInvalidValue("getTransformFeedbackVarying: `index` is greater or "
|
||||
mContext->ErrorInvalidValue("`index` is greater or "
|
||||
"equal to TRANSFORM_FEEDBACK_VARYINGS.");
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ struct LinkedProgramInfo final
|
|||
mutable CacheMap<const WebGLVertexArray*,
|
||||
CachedDrawFetchLimits> mDrawFetchCache;
|
||||
|
||||
const CachedDrawFetchLimits* GetDrawFetchLimits(const char* funcName) const;
|
||||
const CachedDrawFetchLimits* GetDrawFetchLimits() const;
|
||||
|
||||
//////
|
||||
|
||||
|
|
|
@ -65,10 +65,8 @@ TargetForDriver(const gl::GLContext* gl, GLenum target)
|
|||
void
|
||||
WebGLQuery::BeginQuery(GLenum target, WebGLRefPtr<WebGLQuery>& slot)
|
||||
{
|
||||
const char funcName[] = "beginQuery";
|
||||
|
||||
if (mTarget && target != mTarget) {
|
||||
mContext->ErrorInvalidOperation("%s: Queries cannot change targets.", funcName);
|
||||
mContext->ErrorInvalidOperation("Queries cannot change targets.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -109,25 +107,23 @@ WebGLQuery::EndQuery()
|
|||
void
|
||||
WebGLQuery::GetQueryParameter(GLenum pname, JS::MutableHandleValue retval) const
|
||||
{
|
||||
const char funcName[] = "getQueryParameter";
|
||||
|
||||
switch (pname) {
|
||||
case LOCAL_GL_QUERY_RESULT_AVAILABLE:
|
||||
case LOCAL_GL_QUERY_RESULT:
|
||||
break;
|
||||
|
||||
default:
|
||||
mContext->ErrorInvalidEnumArg(funcName, "pname", pname);
|
||||
mContext->ErrorInvalidEnumInfo("pname", pname);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mTarget) {
|
||||
mContext->ErrorInvalidOperation("%s: Query has never been active.", funcName);
|
||||
mContext->ErrorInvalidOperation("Query has never been active.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mActiveSlot)
|
||||
return mContext->ErrorInvalidOperation("%s: Query is still active.", funcName);
|
||||
return mContext->ErrorInvalidOperation("Query is still active.");
|
||||
|
||||
// End of validation
|
||||
////
|
||||
|
@ -208,15 +204,15 @@ WebGLQuery::DeleteQuery()
|
|||
}
|
||||
|
||||
void
|
||||
WebGLQuery::QueryCounter(const char* funcName, GLenum target)
|
||||
WebGLQuery::QueryCounter(GLenum target)
|
||||
{
|
||||
if (target != LOCAL_GL_TIMESTAMP_EXT) {
|
||||
mContext->ErrorInvalidEnum("%s: `target` must be TIMESTAMP_EXT.", funcName);
|
||||
mContext->ErrorInvalidEnum("`target` must be TIMESTAMP_EXT.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (mTarget && target != mTarget) {
|
||||
mContext->ErrorInvalidOperation("%s: Queries cannot change targets.", funcName);
|
||||
mContext->ErrorInvalidOperation("Queries cannot change targets.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
void EndQuery();
|
||||
void GetQueryParameter(GLenum pname, JS::MutableHandleValue retval) const;
|
||||
bool IsQuery() const;
|
||||
void QueryCounter(const char* funcName, GLenum target);
|
||||
void QueryCounter(GLenum target);
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -175,13 +175,12 @@ WebGLRenderbuffer::DoRenderbufferStorage(uint32_t samples,
|
|||
}
|
||||
|
||||
void
|
||||
WebGLRenderbuffer::RenderbufferStorage(const char* funcName, uint32_t samples,
|
||||
GLenum internalFormat, uint32_t width,
|
||||
uint32_t height)
|
||||
WebGLRenderbuffer::RenderbufferStorage(uint32_t samples, GLenum internalFormat,
|
||||
uint32_t width, uint32_t height)
|
||||
{
|
||||
const auto usage = mContext->mFormatUsage->GetRBUsage(internalFormat);
|
||||
if (!usage) {
|
||||
mContext->ErrorInvalidEnum("%s: Invalid `internalFormat`: 0x%04x.", funcName,
|
||||
mContext->ErrorInvalidEnum("Invalid `internalFormat`: 0x%04x.",
|
||||
internalFormat);
|
||||
return;
|
||||
}
|
||||
|
@ -189,9 +188,8 @@ WebGLRenderbuffer::RenderbufferStorage(const char* funcName, uint32_t samples,
|
|||
if (width > mContext->mGLMaxRenderbufferSize ||
|
||||
height > mContext->mGLMaxRenderbufferSize)
|
||||
{
|
||||
mContext->ErrorInvalidValue("%s: Width or height exceeds maximum renderbuffer"
|
||||
" size.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidValue("Width or height exceeds maximum renderbuffer"
|
||||
" size.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -201,7 +199,7 @@ WebGLRenderbuffer::RenderbufferStorage(const char* funcName, uint32_t samples,
|
|||
MOZ_ASSERT(usage->maxSamplesKnown);
|
||||
|
||||
if (samples > usage->maxSamples) {
|
||||
mContext->ErrorInvalidOperation("%s: `samples` is out of the valid range.", funcName);
|
||||
mContext->ErrorInvalidOperation("`samples` is out of the valid range.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -209,8 +207,7 @@ WebGLRenderbuffer::RenderbufferStorage(const char* funcName, uint32_t samples,
|
|||
|
||||
const GLenum error = DoRenderbufferStorage(samples, usage, width, height);
|
||||
if (error) {
|
||||
const char* errorName = WebGLContext::ErrorName(error);
|
||||
mContext->GenerateWarning("%s generated error %s", funcName, errorName);
|
||||
mContext->GenerateWarning("Unexpected error %s", EnumString(error).c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -222,7 +219,7 @@ WebGLRenderbuffer::RenderbufferStorage(const char* funcName, uint32_t samples,
|
|||
mHeight = height;
|
||||
mImageDataStatus = WebGLImageDataStatus::UninitializedImageData;
|
||||
|
||||
InvalidateStatusOfAttachedFBs(funcName);
|
||||
InvalidateStatusOfAttachedFBs();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -72,8 +72,8 @@ public:
|
|||
return mContext;
|
||||
}
|
||||
|
||||
void RenderbufferStorage(const char* funcName, uint32_t samples,
|
||||
GLenum internalFormat, uint32_t width, uint32_t height);
|
||||
void RenderbufferStorage(uint32_t samples, GLenum internalFormat, uint32_t width,
|
||||
uint32_t height);
|
||||
// Only handles a subset of `pname`s.
|
||||
GLint GetRenderbufferParameter(RBTarget target, RBParam pname) const;
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ WebGLSampler::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto)
|
|||
}
|
||||
|
||||
static bool
|
||||
ValidateSamplerParameterParams(WebGLContext* webgl, const char* funcName, GLenum pname,
|
||||
ValidateSamplerParameterParams(WebGLContext* webgl, GLenum pname,
|
||||
const FloatOrInt& param)
|
||||
{
|
||||
const auto& paramInt = param.i;
|
||||
|
@ -129,19 +129,18 @@ ValidateSamplerParameterParams(WebGLContext* webgl, const char* funcName, GLenum
|
|||
break;
|
||||
|
||||
default:
|
||||
webgl->ErrorInvalidEnumArg(funcName, "pname", pname);
|
||||
webgl->ErrorInvalidEnumInfo("pname", pname);
|
||||
return false;
|
||||
}
|
||||
|
||||
webgl->ErrorInvalidEnumArg(funcName, "param", paramInt);
|
||||
webgl->ErrorInvalidEnumInfo("param", paramInt);
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
WebGLSampler::SamplerParameter(const char* funcName, GLenum pname,
|
||||
const FloatOrInt& param)
|
||||
WebGLSampler::SamplerParameter(GLenum pname, const FloatOrInt& param)
|
||||
{
|
||||
if (!ValidateSamplerParameterParams(mContext, funcName, pname, param))
|
||||
if (!ValidateSamplerParameterParams(mContext, pname, param))
|
||||
return;
|
||||
|
||||
switch (pname) {
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
|
||||
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override;
|
||||
|
||||
void SamplerParameter(const char* funcName, GLenum pname, const FloatOrInt& param);
|
||||
void SamplerParameter(GLenum pname, const FloatOrInt& param);
|
||||
|
||||
const auto& State() const { return mState; }
|
||||
};
|
||||
|
|
|
@ -172,15 +172,13 @@ WebGLShader::~WebGLShader()
|
|||
void
|
||||
WebGLShader::ShaderSource(const nsAString& source)
|
||||
{
|
||||
const char funcName[] = "shaderSource";
|
||||
nsString sourceWithoutComments;
|
||||
if (!TruncateComments(source, &sourceWithoutComments)) {
|
||||
mContext->ErrorOutOfMemory("%s: Failed to alloc for empting comment contents.",
|
||||
funcName);
|
||||
mContext->ErrorOutOfMemory("Failed to alloc for empting comment contents.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ValidateGLSLPreprocString(mContext, funcName, sourceWithoutComments))
|
||||
if (!ValidateGLSLPreprocString(mContext, sourceWithoutComments))
|
||||
return;
|
||||
|
||||
// We checked that the source stripped of comments is in the
|
||||
|
|
|
@ -33,12 +33,12 @@ Mutable(const T& x)
|
|||
}
|
||||
|
||||
void
|
||||
WebGLTexture::ImageInfo::Clear(const char* funcName)
|
||||
WebGLTexture::ImageInfo::Clear()
|
||||
{
|
||||
if (!IsDefined())
|
||||
return;
|
||||
|
||||
OnRespecify(funcName);
|
||||
OnRespecify();
|
||||
|
||||
Mutable(mFormat) = LOCAL_GL_NONE;
|
||||
Mutable(mWidth) = 0;
|
||||
|
@ -49,7 +49,7 @@ WebGLTexture::ImageInfo::Clear(const char* funcName)
|
|||
}
|
||||
|
||||
void
|
||||
WebGLTexture::ImageInfo::Set(const char* funcName, const ImageInfo& a)
|
||||
WebGLTexture::ImageInfo::Set(const ImageInfo& a)
|
||||
{
|
||||
MOZ_ASSERT(a.IsDefined());
|
||||
|
||||
|
@ -62,7 +62,7 @@ WebGLTexture::ImageInfo::Set(const char* funcName, const ImageInfo& a)
|
|||
|
||||
// But *don't* transfer mAttachPoints!
|
||||
MOZ_ASSERT(a.mAttachPoints.empty());
|
||||
OnRespecify(funcName);
|
||||
OnRespecify();
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -89,10 +89,10 @@ WebGLTexture::ImageInfo::RemoveAttachPoint(WebGLFBAttachPoint* attachPoint)
|
|||
}
|
||||
|
||||
void
|
||||
WebGLTexture::ImageInfo::OnRespecify(const char* funcName) const
|
||||
WebGLTexture::ImageInfo::OnRespecify() const
|
||||
{
|
||||
for (auto cur : mAttachPoints) {
|
||||
cur->OnBackingStoreRespecified(funcName);
|
||||
cur->OnBackingStoreRespecified();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,9 +143,8 @@ WebGLTexture::WebGLTexture(WebGLContext* webgl, GLuint tex)
|
|||
void
|
||||
WebGLTexture::Delete()
|
||||
{
|
||||
const char funcName[] = "WebGLTexture::Delete";
|
||||
for (auto& cur : mImageInfoArr) {
|
||||
cur.Clear(funcName);
|
||||
cur.Clear();
|
||||
}
|
||||
|
||||
mContext->gl->fDeleteTextures(1, &mGLName);
|
||||
|
@ -167,27 +166,27 @@ WebGLTexture::MemoryUsage() const
|
|||
}
|
||||
|
||||
void
|
||||
WebGLTexture::SetImageInfo(const char* funcName, ImageInfo* target,
|
||||
WebGLTexture::SetImageInfo(ImageInfo* target,
|
||||
const ImageInfo& newInfo)
|
||||
{
|
||||
target->Set(funcName, newInfo);
|
||||
target->Set(newInfo);
|
||||
|
||||
InvalidateResolveCache();
|
||||
}
|
||||
|
||||
void
|
||||
WebGLTexture::SetImageInfosAtLevel(const char* funcName, uint32_t level,
|
||||
WebGLTexture::SetImageInfosAtLevel(uint32_t level,
|
||||
const ImageInfo& newInfo)
|
||||
{
|
||||
for (uint8_t i = 0; i < mFaceCount; i++) {
|
||||
ImageInfoAtFace(i, level).Set(funcName, newInfo);
|
||||
ImageInfoAtFace(i, level).Set(newInfo);
|
||||
}
|
||||
|
||||
InvalidateResolveCache();
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLTexture::IsMipmapComplete(const char* funcName, uint32_t texUnit,
|
||||
WebGLTexture::IsMipmapComplete(uint32_t texUnit,
|
||||
bool* const out_initFailed)
|
||||
{
|
||||
*out_initFailed = false;
|
||||
|
@ -211,7 +210,7 @@ WebGLTexture::IsMipmapComplete(const char* funcName, uint32_t texUnit,
|
|||
MOZ_ASSERT(refWidth && refHeight && refDepth);
|
||||
|
||||
for (uint32_t level = mBaseMipmapLevel; level <= maxLevel; level++) {
|
||||
if (!EnsureLevelInitialized(funcName, level)) {
|
||||
if (!EnsureLevelInitialized(level)) {
|
||||
*out_initFailed = true;
|
||||
return false;
|
||||
}
|
||||
|
@ -303,7 +302,7 @@ WebGLTexture::IsCubeComplete() const
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLTexture::IsComplete(const char* funcName, uint32_t texUnit,
|
||||
WebGLTexture::IsComplete(uint32_t texUnit,
|
||||
const char** const out_reason, bool* const out_initFailed)
|
||||
{
|
||||
*out_initFailed = false;
|
||||
|
@ -350,7 +349,7 @@ WebGLTexture::IsComplete(const char* funcName, uint32_t texUnit,
|
|||
// the texture is not mipmap complete."
|
||||
const bool requiresMipmap = (minFilter != LOCAL_GL_NEAREST &&
|
||||
minFilter != LOCAL_GL_LINEAR);
|
||||
if (requiresMipmap && !IsMipmapComplete(funcName, texUnit, out_initFailed)) {
|
||||
if (requiresMipmap && !IsMipmapComplete(texUnit, out_initFailed)) {
|
||||
if (*out_initFailed)
|
||||
return false;
|
||||
|
||||
|
@ -444,7 +443,7 @@ WebGLTexture::IsComplete(const char* funcName, uint32_t texUnit,
|
|||
// (already covered)
|
||||
}
|
||||
|
||||
if (!EnsureLevelInitialized(funcName, mBaseMipmapLevel)) {
|
||||
if (!EnsureLevelInitialized(mBaseMipmapLevel)) {
|
||||
*out_initFailed = true;
|
||||
return false;
|
||||
}
|
||||
|
@ -480,23 +479,22 @@ WebGLTexture::MaxEffectiveMipmapLevel(uint32_t texUnit, uint32_t* const out) con
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLTexture::GetFakeBlackType(const char* funcName, uint32_t texUnit,
|
||||
WebGLTexture::GetFakeBlackType(uint32_t texUnit,
|
||||
FakeBlackType* const out_fakeBlack)
|
||||
{
|
||||
const char* incompleteReason;
|
||||
bool initFailed = false;
|
||||
if (!IsComplete(funcName, texUnit, &incompleteReason, &initFailed)) {
|
||||
if (!IsComplete(texUnit, &incompleteReason, &initFailed)) {
|
||||
if (initFailed) {
|
||||
mContext->ErrorOutOfMemory("%s: Failed to initialize texture data.",
|
||||
funcName);
|
||||
mContext->ErrorOutOfMemory("Failed to initialize texture data.");
|
||||
return false; // The world just exploded.
|
||||
}
|
||||
|
||||
if (incompleteReason) {
|
||||
mContext->GenerateWarning("%s: Active texture %u for target 0x%04x is"
|
||||
mContext->GenerateWarning("Active texture %u for target 0x%04x is"
|
||||
" 'incomplete', and will be rendered as"
|
||||
" RGBA(0,0,0,1), as per the GLES 2.0.24 $3.8.2: %s",
|
||||
funcName, texUnit, mTarget.get(),
|
||||
texUnit, mTarget.get(),
|
||||
incompleteReason);
|
||||
}
|
||||
*out_fakeBlack = FakeBlackType::RGBA0001;
|
||||
|
@ -526,11 +524,11 @@ SetSwizzle(gl::GLContext* gl, TexTarget target, const GLint* swizzle)
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLTexture::ResolveForDraw(const char* funcName, uint32_t texUnit,
|
||||
WebGLTexture::ResolveForDraw(uint32_t texUnit,
|
||||
FakeBlackType* const out_fakeBlack)
|
||||
{
|
||||
if (!mIsResolved) {
|
||||
if (!GetFakeBlackType(funcName, texUnit, &mResolved_FakeBlack))
|
||||
if (!GetFakeBlackType(texUnit, &mResolved_FakeBlack))
|
||||
return false;
|
||||
|
||||
// Check which swizzle we should use. Since the texture must be complete at this
|
||||
|
@ -559,7 +557,7 @@ WebGLTexture::ResolveForDraw(const char* funcName, uint32_t texUnit,
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLTexture::EnsureImageDataInitialized(const char* funcName, TexImageTarget target,
|
||||
WebGLTexture::EnsureImageDataInitialized(TexImageTarget target,
|
||||
uint32_t level)
|
||||
{
|
||||
auto& imageInfo = ImageInfoAt(target, level);
|
||||
|
@ -569,20 +567,20 @@ WebGLTexture::EnsureImageDataInitialized(const char* funcName, TexImageTarget ta
|
|||
if (imageInfo.IsDataInitialized())
|
||||
return true;
|
||||
|
||||
return InitializeImageData(funcName, target, level);
|
||||
return InitializeImageData(target, level);
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLTexture::EnsureLevelInitialized(const char* funcName, uint32_t level)
|
||||
WebGLTexture::EnsureLevelInitialized(uint32_t level)
|
||||
{
|
||||
if (mTarget != LOCAL_GL_TEXTURE_CUBE_MAP)
|
||||
return EnsureImageDataInitialized(funcName, mTarget.get(), level);
|
||||
return EnsureImageDataInitialized(mTarget.get(), level);
|
||||
|
||||
for (GLenum texImageTarget = LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X;
|
||||
texImageTarget <= LOCAL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z;
|
||||
++texImageTarget)
|
||||
{
|
||||
if (!EnsureImageDataInitialized(funcName, texImageTarget, level))
|
||||
if (!EnsureImageDataInitialized(texImageTarget, level))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -630,7 +628,7 @@ ZeroANGLEDepthTexture(WebGLContext* webgl, GLuint tex,
|
|||
}
|
||||
|
||||
static bool
|
||||
ZeroTextureData(WebGLContext* webgl, const char* funcName, GLuint tex,
|
||||
ZeroTextureData(WebGLContext* webgl, GLuint tex,
|
||||
TexImageTarget target, uint32_t level,
|
||||
const webgl::FormatUsageInfo* usage, uint32_t width, uint32_t height,
|
||||
uint32_t depth)
|
||||
|
@ -644,9 +642,8 @@ ZeroTextureData(WebGLContext* webgl, const char* funcName, GLuint tex,
|
|||
// We have no sympathy for any of these cases.
|
||||
|
||||
// "Doctor, it hurts when I do this!" "Well don't do that!"
|
||||
webgl->GenerateWarning("%s: This operation requires zeroing texture data. This is"
|
||||
" slow.",
|
||||
funcName);
|
||||
webgl->GenerateWarning("This operation requires zeroing texture data. This is"
|
||||
" slow.");
|
||||
|
||||
gl::GLContext* gl = webgl->GL();
|
||||
|
||||
|
@ -742,7 +739,7 @@ ZeroTextureData(WebGLContext* webgl, const char* funcName, GLuint tex,
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLTexture::InitializeImageData(const char* funcName, TexImageTarget target,
|
||||
WebGLTexture::InitializeImageData(TexImageTarget target,
|
||||
uint32_t level)
|
||||
{
|
||||
auto& imageInfo = ImageInfoAt(target, level);
|
||||
|
@ -754,7 +751,7 @@ WebGLTexture::InitializeImageData(const char* funcName, TexImageTarget target,
|
|||
const auto& height = imageInfo.mHeight;
|
||||
const auto& depth = imageInfo.mDepth;
|
||||
|
||||
if (!ZeroTextureData(mContext, funcName, mGLName, target, level, usage, width, height,
|
||||
if (!ZeroTextureData(mContext, mGLName, target, level, usage, width, height,
|
||||
depth))
|
||||
{
|
||||
return false;
|
||||
|
@ -781,7 +778,7 @@ WebGLTexture::ClampLevelBaseAndMax()
|
|||
}
|
||||
|
||||
void
|
||||
WebGLTexture::PopulateMipChain(const char* funcName, uint32_t firstLevel,
|
||||
WebGLTexture::PopulateMipChain(uint32_t firstLevel,
|
||||
uint32_t lastLevel)
|
||||
{
|
||||
const ImageInfo& baseImageInfo = ImageInfoAtFace(0, firstLevel);
|
||||
|
@ -813,7 +810,7 @@ WebGLTexture::PopulateMipChain(const char* funcName, uint32_t firstLevel,
|
|||
const ImageInfo cur(baseImageInfo.mFormat, refWidth, refHeight, refDepth,
|
||||
baseImageInfo.IsDataInitialized());
|
||||
|
||||
SetImageInfosAtLevel(funcName, level, cur);
|
||||
SetImageInfosAtLevel(level, cur);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -862,8 +859,7 @@ WebGLTexture::BindTexture(TexTarget texTarget)
|
|||
|
||||
void
|
||||
WebGLTexture::GenerateMipmap(TexTarget texTarget)
|
||||
{
|
||||
const char funcName[] = "generateMipmap";
|
||||
{\
|
||||
// GLES 3.0.4 p160:
|
||||
// "Mipmap generation replaces texel array levels level base + 1 through q with arrays
|
||||
// derived from the level base array, regardless of their previous contents. All
|
||||
|
@ -871,43 +867,37 @@ WebGLTexture::GenerateMipmap(TexTarget texTarget)
|
|||
// computation."
|
||||
const ImageInfo& baseImageInfo = BaseImageInfo();
|
||||
if (!baseImageInfo.IsDefined()) {
|
||||
mContext->ErrorInvalidOperation("%s: The base level of the texture is not"
|
||||
" defined.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("The base level of the texture is not"
|
||||
" defined.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsCubeMap() && !IsCubeComplete()) {
|
||||
mContext->ErrorInvalidOperation("%s: Cube maps must be \"cube complete\".",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("Cube maps must be \"cube complete\".");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto format = baseImageInfo.mFormat->format;
|
||||
if (!mContext->IsWebGL2()) {
|
||||
if (!baseImageInfo.IsPowerOfTwo()) {
|
||||
mContext->ErrorInvalidOperation("%s: The base level of the texture does not"
|
||||
" have power-of-two dimensions.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("The base level of the texture does not"
|
||||
" have power-of-two dimensions.");
|
||||
return;
|
||||
}
|
||||
if (format->isSRGB) {
|
||||
mContext->ErrorInvalidOperation("%s: EXT_sRGB forbids GenerateMipmap with"
|
||||
" sRGB.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("EXT_sRGB forbids GenerateMipmap with"
|
||||
" sRGB.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (format->compression) {
|
||||
mContext->ErrorInvalidOperation("%s: Texture data at base level is compressed.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("Texture data at base level is compressed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (format->d) {
|
||||
mContext->ErrorInvalidOperation("%s: Depth textures are not supported.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("Depth textures are not supported.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -930,10 +920,9 @@ WebGLTexture::GenerateMipmap(TexTarget texTarget)
|
|||
}
|
||||
|
||||
if (!canGenerateMipmap) {
|
||||
mContext->ErrorInvalidOperation("%s: Texture at base level is not unsized"
|
||||
mContext->ErrorInvalidOperation("Texture at base level is not unsized"
|
||||
" internal format or is not"
|
||||
" color-renderable or texture-filterable.",
|
||||
funcName);
|
||||
" color-renderable or texture-filterable.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -960,7 +949,7 @@ WebGLTexture::GenerateMipmap(TexTarget texTarget)
|
|||
// Note that we don't use MaxEffectiveMipmapLevel() here, since that returns
|
||||
// mBaseMipmapLevel if the min filter doesn't require mipmaps.
|
||||
const uint32_t maxLevel = mBaseMipmapLevel + baseImageInfo.PossibleMipmapLevels() - 1;
|
||||
PopulateMipChain(funcName, mBaseMipmapLevel, maxLevel);
|
||||
PopulateMipChain(mBaseMipmapLevel, maxLevel);
|
||||
}
|
||||
|
||||
JS::Value
|
||||
|
@ -1135,11 +1124,11 @@ WebGLTexture::TexParameter(TexTarget texTarget, GLenum pname, const FloatOrInt&
|
|||
|
||||
if (paramBadEnum) {
|
||||
if (!param.isFloat) {
|
||||
mContext->ErrorInvalidEnum("texParameteri: pname 0x%04x: Invalid param"
|
||||
mContext->ErrorInvalidEnum("pname 0x%04x: Invalid param"
|
||||
" 0x%04x.",
|
||||
pname, param.i);
|
||||
} else {
|
||||
mContext->ErrorInvalidEnum("texParameterf: pname 0x%04x: Invalid param %g.",
|
||||
mContext->ErrorInvalidEnum("pname 0x%04x: Invalid param %g.",
|
||||
pname, param.f);
|
||||
}
|
||||
return;
|
||||
|
@ -1147,11 +1136,11 @@ WebGLTexture::TexParameter(TexTarget texTarget, GLenum pname, const FloatOrInt&
|
|||
|
||||
if (paramBadValue) {
|
||||
if (!param.isFloat) {
|
||||
mContext->ErrorInvalidValue("texParameteri: pname 0x%04x: Invalid param %i"
|
||||
mContext->ErrorInvalidValue("pname 0x%04x: Invalid param %i"
|
||||
" (0x%x).",
|
||||
pname, param.i, param.i);
|
||||
} else {
|
||||
mContext->ErrorInvalidValue("texParameterf: pname 0x%04x: Invalid param %g.",
|
||||
mContext->ErrorInvalidValue("pname 0x%04x: Invalid param %g.",
|
||||
pname, param.f);
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -48,8 +48,7 @@ class TexUnpackBlob;
|
|||
|
||||
|
||||
bool
|
||||
DoesTargetMatchDimensions(WebGLContext* webgl, TexImageTarget target, uint8_t dims,
|
||||
const char* funcName);
|
||||
DoesTargetMatchDimensions(WebGLContext* webgl, TexImageTarget target, uint8_t dims);
|
||||
|
||||
namespace webgl {
|
||||
|
||||
|
@ -118,19 +117,17 @@ public:
|
|||
// And in turn, it needs these forwards:
|
||||
protected:
|
||||
// We need to forward these.
|
||||
void SetImageInfo(const char* funcName, ImageInfo* target, const ImageInfo& newInfo);
|
||||
void SetImageInfosAtLevel(const char* funcName, uint32_t level,
|
||||
const ImageInfo& newInfo);
|
||||
void SetImageInfo(ImageInfo* target, const ImageInfo& newInfo);
|
||||
void SetImageInfosAtLevel(uint32_t level, const ImageInfo& newInfo);
|
||||
|
||||
public:
|
||||
// We store information about the various images that are part of this
|
||||
// texture. (cubemap faces, mipmap levels)
|
||||
class ImageInfo
|
||||
{
|
||||
friend void WebGLTexture::SetImageInfo(const char* funcName, ImageInfo* target,
|
||||
friend void WebGLTexture::SetImageInfo(ImageInfo* target,
|
||||
const ImageInfo& newInfo);
|
||||
friend void WebGLTexture::SetImageInfosAtLevel(const char* funcName,
|
||||
uint32_t level,
|
||||
friend void WebGLTexture::SetImageInfosAtLevel(uint32_t level,
|
||||
const ImageInfo& newInfo);
|
||||
|
||||
public:
|
||||
|
@ -170,14 +167,14 @@ public:
|
|||
MOZ_ASSERT(mFormat);
|
||||
}
|
||||
|
||||
void Clear(const char* funcName);
|
||||
void Clear();
|
||||
|
||||
~ImageInfo() {
|
||||
MOZ_ASSERT(!mAttachPoints.size());
|
||||
}
|
||||
|
||||
protected:
|
||||
void Set(const char* funcName, const ImageInfo& a);
|
||||
void Set(const ImageInfo& a);
|
||||
|
||||
public:
|
||||
uint32_t PossibleMipmapLevels() const {
|
||||
|
@ -191,7 +188,7 @@ public:
|
|||
|
||||
void AddAttachPoint(WebGLFBAttachPoint* attachPoint);
|
||||
void RemoveAttachPoint(WebGLFBAttachPoint* attachPoint);
|
||||
void OnRespecify(const char* funcName) const;
|
||||
void OnRespecify() const;
|
||||
|
||||
size_t MemoryUsage() const;
|
||||
|
||||
|
@ -247,55 +244,55 @@ public:
|
|||
// WebGLTextureUpload.cpp
|
||||
|
||||
protected:
|
||||
void TexOrSubImageBlob(bool isSubImage, const char* funcName, TexImageTarget target,
|
||||
void TexOrSubImageBlob(bool isSubImage, TexImageTarget target,
|
||||
GLint level, GLenum internalFormat, GLint xOffset,
|
||||
GLint yOffset, GLint zOffset,
|
||||
const webgl::PackingInfo& pi,
|
||||
const webgl::TexUnpackBlob* blob);
|
||||
|
||||
bool ValidateTexImageSpecification(const char* funcName, TexImageTarget target,
|
||||
bool ValidateTexImageSpecification(TexImageTarget target,
|
||||
GLint level, uint32_t width, uint32_t height,
|
||||
uint32_t depth,
|
||||
WebGLTexture::ImageInfo** const out_imageInfo);
|
||||
bool ValidateTexImageSelection(const char* funcName, TexImageTarget target,
|
||||
bool ValidateTexImageSelection(TexImageTarget target,
|
||||
GLint level, GLint xOffset, GLint yOffset,
|
||||
GLint zOffset, uint32_t width, uint32_t height,
|
||||
uint32_t depth,
|
||||
WebGLTexture::ImageInfo** const out_imageInfo);
|
||||
bool ValidateCopyTexImageForFeedback(const char* funcName, uint32_t level, GLint layer = 0) const;
|
||||
bool ValidateCopyTexImageForFeedback(uint32_t level, GLint layer = 0) const;
|
||||
|
||||
bool ValidateUnpack(const char* funcName, const webgl::TexUnpackBlob* blob,
|
||||
bool ValidateUnpack(const webgl::TexUnpackBlob* blob,
|
||||
bool isFunc3D, const webgl::PackingInfo& srcPI) const;
|
||||
public:
|
||||
void TexStorage(const char* funcName, TexTarget target, GLsizei levels,
|
||||
void TexStorage(TexTarget target, GLsizei levels,
|
||||
GLenum sizedFormat, GLsizei width, GLsizei height, GLsizei depth);
|
||||
void TexImage(const char* funcName, TexImageTarget target, GLint level,
|
||||
void TexImage(TexImageTarget target, GLint level,
|
||||
GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth,
|
||||
GLint border, const webgl::PackingInfo& pi, const TexImageSource& src);
|
||||
void TexSubImage(const char* funcName, TexImageTarget target, GLint level,
|
||||
void TexSubImage(TexImageTarget target, GLint level,
|
||||
GLint xOffset, GLint yOffset, GLint zOffset, GLsizei width,
|
||||
GLsizei height, GLsizei depth, const webgl::PackingInfo& pi,
|
||||
const TexImageSource& src);
|
||||
protected:
|
||||
void TexImage(const char* funcName, TexImageTarget target, GLint level,
|
||||
void TexImage(TexImageTarget target, GLint level,
|
||||
GLenum internalFormat, const webgl::PackingInfo& pi,
|
||||
const webgl::TexUnpackBlob* blob);
|
||||
void TexSubImage(const char* funcName, TexImageTarget target, GLint level,
|
||||
void TexSubImage(TexImageTarget target, GLint level,
|
||||
GLint xOffset, GLint yOffset, GLint zOffset,
|
||||
const webgl::PackingInfo& pi, const webgl::TexUnpackBlob* blob);
|
||||
public:
|
||||
void CompressedTexImage(const char* funcName, TexImageTarget target, GLint level,
|
||||
void CompressedTexImage(TexImageTarget target, GLint level,
|
||||
GLenum internalFormat, GLsizei width, GLsizei height,
|
||||
GLsizei depth, GLint border, const TexImageSource& src,
|
||||
const Maybe<GLsizei>& expectedImageSize);
|
||||
void CompressedTexSubImage(const char* funcName, TexImageTarget target, GLint level,
|
||||
void CompressedTexSubImage(TexImageTarget target, GLint level,
|
||||
GLint xOffset, GLint yOffset, GLint zOffset, GLsizei width,
|
||||
GLsizei height, GLsizei depth, GLenum sizedUnpackFormat,
|
||||
const TexImageSource& src, const Maybe<GLsizei>& expectedImageSize);
|
||||
|
||||
void CopyTexImage2D(TexImageTarget target, GLint level, GLenum internalFormat,
|
||||
GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
|
||||
void CopyTexSubImage(const char* funcName, TexImageTarget target, GLint level,
|
||||
void CopyTexSubImage(TexImageTarget target, GLint level,
|
||||
GLint xOffset, GLint yOffset, GLint zOffset, GLint x, GLint y,
|
||||
GLsizei width, GLsizei height);
|
||||
|
||||
|
@ -304,7 +301,7 @@ public:
|
|||
protected:
|
||||
void ClampLevelBaseAndMax();
|
||||
|
||||
void PopulateMipChain(const char* funcName, uint32_t baseLevel, uint32_t maxLevel);
|
||||
void PopulateMipChain(uint32_t baseLevel, uint32_t maxLevel);
|
||||
|
||||
bool MaxEffectiveMipmapLevel(uint32_t texUnit, uint32_t* const out) const;
|
||||
|
||||
|
@ -345,11 +342,11 @@ public:
|
|||
return const_cast<WebGLTexture*>(this)->ImageInfoAt(texImageTarget, level);
|
||||
}
|
||||
|
||||
void SetImageInfoAt(const char* funcName, TexImageTarget texImageTarget, GLint level,
|
||||
void SetImageInfoAt(TexImageTarget texImageTarget, GLint level,
|
||||
const ImageInfo& val)
|
||||
{
|
||||
ImageInfo* target = &ImageInfoAt(texImageTarget, level);
|
||||
SetImageInfo(funcName, target, val);
|
||||
SetImageInfo(target, val);
|
||||
}
|
||||
|
||||
const ImageInfo& BaseImageInfo() const {
|
||||
|
@ -361,11 +358,11 @@ public:
|
|||
|
||||
size_t MemoryUsage() const;
|
||||
|
||||
bool InitializeImageData(const char* funcName, TexImageTarget target, uint32_t level);
|
||||
bool InitializeImageData(TexImageTarget target, uint32_t level);
|
||||
protected:
|
||||
bool EnsureImageDataInitialized(const char* funcName, TexImageTarget target,
|
||||
bool EnsureImageDataInitialized(TexImageTarget target,
|
||||
uint32_t level);
|
||||
bool EnsureLevelInitialized(const char* funcName, uint32_t level);
|
||||
bool EnsureLevelInitialized(uint32_t level);
|
||||
|
||||
public:
|
||||
void SetGeneratedMipmap();
|
||||
|
@ -374,12 +371,12 @@ public:
|
|||
|
||||
bool AreAllLevel0ImageInfosEqual() const;
|
||||
|
||||
bool IsMipmapComplete(const char* funcName, uint32_t texUnit,
|
||||
bool IsMipmapComplete(uint32_t texUnit,
|
||||
bool* const out_initFailed);
|
||||
|
||||
bool IsCubeComplete() const;
|
||||
|
||||
bool IsComplete(const char* funcName, uint32_t texUnit, const char** const out_reason,
|
||||
bool IsComplete(uint32_t texUnit, const char** const out_reason,
|
||||
bool* const out_initFailed);
|
||||
|
||||
bool IsMipmapCubeComplete() const;
|
||||
|
@ -388,13 +385,13 @@ public:
|
|||
|
||||
// Resolve cache optimizations
|
||||
protected:
|
||||
bool GetFakeBlackType(const char* funcName, uint32_t texUnit,
|
||||
bool GetFakeBlackType(uint32_t texUnit,
|
||||
FakeBlackType* const out_fakeBlack);
|
||||
public:
|
||||
bool IsFeedback(WebGLContext* webgl, const char* funcName, uint32_t texUnit,
|
||||
bool IsFeedback(WebGLContext* webgl, uint32_t texUnit,
|
||||
const std::vector<const WebGLFBAttachPoint*>& fbAttachments) const;
|
||||
|
||||
bool ResolveForDraw(const char* funcName, uint32_t texUnit,
|
||||
bool ResolveForDraw(uint32_t texUnit,
|
||||
FakeBlackType* const out_fakeBlack);
|
||||
|
||||
void InvalidateResolveCache() { mIsResolved = false; }
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -41,10 +41,8 @@ WebGLTransformFeedback::Delete()
|
|||
void
|
||||
WebGLTransformFeedback::BeginTransformFeedback(GLenum primMode)
|
||||
{
|
||||
const char funcName[] = "beginTransformFeedback";
|
||||
|
||||
if (mIsActive)
|
||||
return mContext->ErrorInvalidOperation("%s: Already active.", funcName);
|
||||
return mContext->ErrorInvalidOperation("Already active.");
|
||||
|
||||
switch (primMode) {
|
||||
case LOCAL_GL_POINTS:
|
||||
|
@ -52,9 +50,8 @@ WebGLTransformFeedback::BeginTransformFeedback(GLenum primMode)
|
|||
case LOCAL_GL_TRIANGLES:
|
||||
break;
|
||||
default:
|
||||
mContext->ErrorInvalidEnum("%s: `primitiveMode` must be one of POINTS, LINES, or"
|
||||
" TRIANGLES.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidEnum("`primitiveMode` must be one of POINTS, LINES, or"
|
||||
" TRIANGLES.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -63,9 +60,8 @@ WebGLTransformFeedback::BeginTransformFeedback(GLenum primMode)
|
|||
!prog->IsLinked() ||
|
||||
prog->LinkInfo()->componentsPerTFVert.empty())
|
||||
{
|
||||
mContext->ErrorInvalidOperation("%s: Current program not valid for transform"
|
||||
" feedback.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("Current program not valid for transform"
|
||||
" feedback.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -79,9 +75,9 @@ WebGLTransformFeedback::BeginTransformFeedback(GLenum primMode)
|
|||
|
||||
const auto& buffer = indexedBinding.mBufferBinding;
|
||||
if (!buffer) {
|
||||
mContext->ErrorInvalidOperation("%s: No buffer attached to required transform"
|
||||
mContext->ErrorInvalidOperation("No buffer attached to required transform"
|
||||
" feedback index %u.",
|
||||
funcName, (uint32_t)i);
|
||||
(uint32_t)i);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -113,10 +109,8 @@ WebGLTransformFeedback::BeginTransformFeedback(GLenum primMode)
|
|||
void
|
||||
WebGLTransformFeedback::EndTransformFeedback()
|
||||
{
|
||||
const char funcName[] = "endTransformFeedback";
|
||||
|
||||
if (!mIsActive)
|
||||
return mContext->ErrorInvalidOperation("%s: Not active.", funcName);
|
||||
return mContext->ErrorInvalidOperation("Not active.");
|
||||
|
||||
////
|
||||
|
||||
|
@ -148,12 +142,10 @@ WebGLTransformFeedback::EndTransformFeedback()
|
|||
void
|
||||
WebGLTransformFeedback::PauseTransformFeedback()
|
||||
{
|
||||
const char funcName[] = "pauseTransformFeedback";
|
||||
|
||||
if (!mIsActive ||
|
||||
mIsPaused)
|
||||
{
|
||||
mContext->ErrorInvalidOperation("%s: Not active or is paused.", funcName);
|
||||
mContext->ErrorInvalidOperation("Not active or is paused.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -170,14 +162,11 @@ WebGLTransformFeedback::PauseTransformFeedback()
|
|||
void
|
||||
WebGLTransformFeedback::ResumeTransformFeedback()
|
||||
{
|
||||
const char funcName[] = "resumeTransformFeedback";
|
||||
|
||||
if (!mIsPaused)
|
||||
return mContext->ErrorInvalidOperation("%s: Not paused.", funcName);
|
||||
return mContext->ErrorInvalidOperation("Not paused.");
|
||||
|
||||
if (mContext->mCurrentProgram != mActive_Program) {
|
||||
mContext->ErrorInvalidOperation("%s: Active program differs from original.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("Active program differs from original.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ class WebGLTransformFeedback final
|
|||
friend class WebGLProgram;
|
||||
|
||||
friend const webgl::CachedDrawFetchLimits*
|
||||
ValidateDraw(WebGLContext*, const char*, GLenum, uint32_t);
|
||||
ValidateDraw(WebGLContext*, GLenum, uint32_t);
|
||||
|
||||
public:
|
||||
const GLuint mGLName;
|
||||
|
|
|
@ -29,20 +29,18 @@ WebGLUniformLocation::~WebGLUniformLocation()
|
|||
{ }
|
||||
|
||||
bool
|
||||
WebGLUniformLocation::ValidateForProgram(const WebGLProgram* prog,
|
||||
const char* funcName) const
|
||||
WebGLUniformLocation::ValidateForProgram(const WebGLProgram* prog) const
|
||||
{
|
||||
// Check the weak-pointer.
|
||||
if (!mLinkInfo) {
|
||||
mContext->ErrorInvalidOperation("%s: This uniform location is obsolete because"
|
||||
" its program has been successfully relinked.",
|
||||
funcName);
|
||||
mContext->ErrorInvalidOperation("This uniform location is obsolete because"
|
||||
" its program has been successfully relinked.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mLinkInfo->prog != prog) {
|
||||
mContext->ErrorInvalidOperation("%s: This uniform location corresponds to a"
|
||||
" different program.", funcName);
|
||||
mContext->ErrorInvalidOperation("This uniform location corresponds to a"
|
||||
" different program.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -119,23 +117,22 @@ IsUniformSetterTypeValid(GLenum setterType, GLenum uniformType)
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLUniformLocation::ValidateSizeAndType(uint8_t setterElemSize, GLenum setterType,
|
||||
const char* funcName) const
|
||||
WebGLUniformLocation::ValidateSizeAndType(uint8_t setterElemSize, GLenum setterType) const
|
||||
{
|
||||
MOZ_ASSERT(mLinkInfo);
|
||||
|
||||
const auto& uniformElemSize = mInfo->mActiveInfo->mElemSize;
|
||||
if (setterElemSize != uniformElemSize) {
|
||||
mContext->ErrorInvalidOperation("%s: Function used differs from uniform size: %i",
|
||||
funcName, uniformElemSize);
|
||||
mContext->ErrorInvalidOperation("Function used differs from uniform size: %i",
|
||||
uniformElemSize);
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto& uniformElemType = mInfo->mActiveInfo->mElemType;
|
||||
if (!IsUniformSetterTypeValid(setterType, uniformElemType)) {
|
||||
mContext->ErrorInvalidOperation("%s: Function used is incompatible with uniform"
|
||||
mContext->ErrorInvalidOperation("Function used is incompatible with uniform"
|
||||
" type: %i",
|
||||
funcName, uniformElemType);
|
||||
uniformElemType);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -143,17 +140,17 @@ WebGLUniformLocation::ValidateSizeAndType(uint8_t setterElemSize, GLenum setterT
|
|||
}
|
||||
|
||||
bool
|
||||
WebGLUniformLocation::ValidateArrayLength(uint8_t setterElemSize, size_t setterArraySize,
|
||||
const char* funcName) const
|
||||
WebGLUniformLocation::ValidateArrayLength(uint8_t setterElemSize,
|
||||
size_t setterArraySize) const
|
||||
{
|
||||
MOZ_ASSERT(mLinkInfo);
|
||||
|
||||
if (setterArraySize == 0 ||
|
||||
setterArraySize % setterElemSize)
|
||||
{
|
||||
mContext->ErrorInvalidValue("%s: Expected an array of length a multiple of %d,"
|
||||
mContext->ErrorInvalidValue("Expected an array of length a multiple of %d,"
|
||||
" got an array of length %zu.",
|
||||
funcName, setterElemSize, setterArraySize);
|
||||
setterElemSize, setterArraySize);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -167,10 +164,10 @@ WebGLUniformLocation::ValidateArrayLength(uint8_t setterElemSize, size_t setterA
|
|||
if (!mInfo->mActiveInfo->mIsArray &&
|
||||
setterArraySize != setterElemSize)
|
||||
{
|
||||
mContext->ErrorInvalidOperation("%s: Expected an array of length exactly %d"
|
||||
mContext->ErrorInvalidOperation("Expected an array of length exactly %d"
|
||||
" (since this uniform is not an array uniform),"
|
||||
" got an array of length %zu.",
|
||||
funcName, setterElemSize, setterArraySize);
|
||||
setterElemSize, setterArraySize);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,11 +52,9 @@ public:
|
|||
WebGLUniformLocation(WebGLContext* webgl, const webgl::LinkedProgramInfo* linkInfo,
|
||||
webgl::UniformInfo* info, GLuint loc, size_t arrayIndex);
|
||||
|
||||
bool ValidateForProgram(const WebGLProgram* prog, const char* funcName) const;
|
||||
bool ValidateSizeAndType(uint8_t setterElemSize, GLenum setterType,
|
||||
const char* funcName) const;
|
||||
bool ValidateArrayLength(uint8_t setterElemSize, size_t setterArraySize,
|
||||
const char* funcName) const;
|
||||
bool ValidateForProgram(const WebGLProgram* prog) const;
|
||||
bool ValidateSizeAndType(uint8_t setterElemSize, GLenum setterType) const;
|
||||
bool ValidateArrayLength(uint8_t setterElemSize, size_t setterArraySize) const;
|
||||
|
||||
JS::Value GetUniform(JSContext* js) const;
|
||||
|
||||
|
|
|
@ -174,22 +174,20 @@ IsValidGLSLPreprocChar(char16_t c)
|
|||
////
|
||||
|
||||
bool
|
||||
ValidateGLSLPreprocString(WebGLContext* webgl, const char* funcName,
|
||||
const nsAString& string)
|
||||
ValidateGLSLPreprocString(WebGLContext* webgl, const nsAString& string)
|
||||
{
|
||||
for (size_t i = 0; i < string.Length(); ++i) {
|
||||
const auto& cur = string[i];
|
||||
|
||||
if (!IsValidGLSLPreprocChar(cur)) {
|
||||
webgl->ErrorInvalidValue("%s: String contains the illegal character 0x%x.",
|
||||
funcName, cur);
|
||||
webgl->ErrorInvalidValue("String contains the illegal character 0x%x.", cur);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cur == '\\' && !webgl->IsWebGL2()) {
|
||||
// Todo: Backslash is technically still invalid in WebGLSL 1 under even under
|
||||
// WebGL 2.
|
||||
webgl->ErrorInvalidValue("%s: Backslash is not valid in WebGL 1.", funcName);
|
||||
webgl->ErrorInvalidValue("Backslash is not valid in WebGL 1.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -198,24 +196,23 @@ ValidateGLSLPreprocString(WebGLContext* webgl, const char* funcName,
|
|||
}
|
||||
|
||||
bool
|
||||
ValidateGLSLVariableName(const nsAString& name, WebGLContext* webgl, const char* funcName)
|
||||
ValidateGLSLVariableName(const nsAString& name, WebGLContext* webgl)
|
||||
{
|
||||
if (name.IsEmpty())
|
||||
return false;
|
||||
|
||||
const uint32_t maxSize = webgl->IsWebGL2() ? 1024 : 256;
|
||||
if (name.Length() > maxSize) {
|
||||
webgl->ErrorInvalidValue("%s: Identifier is %u characters long, exceeds the"
|
||||
webgl->ErrorInvalidValue("Identifier is %u characters long, exceeds the"
|
||||
" maximum allowed length of %u characters.",
|
||||
funcName, name.Length(), maxSize);
|
||||
name.Length(), maxSize);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < name.Length(); ++i) {
|
||||
const auto& cur = name[i];
|
||||
if (!IsValidGLSLChar(cur)) {
|
||||
webgl->ErrorInvalidValue("%s: String contains the illegal character 0x%x'.",
|
||||
funcName, cur);
|
||||
webgl->ErrorInvalidValue("String contains the illegal character 0x%x'.", cur);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -226,8 +223,7 @@ ValidateGLSLVariableName(const nsAString& name, WebGLContext* webgl, const char*
|
|||
if (Substring(name, 0, prefix1.Length()).Equals(prefix1) ||
|
||||
Substring(name, 0, prefix2.Length()).Equals(prefix2))
|
||||
{
|
||||
webgl->ErrorInvalidOperation("%s: String contains a reserved GLSL prefix.",
|
||||
funcName);
|
||||
webgl->ErrorInvalidOperation("String contains a reserved GLSL prefix.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,11 +36,9 @@ class WebGLContext;
|
|||
bool
|
||||
TruncateComments(const nsAString& src, nsAString* const out);
|
||||
bool
|
||||
ValidateGLSLPreprocString(WebGLContext* webgl, const char* funcName,
|
||||
const nsAString& string);
|
||||
ValidateGLSLPreprocString(WebGLContext* webgl, const nsAString& string);
|
||||
bool
|
||||
ValidateGLSLVariableName(const nsAString& name, WebGLContext* webgl,
|
||||
const char* funcName);
|
||||
ValidateGLSLVariableName(const nsAString& name, WebGLContext* webgl);
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче