Image::loadCompressedData now uses new 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@2317 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 557aab05
...@@ -210,8 +210,19 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei widt ...@@ -210,8 +210,19 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei widt
void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, 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); GLuint clientVersion = mRenderer->getCurrentClientVersion();
ASSERT(yoffset % 4 == 0); GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion, width, 1);
GLsizei inputDepthPitch = gl::GetDepthPitch(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion, width, height, 1);
GLuint outputPixelSize = d3d11::GetFormatPixelBytes(mDXGIFormat);
GLuint outputBlockWidth = d3d11::GetBlockWidth(mDXGIFormat);
GLuint outputBlockHeight = d3d11::GetBlockHeight(mDXGIFormat);
ASSERT(xoffset % outputBlockWidth == 0);
ASSERT(yoffset % outputBlockHeight == 0);
LoadImageFunction loadFunction = d3d11::GetImageLoadFunction(mInternalFormat, GL_UNSIGNED_BYTE, 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);
...@@ -221,25 +232,12 @@ void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GL ...@@ -221,25 +232,12 @@ void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GL
return; return;
} }
// Size computation assumes a 4x4 block compressed texture format void* offsetMappedData = (void*)((BYTE*)mappedImage.pData + ((yoffset / outputBlockHeight) * mappedImage.RowPitch +
size_t blockSize = d3d11::ComputeBlockSizeBits(mDXGIFormat) / 8; (xoffset / outputBlockWidth) * outputPixelSize +
void* offsetMappedData = (void*)((BYTE*)mappedImage.pData + ((yoffset / 4) * mappedImage.RowPitch + (xoffset / 4) * blockSize + zoffset * mappedImage.DepthPitch)); zoffset * mappedImage.DepthPitch));
GLsizei inputSize = gl::ComputeCompressedSize(width, height, mInternalFormat); loadFunction(width, height, depth, input, inputRowPitch, inputDepthPitch,
GLsizei inputRowPitch = gl::ComputeCompressedRowPitch(width, mInternalFormat); offsetMappedData, mappedImage.RowPitch, mappedImage.DepthPitch);
GLsizei inputDepthPitch = gl::ComputeCompressedDepthPitch(width, height, mInternalFormat);
int rows = inputSize / inputRowPitch;
for (int z = 0; z < depth; ++z)
{
for (int y = 0; y < rows; ++y)
{
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();
} }
......
...@@ -407,13 +407,25 @@ void Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width ...@@ -407,13 +407,25 @@ void Image9::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width
void Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, 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(yoffset % 4 == 0);
// 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);
RECT lockRect = { GLuint clientVersion = mRenderer->getCurrentClientVersion();
GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion, width, 1);
GLsizei inputDepthPitch = gl::GetDepthPitch(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion, width, height, 1);
GLuint outputPixelSize = d3d9::GetFormatPixelBytes(mD3DFormat);
GLuint outputBlockWidth = d3d9::GetBlockWidth(mD3DFormat);
GLuint outputBlockHeight = d3d9::GetBlockHeight(mD3DFormat);
ASSERT(xoffset % outputBlockWidth == 0);
ASSERT(yoffset % outputBlockHeight == 0);
LoadImageFunction loadFunction = d3d9::GetImageLoadFunction(mInternalFormat, mRenderer);
ASSERT(loadFunction != NULL);
RECT lockRect =
{
xoffset, yoffset, xoffset, yoffset,
xoffset + width, yoffset + height xoffset + width, yoffset + height
}; };
...@@ -425,13 +437,8 @@ void Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLs ...@@ -425,13 +437,8 @@ void Image9::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLs
return; return;
} }
GLsizei inputSize = gl::ComputeCompressedSize(width, height, mInternalFormat); loadFunction(width, height, depth, input, inputRowPitch, inputDepthPitch,
GLsizei inputPitch = gl::ComputeCompressedRowPitch(width, mInternalFormat); locked.pBits, locked.Pitch, 0);
int rows = inputSize / inputPitch;
for (int i = 0; i < rows; ++i)
{
memcpy((void*)((BYTE*)locked.pBits + i * locked.Pitch), (void*)((BYTE*)input + i * inputPitch), inputPitch);
}
unlock(); unlock();
} }
......
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