VirtGL: Continuation fix for N_SE-48185
authorFrédéric Dalleau <frederic.dalleau@linux.intel.com>
Wed, 4 Sep 2013 12:04:31 +0000 (14:04 +0200)
committerjinhyung.jo <jinhyung.jo@samsung.com>
Wed, 11 Sep 2013 09:21:01 +0000 (18:21 +0900)
Check Buffer creation result on Windows for Pixmap and PBuffers

Change-Id: I60d82a7292e68f43235ef1283228c67ec7a5369d

Conflicts:

tizen/src/hw/opengl_exec.c

tizen/src/hw/opengl_exec.c

index 93fbff2..1a29f28 100644 (file)
@@ -2159,37 +2159,43 @@ int do_function_call(ProcessState *process, int func_number, unsigned long *args
             const GLXFBConfig *fbconfig = get_fbconfig(process, client_fbconfig);
 
             if (fbconfig) {
-
                 /* Create a light-weight context just for creating surface */
                 GloContext *context = __glo_context_create(fbconfig->formatFlags);
-
-                /* glXPixmap same as input Pixmap */
-                ClientGLXDrawable client_drawable = to_drawable(args[2]);
-
-                QGloSurface *qsurface = calloc(1, sizeof(QGloSurface));
-
-                /* get the width and height */
-                int width, height;
-                glo_geometry_get_from_glx((int*)args[3], &width, &height);
-
-                DEBUGF( "glXCreatePixmap: %dX%d.\n", width, height);
-                qsurface->surface = glo_surface_create(width, height, context);
-                qsurface->client_drawable = client_drawable;
-                               qsurface->type = SURFACE_PIXMAP;
-                               qsurface->status = SURFACE_PENDING;
-                qsurface_pixmap_ref(qsurface);
-
-                /* Keep this surface, will link it with context in MakeCurrent */
-                keep_qsurface(process, qsurface);
-
-                /* If this pixmap is linked as texture previously */
-                               if (link_drawable(process, client_drawable))
-                                       glo_surface_as_texture(process->current_state->context,
-                                                       qsurface->surface, qsurface->type);
-
-
-                ret.i = (int)client_drawable;
-
+                if (context) {
+                    /* glXPixmap same as input Pixmap */
+                    ClientGLXDrawable client_drawable = to_drawable(args[2]);
+
+                    QGloSurface *qsurface = calloc(1, sizeof(QGloSurface));
+                    if (qsurface) {
+                        /* get the width and height */
+                        int width, height;
+                        glo_geometry_get_from_glx((int*)args[3], &width, &height);
+
+                        DEBUGF( "glXCreatePixmap: %dX%d.\n", width, height);
+                        qsurface->surface = glo_surface_create(width, height, context);
+                        if (qsurface->surface) {
+                            qsurface->client_drawable = client_drawable;
+                            qsurface->type = SURFACE_PIXMAP;
+                            qsurface->status = SURFACE_PENDING;
+                            qsurface_pixmap_ref(qsurface);
+
+                            /* Keep this surface, will link it with context in MakeCurrent */
+                            keep_qsurface(process, qsurface);
+
+                            /* If this pixmap is linked as texture previously */
+                            if (link_drawable(process, client_drawable))
+                                glo_surface_as_texture(process->current_state->context,
+                                        qsurface->surface, qsurface->type);
+
+                            ret.i = (int)client_drawable;
+                        } else {
+                            free(qsurface);
+                            glo_context_destroy(context);
+                        }
+                    } else {
+                        glo_context_destroy(context);
+                    }
+                }
             }
             break;
         }
@@ -2267,31 +2273,40 @@ int do_function_call(ProcessState *process, int func_number, unsigned long *args
                        ret.i = 0;
                        const GLXFBConfig *fbconfig = get_fbconfig(process, client_fbconfig);
 
-                       if (fbconfig) {
-
-                               /* Create a light-weight context just for creating surface */
-                               GloContext *context = __glo_context_create(fbconfig->formatFlags);
-
-                               QGloSurface *qsurface = calloc(1, sizeof(QGloSurface));
-
-                               /* get the width and height */
-                               int width, height;
-                               glo_geometry_get_from_glx((int*)args[2], &width, &height);
-
-                               DEBUGF( "glXCreatePbuffer: %dX%d.\n", width, height);
-                               qsurface->surface = glo_surface_create(width, height, context);
-                               /* Use GloSurface handler as no input client_drawable, and
-                                * keep only low 32bit of handler on x86_64 host.  */
-                               qsurface->client_drawable = (ClientGLXDrawable)(long)qsurface->surface;
-                               qsurface->type = SURFACE_PBUFFER;
-                               qsurface->status = SURFACE_PENDING;
-                               /*                qsurface->ref = 1;*/
-
-                               /* Keep this surface, will link it with context in MakeCurrent */
-                               keep_qsurface(process, qsurface);
+            if (fbconfig) {
 
-                               ret.i = qsurface->client_drawable;
-                       }
+                /* Create a light-weight context just for creating surface */
+                GloContext *context = __glo_context_create(fbconfig->formatFlags);
+                if (context) {
+                    QGloSurface *qsurface = calloc(1, sizeof(QGloSurface));
+                    if (qsurface) {
+                        /* get the width and height */
+                        int width, height;
+                        glo_geometry_get_from_glx((int*)args[2], &width, &height);
+
+                        DEBUGF( "glXCreatePbuffer: %dX%d.\n", width, height);
+                        qsurface->surface = glo_surface_create(width, height, context);
+                        if (qsurface->surface) {
+                            /* Use GloSurface handler as no input client_drawable, and
+                             * keep only low 32bit of handler on x86_64 host.  */
+                            qsurface->client_drawable = (ClientGLXDrawable)(long)qsurface->surface;
+                            qsurface->type = SURFACE_PBUFFER;
+                            qsurface->status = SURFACE_PENDING;
+                            /*                qsurface->ref = 1;*/
+
+                            /* Keep this surface, will link it with context in MakeCurrent */
+                            keep_qsurface(process, qsurface);
+
+                            ret.i = qsurface->client_drawable;
+                        } else {
+                            free(qsurface);
+                            glo_context_destroy(context);
+                        }
+                    } else {
+                        glo_context_destroy(context);
+                    }
+                }
+            }
                        break;
                }
        case glXDestroyPbuffer_func: