aboutsummaryrefslogtreecommitdiffstats
path: root/emulator
diff options
context:
space:
mode:
authorbohu <bohu@google.com>2014-11-06 16:11:09 -0800
committerbohu <bohu@google.com>2014-11-25 12:31:49 -0800
commit1e27d3eda4d96227f97bb18185e3923e6375abfa (patch)
tree8212fda6421e438a5879bb4da21eb3495f20b6f0 /emulator
parentd3a31ab8b369cad6dc40a66fc3bb9c6b0bef0c11 (diff)
downloadsdk-1e27d3eda4d96227f97bb18185e3923e6375abfa.zip
sdk-1e27d3eda4d96227f97bb18185e3923e6375abfa.tar.gz
sdk-1e27d3eda4d96227f97bb18185e3923e6375abfa.tar.bz2
Correctly set error code
Fixed a few error codes to be more accurate Change-Id: Ifad6bf51c399215a9110bd40cfd380309ac6422c
Diffstat (limited to 'emulator')
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp31
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp1
2 files changed, 28 insertions, 4 deletions
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
index 780555e..7f4cd4f 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
@@ -1143,7 +1143,10 @@ GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target
FramebufferData *fbData = (FramebufferData *)fbObj.Ptr();
GLenum target;
GLuint name = fbData->getAttachment(attachment, &target, NULL);
- SET_ERROR_IF(!name && pname != GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_INVALID_ENUM);
+ if (!name) {
+ SET_ERROR_IF(pname != GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE &&
+ pname != GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, GL_INVALID_ENUM);
+ }
if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE) {
if (target == GL_TEXTURE_2D) {
*params = GL_TEXTURE;
@@ -1152,6 +1155,8 @@ GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target
else if (target == GL_RENDERBUFFER) {
*params = GL_RENDERBUFFER;
return;
+ } else {
+ *params = GL_NONE;
}
}
else if (pname == GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME) {
@@ -1500,10 +1505,15 @@ GL_APICALL int GL_APIENTRY glGetUniformLocation(GLuint program, const GLchar* na
return -1;
}
-
+static bool s_invalidVertexAttribIndex(GLuint index) {
+ GLint param=0;
+ glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &param);
+ return (param < 0 || index >= (GLuint)param);
+}
GL_APICALL void GL_APIENTRY glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params){
GET_CTX_V2();
+ SET_ERROR_IF(s_invalidVertexAttribIndex(index), GL_INVALID_VALUE);
const GLESpointer* p = ctx->getPointer(index);
if(p) {
switch(pname){
@@ -1545,6 +1555,7 @@ GL_APICALL void GL_APIENTRY glGetVertexAttribfv(GLuint index, GLenum pname, GLf
GL_APICALL void GL_APIENTRY glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params){
GET_CTX_V2();
+ SET_ERROR_IF(s_invalidVertexAttribIndex(index), GL_INVALID_VALUE);
const GLESpointer* p = ctx->getPointer(index);
if(p) {
switch(pname){
@@ -1621,7 +1632,8 @@ GL_APICALL GLboolean GL_APIENTRY glIsBuffer(GLuint buffer){
GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer){
GET_CTX_RET(GL_FALSE)
if(framebuffer && ctx->shareGroup().Ptr()){
- return ctx->shareGroup()->isObject(FRAMEBUFFER,framebuffer) ? GL_TRUE :GL_FALSE;
+ return (ctx->shareGroup()->isObject(FRAMEBUFFER,framebuffer) &&
+ ctx->getFramebufferBinding() == framebuffer) ? GL_TRUE :GL_FALSE;
}
return GL_FALSE;
}
@@ -1629,7 +1641,8 @@ GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer){
GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer){
GET_CTX_RET(GL_FALSE)
if(renderbuffer && ctx->shareGroup().Ptr()){
- return ctx->shareGroup()->isObject(RENDERBUFFER,renderbuffer) ? GL_TRUE :GL_FALSE;
+ return (ctx->shareGroup()->isObject(RENDERBUFFER,renderbuffer) &&
+ ctx->getRenderbufferBinding() == renderbuffer) ? GL_TRUE :GL_FALSE;
}
return GL_FALSE;
}
@@ -1721,7 +1734,9 @@ GL_APICALL void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units){
GL_APICALL void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels){
GET_CTX();
SET_ERROR_IF(!(GLESv2Validate::readPixelFrmt(format) && GLESv2Validate::pixelType(ctx,type)),GL_INVALID_ENUM);
+ SET_ERROR_IF((width < 0 || height < 0),GL_INVALID_VALUE);
SET_ERROR_IF(!(GLESv2Validate::pixelOp(format,type)),GL_INVALID_OPERATION);
+ SET_ERROR_IF(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE, GL_INVALID_FRAMEBUFFER_OPERATION);
ctx->dispatcher().glReadPixels(x,y,width,height,format,type,pixels);
}
@@ -1837,6 +1852,14 @@ GL_APICALL void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass
GL_APICALL void GL_APIENTRY glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass){
GET_CTX();
+ switch (face) {
+ case GL_FRONT:
+ case GL_BACK:
+ case GL_FRONT_AND_BACK:
+ break;
+ default:
+ SET_ERROR_IF(1, GL_INVALID_ENUM);
+ }
ctx->dispatcher().glStencilOp(fail,zfail,zpass);
}
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp
index 3f00428..b711317 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp
@@ -113,6 +113,7 @@ bool GLESv2Validate::pixelStoreParam(GLenum param){
bool GLESv2Validate::readPixelFrmt(GLenum format){
switch(format) {
case GL_ALPHA:
+ case GL_LUMINANCE_ALPHA:
case GL_RGB:
case GL_RGBA:
return true;