Commit feda4d29 by Jamie Madill

Accept ImageIndex in TextureD3D::subImage and getImage.

This paves the way for setting data on the TextureStorage directly instead of working through the Image objects. BUG=angle:741 Change-Id: I3be3d5f9b2e45707c1630b74ad3f4789e034c3fd Reviewed-on: https://chromium-review.googlesource.com/218311Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent e6256f87
......@@ -211,6 +211,7 @@
<ClInclude Include="..\..\src\libGLESv2\Shader.h"/>
<ClInclude Include="..\..\src\libGLESv2\BinaryStream.h"/>
<ClInclude Include="..\..\src\libGLESv2\resource.h"/>
<ClInclude Include="..\..\src\libGLESv2\ImageIndex.h"/>
<ClInclude Include="..\..\src\libGLESv2\Sampler.h"/>
<ClInclude Include="..\..\src\libGLESv2\Caps.h"/>
<ClInclude Include="..\..\src\libGLESv2\TransformFeedback.h"/>
......@@ -418,6 +419,7 @@
<ClCompile Include="..\..\src\libGLESv2\Uniform.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\main.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\Renderbuffer.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\ImageIndex.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\Sampler.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\Framebuffer.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\Texture.cpp"/>
......
......@@ -81,6 +81,9 @@
<ClInclude Include="..\..\src\libGLESv2\resource.h">
<Filter>src\libGLESv2</Filter>
</ClInclude>
<ClInclude Include="..\..\src\libGLESv2\ImageIndex.h">
<Filter>src\libGLESv2</Filter>
</ClInclude>
<ClInclude Include="..\..\src\libGLESv2\Sampler.h">
<Filter>src\libGLESv2</Filter>
</ClInclude>
......@@ -222,6 +225,9 @@
<ClInclude Include="..\..\src\libGLESv2\VertexArray.h">
<Filter>src\libGLESv2</Filter>
</ClInclude>
<ClCompile Include="..\..\src\libGLESv2\ImageIndex.cpp">
<Filter>src\libGLESv2</Filter>
</ClCompile>
<ClCompile Include="..\..\src\libGLESv2\Sampler.cpp">
<Filter>src\libGLESv2</Filter>
</ClCompile>
......
......@@ -59,6 +59,8 @@
'libGLESv2/FramebufferAttachment.h',
'libGLESv2/HandleAllocator.cpp',
'libGLESv2/HandleAllocator.h',
'libGLESv2/ImageIndex.h',
'libGLESv2/ImageIndex.cpp',
'libGLESv2/Program.cpp',
'libGLESv2/Program.h',
'libGLESv2/ProgramBinary.cpp',
......
//
// Copyright 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ImageIndex.cpp: Implementation for ImageIndex methods.
#include "libGLESv2/ImageIndex.h"
#include "libGLESv2/Texture.h"
#include "common/utilities.h"
namespace gl
{
ImageIndex::ImageIndex(const ImageIndex &other)
: type(other.type),
mipIndex(other.mipIndex),
layerIndex(other.layerIndex)
{}
ImageIndex &ImageIndex::operator=(const ImageIndex &other)
{
type = other.type;
mipIndex = other.mipIndex;
layerIndex = other.layerIndex;
return *this;
}
ImageIndex ImageIndex::Make2D(GLint mipIndex)
{
return ImageIndex(GL_TEXTURE_2D, mipIndex, 0);
}
ImageIndex ImageIndex::MakeCube(GLenum target, GLint mipIndex)
{
ASSERT(gl::IsCubemapTextureTarget(target));
return ImageIndex(target, mipIndex, TextureCubeMap::targetToLayerIndex(target));
}
ImageIndex ImageIndex::Make2DArray(GLint mipIndex, GLint layerIndex)
{
return ImageIndex(GL_TEXTURE_2D_ARRAY, mipIndex, layerIndex);
}
ImageIndex ImageIndex::Make3D(GLint mipIndex, GLint layerIndex)
{
return ImageIndex(GL_TEXTURE_3D, mipIndex, layerIndex);
}
ImageIndex::ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn)
: type(typeIn),
mipIndex(mipIndexIn),
layerIndex(layerIndexIn)
{}
}
//
// Copyright 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ImageIndex.h: A helper struct for indexing into an Image array
#ifndef LIBGLESV2_IMAGE_INDEX_H_
#define LIBGLESV2_IMAGE_INDEX_H_
#include "angle_gl.h"
namespace gl
{
struct ImageIndex
{
GLenum type;
GLint mipIndex;
GLint layerIndex;
ImageIndex(const ImageIndex &other);
ImageIndex &operator=(const ImageIndex &other);
static ImageIndex Make2D(GLint mipIndex);
static ImageIndex MakeCube(GLenum target, GLint mipIndex);
static ImageIndex Make2DArray(GLint mipIndex, GLint layerIndex);
static ImageIndex Make3D(GLint mipIndex, GLint layerIndex = 0);
private:
ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn);
};
}
#endif // LIBGLESV2_IMAGE_INDEX_H_
......@@ -12,6 +12,7 @@
#include "libGLESv2/main.h"
#include "libGLESv2/Context.h"
#include "libGLESv2/formatutils.h"
#include "libGLESv2/ImageIndex.h"
#include "libGLESv2/Renderbuffer.h"
#include "libGLESv2/renderer/Image.h"
#include "libGLESv2/renderer/d3d/TextureStorage.h"
......@@ -115,25 +116,25 @@ GLenum Texture::getBaseLevelInternalFormat() const
GLsizei Texture::getWidth(const ImageIndex &index) const
{
rx::Image *image = mTexture->getImage(index.mipIndex, index.layerIndex);
rx::Image *image = mTexture->getImage(index);
return image->getWidth();
}
GLsizei Texture::getHeight(const ImageIndex &index) const
{
rx::Image *image = mTexture->getImage(index.mipIndex, index.layerIndex);
rx::Image *image = mTexture->getImage(index);
return image->getHeight();
}
GLenum Texture::getInternalFormat(const ImageIndex &index) const
{
rx::Image *image = mTexture->getImage(index.mipIndex, index.layerIndex);
rx::Image *image = mTexture->getImage(index);
return image->getInternalFormat();
}
GLenum Texture::getActualFormat(const ImageIndex &index) const
{
rx::Image *image = mTexture->getImage(index.mipIndex, index.layerIndex);
rx::Image *image = mTexture->getImage(index);
return image->getActualFormat();
}
......
......@@ -240,54 +240,6 @@ class Texture2DArray : public Texture
bool isLevelComplete(int level) const;
};
struct ImageIndex
{
GLenum type;
GLint mipIndex;
GLint layerIndex;
ImageIndex(const ImageIndex &other)
: type(other.type),
mipIndex(other.mipIndex),
layerIndex(other.layerIndex)
{}
ImageIndex &operator=(const ImageIndex &other)
{
type = other.type;
mipIndex = other.mipIndex;
layerIndex = other.layerIndex;
return *this;
}
static ImageIndex Make2D(GLint mipIndex)
{
return ImageIndex(GL_TEXTURE_2D, mipIndex, 0);
}
static ImageIndex MakeCube(GLenum target, GLint mipIndex)
{
return ImageIndex(target, mipIndex, TextureCubeMap::targetToLayerIndex(target));
}
static ImageIndex Make2DArray(GLint mipIndex, GLint layerIndex)
{
return ImageIndex(GL_TEXTURE_2D_ARRAY, mipIndex, layerIndex);
}
static ImageIndex Make3D(GLint mipIndex, GLint layerIndex = 0)
{
return ImageIndex(GL_TEXTURE_3D, mipIndex, layerIndex);
}
private:
ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn)
: type(typeIn),
mipIndex(mipIndexIn),
layerIndex(layerIndexIn)
{}
};
}
#endif // LIBGLESV2_TEXTURE_H_
......@@ -13,6 +13,8 @@
#include "angle_gl.h"
#include "libGLESv2/ImageIndex.h"
namespace egl
{
class Surface;
......@@ -42,7 +44,9 @@ class TextureImpl
// higher level code should not rely on it.
virtual TextureStorageInterface *getNativeTexture() = 0;
// Deprecated in favour of the ImageIndex method
virtual Image *getImage(int level, int layer) const = 0;
virtual Image *getImage(const gl::ImageIndex &index) const = 0;
virtual GLsizei getLayerCount(int level) const = 0;
virtual void setUsage(GLenum usage) = 0;
......
......@@ -121,7 +121,7 @@ void TextureD3D::setImage(const gl::PixelUnpackState &unpack, GLenum type, const
}
bool TextureD3D::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels, Image *image)
GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels, const gl::ImageIndex &index)
{
const void *pixelData = pixels;
......@@ -138,6 +138,9 @@ bool TextureD3D::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei w
if (pixelData != NULL)
{
Image *image = getImage(index);
ASSERT(image);
image->loadData(xoffset, yoffset, zoffset, width, height, depth, unpack.alignment, type, pixelData);
mDirtyImages = true;
}
......@@ -238,6 +241,14 @@ Image *TextureD3D_2D::getImage(int level, int layer) const
return mImageArray[level];
}
Image *TextureD3D_2D::getImage(const gl::ImageIndex &index) const
{
ASSERT(index.mipIndex < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
ASSERT(index.layerIndex == 0);
ASSERT(index.type == GL_TEXTURE_2D);
return mImageArray[index.mipIndex];
}
GLsizei TextureD3D_2D::getLayerCount(int level) const
{
ASSERT(level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
......@@ -343,7 +354,8 @@ void TextureD3D_2D::subImage(GLenum target, GLint level, GLint xoffset, GLint yo
}
}
if (!fastUnpacked && TextureD3D::subImage(xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels, mImageArray[level]))
gl::ImageIndex index = gl::ImageIndex::Make2D(level);
if (!fastUnpacked && TextureD3D::subImage(xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels, index))
{
commitRect(level, xoffset, yoffset, width, height);
}
......@@ -759,6 +771,13 @@ Image *TextureD3D_Cube::getImage(int level, int layer) const
return mImageArray[layer][level];
}
Image *TextureD3D_Cube::getImage(const gl::ImageIndex &index) const
{
ASSERT(index.mipIndex < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
ASSERT(index.layerIndex < 6);
return mImageArray[index.layerIndex][index.mipIndex];
}
GLsizei TextureD3D_Cube::getLayerCount(int level) const
{
ASSERT(level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
......@@ -808,7 +827,8 @@ void TextureD3D_Cube::subImage(GLenum target, GLint level, GLint xoffset, GLint
int faceIndex = gl::TextureCubeMap::targetToLayerIndex(target);
if (TextureD3D::subImage(xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels, mImageArray[faceIndex][level]))
gl::ImageIndex index = gl::ImageIndex::MakeCube(target, level);
if (TextureD3D::subImage(xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels, index))
{
commitRect(faceIndex, level, xoffset, yoffset, width, height);
}
......@@ -1251,6 +1271,14 @@ Image *TextureD3D_3D::getImage(int level, int layer) const
return mImageArray[level];
}
Image *TextureD3D_3D::getImage(const gl::ImageIndex &index) const
{
ASSERT(index.mipIndex < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
ASSERT(index.layerIndex == 0);
ASSERT(index.type == GL_TEXTURE_3D);
return mImageArray[index.mipIndex];
}
GLsizei TextureD3D_3D::getLayerCount(int level) const
{
ASSERT(level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
......@@ -1356,7 +1384,8 @@ void TextureD3D_3D::subImage(GLenum target, GLint level, GLint xoffset, GLint yo
}
}
if (!fastUnpacked && TextureD3D::subImage(xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels, mImageArray[level]))
gl::ImageIndex index = gl::ImageIndex::Make3D(level);
if (!fastUnpacked && TextureD3D::subImage(xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels, index))
{
commitRect(level, xoffset, yoffset, zoffset, width, height, depth);
}
......@@ -1740,6 +1769,14 @@ Image *TextureD3D_2DArray::getImage(int level, int layer) const
return mImageArray[level][layer];
}
Image *TextureD3D_2DArray::getImage(const gl::ImageIndex &index) const
{
ASSERT(index.mipIndex < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
ASSERT(index.layerIndex < mLayerCounts[index.mipIndex]);
ASSERT(index.type == GL_TEXTURE_2D_ARRAY);
return mImageArray[index.mipIndex][index.layerIndex];
}
GLsizei TextureD3D_2DArray::getLayerCount(int level) const
{
ASSERT(level < gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS);
......@@ -1818,7 +1855,8 @@ void TextureD3D_2DArray::subImage(GLenum target, GLint level, GLint xoffset, GLi
int layer = zoffset + i;
const void *layerPixels = pixels ? (reinterpret_cast<const unsigned char*>(pixels) + (inputDepthPitch * i)) : NULL;
if (TextureD3D::subImage(xoffset, yoffset, zoffset, width, height, 1, format, type, unpack, layerPixels, mImageArray[level][layer]))
gl::ImageIndex index = gl::ImageIndex::Make2DArray(level, layer);
if (TextureD3D::subImage(xoffset, yoffset, zoffset, width, height, 1, format, type, unpack, layerPixels, index))
{
commitRect(level, xoffset, yoffset, layer, width, height);
}
......
......@@ -58,7 +58,7 @@ class TextureD3D : public TextureImpl
protected:
void setImage(const gl::PixelUnpackState &unpack, GLenum type, const void *pixels, Image *image);
bool subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels, Image *image);
GLenum format, GLenum type, const gl::PixelUnpackState &unpack, const void *pixels, const gl::ImageIndex &index);
void setCompressedImage(GLsizei imageSize, const void *pixels, Image *image);
bool subImageCompressed(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLsizei imageSize, const void *pixels, Image *image);
......@@ -94,6 +94,7 @@ class TextureD3D_2D : public TextureD3D
virtual ~TextureD3D_2D();
virtual Image *getImage(int level, int layer) const;
virtual Image *getImage(const gl::ImageIndex &index) const;
virtual GLsizei getLayerCount(int level) const;
GLsizei getWidth(GLint level) const;
......@@ -149,6 +150,7 @@ class TextureD3D_Cube : public TextureD3D
virtual ~TextureD3D_Cube();
virtual Image *getImage(int level, int layer) const;
virtual Image *getImage(const gl::ImageIndex &index) const;
virtual GLsizei getLayerCount(int level) const;
virtual bool hasDirtyImages() const { return mDirtyImages; }
......@@ -206,6 +208,7 @@ class TextureD3D_3D : public TextureD3D
virtual ~TextureD3D_3D();
virtual Image *getImage(int level, int layer) const;
virtual Image *getImage(const gl::ImageIndex &index) const;
virtual GLsizei getLayerCount(int level) const;
GLsizei getWidth(GLint level) const;
......@@ -262,6 +265,7 @@ class TextureD3D_2DArray : public TextureD3D
virtual ~TextureD3D_2DArray();
virtual Image *getImage(int level, int layer) const;
virtual Image *getImage(const gl::ImageIndex &index) const;
virtual GLsizei getLayerCount(int level) const;
GLsizei getWidth(GLint level) const;
......
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