gallium: add basic support for ARB_sample_shading
authorIlia Mirkin <imirkin@alum.mit.edu>
Sun, 30 Mar 2014 22:21:04 +0000 (18:21 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Sat, 26 Apr 2014 15:52:01 +0000 (11:52 -0400)
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
19 files changed:
src/gallium/auxiliary/tgsi/tgsi_strings.c
src/gallium/docs/source/context.rst
src/gallium/docs/source/screen.rst
src/gallium/docs/source/tgsi.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/include/pipe/p_context.h
src/gallium/include/pipe/p_defines.h
src/gallium/include/pipe/p_shader_tokens.h

index b0ba3efa17bd90d3b9865233ececd0fb2d1b877f..2be726cdbbf3369c68df25b9234171b86ab21568 100644 (file)
@@ -81,7 +81,10 @@ const char *tgsi_semantic_names[TGSI_SEMANTIC_COUNT] =
    "PCOORD",
    "VIEWPORT_INDEX",
    "LAYER",
-   "CULLDIST"
+   "CULLDIST",
+   "SAMPLEID",
+   "SAMPLEPOS",
+   "SAMPLEMASK"
 };
 
 const char *tgsi_texture_names[TGSI_TEXTURE_COUNT] =
index 1fc8a3e4bad0436961ecf5ae2e6ccab7a1110035..fc8dd16f8949f2dbcb33aa14a7977aa6d99d4c32 100644 (file)
@@ -67,6 +67,7 @@ objects. They all follow simple, one-method binding calls, e.g.
   which are used as comparison values in stencil test.
 * ``set_blend_color``
 * ``set_sample_mask``
+* ``set_min_samples`` sets the minimum number of samples that must be run.
 * ``set_clip_state``
 * ``set_polygon_stipple``
 * ``set_scissor_states`` sets the bounds for the scissor test, which culls
index 89cbdbf8051fabda77f94833464260552c101f42..f5acebb3508eabcb693d81c89d9f18e1908c0f87 100644 (file)
@@ -197,6 +197,9 @@ The integer capabilities:
   in conjunction with a texture gather opcode.
 * ``PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET``: The maximum offset that can be used
   in conjunction with a texture gather opcode.
+* ``PIPE_CAP_SAMPLE_SHADING``: Whether there is support for per-sample
+  shading. The context->set_min_samples function will be expected to be
+  implemented.
 
 
 .. _pipe_capf:
index d5325f4a935bbdf7ec4121512d76f8c658cb3fe7..b7d016acb08637c20129b15dd38b5ca9731cd48c 100644 (file)
@@ -2621,6 +2621,26 @@ distances and by the PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT
 which specifies the maximum number of registers which can be
 annotated with those semantics.
 
+TGSI_SEMANTIC_SAMPLEID
+""""""""""""""""""""""
+
+For fragment shaders, this semantic label indicates that a system value
+contains the current sample id (i.e. gl_SampleID). Only the X value is used.
+
+TGSI_SEMANTIC_SAMPLEPOS
+"""""""""""""""""""""""
+
+For fragment shaders, this semantic label indicates that a system value
+contains the current sample's position (i.e. gl_SamplePosition). Only the X
+and Y values are used.
+
+TGSI_SEMANTIC_SAMPLEMASK
+""""""""""""""""""""""""
+
+For fragment shaders, this semantic label indicates that an output contains
+the sample mask used to disable further sample processing
+(i.e. gl_SampleMask). Only the X value is used, up to 32x MS.
+
 
 Declaration Interpolate
 ^^^^^^^^^^^^^^^^^^^^^^^
index 08556a4963b6758c80b479eccbcae44214cb8fa5..d62d4b61b6f4277d5aa0ffff77e9bd47d557f177 100644 (file)
@@ -208,6 +208,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
         case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
         case PIPE_CAP_FAKE_SW_MSAA:
        case PIPE_CAP_TEXTURE_QUERY_LOD:
+        case PIPE_CAP_SAMPLE_SHADING:
                return 0;
 
        /* Stream output. */
index b484d36d3d37cc8a5a6bcd26738458b1f3bd3554..8ee4330494a69aeafd6e8e3edd17fbff6f168894 100644 (file)
@@ -220,6 +220,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
    case PIPE_CAP_TEXTURE_GATHER_SM5:
    case PIPE_CAP_FAKE_SW_MSAA:
    case PIPE_CAP_TEXTURE_QUERY_LOD:
+   case PIPE_CAP_SAMPLE_SHADING:
       return 0;
 
    case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
index c368fe5ac9d2dfbbe022482d640d432a2db1e314..c8fa686c5e7636429e2027aa5d7e404c6b341a03 100644 (file)
@@ -439,6 +439,7 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
    case PIPE_CAP_FAKE_SW_MSAA:
    case PIPE_CAP_TEXTURE_QUERY_LOD:
+   case PIPE_CAP_SAMPLE_SHADING:
       return 0;
 
    default:
index 27073a484f04af51f3318fb01d7dd52deef7d5bf..98dbab7849779d924517ffd8313da18f5303ed39 100644 (file)
@@ -241,6 +241,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_GATHER_SM5:
    case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
    case PIPE_CAP_TEXTURE_QUERY_LOD:
+   case PIPE_CAP_SAMPLE_SHADING:
       return 0;
    case PIPE_CAP_FAKE_SW_MSAA:
        return 1;
index 0e10679e659275ab4c82ef3798e468741b9addba..77a04d26bdec8744c4c48c48a93f95fa99901823 100644 (file)
@@ -135,6 +135,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
    case PIPE_CAP_FAKE_SW_MSAA:
    case PIPE_CAP_TEXTURE_QUERY_LOD:
+   case PIPE_CAP_SAMPLE_SHADING:
       return 0;
    case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
    case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
index 4a8423f39447be82a509d6859ed226d4f42b034e..243c7c4c39c9b1e0a34b66bb78fa742ee932f230 100644 (file)
@@ -198,6 +198,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_GATHER_SM5:
    case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
    case PIPE_CAP_FAKE_SW_MSAA:
+   case PIPE_CAP_SAMPLE_SHADING:
       return 0;
    case PIPE_CAP_MAX_VIEWPORTS:
       return NV50_MAX_VIEWPORTS;
index 64674f71034c835257f2fb4d81c4c4ad9b0ceed4..2b8c6b2bb92b14e8e2f64d688f4bfdd2a5b09803 100644 (file)
@@ -181,6 +181,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_GATHER_SM5:
    case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
    case PIPE_CAP_FAKE_SW_MSAA:
+   case PIPE_CAP_SAMPLE_SHADING:
       return 0;
    case PIPE_CAP_MAX_VIEWPORTS:
       return 1;
index a60cdca765919528a38a8cb62ee5355b3778bf9b..d570514227b50006c17186e6b2f1510766b7d89a 100644 (file)
@@ -173,6 +173,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
         case PIPE_CAP_TEXTURE_GATHER_SM5:
         case PIPE_CAP_TEXTURE_QUERY_LOD:
         case PIPE_CAP_FAKE_SW_MSAA:
+        case PIPE_CAP_SAMPLE_SHADING:
             return 0;
 
         /* SWTCL-only features. */
index 68d739d893757cab98bd637f046287385da0a6e3..0668b27f4aaa57c3b648f760499d8437560a744e 100644 (file)
@@ -314,6 +314,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS:
        case PIPE_CAP_TEXTURE_GATHER_SM5:
        case PIPE_CAP_TEXTURE_QUERY_LOD:
+        case PIPE_CAP_SAMPLE_SHADING:
                return 0;
 
        /* Stream output. */
index a1aea7b3db38732a801eb5d4e8b93504050690e4..873115b81422d7feb74eb2e757e0b005b4d507a0 100644 (file)
@@ -243,6 +243,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_TGSI_TEXCOORD:
        case PIPE_CAP_FAKE_SW_MSAA:
        case PIPE_CAP_TEXTURE_QUERY_LOD:
+        case PIPE_CAP_SAMPLE_SHADING:
                return 0;
 
        case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
index b4ca728ec937c305ac4413c59273b07b74e329b7..e7c331967056f60cc8fecfc5088eceb7c3fe5f80 100644 (file)
@@ -189,6 +189,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_GATHER_SM5:
    case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
    case PIPE_CAP_TEXTURE_QUERY_LOD:
+   case PIPE_CAP_SAMPLE_SHADING:
       return 0;
    case PIPE_CAP_FAKE_SW_MSAA:
       return 1;
index 5a0436a3888a5409e3d2e08ef1216881fa80b3a9..8c70bb7184fc00053905f3fc075ae798acd36765 100644 (file)
@@ -273,6 +273,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
    case PIPE_CAP_FAKE_SW_MSAA:
    case PIPE_CAP_TEXTURE_QUERY_LOD:
+   case PIPE_CAP_SAMPLE_SHADING:
       return 0;
    case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
       return 64;
index bf27285c0f39bc32b6bdd7453bd35b63f844fcd8..bc435308d2eb05bdb50b279adcb13e25763e115e 100644 (file)
@@ -190,6 +190,9 @@ struct pipe_context {
    void (*set_sample_mask)( struct pipe_context *,
                             unsigned sample_mask );
 
+   void (*set_min_samples)( struct pipe_context *,
+                            unsigned min_samples );
+
    void (*set_clip_state)( struct pipe_context *,
                             const struct pipe_clip_state * );
 
index a3a1ae1c888345a363245c727afdad704d1f3da9..fec17f9133ff90b306d01fe3442855bb21e2554b 100644 (file)
@@ -556,6 +556,7 @@ enum pipe_cap {
    PIPE_CAP_TEXTURE_QUERY_LOD = 94,
    PIPE_CAP_MIN_TEXTURE_GATHER_OFFSET = 95,
    PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET = 96,
+   PIPE_CAP_SAMPLE_SHADING = 97,
 };
 
 #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)
index a2e649ec439538e8703fdde8fab199c13c23091e..74e04756730faf45f818947b6e9b2cf40c7d3e81 100644 (file)
@@ -167,7 +167,10 @@ struct tgsi_declaration_interp
 #define TGSI_SEMANTIC_VIEWPORT_INDEX 21 /**< viewport index */
 #define TGSI_SEMANTIC_LAYER      22 /**< layer (rendertarget index) */
 #define TGSI_SEMANTIC_CULLDIST   23
-#define TGSI_SEMANTIC_COUNT      24 /**< number of semantic values */
+#define TGSI_SEMANTIC_SAMPLEID   24
+#define TGSI_SEMANTIC_SAMPLEPOS  25
+#define TGSI_SEMANTIC_SAMPLEMASK 26
+#define TGSI_SEMANTIC_COUNT      27 /**< number of semantic values */
 
 struct tgsi_declaration_semantic
 {