зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1359055 - Part 1: PBO offset for WebGL compressedTexImage; r=baku,jgilbert
MozReview-Commit-ID: LN2diy41A2Z --HG-- extra : rebase_source : d77ee2b289348e0609bac248dfab670c72623fa0
This commit is contained in:
Родитель
daeca3277c
Коммит
280b27a0fb
|
@ -115,6 +115,17 @@ protected:
|
|||
////////////////////////////////////
|
||||
|
||||
public:
|
||||
void CompressedTexImage3D(GLenum target, GLint level, GLenum internalFormat,
|
||||
GLsizei width, GLsizei height, GLsizei depth, GLint border,
|
||||
GLsizei imageSize, WebGLintptr offset)
|
||||
{
|
||||
const char funcName[] = "compressedTexImage3D";
|
||||
const uint8_t funcDims = 3;
|
||||
const TexImageSourceAdapter src(&offset, 0, 0);
|
||||
CompressedTexImage(funcName, funcDims, target, level, internalFormat, width,
|
||||
height, depth, border, src, Some(imageSize));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CompressedTexImage3D(GLenum target, GLint level, GLenum internalFormat,
|
||||
GLsizei width, GLsizei height, GLsizei depth, GLint border,
|
||||
|
@ -125,7 +136,19 @@ public:
|
|||
const uint8_t funcDims = 3;
|
||||
const TexImageSourceAdapter src(&anySrc, viewElemOffset, viewElemLengthOverride);
|
||||
CompressedTexImage(funcName, funcDims, target, level, internalFormat, width,
|
||||
height, depth, border, src);
|
||||
height, depth, border, src, Nothing());
|
||||
}
|
||||
|
||||
void CompressedTexSubImage3D(GLenum target, GLint level, GLint xOffset, GLint yOffset,
|
||||
GLint zOffset, GLsizei width, GLsizei height,
|
||||
GLsizei depth, GLenum unpackFormat,
|
||||
GLsizei imageSize, WebGLintptr offset)
|
||||
{
|
||||
const char funcName[] = "compressedTexSubImage3D";
|
||||
const uint8_t funcDims = 3;
|
||||
const TexImageSourceAdapter src(&offset, 0, 0);
|
||||
CompressedTexSubImage(funcName, funcDims, target, level, xOffset, yOffset,
|
||||
zOffset, width, height, depth, unpackFormat, src, Some(imageSize));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -139,7 +162,7 @@ public:
|
|||
const uint8_t funcDims = 3;
|
||||
const TexImageSourceAdapter src(&anySrc, viewElemOffset, viewElemLengthOverride);
|
||||
CompressedTexSubImage(funcName, funcDims, target, level, xOffset, yOffset,
|
||||
zOffset, width, height, depth, unpackFormat, src);
|
||||
zOffset, width, height, depth, unpackFormat, src, Nothing());
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
|
|
|
@ -1052,6 +1052,18 @@ protected:
|
|||
////////////////////////////////////
|
||||
|
||||
public:
|
||||
void CompressedTexImage2D(GLenum target, GLint level, GLenum internalFormat,
|
||||
GLsizei width, GLsizei height, GLint border,
|
||||
GLsizei imageSize, WebGLsizeiptr offset)
|
||||
{
|
||||
const char funcName[] = "compressedTexImage2D";
|
||||
const uint8_t funcDims = 2;
|
||||
const GLsizei depth = 1;
|
||||
const TexImageSourceAdapter src(&offset, 0, 0);
|
||||
CompressedTexImage(funcName, funcDims, target, level, internalFormat, width,
|
||||
height, depth, border, src, Some(imageSize));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void CompressedTexImage2D(GLenum target, GLint level, GLenum internalFormat,
|
||||
GLsizei width, GLsizei height, GLint border,
|
||||
|
@ -1063,7 +1075,20 @@ public:
|
|||
const GLsizei depth = 1;
|
||||
const TexImageSourceAdapter src(&anySrc, viewElemOffset, viewElemLengthOverride);
|
||||
CompressedTexImage(funcName, funcDims, target, level, internalFormat, width,
|
||||
height, depth, border, src);
|
||||
height, depth, border, src, Nothing());
|
||||
}
|
||||
|
||||
void CompressedTexSubImage2D(GLenum target, GLint level, GLint xOffset, GLint yOffset,
|
||||
GLsizei width, GLsizei height, GLenum unpackFormat,
|
||||
GLsizei imageSize, WebGLsizeiptr offset)
|
||||
{
|
||||
const char funcName[] = "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,
|
||||
zOffset, width, height, depth, unpackFormat, src, Some(imageSize));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
@ -1078,20 +1103,19 @@ public:
|
|||
const GLsizei depth = 1;
|
||||
const TexImageSourceAdapter src(&anySrc, viewElemOffset, viewElemLengthOverride);
|
||||
CompressedTexSubImage(funcName, funcDims, target, level, xOffset, yOffset,
|
||||
zOffset, width, height, depth, unpackFormat, src);
|
||||
zOffset, width, height, depth, unpackFormat, src, Nothing());
|
||||
}
|
||||
|
||||
protected:
|
||||
void CompressedTexImage(const char* funcName, uint8_t funcDims, GLenum target,
|
||||
GLint level, GLenum internalFormat, GLsizei width,
|
||||
GLsizei height, GLsizei depth, GLint border,
|
||||
const TexImageSource& src);
|
||||
|
||||
const TexImageSource& src, const Maybe<GLsizei>& expectedImageSize);
|
||||
void CompressedTexSubImage(const char* funcName, uint8_t funcDims, GLenum target,
|
||||
GLint level, GLint xOffset, GLint yOffset, GLint zOffset,
|
||||
GLsizei width, GLsizei height, GLsizei depth,
|
||||
GLenum unpackFormat, const TexImageSource& src);
|
||||
|
||||
GLenum unpackFormat, const TexImageSource& src,
|
||||
const Maybe<GLsizei>& expectedImageSize);
|
||||
////////////////////////////////////
|
||||
|
||||
public:
|
||||
|
@ -1257,7 +1281,7 @@ protected:
|
|||
UniquePtr<webgl::TexUnpackBytes>
|
||||
FromCompressed(const char* funcName, TexImageTarget target, GLsizei rawWidth,
|
||||
GLsizei rawHeight, GLsizei rawDepth, GLint border,
|
||||
const TexImageSource& src);
|
||||
const TexImageSource& src, const Maybe<GLsizei>& expectedImageSize);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Vertices Feature (WebGLContextVertices.cpp)
|
||||
|
|
|
@ -318,7 +318,7 @@ void
|
|||
WebGLContext::CompressedTexImage(const char* funcName, uint8_t funcDims, GLenum rawTarget,
|
||||
GLint level, GLenum internalFormat, GLsizei width,
|
||||
GLsizei height, GLsizei depth, GLint border,
|
||||
const TexImageSource& src)
|
||||
const TexImageSource& src, const Maybe<GLsizei>& expectedImageSize)
|
||||
{
|
||||
TexImageTarget target;
|
||||
WebGLTexture* tex;
|
||||
|
@ -326,7 +326,7 @@ WebGLContext::CompressedTexImage(const char* funcName, uint8_t funcDims, GLenum
|
|||
return;
|
||||
|
||||
tex->CompressedTexImage(funcName, target, level, internalFormat, width, height, depth,
|
||||
border, src);
|
||||
border, src, expectedImageSize);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -334,7 +334,7 @@ WebGLContext::CompressedTexSubImage(const char* funcName, uint8_t funcDims,
|
|||
GLenum rawTarget, GLint level, GLint xOffset,
|
||||
GLint yOffset, GLint zOffset, GLsizei width,
|
||||
GLsizei height, GLsizei depth, GLenum unpackFormat,
|
||||
const TexImageSource& src)
|
||||
const TexImageSource& src, const Maybe<GLsizei>& expectedImageSize)
|
||||
{
|
||||
TexImageTarget target;
|
||||
WebGLTexture* tex;
|
||||
|
@ -342,7 +342,7 @@ WebGLContext::CompressedTexSubImage(const char* funcName, uint8_t funcDims,
|
|||
return;
|
||||
|
||||
tex->CompressedTexSubImage(funcName, target, level, xOffset, yOffset, zOffset, width,
|
||||
height, depth, unpackFormat, src);
|
||||
height, depth, unpackFormat, src, expectedImageSize);
|
||||
}
|
||||
|
||||
////
|
||||
|
|
|
@ -273,11 +273,12 @@ protected:
|
|||
public:
|
||||
void CompressedTexImage(const char* funcName, TexImageTarget target, GLint level,
|
||||
GLenum internalFormat, GLsizei width, GLsizei height,
|
||||
GLsizei depth, GLint border, const TexImageSource& src);
|
||||
GLsizei depth, GLint border, const TexImageSource& src,
|
||||
const Maybe<GLsizei>& expectedImageSize);
|
||||
void CompressedTexSubImage(const char* funcName, TexImageTarget target, GLint level,
|
||||
GLint xOffset, GLint yOffset, GLint zOffset, GLsizei width,
|
||||
GLsizei height, GLsizei depth, GLenum sizedUnpackFormat,
|
||||
const TexImageSource& src);
|
||||
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);
|
||||
|
|
|
@ -186,7 +186,8 @@ FromView(WebGLContext* webgl, const char* funcName, TexImageTarget target,
|
|||
|
||||
static UniquePtr<webgl::TexUnpackBytes>
|
||||
FromPboOffset(WebGLContext* webgl, const char* funcName, TexImageTarget target,
|
||||
uint32_t width, uint32_t height, uint32_t depth, WebGLsizeiptr pboOffset)
|
||||
uint32_t width, uint32_t height, uint32_t depth, WebGLsizeiptr pboOffset,
|
||||
const Maybe<GLsizei>& expectedImageSize)
|
||||
{
|
||||
if (pboOffset < 0) {
|
||||
webgl->ErrorInvalidValue("%s: offset cannot be negative.", funcName);
|
||||
|
@ -204,7 +205,17 @@ FromPboOffset(WebGLContext* webgl, const char* funcName, TexImageTarget target,
|
|||
return nullptr;
|
||||
}
|
||||
availBufferBytes -= pboOffset;
|
||||
|
||||
if (expectedImageSize.isSome()) {
|
||||
if (expectedImageSize.ref() < 0) {
|
||||
webgl->ErrorInvalidValue("%s: ImageSize can't be less than 0.", funcName);
|
||||
return nullptr;
|
||||
}
|
||||
if (size_t(expectedImageSize.ref()) != availBufferBytes) {
|
||||
webgl->ErrorInvalidOperation("%s: ImageSize doesn't match the required upload byte size.", funcName);
|
||||
return nullptr;
|
||||
}
|
||||
availBufferBytes = size_t(expectedImageSize.ref());
|
||||
}
|
||||
const bool isClientData = false;
|
||||
const auto ptr = (const uint8_t*)pboOffset;
|
||||
return MakeUnique<webgl::TexUnpackBytes>(webgl, target, width, height, depth,
|
||||
|
@ -399,7 +410,7 @@ WebGLContext::From(const char* funcName, TexImageTarget target, GLsizei rawWidth
|
|||
|
||||
if (src.mPboOffset) {
|
||||
return FromPboOffset(this, funcName, target, width, height, depth,
|
||||
*(src.mPboOffset));
|
||||
*(src.mPboOffset), Nothing());
|
||||
}
|
||||
|
||||
if (mBoundPixelUnpackBuffer) {
|
||||
|
@ -1415,7 +1426,8 @@ WebGLTexture::TexSubImage(const char* funcName, TexImageTarget target, GLint lev
|
|||
UniquePtr<webgl::TexUnpackBytes>
|
||||
WebGLContext::FromCompressed(const char* funcName, TexImageTarget target,
|
||||
GLsizei rawWidth, GLsizei rawHeight, GLsizei rawDepth,
|
||||
GLint border, const TexImageSource& src)
|
||||
GLint border, const TexImageSource& src,
|
||||
const Maybe<GLsizei>& expectedImageSize)
|
||||
{
|
||||
uint32_t width, height, depth;
|
||||
if (!ValidateExtents(this, funcName, rawWidth, rawHeight, rawDepth, border, &width,
|
||||
|
@ -1426,7 +1438,7 @@ WebGLContext::FromCompressed(const char* funcName, TexImageTarget target,
|
|||
|
||||
if (src.mPboOffset) {
|
||||
return FromPboOffset(this, funcName, target, width, height, depth,
|
||||
*(src.mPboOffset));
|
||||
*(src.mPboOffset), expectedImageSize);
|
||||
}
|
||||
|
||||
if (mBoundPixelUnpackBuffer) {
|
||||
|
@ -1442,10 +1454,10 @@ void
|
|||
WebGLTexture::CompressedTexImage(const char* funcName, TexImageTarget target, GLint level,
|
||||
GLenum internalFormat, GLsizei rawWidth,
|
||||
GLsizei rawHeight, GLsizei rawDepth, GLint border,
|
||||
const TexImageSource& src)
|
||||
const TexImageSource& src, const Maybe<GLsizei>& expectedImageSize)
|
||||
{
|
||||
const auto blob = mContext->FromCompressed(funcName, target, rawWidth, rawHeight,
|
||||
rawDepth, border, src);
|
||||
rawDepth, border, src, expectedImageSize);
|
||||
if (!blob)
|
||||
return;
|
||||
|
||||
|
@ -1500,6 +1512,8 @@ WebGLTexture::CompressedTexImage(const char* funcName, TexImageTarget target, GL
|
|||
// Do the thing!
|
||||
|
||||
mContext->gl->MakeCurrent();
|
||||
const ScopedLazyBind bindPBO(mContext->gl, LOCAL_GL_PIXEL_UNPACK_BUFFER,
|
||||
mContext->mBoundPixelUnpackBuffer);
|
||||
|
||||
// Warning: Possibly shared memory. See bug 1225033.
|
||||
GLenum error = DoCompressedTexImage(mContext->gl, target, level, internalFormat,
|
||||
|
@ -1553,11 +1567,11 @@ WebGLTexture::CompressedTexSubImage(const char* funcName, TexImageTarget target,
|
|||
GLint level, GLint xOffset, GLint yOffset,
|
||||
GLint zOffset, GLsizei rawWidth, GLsizei rawHeight,
|
||||
GLsizei rawDepth, GLenum sizedUnpackFormat,
|
||||
const TexImageSource& src)
|
||||
const TexImageSource& src, const Maybe<GLsizei>& expectedImageSize)
|
||||
{
|
||||
const GLint border = 0;
|
||||
const auto blob = mContext->FromCompressed(funcName, target, rawWidth, rawHeight,
|
||||
rawDepth, border, src);
|
||||
rawDepth, border, src, expectedImageSize);
|
||||
if (!blob)
|
||||
return;
|
||||
|
||||
|
@ -1651,6 +1665,9 @@ WebGLTexture::CompressedTexSubImage(const char* funcName, TexImageTarget target,
|
|||
return;
|
||||
}
|
||||
|
||||
const ScopedLazyBind bindPBO(mContext->gl, LOCAL_GL_PIXEL_UNPACK_BUFFER,
|
||||
mContext->mBoundPixelUnpackBuffer);
|
||||
|
||||
// Warning: Possibly shared memory. See bug 1225033.
|
||||
GLenum error = DoCompressedTexSubImage(mContext->gl, target, level, xOffset, yOffset,
|
||||
zOffset, blob->mWidth, blob->mHeight,
|
||||
|
|
|
@ -511,19 +511,19 @@ interface WebGL2RenderingContextBase
|
|||
GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
|
||||
void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width,
|
||||
GLsizei height, GLint border, GLintptr offset);
|
||||
GLsizei height, GLint border, GLsizei imageSize, GLintptr offset);
|
||||
void compressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width,
|
||||
GLsizei height, GLint border, ArrayBufferView srcData,
|
||||
optional GLuint srcOffset = 0, optional GLuint srcLengthOverride = 0);
|
||||
|
||||
void compressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width,
|
||||
GLsizei height, GLsizei depth, GLint border, GLintptr offset);
|
||||
GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, GLintptr offset);
|
||||
void compressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width,
|
||||
GLsizei height, GLsizei depth, GLint border, ArrayBufferView srcData,
|
||||
optional GLuint srcOffset = 0, optional GLuint srcLengthOverride = 0);
|
||||
|
||||
void compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
|
||||
GLsizei width, GLsizei height, GLenum format, GLintptr offset);
|
||||
GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, GLintptr offset);
|
||||
void compressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
|
||||
GLsizei width, GLsizei height, GLenum format,
|
||||
ArrayBufferView srcData,
|
||||
|
@ -532,7 +532,7 @@ interface WebGL2RenderingContextBase
|
|||
|
||||
void compressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
|
||||
GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
|
||||
GLenum format, GLintptr offset);
|
||||
GLenum format, GLsizei imageSize, GLintptr offset);
|
||||
void compressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset,
|
||||
GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
|
||||
GLenum format, ArrayBufferView srcData,
|
||||
|
|
Загрузка…
Ссылка в новой задаче