Fix issues raised by the GLES 1.1 conformance test
- Most of the fixes are about unhandled enums. - Adding an unbindBuffer method to GLEScontext, and use it in the glDeleteBuffers call, so a buffer is not considered bound after it has been deleted. - Handle the case where a call to glCompressedTexImage2D gets NULL as its data (in which case the uncompressTexture function should only calculate the output format, but not attempt to uncompress the NULL data). - A few segfaults. Change-Id: I6a856ea6da1be3b15b41140d6383508a6803897c
This commit is contained in:
@@ -337,7 +337,6 @@ GL_API void GL_APIENTRY glCompressedTexImage2D( GLenum target, GLint level, GLe
|
||||
tmpHeight/=2;
|
||||
delete uncompressed;
|
||||
}
|
||||
ctx->dispatcher().glCompressedTexImage2D(target,level,internalformat,width,height,border,imageSize,data);
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) {
|
||||
@@ -375,6 +374,7 @@ GL_API void GL_APIENTRY glDeleteBuffers( GLsizei n, const GLuint *buffers) {
|
||||
if(thrd->shareGroup.Ptr()) {
|
||||
for(int i=0; i < n; i++){
|
||||
thrd->shareGroup->deleteName(VERTEXBUFFER,buffers[i]);
|
||||
ctx->unbindBuffer(buffers[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -555,7 +555,18 @@ GL_API void GL_APIENTRY glGenTextures( GLsizei n, GLuint *textures) {
|
||||
|
||||
GL_API void GL_APIENTRY glGetBooleanv( GLenum pname, GLboolean *params) {
|
||||
GET_CTX()
|
||||
ctx->dispatcher().glGetBooleanv(pname,params);
|
||||
switch(pname)
|
||||
{
|
||||
case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
|
||||
case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
|
||||
GLint i;
|
||||
glGetIntegerv(pname, &i);
|
||||
*params = (i != 0) ? GL_TRUE : GL_FALSE;
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx->dispatcher().glGetBooleanv(pname,params);
|
||||
}
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glGetBufferParameteriv( GLenum target, GLenum pname, GLint *params) {
|
||||
@@ -596,22 +607,56 @@ GL_API void GL_APIENTRY glGetClipPlanex( GLenum pname, GLfixed eqn[4]) {
|
||||
|
||||
GL_API void GL_APIENTRY glGetFixedv( GLenum pname, GLfixed *params) {
|
||||
GET_CTX()
|
||||
size_t nParams = glParamSize(pname);
|
||||
GLfloat fParams[16];
|
||||
ctx->dispatcher().glGetFloatv(pname,fParams);
|
||||
for(size_t i =0 ; i < nParams;i++) {
|
||||
params[i] = F2X(fParams[i]);
|
||||
switch(pname)
|
||||
{
|
||||
case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
|
||||
case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
|
||||
GLint i;
|
||||
glGetIntegerv(pname, &i);
|
||||
*params = I2X(i);
|
||||
break;
|
||||
|
||||
default:
|
||||
size_t nParams = glParamSize(pname);
|
||||
GLfloat fParams[16];
|
||||
ctx->dispatcher().glGetFloatv(pname,fParams);
|
||||
for(size_t i =0 ; i < nParams;i++) {
|
||||
params[i] = F2X(fParams[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glGetFloatv( GLenum pname, GLfloat *params) {
|
||||
GET_CTX()
|
||||
ctx->dispatcher().glGetFloatv(pname,params);
|
||||
switch(pname)
|
||||
{
|
||||
case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
|
||||
case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
|
||||
GLint i;
|
||||
glGetIntegerv(pname, &i);
|
||||
*params = (GLfloat)i;
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx->dispatcher().glGetFloatv(pname,params);
|
||||
}
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glGetIntegerv( GLenum pname, GLint *params) {
|
||||
GET_CTX()
|
||||
ctx->dispatcher().glGetIntegerv(pname,params);
|
||||
switch(pname)
|
||||
{
|
||||
case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
|
||||
*params = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
|
||||
case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
|
||||
*params = GL_RGBA;
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx->dispatcher().glGetIntegerv(pname,params);
|
||||
}
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glGetLightfv( GLenum light, GLenum pname, GLfloat *params) {
|
||||
@@ -632,6 +677,11 @@ GL_API void GL_APIENTRY glGetLightxv( GLenum light, GLenum pname, GLfixed *para
|
||||
params[3] = F2X(tmpParams[3]);
|
||||
case GL_SPOT_DIRECTION:
|
||||
params[2] = F2X(tmpParams[2]);
|
||||
case GL_SPOT_EXPONENT:
|
||||
case GL_SPOT_CUTOFF:
|
||||
case GL_CONSTANT_ATTENUATION:
|
||||
case GL_LINEAR_ATTENUATION:
|
||||
case GL_QUADRATIC_ATTENUATION:
|
||||
params[1] = F2X(tmpParams[1]);
|
||||
break;
|
||||
default:{
|
||||
@@ -663,6 +713,7 @@ GL_API void GL_APIENTRY glGetMaterialxv( GLenum face, GLenum pname, GLfixed *pa
|
||||
params[1] = tmpParams[1];
|
||||
case GL_SHININESS:
|
||||
params[0] = tmpParams[0];
|
||||
break;
|
||||
default:{
|
||||
ctx->setGLerror(GL_INVALID_ENUM);
|
||||
return;
|
||||
@@ -780,18 +831,24 @@ GL_API void GL_APIENTRY glLightxv( GLenum light, GLenum pname, const GLfixed *p
|
||||
case GL_AMBIENT:
|
||||
case GL_DIFFUSE:
|
||||
case GL_SPECULAR:
|
||||
case GL_EMISSION:
|
||||
case GL_POSITION:
|
||||
tmpParams[3] = X2F(params[3]);
|
||||
case GL_SPOT_DIRECTION:
|
||||
tmpParams[2] = X2F(params[2]);
|
||||
tmpParams[1] = X2F(params[1]);
|
||||
case GL_SPOT_EXPONENT:
|
||||
case GL_SPOT_CUTOFF:
|
||||
case GL_CONSTANT_ATTENUATION:
|
||||
case GL_LINEAR_ATTENUATION:
|
||||
case GL_QUADRATIC_ATTENUATION:
|
||||
tmpParams[0] = X2F(params[0]);
|
||||
break;
|
||||
default: {
|
||||
ctx->setGLerror(GL_INVALID_ENUM);
|
||||
return;
|
||||
}
|
||||
}
|
||||
tmpParams[0] = X2F(params[0]);
|
||||
ctx->dispatcher().glLightfv(light,pname,tmpParams);
|
||||
}
|
||||
|
||||
@@ -935,14 +992,9 @@ GL_API void GL_APIENTRY glPointParameterx( GLenum pname, GLfixed param)
|
||||
|
||||
GL_API void GL_APIENTRY glPointParameterxv( GLenum pname, const GLfixed *params) {
|
||||
GET_CTX()
|
||||
GLfloat tmpParams[3];
|
||||
int i = 0;
|
||||
|
||||
do {
|
||||
tmpParams[i] = X2F(params[i]);
|
||||
i++;
|
||||
}while(pname != GL_POINT_DISTANCE_ATTENUATION);
|
||||
ctx->dispatcher().glPointParameterfv(pname,tmpParams);
|
||||
GLfloat tmpParam = X2F(*params) ;
|
||||
ctx->dispatcher().glPointParameterfv(pname,&tmpParam);
|
||||
}
|
||||
|
||||
GL_API void GL_APIENTRY glPointSize( GLfloat size) {
|
||||
|
||||
@@ -45,7 +45,6 @@ bool GLEScmValidate::alphaFunc(GLenum f) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool GLEScmValidate::vertexPointerParams(GLint size,GLsizei stride) {
|
||||
return ((size >=2) && (size <= 4)) && (stride >=0) ;
|
||||
}
|
||||
@@ -55,7 +54,7 @@ bool GLEScmValidate::colorPointerParams(GLint size,GLsizei stride) {
|
||||
}
|
||||
|
||||
bool GLEScmValidate::texCoordPointerParams(GLint size,GLsizei stride) {
|
||||
return ((size >=1) && (size <= 4)) && (stride >=0) ;
|
||||
return ((size >=2) && (size <= 4)) && (stride >=0) ;
|
||||
}
|
||||
|
||||
bool GLEScmValidate::supportedArrays(GLenum arr) {
|
||||
@@ -107,6 +106,7 @@ bool GLEScmValidate::texParams(GLenum target,GLenum pname) {
|
||||
bool GLEScmValidate::texEnv(GLenum target,GLenum pname) {
|
||||
switch(pname) {
|
||||
case GL_TEXTURE_ENV_MODE:
|
||||
case GL_TEXTURE_ENV_COLOR:
|
||||
case GL_COMBINE_RGB:
|
||||
case GL_COMBINE_ALPHA:
|
||||
case GL_SRC0_RGB:
|
||||
@@ -204,6 +204,7 @@ bool GLEScmValidate::blendSrc(GLenum s) {
|
||||
case GL_ONE_MINUS_SRC_ALPHA:
|
||||
case GL_DST_ALPHA:
|
||||
case GL_ONE_MINUS_DST_ALPHA:
|
||||
case GL_SRC_ALPHA_SATURATE:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -39,11 +39,12 @@ void getPaletteInfo(GLenum internalFormat,unsigned int& indexSizeBits,unsigned i
|
||||
case GL_PALETTE4_RGBA8_OES:
|
||||
indexSizeBits = 4;
|
||||
colorSizeBytes = 4;
|
||||
colorFrmt = GL_RGBA;
|
||||
colorFrmt = GL_RGBA;
|
||||
break;
|
||||
|
||||
case GL_PALETTE4_RGBA4_OES:
|
||||
colorFrmt = GL_RGBA;
|
||||
colorFrmt = GL_RGBA;
|
||||
/* fall-through */
|
||||
case GL_PALETTE4_R5_G6_B5_OES:
|
||||
case GL_PALETTE4_RGB5_A1_OES:
|
||||
indexSizeBits = 4;
|
||||
@@ -58,9 +59,12 @@ void getPaletteInfo(GLenum internalFormat,unsigned int& indexSizeBits,unsigned i
|
||||
case GL_PALETTE8_RGBA8_OES:
|
||||
indexSizeBits = 8;
|
||||
colorSizeBytes = 4;
|
||||
colorFrmt = GL_RGBA;
|
||||
colorFrmt = GL_RGBA;
|
||||
break;
|
||||
|
||||
case GL_PALETTE8_RGBA4_OES:
|
||||
colorFrmt = GL_RGBA;
|
||||
/* fall-through */
|
||||
case GL_PALETTE8_R5_G6_B5_OES:
|
||||
case GL_PALETTE8_RGB5_A1_OES:
|
||||
indexSizeBits = 8;
|
||||
@@ -104,9 +108,13 @@ unsigned char* uncompressTexture(GLenum internalformat,GLenum& formatOut,GLsizei
|
||||
unsigned int indexSizeBits; //the size of the color index in the pallete
|
||||
unsigned int colorSizeBytes; //the size of each color cell in the pallete
|
||||
|
||||
const unsigned char* palette = static_cast<const unsigned char *>(data);
|
||||
|
||||
getPaletteInfo(internalformat,indexSizeBits,colorSizeBytes,formatOut);
|
||||
if(!data)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const unsigned char* palette = static_cast<const unsigned char *>(data);
|
||||
|
||||
//the pallete positioned in the begininng of the data
|
||||
// so we jump over it to get to the colos indices in the palette
|
||||
|
||||
@@ -68,7 +68,18 @@ bool GLEScontext::isArrEnabled(GLenum arr) {
|
||||
}
|
||||
|
||||
const GLESpointer* GLEScontext::getPointer(GLenum arrType) {
|
||||
if(m_map.find(arrType) != m_map.end()) return m_map[arrType];
|
||||
GLenum type =
|
||||
arrType == GL_VERTEX_ARRAY_POINTER ? GL_VERTEX_ARRAY :
|
||||
arrType == GL_NORMAL_ARRAY_POINTER ? GL_NORMAL_ARRAY :
|
||||
arrType == GL_TEXTURE_COORD_ARRAY_POINTER ? GL_TEXTURE_COORD_ARRAY :
|
||||
arrType == GL_COLOR_ARRAY_POINTER ? GL_COLOR_ARRAY :
|
||||
arrType == GL_POINT_SIZE_ARRAY_POINTER_OES ? GL_POINT_SIZE_ARRAY_OES :
|
||||
0;
|
||||
|
||||
if(type != 0 && m_map.find(type) != m_map.end())
|
||||
{
|
||||
return m_map[type];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -268,6 +279,17 @@ void GLEScontext::bindBuffer(GLenum target,GLuint buffer) {
|
||||
}
|
||||
}
|
||||
|
||||
void GLEScontext::unbindBuffer(GLuint buffer) {
|
||||
if(m_arrayBuffer == buffer)
|
||||
{
|
||||
m_arrayBuffer = 0;
|
||||
}
|
||||
if(m_elementBuffer == buffer)
|
||||
{
|
||||
m_elementBuffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//checks if any buffer is binded to target
|
||||
bool GLEScontext::isBindedBuffer(GLenum target) {
|
||||
if(target == GL_ARRAY_BUFFER) {
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
const GLESpointer* getPointer(GLenum arrType);
|
||||
virtual void convertArrs(GLESFloatArrays& fArrs,GLint first,GLsizei count,GLenum type,const GLvoid* indices,bool direct) = 0;
|
||||
void bindBuffer(GLenum target,GLuint buffer);
|
||||
void unbindBuffer(GLuint buffer);
|
||||
bool isBuffer(GLuint buffer);
|
||||
bool isBindedBuffer(GLenum target);
|
||||
GLvoid* getBindedBuffer(GLenum target);
|
||||
|
||||
@@ -25,5 +25,6 @@
|
||||
(d) < -32768.65535 ? -32768 * 65536 + 65535 : \
|
||||
((GLfixed) ((d) * 65536)))
|
||||
|
||||
#define I2X(d) ((d)*65536)
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user