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
...@@ -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);
......
...@@ -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