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
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.
// "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
bool isCompressed(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 setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, 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);
Error subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const PixelUnpackState &unpack, const void *pixels);
Error copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
Error storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
Error setImage(GLenum target, size_t level, GLenum internalFormat, const Extents &size, GLenum format, GLenum type,
const PixelUnpackState &unpack, const uint8_t *pixels) override;
Error setCompressedImage(GLenum target, size_t level, GLenum internalFormat, const Extents &size,
const PixelUnpackState &unpack, const uint8_t *pixels) override;
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 void bindTexImage(egl::Surface *surface);
virtual void releaseTexImage();
virtual Error generateMipmaps();
private:
DISALLOW_COPY_AND_ASSIGN(Texture2D);
......@@ -153,13 +172,6 @@ class TextureCubeMap : public Texture
bool isCompressed(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;
bool isCubeComplete() const;
......@@ -188,12 +200,6 @@ class Texture3D : public Texture
bool isCompressed(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;
private:
......@@ -217,12 +223,6 @@ class Texture2DArray : public Texture
bool isCompressed(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;
private:
......
......@@ -57,19 +57,14 @@ struct Rectangle
bool ClipRectangle(const Rectangle &source, const Rectangle &clip, Rectangle *intersection);
struct Box
struct Offset
{
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) { }
bool operator==(const Box &other) const;
bool operator!=(const Box &other) const;
Offset() : x(0), y(0), z(0) { }
Offset(int x_in, int y_in, int z_in) : x(x_in), y(y_in), z(z_in) { }
};
struct Extents
......@@ -82,6 +77,23 @@ struct Extents
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
{
bool cullFace;
......
......@@ -20,6 +20,9 @@ namespace gl
{
class Framebuffer;
struct Rectangle;
struct Extents;
struct Box;
struct Offset;
struct ImageIndex;
}
......@@ -46,15 +49,13 @@ class Image
void markClean() {mDirty = false;}
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,
GLint unpackAlignment, GLenum type, 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 loadData(const gl::Box &area, GLint unpackAlignment, GLenum type, const void *input) = 0;
virtual gl::Error loadCompressedData(const gl::Box &area, 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(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea,
virtual gl::Error copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea, const gl::Framebuffer *source) = 0;
virtual gl::Error copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea,
const gl::ImageIndex &sourceIndex, TextureStorage *source) = 0;
protected:
......
......@@ -9,12 +9,14 @@
#ifndef LIBANGLE_RENDERER_TEXTUREIMPL_H_
#define LIBANGLE_RENDERER_TEXTUREIMPL_H_
#include "common/angleutils.h"
#include "libANGLE/Error.h"
#include "libANGLE/ImageIndex.h"
#include "common/angleutils.h"
#include "angle_gl.h"
#include "libANGLE/ImageIndex.h"
#include <stdint.h>
namespace egl
{
......@@ -23,6 +25,10 @@ class Surface;
namespace gl
{
struct Box;
struct Extents;
struct Offset;
struct Rectangle;
class Framebuffer;
struct PixelUnpackState;
struct SamplerState;
......@@ -45,13 +51,22 @@ class TextureImpl
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 setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, 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 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;
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 storage(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) = 0;
virtual gl::Error setImage(GLenum target, size_t level, GLenum internalFormat, const gl::Extents &size, GLenum format, GLenum type,
const gl::PixelUnpackState &unpack, const uint8_t *pixels) = 0;
virtual gl::Error setSubImage(GLenum target, size_t level, const gl::Box &area, GLenum format, GLenum type,
const gl::PixelUnpackState &unpack, const uint8_t *pixels) = 0;
virtual gl::Error setCompressedImage(GLenum target, size_t level, GLenum internalFormat, const gl::Extents &size,
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;
......
......@@ -27,7 +27,7 @@ ImageD3D *ImageD3D::makeImageD3D(Image *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();
ASSERT(colorbuffer);
......@@ -40,7 +40,7 @@ gl::Error ImageD3D::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::
}
ASSERT(renderTarget);
return copy(xoffset, yoffset, zoffset, area, renderTarget);
return copy(destOffset, sourceArea, renderTarget);
}
}
......@@ -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 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:
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)
if (mIncompleteTextures.find(type) == mIncompleteTextures.end())
{
const GLubyte color[] = { 0, 0, 0, 255 };
const gl::Extents colorSize(1, 1, 1);
const gl::PixelUnpackState incompleteUnpackState(1);
gl::Texture* t = NULL;
switch (type)
{
default:
UNREACHABLE();
// default falls through to TEXTURE_2D
case GL_TEXTURE_2D:
{
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;
default: UNREACHABLE(); // default falls through to TEXTURE_2D
case GL_TEXTURE_2D: t = new gl::Texture2D(createTexture(type), gl::Texture::INCOMPLETE_TEXTURE_ID); break;
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_ARRAY: t = new gl::Texture2DArray(createTexture(type), gl::Texture::INCOMPLETE_TEXTURE_ID); 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);
incomplete2darray->setImage(0, 1, 1, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
t = incomplete2darray;
t->setImage(face, 0, GL_RGBA, colorSize, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
}
break;
}
else
{
t->setImage(type, 0, GL_RGBA, colorSize, GL_RGBA, GL_UNSIGNED_BYTE, incompleteUnpackState, color);
}
mIncompleteTextures[type].set(t);
......
......@@ -107,14 +107,14 @@ class RendererD3D : public Renderer
virtual bool getPostSubBufferSupport() const = 0;
// Pixel operations
virtual gl::Error copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level) = 0;
virtual gl::Error copyImageCube(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level) = 0;
virtual gl::Error copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level) = 0;
virtual gl::Error copyImage2DArray(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level) = 0;
virtual gl::Error copyImage2D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLint level) = 0;
virtual gl::Error copyImageCube(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLenum target, GLint level) = 0;
virtual gl::Error copyImage3D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLint level) = 0;
virtual gl::Error copyImage2DArray(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLint level) = 0;
// RenderTarget creation
virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTarget **outRT) = 0;
......
......@@ -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 ||
mHeight != height ||
if (mWidth != size.width ||
mHeight != size.height ||
mInternalFormat != internalformat ||
forceRelease)
{
......@@ -214,9 +214,9 @@ bool Image11::redefine(GLenum target, GLenum internalformat, GLsizei width, GLsi
disassociateStorage();
mRecoveredFromStorageCount = 0;
mWidth = width;
mHeight = height;
mDepth = depth;
mWidth = size.width;
mHeight = size.height;
mDepth = size.depth;
mInternalFormat = internalformat;
mTarget = target;
......@@ -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
// into the target pixel rectangle.
gl::Error Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, GLenum type, const void *input)
gl::Error Image11::loadData(const gl::Box &area, GLint unpackAlignment, GLenum type, const void *input)
{
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat);
GLsizei inputRowPitch = formatInfo.computeRowPitch(type, width, unpackAlignment);
GLsizei inputDepthPitch = formatInfo.computeDepthPitch(type, width, height, unpackAlignment);
GLsizei inputRowPitch = formatInfo.computeRowPitch(type, area.width, unpackAlignment);
GLsizei inputDepthPitch = formatInfo.computeDepthPitch(type, area.width, area.height, unpackAlignment);
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mDXGIFormat);
GLuint outputPixelSize = dxgiFormatInfo.pixelBytes;
......@@ -265,8 +264,8 @@ gl::Error Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei
return error;
}
uint8_t* offsetMappedData = (reinterpret_cast<uint8_t*>(mappedImage.pData) + (yoffset * mappedImage.RowPitch + xoffset * outputPixelSize + zoffset * mappedImage.DepthPitch));
loadFunction(width, height, depth,
uint8_t *offsetMappedData = (reinterpret_cast<uint8_t*>(mappedImage.pData) + (area.y * mappedImage.RowPitch + area.x * outputPixelSize + area.z * mappedImage.DepthPitch));
loadFunction(area.width, area.height, area.depth,
reinterpret_cast<const uint8_t*>(input), inputRowPitch, inputDepthPitch,
offsetMappedData, mappedImage.RowPitch, mappedImage.DepthPitch);
......@@ -275,20 +274,19 @@ gl::Error Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei
return gl::Error(GL_NO_ERROR);
}
gl::Error Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
const void *input)
gl::Error Image11::loadCompressedData(const gl::Box &area, const void *input)
{
const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(mInternalFormat);
GLsizei inputRowPitch = formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, width, 1);
GLsizei inputDepthPitch = formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, width, height, 1);
GLsizei inputRowPitch = formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, area.width, 1);
GLsizei inputDepthPitch = formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, area.width, area.height, 1);
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mDXGIFormat);
GLuint outputPixelSize = dxgiFormatInfo.pixelBytes;
GLuint outputBlockWidth = dxgiFormatInfo.blockWidth;
GLuint outputBlockHeight = dxgiFormatInfo.blockHeight;
ASSERT(xoffset % outputBlockWidth == 0);
ASSERT(yoffset % outputBlockHeight == 0);
ASSERT(area.x % outputBlockWidth == 0);
ASSERT(area.y % outputBlockHeight == 0);
const d3d11::TextureFormat &d3dFormatInfo = d3d11::GetTextureFormatInfo(mInternalFormat, mFeatureLevel);
LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions.at(GL_UNSIGNED_BYTE);
......@@ -300,11 +298,11 @@ gl::Error Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffse
return error;
}
uint8_t* offsetMappedData = reinterpret_cast<uint8_t*>(mappedImage.pData) + ((yoffset / outputBlockHeight) * mappedImage.RowPitch +
(xoffset / outputBlockWidth) * outputPixelSize +
zoffset * mappedImage.DepthPitch);
uint8_t* offsetMappedData = reinterpret_cast<uint8_t*>(mappedImage.pData) + ((area.y / outputBlockHeight) * mappedImage.RowPitch +
(area.x / outputBlockWidth) * outputPixelSize +
area.z * mappedImage.DepthPitch);
loadFunction(width, height, depth,
loadFunction(area.width, area.height, area.depth,
reinterpret_cast<const uint8_t*>(input), inputRowPitch, inputDepthPitch,
offsetMappedData, mappedImage.RowPitch, mappedImage.DepthPitch);
......@@ -313,7 +311,7 @@ gl::Error Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffse
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);
ASSERT(sourceRenderTarget->getTexture());
......@@ -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.");
}
gl::Error error = copy(xoffset, yoffset, zoffset, sourceArea, sourceTexture2D, subresourceIndex);
gl::Error error = copy(destOffset, sourceArea, sourceTexture2D, subresourceIndex);
SafeRelease(sourceTexture2D);
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);
......@@ -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.");
}
error = copy(xoffset, yoffset, zoffset, sourceArea, sourceTexture2D, subresourceIndex);
error = copy(destOffset, sourceArea, sourceTexture2D, subresourceIndex);
SafeRelease(sourceTexture2D);
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;
source->GetDesc(&textureDesc);
......@@ -418,7 +416,8 @@ gl::Error Image11::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::R
srcBox.front = 0;
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)
{
......@@ -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
const d3d11::DXGIFormat &dxgiFormatInfo = d3d11::GetDXGIFormatInfo(mDXGIFormat);
GLsizei rowOffset = dxgiFormatInfo.pixelBytes * xoffset;
uint8_t *dataOffset = static_cast<uint8_t*>(mappedImage.pData) + mappedImage.RowPitch * yoffset + rowOffset + zoffset * mappedImage.DepthPitch;
GLsizei rowOffset = dxgiFormatInfo.pixelBytes * destOffset.x;
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);
......
......@@ -39,17 +39,15 @@ class Image11 : public ImageD3D
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;
virtual gl::Error loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, GLenum type, 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 loadData(const gl::Box &area, GLint unpackAlignment, GLenum type, const void *input);
virtual gl::Error loadCompressedData(const gl::Box &area, const void *input);
virtual gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, 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, RenderTarget *source);
virtual gl::Error copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea,
const gl::ImageIndex &sourceIndex, TextureStorage *source);
gl::Error recoverFromAssociatedStorage();
......@@ -64,7 +62,7 @@ class Image11 : public ImageD3D
DISALLOW_COPY_AND_ASSIGN(Image11);
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 createStagingTexture();
......
......@@ -2102,8 +2102,8 @@ int Renderer11::getMaxSwapInterval() const
return 4;
}
gl::Error Renderer11::copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level)
gl::Error Renderer11::copyImage2D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLint level)
{
gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer();
ASSERT(colorbuffer);
......@@ -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::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);
// 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
return gl::Error(GL_NO_ERROR);
}
gl::Error Renderer11::copyImageCube(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level)
gl::Error Renderer11::copyImageCube(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLenum target, GLint level)
{
gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer();
ASSERT(colorbuffer);
......@@ -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::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);
// 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
return gl::Error(GL_NO_ERROR);
}
gl::Error Renderer11::copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level)
gl::Error Renderer11::copyImage3D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLint level)
{
gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer();
ASSERT(colorbuffer);
......@@ -2224,7 +2224,7 @@ gl::Error Renderer11::copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectan
TextureStorage11_3D *storage11 = TextureStorage11_3D::makeTextureStorage11_3D(storage);
ASSERT(storage11);
gl::ImageIndex index = gl::ImageIndex::Make3D(level, zOffset);
gl::ImageIndex index = gl::ImageIndex::Make3D(level, destOffset.z);
RenderTarget *destRenderTarget = NULL;
error = storage11->getRenderTarget(index, &destRenderTarget);
if (error.isError())
......@@ -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::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);
// 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
return gl::Error(GL_NO_ERROR);
}
gl::Error Renderer11::copyImage2DArray(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level)
gl::Error Renderer11::copyImage2DArray(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLint level)
{
gl::FramebufferAttachment *colorbuffer = framebuffer->getReadColorbuffer();
ASSERT(colorbuffer);
......@@ -2275,7 +2275,7 @@ gl::Error Renderer11::copyImage2DArray(gl::Framebuffer *framebuffer, const gl::R
TextureStorage11_2DArray *storage11 = TextureStorage11_2DArray::makeTextureStorage11_2DArray(storage);
ASSERT(storage11);
gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, zOffset);
gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, destOffset.z);
RenderTarget *destRenderTarget = NULL;
error = storage11->getRenderTarget(index, &destRenderTarget);
if (error.isError())
......@@ -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::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);
// Use nearest filtering because source and destination are the same size for the direct
......
......@@ -118,14 +118,14 @@ class Renderer11 : public RendererD3D
virtual int getMaxSwapInterval() const;
// Pixel operations
virtual gl::Error copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level);
virtual gl::Error copyImageCube(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level);
virtual gl::Error copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level);
virtual gl::Error copyImage2DArray(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level);
virtual gl::Error copyImage2D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLint level);
virtual gl::Error copyImageCube(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLenum target, GLint level);
virtual gl::Error copyImage3D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLint level);
virtual gl::Error copyImage2DArray(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLint level);
// RenderTarget creation
virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTarget **outRT);
......
......@@ -12,6 +12,7 @@
#include "libANGLE/renderer/d3d/d3d9/TextureStorage9.h"
#include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h"
#include "libANGLE/renderer/d3d/d3d9/Renderer9.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h"
......@@ -216,7 +217,7 @@ gl::Error Blit9::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest)
device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
setViewport(getSurfaceRect(dest), 0, 0);
setViewport(getSurfaceRect(dest), gl::Offset(0, 0, 0));
render();
......@@ -227,7 +228,7 @@ gl::Error Blit9::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest)
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();
if (error.isError())
......@@ -258,7 +259,7 @@ gl::Error Blit9::copy2D(gl::Framebuffer *framebuffer, const RECT &sourceRect, GL
}
ASSERT(destSurface);
gl::Error result = copy(source, sourceRect, destFormat, xoffset, yoffset, destSurface);
gl::Error result = copy(source, sourceRect, destFormat, destOffset, destSurface);
SafeRelease(destSurface);
SafeRelease(source);
......@@ -266,7 +267,7 @@ gl::Error Blit9::copy2D(gl::Framebuffer *framebuffer, const RECT &sourceRect, GL
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();
if (error.isError())
......@@ -297,7 +298,7 @@ gl::Error Blit9::copyCube(gl::Framebuffer *framebuffer, const RECT &sourceRect,
}
ASSERT(destSurface);
gl::Error result = copy(source, sourceRect, destFormat, xoffset, yoffset, destSurface);
gl::Error result = copy(source, sourceRect, destFormat, destOffset, destSurface);
SafeRelease(destSurface);
SafeRelease(source);
......@@ -305,7 +306,7 @@ gl::Error Blit9::copyCube(gl::Framebuffer *framebuffer, const RECT &sourceRect,
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);
......@@ -319,7 +320,7 @@ gl::Error Blit9::copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum
if (sourceDesc.Format == destDesc.Format && destDesc.Usage & D3DUSAGE_RENDERTARGET &&
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);
if (FAILED(result))
......@@ -332,11 +333,11 @@ gl::Error Blit9::copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum
}
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();
if (error.isError())
......@@ -358,7 +359,7 @@ gl::Error Blit9::formatConvert(IDirect3DSurface9 *source, const RECT &sourceRect
device->SetTexture(0, texture);
device->SetRenderTarget(0, dest);
setViewport(sourceRect, xoffset, yoffset);
setViewport(sourceRect, destOffset);
setCommonBlitState();
......@@ -547,13 +548,13 @@ gl::Error Blit9::copySurfaceToTexture(IDirect3DSurface9 *surface, const RECT &so
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();
D3DVIEWPORT9 vp;
vp.X = xoffset;
vp.Y = yoffset;
vp.X = offset.x;
vp.Y = offset.y;
vp.Width = sourceRect.right - sourceRect.left;
vp.Height = sourceRect.bottom - sourceRect.top;
vp.MinZ = 0.0f;
......
......@@ -17,6 +17,7 @@
namespace gl
{
class Framebuffer;
struct Offset;
}
namespace rx
......@@ -34,13 +35,13 @@ class Blit9
// Copy from source surface to dest surface.
// 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 copyCube(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, 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(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.
// 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.
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.
// Requires that source is RGB(A) and dest has the same format as source.
......@@ -55,9 +56,9 @@ class Blit9
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);
void setViewport(const RECT &sourceRect, GLint xoffset, GLint yoffset);
void setViewport(const RECT &sourceRect, const gl::Offset &offset);
void setCommonBlitState();
RECT getSurfaceRect(IDirect3DSurface9 *surface) const;
......
......@@ -169,23 +169,23 @@ gl::Error Image9::copyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface
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.
ASSERT(depth <= 1);
ASSERT(size.depth <= 1);
// Only 2D and cube texture are supported by the D3D9 backend.
ASSERT(target == GL_TEXTURE_2D || target == GL_TEXTURE_CUBE_MAP);
if (mWidth != width ||
mHeight != height ||
mDepth != depth ||
if (mWidth != size.width ||
mHeight != size.height ||
mDepth != size.depth ||
mInternalFormat != internalformat ||
forceRelease)
{
mWidth = width;
mHeight = height;
mDepth = depth;
mWidth = size.width;
mHeight = size.height;
mDepth = size.depth;
mInternalFormat = internalformat;
// compute the d3d format that will be used
......@@ -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);
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);
IDirect3DSurface9 *sourceSurface = NULL;
......@@ -431,10 +431,10 @@ gl::Error Image9::copyToSurface(IDirect3DSurface9 *destSurface, GLint xoffset, G
ASSERT(sourceSurface && sourceSurface != destSurface);
RECT rect;
rect.left = xoffset;
rect.top = yoffset;
rect.right = xoffset + width;
rect.bottom = yoffset + height;
rect.left = area.x;
rect.top = area.y;
rect.right = area.x + area.width;
rect.bottom = area.y + area.height;
POINT point = {rect.left, rect.top};
......@@ -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
// into the target pixel rectangle.
gl::Error Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, GLenum type, const void *input)
gl::Error Image9::loadData(const gl::Box &area, GLint unpackAlignment, GLenum type, const void *input)
{
// 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);
GLsizei inputRowPitch = formatInfo.computeRowPitch(type, width, unpackAlignment);
GLsizei inputRowPitch = formatInfo.computeRowPitch(type, area.width, unpackAlignment);
const d3d9::TextureFormat &d3dFormatInfo = d3d9::GetTextureFormatInfo(mInternalFormat);
ASSERT(d3dFormatInfo.loadFunction != NULL);
RECT lockRect =
{
xoffset, yoffset,
xoffset + width, yoffset + height
area.x, area.y,
area.x + area.width, area.y + area.height
};
D3DLOCKED_RECT locked;
......@@ -502,7 +501,7 @@ gl::Error Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei
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<uint8_t*>(locked.pBits), locked.Pitch, 0);
......@@ -511,27 +510,26 @@ gl::Error Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei
return gl::Error(GL_NO_ERROR);
}
gl::Error Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
const void *input)
gl::Error Image9::loadCompressedData(const gl::Box &area, const void *input)
{
// 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);
GLsizei inputRowPitch = formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, width, 1);
GLsizei inputDepthPitch = formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, width, height, 1);
GLsizei inputRowPitch = formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, area.width, 1);
GLsizei inputDepthPitch = formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, area.width, area.height, 1);
const d3d9::TextureFormat &d3d9FormatInfo = d3d9::GetTextureFormatInfo(mInternalFormat);
ASSERT(xoffset % d3d9::GetD3DFormatInfo(d3d9FormatInfo.texFormat).blockWidth == 0);
ASSERT(yoffset % d3d9::GetD3DFormatInfo(d3d9FormatInfo.texFormat).blockHeight == 0);
ASSERT(area.x % d3d9::GetD3DFormatInfo(d3d9FormatInfo.texFormat).blockWidth == 0);
ASSERT(area.y % d3d9::GetD3DFormatInfo(d3d9FormatInfo.texFormat).blockHeight == 0);
ASSERT(d3d9FormatInfo.loadFunction != NULL);
RECT lockRect =
{
xoffset, yoffset,
xoffset + width, yoffset + height
area.x, area.y,
area.x + area.width, area.y + area.height
};
D3DLOCKED_RECT locked;
......@@ -541,7 +539,7 @@ gl::Error Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset
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<uint8_t*>(locked.pBits), locked.Pitch, 0);
......@@ -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
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);
// ES3.0 only behaviour to copy into a 3d texture
ASSERT(zoffset == 0);
ASSERT(destOffset.z == 0);
RenderTarget9 *renderTarget = RenderTarget9::makeRenderTarget9(source);
......@@ -590,7 +588,7 @@ gl::Error Image9::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Re
int height = sourceArea.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};
result = renderTargetData->LockRect(&sourceLock, &sourceRect, 0);
......@@ -779,7 +777,7 @@ gl::Error Image9::copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Re
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
UNIMPLEMENTED();
......
......@@ -34,7 +34,7 @@ class Image9 : public ImageD3D
static gl::Error generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9 *sourceSurface);
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;
......@@ -44,13 +44,11 @@ class Image9 : public ImageD3D
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 loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, GLenum type, 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 loadData(const gl::Box &area, GLint unpackAlignment, GLenum type, const void *input);
virtual gl::Error loadCompressedData(const gl::Box &area, const void *input);
virtual gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, 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, RenderTarget *source);
virtual gl::Error copy(const gl::Offset &destOffset, const gl::Rectangle &sourceArea,
const gl::ImageIndex &sourceIndex, TextureStorage *source);
private:
......@@ -60,7 +58,7 @@ class Image9 : public ImageD3D
gl::Error createSurface();
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);
void unlock();
......
......@@ -2441,8 +2441,8 @@ D3DPOOL Renderer9::getBufferPool(DWORD usage) const
return D3DPOOL_DEFAULT;
}
gl::Error Renderer9::copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level)
gl::Error Renderer9::copyImage2D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLint level)
{
RECT rect;
rect.left = sourceRect.x;
......@@ -2450,11 +2450,11 @@ gl::Error Renderer9::copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectang
rect.right = sourceRect.x + sourceRect.width;
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,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level)
gl::Error Renderer9::copyImageCube(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLenum target, GLint level)
{
RECT rect;
rect.left = sourceRect.x;
......@@ -2462,19 +2462,19 @@ gl::Error Renderer9::copyImageCube(gl::Framebuffer *framebuffer, const gl::Recta
rect.right = sourceRect.x + sourceRect.width;
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,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level)
gl::Error Renderer9::copyImage3D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLint level)
{
// 3D textures are not available in the D3D9 backend.
UNREACHABLE();
return gl::Error(GL_INVALID_OPERATION);
}
gl::Error Renderer9::copyImage2DArray(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level)
gl::Error Renderer9::copyImage2DArray(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLint level)
{
// 2D array textures are not available in the D3D9 backend.
UNREACHABLE();
......
......@@ -127,14 +127,14 @@ class Renderer9 : public RendererD3D
virtual int getMaxSwapInterval() const;
// Pixel operations
virtual gl::Error copyImage2D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLint level);
virtual gl::Error copyImageCube(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, TextureStorage *storage, GLenum target, GLint level);
virtual gl::Error copyImage3D(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level);
virtual gl::Error copyImage2DArray(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
GLint xoffset, GLint yoffset, GLint zOffset, TextureStorage *storage, GLint level);
virtual gl::Error copyImage2D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLint level);
virtual gl::Error copyImageCube(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLenum target, GLint level);
virtual gl::Error copyImage3D(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLint level);
virtual gl::Error copyImage2DArray(const gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
const gl::Offset &destOffset, TextureStorage *storage, GLint level);
// RenderTarget creation
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
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:
{
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));
context->recordError(error);
return;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment