Commit 73a84969 by Jamie Madill Committed by Commit Bot

Refactor more Texture entry points to a consistent style.

TexImage, SubImage and the Compressed variants were all taking a GL Context as the first parameter, which is a layering violation and also caused problems with reworking how the sync works. Fix this by refactoring them in the same style as the CopyTex* entry points. BUG=angleproject:1260 BUG=angleproject:747 Change-Id: Ibe5e87d0ebc790e2dcadb8ba153cf40fec73d1f6 Reviewed-on: https://chromium-review.googlesource.com/327258Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 6ad306cb
...@@ -2421,4 +2421,218 @@ void Context::invalidateSubFramebuffer(GLenum target, ...@@ -2421,4 +2421,218 @@ void Context::invalidateSubFramebuffer(GLenum target,
} }
} }
void Context::texImage2D(GLenum target,
GLint level,
GLint internalformat,
GLsizei width,
GLsizei height,
GLint border,
GLenum format,
GLenum type,
const GLvoid *pixels)
{
// Sync the unpack state
syncRendererState(mState.unpackStateBitMask());
Extents size(width, height, 1);
Texture *texture =
getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target);
Error error = texture->setImage(mState.getUnpackState(), target, level, internalformat, size,
format, type, reinterpret_cast<const uint8_t *>(pixels));
if (error.isError())
{
recordError(error);
}
}
void Context::texImage3D(GLenum target,
GLint level,
GLint internalformat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLint border,
GLenum format,
GLenum type,
const GLvoid *pixels)
{
// Sync the unpack state
syncRendererState(mState.unpackStateBitMask());
Extents size(width, height, depth);
Texture *texture = getTargetTexture(target);
Error error = texture->setImage(mState.getUnpackState(), target, level, internalformat, size,
format, type, reinterpret_cast<const uint8_t *>(pixels));
if (error.isError())
{
recordError(error);
}
}
void Context::texSubImage2D(GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLsizei width,
GLsizei height,
GLenum format,
GLenum type,
const GLvoid *pixels)
{
// Zero sized uploads are valid but no-ops
if (width == 0 || height == 0)
{
return;
}
// Sync the unpack state
syncRendererState(mState.unpackStateBitMask());
Box area(xoffset, yoffset, 0, width, height, 1);
Texture *texture =
getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target);
Error error = texture->setSubImage(mState.getUnpackState(), target, level, area, format, type,
reinterpret_cast<const uint8_t *>(pixels));
if (error.isError())
{
recordError(error);
}
}
void Context::texSubImage3D(GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLint zoffset,
GLsizei width,
GLsizei height,
GLsizei depth,
GLenum format,
GLenum type,
const GLvoid *pixels)
{
// Zero sized uploads are valid but no-ops
if (width == 0 || height == 0 || depth == 0)
{
return;
}
// Sync the unpack state
syncRendererState(mState.unpackStateBitMask());
Box area(xoffset, yoffset, zoffset, width, height, depth);
Texture *texture = getTargetTexture(target);
Error error = texture->setSubImage(mState.getUnpackState(), target, level, area, format, type,
reinterpret_cast<const uint8_t *>(pixels));
if (error.isError())
{
recordError(error);
}
}
void Context::compressedTexImage2D(GLenum target,
GLint level,
GLenum internalformat,
GLsizei width,
GLsizei height,
GLint border,
GLsizei imageSize,
const GLvoid *data)
{
// Sync the unpack state
syncRendererState(mState.unpackStateBitMask());
Extents size(width, height, 1);
Texture *texture =
getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target);
Error error =
texture->setCompressedImage(mState.getUnpackState(), target, level, internalformat, size,
imageSize, reinterpret_cast<const uint8_t *>(data));
if (error.isError())
{
recordError(error);
}
}
void Context::compressedTexImage3D(GLenum target,
GLint level,
GLenum internalformat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLint border,
GLsizei imageSize,
const GLvoid *data)
{
// Sync the unpack state
syncRendererState(mState.unpackStateBitMask());
Extents size(width, height, depth);
Texture *texture = getTargetTexture(target);
Error error =
texture->setCompressedImage(mState.getUnpackState(), target, level, internalformat, size,
imageSize, reinterpret_cast<const uint8_t *>(data));
if (error.isError())
{
recordError(error);
}
}
void Context::compressedTexSubImage2D(GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLsizei width,
GLsizei height,
GLenum format,
GLsizei imageSize,
const GLvoid *data)
{
// Sync the unpack state
syncRendererState(mState.unpackStateBitMask());
Box area(xoffset, yoffset, 0, width, height, 1);
Texture *texture =
getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target);
Error error =
texture->setCompressedSubImage(mState.getUnpackState(), target, level, area, format,
imageSize, reinterpret_cast<const uint8_t *>(data));
if (error.isError())
{
recordError(error);
}
}
void Context::compressedTexSubImage3D(GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLint zoffset,
GLsizei width,
GLsizei height,
GLsizei depth,
GLenum format,
GLsizei imageSize,
const GLvoid *data)
{
// Zero sized uploads are valid but no-ops
if (width == 0 || height == 0)
{
return;
}
// Sync the unpack state
syncRendererState(mState.unpackStateBitMask());
Box area(xoffset, yoffset, zoffset, width, height, depth);
Texture *texture = getTargetTexture(target);
Error error =
texture->setCompressedSubImage(mState.getUnpackState(), target, level, area, format,
imageSize, reinterpret_cast<const uint8_t *>(data));
if (error.isError())
{
recordError(error);
}
}
} // namespace gl } // namespace gl
...@@ -286,6 +286,83 @@ class Context final : public ValidationContext ...@@ -286,6 +286,83 @@ class Context final : public ValidationContext
GLsizei width, GLsizei width,
GLsizei height); GLsizei height);
void texImage2D(GLenum target,
GLint level,
GLint internalformat,
GLsizei width,
GLsizei height,
GLint border,
GLenum format,
GLenum type,
const GLvoid *pixels);
void texImage3D(GLenum target,
GLint level,
GLint internalformat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLint border,
GLenum format,
GLenum type,
const GLvoid *pixels);
void texSubImage2D(GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLsizei width,
GLsizei height,
GLenum format,
GLenum type,
const GLvoid *pixels);
void texSubImage3D(GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLint zoffset,
GLsizei width,
GLsizei height,
GLsizei depth,
GLenum format,
GLenum type,
const GLvoid *pixels);
void compressedTexImage2D(GLenum target,
GLint level,
GLenum internalformat,
GLsizei width,
GLsizei height,
GLint border,
GLsizei imageSize,
const GLvoid *data);
void compressedTexImage3D(GLenum target,
GLint level,
GLenum internalformat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLint border,
GLsizei imageSize,
const GLvoid *data);
void compressedTexSubImage2D(GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLsizei width,
GLsizei height,
GLenum format,
GLsizei imageSize,
const GLvoid *data);
void compressedTexSubImage3D(GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLint zoffset,
GLsizei width,
GLsizei height,
GLsizei depth,
GLenum format,
GLsizei imageSize,
const GLvoid *data);
Error flush(); Error flush();
Error finish(); Error finish();
......
...@@ -87,10 +87,12 @@ TEST(ImageTest, RespecificationReleasesReferences) ...@@ -87,10 +87,12 @@ TEST(ImageTest, RespecificationReleasesReferences)
gl::Texture *texture = new gl::Texture(textureImpl, 1, GL_TEXTURE_2D); gl::Texture *texture = new gl::Texture(textureImpl, 1, GL_TEXTURE_2D);
texture->addRef(); texture->addRef();
gl::PixelUnpackState defaultUnpackState;
EXPECT_CALL(*textureImpl, setImage(_, _, _, _, _, _, _, _)) EXPECT_CALL(*textureImpl, setImage(_, _, _, _, _, _, _, _))
.WillOnce(Return(gl::Error(GL_NO_ERROR))) .WillOnce(Return(gl::Error(GL_NO_ERROR)))
.RetiresOnSaturation(); .RetiresOnSaturation();
texture->setImage(nullptr, GL_TEXTURE_2D, 0, GL_RGBA8, gl::Extents(1, 1, 1), GL_RGBA, texture->setImage(defaultUnpackState, GL_TEXTURE_2D, 0, GL_RGBA8, gl::Extents(1, 1, 1), GL_RGBA,
GL_UNSIGNED_BYTE, nullptr); GL_UNSIGNED_BYTE, nullptr);
rx::MockImageImpl *imageImpl = new rx::MockImageImpl(); rx::MockImageImpl *imageImpl = new rx::MockImageImpl();
...@@ -110,7 +112,7 @@ TEST(ImageTest, RespecificationReleasesReferences) ...@@ -110,7 +112,7 @@ TEST(ImageTest, RespecificationReleasesReferences)
.WillOnce(Return(gl::Error(GL_NO_ERROR))) .WillOnce(Return(gl::Error(GL_NO_ERROR)))
.RetiresOnSaturation(); .RetiresOnSaturation();
texture->setImage(nullptr, GL_TEXTURE_2D, 0, GL_RGBA8, gl::Extents(1, 1, 1), GL_RGBA, texture->setImage(defaultUnpackState, GL_TEXTURE_2D, 0, GL_RGBA8, gl::Extents(1, 1, 1), GL_RGBA,
GL_UNSIGNED_BYTE, nullptr); GL_UNSIGNED_BYTE, nullptr);
EXPECT_EQ(texture->getRefCount(), 1u); EXPECT_EQ(texture->getRefCount(), 1u);
......
...@@ -369,7 +369,7 @@ egl::Surface *Texture::getBoundSurface() const ...@@ -369,7 +369,7 @@ egl::Surface *Texture::getBoundSurface() const
return mBoundSurface; return mBoundSurface;
} }
Error Texture::setImage(Context *context, Error Texture::setImage(const PixelUnpackState &unpackState,
GLenum target, GLenum target,
size_t level, size_t level,
GLenum internalFormat, GLenum internalFormat,
...@@ -384,16 +384,8 @@ Error Texture::setImage(Context *context, ...@@ -384,16 +384,8 @@ Error Texture::setImage(Context *context,
releaseTexImageInternal(); releaseTexImageInternal();
orphanImages(); orphanImages();
// Hack: allow nullptr for testing Error error =
if (context != nullptr) mTexture->setImage(target, level, internalFormat, size, format, type, unpackState, pixels);
{
// Sync the unpack state
context->syncRendererState(context->getState().unpackStateBitMask());
}
const PixelUnpackState defaultUnpack;
const PixelUnpackState &unpack = context ? context->getState().getUnpackState() : defaultUnpack;
Error error = mTexture->setImage(target, level, internalFormat, size, format, type, unpack, pixels);
if (error.isError()) if (error.isError())
{ {
return error; return error;
...@@ -404,7 +396,7 @@ Error Texture::setImage(Context *context, ...@@ -404,7 +396,7 @@ Error Texture::setImage(Context *context,
return Error(GL_NO_ERROR); return Error(GL_NO_ERROR);
} }
Error Texture::setSubImage(Context *context, Error Texture::setSubImage(const PixelUnpackState &unpackState,
GLenum target, GLenum target,
size_t level, size_t level,
const Box &area, const Box &area,
...@@ -413,15 +405,10 @@ Error Texture::setSubImage(Context *context, ...@@ -413,15 +405,10 @@ Error Texture::setSubImage(Context *context,
const uint8_t *pixels) const uint8_t *pixels)
{ {
ASSERT(target == mTarget || (mTarget == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); ASSERT(target == mTarget || (mTarget == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target)));
return mTexture->setSubImage(target, level, area, format, type, unpackState, pixels);
// Sync the unpack state
context->syncRendererState(context->getState().unpackStateBitMask());
const PixelUnpackState &unpack = context->getState().getUnpackState();
return mTexture->setSubImage(target, level, area, format, type, unpack, pixels);
} }
Error Texture::setCompressedImage(Context *context, Error Texture::setCompressedImage(const PixelUnpackState &unpackState,
GLenum target, GLenum target,
size_t level, size_t level,
GLenum internalFormat, GLenum internalFormat,
...@@ -435,11 +422,8 @@ Error Texture::setCompressedImage(Context *context, ...@@ -435,11 +422,8 @@ Error Texture::setCompressedImage(Context *context,
releaseTexImageInternal(); releaseTexImageInternal();
orphanImages(); orphanImages();
// Sync the unpack state Error error = mTexture->setCompressedImage(target, level, internalFormat, size, unpackState,
context->syncRendererState(context->getState().unpackStateBitMask()); imageSize, pixels);
const PixelUnpackState &unpack = context->getState().getUnpackState();
Error error = mTexture->setCompressedImage(target, level, internalFormat, size, unpack, imageSize, pixels);
if (error.isError()) if (error.isError())
{ {
return error; return error;
...@@ -450,7 +434,7 @@ Error Texture::setCompressedImage(Context *context, ...@@ -450,7 +434,7 @@ Error Texture::setCompressedImage(Context *context,
return Error(GL_NO_ERROR); return Error(GL_NO_ERROR);
} }
Error Texture::setCompressedSubImage(Context *context, Error Texture::setCompressedSubImage(const PixelUnpackState &unpackState,
GLenum target, GLenum target,
size_t level, size_t level,
const Box &area, const Box &area,
...@@ -460,11 +444,8 @@ Error Texture::setCompressedSubImage(Context *context, ...@@ -460,11 +444,8 @@ Error Texture::setCompressedSubImage(Context *context,
{ {
ASSERT(target == mTarget || (mTarget == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target))); ASSERT(target == mTarget || (mTarget == GL_TEXTURE_CUBE_MAP && IsCubeMapTextureTarget(target)));
// Sync the unpack state return mTexture->setCompressedSubImage(target, level, area, format, unpackState, imageSize,
context->syncRendererState(context->getState().unpackStateBitMask()); pixels);
const PixelUnpackState &unpack = context->getState().getUnpackState();
return mTexture->setCompressedSubImage(target, level, area, format, unpack, imageSize, pixels);
} }
Error Texture::copyImage(GLenum target, size_t level, const Rectangle &sourceArea, GLenum internalFormat, Error Texture::copyImage(GLenum target, size_t level, const Rectangle &sourceArea, GLenum internalFormat,
......
...@@ -30,7 +30,6 @@ class Surface; ...@@ -30,7 +30,6 @@ class Surface;
namespace gl namespace gl
{ {
class Context;
class Framebuffer; class Framebuffer;
struct Data; struct Data;
...@@ -118,7 +117,7 @@ class Texture final : public egl::ImageSibling, ...@@ -118,7 +117,7 @@ class Texture final : public egl::ImageSibling,
bool isCubeComplete() const; bool isCubeComplete() const;
size_t getMipCompleteLevels() const; size_t getMipCompleteLevels() const;
Error setImage(Context *context, Error setImage(const PixelUnpackState &unpackState,
GLenum target, GLenum target,
size_t level, size_t level,
GLenum internalFormat, GLenum internalFormat,
...@@ -126,7 +125,7 @@ class Texture final : public egl::ImageSibling, ...@@ -126,7 +125,7 @@ class Texture final : public egl::ImageSibling,
GLenum format, GLenum format,
GLenum type, GLenum type,
const uint8_t *pixels); const uint8_t *pixels);
Error setSubImage(Context *context, Error setSubImage(const PixelUnpackState &unpackState,
GLenum target, GLenum target,
size_t level, size_t level,
const Box &area, const Box &area,
...@@ -134,14 +133,14 @@ class Texture final : public egl::ImageSibling, ...@@ -134,14 +133,14 @@ class Texture final : public egl::ImageSibling,
GLenum type, GLenum type,
const uint8_t *pixels); const uint8_t *pixels);
Error setCompressedImage(Context *context, Error setCompressedImage(const PixelUnpackState &unpackState,
GLenum target, GLenum target,
size_t level, size_t level,
GLenum internalFormat, GLenum internalFormat,
const Extents &size, const Extents &size,
size_t imageSize, size_t imageSize,
const uint8_t *pixels); const uint8_t *pixels);
Error setCompressedSubImage(Context *context, Error setCompressedSubImage(const PixelUnpackState &unpackState,
GLenum target, GLenum target,
size_t level, size_t level,
const Box &area, const Box &area,
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "libANGLE/validationES2.h" #include "libANGLE/validationES2.h"
#include "libANGLE/validationES.h" #include "libANGLE/validationES.h"
#include "libANGLE/validationES3.h"
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/Texture.h" #include "libANGLE/Texture.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
...@@ -1753,4 +1754,132 @@ bool ValidateDrawBuffersEXT(ValidationContext *context, GLsizei n, const GLenum ...@@ -1753,4 +1754,132 @@ bool ValidateDrawBuffersEXT(ValidationContext *context, GLsizei n, const GLenum
return ValidateDrawBuffersBase(context, n, bufs); return ValidateDrawBuffersBase(context, n, bufs);
} }
bool ValidateTexImage2D(Context *context,
GLenum target,
GLint level,
GLint internalformat,
GLsizei width,
GLsizei height,
GLint border,
GLenum format,
GLenum type,
const GLvoid *pixels)
{
if (context->getClientVersion() < 3)
{
return ValidateES2TexImageParameters(context, target, level, internalformat, false, false,
0, 0, width, height, border, format, type, pixels);
}
ASSERT(context->getClientVersion() >= 3);
return ValidateES3TexImage2DParameters(context, target, level, internalformat, false, false, 0,
0, 0, width, height, 1, border, format, type, pixels);
}
bool ValidateTexSubImage2D(Context *context,
GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLsizei width,
GLsizei height,
GLenum format,
GLenum type,
const GLvoid *pixels)
{
if (context->getClientVersion() < 3)
{
return ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true, xoffset,
yoffset, width, height, 0, format, type, pixels);
}
ASSERT(context->getClientVersion() >= 3);
return ValidateES3TexImage2DParameters(context, target, level, GL_NONE, false, true, xoffset,
yoffset, 0, width, height, 1, 0, format, type, pixels);
}
bool ValidateCompressedTexImage2D(Context *context,
GLenum target,
GLint level,
GLenum internalformat,
GLsizei width,
GLsizei height,
GLint border,
GLsizei imageSize,
const GLvoid *data)
{
if (context->getClientVersion() < 3)
{
if (!ValidateES2TexImageParameters(context, target, level, internalformat, true, false, 0,
0, width, height, border, GL_NONE, GL_NONE, data))
{
return false;
}
}
else
{
ASSERT(context->getClientVersion() >= 3);
if (!ValidateES3TexImage2DParameters(context, target, level, internalformat, true, false, 0,
0, 0, width, height, 1, border, GL_NONE, GL_NONE,
data))
{
return false;
}
}
const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat);
if (imageSize < 0 ||
static_cast<GLuint>(imageSize) !=
formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
{
context->recordError(Error(GL_INVALID_VALUE));
return false;
}
return true;
}
bool ValidateCompressedTexSubImage2D(Context *context,
GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLsizei width,
GLsizei height,
GLenum format,
GLsizei imageSize,
const GLvoid *data)
{
if (context->getClientVersion() < 3)
{
if (!ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true, xoffset,
yoffset, width, height, 0, GL_NONE, GL_NONE, data))
{
return false;
}
}
else
{
ASSERT(context->getClientVersion() >= 3);
if (!ValidateES3TexImage2DParameters(context, target, level, GL_NONE, true, true, xoffset,
yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE,
data))
{
return false;
}
}
const InternalFormat &formatInfo = GetInternalFormatInfo(format);
if (imageSize < 0 ||
static_cast<GLuint>(imageSize) !=
formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
{
context->recordError(Error(GL_INVALID_VALUE));
return false;
}
return true;
}
} // namespace gl } // namespace gl
...@@ -128,6 +128,45 @@ bool ValidateBlitFramebufferANGLE(Context *context, ...@@ -128,6 +128,45 @@ bool ValidateBlitFramebufferANGLE(Context *context,
GLenum filter); GLenum filter);
bool ValidateClear(ValidationContext *context, GLbitfield mask); bool ValidateClear(ValidationContext *context, GLbitfield mask);
bool ValidateTexImage2D(Context *context,
GLenum target,
GLint level,
GLint internalformat,
GLsizei width,
GLsizei height,
GLint border,
GLenum format,
GLenum type,
const GLvoid *pixels);
bool ValidateTexSubImage2D(Context *context,
GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLsizei width,
GLsizei height,
GLenum format,
GLenum type,
const GLvoid *pixels);
bool ValidateCompressedTexImage2D(Context *context,
GLenum target,
GLint level,
GLenum internalformat,
GLsizei width,
GLsizei height,
GLint border,
GLsizei imageSize,
const GLvoid *data);
bool ValidateCompressedTexSubImage2D(Context *context,
GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLsizei width,
GLsizei height,
GLenum format,
GLsizei imageSize,
const GLvoid *data);
} // namespace gl } // namespace gl
......
...@@ -1781,4 +1781,89 @@ bool ValidateCopyTexSubImage3D(Context *context, ...@@ -1781,4 +1781,89 @@ bool ValidateCopyTexSubImage3D(Context *context,
yoffset, zoffset, x, y, width, height, 0); yoffset, zoffset, x, y, width, height, 0);
} }
bool ValidateTexImage3D(Context *context,
GLenum target,
GLint level,
GLint internalformat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLint border,
GLenum format,
GLenum type,
const GLvoid *pixels)
{
if (context->getClientVersion() < 3)
{
context->recordError(Error(GL_INVALID_OPERATION));
return false;
}
return ValidateES3TexImage3DParameters(context, target, level, internalformat, false, false, 0,
0, 0, width, height, depth, border, format, type,
pixels);
}
bool ValidateTexSubImage3D(Context *context,
GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLint zoffset,
GLsizei width,
GLsizei height,
GLsizei depth,
GLenum format,
GLenum type,
const GLvoid *pixels)
{
if (context->getClientVersion() < 3)
{
context->recordError(Error(GL_INVALID_OPERATION));
return false;
}
return ValidateES3TexImage3DParameters(context, target, level, GL_NONE, false, true, xoffset,
yoffset, zoffset, width, height, depth, 0, format, type,
pixels);
}
bool ValidateCompressedTexSubImage3D(Context *context,
GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLint zoffset,
GLsizei width,
GLsizei height,
GLsizei depth,
GLenum format,
GLsizei imageSize,
const GLvoid *data)
{
if (context->getClientVersion() < 3)
{
context->recordError(Error(GL_INVALID_OPERATION));
return false;
}
const InternalFormat &formatInfo = GetInternalFormatInfo(format);
if (imageSize < 0 ||
static_cast<GLuint>(imageSize) !=
formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
{
context->recordError(Error(GL_INVALID_VALUE));
return false;
}
if (!data)
{
context->recordError(Error(GL_INVALID_VALUE));
return false;
}
return ValidateES3TexImage3DParameters(context, target, level, GL_NONE, true, true, 0, 0, 0,
width, height, depth, 0, GL_NONE, GL_NONE, data);
}
} // namespace gl } // namespace gl
...@@ -237,6 +237,41 @@ bool ValidateCopyTexSubImage3D(Context *context, ...@@ -237,6 +237,41 @@ bool ValidateCopyTexSubImage3D(Context *context,
GLint y, GLint y,
GLsizei width, GLsizei width,
GLsizei height); GLsizei height);
bool ValidateTexImage3D(Context *context,
GLenum target,
GLint level,
GLint internalformat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLint border,
GLenum format,
GLenum type,
const GLvoid *pixels);
bool ValidateTexSubImage3D(Context *context,
GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLint zoffset,
GLsizei width,
GLsizei height,
GLsizei depth,
GLenum format,
GLenum type,
const GLvoid *pixels);
bool ValidateCompressedTexSubImage3D(Context *context,
GLenum target,
GLint level,
GLint xoffset,
GLint yoffset,
GLint zoffset,
GLsizei width,
GLsizei height,
GLsizei depth,
GLenum format,
GLsizei imageSize,
const GLvoid *data);
} // namespace gl } // namespace gl
......
...@@ -674,38 +674,15 @@ void GL_APIENTRY CompressedTexImage2D(GLenum target, GLint level, GLenum interna ...@@ -674,38 +674,15 @@ void GL_APIENTRY CompressedTexImage2D(GLenum target, GLint level, GLenum interna
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (context->getClientVersion() < 3 && if (!context->skipValidation() &&
!ValidateES2TexImageParameters(context, target, level, internalformat, true, false, !ValidateCompressedTexImage2D(context, target, level, internalformat, width, height,
0, 0, width, height, border, GL_NONE, GL_NONE, data)) border, imageSize, data))
{
return;
}
if (context->getClientVersion() >= 3 &&
!ValidateES3TexImage2DParameters(context, target, level, internalformat, true, false, 0,
0, 0, width, height, 1, border, GL_NONE, GL_NONE,
data))
{
return;
}
const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat);
if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
{ {
context->recordError(Error(GL_INVALID_VALUE));
return; return;
} }
Extents size(width, height, 1); context->compressedTexImage2D(target, level, internalformat, width, height, border,
Texture *texture = context->getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); imageSize, data);
Error error =
texture->setCompressedImage(context, target, level, internalformat, size, imageSize,
reinterpret_cast<const uint8_t *>(data));
if (error.isError())
{
context->recordError(error);
return;
}
} }
} }
...@@ -720,38 +697,15 @@ void GL_APIENTRY CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs ...@@ -720,38 +697,15 @@ void GL_APIENTRY CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (context->getClientVersion() < 3 && if (!context->skipValidation() &&
!ValidateES2TexImageParameters(context, target, level, GL_NONE, true, true, !ValidateCompressedTexSubImage2D(context, target, level, xoffset, yoffset, width,
xoffset, yoffset, width, height, 0, GL_NONE, GL_NONE, data)) height, format, imageSize, data))
{
return;
}
if (context->getClientVersion() >= 3 &&
!ValidateES3TexImage2DParameters(context, target, level, GL_NONE, true, true, xoffset,
yoffset, 0, width, height, 1, 0, GL_NONE, GL_NONE,
data))
{
return;
}
const InternalFormat &formatInfo = GetInternalFormatInfo(format);
if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
{ {
context->recordError(Error(GL_INVALID_VALUE));
return; return;
} }
Box area(xoffset, yoffset, 0, width, height, 1); context->compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format,
Texture *texture = context->getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); imageSize, data);
Error error =
texture->setCompressedSubImage(context, target, level, area, format, imageSize,
reinterpret_cast<const uint8_t *>(data));
if (error.isError())
{
context->recordError(error);
return;
}
} }
} }
...@@ -3440,30 +3394,15 @@ void GL_APIENTRY TexImage2D(GLenum target, GLint level, GLint internalformat, GL ...@@ -3440,30 +3394,15 @@ void GL_APIENTRY TexImage2D(GLenum target, GLint level, GLint internalformat, GL
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (context->getClientVersion() < 3 && if (!context->skipValidation() &&
!ValidateES2TexImageParameters(context, target, level, internalformat, false, false, !ValidateTexImage2D(context, target, level, internalformat, width, height, border,
0, 0, width, height, border, format, type, pixels)) format, type, pixels))
{
return;
}
if (context->getClientVersion() >= 3 &&
!ValidateES3TexImage2DParameters(context, target, level, internalformat, false, false,
0, 0, 0, width, height, 1, border, format, type,
pixels))
{ {
return; return;
} }
Extents size(width, height, 1); context->texImage2D(target, level, internalformat, width, height, border, format, type,
Texture *texture = context->getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); pixels);
Error error = texture->setImage(context, target, level, internalformat, size, format, type,
reinterpret_cast<const uint8_t *>(pixels));
if (error.isError())
{
context->recordError(error);
return;
}
} }
} }
...@@ -3592,35 +3531,15 @@ void GL_APIENTRY TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint ...@@ -3592,35 +3531,15 @@ void GL_APIENTRY TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (context->getClientVersion() < 3 && if (!context->skipValidation() &&
!ValidateES2TexImageParameters(context, target, level, GL_NONE, false, true, !ValidateTexSubImage2D(context, target, level, xoffset, yoffset, width, height, format,
xoffset, yoffset, width, height, 0, format, type, pixels)) type, pixels))
{
return;
}
if (context->getClientVersion() >= 3 &&
!ValidateES3TexImage2DParameters(context, target, level, GL_NONE, false, true, xoffset,
yoffset, 0, width, height, 1, 0, format, type, pixels))
{
return;
}
// Zero sized uploads are valid but no-ops
if (width == 0 || height == 0)
{ {
return; return;
} }
Box area(xoffset, yoffset, 0, width, height, 1); context->texSubImage2D(target, level, xoffset, yoffset, width, height, format, type,
Texture *texture = context->getTargetTexture(IsCubeMapTextureTarget(target) ? GL_TEXTURE_CUBE_MAP : target); pixels);
Error error = texture->setSubImage(context, target, level, area, format, type,
reinterpret_cast<const uint8_t *>(pixels));
if (error.isError())
{
context->recordError(error);
return;
}
} }
} }
......
...@@ -94,29 +94,15 @@ void GL_APIENTRY TexImage3D(GLenum target, GLint level, GLint internalformat, GL ...@@ -94,29 +94,15 @@ void GL_APIENTRY TexImage3D(GLenum target, GLint level, GLint internalformat, GL
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (context->getClientVersion() < 3) if (!context->skipValidation() &&
{ !ValidateTexImage3D(context, target, level, internalformat, width, height, depth,
context->recordError(Error(GL_INVALID_OPERATION)); border, format, type, pixels))
return;
}
// validateES3TexImageFormat sets the error code if there is an error
if (!ValidateES3TexImage3DParameters(context, target, level, internalformat, false, false,
0, 0, 0, width, height, depth, border, format, type,
pixels))
{ {
return; return;
} }
Extents size(width, height, depth); context->texImage3D(target, level, internalformat, width, height, depth, border, format,
Texture *texture = context->getTargetTexture(target); type, pixels);
Error error = texture->setImage(context, target, level, internalformat, size, format, type,
reinterpret_cast<const uint8_t *>(pixels));
if (error.isError())
{
context->recordError(error);
return;
}
} }
} }
...@@ -130,35 +116,15 @@ void GL_APIENTRY TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint ...@@ -130,35 +116,15 @@ void GL_APIENTRY TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (context->getClientVersion() < 3) if (!context->skipValidation() &&
{ !ValidateTexSubImage3D(context, target, level, xoffset, yoffset, zoffset, width, height,
context->recordError(Error(GL_INVALID_OPERATION)); depth, format, type, pixels))
return;
}
// validateES3TexImageFormat sets the error code if there is an error
if (!ValidateES3TexImage3DParameters(context, target, level, GL_NONE, false, true, xoffset,
yoffset, zoffset, width, height, depth, 0, format,
type, pixels))
{
return;
}
// Zero sized uploads are valid but no-ops
if (width == 0 || height == 0 || depth == 0)
{ {
return; return;
} }
Box area(xoffset, yoffset, zoffset, width, height, depth); context->texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth,
Texture *texture = context->getTargetTexture(target); format, type, pixels);
Error error = texture->setSubImage(context, target, level, area, format, type,
reinterpret_cast<const uint8_t *>(pixels));
if (error.isError())
{
context->recordError(error);
return;
}
} }
} }
...@@ -192,22 +158,15 @@ void GL_APIENTRY CompressedTexImage3D(GLenum target, GLint level, GLenum interna ...@@ -192,22 +158,15 @@ void GL_APIENTRY CompressedTexImage3D(GLenum target, GLint level, GLenum interna
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (!ValidateCompressedTexImage3D(context, target, level, internalformat, width, height, if (!context->skipValidation() &&
!ValidateCompressedTexImage3D(context, target, level, internalformat, width, height,
depth, border, imageSize, data)) depth, border, imageSize, data))
{ {
return; return;
} }
Extents size(width, height, depth); context->compressedTexImage3D(target, level, internalformat, width, height, depth, border,
Texture *texture = context->getTargetTexture(target); imageSize, data);
Error error =
texture->setCompressedImage(context, target, level, internalformat, size, imageSize,
reinterpret_cast<const uint8_t *>(data));
if (error.isError())
{
context->recordError(error);
return;
}
} }
} }
...@@ -221,48 +180,15 @@ void GL_APIENTRY CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffs ...@@ -221,48 +180,15 @@ void GL_APIENTRY CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffs
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (context->getClientVersion() < 3) if (!context->skipValidation() &&
{ !ValidateCompressedTexSubImage3D(context, target, level, xoffset, yoffset, zoffset,
context->recordError(Error(GL_INVALID_OPERATION)); width, height, depth, format, imageSize, data))
return;
}
const InternalFormat &formatInfo = GetInternalFormatInfo(format);
if (imageSize < 0 || static_cast<GLuint>(imageSize) != formatInfo.computeBlockSize(GL_UNSIGNED_BYTE, width, height))
{
context->recordError(Error(GL_INVALID_VALUE));
return;
}
if (!data)
{
context->recordError(Error(GL_INVALID_VALUE));
return;
}
// validateES3TexImageFormat sets the error code if there is an error
if (!ValidateES3TexImage3DParameters(context, target, level, GL_NONE, true, true, 0, 0, 0,
width, height, depth, 0, GL_NONE, GL_NONE, data))
{
return;
}
// Zero sized uploads are valid but no-ops
if (width == 0 || height == 0)
{ {
return; return;
} }
Box area(xoffset, yoffset, zoffset, width, height, depth); context->compressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height,
Texture *texture = context->getTargetTexture(target); depth, format, imageSize, data);
Error error =
texture->setCompressedSubImage(context, target, level, area, format, imageSize,
reinterpret_cast<const uint8_t *>(data));
if (error.isError())
{
context->recordError(error);
return;
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment