gallium, intel: Implements new __DRI_IMAGE_USE_LINEAR and PIPE_BIND_LINEAR flags...
authorAxel Davy <axel.davy@ens.fr>
Thu, 15 Aug 2013 10:47:58 +0000 (12:47 +0200)
committerKristian Høgsberg <krh@bitplanet.net>
Fri, 6 Sep 2013 22:02:34 +0000 (15:02 -0700)
Signed-off-by: Axel Davy <axel.davy@ens.fr>
12 files changed:
include/GL/internal/dri_interface.h
src/gallium/drivers/i915/i915_resource.c
src/gallium/drivers/ilo/ilo_resource.c
src/gallium/drivers/nv50/nv50_miptree.c
src/gallium/drivers/nvc0/nvc0_miptree.c
src/gallium/drivers/r300/r300_texture.c
src/gallium/drivers/r600/r600_texture.c
src/gallium/drivers/radeonsi/r600_texture.c
src/gallium/include/pipe/p_defines.h
src/gallium/state_trackers/dri/drm/dri2.c
src/mesa/drivers/dri/i915/intel_screen.c
src/mesa/drivers/dri/i965/intel_screen.c

index be31bb874b919253c0f6ec72d1f63b7ec6368230..709fece8d182200990af65ffbe08c919d6190dd8 100644 (file)
@@ -968,6 +968,7 @@ struct __DRIdri2ExtensionRec {
 #define __DRI_IMAGE_USE_SHARE          0x0001
 #define __DRI_IMAGE_USE_SCANOUT                0x0002
 #define __DRI_IMAGE_USE_CURSOR         0x0004 /* Depricated */
+#define __DRI_IMAGE_USE_LINEAR         0x0008
 
 
 /**
index 314ebe9551e080b46f2d581689053ce205b0db30..627ed2b4445156a87d2d3a857a3a3ed26a811bb2 100644 (file)
@@ -12,8 +12,12 @@ i915_resource_create(struct pipe_screen *screen,
    if (template->target == PIPE_BUFFER)
       return i915_buffer_create(screen, template);
    else
-      return i915_texture_create(screen, template, FALSE);
-
+   {
+      if (!(template->bind & PIPE_BIND_LINEAR))
+         return i915_texture_create(screen, template, FALSE);
+      else
+         return i915_texture_create(screen, template, TRUE);
+   }
 }
 
 static struct pipe_resource *
index 5061f694d86f565eccc982ed816eb20881e2aa0c..7dd34359302572d0c0768904dfc4715015f5fea6 100644 (file)
@@ -473,7 +473,7 @@ tex_layout_init_tiling(struct tex_layout *layout)
     *     "The cursor surface address must be 4K byte aligned. The cursor must
     *      be in linear memory, it cannot be tiled."
     */
-   if (unlikely(templ->bind & PIPE_BIND_CURSOR))
+   if (unlikely(templ->bind & (PIPE_BIND_CURSOR | PIPE_BIND_LINEAR)))
       valid_tilings &= tile_none;
 
    /*
index 461710e11307585bc15f007a8a68cc0a87125293..03c34c17ee0d1905dfd376364ad0649ada8bd191 100644 (file)
@@ -326,6 +326,9 @@ nv50_miptree_create(struct pipe_screen *pscreen,
    pipe_reference_init(&pt->reference, 1);
    pt->screen = pscreen;
 
+   if (pt->bind & PIPE_BIND_LINEAR)
+      pt->flags |= NOUVEAU_RESOURCE_FLAG_LINEAR;
+
    bo_config.nv50.memtype = nv50_mt_choose_storage_type(mt, TRUE);
 
    if (!nv50_miptree_init_ms_mode(mt)) {
index 9e57d743f3c27254135cff0beb84032155008e1a..f359207d8502fa516703c0c82340e262505c8f71 100644 (file)
@@ -274,6 +274,9 @@ nvc0_miptree_create(struct pipe_screen *pscreen,
       }
    }
 
+   if (pt->bind & PIPE_BIND_LINEAR)
+      pt->flags |= NOUVEAU_RESOURCE_FLAG_LINEAR;
+
    bo_config.nvc0.memtype = nvc0_mt_choose_storage_type(mt, compressed);
 
    if (!nvc0_miptree_init_ms_mode(mt)) {
index 13e9bc3f66a089d35ff50811e72d832d32fb265f..b7fb08162be5c86196cbea3e8448031ce1e2d130 100644 (file)
@@ -1079,7 +1079,7 @@ struct pipe_resource *r300_texture_create(struct pipe_screen *screen,
     enum radeon_bo_layout microtile, macrotile;
 
     if ((base->flags & R300_RESOURCE_FLAG_TRANSFER) ||
-        (base->bind & PIPE_BIND_SCANOUT)) {
+        (base->bind & (PIPE_BIND_SCANOUT | PIPE_BIND_LINEAR))) {
         microtile = RADEON_LAYOUT_LINEAR;
         macrotile = RADEON_LAYOUT_LINEAR;
     } else {
index 1d7948311dac4149478ee346fddc5579809049c5..07e7c6ca3848475af8fc6c09c24f1fcf9abd1a46 100644 (file)
@@ -608,7 +608,8 @@ struct pipe_resource *r600_texture_create(struct pipe_screen *screen,
         * because 422 formats are used for videos, which prefer linear buffers
         * for fast uploads anyway. */
        if (!(templ->flags & R600_RESOURCE_FLAG_TRANSFER) &&
-           desc->layout != UTIL_FORMAT_LAYOUT_SUBSAMPLED) {
+           (desc->layout != UTIL_FORMAT_LAYOUT_SUBSAMPLED) &&
+           !(templ->bind & PIPE_BIND_LINEAR)) {
                if (templ->flags & R600_RESOURCE_FLAG_FORCE_TILING) {
                        array_mode = V_038000_ARRAY_2D_TILED_THIN1;
                } else if (!(templ->bind & PIPE_BIND_SCANOUT) &&
index bc66dc3b8b48d0258eb756da02b60fa49c878bb4..ef4e8653aee4e26ff1717a61b1bdc3708e6a7f28 100644 (file)
@@ -515,7 +515,7 @@ struct pipe_resource *si_texture_create(struct pipe_screen *screen,
        int r;
 
        if (!(templ->flags & R600_RESOURCE_FLAG_TRANSFER) &&
-           !(templ->bind & PIPE_BIND_CURSOR)) {
+           !(templ->bind & PIPE_BIND_CURSOR | PIPE_BIND_LINEAR)) {
                if (templ->flags & R600_RESOURCE_FLAG_FORCE_TILING ||
                    templ->nr_samples > 1) {
                        array_mode = V_009910_ARRAY_2D_TILED_THIN1;
index fb42cdffea6e161745350b1aee87c9f2902c72a1..63869c9368787af103f3e851ff2cceea442528f9 100644 (file)
@@ -330,9 +330,13 @@ enum pipe_flush_flags {
  * The shared flag is quite underspecified, but certainly isn't a
  * binding flag - it seems more like a message to the winsys to create
  * a shareable allocation.
+ * 
+ * The third flag has been added to be able to force textures to be created
+ * in linear mode (no tiling).
  */
 #define PIPE_BIND_SCANOUT     (1 << 14) /*  */
 #define PIPE_BIND_SHARED      (1 << 15) /* get_texture_handle ??? */
+#define PIPE_BIND_LINEAR      (1 << 21)
 
 
 /* Flags for the driver about resource behaviour:
index 1dcc1f7fd063b3fcf23f76b556b5449ff6ecb451..e4477d6de77bbe77a54242836606221d9d45a9bb 100644 (file)
@@ -628,6 +628,8 @@ dri2_create_image(__DRIscreen *_screen,
       tex_usage |= PIPE_BIND_SCANOUT;
    if (use & __DRI_IMAGE_USE_SHARE)
       tex_usage |= PIPE_BIND_SHARED;
+   if (use & __DRI_IMAGE_USE_LINEAR)
+      tex_usage |= PIPE_BIND_LINEAR;
    if (use & __DRI_IMAGE_USE_CURSOR) {
       if (width != 64 || height != 64)
          return NULL;
index f8b95f44a9d29ba214f63d20e5ec49031db1f6ae..5a4734ffa473c5e724e75daa1e2b46ff3db0fab0 100644 (file)
@@ -482,6 +482,9 @@ intel_create_image(__DRIscreen *screen,
       tiling = I915_TILING_NONE;
    }
 
+   if (use & __DRI_IMAGE_USE_LINEAR)
+      tiling = I915_TILING_NONE;
+
    image = intel_allocate_image(format, loaderPrivate);
    if (image == NULL)
       return NULL;
index 0580d6f4e786c74781b965698cbf2c6e965646ed..eb6515e763d2a6a7318fc5ff5c530a1d5bb11ed5 100644 (file)
@@ -530,6 +530,9 @@ intel_create_image(__DRIscreen *screen,
       tiling = I915_TILING_NONE;
    }
 
+   if (use & __DRI_IMAGE_USE_LINEAR)
+      tiling = I915_TILING_NONE;
+
    image = intel_allocate_image(format, loaderPrivate);
    if (image == NULL)
       return NULL;