Added depth parameters to all image loading functions.

TRAC #22705 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods Author: Geoff Lang git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2159 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 8dce651e
......@@ -2031,7 +2031,7 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
return gl::error(GL_INVALID_OPERATION);
}
GLsizei outputPitch = ComputePitch(width, ConvertSizedInternalFormat(format, type), getPackAlignment());
GLsizei outputPitch = ComputeRowPitch(width, ConvertSizedInternalFormat(format, type), getPackAlignment());
// sized query sanity check
if (bufSize)
{
......
......@@ -198,7 +198,7 @@ void Texture::setImage(GLint unpackAlignment, const void *pixels, rx::Image *ima
{
if (pixels != NULL)
{
image->loadData(0, 0, image->getWidth(), image->getHeight(), unpackAlignment, pixels);
image->loadData(0, 0, 0, image->getWidth(), image->getHeight(), image->getDepth(), unpackAlignment, pixels);
mDirtyImages = true;
}
}
......@@ -207,27 +207,29 @@ void Texture::setCompressedImage(GLsizei imageSize, const void *pixels, rx::Imag
{
if (pixels != NULL)
{
image->loadCompressedData(0, 0, image->getWidth(), image->getHeight(), pixels);
image->loadCompressedData(0, 0, 0, image->getWidth(), image->getHeight(), image->getDepth(), pixels);
mDirtyImages = true;
}
}
bool Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, rx::Image *image)
bool Texture::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, rx::Image *image)
{
if (pixels != NULL)
{
image->loadData(xoffset, yoffset, width, height, unpackAlignment, pixels);
image->loadData(xoffset, yoffset, zoffset, width, height, depth, unpackAlignment, pixels);
mDirtyImages = true;
}
return true;
}
bool Texture::subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels, rx::Image *image)
bool Texture::subImageCompressed(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLsizei imageSize, const void *pixels, rx::Image *image)
{
if (pixels != NULL)
{
image->loadCompressedData(xoffset, yoffset, width, height, pixels);
image->loadCompressedData(xoffset, yoffset, zoffset, width, height, depth, pixels);
mDirtyImages = true;
}
......@@ -387,7 +389,7 @@ void Texture2D::redefineImage(GLint level, GLint internalformat, GLsizei width,
const int storageHeight = std::max(1, mImageArray[0]->getHeight() >> level);
const int storageFormat = mImageArray[0]->getInternalFormat();
mImageArray[level]->redefine(mRenderer, internalformat, width, height, false);
mImageArray[level]->redefine(mRenderer, internalformat, width, height, 1, false);
if (mTexStorage)
{
......@@ -424,7 +426,7 @@ void Texture2D::bindTexImage(egl::Surface *surface)
GLint internalformat = surface->getFormat();
mImageArray[0]->redefine(mRenderer, internalformat, surface->getWidth(), surface->getHeight(), true);
mImageArray[0]->redefine(mRenderer, internalformat, surface->getWidth(), surface->getHeight(), 1, true);
delete mTexStorage;
mTexStorage = new rx::TextureStorageInterface2D(mRenderer, surface->getSwapChain());
......@@ -449,7 +451,7 @@ void Texture2D::releaseTexImage()
for (int i = 0; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
{
mImageArray[i]->redefine(mRenderer, GL_NONE, 0, 0, true);
mImageArray[i]->redefine(mRenderer, GL_NONE, 0, 0, 0, true);
}
}
}
......@@ -476,7 +478,7 @@ void Texture2D::commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei wi
void Texture2D::subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
{
if (Texture::subImage(xoffset, yoffset, width, height, format, type, unpackAlignment, pixels, mImageArray[level]))
if (Texture::subImage(xoffset, yoffset, 0, width, height, 1, format, type, unpackAlignment, pixels, mImageArray[level]))
{
commitRect(level, xoffset, yoffset, width, height);
}
......@@ -484,7 +486,7 @@ void Texture2D::subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei widt
void Texture2D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels)
{
if (Texture::subImageCompressed(xoffset, yoffset, width, height, format, imageSize, pixels, mImageArray[level]))
if (Texture::subImageCompressed(xoffset, yoffset, 0, width, height, 1, format, imageSize, pixels, mImageArray[level]))
{
commitRect(level, xoffset, yoffset, width, height);
}
......@@ -566,14 +568,14 @@ void Texture2D::storage(GLsizei levels, GLenum internalformat, GLsizei width, GL
for (int level = 0; level < levels; level++)
{
mImageArray[level]->redefine(mRenderer, internalformat, width, height, true);
mImageArray[level]->redefine(mRenderer, internalformat, width, height, 1, true);
width = std::max(1, width >> 1);
height = std::max(1, height >> 1);
}
for (int level = levels; level < IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++)
{
mImageArray[level]->redefine(mRenderer, GL_NONE, 0, 0, true);
mImageArray[level]->redefine(mRenderer, GL_NONE, 0, 0, 0, true);
}
if (mTexStorage->isManaged())
......@@ -1026,7 +1028,7 @@ void TextureCubeMap::commitRect(int face, GLint level, GLint xoffset, GLint yoff
void TextureCubeMap::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
{
if (Texture::subImage(xoffset, yoffset, width, height, format, type, unpackAlignment, pixels, mImageArray[faceIndex(target)][level]))
if (Texture::subImage(xoffset, yoffset, 0, width, height, 1, format, type, unpackAlignment, pixels, mImageArray[faceIndex(target)][level]))
{
commitRect(faceIndex(target), level, xoffset, yoffset, width, height);
}
......@@ -1034,7 +1036,7 @@ void TextureCubeMap::subImage(GLenum target, GLint level, GLint xoffset, GLint y
void TextureCubeMap::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels)
{
if (Texture::subImageCompressed(xoffset, yoffset, width, height, format, imageSize, pixels, mImageArray[faceIndex(target)][level]))
if (Texture::subImageCompressed(xoffset, yoffset, 0, width, height, 1, format, imageSize, pixels, mImageArray[faceIndex(target)][level]))
{
commitRect(faceIndex(target), level, xoffset, yoffset, width, height);
}
......@@ -1249,7 +1251,7 @@ void TextureCubeMap::redefineImage(int face, GLint level, GLint internalformat,
const int storageHeight = std::max(1, mImageArray[0][0]->getHeight() >> level);
const int storageFormat = mImageArray[0][0]->getInternalFormat();
mImageArray[face][level]->redefine(mRenderer, internalformat, width, height, false);
mImageArray[face][level]->redefine(mRenderer, internalformat, width, height, 1, false);
if (mTexStorage)
{
......@@ -1360,7 +1362,7 @@ void TextureCubeMap::storage(GLsizei levels, GLenum internalformat, GLsizei size
{
for (int face = 0; face < 6; face++)
{
mImageArray[face][level]->redefine(mRenderer, internalformat, size, size, true);
mImageArray[face][level]->redefine(mRenderer, internalformat, size, size, 1, true);
size = std::max(1, size >> 1);
}
}
......@@ -1369,7 +1371,7 @@ void TextureCubeMap::storage(GLsizei levels, GLenum internalformat, GLsizei size
{
for (int face = 0; face < 6; face++)
{
mImageArray[face][level]->redefine(mRenderer, GL_NONE, 0, 0, true);
mImageArray[face][level]->redefine(mRenderer, GL_NONE, 0, 0, 0, true);
}
}
......
......@@ -101,9 +101,11 @@ class Texture : public RefCountObject
protected:
void setImage(GLint unpackAlignment, const void *pixels, rx::Image *image);
bool subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, rx::Image *image);
bool subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, GLint unpackAlignment, const void *pixels, rx::Image *image);
void setCompressedImage(GLsizei imageSize, const void *pixels, rx::Image *image);
bool subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels, rx::Image *image);
bool subImageCompressed(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLsizei imageSize, const void *pixels, rx::Image *image);
GLint creationLevels(GLsizei width, GLsizei height) const;
GLint creationLevels(GLsizei size) const;
......
......@@ -41,14 +41,14 @@ class Image11 : public Image
virtual bool updateSurface(TextureStorageInterface2D *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
virtual bool updateSurface(TextureStorageInterfaceCube *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
virtual bool redefine(Renderer *renderer, GLint internalformat, GLsizei width, GLsizei height, bool forceRelease);
virtual bool redefine(Renderer *renderer, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease);
virtual bool isRenderableFormat() const;
DXGI_FORMAT getDXGIFormat() const;
virtual void loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
virtual void loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, const void *input);
virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
const void *input);
virtual void copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
......
......@@ -141,10 +141,14 @@ void Image9::copyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface9 *so
else UNREACHABLE();
}
bool Image9::redefine(rx::Renderer *renderer, GLint internalformat, GLsizei width, GLsizei height, bool forceRelease)
bool Image9::redefine(rx::Renderer *renderer, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease)
{
// 3D textures are not supported by the D3D9 backend.
ASSERT(depth <= 1);
if (mWidth != width ||
mHeight != height ||
mDepth != depth ||
mInternalFormat != internalformat ||
forceRelease)
{
......@@ -152,6 +156,7 @@ bool Image9::redefine(rx::Renderer *renderer, GLint internalformat, GLsizei widt
mWidth = width;
mHeight = height;
mDepth = depth;
mInternalFormat = internalformat;
// compute the d3d format that will be used
mD3DFormat = mRenderer->ConvertTextureInternalFormat(internalformat);
......@@ -351,9 +356,12 @@ bool Image9::updateSurface(IDirect3DSurface9 *destSurface, GLint xoffset, GLint
// Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input
// into the target pixel rectangle.
void Image9::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
void Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, const void *input)
{
// 3D textures are not supported by the D3D9 backend.
ASSERT(zoffset == 0 && depth == 1);
RECT lockRect =
{
xoffset, yoffset,
......@@ -368,81 +376,81 @@ void Image9::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heigh
}
GLsizei inputPitch = gl::ComputePitch(width, mInternalFormat, unpackAlignment);
GLsizei inputPitch = gl::ComputeRowPitch(width, mInternalFormat, unpackAlignment);
switch (mInternalFormat)
{
case GL_ALPHA8_EXT:
if (gl::supportsSSE2())
{
loadAlphaDataToBGRASSE2(width, height, inputPitch, input, locked.Pitch, locked.pBits);
loadAlphaDataToBGRASSE2(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
}
else
{
loadAlphaDataToBGRA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
loadAlphaDataToBGRA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
}
break;
case GL_LUMINANCE8_EXT:
loadLuminanceDataToNativeOrBGRA(width, height, inputPitch, input, locked.Pitch, locked.pBits, getD3DFormat() == D3DFMT_L8);
loadLuminanceDataToNativeOrBGRA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits, getD3DFormat() == D3DFMT_L8);
break;
case GL_ALPHA32F_EXT:
loadAlphaFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
loadAlphaFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_LUMINANCE32F_EXT:
loadLuminanceFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
loadLuminanceFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_ALPHA16F_EXT:
loadAlphaHalfFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
loadAlphaHalfFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_LUMINANCE16F_EXT:
loadLuminanceHalfFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
loadLuminanceHalfFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_LUMINANCE8_ALPHA8_EXT:
loadLuminanceAlphaDataToNativeOrBGRA(width, height, inputPitch, input, locked.Pitch, locked.pBits, getD3DFormat() == D3DFMT_A8L8);
loadLuminanceAlphaDataToNativeOrBGRA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits, getD3DFormat() == D3DFMT_A8L8);
break;
case GL_LUMINANCE_ALPHA32F_EXT:
loadLuminanceAlphaFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
loadLuminanceAlphaFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_LUMINANCE_ALPHA16F_EXT:
loadLuminanceAlphaHalfFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
loadLuminanceAlphaHalfFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_RGB8_OES:
loadRGBUByteDataToBGRX(width, height, inputPitch, input, locked.Pitch, locked.pBits);
loadRGBUByteDataToBGRX(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_RGB565:
loadRGB565DataToBGRA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
loadRGB565DataToBGRA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_RGBA8_OES:
if (gl::supportsSSE2())
{
loadRGBAUByteDataToBGRASSE2(width, height, inputPitch, input, locked.Pitch, locked.pBits);
loadRGBAUByteDataToBGRASSE2(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
}
else
{
loadRGBAUByteDataToBGRA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
loadRGBAUByteDataToBGRA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
}
break;
case GL_RGBA4:
loadRGBA4444DataToBGRA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
loadRGBA4444DataToBGRA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_RGB5_A1:
loadRGBA5551DataToBGRA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
loadRGBA5551DataToBGRA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_BGRA8_EXT:
loadBGRADataToBGRA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
loadBGRADataToBGRA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
// float textures are converted to RGBA, not BGRA, as they're stored that way in D3D
case GL_RGB32F_EXT:
loadRGBFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
loadRGBFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_RGB16F_EXT:
loadRGBHalfFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
loadRGBHalfFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_RGBA32F_EXT:
loadRGBAFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
loadRGBAFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_RGBA16F_EXT:
loadRGBAHalfFloatDataToRGBA(width, height, inputPitch, input, locked.Pitch, locked.pBits);
loadRGBAHalfFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
default: UNREACHABLE();
}
......@@ -450,12 +458,15 @@ void Image9::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heigh
unlock();
}
void Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
void Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
const void *input)
{
ASSERT(xoffset % 4 == 0);
ASSERT(yoffset % 4 == 0);
// 3D textures are not supported by the D3D9 backend.
ASSERT(zoffset == 0 && depth == 1);
RECT lockRect = {
xoffset, yoffset,
xoffset + width, yoffset + height
......@@ -469,7 +480,7 @@ void Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLs
}
GLsizei inputSize = gl::ComputeCompressedSize(width, height, mInternalFormat);
GLsizei inputPitch = gl::ComputeCompressedPitch(width, mInternalFormat);
GLsizei inputPitch = gl::ComputeCompressedRowPitch(width, mInternalFormat);
int rows = inputSize / inputPitch;
for (int i = 0; i < rows; ++i)
{
......
......@@ -37,7 +37,7 @@ class Image9 : public Image
static void generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9 *sourceSurface);
static void copyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface9 *source);
virtual bool redefine(Renderer *renderer, GLint internalformat, GLsizei width, GLsizei height, bool forceRelease);
virtual bool redefine(Renderer *renderer, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease);
virtual bool isRenderableFormat() const;
D3DFORMAT getD3DFormat() const;
......@@ -50,9 +50,9 @@ class Image9 : public Image
virtual bool updateSurface(TextureStorageInterface2D *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
virtual bool updateSurface(TextureStorageInterfaceCube *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
virtual void loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
virtual void loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, const void *input);
virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
const void *input);
virtual void copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
......
......@@ -15,17 +15,20 @@
namespace rx
{
void Image::loadRGBAUByteDataToBGRASSE2(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output)
void Image::loadRGBAUByteDataToBGRASSE2(GLsizei width, GLsizei height, GLsizei depth,
int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{
const unsigned int *source = NULL;
unsigned int *dest = NULL;
__m128i brMask = _mm_set1_epi32(0x00ff00ff);
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++)
{
source = reinterpret_cast<const unsigned int*>(static_cast<const unsigned char*>(input) + y * inputPitch);
dest = reinterpret_cast<unsigned int*>(static_cast<unsigned char*>(output) + y * outputPitch);
source = reinterpret_cast<const unsigned int*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch);
dest = reinterpret_cast<unsigned int*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch);
int x = 0;
// Make output writes aligned
......@@ -55,19 +58,23 @@ void Image::loadRGBAUByteDataToBGRASSE2(GLsizei width, GLsizei height,
dest[x] = (_rotl(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00);
}
}
}
}
void Image::loadAlphaDataToBGRASSE2(GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output)
void Image::loadAlphaDataToBGRASSE2(GLsizei width, GLsizei height, GLsizei depth,
int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{
const unsigned char *source = NULL;
unsigned int *dest = NULL;
__m128i zeroWide = _mm_setzero_si128();
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++)
{
source = static_cast<const unsigned char*>(input) + y * inputPitch;
dest = reinterpret_cast<unsigned int*>(static_cast<unsigned char*>(output) + y * outputPitch);
source = static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch;
dest = reinterpret_cast<unsigned int*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch);
int x;
// Make output writes aligned
......@@ -95,6 +102,7 @@ void Image::loadAlphaDataToBGRASSE2(GLsizei width, GLsizei height,
dest[x] = static_cast<unsigned int>(source[x]) << 24;
}
}
}
}
}
......@@ -259,7 +259,7 @@ int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsig
return -1;
}
GLsizei ComputePitch(GLsizei width, GLint internalformat, GLint alignment)
GLsizei ComputeRowPitch(GLsizei width, GLint internalformat, GLint alignment)
{
ASSERT(alignment > 0 && isPow2(alignment));
......@@ -267,11 +267,21 @@ GLsizei ComputePitch(GLsizei width, GLint internalformat, GLint alignment)
return (rawPitch + alignment - 1) & ~(alignment - 1);
}
GLsizei ComputeCompressedPitch(GLsizei width, GLenum internalformat)
GLsizei ComputeDepthPitch(GLsizei width, GLsizei height, GLint internalformat, GLint alignment)
{
return ComputeRowPitch(width, internalformat, alignment) * height;
}
GLsizei ComputeCompressedRowPitch(GLsizei width, GLenum internalformat)
{
return ComputeCompressedSize(width, 1, internalformat);
}
GLsizei ComputeCompressedDepthPitch(GLsizei width, GLsizei height, GLenum internalformat)
{
return ComputeCompressedSize(width, height, internalformat);
}
GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum internalformat)
{
switch (internalformat)
......
......@@ -35,8 +35,10 @@ int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsig
void MakeValidSize(bool isImage, bool isCompressed, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset);
int ComputePixelSize(GLint internalformat);
GLsizei ComputePitch(GLsizei width, GLint internalformat, GLint alignment);
GLsizei ComputeCompressedPitch(GLsizei width, GLenum format);
GLsizei ComputeRowPitch(GLsizei width, GLint internalformat, GLint alignment);
GLsizei ComputeDepthPitch(GLsizei width, GLsizei height, GLint internalformat, GLint alignment);
GLsizei ComputeCompressedRowPitch(GLsizei width, GLenum format);
GLsizei ComputeCompressedDepthPitch(GLsizei width, GLsizei height, GLenum format);
GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum format);
bool IsCompressed(GLenum format);
bool IsDepthTexture(GLenum format);
......
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