Texture: Avoid attempting to create 0 sized D3D textures

Issue=301 Signed-off-by: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@1074 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 56c62636
#define MAJOR_VERSION 1 #define MAJOR_VERSION 1
#define MINOR_VERSION 0 #define MINOR_VERSION 0
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 1072 #define BUILD_REVISION 1074
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -1701,9 +1701,12 @@ TextureStorage2D::TextureStorage2D(IDirect3DTexture9 *surfaceTexture) : TextureS ...@@ -1701,9 +1701,12 @@ TextureStorage2D::TextureStorage2D(IDirect3DTexture9 *surfaceTexture) : TextureS
TextureStorage2D::TextureStorage2D(int levels, D3DFORMAT format, int width, int height, bool renderTarget) TextureStorage2D::TextureStorage2D(int levels, D3DFORMAT format, int width, int height, bool renderTarget)
: TextureStorage(renderTarget), mRenderTargetSerial(RenderbufferStorage::issueSerial()) : TextureStorage(renderTarget), mRenderTargetSerial(RenderbufferStorage::issueSerial())
{ {
IDirect3DDevice9 *device = getDevice();
mTexture = NULL; mTexture = NULL;
// if the width or height is not positive this should be treated as an incomplete texture
// we handle that here by skipping the d3d texture creation
if (width > 0 && height > 0)
{
IDirect3DDevice9 *device = getDevice();
HRESULT result = device->CreateTexture(width, height, levels, isRenderTarget() ? D3DUSAGE_RENDERTARGET : 0, format, getPool(), &mTexture, NULL); HRESULT result = device->CreateTexture(width, height, levels, isRenderTarget() ? D3DUSAGE_RENDERTARGET : 0, format, getPool(), &mTexture, NULL);
if (FAILED(result)) if (FAILED(result))
...@@ -1711,6 +1714,7 @@ TextureStorage2D::TextureStorage2D(int levels, D3DFORMAT format, int width, int ...@@ -1711,6 +1714,7 @@ TextureStorage2D::TextureStorage2D(int levels, D3DFORMAT format, int width, int
ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
error(GL_OUT_OF_MEMORY); error(GL_OUT_OF_MEMORY);
} }
}
} }
TextureStorage2D::~TextureStorage2D() TextureStorage2D::~TextureStorage2D()
...@@ -2382,9 +2386,12 @@ TextureStorage *Texture2D::getStorage(bool renderTarget) ...@@ -2382,9 +2386,12 @@ TextureStorage *Texture2D::getStorage(bool renderTarget)
TextureStorageCubeMap::TextureStorageCubeMap(int levels, D3DFORMAT format, int size, bool renderTarget) TextureStorageCubeMap::TextureStorageCubeMap(int levels, D3DFORMAT format, int size, bool renderTarget)
: TextureStorage(renderTarget), mFirstRenderTargetSerial(RenderbufferStorage::issueCubeSerials()) : TextureStorage(renderTarget), mFirstRenderTargetSerial(RenderbufferStorage::issueCubeSerials())
{ {
IDirect3DDevice9 *device = getDevice();
mTexture = NULL; mTexture = NULL;
// if the size is not positive this should be treated as an incomplete texture
// we handle that here by skipping the d3d texture creation
if (size > 0)
{
IDirect3DDevice9 *device = getDevice();
HRESULT result = device->CreateCubeTexture(size, levels, isRenderTarget() ? D3DUSAGE_RENDERTARGET : 0, format, getPool(), &mTexture, NULL); HRESULT result = device->CreateCubeTexture(size, levels, isRenderTarget() ? D3DUSAGE_RENDERTARGET : 0, format, getPool(), &mTexture, NULL);
if (FAILED(result)) if (FAILED(result))
...@@ -2392,6 +2399,7 @@ TextureStorageCubeMap::TextureStorageCubeMap(int levels, D3DFORMAT format, int s ...@@ -2392,6 +2399,7 @@ TextureStorageCubeMap::TextureStorageCubeMap(int levels, D3DFORMAT format, int s
ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
error(GL_OUT_OF_MEMORY); error(GL_OUT_OF_MEMORY);
} }
}
} }
TextureStorageCubeMap::~TextureStorageCubeMap() TextureStorageCubeMap::~TextureStorageCubeMap()
......
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