Commit 1ba6b8db by Geoff Lang

Refactor Texture::setImage and subImage to use gl::Error objects.

BUG=angle:520 Change-Id: Ib43ace0fbdab59086ae4314cce139636d9045e65 Reviewed-on: https://chromium-review.googlesource.com/216644Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent b60fe31f
...@@ -226,11 +226,11 @@ GLenum Texture2D::getActualFormat(GLint level) const ...@@ -226,11 +226,11 @@ GLenum Texture2D::getActualFormat(GLint level) const
return GL_NONE; return GL_NONE;
} }
void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) Error Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{ {
releaseTexImage(); releaseTexImage();
mTexture->setImage(GL_TEXTURE_2D, level, width, height, 1, internalFormat, format, type, unpack, pixels); return mTexture->setImage(GL_TEXTURE_2D, level, width, height, 1, internalFormat, format, type, unpack, pixels);
} }
void Texture2D::bindTexImage(egl::Surface *surface) void Texture2D::bindTexImage(egl::Surface *surface)
...@@ -261,9 +261,9 @@ void Texture2D::setCompressedImage(GLint level, GLenum format, GLsizei width, GL ...@@ -261,9 +261,9 @@ void Texture2D::setCompressedImage(GLint level, GLenum format, GLsizei width, GL
mTexture->setCompressedImage(GL_TEXTURE_2D, level, format, width, height, 1, imageSize, pixels); mTexture->setCompressedImage(GL_TEXTURE_2D, level, format, width, height, 1, imageSize, pixels);
} }
void Texture2D::subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) Error Texture2D::subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{ {
mTexture->subImage(GL_TEXTURE_2D, level, xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels); return mTexture->subImage(GL_TEXTURE_2D, level, xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels);
} }
void Texture2D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels) void Texture2D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels)
...@@ -467,34 +467,34 @@ GLenum TextureCubeMap::getActualFormat(GLenum target, GLint level) const ...@@ -467,34 +467,34 @@ GLenum TextureCubeMap::getActualFormat(GLenum target, GLint level) const
return GL_NONE; return GL_NONE;
} }
void TextureCubeMap::setImagePosX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) Error TextureCubeMap::setImagePosX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{ {
mTexture->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, width, height, 1, internalFormat, format, type, unpack, pixels); return mTexture->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, width, height, 1, internalFormat, format, type, unpack, pixels);
} }
void TextureCubeMap::setImageNegX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) Error TextureCubeMap::setImageNegX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{ {
mTexture->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, level, width, height, 1, internalFormat, format, type, unpack, pixels); return mTexture->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, level, width, height, 1, internalFormat, format, type, unpack, pixels);
} }
void TextureCubeMap::setImagePosY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) Error TextureCubeMap::setImagePosY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{ {
mTexture->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, level, width, height, 1, internalFormat, format, type, unpack, pixels); return mTexture->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, level, width, height, 1, internalFormat, format, type, unpack, pixels);
} }
void TextureCubeMap::setImageNegY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) Error TextureCubeMap::setImageNegY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{ {
mTexture->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, level, width, height, 1, internalFormat, format, type, unpack, pixels); return mTexture->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, level, width, height, 1, internalFormat, format, type, unpack, pixels);
} }
void TextureCubeMap::setImagePosZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) Error TextureCubeMap::setImagePosZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{ {
mTexture->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, level, width, height, 1, internalFormat, format, type, unpack, pixels); return mTexture->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, level, width, height, 1, internalFormat, format, type, unpack, pixels);
} }
void TextureCubeMap::setImageNegZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) Error TextureCubeMap::setImageNegZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{ {
mTexture->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, level, width, height, 1, internalFormat, format, type, unpack, pixels); return mTexture->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, level, width, height, 1, internalFormat, format, type, unpack, pixels);
} }
void TextureCubeMap::setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels) void TextureCubeMap::setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels)
...@@ -502,9 +502,9 @@ void TextureCubeMap::setCompressedImage(GLenum target, GLint level, GLenum forma ...@@ -502,9 +502,9 @@ void TextureCubeMap::setCompressedImage(GLenum target, GLint level, GLenum forma
mTexture->setCompressedImage(target, level, format, width, height, 1, imageSize, pixels); mTexture->setCompressedImage(target, level, format, width, height, 1, imageSize, pixels);
} }
void TextureCubeMap::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) Error TextureCubeMap::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{ {
mTexture->subImage(target, level, xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels); return mTexture->subImage(target, level, xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels);
} }
void TextureCubeMap::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels) void TextureCubeMap::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels)
...@@ -734,9 +734,9 @@ bool Texture3D::isDepth(GLint level) const ...@@ -734,9 +734,9 @@ bool Texture3D::isDepth(GLint level) const
return GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0; return GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0;
} }
void Texture3D::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) Error Texture3D::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{ {
mTexture->setImage(GL_TEXTURE_3D, level, width, height, depth, internalFormat, format, type, unpack, pixels); return mTexture->setImage(GL_TEXTURE_3D, level, width, height, depth, internalFormat, format, type, unpack, pixels);
} }
void Texture3D::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels) void Texture3D::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels)
...@@ -744,9 +744,9 @@ void Texture3D::setCompressedImage(GLint level, GLenum format, GLsizei width, GL ...@@ -744,9 +744,9 @@ void Texture3D::setCompressedImage(GLint level, GLenum format, GLsizei width, GL
mTexture->setCompressedImage(GL_TEXTURE_3D, level, format, width, height, depth, imageSize, pixels); mTexture->setCompressedImage(GL_TEXTURE_3D, level, format, width, height, depth, imageSize, pixels);
} }
void Texture3D::subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) Error Texture3D::subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{ {
mTexture->subImage(GL_TEXTURE_3D, level, xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels); return mTexture->subImage(GL_TEXTURE_3D, level, xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels);
} }
void Texture3D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels) void Texture3D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels)
...@@ -892,9 +892,9 @@ bool Texture2DArray::isDepth(GLint level) const ...@@ -892,9 +892,9 @@ bool Texture2DArray::isDepth(GLint level) const
return GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0; return GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0;
} }
void Texture2DArray::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) Error Texture2DArray::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{ {
mTexture->setImage(GL_TEXTURE_2D_ARRAY, level, width, height, depth, internalFormat, format, type, unpack, pixels); return mTexture->setImage(GL_TEXTURE_2D_ARRAY, level, width, height, depth, internalFormat, format, type, unpack, pixels);
} }
void Texture2DArray::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels) void Texture2DArray::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels)
...@@ -902,9 +902,9 @@ void Texture2DArray::setCompressedImage(GLint level, GLenum format, GLsizei widt ...@@ -902,9 +902,9 @@ void Texture2DArray::setCompressedImage(GLint level, GLenum format, GLsizei widt
mTexture->setCompressedImage(GL_TEXTURE_2D_ARRAY, level, format, width, height, depth, imageSize, pixels); mTexture->setCompressedImage(GL_TEXTURE_2D_ARRAY, level, format, width, height, depth, imageSize, pixels);
} }
void Texture2DArray::subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels) Error Texture2DArray::subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
{ {
mTexture->subImage(GL_TEXTURE_2D_ARRAY, level, xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels); return mTexture->subImage(GL_TEXTURE_2D_ARRAY, level, xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels);
} }
void Texture2DArray::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels) void Texture2DArray::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels)
......
...@@ -116,9 +116,9 @@ class Texture2D : public Texture ...@@ -116,9 +116,9 @@ class Texture2D : public Texture
bool isCompressed(GLint level) const; bool isCompressed(GLint level) const;
bool isDepth(GLint level) const; bool isDepth(GLint level) const;
void setImage(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels); Error setImage(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels); void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
void subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels); Error subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels); void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
void copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source); void copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
...@@ -152,16 +152,16 @@ class TextureCubeMap : public Texture ...@@ -152,16 +152,16 @@ class TextureCubeMap : public Texture
bool isCompressed(GLenum target, GLint level) const; bool isCompressed(GLenum target, GLint level) const;
bool isDepth(GLenum target, GLint level) const; bool isDepth(GLenum target, GLint level) const;
void setImagePosX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels); Error setImagePosX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void setImageNegX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels); Error setImageNegX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void setImagePosY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels); Error setImagePosY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void setImageNegY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels); Error setImageNegY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void setImagePosZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels); Error setImagePosZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void setImageNegZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels); Error setImageNegZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels); void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels); Error subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels); void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source); void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
void storage(GLsizei levels, GLenum internalformat, GLsizei size); void storage(GLsizei levels, GLenum internalformat, GLsizei size);
...@@ -195,9 +195,9 @@ class Texture3D : public Texture ...@@ -195,9 +195,9 @@ class Texture3D : public Texture
bool isCompressed(GLint level) const; bool isCompressed(GLint level) const;
bool isDepth(GLint level) const; bool isDepth(GLint level) const;
void setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels); Error setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels); void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
void subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels); Error subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels); void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
...@@ -225,9 +225,9 @@ class Texture2DArray : public Texture ...@@ -225,9 +225,9 @@ class Texture2DArray : public Texture
bool isCompressed(GLint level) const; bool isCompressed(GLint level) const;
bool isDepth(GLint level) const; bool isDepth(GLint level) const;
void setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels); Error setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels); void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
void subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels); Error subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels); void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); void storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
......
...@@ -4145,43 +4145,78 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL ...@@ -4145,43 +4145,78 @@ void __stdcall glTexImage2D(GLenum target, GLint level, GLint internalformat, GL
case GL_TEXTURE_2D: case GL_TEXTURE_2D:
{ {
gl::Texture2D *texture = context->getTexture2D(); gl::Texture2D *texture = context->getTexture2D();
texture->setImage(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels); gl::Error error = texture->setImage(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
} }
break; break;
case GL_TEXTURE_CUBE_MAP_POSITIVE_X: case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
{ {
gl::TextureCubeMap *texture = context->getTextureCubeMap(); gl::TextureCubeMap *texture = context->getTextureCubeMap();
texture->setImagePosX(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels); gl::Error error = texture->setImagePosX(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
} }
break; break;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
{ {
gl::TextureCubeMap *texture = context->getTextureCubeMap(); gl::TextureCubeMap *texture = context->getTextureCubeMap();
texture->setImageNegX(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels); gl::Error error = texture->setImageNegX(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
} }
break; break;
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
{ {
gl::TextureCubeMap *texture = context->getTextureCubeMap(); gl::TextureCubeMap *texture = context->getTextureCubeMap();
texture->setImagePosY(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels); gl::Error error = texture->setImagePosY(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
} }
break; break;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
{ {
gl::TextureCubeMap *texture = context->getTextureCubeMap(); gl::TextureCubeMap *texture = context->getTextureCubeMap();
texture->setImageNegY(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels); gl::Error error = texture->setImageNegY(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
} }
break; break;
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
{ {
gl::TextureCubeMap *texture = context->getTextureCubeMap(); gl::TextureCubeMap *texture = context->getTextureCubeMap();
texture->setImagePosZ(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels); gl::Error error = texture->setImagePosZ(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
} }
break; break;
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
{ {
gl::TextureCubeMap *texture = context->getTextureCubeMap(); gl::TextureCubeMap *texture = context->getTextureCubeMap();
texture->setImageNegZ(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels); gl::Error error = texture->setImageNegZ(level, width, height, internalformat, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
} }
break; break;
default: UNREACHABLE(); default: UNREACHABLE();
...@@ -4372,7 +4407,12 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint ...@@ -4372,7 +4407,12 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint
case GL_TEXTURE_2D: case GL_TEXTURE_2D:
{ {
gl::Texture2D *texture = context->getTexture2D(); gl::Texture2D *texture = context->getTexture2D();
texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels); gl::Error error = texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
} }
break; break;
...@@ -4384,7 +4424,12 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint ...@@ -4384,7 +4424,12 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
{ {
gl::TextureCubeMap *texture = context->getTextureCubeMap(); gl::TextureCubeMap *texture = context->getTextureCubeMap();
texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels); gl::Error error = texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
} }
break; break;
...@@ -5015,14 +5060,24 @@ void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GL ...@@ -5015,14 +5060,24 @@ void __stdcall glTexImage3D(GLenum target, GLint level, GLint internalformat, GL
case GL_TEXTURE_3D: case GL_TEXTURE_3D:
{ {
gl::Texture3D *texture = context->getTexture3D(); gl::Texture3D *texture = context->getTexture3D();
texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels); gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
} }
break; break;
case GL_TEXTURE_2D_ARRAY: case GL_TEXTURE_2D_ARRAY:
{ {
gl::Texture2DArray *texture = context->getTexture2DArray(); gl::Texture2DArray *texture = context->getTexture2DArray();
texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels); gl::Error error = texture->setImage(level, width, height, depth, internalformat, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
} }
break; break;
...@@ -5068,14 +5123,24 @@ void __stdcall glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint ...@@ -5068,14 +5123,24 @@ void __stdcall glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint
case GL_TEXTURE_3D: case GL_TEXTURE_3D:
{ {
gl::Texture3D *texture = context->getTexture3D(); gl::Texture3D *texture = context->getTexture3D();
texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels); gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
} }
break; break;
case GL_TEXTURE_2D_ARRAY: case GL_TEXTURE_2D_ARRAY:
{ {
gl::Texture2DArray *texture = context->getTexture2DArray(); gl::Texture2DArray *texture = context->getTexture2DArray();
texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels); gl::Error error = texture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, context->getState().getUnpackState(), pixels);
if (error.isError())
{
context->recordError(error);
return;
}
} }
break; break;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
// Image.h: Defines the rx::Image class, an abstract base class for the // Image.h: Defines the rx::Image class, an abstract base class for the
// renderer-specific classes which will define the interface to the underlying // renderer-specific classes which will define the interface to the underlying
// surfaces or resources. // surfaces or resources.
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#define LIBGLESV2_RENDERER_IMAGE_H_ #define LIBGLESV2_RENDERER_IMAGE_H_
#include "common/debug.h" #include "common/debug.h"
#include "libGLESv2/Error.h"
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
...@@ -45,8 +46,8 @@ class Image ...@@ -45,8 +46,8 @@ class Image
virtual bool redefine(Renderer *renderer, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease) = 0; virtual bool redefine(Renderer *renderer, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease) = 0;
virtual void loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, virtual gl::Error loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, GLenum type, const void *input) = 0; GLint unpackAlignment, GLenum type, const void *input) = 0;
virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
const void *input) = 0; const void *input) = 0;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#define LIBGLESV2_RENDERER_TEXTUREIMPL_H_ #define LIBGLESV2_RENDERER_TEXTUREIMPL_H_
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libGLESv2/Error.h"
#include "angle_gl.h" #include "angle_gl.h"
...@@ -51,9 +52,9 @@ class TextureImpl ...@@ -51,9 +52,9 @@ class TextureImpl
virtual void setUsage(GLenum usage) = 0; virtual void setUsage(GLenum usage) = 0;
virtual void setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels) = 0; virtual gl::Error setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels) = 0;
virtual void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels) = 0; virtual void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels) = 0;
virtual void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels) = 0; virtual gl::Error subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels) = 0;
virtual void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels) = 0; virtual void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels) = 0;
virtual void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source) = 0; virtual void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source) = 0;
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source) = 0; virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source) = 0;
......
...@@ -37,10 +37,10 @@ class ImageD3D : public Image ...@@ -37,10 +37,10 @@ class ImageD3D : public Image
virtual void setManagedSurfaceCube(TextureStorage *storage, int face, int level) {}; virtual void setManagedSurfaceCube(TextureStorage *storage, int face, int level) {};
virtual void setManagedSurface3D(TextureStorage *storage, int level) {}; virtual void setManagedSurface3D(TextureStorage *storage, int level) {};
virtual void setManagedSurface2DArray(TextureStorage *storage, int layer, int level) {}; virtual void setManagedSurface2DArray(TextureStorage *storage, int layer, int level) {};
virtual bool copyToStorage2D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0; virtual gl::Error copyToStorage2D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0;
virtual bool copyToStorageCube(TextureStorage *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0; virtual gl::Error copyToStorageCube(TextureStorage *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0;
virtual bool copyToStorage3D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth) = 0; virtual gl::Error copyToStorage3D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth) = 0;
virtual bool copyToStorage2DArray(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height) = 0; virtual gl::Error copyToStorage2DArray(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height) = 0;
private: private:
DISALLOW_COPY_AND_ASSIGN(ImageD3D); DISALLOW_COPY_AND_ASSIGN(ImageD3D);
......
...@@ -90,12 +90,12 @@ GLenum TextureD3D::getBaseLevelInternalFormat() const ...@@ -90,12 +90,12 @@ GLenum TextureD3D::getBaseLevelInternalFormat() const
return (baseImage ? baseImage->getInternalFormat() : GL_NONE); return (baseImage ? baseImage->getInternalFormat() : GL_NONE);
} }
void TextureD3D::setImage(const gl::PixelUnpackState &unpack, GLenum type, const void *pixels, Image *image) gl::Error TextureD3D::setImage(const gl::PixelUnpackState &unpack, GLenum type, const void *pixels, Image *image)
{ {
// No-op // No-op
if (image->getWidth() == 0 || image->getHeight() == 0 || image->getDepth() == 0) if (image->getWidth() == 0 || image->getHeight() == 0 || image->getDepth() == 0)
{ {
return; return gl::Error(GL_NO_ERROR);
} }
// We no longer need the "GLenum format" parameter to TexImage to determine what data format "pixels" contains. // We no longer need the "GLenum format" parameter to TexImage to determine what data format "pixels" contains.
...@@ -115,13 +115,20 @@ void TextureD3D::setImage(const gl::PixelUnpackState &unpack, GLenum type, const ...@@ -115,13 +115,20 @@ void TextureD3D::setImage(const gl::PixelUnpackState &unpack, GLenum type, const
if (pixelData != NULL) if (pixelData != NULL)
{ {
image->loadData(0, 0, 0, image->getWidth(), image->getHeight(), image->getDepth(), unpack.alignment, type, pixelData); gl::Error error = image->loadData(0, 0, 0, image->getWidth(), image->getHeight(), image->getDepth(), unpack.alignment, type, pixelData);
if (error.isError())
{
return error;
}
mDirtyImages = true; mDirtyImages = true;
} }
return gl::Error(GL_NO_ERROR);
} }
bool TextureD3D::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, gl::Error TextureD3D::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels, const gl::ImageIndex &index) GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels, const gl::ImageIndex &index)
{ {
const void *pixelData = pixels; const void *pixelData = pixels;
...@@ -141,11 +148,17 @@ bool TextureD3D::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei w ...@@ -141,11 +148,17 @@ bool TextureD3D::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei w
Image *image = getImage(index); Image *image = getImage(index);
ASSERT(image); ASSERT(image);
image->loadData(xoffset, yoffset, zoffset, width, height, depth, unpack.alignment, type, pixelData); gl::Error error = image->loadData(xoffset, yoffset, zoffset, width, height, depth, unpack.alignment,
type, pixelData);
if (error.isError())
{
return error;
}
mDirtyImages = true; mDirtyImages = true;
} }
return true; return gl::Error(GL_NO_ERROR);
} }
void TextureD3D::setCompressedImage(GLsizei imageSize, const void *pixels, Image *image) void TextureD3D::setCompressedImage(GLsizei imageSize, const void *pixels, Image *image)
...@@ -174,12 +187,13 @@ bool TextureD3D::isFastUnpackable(const gl::PixelUnpackState &unpack, GLenum siz ...@@ -174,12 +187,13 @@ bool TextureD3D::isFastUnpackable(const gl::PixelUnpackState &unpack, GLenum siz
return unpack.pixelBuffer.id() != 0 && mRenderer->supportsFastCopyBufferToTexture(sizedInternalFormat); return unpack.pixelBuffer.id() != 0 && mRenderer->supportsFastCopyBufferToTexture(sizedInternalFormat);
} }
bool TextureD3D::fastUnpackPixels(const gl::PixelUnpackState &unpack, const void *pixels, const gl::Box &destArea, gl::Error TextureD3D::fastUnpackPixels(const gl::PixelUnpackState &unpack, const void *pixels, const gl::Box &destArea,
GLenum sizedInternalFormat, GLenum type, RenderTarget *destRenderTarget) GLenum sizedInternalFormat, GLenum type, RenderTarget *destRenderTarget)
{ {
// No-op
if (destArea.width <= 0 && destArea.height <= 0 && destArea.depth <= 0) if (destArea.width <= 0 && destArea.height <= 0 && destArea.depth <= 0)
{ {
return true; return gl::Error(GL_NO_ERROR);
} }
// In order to perform the fast copy through the shader, we must have the right format, and be able // In order to perform the fast copy through the shader, we must have the right format, and be able
...@@ -191,10 +205,10 @@ bool TextureD3D::fastUnpackPixels(const gl::PixelUnpackState &unpack, const void ...@@ -191,10 +205,10 @@ bool TextureD3D::fastUnpackPixels(const gl::PixelUnpackState &unpack, const void
gl::Error error = mRenderer->fastCopyBufferToTexture(unpack, offset, destRenderTarget, sizedInternalFormat, type, destArea); gl::Error error = mRenderer->fastCopyBufferToTexture(unpack, offset, destRenderTarget, sizedInternalFormat, type, destArea);
if (error.isError()) if (error.isError())
{ {
return false; return error;
} }
return true; return gl::Error(GL_NO_ERROR);
} }
GLint TextureD3D::creationLevels(GLsizei width, GLsizei height, GLsizei depth) const GLint TextureD3D::creationLevels(GLsizei width, GLsizei height, GLsizei depth) const
...@@ -334,7 +348,9 @@ bool TextureD3D_2D::isDepth(GLint level) const ...@@ -334,7 +348,9 @@ bool TextureD3D_2D::isDepth(GLint level) const
return gl::GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0; return gl::GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0;
} }
void TextureD3D_2D::setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels) gl::Error TextureD3D_2D::setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth,
GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack,
const void *pixels)
{ {
ASSERT(target == GL_TEXTURE_2D && depth == 1); ASSERT(target == GL_TEXTURE_2D && depth == 1);
...@@ -353,8 +369,14 @@ void TextureD3D_2D::setImage(GLenum target, GLint level, GLsizei width, GLsizei ...@@ -353,8 +369,14 @@ void TextureD3D_2D::setImage(GLenum target, GLint level, GLsizei width, GLsizei
RenderTarget *destRenderTarget = getRenderTarget(index); RenderTarget *destRenderTarget = getRenderTarget(index);
gl::Box destArea(0, 0, 0, getWidth(level), getHeight(level), 1); gl::Box destArea(0, 0, 0, getWidth(level), getHeight(level), 1);
if (destRenderTarget && fastUnpackPixels(unpack, pixels, destArea, sizedInternalFormat, type, destRenderTarget)) if (destRenderTarget)
{ {
gl::Error error = fastUnpackPixels(unpack, pixels, destArea, sizedInternalFormat, type, destRenderTarget);
if (error.isError())
{
return error;
}
// Ensure we don't overwrite our newly initialized data // Ensure we don't overwrite our newly initialized data
mImageArray[level]->markClean(); mImageArray[level]->markClean();
...@@ -364,8 +386,14 @@ void TextureD3D_2D::setImage(GLenum target, GLint level, GLsizei width, GLsizei ...@@ -364,8 +386,14 @@ void TextureD3D_2D::setImage(GLenum target, GLint level, GLsizei width, GLsizei
if (!fastUnpacked) if (!fastUnpacked)
{ {
TextureD3D::setImage(unpack, type, pixels, mImageArray[level]); gl::Error error = TextureD3D::setImage(unpack, type, pixels, mImageArray[level]);
if (error.isError())
{
return error;
}
} }
return gl::Error(GL_NO_ERROR);
} }
void TextureD3D_2D::setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels) void TextureD3D_2D::setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels)
...@@ -378,7 +406,9 @@ void TextureD3D_2D::setCompressedImage(GLenum target, GLint level, GLenum format ...@@ -378,7 +406,9 @@ void TextureD3D_2D::setCompressedImage(GLenum target, GLint level, GLenum format
TextureD3D::setCompressedImage(imageSize, pixels, mImageArray[level]); TextureD3D::setCompressedImage(imageSize, pixels, mImageArray[level]);
} }
void TextureD3D_2D::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels) gl::Error TextureD3D_2D::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type,
const gl::PixelUnpackState &unpack, const void *pixels)
{ {
ASSERT(target == GL_TEXTURE_2D && depth == 1 && zoffset == 0); ASSERT(target == GL_TEXTURE_2D && depth == 1 && zoffset == 0);
...@@ -390,8 +420,14 @@ void TextureD3D_2D::subImage(GLenum target, GLint level, GLint xoffset, GLint yo ...@@ -390,8 +420,14 @@ void TextureD3D_2D::subImage(GLenum target, GLint level, GLint xoffset, GLint yo
RenderTarget *renderTarget = getRenderTarget(index); RenderTarget *renderTarget = getRenderTarget(index);
gl::Box destArea(xoffset, yoffset, 0, width, height, 1); gl::Box destArea(xoffset, yoffset, 0, width, height, 1);
if (renderTarget && fastUnpackPixels(unpack, pixels, destArea, getInternalFormat(level), type, renderTarget)) if (renderTarget)
{ {
gl::Error error = fastUnpackPixels(unpack, pixels, destArea, getInternalFormat(level), type, renderTarget);
if (error.isError())
{
return error;
}
// Ensure we don't overwrite our newly initialized data // Ensure we don't overwrite our newly initialized data
mImageArray[level]->markClean(); mImageArray[level]->markClean();
...@@ -399,10 +435,24 @@ void TextureD3D_2D::subImage(GLenum target, GLint level, GLint xoffset, GLint yo ...@@ -399,10 +435,24 @@ void TextureD3D_2D::subImage(GLenum target, GLint level, GLint xoffset, GLint yo
} }
} }
if (!fastUnpacked && TextureD3D::subImage(xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels, index)) if (!fastUnpacked)
{ {
commitRect(level, xoffset, yoffset, width, height); gl::ImageIndex index = gl::ImageIndex::Make2D(level);
gl::Error error = TextureD3D::subImage(xoffset, yoffset, 0, width, height, 1, format, type, unpack,
pixels, index);
if (error.isError())
{
return error;
}
error = commitRect(level, xoffset, yoffset, width, height);
if (error.isError())
{
return error;
}
} }
return gl::Error(GL_NO_ERROR);
} }
void TextureD3D_2D::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels) void TextureD3D_2D::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels)
...@@ -753,16 +803,21 @@ void TextureD3D_2D::redefineImage(GLint level, GLenum internalformat, GLsizei wi ...@@ -753,16 +803,21 @@ void TextureD3D_2D::redefineImage(GLint level, GLenum internalformat, GLsizei wi
} }
} }
void TextureD3D_2D::commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) gl::Error TextureD3D_2D::commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
{ {
if (isValidLevel(level)) if (isValidLevel(level))
{ {
ImageD3D *image = mImageArray[level]; ImageD3D *image = mImageArray[level];
if (image->copyToStorage2D(mTexStorage, level, xoffset, yoffset, width, height)) gl::Error error = image->copyToStorage2D(mTexStorage, level, xoffset, yoffset, width, height);
if (error.isError())
{ {
image->markClean(); return error;
} }
image->markClean();
} }
return gl::Error(GL_NO_ERROR);
} }
gl::ImageIndexIterator TextureD3D_2D::imageIterator() const gl::ImageIndexIterator TextureD3D_2D::imageIterator() const
...@@ -838,7 +893,9 @@ bool TextureD3D_Cube::isDepth(GLint level, GLint layer) const ...@@ -838,7 +893,9 @@ bool TextureD3D_Cube::isDepth(GLint level, GLint layer) const
return gl::GetInternalFormatInfo(getInternalFormat(level, layer)).depthBits > 0; return gl::GetInternalFormatInfo(getInternalFormat(level, layer)).depthBits > 0;
} }
void TextureD3D_Cube::setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels) gl::Error TextureD3D_Cube::setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth,
GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack,
const void *pixels)
{ {
ASSERT(depth == 1); ASSERT(depth == 1);
...@@ -847,7 +904,7 @@ void TextureD3D_Cube::setImage(GLenum target, GLint level, GLsizei width, GLsize ...@@ -847,7 +904,7 @@ void TextureD3D_Cube::setImage(GLenum target, GLint level, GLsizei width, GLsize
redefineImage(faceIndex, level, sizedInternalFormat, width, height); redefineImage(faceIndex, level, sizedInternalFormat, width, height);
TextureD3D::setImage(unpack, type, pixels, mImageArray[faceIndex][level]); return TextureD3D::setImage(unpack, type, pixels, mImageArray[faceIndex][level]);
} }
void TextureD3D_Cube::setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels) void TextureD3D_Cube::setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels)
...@@ -862,17 +919,29 @@ void TextureD3D_Cube::setCompressedImage(GLenum target, GLint level, GLenum form ...@@ -862,17 +919,29 @@ void TextureD3D_Cube::setCompressedImage(GLenum target, GLint level, GLenum form
TextureD3D::setCompressedImage(imageSize, pixels, mImageArray[faceIndex][level]); TextureD3D::setCompressedImage(imageSize, pixels, mImageArray[faceIndex][level]);
} }
void TextureD3D_Cube::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels) gl::Error TextureD3D_Cube::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type,
const gl::PixelUnpackState &unpack, const void *pixels)
{ {
ASSERT(depth == 1 && zoffset == 0); ASSERT(depth == 1 && zoffset == 0);
int faceIndex = gl::TextureCubeMap::targetToLayerIndex(target); int faceIndex = gl::TextureCubeMap::targetToLayerIndex(target);
gl::ImageIndex index = gl::ImageIndex::MakeCube(target, level); gl::ImageIndex index = gl::ImageIndex::MakeCube(target, level);
if (TextureD3D::subImage(xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels, index)) gl::Error error = TextureD3D::subImage(xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels,
index);
if (error.isError())
{ {
commitRect(faceIndex, level, xoffset, yoffset, width, height); return error;
}
error = commitRect(faceIndex, level, xoffset, yoffset, width, height);
if (error.isError())
{
return error;
} }
return gl::Error(GL_NO_ERROR);
} }
void TextureD3D_Cube::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels) void TextureD3D_Cube::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels)
...@@ -1248,14 +1317,21 @@ void TextureD3D_Cube::redefineImage(int faceIndex, GLint level, GLenum internalf ...@@ -1248,14 +1317,21 @@ void TextureD3D_Cube::redefineImage(int faceIndex, GLint level, GLenum internalf
} }
} }
void TextureD3D_Cube::commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) gl::Error TextureD3D_Cube::commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
{ {
if (isValidFaceLevel(faceIndex, level)) if (isValidFaceLevel(faceIndex, level))
{ {
ImageD3D *image = mImageArray[faceIndex][level]; ImageD3D *image = mImageArray[faceIndex][level];
if (image->copyToStorageCube(mTexStorage, faceIndex, level, xoffset, yoffset, width, height)) gl::Error error = image->copyToStorageCube(mTexStorage, faceIndex, level, xoffset, yoffset, width, height);
image->markClean(); if (error.isError())
{
return error;
}
image->markClean();
} }
return gl::Error(GL_NO_ERROR);
} }
gl::ImageIndexIterator TextureD3D_Cube::imageIterator() const gl::ImageIndexIterator TextureD3D_Cube::imageIterator() const
...@@ -1350,7 +1426,9 @@ bool TextureD3D_3D::isDepth(GLint level) const ...@@ -1350,7 +1426,9 @@ bool TextureD3D_3D::isDepth(GLint level) const
return gl::GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0; return gl::GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0;
} }
void TextureD3D_3D::setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels) gl::Error TextureD3D_3D::setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth,
GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack,
const void *pixels)
{ {
ASSERT(target == GL_TEXTURE_3D); ASSERT(target == GL_TEXTURE_3D);
GLenum sizedInternalFormat = gl::GetSizedInternalFormat(internalFormat, type); GLenum sizedInternalFormat = gl::GetSizedInternalFormat(internalFormat, type);
...@@ -1367,8 +1445,14 @@ void TextureD3D_3D::setImage(GLenum target, GLint level, GLsizei width, GLsizei ...@@ -1367,8 +1445,14 @@ void TextureD3D_3D::setImage(GLenum target, GLint level, GLsizei width, GLsizei
RenderTarget *destRenderTarget = getRenderTarget(index); RenderTarget *destRenderTarget = getRenderTarget(index);
gl::Box destArea(0, 0, 0, getWidth(level), getHeight(level), getDepth(level)); gl::Box destArea(0, 0, 0, getWidth(level), getHeight(level), getDepth(level));
if (destRenderTarget && fastUnpackPixels(unpack, pixels, destArea, sizedInternalFormat, type, destRenderTarget)) if (destRenderTarget)
{ {
gl::Error error = fastUnpackPixels(unpack, pixels, destArea, sizedInternalFormat, type, destRenderTarget);
if (error.isError())
{
return error;
}
// Ensure we don't overwrite our newly initialized data // Ensure we don't overwrite our newly initialized data
mImageArray[level]->markClean(); mImageArray[level]->markClean();
...@@ -1378,8 +1462,14 @@ void TextureD3D_3D::setImage(GLenum target, GLint level, GLsizei width, GLsizei ...@@ -1378,8 +1462,14 @@ void TextureD3D_3D::setImage(GLenum target, GLint level, GLsizei width, GLsizei
if (!fastUnpacked) if (!fastUnpacked)
{ {
TextureD3D::setImage(unpack, type, pixels, mImageArray[level]); gl::Error error = TextureD3D::setImage(unpack, type, pixels, mImageArray[level]);
if (error.isError())
{
return error;
}
} }
return gl::Error(GL_NO_ERROR);
} }
void TextureD3D_3D::setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels) void TextureD3D_3D::setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels)
...@@ -1392,7 +1482,9 @@ void TextureD3D_3D::setCompressedImage(GLenum target, GLint level, GLenum format ...@@ -1392,7 +1482,9 @@ void TextureD3D_3D::setCompressedImage(GLenum target, GLint level, GLenum format
TextureD3D::setCompressedImage(imageSize, pixels, mImageArray[level]); TextureD3D::setCompressedImage(imageSize, pixels, mImageArray[level]);
} }
void TextureD3D_3D::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels) gl::Error TextureD3D_3D::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type,
const gl::PixelUnpackState &unpack, const void *pixels)
{ {
ASSERT(target == GL_TEXTURE_3D); ASSERT(target == GL_TEXTURE_3D);
...@@ -1406,8 +1498,14 @@ void TextureD3D_3D::subImage(GLenum target, GLint level, GLint xoffset, GLint yo ...@@ -1406,8 +1498,14 @@ void TextureD3D_3D::subImage(GLenum target, GLint level, GLint xoffset, GLint yo
RenderTarget *destRenderTarget = getRenderTarget(index); RenderTarget *destRenderTarget = getRenderTarget(index);
gl::Box destArea(xoffset, yoffset, zoffset, width, height, depth); gl::Box destArea(xoffset, yoffset, zoffset, width, height, depth);
if (destRenderTarget && fastUnpackPixels(unpack, pixels, destArea, getInternalFormat(level), type, destRenderTarget)) if (destRenderTarget)
{ {
gl::Error error = fastUnpackPixels(unpack, pixels, destArea, getInternalFormat(level), type, destRenderTarget);
if (error.isError())
{
return error;
}
// Ensure we don't overwrite our newly initialized data // Ensure we don't overwrite our newly initialized data
mImageArray[level]->markClean(); mImageArray[level]->markClean();
...@@ -1415,10 +1513,24 @@ void TextureD3D_3D::subImage(GLenum target, GLint level, GLint xoffset, GLint yo ...@@ -1415,10 +1513,24 @@ void TextureD3D_3D::subImage(GLenum target, GLint level, GLint xoffset, GLint yo
} }
} }
if (!fastUnpacked && TextureD3D::subImage(xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels, index)) if (!fastUnpacked)
{ {
commitRect(level, xoffset, yoffset, zoffset, width, height, depth); gl::ImageIndex index = gl::ImageIndex::Make3D(level);
gl::Error error = TextureD3D::subImage(xoffset, yoffset, zoffset, width, height, depth, format, type, unpack,
pixels, index);
if (error.isError())
{
return error;
}
error = commitRect(level, xoffset, yoffset, zoffset, width, height, depth);
if (error.isError())
{
return error;
}
} }
return gl::Error(GL_NO_ERROR);
} }
void TextureD3D_3D::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels) void TextureD3D_3D::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels)
...@@ -1733,16 +1845,21 @@ void TextureD3D_3D::redefineImage(GLint level, GLenum internalformat, GLsizei wi ...@@ -1733,16 +1845,21 @@ void TextureD3D_3D::redefineImage(GLint level, GLenum internalformat, GLsizei wi
} }
} }
void TextureD3D_3D::commitRect(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth) gl::Error TextureD3D_3D::commitRect(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth)
{ {
if (isValidLevel(level)) if (isValidLevel(level))
{ {
ImageD3D *image = mImageArray[level]; ImageD3D *image = mImageArray[level];
if (image->copyToStorage3D(mTexStorage, level, xoffset, yoffset, zoffset, width, height, depth)) gl::Error error = image->copyToStorage3D(mTexStorage, level, xoffset, yoffset, zoffset, width, height, depth);
if (error.isError())
{ {
image->markClean(); return error;
} }
image->markClean();
} }
return gl::Error(GL_NO_ERROR);
} }
gl::ImageIndexIterator TextureD3D_3D::imageIterator() const gl::ImageIndexIterator TextureD3D_3D::imageIterator() const
...@@ -1823,7 +1940,9 @@ bool TextureD3D_2DArray::isDepth(GLint level) const ...@@ -1823,7 +1940,9 @@ bool TextureD3D_2DArray::isDepth(GLint level) const
return gl::GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0; return gl::GetInternalFormatInfo(getInternalFormat(level)).depthBits > 0;
} }
void TextureD3D_2DArray::setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels) gl::Error TextureD3D_2DArray::setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth,
GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack,
const void *pixels)
{ {
ASSERT(target == GL_TEXTURE_2D_ARRAY); ASSERT(target == GL_TEXTURE_2D_ARRAY);
...@@ -1837,8 +1956,14 @@ void TextureD3D_2DArray::setImage(GLenum target, GLint level, GLsizei width, GLs ...@@ -1837,8 +1956,14 @@ void TextureD3D_2DArray::setImage(GLenum target, GLint level, GLsizei width, GLs
for (int i = 0; i < depth; i++) for (int i = 0; i < depth; i++)
{ {
const void *layerPixels = pixels ? (reinterpret_cast<const unsigned char*>(pixels) + (inputDepthPitch * i)) : NULL; const void *layerPixels = pixels ? (reinterpret_cast<const unsigned char*>(pixels) + (inputDepthPitch * i)) : NULL;
TextureD3D::setImage(unpack, type, layerPixels, mImageArray[level][i]); gl::Error error = TextureD3D::setImage(unpack, type, layerPixels, mImageArray[level][i]);
if (error.isError())
{
return error;
}
} }
return gl::Error(GL_NO_ERROR);
} }
void TextureD3D_2DArray::setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels) void TextureD3D_2DArray::setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels)
...@@ -1858,7 +1983,9 @@ void TextureD3D_2DArray::setCompressedImage(GLenum target, GLint level, GLenum f ...@@ -1858,7 +1983,9 @@ void TextureD3D_2DArray::setCompressedImage(GLenum target, GLint level, GLenum f
} }
} }
void TextureD3D_2DArray::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels) gl::Error TextureD3D_2DArray::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset,
GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type,
const gl::PixelUnpackState &unpack, const void *pixels)
{ {
ASSERT(target == GL_TEXTURE_2D_ARRAY); ASSERT(target == GL_TEXTURE_2D_ARRAY);
...@@ -1871,11 +1998,21 @@ void TextureD3D_2DArray::subImage(GLenum target, GLint level, GLint xoffset, GLi ...@@ -1871,11 +1998,21 @@ void TextureD3D_2DArray::subImage(GLenum target, GLint level, GLint xoffset, GLi
const void *layerPixels = pixels ? (reinterpret_cast<const unsigned char*>(pixels) + (inputDepthPitch * i)) : NULL; const void *layerPixels = pixels ? (reinterpret_cast<const unsigned char*>(pixels) + (inputDepthPitch * i)) : NULL;
gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, layer); gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, layer);
if (TextureD3D::subImage(xoffset, yoffset, zoffset, width, height, 1, format, type, unpack, layerPixels, index)) gl::Error error = TextureD3D::subImage(xoffset, yoffset, zoffset, width, height, 1, format, type, unpack,
layerPixels, index);
if (error.isError())
{ {
commitRect(level, xoffset, yoffset, layer, width, height); return error;
}
error = commitRect(level, xoffset, yoffset, layer, width, height);
if (error.isError())
{
return error;
} }
} }
return gl::Error(GL_NO_ERROR);
} }
void TextureD3D_2DArray::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels) void TextureD3D_2DArray::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels)
...@@ -2239,16 +2376,21 @@ void TextureD3D_2DArray::redefineImage(GLint level, GLenum internalformat, GLsiz ...@@ -2239,16 +2376,21 @@ void TextureD3D_2DArray::redefineImage(GLint level, GLenum internalformat, GLsiz
} }
} }
void TextureD3D_2DArray::commitRect(GLint level, GLint xoffset, GLint yoffset, GLint layerTarget, GLsizei width, GLsizei height) gl::Error TextureD3D_2DArray::commitRect(GLint level, GLint xoffset, GLint yoffset, GLint layerTarget, GLsizei width, GLsizei height)
{ {
if (isValidLevel(level) && layerTarget < getLayers(level)) if (isValidLevel(level) && layerTarget < getLayers(level))
{ {
ImageD3D *image = mImageArray[level][layerTarget]; ImageD3D *image = mImageArray[level][layerTarget];
if (image->copyToStorage2DArray(mTexStorage, level, xoffset, yoffset, layerTarget, width, height)) gl::Error error = image->copyToStorage2DArray(mTexStorage, level, xoffset, yoffset, layerTarget, width, height);
if (error.isError())
{ {
image->markClean(); return error;
} }
image->markClean();
} }
return gl::Error(GL_NO_ERROR);
} }
gl::ImageIndexIterator TextureD3D_2DArray::imageIterator() const gl::ImageIndexIterator TextureD3D_2DArray::imageIterator() const
......
...@@ -61,15 +61,15 @@ class TextureD3D : public TextureImpl ...@@ -61,15 +61,15 @@ class TextureD3D : public TextureImpl
virtual void generateMipmaps(); virtual void generateMipmaps();
protected: protected:
void setImage(const gl::PixelUnpackState &unpack, GLenum type, const void *pixels, Image *image); gl::Error setImage(const gl::PixelUnpackState &unpack, GLenum type, const void *pixels, Image *image);
bool subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, gl::Error subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels, const gl::ImageIndex &index); GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels, const gl::ImageIndex &index);
void setCompressedImage(GLsizei imageSize, const void *pixels, Image *image); void setCompressedImage(GLsizei imageSize, const void *pixels, Image *image);
bool subImageCompressed(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, bool subImageCompressed(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLsizei imageSize, const void *pixels, Image *image); GLenum format, GLsizei imageSize, const void *pixels, Image *image);
bool isFastUnpackable(const gl::PixelUnpackState &unpack, GLenum sizedInternalFormat); bool isFastUnpackable(const gl::PixelUnpackState &unpack, GLenum sizedInternalFormat);
bool fastUnpackPixels(const gl::PixelUnpackState &unpack, const void *pixels, const gl::Box &destArea, gl::Error fastUnpackPixels(const gl::PixelUnpackState &unpack, const void *pixels, const gl::Box &destArea,
GLenum sizedInternalFormat, GLenum type, RenderTarget *destRenderTarget); GLenum sizedInternalFormat, GLenum type, RenderTarget *destRenderTarget);
GLint creationLevels(GLsizei width, GLsizei height, GLsizei depth) const; GLint creationLevels(GLsizei width, GLsizei height, GLsizei depth) const;
int mipLevels() const; int mipLevels() const;
...@@ -109,9 +109,9 @@ class TextureD3D_2D : public TextureD3D ...@@ -109,9 +109,9 @@ class TextureD3D_2D : public TextureD3D
GLenum getActualFormat(GLint level) const; GLenum getActualFormat(GLint level) const;
bool isDepth(GLint level) const; bool isDepth(GLint level) const;
virtual void setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels); virtual gl::Error setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels); virtual void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
virtual void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels); virtual gl::Error subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels); virtual void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
virtual void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source); virtual void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source); virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
...@@ -145,7 +145,7 @@ class TextureD3D_2D : public TextureD3D ...@@ -145,7 +145,7 @@ class TextureD3D_2D : public TextureD3D
void updateStorageLevel(int level); void updateStorageLevel(int level);
void redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height); void redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height);
void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); gl::Error commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
TextureStorage *mTexStorage; TextureStorage *mTexStorage;
ImageD3D *mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS]; ImageD3D *mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
...@@ -168,9 +168,9 @@ class TextureD3D_Cube : public TextureD3D ...@@ -168,9 +168,9 @@ class TextureD3D_Cube : public TextureD3D
GLenum getInternalFormat(GLint level, GLint layer) const; GLenum getInternalFormat(GLint level, GLint layer) const;
bool isDepth(GLint level, GLint layer) const; bool isDepth(GLint level, GLint layer) const;
virtual void setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels); virtual gl::Error setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels); virtual void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
virtual void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels); virtual gl::Error subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels); virtual void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
virtual void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source); virtual void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source); virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
...@@ -204,7 +204,7 @@ class TextureD3D_Cube : public TextureD3D ...@@ -204,7 +204,7 @@ class TextureD3D_Cube : public TextureD3D
void updateStorageFaceLevel(int faceIndex, int level); void updateStorageFaceLevel(int faceIndex, int level);
void redefineImage(int faceIndex, GLint level, GLenum internalformat, GLsizei width, GLsizei height); void redefineImage(int faceIndex, GLint level, GLenum internalformat, GLsizei width, GLsizei height);
void commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); gl::Error commitRect(int faceIndex, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
ImageD3D *mImageArray[6][gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS]; ImageD3D *mImageArray[6][gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
...@@ -227,9 +227,9 @@ class TextureD3D_3D : public TextureD3D ...@@ -227,9 +227,9 @@ class TextureD3D_3D : public TextureD3D
GLenum getInternalFormat(GLint level) const; GLenum getInternalFormat(GLint level) const;
bool isDepth(GLint level) const; bool isDepth(GLint level) const;
virtual void setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels); virtual gl::Error setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels); virtual void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
virtual void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels); virtual gl::Error subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels); virtual void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
virtual void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source); virtual void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source); virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
...@@ -262,7 +262,7 @@ class TextureD3D_3D : public TextureD3D ...@@ -262,7 +262,7 @@ class TextureD3D_3D : public TextureD3D
void updateStorageLevel(int level); void updateStorageLevel(int level);
void redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); void redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
void commitRect(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); gl::Error commitRect(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
ImageD3D *mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS]; ImageD3D *mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
...@@ -285,9 +285,9 @@ class TextureD3D_2DArray : public TextureD3D ...@@ -285,9 +285,9 @@ class TextureD3D_2DArray : public TextureD3D
GLenum getInternalFormat(GLint level) const; GLenum getInternalFormat(GLint level) const;
bool isDepth(GLint level) const; bool isDepth(GLint level) const;
virtual void setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels); virtual gl::Error setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels); virtual void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels);
virtual void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels); virtual gl::Error subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels);
virtual void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels); virtual void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels);
virtual void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source); virtual void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source); virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
...@@ -321,7 +321,7 @@ class TextureD3D_2DArray : public TextureD3D ...@@ -321,7 +321,7 @@ class TextureD3D_2DArray : public TextureD3D
void deleteImages(); void deleteImages();
void redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); void redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
void commitRect(GLint level, GLint xoffset, GLint yoffset, GLint layerTarget, GLsizei width, GLsizei height); gl::Error commitRect(GLint level, GLint xoffset, GLint yoffset, GLint layerTarget, GLsizei width, GLsizei height);
// Storing images as an array of single depth textures since D3D11 treats each array level of a // Storing images as an array of single depth textures since D3D11 treats each array level of a
// Texture2D object as a separate subresource. Each layer would have to be looped over // Texture2D object as a separate subresource. Each layer would have to be looped over
......
...@@ -99,31 +99,31 @@ bool Image11::isDirty() const ...@@ -99,31 +99,31 @@ bool Image11::isDirty() const
return mDirty; return mDirty;
} }
bool Image11::copyToStorage2D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) gl::Error Image11::copyToStorage2D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
{ {
TextureStorage11_2D *storage11 = TextureStorage11_2D::makeTextureStorage11_2D(storage); TextureStorage11_2D *storage11 = TextureStorage11_2D::makeTextureStorage11_2D(storage);
return copyToStorageImpl(storage11, level, 0, xoffset, yoffset, width, height); return copyToStorageImpl(storage11, level, 0, xoffset, yoffset, width, height);
} }
bool Image11::copyToStorageCube(TextureStorage *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) gl::Error Image11::copyToStorageCube(TextureStorage *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
{ {
TextureStorage11_Cube *storage11 = TextureStorage11_Cube::makeTextureStorage11_Cube(storage); TextureStorage11_Cube *storage11 = TextureStorage11_Cube::makeTextureStorage11_Cube(storage);
return copyToStorageImpl(storage11, level, face, xoffset, yoffset, width, height); return copyToStorageImpl(storage11, level, face, xoffset, yoffset, width, height);
} }
bool Image11::copyToStorage3D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth) gl::Error Image11::copyToStorage3D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth)
{ {
TextureStorage11_3D *storage11 = TextureStorage11_3D::makeTextureStorage11_3D(storage); TextureStorage11_3D *storage11 = TextureStorage11_3D::makeTextureStorage11_3D(storage);
return copyToStorageImpl(storage11, level, 0, xoffset, yoffset, width, height); return copyToStorageImpl(storage11, level, 0, xoffset, yoffset, width, height);
} }
bool Image11::copyToStorage2DArray(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint arrayLayer, GLsizei width, GLsizei height) gl::Error Image11::copyToStorage2DArray(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint arrayLayer, GLsizei width, GLsizei height)
{ {
TextureStorage11_2DArray *storage11 = TextureStorage11_2DArray::makeTextureStorage11_2DArray(storage); TextureStorage11_2DArray *storage11 = TextureStorage11_2DArray::makeTextureStorage11_2DArray(storage);
return copyToStorageImpl(storage11, level, arrayLayer, xoffset, yoffset, width, height); return copyToStorageImpl(storage11, level, arrayLayer, xoffset, yoffset, width, height);
} }
bool Image11::copyToStorageImpl(TextureStorage11 *storage11, int level, int layerTarget, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) gl::Error Image11::copyToStorageImpl(TextureStorage11 *storage11, int level, int layerTarget, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
{ {
// If an app's behavior results in an Image11 copying its data to/from to a TextureStorage multiple times, // If an app's behavior results in an Image11 copying its data to/from to a TextureStorage multiple times,
// then we should just keep the staging texture around to prevent the copying from impacting perf. // then we should just keep the staging texture around to prevent the copying from impacting perf.
...@@ -137,10 +137,15 @@ bool Image11::copyToStorageImpl(TextureStorage11 *storage11, int level, int laye ...@@ -137,10 +137,15 @@ bool Image11::copyToStorageImpl(TextureStorage11 *storage11, int level, int laye
storage11->releaseAssociatedImage(level, layerTarget, this); storage11->releaseAssociatedImage(level, layerTarget, this);
} }
bool updateSubresourceSuccess = storage11->updateSubresourceLevel(getStagingTexture(), getStagingSubresource(), level, layerTarget, xoffset, yoffset, 0, width, height, 1); gl::Error error = storage11->updateSubresourceLevel(getStagingTexture(), getStagingSubresource(), level, layerTarget,
xoffset, yoffset, 0, width, height, 1);
if (error.isError())
{
return error;
}
// Once the image data has been copied into the Storage, we can release it locally. // Once the image data has been copied into the Storage, we can release it locally.
if (attemptToReleaseStagingTexture && updateSubresourceSuccess) if (attemptToReleaseStagingTexture)
{ {
storage11->associateImage(this, level, layerTarget); storage11->associateImage(this, level, layerTarget);
releaseStagingTexture(); releaseStagingTexture();
...@@ -150,7 +155,7 @@ bool Image11::copyToStorageImpl(TextureStorage11 *storage11, int level, int laye ...@@ -150,7 +155,7 @@ bool Image11::copyToStorageImpl(TextureStorage11 *storage11, int level, int laye
mAssociatedStorageLayerTarget = layerTarget; mAssociatedStorageLayerTarget = layerTarget;
} }
return updateSubresourceSuccess; return gl::Error(GL_NO_ERROR);
} }
bool Image11::isAssociatedStorageValid(TextureStorage11* textureStorage) const bool Image11::isAssociatedStorageValid(TextureStorage11* textureStorage) const
...@@ -247,8 +252,8 @@ DXGI_FORMAT Image11::getDXGIFormat() const ...@@ -247,8 +252,8 @@ DXGI_FORMAT Image11::getDXGIFormat() const
// Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input // Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input
// into the target pixel rectangle. // into the target pixel rectangle.
void Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, gl::Error Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, GLenum type, const void *input) GLint unpackAlignment, GLenum type, const void *input)
{ {
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat); const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat);
GLsizei inputRowPitch = formatInfo.computeRowPitch(type, width, unpackAlignment); GLsizei inputRowPitch = formatInfo.computeRowPitch(type, width, unpackAlignment);
...@@ -264,8 +269,7 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei widt ...@@ -264,8 +269,7 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei widt
HRESULT result = map(D3D11_MAP_WRITE, &mappedImage); HRESULT result = map(D3D11_MAP_WRITE, &mappedImage);
if (FAILED(result)) if (FAILED(result))
{ {
ERR("Could not map image for loading."); return gl::Error(GL_OUT_OF_MEMORY, "Could not map internal image for loading texture data, result: 0x%X.", result);
return;
} }
uint8_t* offsetMappedData = (reinterpret_cast<uint8_t*>(mappedImage.pData) + (yoffset * mappedImage.RowPitch + xoffset * outputPixelSize + zoffset * mappedImage.DepthPitch)); uint8_t* offsetMappedData = (reinterpret_cast<uint8_t*>(mappedImage.pData) + (yoffset * mappedImage.RowPitch + xoffset * outputPixelSize + zoffset * mappedImage.DepthPitch));
...@@ -274,6 +278,8 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei widt ...@@ -274,6 +278,8 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei widt
offsetMappedData, mappedImage.RowPitch, mappedImage.DepthPitch); offsetMappedData, mappedImage.RowPitch, mappedImage.DepthPitch);
unmap(); unmap();
return gl::Error(GL_NO_ERROR);
} }
void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
......
...@@ -37,17 +37,17 @@ class Image11 : public ImageD3D ...@@ -37,17 +37,17 @@ class Image11 : public ImageD3D
virtual bool isDirty() const; virtual bool isDirty() const;
virtual bool copyToStorage2D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); virtual gl::Error copyToStorage2D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
virtual bool copyToStorageCube(TextureStorage *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); virtual gl::Error copyToStorageCube(TextureStorage *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
virtual bool copyToStorage3D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); virtual gl::Error copyToStorage3D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
virtual bool copyToStorage2DArray(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint arrayLayer, GLsizei width, GLsizei height); virtual gl::Error copyToStorage2DArray(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint arrayLayer, GLsizei width, GLsizei height);
virtual bool redefine(Renderer *renderer, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease); virtual bool redefine(Renderer *renderer, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease);
DXGI_FORMAT getDXGIFormat() const; DXGI_FORMAT getDXGIFormat() const;
virtual void loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, virtual gl::Error loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, GLenum type, const void *input); GLint unpackAlignment, GLenum type, const void *input);
virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
const void *input); const void *input);
...@@ -64,7 +64,7 @@ class Image11 : public ImageD3D ...@@ -64,7 +64,7 @@ class Image11 : public ImageD3D
private: private:
DISALLOW_COPY_AND_ASSIGN(Image11); DISALLOW_COPY_AND_ASSIGN(Image11);
bool copyToStorageImpl(TextureStorage11 *storage11, int level, int layerTarget, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); gl::Error copyToStorageImpl(TextureStorage11 *storage11, int level, int layerTarget, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
ID3D11Resource *getStagingTexture(); ID3D11Resource *getStagingTexture();
unsigned int getStagingSubresource(); unsigned int getStagingSubresource();
......
...@@ -287,60 +287,57 @@ void TextureStorage11::invalidateSwizzleCache() ...@@ -287,60 +287,57 @@ void TextureStorage11::invalidateSwizzleCache()
} }
} }
bool TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, unsigned int sourceSubresource, gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, unsigned int sourceSubresource,
int level, int layerTarget, GLint xoffset, GLint yoffset, GLint zoffset, int level, int layerTarget, GLint xoffset, GLint yoffset, GLint zoffset,
GLsizei width, GLsizei height, GLsizei depth) GLsizei width, GLsizei height, GLsizei depth)
{ {
if (srcTexture) ASSERT(srcTexture);
{
invalidateSwizzleCacheLevel(level);
gl::Extents texSize(getLevelWidth(level), getLevelHeight(level), getLevelDepth(level)); invalidateSwizzleCacheLevel(level);
gl::Box copyArea(xoffset, yoffset, zoffset, width, height, depth);
bool fullCopy = copyArea.x == 0 && gl::Extents texSize(getLevelWidth(level), getLevelHeight(level), getLevelDepth(level));
copyArea.y == 0 && gl::Box copyArea(xoffset, yoffset, zoffset, width, height, depth);
copyArea.z == 0 &&
copyArea.width == texSize.width &&
copyArea.height == texSize.height &&
copyArea.depth == texSize.depth;
ID3D11Resource *dstTexture = getResource(); bool fullCopy = copyArea.x == 0 &&
unsigned int dstSubresource = getSubresourceIndex(level + mTopLevel, layerTarget); copyArea.y == 0 &&
copyArea.z == 0 &&
copyArea.width == texSize.width &&
copyArea.height == texSize.height &&
copyArea.depth == texSize.depth;
ASSERT(dstTexture); ID3D11Resource *dstTexture = getResource();
unsigned int dstSubresource = getSubresourceIndex(level + mTopLevel, layerTarget);
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mTextureFormat); ASSERT(dstTexture);
if (!fullCopy && (dxgiFormatInfo.depthBits > 0 || dxgiFormatInfo.stencilBits > 0))
{
// CopySubresourceRegion cannot copy partial depth stencils, use the blitter instead
Blit11 *blitter = mRenderer->getBlitter();
return !blitter->copyDepthStencil(srcTexture, sourceSubresource, copyArea, texSize, const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mTextureFormat);
dstTexture, dstSubresource, copyArea, texSize, if (!fullCopy && (dxgiFormatInfo.depthBits > 0 || dxgiFormatInfo.stencilBits > 0))
NULL).isError(); {
} // CopySubresourceRegion cannot copy partial depth stencils, use the blitter instead
else Blit11 *blitter = mRenderer->getBlitter();
{
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mTextureFormat);
D3D11_BOX srcBox; return blitter->copyDepthStencil(srcTexture, sourceSubresource, copyArea, texSize,
srcBox.left = copyArea.x; dstTexture, dstSubresource, copyArea, texSize,
srcBox.top = copyArea.y; NULL);
srcBox.right = copyArea.x + roundUp((unsigned int)width, dxgiFormatInfo.blockWidth); }
srcBox.bottom = copyArea.y + roundUp((unsigned int)height, dxgiFormatInfo.blockHeight); else
srcBox.front = copyArea.z; {
srcBox.back = copyArea.z + copyArea.depth; const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mTextureFormat);
ID3D11DeviceContext *context = mRenderer->getDeviceContext(); D3D11_BOX srcBox;
srcBox.left = copyArea.x;
srcBox.top = copyArea.y;
srcBox.right = copyArea.x + roundUp((unsigned int)width, dxgiFormatInfo.blockWidth);
srcBox.bottom = copyArea.y + roundUp((unsigned int)height, dxgiFormatInfo.blockHeight);
srcBox.front = copyArea.z;
srcBox.back = copyArea.z + copyArea.depth;
context->CopySubresourceRegion(dstTexture, dstSubresource, copyArea.x, copyArea.y, copyArea.z, ID3D11DeviceContext *context = mRenderer->getDeviceContext();
srcTexture, sourceSubresource, fullCopy ? NULL : &srcBox);
return true;
}
}
return false; context->CopySubresourceRegion(dstTexture, dstSubresource, copyArea.x, copyArea.y, copyArea.z,
srcTexture, sourceSubresource, fullCopy ? NULL : &srcBox);
return gl::Error(GL_NO_ERROR);
}
} }
bool TextureStorage11::copySubresourceLevel(ID3D11Resource* dstTexture, unsigned int dstSubresource, bool TextureStorage11::copySubresourceLevel(ID3D11Resource* dstTexture, unsigned int dstSubresource,
......
...@@ -57,9 +57,9 @@ class TextureStorage11 : public TextureStorage ...@@ -57,9 +57,9 @@ class TextureStorage11 : public TextureStorage
void invalidateSwizzleCacheLevel(int mipLevel); void invalidateSwizzleCacheLevel(int mipLevel);
void invalidateSwizzleCache(); void invalidateSwizzleCache();
bool updateSubresourceLevel(ID3D11Resource *texture, unsigned int sourceSubresource, int level, gl::Error updateSubresourceLevel(ID3D11Resource *texture, unsigned int sourceSubresource, int level,
int layerTarget, GLint xoffset, GLint yoffset, GLint zoffset, int layerTarget, GLint xoffset, GLint yoffset, GLint zoffset,
GLsizei width, GLsizei height, GLsizei depth); GLsizei width, GLsizei height, GLsizei depth);
bool copySubresourceLevel(ID3D11Resource* dstTexture, unsigned int dstSubresource, int level, bool copySubresourceLevel(ID3D11Resource* dstTexture, unsigned int dstSubresource, int level,
int layerTarget, GLint xoffset, GLint yoffset, GLint zoffset, int layerTarget, GLint xoffset, GLint yoffset, GLint zoffset,
......
...@@ -301,88 +301,95 @@ void Image9::setManagedSurface(IDirect3DSurface9 *surface) ...@@ -301,88 +301,95 @@ void Image9::setManagedSurface(IDirect3DSurface9 *surface)
} }
} }
bool Image9::copyToStorage2D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) gl::Error Image9::copyToStorage2D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
{ {
ASSERT(getSurface() != NULL); ASSERT(getSurface() != NULL);
TextureStorage9_2D *storage9 = TextureStorage9_2D::makeTextureStorage9_2D(storage); TextureStorage9_2D *storage9 = TextureStorage9_2D::makeTextureStorage9_2D(storage);
return copyToSurface(storage9->getSurfaceLevel(level, true), xoffset, yoffset, width, height); return copyToSurface(storage9->getSurfaceLevel(level, true), xoffset, yoffset, width, height);
} }
bool Image9::copyToStorageCube(TextureStorage *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) gl::Error Image9::copyToStorageCube(TextureStorage *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
{ {
ASSERT(getSurface() != NULL); ASSERT(getSurface() != NULL);
TextureStorage9_Cube *storage9 = TextureStorage9_Cube::makeTextureStorage9_Cube(storage); TextureStorage9_Cube *storage9 = TextureStorage9_Cube::makeTextureStorage9_Cube(storage);
return copyToSurface(storage9->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level, true), xoffset, yoffset, width, height); return copyToSurface(storage9->getCubeMapSurface(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, level, true), xoffset, yoffset, width, height);
} }
bool Image9::copyToStorage3D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth) gl::Error Image9::copyToStorage3D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth)
{ {
// 3D textures are not supported by the D3D9 backend. // 3D textures are not supported by the D3D9 backend.
UNREACHABLE(); UNREACHABLE();
return false; return gl::Error(GL_INVALID_OPERATION);
} }
bool Image9::copyToStorage2DArray(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height) gl::Error Image9::copyToStorage2DArray(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height)
{ {
// 2D array textures are not supported by the D3D9 backend. // 2D array textures are not supported by the D3D9 backend.
UNREACHABLE(); UNREACHABLE();
return false; return gl::Error(GL_INVALID_OPERATION);
} }
bool Image9::copyToSurface(IDirect3DSurface9 *destSurface, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) gl::Error Image9::copyToSurface(IDirect3DSurface9 *destSurface, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
{ {
ASSERT(width > 0 && height > 0); ASSERT(width > 0 && height > 0);
ASSERT(destSurface);
if (!destSurface)
return false;
IDirect3DSurface9 *sourceSurface = getSurface(); IDirect3DSurface9 *sourceSurface = getSurface();
ASSERT(sourceSurface && sourceSurface != destSurface);
if (sourceSurface && sourceSurface != destSurface) RECT rect;
{ rect.left = xoffset;
RECT rect; rect.top = yoffset;
rect.left = xoffset; rect.right = xoffset + width;
rect.top = yoffset; rect.bottom = yoffset + height;
rect.right = xoffset + width;
rect.bottom = yoffset + height;
POINT point = {rect.left, rect.top}; POINT point = {rect.left, rect.top};
IDirect3DDevice9 *device = mRenderer->getDevice(); IDirect3DDevice9 *device = mRenderer->getDevice();
if (mD3DPool == D3DPOOL_MANAGED) if (mD3DPool == D3DPOOL_MANAGED)
{ {
D3DSURFACE_DESC desc; D3DSURFACE_DESC desc;
sourceSurface->GetDesc(&desc); sourceSurface->GetDesc(&desc);
IDirect3DSurface9 *surf = 0; IDirect3DSurface9 *surf = 0;
HRESULT result = device->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &surf, NULL); HRESULT result = device->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &surf, NULL);
if (FAILED(result))
{
SafeRelease(destSurface);
return gl::Error(GL_OUT_OF_MEMORY, "Internal CreateOffscreenPlainSurface call failed, result: 0x%X.", result);
}
if (SUCCEEDED(result)) copyLockableSurfaces(surf, sourceSurface);
{ result = device->UpdateSurface(surf, &rect, destSurface, &point);
copyLockableSurfaces(surf, sourceSurface); SafeRelease(surf);
result = device->UpdateSurface(surf, &rect, destSurface, &point); ASSERT(SUCCEEDED(result));
ASSERT(SUCCEEDED(result)); if (FAILED(result))
SafeRelease(surf); {
} SafeRelease(destSurface);
return gl::Error(GL_OUT_OF_MEMORY, "Internal UpdateSurface call failed, result: 0x%X.", result);
} }
else }
else
{
// UpdateSurface: source must be SYSTEMMEM, dest must be DEFAULT pools
HRESULT result = device->UpdateSurface(sourceSurface, &rect, destSurface, &point);
ASSERT(SUCCEEDED(result));
if (FAILED(result))
{ {
// UpdateSurface: source must be SYSTEMMEM, dest must be DEFAULT pools SafeRelease(destSurface);
HRESULT result = device->UpdateSurface(sourceSurface, &rect, destSurface, &point); return gl::Error(GL_OUT_OF_MEMORY, "Internal UpdateSurface call failed, result: 0x%X.", result);
UNUSED_ASSERTION_VARIABLE(result);
ASSERT(SUCCEEDED(result));
} }
} }
SafeRelease(destSurface); SafeRelease(destSurface);
return true; return gl::Error(GL_NO_ERROR);
} }
// Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input // Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input
// into the target pixel rectangle. // into the target pixel rectangle.
void Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, gl::Error Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, GLenum type, const void *input) GLint unpackAlignment, GLenum type, const void *input)
{ {
// 3D textures are not supported by the D3D9 backend. // 3D textures are not supported by the D3D9 backend.
ASSERT(zoffset == 0 && depth == 1); ASSERT(zoffset == 0 && depth == 1);
...@@ -403,7 +410,7 @@ void Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width ...@@ -403,7 +410,7 @@ void Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width
HRESULT result = lock(&locked, &lockRect); HRESULT result = lock(&locked, &lockRect);
if (FAILED(result)) if (FAILED(result))
{ {
return; return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock internal texture for loading data, result: 0x%X.", result);
} }
d3dFormatInfo.loadFunction(width, height, depth, d3dFormatInfo.loadFunction(width, height, depth,
...@@ -411,6 +418,8 @@ void Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width ...@@ -411,6 +418,8 @@ void Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width
reinterpret_cast<uint8_t*>(locked.pBits), locked.Pitch, 0); reinterpret_cast<uint8_t*>(locked.pBits), locked.Pitch, 0);
unlock(); unlock();
return gl::Error(GL_NO_ERROR);
} }
void Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, void Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
......
...@@ -44,13 +44,13 @@ class Image9 : public ImageD3D ...@@ -44,13 +44,13 @@ class Image9 : public ImageD3D
virtual void setManagedSurface2D(TextureStorage *storage, int level); virtual void setManagedSurface2D(TextureStorage *storage, int level);
virtual void setManagedSurfaceCube(TextureStorage *storage, int face, int level); virtual void setManagedSurfaceCube(TextureStorage *storage, int face, int level);
virtual bool copyToStorage2D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); virtual gl::Error copyToStorage2D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
virtual bool copyToStorageCube(TextureStorage *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); virtual gl::Error copyToStorageCube(TextureStorage *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
virtual bool copyToStorage3D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); virtual gl::Error copyToStorage3D(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
virtual bool copyToStorage2DArray(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height); virtual gl::Error copyToStorage2DArray(TextureStorage *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height);
virtual void loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, virtual gl::Error loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, GLenum type, const void *input); GLint unpackAlignment, GLenum type, const void *input);
virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
const void *input); const void *input);
...@@ -61,11 +61,11 @@ class Image9 : public ImageD3D ...@@ -61,11 +61,11 @@ class Image9 : public ImageD3D
void createSurface(); void createSurface();
void setManagedSurface(IDirect3DSurface9 *surface); void setManagedSurface(IDirect3DSurface9 *surface);
bool copyToSurface(IDirect3DSurface9 *dest, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); gl::Error copyToSurface(IDirect3DSurface9 *dest, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
HRESULT lock(D3DLOCKED_RECT *lockedRect, const RECT *rect); HRESULT lock(D3DLOCKED_RECT *lockedRect, const RECT *rect);
void unlock(); void unlock();
Renderer9 *mRenderer; Renderer9 *mRenderer;
D3DPOOL mD3DPool; // can only be D3DPOOL_SYSTEMMEM or D3DPOOL_MANAGED since it needs to be lockable. D3DPOOL mD3DPool; // can only be D3DPOOL_SYSTEMMEM or D3DPOOL_MANAGED since it needs to be lockable.
......
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