Fix for error while running gfxbench with Fastpath.
authormythri.venugopal <mythri.venugopal@samsung.com>
Fri, 31 Jan 2014 14:51:02 +0000 (14:51 +0000)
committermythri.venugopal <mythri.venugopal@samsung.com>
Fri, 31 Jan 2014 14:56:09 +0000 (14:56 +0000)
According to spec, glDrawBuffers return GL_INVALID_OPERATION if the GL is bound to the default framebuffer and n is not 1.
http://www.khronos.org/opengles/sdk/docs/man3/xhtml/glDrawBuffers.xml

src/modules/fastpath/coregl_fastpath.c

index a82bff5..de995b5 100644 (file)
@@ -1089,6 +1089,34 @@ finish:
        return ret;
 }
 
+
+/* Check if the context's state contains object of a given type */
+GLuint
+fastpath_ostate_has_object_type(GL_Object_State *ostate, GL_Object_Type type)
+{
+       GLuint ret = _COREGL_INT_INIT_VALUE;
+
+       GL_Object_Hash_Base *hash_base = NULL;
+       GL_Object *object = NULL;
+       hash_base = _lock_gl_object_hash(ostate, type);
+
+       if(hash_base->hash_field == 0)
+       {
+               ret = 0;
+               goto finish;
+       }
+
+       FIND_OBJ_FROM_HASH_WITH_VERIFY(hash_base, 1, object);
+
+       ret = object->real_id;
+       goto finish;
+
+finish:
+       _unlock_gl_object_hash(ostate, type);
+       return ret;
+}
+
+
 GLint
 fastpath_ostate_set_object_tag(GL_Object_State *ostate, GL_Object_Type type, GLuint glue_name, GLvoid *tag)
 {
@@ -2074,7 +2102,13 @@ fastpath_make_context_current(GLGlueContext *oldctx, GLGlueContext *newctx)
                }
                STATES_COMPARE(gl_draw_buffers, 16 * sizeof(GLenum))
                {
-                       CHECK_GL_ERROR(_orig_fastpath_glDrawBuffers(16, newctx->gl_draw_buffers))
+                       int drawBuffSize = 16;
+                       /* If the  context has only default framebuffer, then size of glDrawBuffers can only be 1 */
+                       if(fastpath_ostate_has_object_type(&newctx->ostate, GL_OBJECT_TYPE_FRAMEBUFFER) == 0) {
+                               drawBuffSize = 1;
+                       }
+
+                       CHECK_GL_ERROR(_orig_fastpath_glDrawBuffers(drawBuffSize, newctx->gl_draw_buffers))
                }
                STATE_COMPARE(gl_vertex_array_binding[0])
                {