Implements a special case for temporary surface creation for DXT low mip levels.

TRAC #12908 The lowest mip levels for DXT textures will have dimensions < 4, so a D3D texture cannot be created to hold them offscreen directly. Instead, we must create a larger texture one of whose mip levels would be the desired dimension, and store the surface from that texture for later inclusion in the final texture. Signed-off-by: Daniel Koch Author: Shannon Woods git-svn-id: https://angleproject.googlecode.com/svn/trunk@398 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 01868135
......@@ -320,7 +320,28 @@ void Texture::createSurface(GLsizei width, GLsizei height, GLenum format, Image
if (width != 0 && height != 0)
{
HRESULT result = getDevice()->CreateTexture(width, height, 1, NULL, selectFormat(format), D3DPOOL_SYSTEMMEM, &newTexture, NULL);
int levelToFetch = 0;
GLsizei requestWidth = width;
GLsizei requestHeight = height;
if (IsCompressed(format) && (width % 4 != 0 || height % 4 != 0))
{
bool isMult4 = false;
int upsampleCount = 0;
while (!isMult4)
{
requestWidth <<= 1;
requestHeight <<= 1;
upsampleCount++;
if (requestWidth % 4 == 0 && requestHeight % 4 == 0)
{
isMult4 = true;
}
}
levelToFetch = upsampleCount;
}
HRESULT result = getDevice()->CreateTexture(requestWidth, requestHeight, levelToFetch + 1, NULL, selectFormat(format),
D3DPOOL_SYSTEMMEM, &newTexture, NULL);
if (FAILED(result))
{
......@@ -328,7 +349,7 @@ void Texture::createSurface(GLsizei width, GLsizei height, GLenum format, Image
return error(GL_OUT_OF_MEMORY);
}
newTexture->GetSurfaceLevel(0, &newSurface);
newTexture->GetSurfaceLevel(levelToFetch, &newSurface);
newTexture->Release();
}
......
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