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,15 +1701,19 @@ TextureStorage2D::TextureStorage2D(IDirect3DTexture9 *surfaceTexture) : TextureS ...@@ -1701,15 +1701,19 @@ 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;
HRESULT result = device->CreateTexture(width, height, levels, isRenderTarget() ? D3DUSAGE_RENDERTARGET : 0, format, getPool(), &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 (FAILED(result)) if (width > 0 && height > 0)
{ {
ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); IDirect3DDevice9 *device = getDevice();
error(GL_OUT_OF_MEMORY); HRESULT result = device->CreateTexture(width, height, levels, isRenderTarget() ? D3DUSAGE_RENDERTARGET : 0, format, getPool(), &mTexture, NULL);
if (FAILED(result))
{
ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
error(GL_OUT_OF_MEMORY);
}
} }
} }
...@@ -2382,15 +2386,19 @@ TextureStorage *Texture2D::getStorage(bool renderTarget) ...@@ -2382,15 +2386,19 @@ 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;
HRESULT result = device->CreateCubeTexture(size, levels, isRenderTarget() ? D3DUSAGE_RENDERTARGET : 0, format, getPool(), &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 (FAILED(result)) if (size > 0)
{ {
ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY); IDirect3DDevice9 *device = getDevice();
error(GL_OUT_OF_MEMORY); HRESULT result = device->CreateCubeTexture(size, levels, isRenderTarget() ? D3DUSAGE_RENDERTARGET : 0, format, getPool(), &mTexture, NULL);
if (FAILED(result))
{
ASSERT(result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY);
error(GL_OUT_OF_MEMORY);
}
} }
} }
......
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