Initialize renderbuffer variables. Make serials constant. Removed X1R5G5B5 support.

TRAC #13792 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@460 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 3f85fbbc
...@@ -94,13 +94,6 @@ void Config::set(D3DDISPLAYMODE displayMode, EGLint minInterval, EGLint maxInter ...@@ -94,13 +94,6 @@ void Config::set(D3DDISPLAYMODE displayMode, EGLint minInterval, EGLint maxInter
mBlueSize = 5; mBlueSize = 5;
mAlphaSize = 0; mAlphaSize = 0;
break; break;
case D3DFMT_X1R5G5B5:
mBufferSize = 16;
mRedSize = 5;
mGreenSize = 5;
mBlueSize = 5;
mAlphaSize = 0;
break;
case D3DFMT_X8R8G8B8: case D3DFMT_X8R8G8B8:
mBufferSize = 32; mBufferSize = 32;
mRedSize = 8; mRedSize = 8;
......
...@@ -146,7 +146,7 @@ bool Display::initialize() ...@@ -146,7 +146,7 @@ bool Display::initialize()
// D3DFMT_A2R10G10B10, // The color_ramp conformance test uses ReadPixels with UNSIGNED_BYTE causing it to think that rendering skipped a colour value. // D3DFMT_A2R10G10B10, // The color_ramp conformance test uses ReadPixels with UNSIGNED_BYTE causing it to think that rendering skipped a colour value.
D3DFMT_A8R8G8B8, D3DFMT_A8R8G8B8,
D3DFMT_R5G6B5, D3DFMT_R5G6B5,
D3DFMT_X1R5G5B5, // D3DFMT_X1R5G5B5, // Has no compatible OpenGL ES renderbuffer format
D3DFMT_X8R8G8B8 D3DFMT_X8R8G8B8
}; };
......
...@@ -2242,16 +2242,6 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum ...@@ -2242,16 +2242,6 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum
r = (rgb & 0xF800) * (1.0f / 0xF800); r = (rgb & 0xF800) * (1.0f / 0xF800);
} }
break; break;
case D3DFMT_X1R5G5B5:
{
unsigned short xrgb = *(unsigned short*)(source + 2 * i + j * lock.Pitch);
a = 1.0f;
b = (xrgb & 0x001F) * (1.0f / 0x001F);
g = (xrgb & 0x03E0) * (1.0f / 0x03E0);
r = (xrgb & 0x7C00) * (1.0f / 0x7C00);
}
break;
case D3DFMT_A1R5G5B5: case D3DFMT_A1R5G5B5:
{ {
unsigned short argb = *(unsigned short*)(source + 2 * i + j * lock.Pitch); unsigned short argb = *(unsigned short*)(source + 2 * i + j * lock.Pitch);
......
...@@ -438,8 +438,8 @@ GLenum Framebuffer::completeness() ...@@ -438,8 +438,8 @@ GLenum Framebuffer::completeness()
DefaultFramebuffer::DefaultFramebuffer(Colorbuffer *color, DepthStencilbuffer *depthStencil) DefaultFramebuffer::DefaultFramebuffer(Colorbuffer *color, DepthStencilbuffer *depthStencil)
{ {
mColorbufferType = GL_RENDERBUFFER; mColorbufferType = GL_RENDERBUFFER;
mDepthbufferType = GL_RENDERBUFFER; mDepthbufferType = (depthStencil->getDepthSize() != 0) ? GL_RENDERBUFFER : GL_NONE;
mStencilbufferType = GL_RENDERBUFFER; mStencilbufferType = (depthStencil->getStencilSize() != 0) ? GL_RENDERBUFFER : GL_NONE;
mColorbufferPointer.set(new Renderbuffer(0, color)); mColorbufferPointer.set(new Renderbuffer(0, color));
...@@ -462,6 +462,9 @@ int Framebuffer::getSamples() ...@@ -462,6 +462,9 @@ int Framebuffer::getSamples()
GLenum DefaultFramebuffer::completeness() GLenum DefaultFramebuffer::completeness()
{ {
// The default framebuffer should always be complete
ASSERT(Framebuffer::completeness() == GL_FRAMEBUFFER_COMPLETE);
return GL_FRAMEBUFFER_COMPLETE; return GL_FRAMEBUFFER_COMPLETE;
} }
......
...@@ -45,7 +45,7 @@ UniformLocation::UniformLocation(const std::string &name, unsigned int element, ...@@ -45,7 +45,7 @@ UniformLocation::UniformLocation(const std::string &name, unsigned int element,
{ {
} }
Program::Program(ResourceManager *manager, GLuint handle) : mResourceManager(manager), mHandle(handle) Program::Program(ResourceManager *manager, GLuint handle) : mResourceManager(manager), mHandle(handle), mSerial(issueSerial())
{ {
mFragmentShader = NULL; mFragmentShader = NULL;
mVertexShader = NULL; mVertexShader = NULL;
...@@ -63,8 +63,6 @@ Program::Program(ResourceManager *manager, GLuint handle) : mResourceManager(man ...@@ -63,8 +63,6 @@ Program::Program(ResourceManager *manager, GLuint handle) : mResourceManager(man
mDeleteStatus = false; mDeleteStatus = false;
mRefCount = 0; mRefCount = 0;
mSerial = issueSerial();
} }
Program::~Program() Program::~Program()
......
...@@ -220,7 +220,7 @@ class Program ...@@ -220,7 +220,7 @@ class Program
unsigned int mRefCount; unsigned int mRefCount;
unsigned int mSerial; const unsigned int mSerial;
static unsigned int mCurrentSerial; static unsigned int mCurrentSerial;
......
...@@ -87,9 +87,13 @@ void Renderbuffer::setStorage(RenderbufferStorage *newStorage) ...@@ -87,9 +87,13 @@ void Renderbuffer::setStorage(RenderbufferStorage *newStorage)
mStorage = newStorage; mStorage = newStorage;
} }
RenderbufferStorage::RenderbufferStorage() RenderbufferStorage::RenderbufferStorage() : mSerial(issueSerial())
{ {
mSerial = issueSerial(); mWidth = 0;
mHeight = 0;
mFormat = GL_RGBA4;
mD3DFormat = D3DFMT_A8R8G8B8;
mSamples = 0;
} }
RenderbufferStorage::~RenderbufferStorage() RenderbufferStorage::~RenderbufferStorage()
...@@ -177,14 +181,10 @@ Colorbuffer::Colorbuffer(IDirect3DSurface9 *renderTarget) : mRenderTarget(render ...@@ -177,14 +181,10 @@ Colorbuffer::Colorbuffer(IDirect3DSurface9 *renderTarget) : mRenderTarget(render
renderTarget->GetDesc(&description); renderTarget->GetDesc(&description);
setSize(description.Width, description.Height); setSize(description.Width, description.Height);
mFormat = dx2es::ConvertBackBufferFormat(description.Format);
mD3DFormat = description.Format; mD3DFormat = description.Format;
mSamples = es2dx::GetSamplesFromMultisampleType(description.MultiSampleType); mSamples = es2dx::GetSamplesFromMultisampleType(description.MultiSampleType);
} }
else
{
mD3DFormat = D3DFMT_UNKNOWN;
mSamples = 0;
}
} }
Colorbuffer::Colorbuffer(const Texture* texture) : mRenderTarget(NULL) Colorbuffer::Colorbuffer(const Texture* texture) : mRenderTarget(NULL)
...@@ -231,13 +231,6 @@ Colorbuffer::Colorbuffer(int width, int height, GLenum format, GLsizei samples) ...@@ -231,13 +231,6 @@ Colorbuffer::Colorbuffer(int width, int height, GLenum format, GLsizei samples)
mD3DFormat = requestedFormat; mD3DFormat = requestedFormat;
mSamples = supportedSamples; mSamples = supportedSamples;
} }
else
{
setSize(0, 0);
mFormat = GL_RGBA4;
mD3DFormat = D3DFMT_UNKNOWN;
mSamples = 0;
}
} }
Colorbuffer::~Colorbuffer() Colorbuffer::~Colorbuffer()
...@@ -320,15 +313,10 @@ DepthStencilbuffer::DepthStencilbuffer(IDirect3DSurface9 *depthStencil) : mDepth ...@@ -320,15 +313,10 @@ DepthStencilbuffer::DepthStencilbuffer(IDirect3DSurface9 *depthStencil) : mDepth
depthStencil->GetDesc(&description); depthStencil->GetDesc(&description);
setSize(description.Width, description.Height); setSize(description.Width, description.Height);
mFormat = (description.Format == D3DFMT_D16 ? GL_DEPTH_COMPONENT16 : GL_DEPTH24_STENCIL8_OES); mFormat = dx2es::ConvertDepthStencilFormat(description.Format);
mSamples = es2dx::GetSamplesFromMultisampleType(description.MultiSampleType); mSamples = es2dx::GetSamplesFromMultisampleType(description.MultiSampleType);
mD3DFormat = description.Format; mD3DFormat = description.Format;
} }
else
{
mD3DFormat = D3DFMT_UNKNOWN;
mSamples = 0;
}
} }
DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples) DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples)
...@@ -365,13 +353,6 @@ DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples) ...@@ -365,13 +353,6 @@ DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples)
mD3DFormat = D3DFMT_D24S8; mD3DFormat = D3DFMT_D24S8;
mSamples = supportedSamples; mSamples = supportedSamples;
} }
else
{
setSize(0, 0);
mFormat = GL_RGBA4; //default format
mD3DFormat = D3DFMT_UNKNOWN;
mSamples = 0;
}
} }
DepthStencilbuffer::~DepthStencilbuffer() DepthStencilbuffer::~DepthStencilbuffer()
......
...@@ -55,7 +55,7 @@ class RenderbufferStorage ...@@ -55,7 +55,7 @@ class RenderbufferStorage
GLenum mFormat; GLenum mFormat;
D3DFORMAT mD3DFormat; D3DFORMAT mD3DFormat;
GLsizei mSamples; GLsizei mSamples;
unsigned int mSerial; const unsigned int mSerial;
private: private:
DISALLOW_COPY_AND_ASSIGN(RenderbufferStorage); DISALLOW_COPY_AND_ASSIGN(RenderbufferStorage);
......
...@@ -623,7 +623,6 @@ unsigned int GetAlphaSize(D3DFORMAT colorFormat) ...@@ -623,7 +623,6 @@ unsigned int GetAlphaSize(D3DFORMAT colorFormat)
case D3DFMT_A1R5G5B5: case D3DFMT_A1R5G5B5:
return 1; return 1;
case D3DFMT_X8R8G8B8: case D3DFMT_X8R8G8B8:
case D3DFMT_X1R5G5B5:
case D3DFMT_R5G6B5: case D3DFMT_R5G6B5:
return 0; return 0;
default: UNREACHABLE(); default: UNREACHABLE();
...@@ -646,7 +645,6 @@ unsigned int GetRedSize(D3DFORMAT colorFormat) ...@@ -646,7 +645,6 @@ unsigned int GetRedSize(D3DFORMAT colorFormat)
return 8; return 8;
case D3DFMT_A1R5G5B5: case D3DFMT_A1R5G5B5:
case D3DFMT_R5G6B5: case D3DFMT_R5G6B5:
case D3DFMT_X1R5G5B5:
return 5; return 5;
default: UNREACHABLE(); default: UNREACHABLE();
} }
...@@ -667,7 +665,6 @@ unsigned int GetGreenSize(D3DFORMAT colorFormat) ...@@ -667,7 +665,6 @@ unsigned int GetGreenSize(D3DFORMAT colorFormat)
case D3DFMT_X8R8G8B8: case D3DFMT_X8R8G8B8:
return 8; return 8;
case D3DFMT_A1R5G5B5: case D3DFMT_A1R5G5B5:
case D3DFMT_X1R5G5B5:
return 5; return 5;
case D3DFMT_R5G6B5: case D3DFMT_R5G6B5:
return 6; return 6;
...@@ -691,7 +688,6 @@ unsigned int GetBlueSize(D3DFORMAT colorFormat) ...@@ -691,7 +688,6 @@ unsigned int GetBlueSize(D3DFORMAT colorFormat)
return 8; return 8;
case D3DFMT_A1R5G5B5: case D3DFMT_A1R5G5B5:
case D3DFMT_R5G6B5: case D3DFMT_R5G6B5:
case D3DFMT_X1R5G5B5:
return 5; return 5;
default: UNREACHABLE(); default: UNREACHABLE();
} }
...@@ -792,3 +788,40 @@ D3DMULTISAMPLE_TYPE GetMultisampleTypeFromSamples(GLsizei samples) ...@@ -792,3 +788,40 @@ D3DMULTISAMPLE_TYPE GetMultisampleTypeFromSamples(GLsizei samples)
} }
} }
namespace dx2es
{
GLenum ConvertBackBufferFormat(D3DFORMAT format)
{
switch (format)
{
case D3DFMT_A4R4G4B4: return GL_RGBA4;
case D3DFMT_A8R8G8B8: return GL_RGBA8_OES;
case D3DFMT_A1R5G5B5: return GL_RGB5_A1;
case D3DFMT_R5G6B5: return GL_RGB565;
case D3DFMT_X8R8G8B8: return GL_RGB8_OES;
default:
UNREACHABLE();
}
return GL_RGBA4;
}
GLenum ConvertDepthStencilFormat(D3DFORMAT format)
{
switch (format)
{
case D3DFMT_D16:
case D3DFMT_D24X8:
return GL_DEPTH_COMPONENT16;
case D3DFMT_D24S8:
return GL_DEPTH24_STENCIL8_OES;
default:
UNREACHABLE();
}
return GL_DEPTH24_STENCIL8_OES;
}
}
...@@ -69,4 +69,12 @@ GLsizei GetSamplesFromMultisampleType(D3DMULTISAMPLE_TYPE type); ...@@ -69,4 +69,12 @@ GLsizei GetSamplesFromMultisampleType(D3DMULTISAMPLE_TYPE type);
} }
namespace dx2es
{
GLenum ConvertBackBufferFormat(D3DFORMAT format);
GLenum ConvertDepthStencilFormat(D3DFORMAT format);
}
#endif // LIBGLESV2_UTILITIES_H #endif // LIBGLESV2_UTILITIES_H
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