Fix FBO/Texture/renderbuffer class hierarchy issues
TRAC #14744
Issue=51/52
Delegated format queries to RenderbufferStorage.
Eliminated TextureColorbufferProxy by merging it into Colorbuffer.
Abstracted texture colorbuffer queries.
Moved some conversion functions to the right namespace.
Fixed line-endings in Texture.cpp
Signed-off-by: Daniel Koch
Author: Nicolas Capens <nicolas@transgaming.com>
git-svn-id: https://angleproject.googlecode.com/svn/trunk@553 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Renderbuffer.cpp b/src/libGLESv2/Renderbuffer.cpp
index 6e4494b..7597504 100644
--- a/src/libGLESv2/Renderbuffer.cpp
+++ b/src/libGLESv2/Renderbuffer.cpp
@@ -54,24 +54,54 @@
return mStorage->getDepthStencil();
}
-int Renderbuffer::getWidth() const
+GLsizei Renderbuffer::getWidth() const
{
return mStorage->getWidth();
}
-int Renderbuffer::getHeight() const
+GLsizei Renderbuffer::getHeight() const
{
return mStorage->getHeight();
}
-GLenum Renderbuffer::getFormat() const
+GLenum Renderbuffer::getInternalFormat() const
{
- return mStorage->getFormat();
+ return mStorage->getInternalFormat();
}
-D3DFORMAT Renderbuffer::getD3DFormat() const
+GLuint Renderbuffer::getRedSize() const
{
- return mStorage->getD3DFormat();
+ return mStorage->getRedSize();
+}
+
+GLuint Renderbuffer::getGreenSize() const
+{
+ return mStorage->getGreenSize();
+}
+
+GLuint Renderbuffer::getBlueSize() const
+{
+ return mStorage->getBlueSize();
+}
+
+GLuint Renderbuffer::getAlphaSize() const
+{
+ return mStorage->getAlphaSize();
+}
+
+GLuint Renderbuffer::getDepthSize() const
+{
+ return mStorage->getDepthSize();
+}
+
+GLuint Renderbuffer::getStencilSize() const
+{
+ return mStorage->getStencilSize();
+}
+
+GLsizei Renderbuffer::getSamples() const
+{
+ return mStorage->getSamples();
}
unsigned int Renderbuffer::getSerial() const
@@ -91,7 +121,7 @@
{
mWidth = 0;
mHeight = 0;
- mFormat = GL_RGBA4;
+ mInternalFormat = GL_RGBA4;
mD3DFormat = D3DFMT_A8R8G8B8;
mSamples = 0;
}
@@ -125,35 +155,49 @@
return NULL;
}
-int RenderbufferStorage::getWidth() const
+GLsizei RenderbufferStorage::getWidth() const
{
return mWidth;
}
-int RenderbufferStorage::getHeight() const
+GLsizei RenderbufferStorage::getHeight() const
{
return mHeight;
}
-void RenderbufferStorage::setSize(int width, int height)
+GLenum RenderbufferStorage::getInternalFormat() const
{
- mWidth = width;
- mHeight = height;
+ return mInternalFormat;
}
-GLenum RenderbufferStorage::getFormat() const
+GLuint RenderbufferStorage::getRedSize() const
{
- return mFormat;
+ return dx2es::GetRedSize(getD3DFormat());
}
-bool RenderbufferStorage::isFloatingPoint() const
+GLuint RenderbufferStorage::getGreenSize() const
{
- return false; // no floating point renderbuffers
+ return dx2es::GetGreenSize(getD3DFormat());
}
-D3DFORMAT RenderbufferStorage::getD3DFormat() const
+GLuint RenderbufferStorage::getBlueSize() const
{
- return mD3DFormat;
+ return dx2es::GetBlueSize(getD3DFormat());
+}
+
+GLuint RenderbufferStorage::getAlphaSize() const
+{
+ return dx2es::GetAlphaSize(getD3DFormat());
+}
+
+GLuint RenderbufferStorage::getDepthSize() const
+{
+ return dx2es::GetDepthSize(getD3DFormat());
+}
+
+GLuint RenderbufferStorage::getStencilSize() const
+{
+ return dx2es::GetStencilSize(getD3DFormat());
}
GLsizei RenderbufferStorage::getSamples() const
@@ -161,6 +205,11 @@
return mSamples;
}
+D3DFORMAT RenderbufferStorage::getD3DFormat() const
+{
+ return mD3DFormat;
+}
+
unsigned int RenderbufferStorage::getSerial() const
{
return mSerial;
@@ -171,7 +220,7 @@
return mCurrentSerial++;
}
-Colorbuffer::Colorbuffer(IDirect3DSurface9 *renderTarget) : mRenderTarget(renderTarget)
+Colorbuffer::Colorbuffer(IDirect3DSurface9 *renderTarget) : mRenderTarget(renderTarget), mTexture(NULL)
{
if (renderTarget)
{
@@ -180,25 +229,32 @@
D3DSURFACE_DESC description;
renderTarget->GetDesc(&description);
- setSize(description.Width, description.Height);
- mFormat = dx2es::ConvertBackBufferFormat(description.Format);
+ mWidth = description.Width;
+ mHeight = description.Height;
+ mInternalFormat = dx2es::ConvertBackBufferFormat(description.Format);
mD3DFormat = description.Format;
- mSamples = es2dx::GetSamplesFromMultisampleType(description.MultiSampleType);
+ mSamples = dx2es::GetSamplesFromMultisampleType(description.MultiSampleType);
}
}
-Colorbuffer::Colorbuffer(const Texture* texture) : mRenderTarget(NULL)
+Colorbuffer::Colorbuffer(Texture *texture, GLenum target) : mRenderTarget(NULL), mTexture(texture), mTarget(target)
{
- setSize(texture->getWidth(), texture->getHeight());
- mD3DFormat = texture->getD3DFormat();
- mSamples = 0;
+ if (texture)
+ {
+ mWidth = texture->getWidth();
+ mHeight = texture->getHeight();
+ mInternalFormat = texture->getInternalFormat();
+ mD3DFormat = texture->getD3DFormat();
+ mSamples = 0;
+
+ mRenderTarget = texture->getRenderTarget(target);
+ }
}
-Colorbuffer::Colorbuffer(int width, int height, GLenum format, GLsizei samples)
+Colorbuffer::Colorbuffer(int width, int height, GLenum format, GLsizei samples) : mRenderTarget(NULL), mTexture(NULL)
{
IDirect3DDevice9 *device = getDevice();
- mRenderTarget = NULL;
D3DFORMAT requestedFormat = es2dx::ConvertRenderbufferFormat(format);
int supportedSamples = getContext()->getNearestSupportedSamples(requestedFormat, samples);
@@ -226,8 +282,9 @@
if (mRenderTarget)
{
- setSize(width, height);
- mFormat = format;
+ mWidth = width;
+ mHeight = height;
+ mInternalFormat = format;
mD3DFormat = requestedFormat;
mSamples = supportedSamples;
}
@@ -241,65 +298,73 @@
}
}
+GLsizei Colorbuffer::getWidth() const
+{
+ if (mTexture)
+ {
+ return mTexture->getWidth();
+ }
+
+ return mWidth;
+}
+
+GLsizei Colorbuffer::getHeight() const
+{
+ if (mTexture)
+ {
+ return mTexture->getHeight();
+ }
+
+ return mHeight;
+}
+
+GLenum Colorbuffer::getInternalFormat() const
+{
+ if (mTexture)
+ {
+ return mTexture->getInternalFormat();
+ }
+
+ return mInternalFormat;
+}
+
+D3DFORMAT Colorbuffer::getD3DFormat() const
+{
+ if (mTexture)
+ {
+ return mTexture->getD3DFormat();
+ }
+
+ return mD3DFormat;
+}
+
+bool Colorbuffer::isFloatingPoint() const
+{
+ if (mTexture)
+ {
+ return mTexture->isFloatingPoint();
+ }
+
+ return false;
+}
+
bool Colorbuffer::isColorbuffer() const
{
return true;
}
-GLuint Colorbuffer::getRedSize() const
-{
- if (mRenderTarget)
- {
- D3DSURFACE_DESC description;
- mRenderTarget->GetDesc(&description);
-
- return es2dx::GetRedSize(description.Format);
- }
-
- return 0;
-}
-
-GLuint Colorbuffer::getGreenSize() const
-{
- if (mRenderTarget)
- {
- D3DSURFACE_DESC description;
- mRenderTarget->GetDesc(&description);
-
- return es2dx::GetGreenSize(description.Format);
- }
-
- return 0;
-}
-
-GLuint Colorbuffer::getBlueSize() const
-{
- if (mRenderTarget)
- {
- D3DSURFACE_DESC description;
- mRenderTarget->GetDesc(&description);
-
- return es2dx::GetBlueSize(description.Format);
- }
-
- return 0;
-}
-
-GLuint Colorbuffer::getAlphaSize() const
-{
- if (mRenderTarget)
- {
- D3DSURFACE_DESC description;
- mRenderTarget->GetDesc(&description);
-
- return es2dx::GetAlphaSize(description.Format);
- }
-
- return 0;
-}
-
IDirect3DSurface9 *Colorbuffer::getRenderTarget()
{
+ if (mTexture)
+ {
+ if (mRenderTarget)
+ {
+ mRenderTarget->Release();
+ }
+
+ mRenderTarget = mTexture->getRenderTarget(mTarget);
+ }
+
return mRenderTarget;
}
@@ -312,9 +377,10 @@
D3DSURFACE_DESC description;
depthStencil->GetDesc(&description);
- setSize(description.Width, description.Height);
- mFormat = dx2es::ConvertDepthStencilFormat(description.Format);
- mSamples = es2dx::GetSamplesFromMultisampleType(description.MultiSampleType);
+ mWidth = description.Width;
+ mHeight = description.Height;
+ mInternalFormat = dx2es::ConvertDepthStencilFormat(description.Format);
+ mSamples = dx2es::GetSamplesFromMultisampleType(description.MultiSampleType);
mD3DFormat = description.Format;
}
}
@@ -348,8 +414,9 @@
if (mDepthStencil)
{
- setSize(width, height);
- mFormat = GL_DEPTH24_STENCIL8_OES;
+ mWidth = width;
+ mHeight = height;
+ mInternalFormat = GL_DEPTH24_STENCIL8_OES;
mD3DFormat = D3DFMT_D24S8;
mSamples = supportedSamples;
}
@@ -373,32 +440,6 @@
return true;
}
-GLuint DepthStencilbuffer::getDepthSize() const
-{
- if (mDepthStencil)
- {
- D3DSURFACE_DESC description;
- mDepthStencil->GetDesc(&description);
-
- return es2dx::GetDepthSize(description.Format);
- }
-
- return 0;
-}
-
-GLuint DepthStencilbuffer::getStencilSize() const
-{
- if (mDepthStencil)
- {
- D3DSURFACE_DESC description;
- mDepthStencil->GetDesc(&description);
-
- return es2dx::GetStencilSize(description.Format);
- }
-
- return 0;
-}
-
IDirect3DSurface9 *DepthStencilbuffer::getDepthStencil()
{
return mDepthStencil;
@@ -408,9 +449,9 @@
{
if (depthStencil)
{
- mFormat = GL_DEPTH_COMPONENT16; // If the renderbuffer parameters are queried, the calling function
- // will expect one of the valid renderbuffer formats for use in
- // glRenderbufferStorage
+ mInternalFormat = GL_DEPTH_COMPONENT16; // If the renderbuffer parameters are queried, the calling function
+ // will expect one of the valid renderbuffer formats for use in
+ // glRenderbufferStorage
}
}
@@ -418,9 +459,9 @@
{
if (getDepthStencil())
{
- mFormat = GL_DEPTH_COMPONENT16; // If the renderbuffer parameters are queried, the calling function
- // will expect one of the valid renderbuffer formats for use in
- // glRenderbufferStorage
+ mInternalFormat = GL_DEPTH_COMPONENT16; // If the renderbuffer parameters are queried, the calling function
+ // will expect one of the valid renderbuffer formats for use in
+ // glRenderbufferStorage
}
}
@@ -442,13 +483,9 @@
{
if (depthStencil)
{
- mFormat = GL_STENCIL_INDEX8; // If the renderbuffer parameters are queried, the calling function
- // will expect one of the valid renderbuffer formats for use in
- // glRenderbufferStorage
- }
- else
- {
- mFormat = GL_RGBA4; //default format
+ mInternalFormat = GL_STENCIL_INDEX8; // If the renderbuffer parameters are queried, the calling function
+ // will expect one of the valid renderbuffer formats for use in
+ // glRenderbufferStorage
}
}
@@ -456,9 +493,9 @@
{
if (getDepthStencil())
{
- mFormat = GL_STENCIL_INDEX8; // If the renderbuffer parameters are queried, the calling function
- // will expect one of the valid renderbuffer formats for use in
- // glRenderbufferStorage
+ mInternalFormat = GL_STENCIL_INDEX8; // If the renderbuffer parameters are queried, the calling function
+ // will expect one of the valid renderbuffer formats for use in
+ // glRenderbufferStorage
}
}