Pass the usage parameter into TextureStorage instead of passing a boolean

Trac #20875 Signed-off-by: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@1108 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 36884639
...@@ -1097,7 +1097,7 @@ D3DPOOL Display::getBufferPool(DWORD usage) const ...@@ -1097,7 +1097,7 @@ D3DPOOL Display::getBufferPool(DWORD usage) const
return D3DPOOL_DEFAULT; return D3DPOOL_DEFAULT;
} }
D3DPOOL Display::getTexturePool(bool renderable) const D3DPOOL Display::getTexturePool(DWORD usage) const
{ {
if (mD3d9Ex != NULL) if (mD3d9Ex != NULL)
{ {
...@@ -1105,7 +1105,7 @@ D3DPOOL Display::getTexturePool(bool renderable) const ...@@ -1105,7 +1105,7 @@ D3DPOOL Display::getTexturePool(bool renderable) const
} }
else else
{ {
if (!renderable) if (!(usage & (D3DUSAGE_DEPTHSTENCIL | D3DUSAGE_RENDERTARGET)))
{ {
return D3DPOOL_MANAGED; return D3DPOOL_MANAGED;
} }
......
...@@ -82,7 +82,7 @@ class Display ...@@ -82,7 +82,7 @@ class Display
virtual bool getOcclusionQuerySupport() const; virtual bool getOcclusionQuerySupport() const;
virtual bool getInstancingSupport() const; virtual bool getInstancingSupport() const;
virtual D3DPOOL getBufferPool(DWORD usage) const; virtual D3DPOOL getBufferPool(DWORD usage) const;
virtual D3DPOOL getTexturePool(bool renderable) const; virtual D3DPOOL getTexturePool(DWORD usage) const;
virtual void notifyDeviceLost(); virtual void notifyDeviceLost();
bool isDeviceLost(); bool isDeviceLost();
......
...@@ -1346,9 +1346,9 @@ void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, ...@@ -1346,9 +1346,9 @@ void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width,
mDirty = true; mDirty = true;
} }
TextureStorage::TextureStorage(bool renderTarget) TextureStorage::TextureStorage(DWORD usage)
: mRenderTarget(renderTarget), : mD3DUsage(usage),
mD3DPool(getDisplay()->getTexturePool(mRenderTarget)), mD3DPool(getDisplay()->getTexturePool(usage)),
mTextureSerial(issueTextureSerial()) mTextureSerial(issueTextureSerial())
{ {
} }
...@@ -1359,7 +1359,7 @@ TextureStorage::~TextureStorage() ...@@ -1359,7 +1359,7 @@ TextureStorage::~TextureStorage()
bool TextureStorage::isRenderTarget() const bool TextureStorage::isRenderTarget() const
{ {
return mRenderTarget; return (mD3DUsage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)) != 0;
} }
bool TextureStorage::isManaged() const bool TextureStorage::isManaged() const
...@@ -1372,6 +1372,11 @@ D3DPOOL TextureStorage::getPool() const ...@@ -1372,6 +1372,11 @@ D3DPOOL TextureStorage::getPool() const
return mD3DPool; return mD3DPool;
} }
DWORD TextureStorage::getUsage() const
{
return mD3DUsage;
}
unsigned int TextureStorage::getTextureSerial() const unsigned int TextureStorage::getTextureSerial() const
{ {
return mTextureSerial; return mTextureSerial;
...@@ -1674,13 +1679,13 @@ bool Texture::copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *sou ...@@ -1674,13 +1679,13 @@ bool Texture::copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *sou
return true; return true;
} }
TextureStorage2D::TextureStorage2D(IDirect3DTexture9 *surfaceTexture) : TextureStorage(true), mRenderTargetSerial(RenderbufferStorage::issueSerial()) TextureStorage2D::TextureStorage2D(IDirect3DTexture9 *surfaceTexture) : TextureStorage(D3DUSAGE_RENDERTARGET), mRenderTargetSerial(RenderbufferStorage::issueSerial())
{ {
mTexture = surfaceTexture; mTexture = surfaceTexture;
} }
TextureStorage2D::TextureStorage2D(int levels, D3DFORMAT format, int width, int height, bool renderTarget) TextureStorage2D::TextureStorage2D(int levels, D3DFORMAT format, DWORD usage, int width, int height)
: TextureStorage(renderTarget), mRenderTargetSerial(RenderbufferStorage::issueSerial()) : TextureStorage(usage), mRenderTargetSerial(RenderbufferStorage::issueSerial())
{ {
mTexture = NULL; mTexture = NULL;
// if the width or height is not positive this should be treated as an incomplete texture // if the width or height is not positive this should be treated as an incomplete texture
...@@ -1688,8 +1693,7 @@ TextureStorage2D::TextureStorage2D(int levels, D3DFORMAT format, int width, int ...@@ -1688,8 +1693,7 @@ TextureStorage2D::TextureStorage2D(int levels, D3DFORMAT format, int width, int
if (width > 0 && height > 0) if (width > 0 && height > 0)
{ {
IDirect3DDevice9 *device = getDevice(); IDirect3DDevice9 *device = getDevice();
DWORD usage = GetTextureUsage(isRenderTarget(), format); HRESULT result = device->CreateTexture(width, height, levels, getUsage(), format, getPool(), &mTexture, NULL);
HRESULT result = device->CreateTexture(width, height, levels, usage, format, getPool(), &mTexture, NULL);
if (FAILED(result)) if (FAILED(result))
{ {
...@@ -2030,9 +2034,10 @@ void Texture2D::storage(GLsizei levels, GLenum internalformat, GLsizei width, GL ...@@ -2030,9 +2034,10 @@ void Texture2D::storage(GLsizei levels, GLenum internalformat, GLsizei width, GL
GLenum type = gl::ExtractType(internalformat); GLenum type = gl::ExtractType(internalformat);
D3DFORMAT d3dfmt = ConvertTextureFormatType(format, type); D3DFORMAT d3dfmt = ConvertTextureFormatType(format, type);
const bool renderTarget = IsTextureFormatRenderable(d3dfmt) && (mUsage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE); const bool renderTarget = IsTextureFormatRenderable(d3dfmt) && (mUsage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
DWORD usage = GetTextureUsage(renderTarget, d3dfmt);
delete mTexStorage; delete mTexStorage;
mTexStorage = new TextureStorage2D(levels, d3dfmt, width, height, renderTarget); mTexStorage = new TextureStorage2D(levels, d3dfmt, usage, width, height);
mImmutable = true; mImmutable = true;
for (int level = 0; level < levels; level++) for (int level = 0; level < levels; level++)
...@@ -2193,9 +2198,10 @@ void Texture2D::createTexture() ...@@ -2193,9 +2198,10 @@ void Texture2D::createTexture()
GLint levels = creationLevels(width, height); GLint levels = creationLevels(width, height);
D3DFORMAT format = mImageArray[0].getD3DFormat(); D3DFORMAT format = mImageArray[0].getD3DFormat();
const bool renderTarget = IsTextureFormatRenderable(format) && (mUsage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE); const bool renderTarget = IsTextureFormatRenderable(format) && (mUsage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
DWORD usage = GetTextureUsage(renderTarget, format);
delete mTexStorage; delete mTexStorage;
mTexStorage = new TextureStorage2D(levels, format, width, height, renderTarget); mTexStorage = new TextureStorage2D(levels, format, usage, width, height);
if (mTexStorage->isManaged()) if (mTexStorage->isManaged())
{ {
...@@ -2236,8 +2242,9 @@ void Texture2D::convertToRenderTarget() ...@@ -2236,8 +2242,9 @@ void Texture2D::convertToRenderTarget()
GLsizei height = mImageArray[0].getHeight(); GLsizei height = mImageArray[0].getHeight();
GLint levels = creationLevels(width, height); GLint levels = creationLevels(width, height);
D3DFORMAT format = mImageArray[0].getD3DFormat(); D3DFORMAT format = mImageArray[0].getD3DFormat();
DWORD usage = GetTextureUsage(true, format);
newTexStorage = new TextureStorage2D(levels, format, width, height, true); newTexStorage = new TextureStorage2D(levels, format, usage, width, height);
if (mTexStorage != NULL) if (mTexStorage != NULL)
{ {
...@@ -2371,8 +2378,8 @@ TextureStorage *Texture2D::getStorage(bool renderTarget) ...@@ -2371,8 +2378,8 @@ TextureStorage *Texture2D::getStorage(bool renderTarget)
return mTexStorage; return mTexStorage;
} }
TextureStorageCubeMap::TextureStorageCubeMap(int levels, D3DFORMAT format, int size, bool renderTarget) TextureStorageCubeMap::TextureStorageCubeMap(int levels, D3DFORMAT format, DWORD usage, int size)
: TextureStorage(renderTarget), mFirstRenderTargetSerial(RenderbufferStorage::issueCubeSerials()) : TextureStorage(usage), mFirstRenderTargetSerial(RenderbufferStorage::issueCubeSerials())
{ {
mTexture = NULL; mTexture = NULL;
// if the size is not positive this should be treated as an incomplete texture // if the size is not positive this should be treated as an incomplete texture
...@@ -2380,8 +2387,7 @@ TextureStorageCubeMap::TextureStorageCubeMap(int levels, D3DFORMAT format, int s ...@@ -2380,8 +2387,7 @@ TextureStorageCubeMap::TextureStorageCubeMap(int levels, D3DFORMAT format, int s
if (size > 0) if (size > 0)
{ {
IDirect3DDevice9 *device = getDevice(); IDirect3DDevice9 *device = getDevice();
DWORD usage = GetTextureUsage(isRenderTarget(), format); HRESULT result = device->CreateCubeTexture(size, levels, getUsage(), format, getPool(), &mTexture, NULL);
HRESULT result = device->CreateCubeTexture(size, levels, usage, format, getPool(), &mTexture, NULL);
if (FAILED(result)) if (FAILED(result))
{ {
...@@ -2720,9 +2726,10 @@ void TextureCubeMap::createTexture() ...@@ -2720,9 +2726,10 @@ void TextureCubeMap::createTexture()
GLint levels = creationLevels(size, 0); GLint levels = creationLevels(size, 0);
D3DFORMAT format = mImageArray[0][0].getD3DFormat(); D3DFORMAT format = mImageArray[0][0].getD3DFormat();
const bool renderTarget = IsTextureFormatRenderable(format) && (mUsage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE); const bool renderTarget = IsTextureFormatRenderable(format) && (mUsage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
DWORD usage = GetTextureUsage(renderTarget, format);
delete mTexStorage; delete mTexStorage;
mTexStorage = new TextureStorageCubeMap(levels, format, size, renderTarget); mTexStorage = new TextureStorageCubeMap(levels, format, usage, size);
if (mTexStorage->isManaged()) if (mTexStorage->isManaged())
{ {
...@@ -2767,8 +2774,9 @@ void TextureCubeMap::convertToRenderTarget() ...@@ -2767,8 +2774,9 @@ void TextureCubeMap::convertToRenderTarget()
GLsizei size = mImageArray[0][0].getWidth(); GLsizei size = mImageArray[0][0].getWidth();
GLint levels = creationLevels(size, 0); GLint levels = creationLevels(size, 0);
D3DFORMAT format = mImageArray[0][0].getD3DFormat(); D3DFORMAT format = mImageArray[0][0].getD3DFormat();
DWORD usage = GetTextureUsage(true, format);
newTexStorage = new TextureStorageCubeMap(levels, format, size, true); newTexStorage = new TextureStorageCubeMap(levels, format, usage, size);
if (mTexStorage != NULL) if (mTexStorage != NULL)
{ {
...@@ -2954,9 +2962,10 @@ void TextureCubeMap::storage(GLsizei levels, GLenum internalformat, GLsizei size ...@@ -2954,9 +2962,10 @@ void TextureCubeMap::storage(GLsizei levels, GLenum internalformat, GLsizei size
GLenum type = gl::ExtractType(internalformat); GLenum type = gl::ExtractType(internalformat);
D3DFORMAT d3dfmt = ConvertTextureFormatType(format, type); D3DFORMAT d3dfmt = ConvertTextureFormatType(format, type);
const bool renderTarget = IsTextureFormatRenderable(d3dfmt) && (mUsage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE); const bool renderTarget = IsTextureFormatRenderable(d3dfmt) && (mUsage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
DWORD usage = GetTextureUsage(renderTarget, d3dfmt);
delete mTexStorage; delete mTexStorage;
mTexStorage = new TextureStorageCubeMap(levels, d3dfmt, size, renderTarget); mTexStorage = new TextureStorageCubeMap(levels, d3dfmt, usage, size);
mImmutable = true; mImmutable = true;
for (int level = 0; level < levels; level++) for (int level = 0; level < levels; level++)
......
...@@ -146,20 +146,21 @@ class Image ...@@ -146,20 +146,21 @@ class Image
class TextureStorage class TextureStorage
{ {
public: public:
explicit TextureStorage(bool renderTarget); explicit TextureStorage(DWORD usage);
virtual ~TextureStorage(); virtual ~TextureStorage();
bool isRenderTarget() const; bool isRenderTarget() const;
bool isManaged() const; bool isManaged() const;
D3DPOOL getPool() const; D3DPOOL getPool() const;
DWORD getUsage() const;
unsigned int getTextureSerial() const; unsigned int getTextureSerial() const;
virtual unsigned int getRenderTargetSerial(GLenum target) const = 0; virtual unsigned int getRenderTargetSerial(GLenum target) const = 0;
private: private:
DISALLOW_COPY_AND_ASSIGN(TextureStorage); DISALLOW_COPY_AND_ASSIGN(TextureStorage);
const bool mRenderTarget; const DWORD mD3DUsage;
const D3DPOOL mD3DPool; const D3DPOOL mD3DPool;
const unsigned int mTextureSerial; const unsigned int mTextureSerial;
...@@ -251,7 +252,7 @@ class TextureStorage2D : public TextureStorage ...@@ -251,7 +252,7 @@ class TextureStorage2D : public TextureStorage
{ {
public: public:
explicit TextureStorage2D(IDirect3DTexture9 *surfaceTexture); explicit TextureStorage2D(IDirect3DTexture9 *surfaceTexture);
TextureStorage2D(int levels, D3DFORMAT format, int width, int height, bool renderTarget); TextureStorage2D(int levels, D3DFORMAT format, DWORD usage, int width, int height);
virtual ~TextureStorage2D(); virtual ~TextureStorage2D();
...@@ -337,7 +338,7 @@ class Texture2D : public Texture ...@@ -337,7 +338,7 @@ class Texture2D : public Texture
class TextureStorageCubeMap : public TextureStorage class TextureStorageCubeMap : public TextureStorage
{ {
public: public:
TextureStorageCubeMap(int levels, D3DFORMAT format, int size, bool renderTarget); TextureStorageCubeMap(int levels, D3DFORMAT format, DWORD usage, int size);
virtual ~TextureStorageCubeMap(); virtual ~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