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, ...@@ -2031,7 +2031,7 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
return gl::error(GL_INVALID_OPERATION); 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 // sized query sanity check
if (bufSize) if (bufSize)
{ {
......
...@@ -198,7 +198,7 @@ void Texture::setImage(GLint unpackAlignment, const void *pixels, rx::Image *ima ...@@ -198,7 +198,7 @@ void Texture::setImage(GLint unpackAlignment, const void *pixels, rx::Image *ima
{ {
if (pixels != NULL) 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; mDirtyImages = true;
} }
} }
...@@ -207,27 +207,29 @@ void Texture::setCompressedImage(GLsizei imageSize, const void *pixels, rx::Imag ...@@ -207,27 +207,29 @@ void Texture::setCompressedImage(GLsizei imageSize, const void *pixels, rx::Imag
{ {
if (pixels != NULL) 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; 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) if (pixels != NULL)
{ {
image->loadData(xoffset, yoffset, width, height, unpackAlignment, pixels); image->loadData(xoffset, yoffset, zoffset, width, height, depth, unpackAlignment, pixels);
mDirtyImages = true; mDirtyImages = true;
} }
return 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) if (pixels != NULL)
{ {
image->loadCompressedData(xoffset, yoffset, width, height, pixels); image->loadCompressedData(xoffset, yoffset, zoffset, width, height, depth, pixels);
mDirtyImages = true; mDirtyImages = true;
} }
...@@ -387,7 +389,7 @@ void Texture2D::redefineImage(GLint level, GLint internalformat, GLsizei width, ...@@ -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 storageHeight = std::max(1, mImageArray[0]->getHeight() >> level);
const int storageFormat = mImageArray[0]->getInternalFormat(); 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) if (mTexStorage)
{ {
...@@ -424,7 +426,7 @@ void Texture2D::bindTexImage(egl::Surface *surface) ...@@ -424,7 +426,7 @@ void Texture2D::bindTexImage(egl::Surface *surface)
GLint internalformat = surface->getFormat(); 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; delete mTexStorage;
mTexStorage = new rx::TextureStorageInterface2D(mRenderer, surface->getSwapChain()); mTexStorage = new rx::TextureStorageInterface2D(mRenderer, surface->getSwapChain());
...@@ -449,7 +451,7 @@ void Texture2D::releaseTexImage() ...@@ -449,7 +451,7 @@ void Texture2D::releaseTexImage()
for (int i = 0; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++) 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 ...@@ -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) 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); commitRect(level, xoffset, yoffset, width, height);
} }
...@@ -484,7 +486,7 @@ void Texture2D::subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei widt ...@@ -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) 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); commitRect(level, xoffset, yoffset, width, height);
} }
...@@ -566,14 +568,14 @@ void Texture2D::storage(GLsizei levels, GLenum internalformat, GLsizei width, GL ...@@ -566,14 +568,14 @@ void Texture2D::storage(GLsizei levels, GLenum internalformat, GLsizei width, GL
for (int level = 0; level < levels; level++) 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); width = std::max(1, width >> 1);
height = std::max(1, height >> 1); height = std::max(1, height >> 1);
} }
for (int level = levels; level < IMPLEMENTATION_MAX_TEXTURE_LEVELS; level++) 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()) if (mTexStorage->isManaged())
...@@ -1026,7 +1028,7 @@ void TextureCubeMap::commitRect(int face, GLint level, GLint xoffset, GLint yoff ...@@ -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) 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); commitRect(faceIndex(target), level, xoffset, yoffset, width, height);
} }
...@@ -1034,7 +1036,7 @@ void TextureCubeMap::subImage(GLenum target, GLint level, GLint xoffset, GLint y ...@@ -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) 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); commitRect(faceIndex(target), level, xoffset, yoffset, width, height);
} }
...@@ -1249,7 +1251,7 @@ void TextureCubeMap::redefineImage(int face, GLint level, GLint internalformat, ...@@ -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 storageHeight = std::max(1, mImageArray[0][0]->getHeight() >> level);
const int storageFormat = mImageArray[0][0]->getInternalFormat(); 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) if (mTexStorage)
{ {
...@@ -1360,7 +1362,7 @@ void TextureCubeMap::storage(GLsizei levels, GLenum internalformat, GLsizei size ...@@ -1360,7 +1362,7 @@ void TextureCubeMap::storage(GLsizei levels, GLenum internalformat, GLsizei size
{ {
for (int face = 0; face < 6; face++) 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); size = std::max(1, size >> 1);
} }
} }
...@@ -1369,7 +1371,7 @@ void TextureCubeMap::storage(GLsizei levels, GLenum internalformat, GLsizei size ...@@ -1369,7 +1371,7 @@ void TextureCubeMap::storage(GLsizei levels, GLenum internalformat, GLsizei size
{ {
for (int face = 0; face < 6; face++) 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 ...@@ -101,9 +101,11 @@ class Texture : public RefCountObject
protected: protected:
void setImage(GLint unpackAlignment, const void *pixels, rx::Image *image); 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); 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 width, GLsizei height) const;
GLint creationLevels(GLsizei size) const; GLint creationLevels(GLsizei size) const;
......
...@@ -18,20 +18,24 @@ Image::Image() ...@@ -18,20 +18,24 @@ Image::Image()
{ {
mWidth = 0; mWidth = 0;
mHeight = 0; mHeight = 0;
mDepth = 0;
mInternalFormat = GL_NONE; mInternalFormat = GL_NONE;
mActualFormat = GL_NONE; mActualFormat = GL_NONE;
} }
void Image::loadAlphaDataToBGRA(GLsizei width, GLsizei height, void Image::loadAlphaDataToBGRA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned char *source = NULL; const unsigned char *source = NULL;
unsigned char *dest = NULL; unsigned char *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = static_cast<const unsigned char*>(input) + y * inputPitch; source = static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch;
dest = static_cast<unsigned char*>(output) + y * outputPitch; dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch;
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = 0; dest[4 * x + 0] = 0;
...@@ -40,32 +44,40 @@ void Image::loadAlphaDataToBGRA(GLsizei width, GLsizei height, ...@@ -40,32 +44,40 @@ void Image::loadAlphaDataToBGRA(GLsizei width, GLsizei height,
dest[4 * x + 3] = source[x]; dest[4 * x + 3] = source[x];
} }
} }
}
} }
void Image::loadAlphaDataToNative(GLsizei width, GLsizei height, void Image::loadAlphaDataToNative(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned char *source = NULL; const unsigned char *source = NULL;
unsigned char *dest = NULL; unsigned char *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = static_cast<const unsigned char*>(input) + y * inputPitch; source = static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch;
dest = static_cast<unsigned char*>(output) + y * outputPitch; dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch;
memcpy(dest, source, width); memcpy(dest, source, width);
} }
}
} }
void Image::loadAlphaFloatDataToRGBA(GLsizei width, GLsizei height, void Image::loadAlphaFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const float *source = NULL; const float *source = NULL;
float *dest = NULL; float *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch);
dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputPitch); dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = 0; dest[4 * x + 0] = 0;
...@@ -74,18 +86,22 @@ void Image::loadAlphaFloatDataToRGBA(GLsizei width, GLsizei height, ...@@ -74,18 +86,22 @@ void Image::loadAlphaFloatDataToRGBA(GLsizei width, GLsizei height,
dest[4 * x + 3] = source[x]; dest[4 * x + 3] = source[x];
} }
} }
}
} }
void Image::loadAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height, void Image::loadAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned short *source = NULL; const unsigned short *source = NULL;
unsigned short *dest = NULL; unsigned short *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch);
dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + y * outputPitch); dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = 0; dest[4 * x + 0] = 0;
...@@ -94,18 +110,23 @@ void Image::loadAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height, ...@@ -94,18 +110,23 @@ void Image::loadAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height,
dest[4 * x + 3] = source[x]; dest[4 * x + 3] = source[x];
} }
} }
}
} }
void Image::loadLuminanceDataToNativeOrBGRA(GLsizei width, GLsizei height, void Image::loadLuminanceDataToNativeOrBGRA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output, bool native) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output,
bool native)
{ {
const unsigned char *source = NULL; const unsigned char *source = NULL;
unsigned char *dest = NULL; unsigned char *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = static_cast<const unsigned char*>(input) + y * inputPitch; source = static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch;
dest = static_cast<unsigned char*>(output) + y * outputPitch; dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch;
if (!native) // BGRA8 destination format if (!native) // BGRA8 destination format
{ {
...@@ -122,18 +143,22 @@ void Image::loadLuminanceDataToNativeOrBGRA(GLsizei width, GLsizei height, ...@@ -122,18 +143,22 @@ void Image::loadLuminanceDataToNativeOrBGRA(GLsizei width, GLsizei height,
memcpy(dest, source, width); memcpy(dest, source, width);
} }
} }
}
} }
void Image::loadLuminanceFloatDataToRGBA(GLsizei width, GLsizei height, void Image::loadLuminanceFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const float *source = NULL; const float *source = NULL;
float *dest = NULL; float *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch);
dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputPitch); dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[x]; dest[4 * x + 0] = source[x];
...@@ -142,18 +167,22 @@ void Image::loadLuminanceFloatDataToRGBA(GLsizei width, GLsizei height, ...@@ -142,18 +167,22 @@ void Image::loadLuminanceFloatDataToRGBA(GLsizei width, GLsizei height,
dest[4 * x + 3] = 1.0f; dest[4 * x + 3] = 1.0f;
} }
} }
}
} }
void Image::loadLuminanceFloatDataToRGB(GLsizei width, GLsizei height, void Image::loadLuminanceFloatDataToRGB(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const float *source = NULL; const float *source = NULL;
float *dest = NULL; float *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch);
dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputPitch); dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[3 * x + 0] = source[x]; dest[3 * x + 0] = source[x];
...@@ -161,18 +190,22 @@ void Image::loadLuminanceFloatDataToRGB(GLsizei width, GLsizei height, ...@@ -161,18 +190,22 @@ void Image::loadLuminanceFloatDataToRGB(GLsizei width, GLsizei height,
dest[3 * x + 2] = source[x]; dest[3 * x + 2] = source[x];
} }
} }
}
} }
void Image::loadLuminanceHalfFloatDataToRGBA(GLsizei width, GLsizei height, void Image::loadLuminanceHalfFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned short *source = NULL; const unsigned short *source = NULL;
unsigned short *dest = NULL; unsigned short *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch);
dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + y * outputPitch); dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[x]; dest[4 * x + 0] = source[x];
...@@ -181,18 +214,23 @@ void Image::loadLuminanceHalfFloatDataToRGBA(GLsizei width, GLsizei height, ...@@ -181,18 +214,23 @@ void Image::loadLuminanceHalfFloatDataToRGBA(GLsizei width, GLsizei height,
dest[4 * x + 3] = 0x3C00; // SEEEEEMMMMMMMMMM, S = 0, E = 15, M = 0: 16bit flpt representation of 1 dest[4 * x + 3] = 0x3C00; // SEEEEEMMMMMMMMMM, S = 0, E = 15, M = 0: 16bit flpt representation of 1
} }
} }
}
} }
void Image::loadLuminanceAlphaDataToNativeOrBGRA(GLsizei width, GLsizei height, void Image::loadLuminanceAlphaDataToNativeOrBGRA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output, bool native) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output,
bool native)
{ {
const unsigned char *source = NULL; const unsigned char *source = NULL;
unsigned char *dest = NULL; unsigned char *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = static_cast<const unsigned char*>(input) + y * inputPitch; source = static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch;
dest = static_cast<unsigned char*>(output) + y * outputPitch; dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch;
if (!native) // BGRA8 destination format if (!native) // BGRA8 destination format
{ {
...@@ -209,18 +247,22 @@ void Image::loadLuminanceAlphaDataToNativeOrBGRA(GLsizei width, GLsizei height, ...@@ -209,18 +247,22 @@ void Image::loadLuminanceAlphaDataToNativeOrBGRA(GLsizei width, GLsizei height,
memcpy(dest, source, width * 2); memcpy(dest, source, width * 2);
} }
} }
}
} }
void Image::loadLuminanceAlphaFloatDataToRGBA(GLsizei width, GLsizei height, void Image::loadLuminanceAlphaFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const float *source = NULL; const float *source = NULL;
float *dest = NULL; float *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch);
dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputPitch); dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[2*x+0]; dest[4 * x + 0] = source[2*x+0];
...@@ -229,18 +271,22 @@ void Image::loadLuminanceAlphaFloatDataToRGBA(GLsizei width, GLsizei height, ...@@ -229,18 +271,22 @@ void Image::loadLuminanceAlphaFloatDataToRGBA(GLsizei width, GLsizei height,
dest[4 * x + 3] = source[2*x+1]; dest[4 * x + 3] = source[2*x+1];
} }
} }
}
} }
void Image::loadLuminanceAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height, void Image::loadLuminanceAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned short *source = NULL; const unsigned short *source = NULL;
unsigned short *dest = NULL; unsigned short *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch);
dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + y * outputPitch); dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[2*x+0]; dest[4 * x + 0] = source[2*x+0];
...@@ -249,18 +295,22 @@ void Image::loadLuminanceAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height, ...@@ -249,18 +295,22 @@ void Image::loadLuminanceAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height,
dest[4 * x + 3] = source[2*x+1]; dest[4 * x + 3] = source[2*x+1];
} }
} }
}
} }
void Image::loadRGBUByteDataToBGRX(GLsizei width, GLsizei height, void Image::loadRGBUByteDataToBGRX(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned char *source = NULL; const unsigned char *source = NULL;
unsigned char *dest = NULL; unsigned char *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = static_cast<const unsigned char*>(input) + y * inputPitch; source = static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch;
dest = static_cast<unsigned char*>(output) + y * outputPitch; dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch;
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[x * 3 + 2]; dest[4 * x + 0] = source[x * 3 + 2];
...@@ -269,18 +319,22 @@ void Image::loadRGBUByteDataToBGRX(GLsizei width, GLsizei height, ...@@ -269,18 +319,22 @@ void Image::loadRGBUByteDataToBGRX(GLsizei width, GLsizei height,
dest[4 * x + 3] = 0xFF; dest[4 * x + 3] = 0xFF;
} }
} }
}
} }
void Image::loadRGBUByteDataToRGBA(GLsizei width, GLsizei height, void Image::loadRGBUByteDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned char *source = NULL; const unsigned char *source = NULL;
unsigned char *dest = NULL; unsigned char *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = static_cast<const unsigned char*>(input) + y * inputPitch; source = static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch;
dest = static_cast<unsigned char*>(output) + y * outputPitch; dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch;
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[x * 3 + 0]; dest[4 * x + 0] = source[x * 3 + 0];
...@@ -289,18 +343,22 @@ void Image::loadRGBUByteDataToRGBA(GLsizei width, GLsizei height, ...@@ -289,18 +343,22 @@ void Image::loadRGBUByteDataToRGBA(GLsizei width, GLsizei height,
dest[4 * x + 3] = 0xFF; dest[4 * x + 3] = 0xFF;
} }
} }
}
} }
void Image::loadRGB565DataToBGRA(GLsizei width, GLsizei height, void Image::loadRGB565DataToBGRA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned short *source = NULL; const unsigned short *source = NULL;
unsigned char *dest = NULL; unsigned char *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputPitch; dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch;
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
unsigned short rgba = source[x]; unsigned short rgba = source[x];
...@@ -310,18 +368,22 @@ void Image::loadRGB565DataToBGRA(GLsizei width, GLsizei height, ...@@ -310,18 +368,22 @@ void Image::loadRGB565DataToBGRA(GLsizei width, GLsizei height,
dest[4 * x + 3] = 0xFF; dest[4 * x + 3] = 0xFF;
} }
} }
}
} }
void Image::loadRGB565DataToRGBA(GLsizei width, GLsizei height, void Image::loadRGB565DataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned short *source = NULL; const unsigned short *source = NULL;
unsigned char *dest = NULL; unsigned char *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputPitch; dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch;
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
unsigned short rgba = source[x]; unsigned short rgba = source[x];
...@@ -331,18 +393,22 @@ void Image::loadRGB565DataToRGBA(GLsizei width, GLsizei height, ...@@ -331,18 +393,22 @@ void Image::loadRGB565DataToRGBA(GLsizei width, GLsizei height,
dest[4 * x + 3] = 0xFF; dest[4 * x + 3] = 0xFF;
} }
} }
}
} }
void Image::loadRGBFloatDataToRGBA(GLsizei width, GLsizei height, void Image::loadRGBFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const float *source = NULL; const float *source = NULL;
float *dest = NULL; float *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch);
dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputPitch); dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[x * 3 + 0]; dest[4 * x + 0] = source[x * 3 + 0];
...@@ -351,32 +417,40 @@ void Image::loadRGBFloatDataToRGBA(GLsizei width, GLsizei height, ...@@ -351,32 +417,40 @@ void Image::loadRGBFloatDataToRGBA(GLsizei width, GLsizei height,
dest[4 * x + 3] = 1.0f; dest[4 * x + 3] = 1.0f;
} }
} }
}
} }
void Image::loadRGBFloatDataToNative(GLsizei width, GLsizei height, void Image::loadRGBFloatDataToNative(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const float *source = NULL; const float *source = NULL;
float *dest = NULL; float *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch);
dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputPitch); dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch);
memcpy(dest, source, width * 12); memcpy(dest, source, width * 12);
} }
}
} }
void Image::loadRGBHalfFloatDataToRGBA(GLsizei width, GLsizei height, void Image::loadRGBHalfFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned short *source = NULL; const unsigned short *source = NULL;
unsigned short *dest = NULL; unsigned short *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch);
dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + y * outputPitch); dest = reinterpret_cast<unsigned short*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
dest[4 * x + 0] = source[x * 3 + 0]; dest[4 * x + 0] = source[x * 3 + 0];
...@@ -385,17 +459,22 @@ void Image::loadRGBHalfFloatDataToRGBA(GLsizei width, GLsizei height, ...@@ -385,17 +459,22 @@ void Image::loadRGBHalfFloatDataToRGBA(GLsizei width, GLsizei height,
dest[4 * x + 3] = 0x3C00; // SEEEEEMMMMMMMMMM, S = 0, E = 15, M = 0: 16bit flpt representation of 1 dest[4 * x + 3] = 0x3C00; // SEEEEEMMMMMMMMMM, S = 0, E = 15, M = 0: 16bit flpt representation of 1
} }
} }
}
} }
void Image::loadRGBAUByteDataToBGRA(GLsizei width, GLsizei height, void Image::loadRGBAUByteDataToBGRA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned int *source = NULL; const unsigned int *source = NULL;
unsigned int *dest = NULL; unsigned int *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned int*>(static_cast<const unsigned char*>(input) + y * inputPitch); 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 * outputPitch); dest = reinterpret_cast<unsigned int*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch);
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
...@@ -403,32 +482,41 @@ void Image::loadRGBAUByteDataToBGRA(GLsizei width, GLsizei height, ...@@ -403,32 +482,41 @@ void Image::loadRGBAUByteDataToBGRA(GLsizei width, GLsizei height,
dest[x] = (_rotl(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00); dest[x] = (_rotl(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00);
} }
} }
}
} }
void Image::loadRGBAUByteDataToNative(GLsizei width, GLsizei height, void Image::loadRGBAUByteDataToNative(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned int *source = NULL; const unsigned int *source = NULL;
unsigned int *dest = NULL; unsigned int *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned int*>(static_cast<const unsigned char*>(input) + y * inputPitch); 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 * outputPitch); dest = reinterpret_cast<unsigned int*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch);
memcpy(dest, source, width * 4); memcpy(dest, source, width * 4);
} }
}
} }
void Image::loadRGBA4444DataToBGRA(GLsizei width, GLsizei height, void Image::loadRGBA4444DataToBGRA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned short *source = NULL; const unsigned short *source = NULL;
unsigned char *dest = NULL; unsigned char *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputPitch; dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch;
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
unsigned short rgba = source[x]; unsigned short rgba = source[x];
...@@ -438,18 +526,22 @@ void Image::loadRGBA4444DataToBGRA(GLsizei width, GLsizei height, ...@@ -438,18 +526,22 @@ void Image::loadRGBA4444DataToBGRA(GLsizei width, GLsizei height,
dest[4 * x + 3] = ((rgba & 0x000F) << 4) | ((rgba & 0x000F) >> 0); dest[4 * x + 3] = ((rgba & 0x000F) << 4) | ((rgba & 0x000F) >> 0);
} }
} }
}
} }
void Image::loadRGBA4444DataToRGBA(GLsizei width, GLsizei height, void Image::loadRGBA4444DataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned short *source = NULL; const unsigned short *source = NULL;
unsigned char *dest = NULL; unsigned char *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputPitch; dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch;
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
unsigned short rgba = source[x]; unsigned short rgba = source[x];
...@@ -459,18 +551,22 @@ void Image::loadRGBA4444DataToRGBA(GLsizei width, GLsizei height, ...@@ -459,18 +551,22 @@ void Image::loadRGBA4444DataToRGBA(GLsizei width, GLsizei height,
dest[4 * x + 3] = ((rgba & 0x000F) << 4) | ((rgba & 0x000F) >> 0); dest[4 * x + 3] = ((rgba & 0x000F) << 4) | ((rgba & 0x000F) >> 0);
} }
} }
}
} }
void Image::loadRGBA5551DataToBGRA(GLsizei width, GLsizei height, void Image::loadRGBA5551DataToBGRA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned short *source = NULL; const unsigned short *source = NULL;
unsigned char *dest = NULL; unsigned char *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputPitch; dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch;
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
unsigned short rgba = source[x]; unsigned short rgba = source[x];
...@@ -480,18 +576,22 @@ void Image::loadRGBA5551DataToBGRA(GLsizei width, GLsizei height, ...@@ -480,18 +576,22 @@ void Image::loadRGBA5551DataToBGRA(GLsizei width, GLsizei height,
dest[4 * x + 3] = (rgba & 0x0001) ? 0xFF : 0; dest[4 * x + 3] = (rgba & 0x0001) ? 0xFF : 0;
} }
} }
}
} }
void Image::loadRGBA5551DataToRGBA(GLsizei width, GLsizei height, void Image::loadRGBA5551DataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned short *source = NULL; const unsigned short *source = NULL;
unsigned char *dest = NULL; unsigned char *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputPitch); source = reinterpret_cast<const unsigned short*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch);
dest = static_cast<unsigned char*>(output) + y * outputPitch; dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch;
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
unsigned short rgba = source[x]; unsigned short rgba = source[x];
...@@ -501,48 +601,61 @@ void Image::loadRGBA5551DataToRGBA(GLsizei width, GLsizei height, ...@@ -501,48 +601,61 @@ void Image::loadRGBA5551DataToRGBA(GLsizei width, GLsizei height,
dest[4 * x + 3] = (rgba & 0x0001) ? 0xFF : 0; dest[4 * x + 3] = (rgba & 0x0001) ? 0xFF : 0;
} }
} }
}
} }
void Image::loadRGBAFloatDataToRGBA(GLsizei width, GLsizei height, void Image::loadRGBAFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const float *source = NULL; const float *source = NULL;
float *dest = NULL; float *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputPitch); source = reinterpret_cast<const float*>(static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch);
dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputPitch); dest = reinterpret_cast<float*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch);
memcpy(dest, source, width * 16); memcpy(dest, source, width * 16);
} }
}
} }
void Image::loadRGBAHalfFloatDataToRGBA(GLsizei width, GLsizei height, void Image::loadRGBAHalfFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned char *source = NULL; const unsigned char *source = NULL;
unsigned char *dest = NULL; unsigned char *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = static_cast<const unsigned char*>(input) + y * inputPitch; source = static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch;
dest = static_cast<unsigned char*>(output) + y * outputPitch; dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch;
memcpy(dest, source, width * 8); memcpy(dest, source, width * 8);
} }
}
} }
void Image::loadBGRADataToBGRA(GLsizei width, GLsizei height, void Image::loadBGRADataToBGRA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned char *source = NULL; const unsigned char *source = NULL;
unsigned char *dest = NULL; unsigned char *dest = NULL;
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = static_cast<const unsigned char*>(input) + y * inputPitch; source = static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch;
dest = static_cast<unsigned char*>(output) + y * outputPitch; dest = static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch;
memcpy(dest, source, width*4); memcpy(dest, source, width*4);
} }
}
} }
} }
...@@ -32,6 +32,7 @@ class Image ...@@ -32,6 +32,7 @@ class Image
GLsizei getWidth() const { return mWidth; } GLsizei getWidth() const { return mWidth; }
GLsizei getHeight() const { return mHeight; } GLsizei getHeight() const { return mHeight; }
GLsizei getDepth() const { return mDepth; }
GLenum getInternalFormat() const { return mInternalFormat; } GLenum getInternalFormat() const { return mInternalFormat; }
GLenum getActualFormat() const { return mActualFormat; } GLenum getActualFormat() const { return mActualFormat; }
...@@ -44,79 +45,111 @@ class Image ...@@ -44,79 +45,111 @@ class Image
virtual bool updateSurface(TextureStorageInterface2D *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0; virtual bool updateSurface(TextureStorageInterface2D *storage, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0;
virtual bool updateSurface(TextureStorageInterfaceCube *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0; virtual bool updateSurface(TextureStorageInterfaceCube *storage, int face, int level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height) = 0;
virtual bool redefine(Renderer *renderer, GLint internalformat, GLsizei width, GLsizei height, bool forceRelease) = 0; virtual bool redefine(Renderer *renderer, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease) = 0;
virtual bool isRenderableFormat() const = 0; virtual bool isRenderableFormat() const = 0;
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) = 0; GLint unpackAlignment, const void *input) = 0;
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) = 0; const void *input) = 0;
virtual void copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source) = 0; virtual void copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source) = 0;
static void loadAlphaDataToBGRA(GLsizei width, GLsizei height, static void loadAlphaDataToBGRA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output); int inputRowPitch, int inputDepthPitch, const void *input,
static void loadAlphaDataToNative(GLsizei width, GLsizei height, size_t outputRowPitch, size_t outputDepthPitch, void *output);
int inputPitch, const void *input, size_t outputPitch, void *output); static void loadAlphaDataToNative(GLsizei width, GLsizei height, GLsizei depth,
static void loadAlphaDataToBGRASSE2(GLsizei width, GLsizei height, int inputRowPitch, int inputDepthPitch, const void *input,
int inputPitch, const void *input, size_t outputPitch, void *output); size_t outRowputPitch, size_t outputDepthPitch, void *output);
static void loadAlphaFloatDataToRGBA(GLsizei width, GLsizei height, static void loadAlphaDataToBGRASSE2(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output); int inputRowPitch, int inputDepthPitch, const void *input,
static void loadAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height, size_t outputRowPitch, size_t outputDepthPitch, void *output);
int inputPitch, const void *input, size_t outputPitch, void *output); static void loadAlphaFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
static void loadLuminanceDataToNativeOrBGRA(GLsizei width, GLsizei height, int inputRowPitch, int inputDepthPitch, const void *input,
int inputPitch, const void *input, size_t outputPitch, void *output, bool native); size_t outputRowPitch, size_t outputDepthPitch, void *output);
static void loadLuminanceFloatDataToRGBA(GLsizei width, GLsizei height, static void loadAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output); int inputRowPitch, int inputDepthPitch, const void *input,
static void loadLuminanceFloatDataToRGB(GLsizei width, GLsizei height, size_t outputRowPitch, size_t outputDepthPitch, void *output);
int inputPitch, const void *input, size_t outputPitch, void *output); static void loadLuminanceDataToNativeOrBGRA(GLsizei width, GLsizei height, GLsizei depth,
static void loadLuminanceHalfFloatDataToRGBA(GLsizei width, GLsizei height, int inputRowPitch, int inputDepthPitch, const void *input,
int inputPitch, const void *input, size_t outputPitch, void *output); size_t outputRowPitch, size_t outputDepthPitch, void *output,
static void loadLuminanceAlphaDataToNativeOrBGRA(GLsizei width, GLsizei height, bool native);
int inputPitch, const void *input, size_t outputPitch, void *output, bool native); static void loadLuminanceFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
static void loadLuminanceAlphaFloatDataToRGBA(GLsizei width, GLsizei height, int inputRowPitch, int inputDepthPitch, const void *input,
int inputPitch, const void *input, size_t outputPitch, void *output); size_t outputRowPitch, size_t outputDepthPitch, void *output);
static void loadLuminanceAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height, static void loadLuminanceFloatDataToRGB(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output); int inputRowPitch, int inputDepthPitch, const void *input,
static void loadRGBUByteDataToBGRX(GLsizei width, GLsizei height, size_t outputRowPitch, size_t outputDepthPitch, void *output);
int inputPitch, const void *input, size_t outputPitch, void *output); static void loadLuminanceHalfFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
static void loadRGBUByteDataToRGBA(GLsizei width, GLsizei height, int inputRowPitch, int inputDepthPitch, const void *input,
int inputPitch, const void *input, size_t outputPitch, void *output); size_t outputRowPitch, size_t outputDepthPitch, void *output);
static void loadRGB565DataToBGRA(GLsizei width, GLsizei height, static void loadLuminanceAlphaDataToNativeOrBGRA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output); int inputRowPitch, int inputDepthPitch, const void *input,
static void loadRGB565DataToRGBA(GLsizei width, GLsizei height, size_t outputRowPitch, size_t outputDepthPitch, void *output,
int inputPitch, const void *input, size_t outputPitch, void *output); bool native);
static void loadRGBFloatDataToRGBA(GLsizei width, GLsizei height, static void loadLuminanceAlphaFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output); int inputRowPitch, int inputDepthPitch, const void *input,
static void loadRGBFloatDataToNative(GLsizei width, GLsizei height, size_t outputRowPitch, size_t outputDepthPitch, void *output);
int inputPitch, const void *input, size_t outputPitch, void *output); static void loadLuminanceAlphaHalfFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
static void loadRGBHalfFloatDataToRGBA(GLsizei width, GLsizei height, int inputRowPitch, int inputDepthPitch, const void *input,
int inputPitch, const void *input, size_t outputPitch, void *output); size_t outputRowPitch, size_t outputDepthPitch, void *output);
static void loadRGBAUByteDataToBGRASSE2(GLsizei width, GLsizei height, static void loadRGBUByteDataToBGRX(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output); int inputRowPitch, int inputDepthPitch, const void *input,
static void loadRGBAUByteDataToBGRA(GLsizei width, GLsizei height, size_t outputRowPitch, size_t outputDepthPitch, void *output);
int inputPitch, const void *input, size_t outputPitch, void *output); static void loadRGBUByteDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
static void loadRGBAUByteDataToNative(GLsizei width, GLsizei height, int inputRowPitch, int inputDepthPitch, const void *input,
int inputPitch, const void *input, size_t outputPitch, void *output); size_t outputRowPitch, size_t outputDepthPitch, void *output);
static void loadRGBA4444DataToBGRA(GLsizei width, GLsizei height, static void loadRGB565DataToBGRA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output); int inputRowPitch, int inputDepthPitch, const void *input,
static void loadRGBA4444DataToRGBA(GLsizei width, GLsizei height, size_t outputRowPitch, size_t outputDepthPitch, void *output);
int inputPitch, const void *input, size_t outputPitch, void *output); static void loadRGB565DataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
static void loadRGBA5551DataToBGRA(GLsizei width, GLsizei height, int inputRowPitch, int inputDepthPitch, const void *input,
int inputPitch, const void *input, size_t outputPitch, void *output); size_t outputRowPitch, size_t outputDepthPitch, void *output);
static void loadRGBA5551DataToRGBA(GLsizei width, GLsizei height, static void loadRGBFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output); int inputRowPitch, int inputDepthPitch, const void *input,
static void loadRGBAFloatDataToRGBA(GLsizei width, GLsizei height, size_t outputRowPitch, size_t outputDepthPitch, void *output);
int inputPitch, const void *input, size_t outputPitch, void *output); static void loadRGBFloatDataToNative(GLsizei width, GLsizei height, GLsizei depth,
static void loadRGBAHalfFloatDataToRGBA(GLsizei width, GLsizei height, int inputRowPitch, int inputDepthPitch, const void *input,
int inputPitch, const void *input, size_t outputPitch, void *output); size_t outputRowPitch, size_t outputDepthPitch, void *output);
static void loadBGRADataToBGRA(GLsizei width, GLsizei height, static void loadRGBHalfFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output); int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output);
static void loadRGBAUByteDataToBGRASSE2(GLsizei width, GLsizei height, GLsizei depth,
int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output);
static void loadRGBAUByteDataToBGRA(GLsizei width, GLsizei height, GLsizei depth,
int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output);
static void loadRGBAUByteDataToNative(GLsizei width, GLsizei height, GLsizei depth,
int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output);
static void loadRGBA4444DataToBGRA(GLsizei width, GLsizei height, GLsizei depth,
int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output);
static void loadRGBA4444DataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output);
static void loadRGBA5551DataToBGRA(GLsizei width, GLsizei height, GLsizei depth,
int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output);
static void loadRGBA5551DataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output);
static void loadRGBAFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output);
static void loadRGBAHalfFloatDataToRGBA(GLsizei width, GLsizei height, GLsizei depth,
int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output);
static void loadBGRADataToBGRA(GLsizei width, GLsizei height, GLsizei depth,
int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output);
protected: protected:
GLsizei mWidth; GLsizei mWidth;
GLsizei mHeight; GLsizei mHeight;
GLsizei mDepth;
GLint mInternalFormat; GLint mInternalFormat;
GLenum mActualFormat; GLenum mActualFormat;
......
...@@ -123,7 +123,7 @@ bool Image11::updateSurface(TextureStorageInterfaceCube *storage, int face, int ...@@ -123,7 +123,7 @@ bool Image11::updateSurface(TextureStorageInterfaceCube *storage, int face, int
return storage11->updateSubresourceLevel(getStagingTexture(), getStagingSubresource(), level, face, xoffset, yoffset, width, height); return storage11->updateSubresourceLevel(getStagingTexture(), getStagingSubresource(), level, face, xoffset, yoffset, width, height);
} }
bool Image11::redefine(Renderer *renderer, GLint internalformat, GLsizei width, GLsizei height, bool forceRelease) bool Image11::redefine(Renderer *renderer, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, bool forceRelease)
{ {
if (mWidth != width || if (mWidth != width ||
mHeight != height || mHeight != height ||
...@@ -134,6 +134,7 @@ bool Image11::redefine(Renderer *renderer, GLint internalformat, GLsizei width, ...@@ -134,6 +134,7 @@ bool Image11::redefine(Renderer *renderer, GLint internalformat, GLsizei width,
mWidth = width; mWidth = width;
mHeight = height; mHeight = height;
mDepth = depth;
mInternalFormat = internalformat; mInternalFormat = internalformat;
// compute the d3d format that will be used // compute the d3d format that will be used
mDXGIFormat = gl_d3d11::ConvertTextureFormat(internalformat); mDXGIFormat = gl_d3d11::ConvertTextureFormat(internalformat);
...@@ -167,7 +168,7 @@ DXGI_FORMAT Image11::getDXGIFormat() const ...@@ -167,7 +168,7 @@ DXGI_FORMAT Image11::getDXGIFormat() const
// Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input // Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input
// into the target pixel rectangle. // into the target pixel rectangle.
void Image11::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, const void *input) GLint unpackAlignment, const void *input)
{ {
D3D11_MAPPED_SUBRESOURCE mappedImage; D3D11_MAPPED_SUBRESOURCE mappedImage;
...@@ -178,68 +179,69 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig ...@@ -178,68 +179,69 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig
return; return;
} }
GLsizei inputPitch = gl::ComputePitch(width, mInternalFormat, unpackAlignment); GLsizei inputRowPitch = gl::ComputeRowPitch(width, mInternalFormat, unpackAlignment);
GLsizei inputDepthPitch = gl::ComputeDepthPitch(width, height, mInternalFormat, unpackAlignment);
size_t pixelSize = d3d11::ComputePixelSizeBits(mDXGIFormat) / 8; size_t pixelSize = d3d11::ComputePixelSizeBits(mDXGIFormat) / 8;
void* offsetMappedData = (void*)((BYTE *)mappedImage.pData + (yoffset * mappedImage.RowPitch + xoffset * pixelSize)); void* offsetMappedData = (void*)((BYTE *)mappedImage.pData + (yoffset * mappedImage.RowPitch + xoffset * pixelSize + zoffset * mappedImage.DepthPitch));
switch (mInternalFormat) switch (mInternalFormat)
{ {
case GL_ALPHA8_EXT: case GL_ALPHA8_EXT:
loadAlphaDataToNative(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); loadAlphaDataToNative(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break; break;
case GL_LUMINANCE8_EXT: case GL_LUMINANCE8_EXT:
loadLuminanceDataToNativeOrBGRA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData, false); loadLuminanceDataToNativeOrBGRA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData, false);
break; break;
case GL_ALPHA32F_EXT: case GL_ALPHA32F_EXT:
loadAlphaFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); loadAlphaFloatDataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break; break;
case GL_LUMINANCE32F_EXT: case GL_LUMINANCE32F_EXT:
loadLuminanceFloatDataToRGB(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); loadLuminanceFloatDataToRGB(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break; break;
case GL_ALPHA16F_EXT: case GL_ALPHA16F_EXT:
loadAlphaHalfFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); loadAlphaHalfFloatDataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break; break;
case GL_LUMINANCE16F_EXT: case GL_LUMINANCE16F_EXT:
loadLuminanceHalfFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); loadLuminanceHalfFloatDataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break; break;
case GL_LUMINANCE8_ALPHA8_EXT: case GL_LUMINANCE8_ALPHA8_EXT:
loadLuminanceAlphaDataToNativeOrBGRA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData, false); loadLuminanceAlphaDataToNativeOrBGRA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData, false);
break; break;
case GL_LUMINANCE_ALPHA32F_EXT: case GL_LUMINANCE_ALPHA32F_EXT:
loadLuminanceAlphaFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); loadLuminanceAlphaFloatDataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break; break;
case GL_LUMINANCE_ALPHA16F_EXT: case GL_LUMINANCE_ALPHA16F_EXT:
loadLuminanceAlphaHalfFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); loadLuminanceAlphaHalfFloatDataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break; break;
case GL_RGB8_OES: case GL_RGB8_OES:
loadRGBUByteDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); loadRGBUByteDataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break; break;
case GL_RGB565: case GL_RGB565:
loadRGB565DataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); loadRGB565DataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break; break;
case GL_RGBA8_OES: case GL_RGBA8_OES:
loadRGBAUByteDataToNative(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); loadRGBAUByteDataToNative(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break; break;
case GL_RGBA4: case GL_RGBA4:
loadRGBA4444DataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); loadRGBA4444DataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break; break;
case GL_RGB5_A1: case GL_RGB5_A1:
loadRGBA5551DataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); loadRGBA5551DataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break; break;
case GL_BGRA8_EXT: case GL_BGRA8_EXT:
loadBGRADataToBGRA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); loadBGRADataToBGRA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break; break;
case GL_RGB32F_EXT: case GL_RGB32F_EXT:
loadRGBFloatDataToNative(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); loadRGBFloatDataToNative(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break; break;
case GL_RGB16F_EXT: case GL_RGB16F_EXT:
loadRGBHalfFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); loadRGBHalfFloatDataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break; break;
case GL_RGBA32F_EXT: case GL_RGBA32F_EXT:
loadRGBAFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); loadRGBAFloatDataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break; break;
case GL_RGBA16F_EXT: case GL_RGBA16F_EXT:
loadRGBAHalfFloatDataToRGBA(width, height, inputPitch, input, mappedImage.RowPitch, offsetMappedData); loadRGBAHalfFloatDataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break; break;
default: UNREACHABLE(); default: UNREACHABLE();
} }
...@@ -247,7 +249,7 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig ...@@ -247,7 +249,7 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig
unmap(); unmap();
} }
void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
const void *input) const void *input)
{ {
ASSERT(xoffset % 4 == 0); ASSERT(xoffset % 4 == 0);
...@@ -263,14 +265,22 @@ void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GL ...@@ -263,14 +265,22 @@ void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GL
// Size computation assumes a 4x4 block compressed texture format // Size computation assumes a 4x4 block compressed texture format
size_t blockSize = d3d11::ComputeBlockSizeBits(mDXGIFormat) / 8; size_t blockSize = d3d11::ComputeBlockSizeBits(mDXGIFormat) / 8;
void* offsetMappedData = (void*)((BYTE *)mappedImage.pData + ((yoffset / 4) * mappedImage.RowPitch + (xoffset / 4) * blockSize)); void* offsetMappedData = (void*)((BYTE*)mappedImage.pData + ((yoffset / 4) * mappedImage.RowPitch + (xoffset / 4) * blockSize + zoffset * mappedImage.DepthPitch));
GLsizei inputSize = gl::ComputeCompressedSize(width, height, mInternalFormat); GLsizei inputSize = gl::ComputeCompressedSize(width, height, mInternalFormat);
GLsizei inputPitch = gl::ComputeCompressedPitch(width, mInternalFormat); GLsizei inputRowPitch = gl::ComputeCompressedRowPitch(width, mInternalFormat);
int rows = inputSize / inputPitch; GLsizei inputDepthPitch = gl::ComputeCompressedDepthPitch(width, height, mInternalFormat);
for (int i = 0; i < rows; ++i) int rows = inputSize / inputRowPitch;
for (int z = 0; z < depth; ++z)
{
for (int y = 0; y < rows; ++y)
{ {
memcpy((void*)((BYTE*)offsetMappedData + i * mappedImage.RowPitch), (void*)((BYTE*)input + i * inputPitch), inputPitch); void *source = (void*)((BYTE*)input + y * inputRowPitch + z * inputDepthPitch);
void *dest = (void*)((BYTE*)offsetMappedData + y * mappedImage.RowPitch + z * mappedImage.DepthPitch);
memcpy(dest, source, inputRowPitch);
}
} }
unmap(); unmap();
......
...@@ -41,14 +41,14 @@ class Image11 : public Image ...@@ -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(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 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; virtual bool isRenderableFormat() const;
DXGI_FORMAT getDXGIFormat() 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); 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); const void *input);
virtual void copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source); 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 ...@@ -141,10 +141,14 @@ void Image9::copyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface9 *so
else UNREACHABLE(); 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 || if (mWidth != width ||
mHeight != height || mHeight != height ||
mDepth != depth ||
mInternalFormat != internalformat || mInternalFormat != internalformat ||
forceRelease) forceRelease)
{ {
...@@ -152,6 +156,7 @@ bool Image9::redefine(rx::Renderer *renderer, GLint internalformat, GLsizei widt ...@@ -152,6 +156,7 @@ bool Image9::redefine(rx::Renderer *renderer, GLint internalformat, GLsizei widt
mWidth = width; mWidth = width;
mHeight = height; mHeight = height;
mDepth = depth;
mInternalFormat = internalformat; mInternalFormat = internalformat;
// compute the d3d format that will be used // compute the d3d format that will be used
mD3DFormat = mRenderer->ConvertTextureInternalFormat(internalformat); mD3DFormat = mRenderer->ConvertTextureInternalFormat(internalformat);
...@@ -351,9 +356,12 @@ bool Image9::updateSurface(IDirect3DSurface9 *destSurface, GLint xoffset, GLint ...@@ -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 // Store the pixel rectangle designated by xoffset,yoffset,width,height with pixels stored as format/type at input
// into the target pixel rectangle. // into the target pixel rectangle.
void Image9::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, void Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, const void *input) GLint unpackAlignment, const void *input)
{ {
// 3D textures are not supported by the D3D9 backend.
ASSERT(zoffset == 0 && depth == 1);
RECT lockRect = RECT lockRect =
{ {
xoffset, yoffset, xoffset, yoffset,
...@@ -368,81 +376,81 @@ void Image9::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heigh ...@@ -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) switch (mInternalFormat)
{ {
case GL_ALPHA8_EXT: case GL_ALPHA8_EXT:
if (gl::supportsSSE2()) 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 else
{ {
loadAlphaDataToBGRA(width, height, inputPitch, input, locked.Pitch, locked.pBits); loadAlphaDataToBGRA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
} }
break; break;
case GL_LUMINANCE8_EXT: 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; break;
case GL_ALPHA32F_EXT: 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; break;
case GL_LUMINANCE32F_EXT: 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; break;
case GL_ALPHA16F_EXT: 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; break;
case GL_LUMINANCE16F_EXT: 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; break;
case GL_LUMINANCE8_ALPHA8_EXT: 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; break;
case GL_LUMINANCE_ALPHA32F_EXT: 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; break;
case GL_LUMINANCE_ALPHA16F_EXT: 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; break;
case GL_RGB8_OES: 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; break;
case GL_RGB565: 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; break;
case GL_RGBA8_OES: case GL_RGBA8_OES:
if (gl::supportsSSE2()) 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 else
{ {
loadRGBAUByteDataToBGRA(width, height, inputPitch, input, locked.Pitch, locked.pBits); loadRGBAUByteDataToBGRA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
} }
break; break;
case GL_RGBA4: 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; break;
case GL_RGB5_A1: 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; break;
case GL_BGRA8_EXT: 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; break;
// float textures are converted to RGBA, not BGRA, as they're stored that way in D3D // float textures are converted to RGBA, not BGRA, as they're stored that way in D3D
case GL_RGB32F_EXT: 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; break;
case GL_RGB16F_EXT: 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; break;
case GL_RGBA32F_EXT: 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; break;
case GL_RGBA16F_EXT: 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; break;
default: UNREACHABLE(); default: UNREACHABLE();
} }
...@@ -450,12 +458,15 @@ void Image9::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heigh ...@@ -450,12 +458,15 @@ void Image9::loadData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heigh
unlock(); 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) const void *input)
{ {
ASSERT(xoffset % 4 == 0); ASSERT(xoffset % 4 == 0);
ASSERT(yoffset % 4 == 0); ASSERT(yoffset % 4 == 0);
// 3D textures are not supported by the D3D9 backend.
ASSERT(zoffset == 0 && depth == 1);
RECT lockRect = { RECT lockRect = {
xoffset, yoffset, xoffset, yoffset,
xoffset + width, yoffset + height xoffset + width, yoffset + height
...@@ -469,7 +480,7 @@ void Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLs ...@@ -469,7 +480,7 @@ void Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLs
} }
GLsizei inputSize = gl::ComputeCompressedSize(width, height, mInternalFormat); GLsizei inputSize = gl::ComputeCompressedSize(width, height, mInternalFormat);
GLsizei inputPitch = gl::ComputeCompressedPitch(width, mInternalFormat); GLsizei inputPitch = gl::ComputeCompressedRowPitch(width, mInternalFormat);
int rows = inputSize / inputPitch; int rows = inputSize / inputPitch;
for (int i = 0; i < rows; ++i) for (int i = 0; i < rows; ++i)
{ {
......
...@@ -37,7 +37,7 @@ class Image9 : public Image ...@@ -37,7 +37,7 @@ class Image9 : public Image
static void generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9 *sourceSurface); static void generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9 *sourceSurface);
static void copyLockableSurfaces(IDirect3DSurface9 *dest, IDirect3DSurface9 *source); 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; virtual bool isRenderableFormat() const;
D3DFORMAT getD3DFormat() const; D3DFORMAT getD3DFormat() const;
...@@ -50,9 +50,9 @@ class Image9 : public Image ...@@ -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(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 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); 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); const void *input);
virtual void copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source); virtual void copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, gl::Framebuffer *source);
......
...@@ -15,17 +15,20 @@ ...@@ -15,17 +15,20 @@
namespace rx namespace rx
{ {
void Image::loadRGBAUByteDataToBGRASSE2(GLsizei width, GLsizei height, void Image::loadRGBAUByteDataToBGRASSE2(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned int *source = NULL; const unsigned int *source = NULL;
unsigned int *dest = NULL; unsigned int *dest = NULL;
__m128i brMask = _mm_set1_epi32(0x00ff00ff); __m128i brMask = _mm_set1_epi32(0x00ff00ff);
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = reinterpret_cast<const unsigned int*>(static_cast<const unsigned char*>(input) + y * inputPitch); 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 * outputPitch); dest = reinterpret_cast<unsigned int*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch);
int x = 0; int x = 0;
// Make output writes aligned // Make output writes aligned
...@@ -55,19 +58,23 @@ void Image::loadRGBAUByteDataToBGRASSE2(GLsizei width, GLsizei height, ...@@ -55,19 +58,23 @@ void Image::loadRGBAUByteDataToBGRASSE2(GLsizei width, GLsizei height,
dest[x] = (_rotl(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00); dest[x] = (_rotl(rgba, 16) & 0x00ff00ff) | (rgba & 0xff00ff00);
} }
} }
}
} }
void Image::loadAlphaDataToBGRASSE2(GLsizei width, GLsizei height, void Image::loadAlphaDataToBGRASSE2(GLsizei width, GLsizei height, GLsizei depth,
int inputPitch, const void *input, size_t outputPitch, void *output) int inputRowPitch, int inputDepthPitch, const void *input,
size_t outputRowPitch, size_t outputDepthPitch, void *output)
{ {
const unsigned char *source = NULL; const unsigned char *source = NULL;
unsigned int *dest = NULL; unsigned int *dest = NULL;
__m128i zeroWide = _mm_setzero_si128(); __m128i zeroWide = _mm_setzero_si128();
for (int z = 0; z < depth; z++)
{
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
source = static_cast<const unsigned char*>(input) + y * inputPitch; source = static_cast<const unsigned char*>(input) + y * inputRowPitch + z * inputDepthPitch;
dest = reinterpret_cast<unsigned int*>(static_cast<unsigned char*>(output) + y * outputPitch); dest = reinterpret_cast<unsigned int*>(static_cast<unsigned char*>(output) + y * outputRowPitch + z * outputDepthPitch);
int x; int x;
// Make output writes aligned // Make output writes aligned
...@@ -95,6 +102,7 @@ void Image::loadAlphaDataToBGRASSE2(GLsizei width, GLsizei height, ...@@ -95,6 +102,7 @@ void Image::loadAlphaDataToBGRASSE2(GLsizei width, GLsizei height,
dest[x] = static_cast<unsigned int>(source[x]) << 24; dest[x] = static_cast<unsigned int>(source[x]) << 24;
} }
} }
}
} }
} }
...@@ -259,7 +259,7 @@ int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsig ...@@ -259,7 +259,7 @@ int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsig
return -1; return -1;
} }
GLsizei ComputePitch(GLsizei width, GLint internalformat, GLint alignment) GLsizei ComputeRowPitch(GLsizei width, GLint internalformat, GLint alignment)
{ {
ASSERT(alignment > 0 && isPow2(alignment)); ASSERT(alignment > 0 && isPow2(alignment));
...@@ -267,11 +267,21 @@ GLsizei ComputePitch(GLsizei width, GLint internalformat, GLint alignment) ...@@ -267,11 +267,21 @@ GLsizei ComputePitch(GLsizei width, GLint internalformat, GLint alignment)
return (rawPitch + alignment - 1) & ~(alignment - 1); 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); 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) GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum internalformat)
{ {
switch (internalformat) switch (internalformat)
......
...@@ -35,8 +35,10 @@ int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsig ...@@ -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); void MakeValidSize(bool isImage, bool isCompressed, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset);
int ComputePixelSize(GLint internalformat); int ComputePixelSize(GLint internalformat);
GLsizei ComputePitch(GLsizei width, GLint internalformat, GLint alignment); GLsizei ComputeRowPitch(GLsizei width, GLint internalformat, GLint alignment);
GLsizei ComputeCompressedPitch(GLsizei width, GLenum format); 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); GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum format);
bool IsCompressed(GLenum format); bool IsCompressed(GLenum format);
bool IsDepthTexture(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