Texture image setting functions use the refactored texture conversion and loading functions.

TRAC #22972 Signed-off-by: Jamie Madill Signed-off-by: Nicolas Capens Author: Geoff Lang git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2316 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent ed0adcf6
...@@ -216,11 +216,11 @@ bool Texture::isMipmapFiltered() const ...@@ -216,11 +216,11 @@ bool Texture::isMipmapFiltered() const
} }
} }
void Texture::setImage(GLint unpackAlignment, const void *pixels, rx::Image *image) void Texture::setImage(GLint unpackAlignment, GLenum type, const void *pixels, rx::Image *image)
{ {
if (pixels != NULL) if (pixels != NULL)
{ {
image->loadData(0, 0, 0, image->getWidth(), image->getHeight(), image->getDepth(), unpackAlignment, pixels); image->loadData(0, 0, 0, image->getWidth(), image->getHeight(), image->getDepth(), unpackAlignment, type, pixels);
mDirtyImages = true; mDirtyImages = true;
} }
} }
...@@ -239,7 +239,7 @@ bool Texture::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei widt ...@@ -239,7 +239,7 @@ bool Texture::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei widt
{ {
if (pixels != NULL) if (pixels != NULL)
{ {
image->loadData(xoffset, yoffset, zoffset, width, height, depth, unpackAlignment, pixels); image->loadData(xoffset, yoffset, zoffset, width, height, depth, unpackAlignment, type, pixels);
mDirtyImages = true; mDirtyImages = true;
} }
...@@ -447,7 +447,7 @@ void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLint inter ...@@ -447,7 +447,7 @@ void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLint inter
: GetSizedInternalFormat(format, type, clientVersion); : GetSizedInternalFormat(format, type, clientVersion);
redefineImage(level, sizedInternalFormat, width, height); redefineImage(level, sizedInternalFormat, width, height);
Texture::setImage(unpackAlignment, pixels, mImageArray[level]); Texture::setImage(unpackAlignment, type, pixels, mImageArray[level]);
} }
void Texture2D::bindTexImage(egl::Surface *surface) void Texture2D::bindTexImage(egl::Surface *surface)
...@@ -524,8 +524,10 @@ void Texture2D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GL ...@@ -524,8 +524,10 @@ void Texture2D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GL
void Texture2D::copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) void Texture2D::copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source)
{ {
GLint internalformat = ConvertSizedInternalFormat(format, GL_UNSIGNED_BYTE); GLuint clientVersion = mRenderer->getCurrentClientVersion();
redefineImage(level, internalformat, width, height); GLint sizedInternalFormat = IsSizedInternalFormat(format, clientVersion) ? format
: GetSizedInternalFormat(format, GL_UNSIGNED_BYTE, clientVersion);
redefineImage(level, sizedInternalFormat, width, height);
if (!mImageArray[level]->isRenderableFormat()) if (!mImageArray[level]->isRenderableFormat())
{ {
...@@ -577,14 +579,16 @@ void Texture2D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yo ...@@ -577,14 +579,16 @@ void Texture2D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yo
if (level < levelCount()) if (level < levelCount())
{ {
GLuint clientVersion = mRenderer->getCurrentClientVersion();
gl::Rectangle sourceRect; gl::Rectangle sourceRect;
sourceRect.x = x; sourceRect.x = x;
sourceRect.width = width; sourceRect.width = width;
sourceRect.y = y; sourceRect.y = y;
sourceRect.height = height; sourceRect.height = height;
mRenderer->copyImage(source, sourceRect, mRenderer->copyImage(source, sourceRect,
gl::ExtractFormat(mImageArray[0]->getInternalFormat()), gl::GetFormat(mImageArray[0]->getInternalFormat(), clientVersion),
xoffset, yoffset, mTexStorage, level); xoffset, yoffset, mTexStorage, level);
} }
} }
...@@ -1261,7 +1265,7 @@ void TextureCubeMap::setImage(int faceIndex, GLint level, GLsizei width, GLsizei ...@@ -1261,7 +1265,7 @@ void TextureCubeMap::setImage(int faceIndex, GLint level, GLsizei width, GLsizei
redefineImage(faceIndex, level, sizedInternalFormat, width, height); redefineImage(faceIndex, level, sizedInternalFormat, width, height);
Texture::setImage(unpackAlignment, pixels, mImageArray[faceIndex][level]); Texture::setImage(unpackAlignment, type, pixels, mImageArray[faceIndex][level]);
} }
unsigned int TextureCubeMap::faceIndex(GLenum face) unsigned int TextureCubeMap::faceIndex(GLenum face)
...@@ -1312,8 +1316,10 @@ void TextureCubeMap::redefineImage(int face, GLint level, GLint internalformat, ...@@ -1312,8 +1316,10 @@ void TextureCubeMap::redefineImage(int face, GLint level, GLint internalformat,
void TextureCubeMap::copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) void TextureCubeMap::copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source)
{ {
unsigned int faceindex = faceIndex(target); unsigned int faceindex = faceIndex(target);
GLint internalformat = gl::ConvertSizedInternalFormat(format, GL_UNSIGNED_BYTE); GLuint clientVersion = mRenderer->getCurrentClientVersion();
redefineImage(faceindex, level, internalformat, width, height); GLint sizedInternalFormat = IsSizedInternalFormat(format, clientVersion) ? format
: GetSizedInternalFormat(format, GL_UNSIGNED_BYTE, clientVersion);
redefineImage(faceindex, level, sizedInternalFormat, width, height);
if (!mImageArray[faceindex][level]->isRenderableFormat()) if (!mImageArray[faceindex][level]->isRenderableFormat())
{ {
...@@ -1371,13 +1377,15 @@ void TextureCubeMap::copySubImage(GLenum target, GLint level, GLint xoffset, GLi ...@@ -1371,13 +1377,15 @@ void TextureCubeMap::copySubImage(GLenum target, GLint level, GLint xoffset, GLi
if (level < levelCount()) if (level < levelCount())
{ {
GLuint clientVersion = mRenderer->getCurrentClientVersion();
gl::Rectangle sourceRect; gl::Rectangle sourceRect;
sourceRect.x = x; sourceRect.x = x;
sourceRect.width = width; sourceRect.width = width;
sourceRect.y = y; sourceRect.y = y;
sourceRect.height = height; sourceRect.height = height;
mRenderer->copyImage(source, sourceRect, gl::ExtractFormat(mImageArray[0][0]->getInternalFormat()), mRenderer->copyImage(source, sourceRect, gl::GetFormat(mImageArray[0][0]->getInternalFormat(), clientVersion),
xoffset, yoffset, mTexStorage, target, level); xoffset, yoffset, mTexStorage, target, level);
} }
} }
...@@ -1611,7 +1619,7 @@ void Texture3D::setImage(GLint level, GLsizei width, GLsizei height, GLsizei dep ...@@ -1611,7 +1619,7 @@ void Texture3D::setImage(GLint level, GLsizei width, GLsizei height, GLsizei dep
: GetSizedInternalFormat(format, type, clientVersion); : GetSizedInternalFormat(format, type, clientVersion);
redefineImage(level, sizedInternalFormat, width, height, depth); redefineImage(level, sizedInternalFormat, width, height, depth);
Texture::setImage(unpackAlignment, pixels, mImageArray[level]); Texture::setImage(unpackAlignment, type, pixels, mImageArray[level]);
} }
void Texture3D::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels) void Texture3D::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels)
...@@ -1728,8 +1736,10 @@ void Texture3D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yo ...@@ -1728,8 +1736,10 @@ void Texture3D::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yo
sourceRect.y = y; sourceRect.y = y;
sourceRect.height = height; sourceRect.height = height;
GLuint clientVersion = mRenderer->getCurrentClientVersion();
mRenderer->copyImage(source, sourceRect, mRenderer->copyImage(source, sourceRect,
gl::ExtractFormat(mImageArray[0]->getInternalFormat()), gl::GetFormat(mImageArray[0]->getInternalFormat(), clientVersion),
xoffset, yoffset, zoffset, mTexStorage, level); xoffset, yoffset, zoffset, mTexStorage, level);
} }
} }
...@@ -2053,12 +2063,12 @@ void Texture2DArray::setImage(GLint level, GLsizei width, GLsizei height, GLsize ...@@ -2053,12 +2063,12 @@ void Texture2DArray::setImage(GLint level, GLsizei width, GLsizei height, GLsize
: GetSizedInternalFormat(format, type, clientVersion); : GetSizedInternalFormat(format, type, clientVersion);
redefineImage(level, sizedInternalFormat, width, height, depth); redefineImage(level, sizedInternalFormat, width, height, depth);
GLsizei inputDepthPitch = gl::ComputeDepthPitch(width, height, sizedInternalFormat, unpackAlignment); GLsizei inputDepthPitch = gl::GetDepthPitch(sizedInternalFormat, type, clientVersion, width, height, unpackAlignment);
for (int i = 0; i < depth; i++) for (int i = 0; i < depth; i++)
{ {
const void *layerPixels = reinterpret_cast<const unsigned char*>(pixels) + (inputDepthPitch * i); const void *layerPixels = reinterpret_cast<const unsigned char*>(pixels) + (inputDepthPitch * i);
Texture::setImage(unpackAlignment, layerPixels, mImageArray[level][i]); Texture::setImage(unpackAlignment, type, layerPixels, mImageArray[level][i]);
} }
} }
...@@ -2067,7 +2077,8 @@ void Texture2DArray::setCompressedImage(GLint level, GLenum format, GLsizei widt ...@@ -2067,7 +2077,8 @@ void Texture2DArray::setCompressedImage(GLint level, GLenum format, GLsizei widt
// compressed formats don't have separate sized internal formats-- we can just use the compressed format directly // compressed formats don't have separate sized internal formats-- we can just use the compressed format directly
redefineImage(level, format, width, height, depth); redefineImage(level, format, width, height, depth);
GLsizei inputDepthPitch = gl::ComputeCompressedDepthPitch(width, height, format); GLuint clientVersion = mRenderer->getCurrentClientVersion();
GLsizei inputDepthPitch = gl::GetDepthPitch(format, GL_UNSIGNED_BYTE, clientVersion, width, height, 1);
for (int i = 0; i < depth; i++) for (int i = 0; i < depth; i++)
{ {
...@@ -2078,8 +2089,9 @@ void Texture2DArray::setCompressedImage(GLint level, GLenum format, GLsizei widt ...@@ -2078,8 +2089,9 @@ void Texture2DArray::setCompressedImage(GLint level, GLenum format, GLsizei widt
void Texture2DArray::subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels) void Texture2DArray::subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
{ {
GLint internalformat = ConvertSizedInternalFormat(format, type); GLint internalformat = getInternalFormat(level);
GLsizei inputDepthPitch = gl::ComputeDepthPitch(width, height, internalformat, unpackAlignment); GLuint clientVersion = mRenderer->getCurrentClientVersion();
GLsizei inputDepthPitch = gl::GetDepthPitch(internalformat, type, width, height, clientVersion, unpackAlignment);
for (int i = 0; i < depth; i++) for (int i = 0; i < depth; i++)
{ {
...@@ -2095,7 +2107,8 @@ void Texture2DArray::subImage(GLint level, GLint xoffset, GLint yoffset, GLint z ...@@ -2095,7 +2107,8 @@ void Texture2DArray::subImage(GLint level, GLint xoffset, GLint yoffset, GLint z
void Texture2DArray::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels) void Texture2DArray::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels)
{ {
GLsizei inputDepthPitch = gl::ComputeCompressedDepthPitch(width, height, format); GLuint clientVersion = mRenderer->getCurrentClientVersion();
GLsizei inputDepthPitch = gl::GetDepthPitch(format, GL_UNSIGNED_BYTE, clientVersion, width, height, 1);
for (int i = 0; i < depth; i++) for (int i = 0; i < depth; i++)
{ {
...@@ -2214,13 +2227,15 @@ void Texture2DArray::copySubImage(GLenum target, GLint level, GLint xoffset, GLi ...@@ -2214,13 +2227,15 @@ void Texture2DArray::copySubImage(GLenum target, GLint level, GLint xoffset, GLi
if (level < levelCount()) if (level < levelCount())
{ {
GLuint clientVersion = mRenderer->getCurrentClientVersion();
gl::Rectangle sourceRect; gl::Rectangle sourceRect;
sourceRect.x = x; sourceRect.x = x;
sourceRect.width = width; sourceRect.width = width;
sourceRect.y = y; sourceRect.y = y;
sourceRect.height = height; sourceRect.height = height;
mRenderer->copyImage(source, sourceRect, gl::ExtractFormat(getInternalFormat(0)), mRenderer->copyImage(source, sourceRect, gl::GetFormat(getInternalFormat(0), clientVersion),
xoffset, yoffset, zoffset, mTexStorage, level); xoffset, yoffset, zoffset, mTexStorage, level);
} }
} }
......
...@@ -106,7 +106,7 @@ class Texture : public RefCountObject ...@@ -106,7 +106,7 @@ class Texture : public RefCountObject
static const GLuint INCOMPLETE_TEXTURE_ID = static_cast<GLuint>(-1); // Every texture takes an id at creation time. The value is arbitrary because it is never registered with the resource manager. static const GLuint INCOMPLETE_TEXTURE_ID = static_cast<GLuint>(-1); // Every texture takes an id at creation time. The value is arbitrary because it is never registered with the resource manager.
protected: protected:
void setImage(GLint unpackAlignment, const void *pixels, rx::Image *image); void setImage(GLint unpackAlignment, GLenum type, const void *pixels, rx::Image *image);
bool subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, 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); 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);
......
...@@ -57,7 +57,7 @@ class Image ...@@ -57,7 +57,7 @@ class Image
virtual bool isRenderableFormat() const = 0; virtual bool isRenderableFormat() const = 0;
virtual void loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, virtual void loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, const void *input) = 0; GLint unpackAlignment, GLenum type, const void *input) = 0;
virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
const void *input) = 0; const void *input) = 0;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "libGLESv2/main.h" #include "libGLESv2/main.h"
#include "libGLESv2/utilities.h" #include "libGLESv2/utilities.h"
#include "libGLESv2/renderer/formatutils11.h"
#include "libGLESv2/renderer/renderer11_utils.h" #include "libGLESv2/renderer/renderer11_utils.h"
#include "libGLESv2/renderer/generatemip.h" #include "libGLESv2/renderer/generatemip.h"
...@@ -182,8 +183,16 @@ DXGI_FORMAT Image11::getDXGIFormat() const ...@@ -182,8 +183,16 @@ 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, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, void Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, const void *input) GLint unpackAlignment, GLenum type, const void *input)
{ {
GLuint clientVersion = mRenderer->getCurrentClientVersion();
GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, type, clientVersion, width, unpackAlignment);
GLsizei inputDepthPitch = gl::GetDepthPitch(mInternalFormat, type, clientVersion, width, height, unpackAlignment);
GLuint outputPixelSize = d3d11::GetFormatPixelBytes(mDXGIFormat);
LoadImageFunction loadFunction = d3d11::GetImageLoadFunction(mInternalFormat, type, clientVersion);
ASSERT(loadFunction != NULL);
D3D11_MAPPED_SUBRESOURCE mappedImage; D3D11_MAPPED_SUBRESOURCE mappedImage;
HRESULT result = map(D3D11_MAP_WRITE, &mappedImage); HRESULT result = map(D3D11_MAP_WRITE, &mappedImage);
if (FAILED(result)) if (FAILED(result))
...@@ -192,72 +201,8 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei widt ...@@ -192,72 +201,8 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei widt
return; return;
} }
GLsizei inputRowPitch = gl::ComputeRowPitch(width, mInternalFormat, unpackAlignment); void* offsetMappedData = (void*)((BYTE *)mappedImage.pData + (yoffset * mappedImage.RowPitch + xoffset * outputPixelSize + zoffset * mappedImage.DepthPitch));
GLsizei inputDepthPitch = gl::ComputeDepthPitch(width, height, mInternalFormat, unpackAlignment); loadFunction(width, height, depth, input, inputRowPitch, inputDepthPitch, offsetMappedData, mappedImage.RowPitch, mappedImage.DepthPitch);
size_t pixelSize = d3d11::ComputePixelSizeBits(mDXGIFormat) / 8;
void* offsetMappedData = (void*)((BYTE *)mappedImage.pData + (yoffset * mappedImage.RowPitch + xoffset * pixelSize + zoffset * mappedImage.DepthPitch));
switch (mInternalFormat)
{
case GL_ALPHA8_EXT:
loadAlphaDataToNative(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break;
case GL_LUMINANCE8_EXT:
loadLuminanceDataToNativeOrBGRA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData, false);
break;
case GL_ALPHA32F_EXT:
loadAlphaFloatDataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break;
case GL_LUMINANCE32F_EXT:
loadLuminanceFloatDataToRGB(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break;
case GL_ALPHA16F_EXT:
loadAlphaHalfFloatDataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break;
case GL_LUMINANCE16F_EXT:
loadLuminanceHalfFloatDataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break;
case GL_LUMINANCE8_ALPHA8_EXT:
loadLuminanceAlphaDataToNativeOrBGRA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData, false);
break;
case GL_LUMINANCE_ALPHA32F_EXT:
loadLuminanceAlphaFloatDataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break;
case GL_LUMINANCE_ALPHA16F_EXT:
loadLuminanceAlphaHalfFloatDataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break;
case GL_RGB8_OES:
loadRGBUByteDataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break;
case GL_RGB565:
loadRGB565DataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break;
case GL_RGBA8_OES:
loadRGBAUByteDataToNative(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break;
case GL_RGBA4:
loadRGBA4444DataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break;
case GL_RGB5_A1:
loadRGBA5551DataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break;
case GL_BGRA8_EXT:
loadBGRADataToBGRA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break;
case GL_RGB32F_EXT:
loadRGBFloatDataToNative(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break;
case GL_RGB16F_EXT:
loadRGBHalfFloatDataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break;
case GL_RGBA32F_EXT:
loadRGBAFloatDataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break;
case GL_RGBA16F_EXT:
loadRGBAHalfFloatDataToRGBA(width, height, depth, inputRowPitch, inputDepthPitch, input, mappedImage.RowPitch, mappedImage.DepthPitch, offsetMappedData);
break;
default: UNREACHABLE();
}
unmap(); unmap();
} }
......
...@@ -49,7 +49,7 @@ class Image11 : public Image ...@@ -49,7 +49,7 @@ class Image11 : public Image
DXGI_FORMAT getDXGIFormat() const; DXGI_FORMAT getDXGIFormat() const;
virtual void loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, virtual void loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, const void *input); GLint unpackAlignment, GLenum type, const void *input);
virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
const void *input); const void *input);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "libGLESv2/renderer/TextureStorage9.h" #include "libGLESv2/renderer/TextureStorage9.h"
#include "libGLESv2/renderer/renderer9_utils.h" #include "libGLESv2/renderer/renderer9_utils.h"
#include "libGLESv2/renderer/formatutils9.h"
#include "libGLESv2/renderer/generatemip.h" #include "libGLESv2/renderer/generatemip.h"
namespace rx namespace rx
...@@ -374,11 +375,17 @@ bool Image9::updateSurface(IDirect3DSurface9 *destSurface, GLint xoffset, GLint ...@@ -374,11 +375,17 @@ 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, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, void Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, const void *input) GLint unpackAlignment, GLenum type, const void *input)
{ {
// 3D textures are not supported by the D3D9 backend. // 3D textures are not supported by the D3D9 backend.
ASSERT(zoffset == 0 && depth == 1); ASSERT(zoffset == 0 && depth == 1);
GLuint clientVersion = mRenderer->getCurrentClientVersion();
GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, type, clientVersion, width, unpackAlignment);
LoadImageFunction loadFunction = d3d9::GetImageLoadFunction(mInternalFormat, mRenderer);
ASSERT(loadFunction != NULL);
RECT lockRect = RECT lockRect =
{ {
xoffset, yoffset, xoffset, yoffset,
...@@ -392,85 +399,7 @@ void Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width ...@@ -392,85 +399,7 @@ void Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width
return; return;
} }
loadFunction(width, height, depth, input, inputRowPitch, 0, locked.pBits, locked.Pitch, 0);
GLsizei inputPitch = gl::ComputeRowPitch(width, mInternalFormat, unpackAlignment);
switch (mInternalFormat)
{
case GL_ALPHA8_EXT:
if (gl::supportsSSE2())
{
loadAlphaDataToBGRASSE2(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
}
else
{
loadAlphaDataToBGRA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
}
break;
case GL_LUMINANCE8_EXT:
loadLuminanceDataToNativeOrBGRA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits, getD3DFormat() == D3DFMT_L8);
break;
case GL_ALPHA32F_EXT:
loadAlphaFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_LUMINANCE32F_EXT:
loadLuminanceFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_ALPHA16F_EXT:
loadAlphaHalfFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_LUMINANCE16F_EXT:
loadLuminanceHalfFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_LUMINANCE8_ALPHA8_EXT:
loadLuminanceAlphaDataToNativeOrBGRA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits, getD3DFormat() == D3DFMT_A8L8);
break;
case GL_LUMINANCE_ALPHA32F_EXT:
loadLuminanceAlphaFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_LUMINANCE_ALPHA16F_EXT:
loadLuminanceAlphaHalfFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_RGB8_OES:
loadRGBUByteDataToBGRX(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_RGB565:
loadRGB565DataToBGRA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_RGBA8_OES:
if (gl::supportsSSE2())
{
loadRGBAUByteDataToBGRASSE2(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
}
else
{
loadRGBAUByteDataToBGRA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
}
break;
case GL_RGBA4:
loadRGBA4444DataToBGRA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_RGB5_A1:
loadRGBA5551DataToBGRA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_BGRA8_EXT:
loadBGRADataToBGRA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
// float textures are converted to RGBA, not BGRA, as they're stored that way in D3D
case GL_RGB32F_EXT:
loadRGBFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_RGB16F_EXT:
loadRGBHalfFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_RGBA32F_EXT:
loadRGBAFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
case GL_RGBA16F_EXT:
loadRGBAHalfFloatDataToRGBA(width, height, depth, inputPitch, 0, input, locked.Pitch, 0, locked.pBits);
break;
default: UNREACHABLE();
}
unlock(); unlock();
} }
......
...@@ -53,7 +53,7 @@ class Image9 : public Image ...@@ -53,7 +53,7 @@ class Image9 : public Image
virtual bool updateSurface(TextureStorageInterface2DArray *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height); virtual bool updateSurface(TextureStorageInterface2DArray *storage, int level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height);
virtual void loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, virtual void loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint unpackAlignment, const void *input); GLint unpackAlignment, GLenum type, const void *input);
virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, virtual void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
const void *input); const void *input);
......
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