gallium: add a texture target to sampler view and a CAP to use it
authorIlia Mirkin <imirkin@alum.mit.edu>
Wed, 20 Aug 2014 23:45:10 +0000 (19:45 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Fri, 12 Sep 2014 04:54:55 +0000 (00:54 -0400)
This allows a sampler view to have a different texture target than the
underlying resource. This will be used to implement the type casting
between 2d arrays and cube maps as specified in ARB_texture_view.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
17 files changed:
src/gallium/auxiliary/util/u_sampler.c
src/gallium/docs/source/screen.rst
src/gallium/drivers/freedreno/freedreno_screen.c
src/gallium/drivers/i915/i915_screen.c
src/gallium/drivers/ilo/ilo_screen.c
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/nouveau/nv30/nv30_screen.c
src/gallium/drivers/nouveau/nv50/nv50_screen.c
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/drivers/svga/svga_screen.c
src/gallium/drivers/vc4/vc4_screen.c
src/gallium/include/pipe/p_defines.h
src/gallium/include/pipe/p_state.h

index 227641bdafcfb2af0ce68d581b9d4fc19b699393..86799fdd5590256c9e8438d8de2fdf7a2bb383d2 100644 (file)
@@ -45,6 +45,7 @@ default_template(struct pipe_sampler_view *view,
    /* XXX: Check if format is compatible with texture->format.
     */
 
+   view->target = texture->target;
    view->format = format;
    view->u.tex.first_level = 0;
    view->u.tex.last_level = texture->last_level;
index 13bf705a87d196e2034ede9920b86c42eb98c290..c83be12f77c0ff576eb0e44675276358d854a947 100644 (file)
@@ -226,6 +226,10 @@ The integer capabilities:
 * ``PIPE_CAP_CONDITIONAL_RENDER_INVERTED``: Whether the driver supports inverted
   condition for conditional rendering.
 * ``PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE``: The maximum supported vertex stride.
+* ``PIPE_CAP_SAMPLER_VIEW_TARGET``: Whether the sampler view's target can be
+  different than the underlying resource's, as permitted by
+  ARB_texture_view. For example a 2d array texture may be reinterpreted as a
+  cube (array) texture and vice-versa.
 
 
 .. _pipe_capf:
index 74cbd9676c49393361c65ebe4a5cfd4830e18352..745ca8e5229c23d636f855b38e6f248848bd2922 100644 (file)
@@ -220,6 +220,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        case PIPE_CAP_DRAW_INDIRECT:
        case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
        case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
+       case PIPE_CAP_SAMPLER_VIEW_TARGET:
                return 0;
 
        /* Stream output. */
index 24e444f1ca49fcd9ef06f42ee939c1f997c97dcc..90067343fba51575dfd5347f02b70416055e2378 100644 (file)
@@ -234,6 +234,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
    case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
    case PIPE_CAP_DRAW_INDIRECT:
    case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
+   case PIPE_CAP_SAMPLER_VIEW_TARGET:
       return 0;
 
    case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
index 3f997a11dac3dfcf8254167bc4e326eda09be766..c56e0e5445602e9ce210f180dea84a601804823b 100644 (file)
@@ -438,6 +438,7 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_DRAW_INDIRECT:
    case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
    case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
+   case PIPE_CAP_SAMPLER_VIEW_TARGET:
       return 0;
 
    case PIPE_CAP_VENDOR_ID:
index 2da52080d6b2bc2ec895399641e8d57675b135d7..e6597e95ea48912de9e7bf90a09510d53034fbd1 100644 (file)
@@ -253,6 +253,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
    case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
    case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
+   case PIPE_CAP_SAMPLER_VIEW_TARGET:
       return 0;
    case PIPE_CAP_FAKE_SW_MSAA:
       return 1;
index 036ce9ea473ad74e19379ef8cd925aca363c3f50..a1373fdd9d5e0a114bd0c277979d1c6c7a1dbb71 100644 (file)
@@ -155,6 +155,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_DRAW_INDIRECT:
    case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
    case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
+   case PIPE_CAP_SAMPLER_VIEW_TARGET:
       return 0;
 
    case PIPE_CAP_VENDOR_ID:
index abc34070d20eda5d49a1e1f2707f2622c03b4a6c..b2a30195251cf0ec3fd59134f603f8cf3d540888 100644 (file)
@@ -203,6 +203,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_COMPUTE:
    case PIPE_CAP_DRAW_INDIRECT:
    case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
+   case PIPE_CAP_SAMPLER_VIEW_TARGET:
       return 0;
 
    case PIPE_CAP_VENDOR_ID:
index 5416ef919f775a23b2b9250a77fa6104a7fb7006..4e7b8d6c82e33735099a390707dc321e6b74d722 100644 (file)
@@ -187,6 +187,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TGSI_VS_LAYER_VIEWPORT:
    case PIPE_CAP_FAKE_SW_MSAA:
    case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
+   case PIPE_CAP_SAMPLER_VIEW_TARGET:
       return 0;
 
    case PIPE_CAP_VENDOR_ID:
index b4ccbeee35c78cc3558a837f52e6786f6c032772..c35559f5e73aed9d23846f40f9c5b20c4c79e61a 100644 (file)
@@ -180,6 +180,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
         case PIPE_CAP_DRAW_INDIRECT:
         case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
         case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
+        case PIPE_CAP_SAMPLER_VIEW_TARGET:
             return 0;
 
         /* SWTCL-only features. */
index 6e00efff35ad5e623ac7ee7c55021edfcda3e100..73c6e3543afdca8246073ab3831bc4a0e72b294e 100644 (file)
@@ -320,6 +320,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
        case PIPE_CAP_DRAW_INDIRECT:
        case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
+       case PIPE_CAP_SAMPLER_VIEW_TARGET:
                return 0;
 
        /* Stream output. */
index b63c5d7fef9402926f79df5ff092c0bdf71947b2..5762ca7702f3f1378aaa0319a9a5d726c57deb4a 100644 (file)
@@ -244,6 +244,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
        case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
        case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
+       case PIPE_CAP_SAMPLER_VIEW_TARGET:
                return 0;
 
        case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
index 956d59c02ba10a5b2146c879953b3e0d343707ea..a6e7fc0a4ca22248212f2c88ca17c40ad2379ed2 100644 (file)
@@ -198,6 +198,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
    case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
    case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
+   case PIPE_CAP_SAMPLER_VIEW_TARGET:
       return 0;
    case PIPE_CAP_FAKE_SW_MSAA:
       return 1;
index edd0a39c105188648cebaacbc22cfa44ccb6a7da..004b4b4306d9f7d7d1c1ffd99e4040c9cf03ed7b 100644 (file)
@@ -280,6 +280,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_DRAW_INDIRECT:
    case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
    case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
+   case PIPE_CAP_SAMPLER_VIEW_TARGET:
       return 0;
    case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
       return 64;
index b2fa623d9c170fdb399c41aa4fef7ab22bed852a..1c4d9dbf843499a0417714d3a2585ddbac517a38 100644 (file)
@@ -161,6 +161,7 @@ vc4_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
         case PIPE_CAP_DRAW_INDIRECT:
         case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
         case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
+        case PIPE_CAP_SAMPLER_VIEW_TARGET:
                 return 0;
 
                 /* Stream output. */
index aae8229a4e2e7f74dd9ae4237149c3d2f4865e93..93156b952bd1f60385b9317d558faab76f5f975f 100644 (file)
@@ -570,6 +570,7 @@ enum pipe_cap {
    PIPE_CAP_UMA = 107,
    PIPE_CAP_CONDITIONAL_RENDER_INVERTED = 108,
    PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE = 109,
+   PIPE_CAP_SAMPLER_VIEW_TARGET = 110,
 };
 
 #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)
index a82686b23a420a5b6eb794909e831104f724f1be..36d253c5157e493bce5e1f302dd2588b6eb28c03 100644 (file)
@@ -361,6 +361,7 @@ struct pipe_surface
 struct pipe_sampler_view
 {
    struct pipe_reference reference;
+   enum pipe_texture_target target; /**< PIPE_TEXTURE_x */
    enum pipe_format format;      /**< typed PIPE_FORMAT_x */
    struct pipe_resource *texture; /**< texture into which this is a view  */
    struct pipe_context *context; /**< context this view belongs to */