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
mBlueSize = 5;
mAlphaSize = 0;
break;
case D3DFMT_X1R5G5B5:
mBufferSize = 16;
mRedSize = 5;
mGreenSize = 5;
mBlueSize = 5;
mAlphaSize = 0;
break;
case D3DFMT_X8R8G8B8:
mBufferSize = 32;
mRedSize = 8;
......
......@@ -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_A8R8G8B8,
D3DFMT_R5G6B5,
D3DFMT_X1R5G5B5,
// D3DFMT_X1R5G5B5, // Has no compatible OpenGL ES renderbuffer format
D3DFMT_X8R8G8B8
};
......
......@@ -2242,16 +2242,6 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum
r = (rgb & 0xF800) * (1.0f / 0xF800);
}
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:
{
unsigned short argb = *(unsigned short*)(source + 2 * i + j * lock.Pitch);
......
......@@ -438,8 +438,8 @@ GLenum Framebuffer::completeness()
DefaultFramebuffer::DefaultFramebuffer(Colorbuffer *color, DepthStencilbuffer *depthStencil)
{
mColorbufferType = GL_RENDERBUFFER;
mDepthbufferType = GL_RENDERBUFFER;
mStencilbufferType = GL_RENDERBUFFER;
mDepthbufferType = (depthStencil->getDepthSize() != 0) ? GL_RENDERBUFFER : GL_NONE;
mStencilbufferType = (depthStencil->getStencilSize() != 0) ? GL_RENDERBUFFER : GL_NONE;
mColorbufferPointer.set(new Renderbuffer(0, color));
......@@ -462,6 +462,9 @@ int Framebuffer::getSamples()
GLenum DefaultFramebuffer::completeness()
{
// The default framebuffer should always be complete
ASSERT(Framebuffer::completeness() == GL_FRAMEBUFFER_COMPLETE);
return GL_FRAMEBUFFER_COMPLETE;
}
......
......@@ -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;
mVertexShader = NULL;
......@@ -63,8 +63,6 @@ Program::Program(ResourceManager *manager, GLuint handle) : mResourceManager(man
mDeleteStatus = false;
mRefCount = 0;
mSerial = issueSerial();
}
Program::~Program()
......
......@@ -220,7 +220,7 @@ class Program
unsigned int mRefCount;
unsigned int mSerial;
const unsigned int mSerial;
static unsigned int mCurrentSerial;
......
......@@ -87,9 +87,13 @@ void Renderbuffer::setStorage(RenderbufferStorage *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()
......@@ -177,14 +181,10 @@ Colorbuffer::Colorbuffer(IDirect3DSurface9 *renderTarget) : mRenderTarget(render
renderTarget->GetDesc(&description);
setSize(description.Width, description.Height);
mFormat = dx2es::ConvertBackBufferFormat(description.Format);
mD3DFormat = description.Format;
mSamples = es2dx::GetSamplesFromMultisampleType(description.MultiSampleType);
}
else
{
mD3DFormat = D3DFMT_UNKNOWN;
mSamples = 0;
}
}
Colorbuffer::Colorbuffer(const Texture* texture) : mRenderTarget(NULL)
......@@ -231,13 +231,6 @@ Colorbuffer::Colorbuffer(int width, int height, GLenum format, GLsizei samples)
mD3DFormat = requestedFormat;
mSamples = supportedSamples;
}
else
{
setSize(0, 0);
mFormat = GL_RGBA4;
mD3DFormat = D3DFMT_UNKNOWN;
mSamples = 0;
}
}
Colorbuffer::~Colorbuffer()
......@@ -320,15 +313,10 @@ DepthStencilbuffer::DepthStencilbuffer(IDirect3DSurface9 *depthStencil) : mDepth
depthStencil->GetDesc(&description);
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);
mD3DFormat = description.Format;
}
else
{
mD3DFormat = D3DFMT_UNKNOWN;
mSamples = 0;
}
}
DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples)
......@@ -365,13 +353,6 @@ DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples)
mD3DFormat = D3DFMT_D24S8;
mSamples = supportedSamples;
}
else
{
setSize(0, 0);
mFormat = GL_RGBA4; //default format
mD3DFormat = D3DFMT_UNKNOWN;
mSamples = 0;
}
}
DepthStencilbuffer::~DepthStencilbuffer()
......
......@@ -55,7 +55,7 @@ class RenderbufferStorage
GLenum mFormat;
D3DFORMAT mD3DFormat;
GLsizei mSamples;
unsigned int mSerial;
const unsigned int mSerial;
private:
DISALLOW_COPY_AND_ASSIGN(RenderbufferStorage);
......
......@@ -623,7 +623,6 @@ unsigned int GetAlphaSize(D3DFORMAT colorFormat)
case D3DFMT_A1R5G5B5:
return 1;
case D3DFMT_X8R8G8B8:
case D3DFMT_X1R5G5B5:
case D3DFMT_R5G6B5:
return 0;
default: UNREACHABLE();
......@@ -646,7 +645,6 @@ unsigned int GetRedSize(D3DFORMAT colorFormat)
return 8;
case D3DFMT_A1R5G5B5:
case D3DFMT_R5G6B5:
case D3DFMT_X1R5G5B5:
return 5;
default: UNREACHABLE();
}
......@@ -667,7 +665,6 @@ unsigned int GetGreenSize(D3DFORMAT colorFormat)
case D3DFMT_X8R8G8B8:
return 8;
case D3DFMT_A1R5G5B5:
case D3DFMT_X1R5G5B5:
return 5;
case D3DFMT_R5G6B5:
return 6;
......@@ -691,7 +688,6 @@ unsigned int GetBlueSize(D3DFORMAT colorFormat)
return 8;
case D3DFMT_A1R5G5B5:
case D3DFMT_R5G6B5:
case D3DFMT_X1R5G5B5:
return 5;
default: UNREACHABLE();
}
......@@ -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);
}
namespace dx2es
{
GLenum ConvertBackBufferFormat(D3DFORMAT format);
GLenum ConvertDepthStencilFormat(D3DFORMAT format);
}
#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