gallium: add PIPE_SHADER_CAP_MAX_OUTPUTS and use it in st/mesa
authorMarek Olšák <marek.olsak@amd.com>
Wed, 1 Oct 2014 18:28:17 +0000 (20:28 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 21 Oct 2014 19:59:02 +0000 (21:59 +0200)
With 5 shader stages and various combinations of enabled and disabled shaders,
the maximum number of outputs in one shader doesn't have to be equal to
the maximum number of inputs in the following shader.

v2: return 32 for softpipe and llvmpipe

16 files changed:
src/gallium/auxiliary/gallivm/lp_bld_limits.h
src/gallium/auxiliary/tgsi/tgsi_exec.h
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/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/svga/svga_screen.c
src/gallium/drivers/vc4/vc4_screen.c
src/gallium/include/pipe/p_defines.h
src/mesa/state_tracker/st_extensions.c

index a96ab2924d2f1b82ea7eaa0b9ace75afbd54a41a..8c66f9d618e06e2597c8137e07147ab5cfdc5986 100644 (file)
@@ -97,6 +97,8 @@ gallivm_get_shader_param(enum pipe_shader_cap param)
       return LP_MAX_TGSI_NESTING;
    case PIPE_SHADER_CAP_MAX_INPUTS:
       return PIPE_MAX_SHADER_INPUTS;
+   case PIPE_SHADER_CAP_MAX_OUTPUTS:
+      return 32;
    case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
       return sizeof(float[4]) * 4096;
    case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
index 4720ec673cfb8ce118b71e271fce61686d406ab5..cc5a9160c5c8548e298725d01f60a314512ca575 100644 (file)
@@ -426,6 +426,8 @@ tgsi_exec_get_shader_param(enum pipe_shader_cap param)
       return TGSI_EXEC_MAX_NESTING;
    case PIPE_SHADER_CAP_MAX_INPUTS:
       return TGSI_EXEC_MAX_INPUT_ATTRIBS;
+   case PIPE_SHADER_CAP_MAX_OUTPUTS:
+      return 32;
    case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
       return TGSI_EXEC_MAX_CONST_BUFFER_SIZE;
    case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
index ba34ec8297abb80533d37415731b151f730ef9d4..88d7e4924f2276a85e824c15dcfc523d8ff706e2 100644 (file)
@@ -267,6 +267,8 @@ support different features.
 * ``PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS``: The maximum number of texture indirections.
 * ``PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH``: The maximum nested control flow depth.
 * ``PIPE_SHADER_CAP_MAX_INPUTS``: The maximum number of input registers.
+* ``PIPE_SHADER_CAP_MAX_OUTPUTS``: The maximum number of output registers.
+  This is valid for all shaders except the fragment shader.
 * ``PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE``: The maximum size per constant buffer in bytes.
 * ``PIPE_SHADER_CAP_MAX_CONST_BUFFERS``: Maximum number of constant buffers that can be bound
   to any shader stage using ``set_constant_buffer``. If 0 or 1, the pipe will
index ddc7302c5c819ebb106b7aafbf2d51e3fb171d6b..90156b49cb60df5bdd5d9ade3c311dd20fa9b411 100644 (file)
@@ -351,6 +351,7 @@ fd_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,
        case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH:
                return 8; /* XXX */
        case PIPE_SHADER_CAP_MAX_INPUTS:
+        case PIPE_SHADER_CAP_MAX_OUTPUTS:
                return 16;
        case PIPE_SHADER_CAP_MAX_TEMPS:
                return 64; /* Max native temporaries. */
index 90067343fba51575dfd5347f02b70416055e2378..2a6e7518b0e1fa852e7deb32573d6936ff68cbf5 100644 (file)
@@ -130,6 +130,8 @@ i915_get_shader_param(struct pipe_screen *screen, unsigned shader, enum pipe_sha
          return 0;
       case PIPE_SHADER_CAP_MAX_INPUTS:
          return 10;
+      case PIPE_SHADER_CAP_MAX_OUTPUTS:
+         return 1;
       case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
          return 32 * sizeof(float[4]);
       case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
index bfd67dad6227fc3351fcd9dd1895205402c87aa9..48c3dea2d7ea949a3964798b3bcca1352da529f5 100644 (file)
@@ -121,6 +121,7 @@ ilo_get_shader_param(struct pipe_screen *screen, unsigned shader,
    case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH:
       return UINT_MAX;
    case PIPE_SHADER_CAP_MAX_INPUTS:
+   case PIPE_SHADER_CAP_MAX_OUTPUTS:
       /* this is limited by how many attributes SF can remap */
       return 16;
    case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
index a1373fdd9d5e0a114bd0c277979d1c6c7a1dbb71..700b9bbfe095682c8406dc298cacfdf6cf3eedfb 100644 (file)
@@ -222,6 +222,7 @@ nv30_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,
       case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH:
          return 0;
       case PIPE_SHADER_CAP_MAX_INPUTS:
+      case PIPE_SHADER_CAP_MAX_OUTPUTS:
          return 16;
       case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
          return ((eng3d->oclass >= NV40_3D_CLASS) ? (468 - 6): (256 - 6)) * sizeof(float[4]);
@@ -258,6 +259,8 @@ nv30_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,
          return 0;
       case PIPE_SHADER_CAP_MAX_INPUTS:
          return 8; /* should be possible to do 10 with nv4x */
+      case PIPE_SHADER_CAP_MAX_OUTPUTS:
+         return 4;
       case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
          return ((eng3d->oclass >= NV40_3D_CLASS) ? 224 : 32) * sizeof(float[4]);
       case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
index 3a46e72a0f7e73ce3447a04977c81689e807c24e..d26a438378c80a426e8f4ae4ced10f06dd76deac 100644 (file)
@@ -253,6 +253,8 @@ nv50_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,
       if (shader == PIPE_SHADER_VERTEX)
          return 32;
       return 15;
+   case PIPE_SHADER_CAP_MAX_OUTPUTS:
+      return 16;
    case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
       return 65536;
    case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
index 3858981348c4c28e59f1356b58ab883b626044a9..a673eb92035086fde0dd4faa7cd239ddabb2c8f8 100644 (file)
@@ -259,6 +259,8 @@ nvc0_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,
        * and excludes 0x60 per-patch inputs.
        */
       return 0x200 / 16;
+   case PIPE_SHADER_CAP_MAX_OUTPUTS:
+      return 32;
    case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
       return 65536;
    case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
index c35559f5e73aed9d23846f40f9c5b20c4c79e61a..db9ad15983cb74b5b7017cd576f54e1f357f7ef7 100644 (file)
@@ -258,6 +258,8 @@ static int r300_get_shader_param(struct pipe_screen *pscreen, unsigned shader, e
              * additional texcoords but there is no two-sided color
              * selection then. However the facing bit can be used instead. */
             return 10;
+        case PIPE_SHADER_CAP_MAX_OUTPUTS:
+            return 4;
         case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
             return (is_r500 ? 256 : 32) * sizeof(float[4]);
         case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
@@ -306,6 +308,8 @@ static int r300_get_shader_param(struct pipe_screen *pscreen, unsigned shader, e
             return is_r500 ? 4 : 0; /* For loops; not sure about conditionals. */
         case PIPE_SHADER_CAP_MAX_INPUTS:
             return 16;
+        case PIPE_SHADER_CAP_MAX_OUTPUTS:
+            return 10;
         case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
             return 256 * sizeof(float[4]);
         case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
index 3962fee4a435ec43a2edab88daba0317e7ad5f88..c7945305182ce938d90628a8ffe329f9aada9ad7 100644 (file)
@@ -434,6 +434,8 @@ static int r600_get_shader_param(struct pipe_screen* pscreen, unsigned shader, e
                return 32;
        case PIPE_SHADER_CAP_MAX_INPUTS:
                return shader == PIPE_SHADER_VERTEX ? 16 : 32;
+       case PIPE_SHADER_CAP_MAX_OUTPUTS:
+               return shader == PIPE_SHADER_FRAGMENT ? 8 : 32;
        case PIPE_SHADER_CAP_MAX_TEMPS:
                return 256; /* Max native temporaries. */
        case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
index cba6d98f29cf4dee417d7cdbe3dd2dc4ef1db119..839711504e5dc7f6e3dda90d7c465f270a31dbbd 100644 (file)
@@ -364,6 +364,8 @@ static int si_get_shader_param(struct pipe_screen* pscreen, unsigned shader, enu
                return 32;
        case PIPE_SHADER_CAP_MAX_INPUTS:
                return shader == PIPE_SHADER_VERTEX ? SI_NUM_VERTEX_BUFFERS : 32;
+       case PIPE_SHADER_CAP_MAX_OUTPUTS:
+               return shader == PIPE_SHADER_FRAGMENT ? 8 : 32;
        case PIPE_SHADER_CAP_MAX_TEMPS:
                return 256; /* Max native temporaries. */
        case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
index 004b4b4306d9f7d7d1c1ffd99e4040c9cf03ed7b..587eaad07c8e30d2b1479b8fc67b18339d95c489 100644 (file)
@@ -330,6 +330,8 @@ static int svga_get_shader_param(struct pipe_screen *screen, unsigned shader, en
          return SVGA3D_MAX_NESTING_LEVEL;
       case PIPE_SHADER_CAP_MAX_INPUTS:
          return 10;
+      case PIPE_SHADER_CAP_MAX_OUTPUTS:
+         return svgascreen->max_color_buffers;
       case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
          return 224 * sizeof(float[4]);
       case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
@@ -387,6 +389,8 @@ static int svga_get_shader_param(struct pipe_screen *screen, unsigned shader, en
          return SVGA3D_MAX_NESTING_LEVEL;
       case PIPE_SHADER_CAP_MAX_INPUTS:
          return 16;
+      case PIPE_SHADER_CAP_MAX_OUTPUTS:
+         return 10;
       case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
          return 256 * sizeof(float[4]);
       case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
index a327c7f26b45580f1869cc00690bc37f4829fe8b..4c0455da0c0c4c606279d21bac2778d32431d9f5 100644 (file)
@@ -283,6 +283,8 @@ vc4_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,
                         return 8;
                 else
                         return 16;
+       case PIPE_SHADER_CAP_MAX_OUTPUTS:
+               return shader == PIPE_SHADER_FRAGMENT ? 1 : 8;
         case PIPE_SHADER_CAP_MAX_TEMPS:
                 return 256; /* GL_MAX_PROGRAM_TEMPORARIES_ARB */
         case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
index d9b1547b1e2521ec45549d734717a0c093919e07..42b6f3755e42d42e66f6540a4ffa90d388f2392b 100644 (file)
@@ -613,6 +613,7 @@ enum pipe_shader_cap
    PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS,
    PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH,
    PIPE_SHADER_CAP_MAX_INPUTS,
+   PIPE_SHADER_CAP_MAX_OUTPUTS,
    PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE,
    PIPE_SHADER_CAP_MAX_CONST_BUFFERS,
    PIPE_SHADER_CAP_MAX_TEMPS,
index 5dd8278007ed1b64916aad9db6935988b32338ac..78bfe30735f287ac8a2c26e7431fa492c71010aa 100644 (file)
@@ -192,6 +192,10 @@ void st_init_limits(struct pipe_screen *screen,
       pc->MaxParameters      = pc->MaxNativeParameters      =
          screen->get_shader_param(screen, sh,
                    PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE) / sizeof(float[4]);
+      pc->MaxInputComponents =
+         screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INPUTS) * 4;
+      pc->MaxOutputComponents =
+         screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_OUTPUTS) * 4;
 
       pc->MaxUniformComponents = 4 * MIN2(pc->MaxNativeParameters, MAX_UNIFORMS);
 
@@ -261,10 +265,6 @@ void st_init_limits(struct pipe_screen *screen,
    c->MaxVarying = screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
                                             PIPE_SHADER_CAP_MAX_INPUTS);
    c->MaxVarying = MIN2(c->MaxVarying, MAX_VARYING);
-   c->Program[MESA_SHADER_FRAGMENT].MaxInputComponents = c->MaxVarying * 4;
-   c->Program[MESA_SHADER_VERTEX].MaxOutputComponents = c->MaxVarying * 4;
-   c->Program[MESA_SHADER_GEOMETRY].MaxInputComponents = c->MaxVarying * 4;
-   c->Program[MESA_SHADER_GEOMETRY].MaxOutputComponents = c->MaxVarying * 4;
    c->MaxGeometryOutputVertices = screen->get_param(screen, PIPE_CAP_MAX_GEOMETRY_OUTPUT_VERTICES);
    c->MaxGeometryTotalOutputComponents = screen->get_param(screen, PIPE_CAP_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS);