gallium: create TGSI_PROPERTY to disable viewport and clipping
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Fri, 16 May 2014 23:20:19 +0000 (01:20 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 2 Jun 2014 10:49:03 +0000 (12:49 +0200)
Marek v2: add a cap

Signed-off-by: Marek Olšák <marek.olsak@amd.com>
19 files changed:
src/gallium/auxiliary/tgsi/tgsi_strings.c
src/gallium/auxiliary/tgsi/tgsi_ureg.c
src/gallium/auxiliary/tgsi/tgsi_ureg.h
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_defines.h
src/gallium/include/pipe/p_shader_tokens.h

index 34dec4f8a3e774f58bd7749428cf246422c715ac..713631fbec4988123a98b27b4f59d716476d02d5 100644 (file)
@@ -122,6 +122,7 @@ const char *tgsi_property_names[TGSI_PROPERTY_COUNT] =
    "FS_DEPTH_LAYOUT",
    "VS_PROHIBIT_UCPS",
    "GS_INVOCATIONS",
+   "VS_POSITION_WINDOW_SPACE"
 };
 
 const char *tgsi_type_names[5] =
index 2bf93ee6adb98172be8410a165f5b526ae916548..bd0a3f79fbdd87eb4c9f17a9dd3ae606403af21f 100644 (file)
@@ -173,6 +173,7 @@ struct ureg_program
    unsigned char property_fs_coord_pixel_center; /* = TGSI_FS_COORD_PIXEL_CENTER_* */
    unsigned char property_fs_color0_writes_all_cbufs; /* = TGSI_FS_COLOR0_WRITES_ALL_CBUFS * */
    unsigned char property_fs_depth_layout; /* TGSI_FS_DEPTH_LAYOUT */
+   boolean property_vs_window_space_position; /* TGSI_VS_WINDOW_SPACE_POSITION */
 
    unsigned nr_addrs;
    unsigned nr_preds;
@@ -331,6 +332,13 @@ ureg_property_fs_depth_layout(struct ureg_program *ureg,
    ureg->property_fs_depth_layout = fs_depth_layout;
 }
 
+void
+ureg_property_vs_window_space_position(struct ureg_program *ureg,
+                                       boolean vs_window_space_position)
+{
+   ureg->property_vs_window_space_position = vs_window_space_position;
+}
+
 struct ureg_src
 ureg_DECL_fs_input_cyl_centroid(struct ureg_program *ureg,
                        unsigned semantic_name,
@@ -1508,6 +1516,14 @@ static void emit_decls( struct ureg_program *ureg )
                     ureg->property_fs_depth_layout);
    }
 
+   if (ureg->property_vs_window_space_position) {
+      assert(ureg->processor == TGSI_PROCESSOR_VERTEX);
+
+      emit_property(ureg,
+                    TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION,
+                    ureg->property_vs_window_space_position);
+   }
+
    if (ureg->processor == TGSI_PROCESSOR_VERTEX) {
       for (i = 0; i < UREG_MAX_INPUT; i++) {
          if (ureg->vs_inputs[i/32] & (1 << (i%32))) {
index a0a50b7220e53d7f56e15880546bbb4affb9725f..28edea6cdae737050c802cff9af95ccbafcf744a 100644 (file)
@@ -184,6 +184,10 @@ void
 ureg_property_fs_depth_layout(struct ureg_program *ureg,
                               unsigned fs_depth_layout);
 
+void
+ureg_property_vs_window_space_position(struct ureg_program *ureg,
+                                       boolean vs_window_space_position);
+
 
 /***********************************************************************
  * Build shader declarations:
index b2922572a5b248ee3a027e7a3a48d405f69ac8c8..b8e356f97bb68465de0c0d4760014cae3f863d39 100644 (file)
@@ -202,6 +202,9 @@ The integer capabilities:
   implemented.
 * ``PIPE_CAP_TEXTURE_GATHER_OFFSETS``: Whether the ``TG4`` instruction can
   accept 4 offsets.
+* ``PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION``: Whether
+  TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION is supported, which disables clipping
+  and viewport transformation.
 
 
 .. _pipe_capf:
index 9500b9d615e4ff69467a2f2bd42f0b409d773114..2ca3c3bbb5dc7bf3300b6f0a332a61c1836a7abf 100644 (file)
@@ -2848,6 +2848,15 @@ input primitive. Each invocation will have a different
 TGSI_SEMANTIC_INVOCATIONID system value set. If not specified, assumed to
 be 1.
 
+VS_WINDOW_SPACE_POSITION
+""""""""""""""""""""""""""
+If this property is set on the vertex shader, the TGSI_SEMANTIC_POSITION output
+is assumed to contain window space coordinates.
+Division of X,Y,Z by W and the viewport transformation are disabled, and 1/W is
+directly taken from the 4-th component of the shader output.
+Naturally, clipping is not performed on window coordinates either.
+The effect of this property is undefined if a geometry or tessellation shader
+are in use.
 
 Texture Sampling and Texture Formats
 ------------------------------------
index 362fb807814ae2834d812a1fceac9037b75237d3..e7a185df00dcfe98e94de313ff19babad7e9ad1b 100644 (file)
@@ -214,6 +214,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        case PIPE_CAP_TEXTURE_QUERY_LOD:
        case PIPE_CAP_SAMPLE_SHADING:
        case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
+       case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
                return 0;
 
        /* Stream output. */
index ad8a23cae22941af533b1714518c057f896447b8..6ce6090e81760da6e9b74c06866884cbbd6011d9 100644 (file)
@@ -222,6 +222,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
    case PIPE_CAP_TEXTURE_QUERY_LOD:
    case PIPE_CAP_SAMPLE_SHADING:
    case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
+   case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
       return 0;
 
    case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
index 0a1c56d51b9d38ed663325b2978b3a306549f72b..b08ae206a7d8c818ca496c4e33e1f2d5a6cfba26 100644 (file)
@@ -441,6 +441,7 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_QUERY_LOD:
    case PIPE_CAP_SAMPLE_SHADING:
    case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
+   case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
       return 0;
 
    default:
index e23680251f8585c193d2423adff426c5d36371d9..a6b712a81267b9444b23bae99eaf34724ce25c0b 100644 (file)
@@ -243,6 +243,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_QUERY_LOD:
    case PIPE_CAP_SAMPLE_SHADING:
    case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
+   case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
       return 0;
    case PIPE_CAP_FAKE_SW_MSAA:
        return 1;
index 7157e0cc57a17bd473ea7c8d90b8c0ab96e22a93..fb9378c4ffe00d01aa65bcc43a8b37762f3b8b92 100644 (file)
@@ -137,6 +137,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_QUERY_LOD:
    case PIPE_CAP_SAMPLE_SHADING:
    case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
+   case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
       return 0;
    case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
    case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
index 36a4ad1da09921b8921a45375ca08b990f11977d..015f13918cbc2b85d1c0cc7cc1a66ee7545613e4 100644 (file)
@@ -199,6 +199,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_GATHER_SM5:
    case PIPE_CAP_FAKE_SW_MSAA:
    case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
+   case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
       return 0;
    case PIPE_CAP_MAX_VIEWPORTS:
       return NV50_MAX_VIEWPORTS;
index 24f14fb415004fd3366e74361b30f2b82033fb26..0537542e6ce857cfe53cfe3c8ba39860b6e6ddae 100644 (file)
@@ -190,6 +190,8 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
       return 1;
    case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS:
       return 4;
+   case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
+      return 0;
    default:
       NOUVEAU_ERR("unknown PIPE_CAP %d\n", param);
       return 0;
index 2c0fc4945dfdfd3f66f58bd2271ba98782f60baa..82d30e7804267b335b64b0bdf1e6b7f2c35d9059 100644 (file)
@@ -175,6 +175,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
         case PIPE_CAP_FAKE_SW_MSAA:
         case PIPE_CAP_SAMPLE_SHADING:
         case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
+        case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
             return 0;
 
         /* SWTCL-only features. */
index 368307c8e9d09c35ee16b8230ceec2a9a9e50cd5..f834a9de15e86a82371c9f54fdcf470c42aec42c 100644 (file)
@@ -316,6 +316,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_TEXTURE_QUERY_LOD:
        case PIPE_CAP_SAMPLE_SHADING:
        case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
+       case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
                return 0;
 
        /* Stream output. */
index 07c00cf33d0a31813a659f12f01c0625414f1cb4..d3745465a3e39eb87576a90d2534bfdf8509251e 100644 (file)
@@ -245,6 +245,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_TEXTURE_QUERY_LOD:
        case PIPE_CAP_SAMPLE_SHADING:
        case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
+       case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
                return 0;
 
        case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
index 316c512da3987b6ee038f71737b3cedcbe919ae5..34dbb91d7468c9dd873301e4ff7030f90248d9ba 100644 (file)
@@ -191,6 +191,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_QUERY_LOD:
    case PIPE_CAP_SAMPLE_SHADING:
    case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
+   case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
       return 0;
    case PIPE_CAP_FAKE_SW_MSAA:
       return 1;
index 458fbd04ce4fea6dabf8d1ddb68e17a1372d1cfb..4e1e3316bca550fd07fdd600adabf01c01b40226 100644 (file)
@@ -275,6 +275,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_TEXTURE_QUERY_LOD:
    case PIPE_CAP_SAMPLE_SHADING:
    case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
+   case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
       return 0;
    case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
       return 64;
index 4024470dac7cc7cb3c90d4bbc98e19c5d3878bbc..b91845aec1861d10525320f77b6621f5b1dfab85 100644 (file)
@@ -558,6 +558,7 @@ enum pipe_cap {
    PIPE_CAP_MAX_TEXTURE_GATHER_OFFSET = 96,
    PIPE_CAP_SAMPLE_SHADING = 97,
    PIPE_CAP_TEXTURE_GATHER_OFFSETS = 98,
+   PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION = 99
 };
 
 #define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)
index d095bd3a8f503562fd5d86b00574a98f56e868e6..9261b79d91e92c27d72f5adc709b01955fcca685 100644 (file)
@@ -237,7 +237,8 @@ union tgsi_immediate_data
 #define TGSI_PROPERTY_FS_DEPTH_LAYOUT        6
 #define TGSI_PROPERTY_VS_PROHIBIT_UCPS       7
 #define TGSI_PROPERTY_GS_INVOCATIONS         8
-#define TGSI_PROPERTY_COUNT                  9
+#define TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION 9
+#define TGSI_PROPERTY_COUNT                  10
 
 struct tgsi_property {
    unsigned Type         : 4;  /**< TGSI_TOKEN_TYPE_PROPERTY */