Commit 0a4f1e27 by Geoff Lang

Merge the Texture set*Image methods and use objects for sizes and offsets.

BUG=angle:681 Change-Id: If2e981c522ca5ba3eab4484594cb41aa23800ec4 Reviewed-on: https://chromium-review.googlesource.com/236261Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent ea878cb9
...@@ -68,9 +68,24 @@ class Texture : public RefCountObject ...@@ -68,9 +68,24 @@ class Texture : public RefCountObject
virtual bool isSamplerComplete(const SamplerState &samplerState, const Data &data) const = 0; virtual bool isSamplerComplete(const SamplerState &samplerState, const Data &data) const = 0;
virtual Error generateMipmaps(); virtual Error setImage(GLenum target, size_t level, GLenum internalFormat, const Extents &size, GLenum format, GLenum type,
const PixelUnpackState &unpack, const uint8_t *pixels);
virtual Error setSubImage(GLenum target, size_t level, const Box &area, GLenum format, GLenum type,
const PixelUnpackState &unpack, const uint8_t *pixels);
virtual Error setCompressedImage(GLenum target, size_t level, GLenum internalFormat, const Extents &size,
const PixelUnpackState &unpack, const uint8_t *pixels);
virtual Error setCompressedSubImage(GLenum target, size_t level, const Box &area, GLenum format,
const PixelUnpackState &unpack, const uint8_t *pixels);
virtual Error copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source); virtual Error copyImage(GLenum target, size_t level, const Rectangle &sourceArea, GLenum internalFormat,
const Framebuffer *source);
virtual Error copySubImage(GLenum target, size_t level, const Offset &destOffset, const Rectangle &sourceArea,
const Framebuffer *source);
virtual Error setStorage(GLenum target, size_t levels, GLenum internalFormat, const Extents &size);
virtual Error generateMipmaps();
// Texture serials provide a unique way of identifying a Texture that isn't a raw pointer. // Texture serials provide a unique way of identifying a Texture that isn't a raw pointer.
// "id" is not good enough, as Textures can be deleted, then re-allocated with the same id. // "id" is not good enough, as Textures can be deleted, then re-allocated with the same id.
...@@ -118,19 +133,23 @@ class Texture2D : public Texture ...@@ -118,19 +133,23 @@ class Texture2D : public Texture
bool isCompressed(GLint level) const; bool isCompressed(GLint level) const;
bool isDepth(GLint level) const; bool isDepth(GLint level) const;
Error setImage(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels); Error setImage(GLenum target, size_t level, GLenum internalFormat, const Extents &size, GLenum format, GLenum type,
Error setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels); const PixelUnpackState &unpack, const uint8_t *pixels) override;
Error subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
Error subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels); Error setCompressedImage(GLenum target, size_t level, GLenum internalFormat, const Extents &size,
Error copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source); const PixelUnpackState &unpack, const uint8_t *pixels) override;
Error storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
Error copyImage(GLenum target, size_t level, const Rectangle &sourceArea, GLenum internalFormat,
const Framebuffer *source) override;
Error setStorage(GLenum target, size_t levels, GLenum internalFormat, const Extents &size) override;
Error generateMipmaps() override;
virtual bool isSamplerComplete(const SamplerState &samplerState, const Data &data) const; virtual bool isSamplerComplete(const SamplerState &samplerState, const Data &data) const;
virtual void bindTexImage(egl::Surface *surface); virtual void bindTexImage(egl::Surface *surface);
virtual void releaseTexImage(); virtual void releaseTexImage();
virtual Error generateMipmaps();
private: private:
DISALLOW_COPY_AND_ASSIGN(Texture2D); DISALLOW_COPY_AND_ASSIGN(Texture2D);
...@@ -153,13 +172,6 @@ class TextureCubeMap : public Texture ...@@ -153,13 +172,6 @@ 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;
Error setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
Error setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, 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);
Error subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels);
Error copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
Error storage(GLsizei levels, GLenum internalformat, GLsizei size);
virtual bool isSamplerComplete(const SamplerState &samplerState, const Data &data) const; virtual bool isSamplerComplete(const SamplerState &samplerState, const Data &data) const;
bool isCubeComplete() const; bool isCubeComplete() const;
...@@ -188,12 +200,6 @@ class Texture3D : public Texture ...@@ -188,12 +200,6 @@ class Texture3D : public Texture
bool isCompressed(GLint level) const; bool isCompressed(GLint level) const;
bool isDepth(GLint level) const; bool isDepth(GLint level) const;
Error setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
Error setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, 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);
Error subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels);
Error storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
virtual bool isSamplerComplete(const SamplerState &samplerState, const Data &data) const; virtual bool isSamplerComplete(const SamplerState &samplerState, const Data &data) const;
private: private:
...@@ -217,12 +223,6 @@ class Texture2DArray : public Texture ...@@ -217,12 +223,6 @@ class Texture2DArray : public Texture
bool isCompressed(GLint level) const; bool isCompressed(GLint level) const;
bool isDepth(GLint level) const; bool isDepth(GLint level) const;
Error setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels);
Error setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, 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);
Error subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels);
Error storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
virtual bool isSamplerComplete(const SamplerState &samplerState, const Data &data) const; virtual bool isSamplerComplete(const SamplerState &samplerState, const Data &data) const;
private: private:
......
...@@ -57,19 +57,14 @@ struct Rectangle ...@@ -57,19 +57,14 @@ struct Rectangle
bool ClipRectangle(const Rectangle &source, const Rectangle &clip, Rectangle *intersection); bool ClipRectangle(const Rectangle &source, const Rectangle &clip, Rectangle *intersection);
struct Box struct Offset
{ {
int x; int x;
int y; int y;
int z; int z;
int width;
int height;
int depth;
Box() : x(0), y(0), z(0), width(0), height(0), depth(0) { } Offset() : x(0), y(0), z(0) { }
Box(int x_in, int y_in, int z_in, int width_in, int height_in, int depth_in) : x(x_in), y(y_in), z(z_in), width(width_in), height(height_in), depth(depth_in) { } Offset(int x_in, int y_in, int z_in) : x(x_in), y(y_in), z(z_in) { }
bool operator==(const Box &other) const;
bool operator!=(const Box &other) const;
}; };
struct Extents struct Extents
...@@ -82,6 +77,23 @@ struct Extents ...@@ -82,6 +77,23 @@ struct Extents
Extents(int width_, int height_, int depth_) : width(width_), height(height_), depth(depth_) { } Extents(int width_, int height_, int depth_) : width(width_), height(height_), depth(depth_) { }
}; };
struct Box
{
int x;
int y;
int z;
int width;
int height;
int depth;
Box() : x(0), y(0), z(0), width(0), height(0), depth(0) { }
Box(int x_in, int y_in, int z_in, int width_in, int height_in, int depth_in) : x(x_in), y(y_in), z(z_in), width(width_in), height(height_in), depth(depth_in) { }
Box(const Offset &offset, const Extents &size) : x(offset.x), y(offset.y), z(offset.z), width(size.width), height(size.height), depth(size.depth) { }
bool operator==(const Box &other) const;
bool operator!=(const Box &other) const;
};
struct RasterizerState struct RasterizerState
{ {
bool cullFace; bool cullFace;
......
...@@ -20,6 +20,9 @@ namespace gl ...@@ -20,6 +20,9 @@ namespace gl
{ {
class Framebuffer; class Framebuffer;
struct Rectangle; struct Rectangle;
struct Extents;
struct Box;
struct Offset;
struct ImageIndex; struct ImageIndex;
} }
...@@ -46,15 +49,13 @@ class Image ...@@ -46,15 +49,13 @@ class Image
void markClean() {mDirty = false;} void markClean() {mDirty = false;}
virtual bool isDirty() const = 0; virtual bool isDirty() const = 0;
virtual bool redefine(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease) = 0; virtual bool redefine(GLenum target, GLenum internalformat, const gl::Extents &size, bool forceRelease) = 0;
virtual gl::Error loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, virtual gl::Error loadData(const gl::Box &area, GLint unpackAlignment, GLenum type, const void *input) = 0;
GLint unpackAlignment, GLenum type, const void *input) = 0; virtual gl::Error loadCompressedData(const gl::Box &area, const void *input) = 0;
virtual gl::Error loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
const void *input) = 0;
virtual gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, gl::Framebuffer *source) = 0; virtual gl::Error copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea, const gl::Framebuffer *source) = 0;
virtual gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, virtual gl::Error copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea,
const gl::ImageIndex &sourceIndex, TextureStorage *source) = 0; const gl::ImageIndex &sourceIndex, TextureStorage *source) = 0;
protected: protected:
......
...@@ -9,12 +9,14 @@ ...@@ -9,12 +9,14 @@
#ifndef LIBANGLE_RENDERER_TEXTUREIMPL_H_ #ifndef LIBANGLE_RENDERER_TEXTUREIMPL_H_
#define LIBANGLE_RENDERER_TEXTUREIMPL_H_ #define LIBANGLE_RENDERER_TEXTUREIMPL_H_
#include "common/angleutils.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/ImageIndex.h"
#include "common/angleutils.h"
#include "angle_gl.h" #include "angle_gl.h"
#include "libANGLE/ImageIndex.h" #include <stdint.h>
namespace egl namespace egl
{ {
...@@ -23,6 +25,10 @@ class Surface; ...@@ -23,6 +25,10 @@ class Surface;
namespace gl namespace gl
{ {
struct Box;
struct Extents;
struct Offset;
struct Rectangle;
class Framebuffer; class Framebuffer;
struct PixelUnpackState; struct PixelUnpackState;
struct SamplerState; struct SamplerState;
...@@ -45,13 +51,22 @@ class TextureImpl ...@@ -45,13 +51,22 @@ class TextureImpl
virtual void setUsage(GLenum usage) = 0; virtual void setUsage(GLenum usage) = 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 gl::Error setImage(GLenum target, size_t level, GLenum internalFormat, const gl::Extents &size, GLenum format, GLenum type,
virtual gl::Error setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels) = 0; const gl::PixelUnpackState &unpack, const uint8_t *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 gl::Error setSubImage(GLenum target, size_t level, const gl::Box &area, GLenum format, GLenum type,
virtual gl::Error subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const gl::PixelUnpackState &unpack, const void *pixels) = 0; const gl::PixelUnpackState &unpack, const uint8_t *pixels) = 0;
virtual gl::Error copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source) = 0;
virtual gl::Error copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source) = 0; virtual gl::Error setCompressedImage(GLenum target, size_t level, GLenum internalFormat, const gl::Extents &size,
virtual gl::Error storage(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) = 0; const gl::PixelUnpackState &unpack, const uint8_t *pixels) = 0;
virtual gl::Error setCompressedSubImage(GLenum target, size_t level, const gl::Box &area, GLenum format,
const gl::PixelUnpackState &unpack, const uint8_t *pixels) = 0;
virtual gl::Error copyImage(GLenum target, size_t level, const gl::Rectangle &sourceArea, GLenum internalFormat,
const gl::Framebuffer *source) = 0;
virtual gl::Error copySubImage(GLenum target, size_t level, const gl::Offset &destOffset, const gl::Rectangle &sourceArea,
const gl::Framebuffer *source) = 0;
virtual gl::Error setStorage(GLenum target, size_t levels, GLenum internalFormat, const gl::Extents &size) = 0;
virtual gl::Error generateMipmaps() = 0; virtual gl::Error generateMipmaps() = 0;
......
...@@ -27,7 +27,7 @@ ImageD3D *ImageD3D::makeImageD3D(Image *img) ...@@ -27,7 +27,7 @@ ImageD3D *ImageD3D::makeImageD3D(Image *img)
return static_cast<ImageD3D*>(img); return static_cast<ImageD3D*>(img);
} }
gl::Error ImageD3D::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &area, gl::Framebuffer *source) gl::Error ImageD3D::copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea, const gl::Framebuffer *source)
{ {
gl::FramebufferAttachment *colorbuffer = source->getReadColorbuffer(); gl::FramebufferAttachment *colorbuffer = source->getReadColorbuffer();
ASSERT(colorbuffer); ASSERT(colorbuffer);
...@@ -40,7 +40,7 @@ gl::Error ImageD3D::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl:: ...@@ -40,7 +40,7 @@ gl::Error ImageD3D::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::
} }
ASSERT(renderTarget); ASSERT(renderTarget);
return copy(xoffset, yoffset, zoffset, area, renderTarget); return copy(destOffset, sourceArea, renderTarget);
} }
} }
...@@ -41,12 +41,12 @@ class ImageD3D : public Image ...@@ -41,12 +41,12 @@ class ImageD3D : public Image
virtual gl::Error setManagedSurface2DArray(TextureStorage *storage, int layer, int level) { return gl::Error(GL_NO_ERROR); }; virtual gl::Error setManagedSurface2DArray(TextureStorage *storage, int layer, int level) { return gl::Error(GL_NO_ERROR); };
virtual gl::Error copyToStorage(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region) = 0; virtual gl::Error copyToStorage(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region) = 0;
gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, gl::Framebuffer *source) override; gl::Error copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea, const gl::Framebuffer *source) override;
private: private:
DISALLOW_COPY_AND_ASSIGN(ImageD3D); DISALLOW_COPY_AND_ASSIGN(ImageD3D);
virtual gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, RenderTarget *source) = 0; virtual gl::Error copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea, RenderTarget *source) = 0;
}; };
} }
......
...@@ -579,55 +579,29 @@ gl::Texture *RendererD3D::getIncompleteTexture(GLenum type) ...@@ -579,55 +579,29 @@ gl::Texture *RendererD3D::getIncompleteTexture(GLenum type)
if (mIncompleteTextures.find(type) == mIncompleteTextures.end()) if (mIncompleteTextures.find(type) == mIncompleteTextures.end())
{ {
const GLubyte color[] = { 0, 0, 0, 255 }; const GLubyte color[] = { 0, 0, 0, 255 };
const gl::Extents colorSize(1, 1, 1);
const gl::PixelUnpackState incompleteUnpackState(1); const gl::PixelUnpackState incompleteUnpackState(1);
gl::Texture* t = NULL; gl::Texture* t = NULL;
switch (type) switch (type)
{ {
default: default: UNREACHABLE(); // default falls through to TEXTURE_2D
UNREACHABLE(); case GL_TEXTURE_2D: t = new gl::Texture2D(createTexture(type), gl::Texture::INCOMPLETE_TEXTURE_ID); break;
// default falls through to TEXTURE_2D case GL_TEXTURE_CUBE_MAP: t = new gl::TextureCubeMap(createTexture(type), gl::Texture::INCOMPLETE_TEXTURE_ID); break;
case GL_TEXTURE_3D: t = new gl::Texture3D(createTexture(type), gl::Texture::INCOMPLETE_TEXTURE_ID); break;
case GL_TEXTURE_2D: case GL_TEXTURE_2D_ARRAY: t = new gl::Texture2DArray(createTexture(type), gl::Texture::INCOMPLETE_TEXTURE_ID); break;
{ }
gl::Texture2D *incomplete2d = new gl::Texture2D(createTexture(GL_TEXTURE_2D), gl::Texture::INCOMPLETE_TEXTURE_ID);
incomplete2d->setImage(0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
t = incomplete2d;
}
break;
case GL_TEXTURE_CUBE_MAP:
{
gl::TextureCubeMap *incompleteCube = new gl::TextureCubeMap(createTexture(GL_TEXTURE_CUBE_MAP), gl::Texture::INCOMPLETE_TEXTURE_ID);
incompleteCube->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
incompleteCube->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
incompleteCube->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
incompleteCube->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
incompleteCube->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
incompleteCube->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
t = incompleteCube;
}
break;
case GL_TEXTURE_3D:
{
gl::Texture3D *incomplete3d = new gl::Texture3D(createTexture(GL_TEXTURE_3D), gl::Texture::INCOMPLETE_TEXTURE_ID);
incomplete3d->setImage(0, 1, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
t = incomplete3d;
}
break;
case GL_TEXTURE_2D_ARRAY: if (type == GL_TEXTURE_CUBE_MAP)
{
for (GLenum face = GL_TEXTURE_CUBE_MAP_POSITIVE_X; face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; face++)
{ {
gl::Texture2DArray *incomplete2darray = new gl::Texture2DArray(createTexture(GL_TEXTURE_2D_ARRAY), gl::Texture::INCOMPLETE_TEXTURE_ID); t->setImage(face, 0, GL_RGBA, colorSize, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
incomplete2darray->setImage(0, 1, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
t = incomplete2darray;
} }
break; }
else
{
t->setImage(type, 0, GL_RGBA, colorSize, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
} }
mIncompleteTextures[type].set(t); mIncompleteTextures[type].set(t);
......
...@@ -107,14 +107,14 @@ class RendererD3D : public Renderer ...@@ -107,14 +107,14 @@ class RendererD3D : public Renderer
virtual bool getPostSubBufferSupport() const = 0; virtual bool getPostSubBufferSupport() const = 0;
// Pixel operations // Pixel operations
virtual gl::Error copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, virtual gl::Error copyImage2D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level) = 0; const gl::Offset &destOffset, TextureStorage *storage, GLint level) = 0;
virtual gl::Error copyImageCube(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, virtual gl::Error copyImageCube(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level) = 0; const gl::Offset &destOffset, TextureStorage *storage, GLenum target, GLint level) = 0;
virtual gl::Error copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, virtual gl::Error copyImage3D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level) = 0; const gl::Offset &destOffset, TextureStorage *storage, GLint level) = 0;
virtual gl::Error copyImage2DArray(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, virtual gl::Error copyImage2DArray(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level) = 0; const gl::Offset &destOffset, TextureStorage *storage, GLint level) = 0;
// RenderTarget creation // RenderTarget creation
virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTarget **outRT) = 0; virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTarget **outRT) = 0;
......
...@@ -202,10 +202,10 @@ void Image11::disassociateStorage() ...@@ -202,10 +202,10 @@ void Image11::disassociateStorage()
} }
} }
bool Image11::redefine(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease) bool Image11::redefine(GLenum target, GLenum internalformat, const gl::Extents &size, bool forceRelease)
{ {
if (mWidth != width || if (mWidth != size.width ||
mHeight != height || mHeight != size.height ||
mInternalFormat != internalformat || mInternalFormat != internalformat ||
forceRelease) forceRelease)
{ {
...@@ -214,9 +214,9 @@ bool Image11::redefine(GLenum target, GLenum internalformat, GLsizei width, GLsi ...@@ -214,9 +214,9 @@ bool Image11::redefine(GLenum target, GLenum internalformat, GLsizei width, GLsi
disassociateStorage(); disassociateStorage();
mRecoveredFromStorageCount = 0; mRecoveredFromStorageCount = 0;
mWidth = width; mWidth = size.width;
mHeight = height; mHeight = size.height;
mDepth = depth; mDepth = size.depth;
mInternalFormat = internalformat; mInternalFormat = internalformat;
mTarget = target; mTarget = target;
...@@ -245,12 +245,11 @@ DXGI_FORMAT Image11::getDXGIFormat() const ...@@ -245,12 +245,11 @@ 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.
gl::Error Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, gl::Error Image11::loadData(const gl::Box &area, 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, area.width, unpackAlignment);
GLsizei inputDepthPitch = formatInfo.computeDepthPitch(type, width, height, unpackAlignment); GLsizei inputDepthPitch = formatInfo.computeDepthPitch(type, area.width, area.height, unpackAlignment);
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mDXGIFormat); const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mDXGIFormat);
GLuint outputPixelSize = dxgiFormatInfo.pixelBytes; GLuint outputPixelSize = dxgiFormatInfo.pixelBytes;
...@@ -265,8 +264,8 @@ gl::Error Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei ...@@ -265,8 +264,8 @@ gl::Error Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei
return error; return error;
} }
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) + (area.y * mappedImage.RowPitch + area.x * outputPixelSize + area.z * mappedImage.DepthPitch));
loadFunction(width, height, depth, loadFunction(area.width, area.height, area.depth,
reinterpret_cast<const uint8_t*>(input), inputRowPitch, inputDepthPitch, reinterpret_cast<const uint8_t*>(input), inputRowPitch, inputDepthPitch,
offsetMappedData, mappedImage.RowPitch, mappedImage.DepthPitch); offsetMappedData, mappedImage.RowPitch, mappedImage.DepthPitch);
...@@ -275,20 +274,19 @@ gl::Error Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei ...@@ -275,20 +274,19 @@ gl::Error Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
gl::Error Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, gl::Error Image11::loadCompressedData(const gl::Box &area, const void *input)
const void *input)
{ {
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat); const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat);
GLsizei inputRowPitch = formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, width, 1); GLsizei inputRowPitch = formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, area.width, 1);
GLsizei inputDepthPitch = formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, width, height, 1); GLsizei inputDepthPitch = formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, area.width, area.height, 1);
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mDXGIFormat); const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mDXGIFormat);
GLuint outputPixelSize = dxgiFormatInfo.pixelBytes; GLuint outputPixelSize = dxgiFormatInfo.pixelBytes;
GLuint outputBlockWidth = dxgiFormatInfo.blockWidth; GLuint outputBlockWidth = dxgiFormatInfo.blockWidth;
GLuint outputBlockHeight = dxgiFormatInfo.blockHeight; GLuint outputBlockHeight = dxgiFormatInfo.blockHeight;
ASSERT(xoffset % outputBlockWidth == 0); ASSERT(area.x % outputBlockWidth == 0);
ASSERT(yoffset % outputBlockHeight == 0); ASSERT(area.y % outputBlockHeight == 0);
const d3d11::TextureFormat &d3dFormatInfo = d3d11::GetTextureFormatInfo(mInternalFormat, mFeatureLevel); const d3d11::TextureFormat &d3dFormatInfo = d3d11::GetTextureFormatInfo(mInternalFormat, mFeatureLevel);
LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions.at(GL_UNSIGNED_BYTE); LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions.at(GL_UNSIGNED_BYTE);
...@@ -300,11 +298,11 @@ gl::Error Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffse ...@@ -300,11 +298,11 @@ gl::Error Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffse
return error; return error;
} }
uint8_t* offsetMappedData = reinterpret_cast<uint8_t*>(mappedImage.pData) + ((yoffset / outputBlockHeight) * mappedImage.RowPitch + uint8_t* offsetMappedData = reinterpret_cast<uint8_t*>(mappedImage.pData) + ((area.y / outputBlockHeight) * mappedImage.RowPitch +
(xoffset / outputBlockWidth) * outputPixelSize + (area.x / outputBlockWidth) * outputPixelSize +
zoffset * mappedImage.DepthPitch); area.z * mappedImage.DepthPitch);
loadFunction(width, height, depth, loadFunction(area.width, area.height, area.depth,
reinterpret_cast<const uint8_t*>(input), inputRowPitch, inputDepthPitch, reinterpret_cast<const uint8_t*>(input), inputRowPitch, inputDepthPitch,
offsetMappedData, mappedImage.RowPitch, mappedImage.DepthPitch); offsetMappedData, mappedImage.RowPitch, mappedImage.DepthPitch);
...@@ -313,7 +311,7 @@ gl::Error Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffse ...@@ -313,7 +311,7 @@ gl::Error Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffse
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
gl::Error Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, RenderTarget *source) gl::Error Image11::copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea, RenderTarget *source)
{ {
RenderTarget11 *sourceRenderTarget = RenderTarget11::makeRenderTarget11(source); RenderTarget11 *sourceRenderTarget = RenderTarget11::makeRenderTarget11(source);
ASSERT(sourceRenderTarget->getTexture()); ASSERT(sourceRenderTarget->getTexture());
...@@ -326,14 +324,14 @@ gl::Error Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::R ...@@ -326,14 +324,14 @@ gl::Error Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::R
return gl::Error(GL_OUT_OF_MEMORY, "Failed to retrieve the ID3D11Texture2D from the source RenderTarget."); return gl::Error(GL_OUT_OF_MEMORY, "Failed to retrieve the ID3D11Texture2D from the source RenderTarget.");
} }
gl::Error error = copy(xoffset, yoffset, zoffset, sourceArea, sourceTexture2D, subresourceIndex); gl::Error error = copy(destOffset, sourceArea, sourceTexture2D, subresourceIndex);
SafeRelease(sourceTexture2D); SafeRelease(sourceTexture2D);
return error; return error;
} }
gl::Error Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, const gl::ImageIndex &sourceIndex, TextureStorage *source) gl::Error Image11::copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea, const gl::ImageIndex &sourceIndex, TextureStorage *source)
{ {
TextureStorage11 *sourceStorage11 = TextureStorage11::makeTextureStorage11(source); TextureStorage11 *sourceStorage11 = TextureStorage11::makeTextureStorage11(source);
...@@ -352,14 +350,14 @@ gl::Error Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::R ...@@ -352,14 +350,14 @@ gl::Error Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::R
return gl::Error(GL_OUT_OF_MEMORY, "Failed to retrieve the ID3D11Texture2D from the source TextureStorage."); return gl::Error(GL_OUT_OF_MEMORY, "Failed to retrieve the ID3D11Texture2D from the source TextureStorage.");
} }
error = copy(xoffset, yoffset, zoffset, sourceArea, sourceTexture2D, subresourceIndex); error = copy(destOffset, sourceArea, sourceTexture2D, subresourceIndex);
SafeRelease(sourceTexture2D); SafeRelease(sourceTexture2D);
return error; return error;
} }
gl::Error Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, ID3D11Texture2D *source, UINT sourceSubResource) gl::Error Image11::copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea, ID3D11Texture2D *source, UINT sourceSubResource)
{ {
D3D11_TEXTURE2D_DESC textureDesc; D3D11_TEXTURE2D_DESC textureDesc;
source->GetDesc(&textureDesc); source->GetDesc(&textureDesc);
...@@ -418,7 +416,8 @@ gl::Error Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::R ...@@ -418,7 +416,8 @@ gl::Error Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::R
srcBox.front = 0; srcBox.front = 0;
srcBox.back = 1; srcBox.back = 1;
deviceContext->CopySubresourceRegion(stagingTexture, stagingSubresourceIndex, xoffset, yoffset, zoffset, srcTex, subresourceAfterResolve, &srcBox); deviceContext->CopySubresourceRegion(stagingTexture, stagingSubresourceIndex, destOffset.x, destOffset.y,
destOffset.z, srcTex, subresourceAfterResolve, &srcBox);
if (textureDesc.SampleDesc.Count > 1) if (textureDesc.SampleDesc.Count > 1)
{ {
...@@ -437,8 +436,8 @@ gl::Error Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::R ...@@ -437,8 +436,8 @@ gl::Error Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::R
// determine the offset coordinate into the destination buffer // determine the offset coordinate into the destination buffer
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mDXGIFormat); const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mDXGIFormat);
GLsizei rowOffset = dxgiFormatInfo.pixelBytes * xoffset; GLsizei rowOffset = dxgiFormatInfo.pixelBytes * destOffset.x;
uint8_t *dataOffset = static_cast<uint8_t*>(mappedImage.pData) + mappedImage.RowPitch * yoffset + rowOffset + zoffset * mappedImage.DepthPitch; uint8_t *dataOffset = static_cast<uint8_t*>(mappedImage.pData) + mappedImage.RowPitch * destOffset.y + rowOffset + destOffset.z * mappedImage.DepthPitch;
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat); const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat);
......
...@@ -39,17 +39,15 @@ class Image11 : public ImageD3D ...@@ -39,17 +39,15 @@ class Image11 : public ImageD3D
virtual gl::Error copyToStorage(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region); virtual gl::Error copyToStorage(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region);
bool redefine(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease) override; bool redefine(GLenum target, GLenum internalformat, const gl::Extents &size, bool forceRelease) override;
DXGI_FORMAT getDXGIFormat() const; DXGI_FORMAT getDXGIFormat() const;
virtual gl::Error loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, virtual gl::Error loadData(const gl::Box &area, GLint unpackAlignment, GLenum type, const void *input);
GLint unpackAlignment, GLenum type, const void *input); virtual gl::Error loadCompressedData(const gl::Box &area, const void *input);
virtual gl::Error loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
const void *input);
virtual gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, RenderTarget *source); virtual gl::Error copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea, RenderTarget *source);
virtual gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, virtual gl::Error copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea,
const gl::ImageIndex &sourceIndex, TextureStorage *source); const gl::ImageIndex &sourceIndex, TextureStorage *source);
gl::Error recoverFromAssociatedStorage(); gl::Error recoverFromAssociatedStorage();
...@@ -64,7 +62,7 @@ class Image11 : public ImageD3D ...@@ -64,7 +62,7 @@ class Image11 : public ImageD3D
DISALLOW_COPY_AND_ASSIGN(Image11); DISALLOW_COPY_AND_ASSIGN(Image11);
gl::Error copyToStorageImpl(TextureStorage11 *storage11, const gl::ImageIndex &index, const gl::Box &region); gl::Error copyToStorageImpl(TextureStorage11 *storage11, const gl::ImageIndex &index, const gl::Box &region);
gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, ID3D11Texture2D *source, UINT sourceSubResource); gl::Error copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea, ID3D11Texture2D *source, UINT sourceSubResource);
gl::Error getStagingTexture(ID3D11Resource **outStagingTexture, unsigned int *outSubresourceIndex); gl::Error getStagingTexture(ID3D11Resource **outStagingTexture, unsigned int *outSubresourceIndex);
gl::Error createStagingTexture(); gl::Error createStagingTexture();
......
...@@ -2102,8 +2102,8 @@ int Renderer11::getMaxSwapInterval() const ...@@ -2102,8 +2102,8 @@ int Renderer11::getMaxSwapInterval() const
return 4; return 4;
} }
gl::Error Renderer11::copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, gl::Error Renderer11::copyImage2D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level) const gl::Offset &destOffset, TextureStorage *storage, GLint level)
{ {
gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer(); gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer();
ASSERT(colorbuffer); ASSERT(colorbuffer);
...@@ -2137,7 +2137,7 @@ gl::Error Renderer11::copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectan ...@@ -2137,7 +2137,7 @@ gl::Error Renderer11::copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectan
gl::Box sourceArea(sourceRect.x, sourceRect.y, 0, sourceRect.width, sourceRect.height, 1); gl::Box sourceArea(sourceRect.x, sourceRect.y, 0, sourceRect.width, sourceRect.height, 1);
gl::Extents sourceSize(sourceRenderTarget->getWidth(), sourceRenderTarget->getHeight(), 1); gl::Extents sourceSize(sourceRenderTarget->getWidth(), sourceRenderTarget->getHeight(), 1);
gl::Box destArea(xoffset, yoffset, 0, sourceRect.width, sourceRect.height, 1); gl::Box destArea(destOffset.x, destOffset.y, 0, sourceRect.width, sourceRect.height, 1);
gl::Extents destSize(destRenderTarget->getWidth(), destRenderTarget->getHeight(), 1); gl::Extents destSize(destRenderTarget->getWidth(), destRenderTarget->getHeight(), 1);
// Use nearest filtering because source and destination are the same size for the direct // Use nearest filtering because source and destination are the same size for the direct
...@@ -2153,8 +2153,8 @@ gl::Error Renderer11::copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectan ...@@ -2153,8 +2153,8 @@ gl::Error Renderer11::copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectan
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
gl::Error Renderer11::copyImageCube(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, gl::Error Renderer11::copyImageCube(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level) const gl::Offset &destOffset, TextureStorage *storage, GLenum target, GLint level)
{ {
gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer(); gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer();
ASSERT(colorbuffer); ASSERT(colorbuffer);
...@@ -2188,7 +2188,7 @@ gl::Error Renderer11::copyImageCube(gl::Framebuffer *framebuffer, const gl::Rect ...@@ -2188,7 +2188,7 @@ gl::Error Renderer11::copyImageCube(gl::Framebuffer *framebuffer, const gl::Rect
gl::Box sourceArea(sourceRect.x, sourceRect.y, 0, sourceRect.width, sourceRect.height, 1); gl::Box sourceArea(sourceRect.x, sourceRect.y, 0, sourceRect.width, sourceRect.height, 1);
gl::Extents sourceSize(sourceRenderTarget->getWidth(), sourceRenderTarget->getHeight(), 1); gl::Extents sourceSize(sourceRenderTarget->getWidth(), sourceRenderTarget->getHeight(), 1);
gl::Box destArea(xoffset, yoffset, 0, sourceRect.width, sourceRect.height, 1); gl::Box destArea(destOffset.x, destOffset.y, 0, sourceRect.width, sourceRect.height, 1);
gl::Extents destSize(destRenderTarget->getWidth(), destRenderTarget->getHeight(), 1); gl::Extents destSize(destRenderTarget->getWidth(), destRenderTarget->getHeight(), 1);
// Use nearest filtering because source and destination are the same size for the direct // Use nearest filtering because source and destination are the same size for the direct
...@@ -2204,8 +2204,8 @@ gl::Error Renderer11::copyImageCube(gl::Framebuffer *framebuffer, const gl::Rect ...@@ -2204,8 +2204,8 @@ gl::Error Renderer11::copyImageCube(gl::Framebuffer *framebuffer, const gl::Rect
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
gl::Error Renderer11::copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, gl::Error Renderer11::copyImage3D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level) const gl::Offset &destOffset, TextureStorage *storage, GLint level)
{ {
gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer(); gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer();
ASSERT(colorbuffer); ASSERT(colorbuffer);
...@@ -2224,7 +2224,7 @@ gl::Error Renderer11::copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectan ...@@ -2224,7 +2224,7 @@ gl::Error Renderer11::copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectan
TextureStorage11_3D *storage11 = TextureStorage11_3D::makeTextureStorage11_3D(storage); TextureStorage11_3D *storage11 = TextureStorage11_3D::makeTextureStorage11_3D(storage);
ASSERT(storage11); ASSERT(storage11);
gl::ImageIndex index = gl::ImageIndex::Make3D(level, zOffset); gl::ImageIndex index = gl::ImageIndex::Make3D(level, destOffset.z);
RenderTarget *destRenderTarget = NULL; RenderTarget *destRenderTarget = NULL;
error = storage11->getRenderTarget(index, &destRenderTarget); error = storage11->getRenderTarget(index, &destRenderTarget);
if (error.isError()) if (error.isError())
...@@ -2239,7 +2239,7 @@ gl::Error Renderer11::copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectan ...@@ -2239,7 +2239,7 @@ gl::Error Renderer11::copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectan
gl::Box sourceArea(sourceRect.x, sourceRect.y, 0, sourceRect.width, sourceRect.height, 1); gl::Box sourceArea(sourceRect.x, sourceRect.y, 0, sourceRect.width, sourceRect.height, 1);
gl::Extents sourceSize(sourceRenderTarget->getWidth(), sourceRenderTarget->getHeight(), 1); gl::Extents sourceSize(sourceRenderTarget->getWidth(), sourceRenderTarget->getHeight(), 1);
gl::Box destArea(xoffset, yoffset, 0, sourceRect.width, sourceRect.height, 1); gl::Box destArea(destOffset.x, destOffset.y, 0, sourceRect.width, sourceRect.height, 1);
gl::Extents destSize(destRenderTarget->getWidth(), destRenderTarget->getHeight(), 1); gl::Extents destSize(destRenderTarget->getWidth(), destRenderTarget->getHeight(), 1);
// Use nearest filtering because source and destination are the same size for the direct // Use nearest filtering because source and destination are the same size for the direct
...@@ -2255,8 +2255,8 @@ gl::Error Renderer11::copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectan ...@@ -2255,8 +2255,8 @@ gl::Error Renderer11::copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectan
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
gl::Error Renderer11::copyImage2DArray(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, gl::Error Renderer11::copyImage2DArray(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level) const gl::Offset &destOffset, TextureStorage *storage, GLint level)
{ {
gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer(); gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer();
ASSERT(colorbuffer); ASSERT(colorbuffer);
...@@ -2275,7 +2275,7 @@ gl::Error Renderer11::copyImage2DArray(gl::Framebuffer *framebuffer, const gl::R ...@@ -2275,7 +2275,7 @@ gl::Error Renderer11::copyImage2DArray(gl::Framebuffer *framebuffer, const gl::R
TextureStorage11_2DArray *storage11 = TextureStorage11_2DArray::makeTextureStorage11_2DArray(storage); TextureStorage11_2DArray *storage11 = TextureStorage11_2DArray::makeTextureStorage11_2DArray(storage);
ASSERT(storage11); ASSERT(storage11);
gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, zOffset); gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, destOffset.z);
RenderTarget *destRenderTarget = NULL; RenderTarget *destRenderTarget = NULL;
error = storage11->getRenderTarget(index, &destRenderTarget); error = storage11->getRenderTarget(index, &destRenderTarget);
if (error.isError()) if (error.isError())
...@@ -2290,7 +2290,7 @@ gl::Error Renderer11::copyImage2DArray(gl::Framebuffer *framebuffer, const gl::R ...@@ -2290,7 +2290,7 @@ gl::Error Renderer11::copyImage2DArray(gl::Framebuffer *framebuffer, const gl::R
gl::Box sourceArea(sourceRect.x, sourceRect.y, 0, sourceRect.width, sourceRect.height, 1); gl::Box sourceArea(sourceRect.x, sourceRect.y, 0, sourceRect.width, sourceRect.height, 1);
gl::Extents sourceSize(sourceRenderTarget->getWidth(), sourceRenderTarget->getHeight(), 1); gl::Extents sourceSize(sourceRenderTarget->getWidth(), sourceRenderTarget->getHeight(), 1);
gl::Box destArea(xoffset, yoffset, 0, sourceRect.width, sourceRect.height, 1); gl::Box destArea(destOffset.x, destOffset.y, 0, sourceRect.width, sourceRect.height, 1);
gl::Extents destSize(destRenderTarget->getWidth(), destRenderTarget->getHeight(), 1); gl::Extents destSize(destRenderTarget->getWidth(), destRenderTarget->getHeight(), 1);
// Use nearest filtering because source and destination are the same size for the direct // Use nearest filtering because source and destination are the same size for the direct
......
...@@ -118,14 +118,14 @@ class Renderer11 : public RendererD3D ...@@ -118,14 +118,14 @@ class Renderer11 : public RendererD3D
virtual int getMaxSwapInterval() const; virtual int getMaxSwapInterval() const;
// Pixel operations // Pixel operations
virtual gl::Error copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, virtual gl::Error copyImage2D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level); const gl::Offset &destOffset, TextureStorage *storage, GLint level);
virtual gl::Error copyImageCube(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, virtual gl::Error copyImageCube(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level); const gl::Offset &destOffset, TextureStorage *storage, GLenum target, GLint level);
virtual gl::Error copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, virtual gl::Error copyImage3D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level); const gl::Offset &destOffset, TextureStorage *storage, GLint level);
virtual gl::Error copyImage2DArray(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, virtual gl::Error copyImage2DArray(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level); const gl::Offset &destOffset, TextureStorage *storage, GLint level);
// RenderTarget creation // RenderTarget creation
virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTarget **outRT); virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTarget **outRT);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "libANGLE/renderer/d3d/d3d9/TextureStorage9.h" #include "libANGLE/renderer/d3d/d3d9/TextureStorage9.h"
#include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h" #include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h"
#include "libANGLE/renderer/d3d/d3d9/Renderer9.h" #include "libANGLE/renderer/d3d/d3d9/Renderer9.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
...@@ -216,7 +217,7 @@ gl::Error Blit9::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest) ...@@ -216,7 +217,7 @@ gl::Error Blit9::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest)
device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
setViewport(getSurfaceRect(dest), 0, 0); setViewport(getSurfaceRect(dest), gl::Offset(0, 0, 0));
render(); render();
...@@ -227,7 +228,7 @@ gl::Error Blit9::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest) ...@@ -227,7 +228,7 @@ gl::Error Blit9::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest)
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
gl::Error Blit9::copy2D(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level) gl::Error Blit9::copy2D(const gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, const gl::Offset &destOffset, TextureStorage *storage, GLint level)
{ {
gl::Error error = initialize(); gl::Error error = initialize();
if (error.isError()) if (error.isError())
...@@ -258,7 +259,7 @@ gl::Error Blit9::copy2D(gl::Framebuffer *framebuffer, const RECT &sourceRect, GL ...@@ -258,7 +259,7 @@ gl::Error Blit9::copy2D(gl::Framebuffer *framebuffer, const RECT &sourceRect, GL
} }
ASSERT(destSurface); ASSERT(destSurface);
gl::Error result = copy(source, sourceRect, destFormat, xoffset, yoffset, destSurface); gl::Error result = copy(source, sourceRect, destFormat, destOffset, destSurface);
SafeRelease(destSurface); SafeRelease(destSurface);
SafeRelease(source); SafeRelease(source);
...@@ -266,7 +267,7 @@ gl::Error Blit9::copy2D(gl::Framebuffer *framebuffer, const RECT &sourceRect, GL ...@@ -266,7 +267,7 @@ gl::Error Blit9::copy2D(gl::Framebuffer *framebuffer, const RECT &sourceRect, GL
return result; return result;
} }
gl::Error Blit9::copyCube(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level) gl::Error Blit9::copyCube(const gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, const gl::Offset &destOffset, TextureStorage *storage, GLenum target, GLint level)
{ {
gl::Error error = initialize(); gl::Error error = initialize();
if (error.isError()) if (error.isError())
...@@ -297,7 +298,7 @@ gl::Error Blit9::copyCube(gl::Framebuffer *framebuffer, const RECT &sourceRect, ...@@ -297,7 +298,7 @@ gl::Error Blit9::copyCube(gl::Framebuffer *framebuffer, const RECT &sourceRect,
} }
ASSERT(destSurface); ASSERT(destSurface);
gl::Error result = copy(source, sourceRect, destFormat, xoffset, yoffset, destSurface); gl::Error result = copy(source, sourceRect, destFormat, destOffset, destSurface);
SafeRelease(destSurface); SafeRelease(destSurface);
SafeRelease(source); SafeRelease(source);
...@@ -305,7 +306,7 @@ gl::Error Blit9::copyCube(gl::Framebuffer *framebuffer, const RECT &sourceRect, ...@@ -305,7 +306,7 @@ gl::Error Blit9::copyCube(gl::Framebuffer *framebuffer, const RECT &sourceRect,
return result; return result;
} }
gl::Error Blit9::copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, IDirect3DSurface9 *dest) gl::Error Blit9::copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, const gl::Offset &destOffset, IDirect3DSurface9 *dest)
{ {
ASSERT(source != NULL && dest != NULL); ASSERT(source != NULL && dest != NULL);
...@@ -319,7 +320,7 @@ gl::Error Blit9::copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum ...@@ -319,7 +320,7 @@ gl::Error Blit9::copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum
if (sourceDesc.Format == destDesc.Format && destDesc.Usage & D3DUSAGE_RENDERTARGET && if (sourceDesc.Format == destDesc.Format && destDesc.Usage & D3DUSAGE_RENDERTARGET &&
d3d9_gl::IsFormatChannelEquivalent(destDesc.Format, destFormat)) // Can use StretchRect d3d9_gl::IsFormatChannelEquivalent(destDesc.Format, destFormat)) // Can use StretchRect
{ {
RECT destRect = {xoffset, yoffset, xoffset + (sourceRect.right - sourceRect.left), yoffset + (sourceRect.bottom - sourceRect.top)}; RECT destRect = { destOffset.x, destOffset.y, destOffset.x + (sourceRect.right - sourceRect.left), destOffset.y + (sourceRect.bottom - sourceRect.top)};
HRESULT result = device->StretchRect(source, &sourceRect, dest, &destRect, D3DTEXF_POINT); HRESULT result = device->StretchRect(source, &sourceRect, dest, &destRect, D3DTEXF_POINT);
if (FAILED(result)) if (FAILED(result))
...@@ -332,11 +333,11 @@ gl::Error Blit9::copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum ...@@ -332,11 +333,11 @@ gl::Error Blit9::copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum
} }
else else
{ {
return formatConvert(source, sourceRect, destFormat, xoffset, yoffset, dest); return formatConvert(source, sourceRect, destFormat, destOffset, dest);
} }
} }
gl::Error Blit9::formatConvert(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, IDirect3DSurface9 *dest) gl::Error Blit9::formatConvert(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, const gl::Offset &destOffset, IDirect3DSurface9 *dest)
{ {
gl::Error error = initialize(); gl::Error error = initialize();
if (error.isError()) if (error.isError())
...@@ -358,7 +359,7 @@ gl::Error Blit9::formatConvert(IDirect3DSurface9 *source, const RECT &sourceRect ...@@ -358,7 +359,7 @@ gl::Error Blit9::formatConvert(IDirect3DSurface9 *source, const RECT &sourceRect
device->SetTexture(0, texture); device->SetTexture(0, texture);
device->SetRenderTarget(0, dest); device->SetRenderTarget(0, dest);
setViewport(sourceRect, xoffset, yoffset); setViewport(sourceRect, destOffset);
setCommonBlitState(); setCommonBlitState();
...@@ -547,13 +548,13 @@ gl::Error Blit9::copySurfaceToTexture(IDirect3DSurface9 *surface, const RECT &so ...@@ -547,13 +548,13 @@ gl::Error Blit9::copySurfaceToTexture(IDirect3DSurface9 *surface, const RECT &so
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
void Blit9::setViewport(const RECT &sourceRect, GLint xoffset, GLint yoffset) void Blit9::setViewport(const RECT &sourceRect, const gl::Offset &offset)
{ {
IDirect3DDevice9 *device = mRenderer->getDevice(); IDirect3DDevice9 *device = mRenderer->getDevice();
D3DVIEWPORT9 vp; D3DVIEWPORT9 vp;
vp.X = xoffset; vp.X = offset.x;
vp.Y = yoffset; vp.Y = offset.y;
vp.Width = sourceRect.right - sourceRect.left; vp.Width = sourceRect.right - sourceRect.left;
vp.Height = sourceRect.bottom - sourceRect.top; vp.Height = sourceRect.bottom - sourceRect.top;
vp.MinZ = 0.0f; vp.MinZ = 0.0f;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
namespace gl namespace gl
{ {
class Framebuffer; class Framebuffer;
struct Offset;
} }
namespace rx namespace rx
...@@ -34,13 +35,13 @@ class Blit9 ...@@ -34,13 +35,13 @@ class Blit9
// Copy from source surface to dest surface. // Copy from source surface to dest surface.
// sourceRect, xoffset, yoffset are in D3D coordinates (0,0 in upper-left) // sourceRect, xoffset, yoffset are in D3D coordinates (0,0 in upper-left)
gl::Error copy2D(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level); gl::Error copy2D(const gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, const gl::Offset &destOffset, TextureStorage *storage, GLint level);
gl::Error copyCube(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level); gl::Error copyCube(const gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, const gl::Offset &destOffset, TextureStorage *storage, GLenum target, GLint level);
// Copy from source surface to dest surface. // Copy from source surface to dest surface.
// sourceRect, xoffset, yoffset are in D3D coordinates (0,0 in upper-left) // sourceRect, xoffset, yoffset are in D3D coordinates (0,0 in upper-left)
// source is interpreted as RGBA and destFormat specifies the desired result format. For example, if destFormat = GL_RGB, the alpha channel will be forced to 0. // source is interpreted as RGBA and destFormat specifies the desired result format. For example, if destFormat = GL_RGB, the alpha channel will be forced to 0.
gl::Error formatConvert(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, IDirect3DSurface9 *dest); gl::Error formatConvert(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, const gl::Offset &destOffset, IDirect3DSurface9 *dest);
// 2x2 box filter sample from source to dest. // 2x2 box filter sample from source to dest.
// Requires that source is RGB(A) and dest has the same format as source. // Requires that source is RGB(A) and dest has the same format as source.
...@@ -55,9 +56,9 @@ class Blit9 ...@@ -55,9 +56,9 @@ class Blit9
gl::Error setFormatConvertShaders(GLenum destFormat); gl::Error setFormatConvertShaders(GLenum destFormat);
gl::Error copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, IDirect3DSurface9 *dest); gl::Error copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, const gl::Offset &destOffset, IDirect3DSurface9 *dest);
gl::Error copySurfaceToTexture(IDirect3DSurface9 *surface, const RECT &sourceRect, IDirect3DTexture9 **outTexture); gl::Error copySurfaceToTexture(IDirect3DSurface9 *surface, const RECT &sourceRect, IDirect3DTexture9 **outTexture);
void setViewport(const RECT &sourceRect, GLint xoffset, GLint yoffset); void setViewport(const RECT &sourceRect, const gl::Offset &offset);
void setCommonBlitState(); void setCommonBlitState();
RECT getSurfaceRect(IDirect3DSurface9 *surface) const; RECT getSurfaceRect(IDirect3DSurface9 *surface) const;
......
...@@ -169,23 +169,23 @@ gl::Error Image9::copyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface ...@@ -169,23 +169,23 @@ gl::Error Image9::copyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
bool Image9::redefine(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease) bool Image9::redefine(GLenum target, GLenum internalformat, const gl::Extents &size, bool forceRelease)
{ {
// 3D textures are not supported by the D3D9 backend. // 3D textures are not supported by the D3D9 backend.
ASSERT(depth <= 1); ASSERT(size.depth <= 1);
// Only 2D and cube texture are supported by the D3D9 backend. // Only 2D and cube texture are supported by the D3D9 backend.
ASSERT(target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP); ASSERT(target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP);
if (mWidth != width || if (mWidth != size.width ||
mHeight != height || mHeight != size.height ||
mDepth != depth || mDepth != size.depth ||
mInternalFormat != internalformat || mInternalFormat != internalformat ||
forceRelease) forceRelease)
{ {
mWidth = width; mWidth = size.width;
mHeight = height; mHeight = size.height;
mDepth = depth; mDepth = size.depth;
mInternalFormat = internalformat; mInternalFormat = internalformat;
// compute the d3d format that will be used // compute the d3d format that will be used
...@@ -411,14 +411,14 @@ gl::Error Image9::copyToStorage(TextureStorage *storage, const gl::ImageIndex &i ...@@ -411,14 +411,14 @@ gl::Error Image9::copyToStorage(TextureStorage *storage, const gl::ImageIndex &i
} }
} }
error = copyToSurface(destSurface, region.x, region.y, region.width, region.height); error = copyToSurface(destSurface, region);
SafeRelease(destSurface); SafeRelease(destSurface);
return error; return error;
} }
gl::Error Image9::copyToSurface(IDirect3DSurface9 *destSurface, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) gl::Error Image9::copyToSurface(IDirect3DSurface9 *destSurface, const gl::Box &area)
{ {
ASSERT(width > 0 && height > 0); ASSERT(area.width > 0 && area.height > 0 && area.depth == 1);
ASSERT(destSurface); ASSERT(destSurface);
IDirect3DSurface9 *sourceSurface = NULL; IDirect3DSurface9 *sourceSurface = NULL;
...@@ -431,10 +431,10 @@ gl::Error Image9::copyToSurface(IDirect3DSurface9 *destSurface, GLint xoffset, G ...@@ -431,10 +431,10 @@ gl::Error Image9::copyToSurface(IDirect3DSurface9 *destSurface, GLint xoffset, G
ASSERT(sourceSurface && sourceSurface != destSurface); ASSERT(sourceSurface && sourceSurface != destSurface);
RECT rect; RECT rect;
rect.left = xoffset; rect.left = area.x;
rect.top = yoffset; rect.top = area.y;
rect.right = xoffset + width; rect.right = area.x + area.width;
rect.bottom = yoffset + height; rect.bottom = area.y + area.height;
POINT point = {rect.left, rect.top}; POINT point = {rect.left, rect.top};
...@@ -477,22 +477,21 @@ gl::Error Image9::copyToSurface(IDirect3DSurface9 *destSurface, GLint xoffset, G ...@@ -477,22 +477,21 @@ gl::Error Image9::copyToSurface(IDirect3DSurface9 *destSurface, GLint xoffset, G
// 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.
gl::Error Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, gl::Error Image9::loadData(const gl::Box &area, 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(area.z == 0 && area.depth == 1);
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, area.width, unpackAlignment);
const d3d9::TextureFormat &d3dFormatInfo = d3d9::GetTextureFormatInfo(mInternalFormat); const d3d9::TextureFormat &d3dFormatInfo = d3d9::GetTextureFormatInfo(mInternalFormat);
ASSERT(d3dFormatInfo.loadFunction != NULL); ASSERT(d3dFormatInfo.loadFunction != NULL);
RECT lockRect = RECT lockRect =
{ {
xoffset, yoffset, area.x, area.y,
xoffset + width, yoffset + height area.x + area.width, area.y + area.height
}; };
D3DLOCKED_RECT locked; D3DLOCKED_RECT locked;
...@@ -502,7 +501,7 @@ gl::Error Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei ...@@ -502,7 +501,7 @@ gl::Error Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei
return error; return error;
} }
d3dFormatInfo.loadFunction(width, height, depth, d3dFormatInfo.loadFunction(area.width, area.height, area.depth,
reinterpret_cast<const uint8_t*>(input), inputRowPitch, 0, reinterpret_cast<const uint8_t*>(input), inputRowPitch, 0,
reinterpret_cast<uint8_t*>(locked.pBits), locked.Pitch, 0); reinterpret_cast<uint8_t*>(locked.pBits), locked.Pitch, 0);
...@@ -511,27 +510,26 @@ gl::Error Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei ...@@ -511,27 +510,26 @@ gl::Error Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
gl::Error Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, gl::Error Image9::loadCompressedData(const gl::Box &area, const void *input)
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(area.z == 0 && area.depth == 1);
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat); const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat);
GLsizei inputRowPitch = formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, width, 1); GLsizei inputRowPitch = formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, area.width, 1);
GLsizei inputDepthPitch = formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, width, height, 1); GLsizei inputDepthPitch = formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, area.width, area.height, 1);
const d3d9::TextureFormat &d3d9FormatInfo = d3d9::GetTextureFormatInfo(mInternalFormat); const d3d9::TextureFormat &d3d9FormatInfo = d3d9::GetTextureFormatInfo(mInternalFormat);
ASSERT(xoffset % d3d9::GetD3DFormatInfo(d3d9FormatInfo.texFormat).blockWidth == 0); ASSERT(area.x % d3d9::GetD3DFormatInfo(d3d9FormatInfo.texFormat).blockWidth == 0);
ASSERT(yoffset % d3d9::GetD3DFormatInfo(d3d9FormatInfo.texFormat).blockHeight == 0); ASSERT(area.y % d3d9::GetD3DFormatInfo(d3d9FormatInfo.texFormat).blockHeight == 0);
ASSERT(d3d9FormatInfo.loadFunction != NULL); ASSERT(d3d9FormatInfo.loadFunction != NULL);
RECT lockRect = RECT lockRect =
{ {
xoffset, yoffset, area.x, area.y,
xoffset + width, yoffset + height area.x + area.width, area.y + area.height
}; };
D3DLOCKED_RECT locked; D3DLOCKED_RECT locked;
...@@ -541,7 +539,7 @@ gl::Error Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset ...@@ -541,7 +539,7 @@ gl::Error Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset
return error; return error;
} }
d3d9FormatInfo.loadFunction(width, height, depth, d3d9FormatInfo.loadFunction(area.width, area.height, area.depth,
reinterpret_cast<const uint8_t*>(input), inputRowPitch, inputDepthPitch, reinterpret_cast<const uint8_t*>(input), inputRowPitch, inputDepthPitch,
reinterpret_cast<uint8_t*>(locked.pBits), locked.Pitch, 0); reinterpret_cast<uint8_t*>(locked.pBits), locked.Pitch, 0);
...@@ -551,12 +549,12 @@ gl::Error Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset ...@@ -551,12 +549,12 @@ gl::Error Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset
} }
// This implements glCopyTex[Sub]Image2D for non-renderable internal texture formats and incomplete textures // This implements glCopyTex[Sub]Image2D for non-renderable internal texture formats and incomplete textures
gl::Error Image9::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, RenderTarget *source) gl::Error Image9::copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea, RenderTarget *source)
{ {
ASSERT(source); ASSERT(source);
// ES3.0 only behaviour to copy into a 3d texture // ES3.0 only behaviour to copy into a 3d texture
ASSERT(zoffset == 0); ASSERT(destOffset.z == 0);
RenderTarget9 *renderTarget = RenderTarget9::makeRenderTarget9(source); RenderTarget9 *renderTarget = RenderTarget9::makeRenderTarget9(source);
...@@ -590,7 +588,7 @@ gl::Error Image9::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Re ...@@ -590,7 +588,7 @@ gl::Error Image9::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Re
int height = sourceArea.height; int height = sourceArea.height;
RECT sourceRect = { sourceArea.x, sourceArea.y, sourceArea.x + width, sourceArea.y + height }; RECT sourceRect = { sourceArea.x, sourceArea.y, sourceArea.x + width, sourceArea.y + height };
RECT destRect = { xoffset, yoffset, xoffset + width, yoffset + height }; RECT destRect = { destOffset.x, destOffset.y, destOffset.x + width, destOffset.y + height };
D3DLOCKED_RECT sourceLock = {0}; D3DLOCKED_RECT sourceLock = {0};
result = renderTargetData->LockRect(&sourceLock, &sourceRect, 0); result = renderTargetData->LockRect(&sourceLock, &sourceRect, 0);
...@@ -779,7 +777,7 @@ gl::Error Image9::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Re ...@@ -779,7 +777,7 @@ gl::Error Image9::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Re
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
gl::Error Image9::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &area, const gl::ImageIndex &srcIndex, TextureStorage *srcStorage) gl::Error Image9::copy(const gl::Offset &destOffset, const gl::Rectangle &area, const gl::ImageIndex &srcIndex, TextureStorage *srcStorage)
{ {
// Currently unreachable, due to only being used in a D3D11-only workaround // Currently unreachable, due to only being used in a D3D11-only workaround
UNIMPLEMENTED(); UNIMPLEMENTED();
......
...@@ -34,7 +34,7 @@ class Image9 : public ImageD3D ...@@ -34,7 +34,7 @@ class Image9 : public ImageD3D
static gl::Error generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9 *sourceSurface); static gl::Error generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9 *sourceSurface);
static gl::Error copyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface9 *source); static gl::Error copyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface9 *source);
bool redefine(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease) override; bool redefine(GLenum target, GLenum internalformat, const gl::Extents &size, bool forceRelease) override;
D3DFORMAT getD3DFormat() const; D3DFORMAT getD3DFormat() const;
...@@ -44,13 +44,11 @@ class Image9 : public ImageD3D ...@@ -44,13 +44,11 @@ class Image9 : public ImageD3D
virtual gl::Error setManagedSurfaceCube(TextureStorage *storage, int face, int level); virtual gl::Error setManagedSurfaceCube(TextureStorage *storage, int face, int level);
virtual gl::Error copyToStorage(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region); virtual gl::Error copyToStorage(TextureStorage *storage, const gl::ImageIndex &index, const gl::Box &region);
virtual gl::Error loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, virtual gl::Error loadData(const gl::Box &area, GLint unpackAlignment, GLenum type, const void *input);
GLint unpackAlignment, GLenum type, const void *input); virtual gl::Error loadCompressedData(const gl::Box &area, const void *input);
virtual gl::Error loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
const void *input);
virtual gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, RenderTarget *source); virtual gl::Error copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea, RenderTarget *source);
virtual gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea, virtual gl::Error copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea,
const gl::ImageIndex &sourceIndex, TextureStorage *source); const gl::ImageIndex &sourceIndex, TextureStorage *source);
private: private:
...@@ -60,7 +58,7 @@ class Image9 : public ImageD3D ...@@ -60,7 +58,7 @@ class Image9 : public ImageD3D
gl::Error createSurface(); gl::Error createSurface();
gl::Error setManagedSurface(IDirect3DSurface9 *surface); gl::Error setManagedSurface(IDirect3DSurface9 *surface);
gl::Error copyToSurface(IDirect3DSurface9 *dest, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height); gl::Error copyToSurface(IDirect3DSurface9 *dest, const gl::Box &area);
gl::Error lock(D3DLOCKED_RECT *lockedRect, const RECT &rect); gl::Error lock(D3DLOCKED_RECT *lockedRect, const RECT &rect);
void unlock(); void unlock();
......
...@@ -2441,8 +2441,8 @@ D3DPOOL Renderer9::getBufferPool(DWORD usage) const ...@@ -2441,8 +2441,8 @@ D3DPOOL Renderer9::getBufferPool(DWORD usage) const
return D3DPOOL_DEFAULT; return D3DPOOL_DEFAULT;
} }
gl::Error Renderer9::copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, gl::Error Renderer9::copyImage2D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level) const gl::Offset &destOffset, TextureStorage *storage, GLint level)
{ {
RECT rect; RECT rect;
rect.left = sourceRect.x; rect.left = sourceRect.x;
...@@ -2450,11 +2450,11 @@ gl::Error Renderer9::copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectang ...@@ -2450,11 +2450,11 @@ gl::Error Renderer9::copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectang
rect.right = sourceRect.x + sourceRect.width; rect.right = sourceRect.x + sourceRect.width;
rect.bottom = sourceRect.y + sourceRect.height; rect.bottom = sourceRect.y + sourceRect.height;
return mBlit->copy2D(framebuffer, rect, destFormat, xoffset, yoffset, storage, level); return mBlit->copy2D(framebuffer, rect, destFormat, destOffset, storage, level);
} }
gl::Error Renderer9::copyImageCube(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, gl::Error Renderer9::copyImageCube(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level) const gl::Offset &destOffset, TextureStorage *storage, GLenum target, GLint level)
{ {
RECT rect; RECT rect;
rect.left = sourceRect.x; rect.left = sourceRect.x;
...@@ -2462,19 +2462,19 @@ gl::Error Renderer9::copyImageCube(gl::Framebuffer *framebuffer, const gl::Recta ...@@ -2462,19 +2462,19 @@ gl::Error Renderer9::copyImageCube(gl::Framebuffer *framebuffer, const gl::Recta
rect.right = sourceRect.x + sourceRect.width; rect.right = sourceRect.x + sourceRect.width;
rect.bottom = sourceRect.y + sourceRect.height; rect.bottom = sourceRect.y + sourceRect.height;
return mBlit->copyCube(framebuffer, rect, destFormat, xoffset, yoffset, storage, target, level); return mBlit->copyCube(framebuffer, rect, destFormat, destOffset, storage, target, level);
} }
gl::Error Renderer9::copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, gl::Error Renderer9::copyImage3D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level) const gl::Offset &destOffset, TextureStorage *storage, GLint level)
{ {
// 3D textures are not available in the D3D9 backend. // 3D textures are not available in the D3D9 backend.
UNREACHABLE(); UNREACHABLE();
return gl::Error(GL_INVALID_OPERATION); return gl::Error(GL_INVALID_OPERATION);
} }
gl::Error Renderer9::copyImage2DArray(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, gl::Error Renderer9::copyImage2DArray(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level) const gl::Offset &destOffset, TextureStorage *storage, GLint level)
{ {
// 2D array textures are not available in the D3D9 backend. // 2D array textures are not available in the D3D9 backend.
UNREACHABLE(); UNREACHABLE();
......
...@@ -127,14 +127,14 @@ class Renderer9 : public RendererD3D ...@@ -127,14 +127,14 @@ class Renderer9 : public RendererD3D
virtual int getMaxSwapInterval() const; virtual int getMaxSwapInterval() const;
// Pixel operations // Pixel operations
virtual gl::Error copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, virtual gl::Error copyImage2D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level); const gl::Offset &destOffset, TextureStorage *storage, GLint level);
virtual gl::Error copyImageCube(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, virtual gl::Error copyImageCube(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level); const gl::Offset &destOffset, TextureStorage *storage, GLenum target, GLint level);
virtual gl::Error copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, virtual gl::Error copyImage3D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level); const gl::Offset &destOffset, TextureStorage *storage, GLint level);
virtual gl::Error copyImage2DArray(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, virtual gl::Error copyImage2DArray(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level); const gl::Offset &destOffset, TextureStorage *storage, GLint level);
// RenderTarget creation // RenderTarget creation
virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTarget **outRT); virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTarget **outRT);
......
...@@ -618,34 +618,12 @@ void GL_APIENTRY TexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalf ...@@ -618,34 +618,12 @@ void GL_APIENTRY TexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalf
return; return;
} }
switch (target) Extents size(width, height, 1);
Texture *texture = context->getTargetTexture(target);
Error error = texture->setStorage(target, levels, internalformat, size);
if (error.isError())
{ {
case GL_TEXTURE_2D: context->recordError(error);
{
Texture2D *texture2d = context->getTexture2D();
Error error = texture2d->storage(levels, internalformat, width, height);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
case GL_TEXTURE_CUBE_MAP:
{
TextureCubeMap *textureCube = context->getTextureCubeMap();
Error error = textureCube->storage(levels, internalformat, width);
if (error.isError())
{
context->recordError(error);
return;
}
}
break;
default:
context->recordError(Error(GL_INVALID_ENUM));
return; return;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment