diff mbox

[2/6] dri/intel: Split out DRI2 buffer update code to separate function

Message ID 1383261196-25093-3-git-send-email-keithp@keithp.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Keith Packard Oct. 31, 2013, 11:13 p.m. UTC
Make an easy place to splice in a DRI3 version of this function

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 src/mesa/drivers/dri/i915/intel_context.c | 90 +++++++++++++++++--------------
 src/mesa/drivers/dri/i965/brw_context.c   | 22 ++++++--
 2 files changed, 68 insertions(+), 44 deletions(-)

Comments

Kristian Høgsberg Nov. 1, 2013, 5:51 p.m. UTC | #1
On Thu, Oct 31, 2013 at 04:13:12PM -0700, Keith Packard wrote:
> Make an easy place to splice in a DRI3 version of this function
> 
> Signed-off-by: Keith Packard <keithp@keithp.com>
> ---
>  src/mesa/drivers/dri/i915/intel_context.c | 90 +++++++++++++++++--------------
>  src/mesa/drivers/dri/i965/brw_context.c   | 22 ++++++--
>  2 files changed, 68 insertions(+), 44 deletions(-)

Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>

> diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c
> index 2748514..1798bc7 100644
> --- a/src/mesa/drivers/dri/i915/intel_context.c
> +++ b/src/mesa/drivers/dri/i915/intel_context.c
> @@ -133,15 +133,58 @@ intel_process_dri2_buffer(struct intel_context *intel,
>  			  struct intel_renderbuffer *rb,
>  			  const char *buffer_name);
>  
> -void
> -intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
> +static void
> +intel_update_dri2_buffers(struct intel_context *intel, __DRIdrawable *drawable)
>  {
> -   struct gl_framebuffer *fb = drawable->driverPrivate;
> -   struct intel_renderbuffer *rb;
> -   struct intel_context *intel = context->driverPrivate;
>     __DRIbuffer *buffers = NULL;
>     int i, count;
>     const char *region_name;
> +   struct intel_renderbuffer *rb;
> +   struct gl_framebuffer *fb = drawable->driverPrivate;
> +
> +   intel_query_dri2_buffers(intel, drawable, &buffers, &count);
> +
> +   if (buffers == NULL)
> +      return;
> +
> +   for (i = 0; i < count; i++) {
> +      switch (buffers[i].attachment) {
> +      case __DRI_BUFFER_FRONT_LEFT:
> +         rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
> +         region_name = "dri2 front buffer";
> +         break;
> +
> +      case __DRI_BUFFER_FAKE_FRONT_LEFT:
> +         rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
> +         region_name = "dri2 fake front buffer";
> +         break;
> +
> +      case __DRI_BUFFER_BACK_LEFT:
> +         rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
> +         region_name = "dri2 back buffer";
> +         break;
> +
> +      case __DRI_BUFFER_DEPTH:
> +      case __DRI_BUFFER_HIZ:
> +      case __DRI_BUFFER_DEPTH_STENCIL:
> +      case __DRI_BUFFER_STENCIL:
> +      case __DRI_BUFFER_ACCUM:
> +      default:
> +         fprintf(stderr,
> +                 "unhandled buffer attach event, attachment type %d\n",
> +                 buffers[i].attachment);
> +         return;
> +      }
> +
> +      intel_process_dri2_buffer(intel, drawable, &buffers[i], rb, region_name);
> +   }
> +}
> +
> +void
> +intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
> +{
> +   struct intel_context *intel = context->driverPrivate;
> +   __DRIscreen *screen = intel->intelScreen->driScrnPriv;
>  
>     /* Set this up front, so that in case our buffers get invalidated
>      * while we're getting new buffers, we don't clobber the stamp and
> @@ -151,42 +194,7 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
>     if (unlikely(INTEL_DEBUG & DEBUG_DRI))
>        fprintf(stderr, "enter %s, drawable %p\n", __func__, drawable);
>  
> -   intel_query_dri2_buffers(intel, drawable, &buffers, &count);
> -
> -   if (buffers == NULL)
> -      return;
> -
> -   for (i = 0; i < count; i++) {
> -       switch (buffers[i].attachment) {
> -       case __DRI_BUFFER_FRONT_LEFT:
> -	   rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
> -	   region_name = "dri2 front buffer";
> -	   break;
> -
> -       case __DRI_BUFFER_FAKE_FRONT_LEFT:
> -	   rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
> -	   region_name = "dri2 fake front buffer";
> -	   break;
> -
> -       case __DRI_BUFFER_BACK_LEFT:
> -	   rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
> -	   region_name = "dri2 back buffer";
> -	   break;
> -
> -       case __DRI_BUFFER_DEPTH:
> -       case __DRI_BUFFER_HIZ:
> -       case __DRI_BUFFER_DEPTH_STENCIL:
> -       case __DRI_BUFFER_STENCIL:
> -       case __DRI_BUFFER_ACCUM:
> -       default:
> -	   fprintf(stderr,
> -		   "unhandled buffer attach event, attachment type %d\n",
> -		   buffers[i].attachment);
> -	   return;
> -       }
> -
> -       intel_process_dri2_buffer(intel, drawable, &buffers[i], rb, region_name);
> -   }
> +   intel_update_dri2_buffers(intel, drawable);
>  
>     driUpdateFramebufferSize(&intel->ctx, drawable);
>  }
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
> index 38147e9..c213b31 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -929,12 +929,11 @@ intel_process_dri2_buffer(struct brw_context *brw,
>                            struct intel_renderbuffer *rb,
>                            const char *buffer_name);
>  
> -void
> -intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
> +static void
> +intel_update_dri2_buffers(struct brw_context *brw, __DRIdrawable *drawable)
>  {
>     struct gl_framebuffer *fb = drawable->driverPrivate;
>     struct intel_renderbuffer *rb;
> -   struct brw_context *brw = context->driverPrivate;
>     __DRIbuffer *buffers = NULL;
>     int i, count;
>     const char *region_name;
> @@ -984,6 +983,23 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
>         intel_process_dri2_buffer(brw, drawable, &buffers[i], rb, region_name);
>     }
>  
> +}
> +
> +void
> +intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
> +{
> +   struct brw_context *brw = context->driverPrivate;
> +
> +   /* Set this up front, so that in case our buffers get invalidated
> +    * while we're getting new buffers, we don't clobber the stamp and
> +    * thus ignore the invalidate. */
> +   drawable->lastStamp = drawable->dri2.stamp;
> +
> +   if (unlikely(INTEL_DEBUG & DEBUG_DRI))
> +      fprintf(stderr, "enter %s, drawable %p\n", __func__, drawable);
> +
> +   intel_update_dri2_buffers(brw, drawable);
> +
>     driUpdateFramebufferSize(&brw->ctx, drawable);
>  }
>  
> -- 
> 1.8.4.2
> 
> 
> ------------------------------------------------------------------------------
> Android is increasing in popularity, but the open development platform that
> developers love is also attractive to malware creators. Download this white
> paper to learn more about secure code signing practices that can help keep
> Android apps secure.
> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
> --
> _______________________________________________
> Dri-devel mailing list
> Dri-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/dri-devel
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
--
diff mbox

Patch

diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c
index 2748514..1798bc7 100644
--- a/src/mesa/drivers/dri/i915/intel_context.c
+++ b/src/mesa/drivers/dri/i915/intel_context.c
@@ -133,15 +133,58 @@  intel_process_dri2_buffer(struct intel_context *intel,
 			  struct intel_renderbuffer *rb,
 			  const char *buffer_name);
 
-void
-intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
+static void
+intel_update_dri2_buffers(struct intel_context *intel, __DRIdrawable *drawable)
 {
-   struct gl_framebuffer *fb = drawable->driverPrivate;
-   struct intel_renderbuffer *rb;
-   struct intel_context *intel = context->driverPrivate;
    __DRIbuffer *buffers = NULL;
    int i, count;
    const char *region_name;
+   struct intel_renderbuffer *rb;
+   struct gl_framebuffer *fb = drawable->driverPrivate;
+
+   intel_query_dri2_buffers(intel, drawable, &buffers, &count);
+
+   if (buffers == NULL)
+      return;
+
+   for (i = 0; i < count; i++) {
+      switch (buffers[i].attachment) {
+      case __DRI_BUFFER_FRONT_LEFT:
+         rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
+         region_name = "dri2 front buffer";
+         break;
+
+      case __DRI_BUFFER_FAKE_FRONT_LEFT:
+         rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
+         region_name = "dri2 fake front buffer";
+         break;
+
+      case __DRI_BUFFER_BACK_LEFT:
+         rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
+         region_name = "dri2 back buffer";
+         break;
+
+      case __DRI_BUFFER_DEPTH:
+      case __DRI_BUFFER_HIZ:
+      case __DRI_BUFFER_DEPTH_STENCIL:
+      case __DRI_BUFFER_STENCIL:
+      case __DRI_BUFFER_ACCUM:
+      default:
+         fprintf(stderr,
+                 "unhandled buffer attach event, attachment type %d\n",
+                 buffers[i].attachment);
+         return;
+      }
+
+      intel_process_dri2_buffer(intel, drawable, &buffers[i], rb, region_name);
+   }
+}
+
+void
+intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
+{
+   struct intel_context *intel = context->driverPrivate;
+   __DRIscreen *screen = intel->intelScreen->driScrnPriv;
 
    /* Set this up front, so that in case our buffers get invalidated
     * while we're getting new buffers, we don't clobber the stamp and
@@ -151,42 +194,7 @@  intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
    if (unlikely(INTEL_DEBUG & DEBUG_DRI))
       fprintf(stderr, "enter %s, drawable %p\n", __func__, drawable);
 
-   intel_query_dri2_buffers(intel, drawable, &buffers, &count);
-
-   if (buffers == NULL)
-      return;
-
-   for (i = 0; i < count; i++) {
-       switch (buffers[i].attachment) {
-       case __DRI_BUFFER_FRONT_LEFT:
-	   rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
-	   region_name = "dri2 front buffer";
-	   break;
-
-       case __DRI_BUFFER_FAKE_FRONT_LEFT:
-	   rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
-	   region_name = "dri2 fake front buffer";
-	   break;
-
-       case __DRI_BUFFER_BACK_LEFT:
-	   rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
-	   region_name = "dri2 back buffer";
-	   break;
-
-       case __DRI_BUFFER_DEPTH:
-       case __DRI_BUFFER_HIZ:
-       case __DRI_BUFFER_DEPTH_STENCIL:
-       case __DRI_BUFFER_STENCIL:
-       case __DRI_BUFFER_ACCUM:
-       default:
-	   fprintf(stderr,
-		   "unhandled buffer attach event, attachment type %d\n",
-		   buffers[i].attachment);
-	   return;
-       }
-
-       intel_process_dri2_buffer(intel, drawable, &buffers[i], rb, region_name);
-   }
+   intel_update_dri2_buffers(intel, drawable);
 
    driUpdateFramebufferSize(&intel->ctx, drawable);
 }
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 38147e9..c213b31 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -929,12 +929,11 @@  intel_process_dri2_buffer(struct brw_context *brw,
                           struct intel_renderbuffer *rb,
                           const char *buffer_name);
 
-void
-intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
+static void
+intel_update_dri2_buffers(struct brw_context *brw, __DRIdrawable *drawable)
 {
    struct gl_framebuffer *fb = drawable->driverPrivate;
    struct intel_renderbuffer *rb;
-   struct brw_context *brw = context->driverPrivate;
    __DRIbuffer *buffers = NULL;
    int i, count;
    const char *region_name;
@@ -984,6 +983,23 @@  intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
        intel_process_dri2_buffer(brw, drawable, &buffers[i], rb, region_name);
    }
 
+}
+
+void
+intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
+{
+   struct brw_context *brw = context->driverPrivate;
+
+   /* Set this up front, so that in case our buffers get invalidated
+    * while we're getting new buffers, we don't clobber the stamp and
+    * thus ignore the invalidate. */
+   drawable->lastStamp = drawable->dri2.stamp;
+
+   if (unlikely(INTEL_DEBUG & DEBUG_DRI))
+      fprintf(stderr, "enter %s, drawable %p\n", __func__, drawable);
+
+   intel_update_dri2_buffers(brw, drawable);
+
    driUpdateFramebufferSize(&brw->ctx, drawable);
 }