intel: Implement EGL_KHR_surfaceless extension
authorKristian Høgsberg <krh@bitplanet.net>
Fri, 4 Jun 2010 18:28:59 +0000 (14:28 -0400)
committerKristian Høgsberg <krh@bitplanet.net>
Thu, 29 Jul 2010 03:07:09 +0000 (23:07 -0400)
src/mesa/drivers/dri/intel/intel_context.c
src/mesa/main/fbobject.c
src/mesa/main/fbobject.h
src/mesa/main/framebuffer.c

index 87513a2a59584b07e2b717128fcaf747d0ebe681..531f62b88074d39a2cd3d10e11d289c23b7b725f 100644 (file)
@@ -418,7 +418,7 @@ intel_prepare_render(struct intel_context *intel)
    __DRIdrawable *drawable;
 
    drawable = driContext->driDrawablePriv;
-   if (drawable->dri2.stamp != driContext->dri2.draw_stamp) {
+   if (drawable && drawable->dri2.stamp != driContext->dri2.draw_stamp) {
       if (drawable->lastStamp != drawable->dri2.stamp)
         intel_update_renderbuffers(driContext, drawable);
       intel_draw_buffer(&intel->ctx, intel->ctx.DrawBuffer);
@@ -426,7 +426,7 @@ intel_prepare_render(struct intel_context *intel)
    }
 
    drawable = driContext->driReadablePriv;
-   if (drawable->dri2.stamp != driContext->dri2.read_stamp) {
+   if (drawable && drawable->dri2.stamp != driContext->dri2.read_stamp) {
       if (drawable->lastStamp != drawable->dri2.stamp)
         intel_update_renderbuffers(driContext, drawable);
       driContext->dri2.read_stamp = drawable->dri2.stamp;
@@ -611,6 +611,7 @@ intelInitContext(struct intel_context *intel,
    __DRIscreen *sPriv = driContextPriv->driScreenPriv;
    struct intel_screen *intelScreen = sPriv->private;
    int bo_reuse_mode;
+   __GLcontextModes visual;
 
    /* we can't do anything without a connection to the device */
    if (intelScreen->bufmgr == NULL)
@@ -622,6 +623,11 @@ intelInitContext(struct intel_context *intel,
       functions->Viewport = intel_viewport;
    }
 
+   if (mesaVis == NULL) {
+      memset(&visual, 0, sizeof visual);
+      mesaVis = &visual;
+   }
+
    if (!_mesa_initialize_context_for_api(&intel->ctx, api, mesaVis, shareCtx,
                                         functions, (void *) intel)) {
       printf("%s: failed to init mesa context\n", __FUNCTION__);
@@ -888,14 +894,21 @@ intelMakeCurrent(__DRIcontext * driContextPriv,
    }
 
    if (driContextPriv) {
-      struct gl_framebuffer *fb = driDrawPriv->driverPrivate;
-      struct gl_framebuffer *readFb = driReadPriv->driverPrivate;
+      struct gl_framebuffer *fb, *readFb;
+      
+      if (driDrawPriv == NULL && driReadPriv == NULL) {
+        fb = _mesa_get_incomplete_framebuffer();
+        readFb = _mesa_get_incomplete_framebuffer();
+      } else {
+        fb = driDrawPriv->driverPrivate;
+        readFb = driReadPriv->driverPrivate;
+        driContextPriv->dri2.draw_stamp = driDrawPriv->dri2.stamp - 1;
+        driContextPriv->dri2.read_stamp = driReadPriv->dri2.stamp - 1;
+      }
 
-      driContextPriv->dri2.draw_stamp = driDrawPriv->dri2.stamp - 1;
-      driContextPriv->dri2.read_stamp = driReadPriv->dri2.stamp - 1;
       intel_prepare_render(intel);
       _mesa_make_current(&intel->ctx, fb, readFb);
-
+      
       /* We do this in intel_prepare_render() too, but intel->ctx.DrawBuffer
        * is NULL at that point.  We can't call _mesa_makecurrent()
        * first, since we need the buffer size for the initial
index 8c86b392c7b06e9d77afaa6dff1655e58607607d..9a84e5a79cff835aa3f14fd8c680f1d8decd3ddb 100644 (file)
@@ -97,6 +97,11 @@ _mesa_init_fbobjects(GLcontext *ctx)
    DummyRenderbuffer.Delete = delete_dummy_renderbuffer;
 }
 
+struct gl_framebuffer *
+_mesa_get_incomplete_framebuffer(void)
+{
+   return &DummyFramebuffer;
+}
 
 /**
  * Helper routine for getting a gl_renderbuffer.
index ff946033a4ddd0150439611e58ae700d38ae4189..5215e930f9504de58ff46e52beb21360f1214595 100644 (file)
@@ -30,6 +30,9 @@
 extern void
 _mesa_init_fbobjects(GLcontext *ctx);
 
+extern struct gl_framebuffer *
+_mesa_get_incomplete_framebuffer(void);
+
 extern struct gl_renderbuffer *
 _mesa_lookup_renderbuffer(GLcontext *ctx, GLuint id);
 
index 56558cfcc1edf43de3b7b247f0343edcd009c217..e0aac26f62b692e122c9d2d8800cf121b821242c 100644 (file)
@@ -75,7 +75,6 @@ compute_depth_max(struct gl_framebuffer *fb)
    fb->_MRD = (GLfloat)1.0 / fb->_DepthMaxF;
 }
 
-
 /**
  * Create and initialize a gl_framebuffer object.
  * This is intended for creating _window_system_ framebuffers, not generic