gallium: Reorg texture usage flags
authorJakob Bornecrantz <jakob@vmware.com>
Wed, 17 Feb 2010 21:08:49 +0000 (21:08 +0000)
committerJakob Bornecrantz <jakob@vmware.com>
Mon, 1 Mar 2010 16:05:35 +0000 (16:05 +0000)
Introduce a new shared usage and rename primary to scanout.
The display target usage is more of a windows concept and
doesn't mean the same thing as shared. Display target means
that the surface should be presentable, for softpipe this
means that it should be backed by a hardware buffer.

13 files changed:
src/gallium/drivers/i915/i915_texture.c
src/gallium/drivers/i965/brw_screen_texture.c
src/gallium/drivers/llvmpipe/lp_texture.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/softpipe/sp_texture.c
src/gallium/drivers/svga/svga_screen_texture.c
src/gallium/include/pipe/p_defines.h
src/gallium/state_trackers/egl/kms/native_kms.c
src/gallium/state_trackers/xorg/xorg_crtc.c
src/gallium/state_trackers/xorg/xorg_dri2.c
src/gallium/state_trackers/xorg/xorg_exa.c
src/gallium/state_trackers/xorg/xvmc/surface.c
src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c

index 7ba222c78b7c640b8361ee0dba1b0990f60c8c2f..5ad65a2e9c8a0c85f7d4e538d178218df735b3ce 100644 (file)
@@ -219,12 +219,12 @@ i915_miptree_layout_2d(struct i915_texture *tex)
    unsigned nblocksy = util_format_get_nblocksy(pt->format, pt->width0);
 
    /* used for scanouts that need special layouts */
-   if (pt->tex_usage & PIPE_TEXTURE_USAGE_PRIMARY)
+   if (pt->tex_usage & PIPE_TEXTURE_USAGE_SCANOUT)
       if (i915_scanout_layout(tex))
          return;
 
-   /* for shared buffers we use something very like scanout */
-   if (pt->tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET)
+   /* shared buffers needs to be compatible with X servers */
+   if (pt->tex_usage & PIPE_TEXTURE_USAGE_SHARED)
       if (i915_display_target_layout(tex))
          return;
 
@@ -369,12 +369,12 @@ i945_miptree_layout_2d(struct i915_texture *tex)
    unsigned nblocksy = util_format_get_nblocksy(pt->format, pt->height0);
 
    /* used for scanouts that need special layouts */
-   if (tex->base.tex_usage & PIPE_TEXTURE_USAGE_PRIMARY)
+   if (tex->base.tex_usage & PIPE_TEXTURE_USAGE_SCANOUT)
       if (i915_scanout_layout(tex))
          return;
 
-   /* for shared buffers we use some very like scanout */
-   if (tex->base.tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET)
+   /* shared buffers needs to be compatible with X servers */
+   if (tex->base.tex_usage & PIPE_TEXTURE_USAGE_SHARED)
       if (i915_display_target_layout(tex))
          return;
 
@@ -642,7 +642,7 @@ i915_texture_create(struct pipe_screen *screen,
 
 
    /* for scanouts and cursors, cursors arn't scanouts */
-   if (templat->tex_usage & PIPE_TEXTURE_USAGE_PRIMARY && templat->width0 != 64)
+   if (templat->tex_usage & PIPE_TEXTURE_USAGE_SCANOUT && templat->width0 != 64)
       buf_usage = INTEL_NEW_SCANOUT;
    else
       buf_usage = INTEL_NEW_TEXTURE;
index 38e99613981348e05f7c5bed81f5f96bafc4ca5b..2d7b6ec2222506a2b62e0d56141f8ff8ab45ffc0 100644 (file)
@@ -231,8 +231,8 @@ static struct pipe_texture *brw_texture_create( struct pipe_screen *screen,
       goto fail;
 
    
-   if (templ->tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
-                           PIPE_TEXTURE_USAGE_PRIMARY)) {
+   if (templ->tex_usage & (PIPE_TEXTURE_USAGE_SCANOUT |
+                           PIPE_TEXTURE_USAGE_SHARED)) {
       buffer_type = BRW_BUFFER_TYPE_SCANOUT;
    }
    else {
index 7f45635542897470e7606f6ca60624194d16d964..7d15e8560078df21bc27240f69771191888b9ebc 100644 (file)
@@ -125,7 +125,8 @@ llvmpipe_texture_create(struct pipe_screen *_screen,
    lpt->base.screen = &screen->base;
 
    if (lpt->base.tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
-                              PIPE_TEXTURE_USAGE_PRIMARY)) {
+                              PIPE_TEXTURE_USAGE_SCANOUT |
+                              PIPE_TEXTURE_USAGE_SHARED)) {
       if (!llvmpipe_displaytarget_layout(screen, lpt))
          goto fail;
    }
index 6a55570571a13e4fb8acbb4ab6102c187f3b408c..2d8b313e5d1236b91b96649c60f93df4355b4c93 100644 (file)
@@ -231,14 +231,16 @@ static boolean r300_is_format_supported(struct pipe_screen* screen,
     /* Check colorbuffer format support. */
     if ((usage & (PIPE_TEXTURE_USAGE_RENDER_TARGET |
                   PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
-                  PIPE_TEXTURE_USAGE_PRIMARY)) &&
+                  PIPE_TEXTURE_USAGE_SCANOUT |
+                  PIPE_TEXTURE_USAGE_SHARED)) &&
         /* 2101010 cannot be rendered to on non-r5xx. */
         (is_r500 || !is_color2101010) &&
         r300_is_colorbuffer_format_supported(format)) {
         retval |= usage &
             (PIPE_TEXTURE_USAGE_RENDER_TARGET |
              PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
-             PIPE_TEXTURE_USAGE_PRIMARY);
+             PIPE_TEXTURE_USAGE_SCANOUT |
+             PIPE_TEXTURE_USAGE_SHARED);
     }
 
     /* Check depth-stencil format support. */
index 371c4e2025121082a196133e8c4075d3be8f2db4..d3997854b2ffcd572431fe44d5d5ad979c8b9af3 100644 (file)
@@ -123,7 +123,8 @@ softpipe_texture_create(struct pipe_screen *screen,
                util_is_power_of_two(template->depth0));
 
    if (spt->base.tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
-                              PIPE_TEXTURE_USAGE_PRIMARY)) {
+                              PIPE_TEXTURE_USAGE_SCANOUT |
+                              PIPE_TEXTURE_USAGE_SHARED)) {
       if (!softpipe_displaytarget_layout(screen, spt))
          goto fail;
    }
index 12f3531a1df7a5412cc74a4610d6b1ad9c7ec199..b34f906ceb06132f5a706b539949e0e54f31f075 100644 (file)
@@ -315,7 +315,11 @@ svga_texture_create(struct pipe_screen *screen,
       tex->key.cachable = 0;
    }
 
-   if(templat->tex_usage & PIPE_TEXTURE_USAGE_PRIMARY) {
+   if(templat->tex_usage & PIPE_TEXTURE_USAGE_SHARED) {
+      tex->key.cachable = 0;
+   }
+
+   if(templat->tex_usage & PIPE_TEXTURE_USAGE_SCANOUT) {
       tex->key.flags |= SVGA3D_SURFACE_HINT_SCANOUT;
       tex->key.cachable = 0;
    }
index 5cebd43ace25806fca313292dd5f927d8a711436..5c97dc87e828e89a29748b60727db3ae78c8703d 100644 (file)
@@ -176,11 +176,12 @@ enum pipe_texture_target {
 #define PIPE_TEX_COMPARE_R_TO_TEXTURE  1
 
 #define PIPE_TEXTURE_USAGE_RENDER_TARGET   0x1
-#define PIPE_TEXTURE_USAGE_DISPLAY_TARGET  0x2 /* ie a backbuffer */
-#define PIPE_TEXTURE_USAGE_PRIMARY         0x4 /* ie a frontbuffer */
+#define PIPE_TEXTURE_USAGE_DISPLAY_TARGET  0x2  /* windows presentable buffer, ie a backbuffer */
+#define PIPE_TEXTURE_USAGE_SCANOUT         0x4  /* ie a frontbuffer */
 #define PIPE_TEXTURE_USAGE_DEPTH_STENCIL   0x8
 #define PIPE_TEXTURE_USAGE_SAMPLER         0x10
 #define PIPE_TEXTURE_USAGE_DYNAMIC         0x20
+#define PIPE_TEXTURE_USAGE_SHARED          0x40
 /** Pipe driver custom usage flags should be greater or equal to this value */
 #define PIPE_TEXTURE_USAGE_CUSTOM          (1 << 16)
 
index ee6ab2e60b8545516bd5ea069a28aed210fb90c7..dbdb1e635a7aedf907d84cb01b1003166fa87ab1 100644 (file)
@@ -55,7 +55,7 @@ kms_surface_validate(struct native_surface *nsurf, uint attachment_mask,
       templ.format = ksurf->color_format;
       templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
       if (ksurf->type == KMS_SURFACE_TYPE_SCANOUT)
-         templ.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY;
+         templ.tex_usage |= PIPE_TEXTURE_SCANOUT;
    }
 
    /* create textures */
index 4a77f540805951af7f59164236baabe37b371db2..8f6426bcc87fe55dfa47144af2e446417c926aa9 100644 (file)
@@ -201,7 +201,7 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image)
 
        memset(&templat, 0, sizeof(templat));
        templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET;
-       templat.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY;
+       templat.tex_usage |= PIPE_TEXTURE_USAGE_SCANOUT;
        templat.target = PIPE_TEXTURE_2D;
        templat.last_level = 0;
        templat.depth0 = 1;
index 5472285ec1bb9b50e4787e45e3077de4c38b0af8..e7f1b2d4112dfadf4a027a4a0cdc7e6f436c5f3f 100644 (file)
@@ -129,7 +129,7 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int form
            template.depth0 = 1;
            template.last_level = 0;
            template.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL |
-               PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
+               PIPE_TEXTURE_USAGE_SHARED;
            tex = ms->screen->texture_create(ms->screen, &template);
            pipe_texture_reference(&exa_priv->depth_stencil_tex, tex);
        }
index 665efdc0f0375b9b21897c908a08376b1d856121..5c3e92efdfd338ea89544bdd2e088c48bd1df04e 100644 (file)
@@ -789,7 +789,7 @@ xorg_exa_set_displayed_usage(PixmapPtr pPixmap)
        return 0;
     }
 
-    priv->flags |= PIPE_TEXTURE_USAGE_PRIMARY;
+    priv->flags |= PIPE_TEXTURE_USAGE_SCANOUT;
 
     return 0;
 }
@@ -805,7 +805,7 @@ xorg_exa_set_shared_usage(PixmapPtr pPixmap)
        return 0;
     }
 
-    priv->flags |= PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
+    priv->flags |= PIPE_TEXTURE_USAGE_SHARED;
 
     return 0;
 }
@@ -943,7 +943,7 @@ xorg_exa_set_texture(PixmapPtr pPixmap, struct  pipe_texture *tex)
 {
     struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
 
-    int mask = PIPE_TEXTURE_USAGE_PRIMARY | PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
+    int mask = PIPE_TEXTURE_USAGE_SHARED | PIPE_TEXTURE_USAGE_SCANOUT;
 
     if (!priv)
        return FALSE;
@@ -976,8 +976,8 @@ xorg_exa_create_root_texture(ScrnInfoPtr pScrn,
     template.depth0 = 1;
     template.last_level = 0;
     template.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET;
-    template.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY;
-    template.tex_usage |= PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
+    template.tex_usage |= PIPE_TEXTURE_USAGE_SCANOUT;
+    template.tex_usage |= PIPE_TEXTURE_USAGE_SHARED;
 
     return exa->scrn->texture_create(exa->scrn, &template);
 }
index 0e39a390c69b2296110621566cb3e3d8c275b867..c113f49e5562e191a14d62e0c595ec7840152924 100644 (file)
@@ -106,7 +106,7 @@ CreateOrResizeBackBuffer(struct pipe_video_context *vpipe, unsigned int width, u
    template.width0 = width;
    template.height0 = height;
    template.depth0 = 1;
-   template.tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
+   template.tex_usage = PIPE_TEXTURE_USAGE_SHARED;
 
    tex = vpipe->screen->texture_create(vpipe->screen, &template);
    if (!tex)
index c814d986b1daa61451f202289b664ef76c81b425..80b5a4c0914944771a6cb88d8f5a07f0366344a7 100644 (file)
@@ -23,7 +23,7 @@ dri_surface_from_handle(struct drm_api *api, struct pipe_screen *pscreen,
        struct pipe_texture tmpl;
 
        memset(&tmpl, 0, sizeof(tmpl));
-       tmpl.tex_usage = PIPE_TEXTURE_USAGE_PRIMARY;
+       tmpl.tex_usage = PIPE_TEXTURE_USAGE_SCANOUT;
        tmpl.target = PIPE_TEXTURE_2D;
        tmpl.last_level = 0;
        tmpl.depth0 = 1;