gallium: add and use PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS
authorMarek Olšák <maraeo@gmail.com>
Tue, 27 Sep 2011 20:22:06 +0000 (22:22 +0200)
committerMarek Olšák <maraeo@gmail.com>
Fri, 30 Sep 2011 21:19:52 +0000 (23:19 +0200)
This removes:
- PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS
- PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS
in favor of the that new per-shader cap.

Reviewed-by: Brian Paul <brianp@vmware.com>
15 files changed:
src/gallium/auxiliary/tgsi/tgsi_exec.h
src/gallium/drivers/cell/ppu/cell_screen.c
src/gallium/drivers/i915/i915_screen.c
src/gallium/drivers/i965/brw_screen.c
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/nv50/nv50_screen.c
src/gallium/drivers/nvc0/nvc0_screen.c
src/gallium/drivers/nvfx/nvfx_screen.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r600/r600_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/state_trackers/d3d1x/gd3d11/d3d11_screen.h
src/mesa/state_tracker/st_extensions.c

index a750715790621286f369dc3a620046e26885ae54..223da2cb1c680118ac83bac6e664d01cb44b3756 100644 (file)
@@ -408,6 +408,8 @@ tgsi_exec_get_shader_param(enum pipe_shader_cap param)
       return 1;
    case PIPE_SHADER_CAP_INTEGERS:
       return 1;
+   case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
+      return PIPE_MAX_SAMPLERS;
    default:
       return 0;
    }
index a98529dc7777a715c4cae9473f391bdf38c96e8c..14a6173ff350f05a4089b5e6376a8f54373fa41b 100644 (file)
@@ -58,8 +58,6 @@ static int
 cell_get_param(struct pipe_screen *screen, enum pipe_cap param)
 {
    switch (param) {
-   case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
-      return CELL_MAX_SAMPLERS;
    case PIPE_CAP_MAX_COMBINED_SAMPLERS:
       return CELL_MAX_SAMPLERS;
    case PIPE_CAP_NPOT_TEXTURES:
@@ -107,7 +105,12 @@ cell_get_shader_param(struct pipe_screen *screen, unsigned shader, enum pipe_sha
    switch(shader)
    {
    case PIPE_SHADER_FRAGMENT:
-      return tgsi_exec_get_shader_param(param);
+      switch (param) {
+      case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
+         return CELL_MAX_SAMPLERS;
+      default:
+         return tgsi_exec_get_shader_param(param);
+      }
    case PIPE_SHADER_VERTEX:
    case PIPE_SHADER_GEOMETRY:
       return draw_get_shader_param(shader, param);
index e0f44cd4ee86d80afdad6945bf2e85b7d9d1a9dd..3d601a5911def3d42488a2e37f3d507cd97a9892 100644 (file)
@@ -140,11 +140,8 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
       return is->debug.lie ? 1 : 0;
 
    /* Texturing. */
-   case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
    case PIPE_CAP_MAX_COMBINED_SAMPLERS:
       return 8;
-   case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
-      return 0;
    case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
       return I915_MAX_TEXTURE_2D_LEVELS;
    case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
@@ -178,7 +175,12 @@ i915_get_shader_param(struct pipe_screen *screen, unsigned shader, enum pipe_sha
 {
    switch(shader) {
    case PIPE_SHADER_VERTEX:
-      return draw_get_shader_param(shader, cap);
+      switch (cap) {
+      case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
+         return 0;
+      default:
+         return draw_get_shader_param(shader, cap);
+      }
    case PIPE_SHADER_FRAGMENT:
       break;
    default:
@@ -220,6 +222,8 @@ i915_get_shader_param(struct pipe_screen *screen, unsigned shader, enum pipe_sha
          return 0;
       case PIPE_SHADER_CAP_INTEGERS:
          return 0;
+      case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
+         return 8;
       default:
          debug_printf("%s: Unknown cap %u.\n", __FUNCTION__, cap);
          return 0;
index 39e9e2fa6ac92caa5b8d77fdd4aad90c93e645da..076338ad5500d43593acc1ca193ac63d27ca09fe 100644 (file)
@@ -154,10 +154,6 @@ static int
 brw_get_param(struct pipe_screen *screen, enum pipe_cap param)
 {
    switch (param) {
-   case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
-      return 8;
-   case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
-      return 8;
    case PIPE_CAP_MAX_COMBINED_SAMPLERS:
       return 16; /* XXX correct? */
    case PIPE_CAP_NPOT_TEXTURES:
@@ -245,6 +241,8 @@ brw_get_shader_param(struct pipe_screen *screen, unsigned shader, enum pipe_shad
           return 1;
       case PIPE_SHADER_CAP_INTEGERS:
          return 0;
+      case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
+         return 8;
       default:
          assert(0);
          return 0;
index 11a264cc5dc7274dfded3c76879374fefb4acf61..7848d80f73950643e51fa12072a0a7190bc1c1a8 100644 (file)
@@ -104,17 +104,6 @@ static int
 llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
 {
    switch (param) {
-   case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
-      return PIPE_MAX_SAMPLERS;
-   case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
-      /* At this time, the draw module and llvmpipe driver only
-       * support vertex shader texture lookups when LLVM is enabled in
-       * the draw module.
-       */
-      if (debug_get_bool_option("DRAW_USE_LLVM", TRUE))
-         return PIPE_MAX_VERTEX_SAMPLERS;
-      else
-         return 0;
    case PIPE_CAP_MAX_COMBINED_SAMPLERS:
       return PIPE_MAX_SAMPLERS + PIPE_MAX_VERTEX_SAMPLERS;
    case PIPE_CAP_NPOT_TEXTURES:
@@ -183,7 +172,19 @@ llvmpipe_get_shader_param(struct pipe_screen *screen, unsigned shader, enum pipe
       return tgsi_exec_get_shader_param(param);
    case PIPE_SHADER_VERTEX:
    case PIPE_SHADER_GEOMETRY:
-      return draw_get_shader_param(shader, param);
+      switch (param) {
+      case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
+         /* At this time, the draw module and llvmpipe driver only
+          * support vertex shader texture lookups when LLVM is enabled in
+          * the draw module.
+          */
+         if (debug_get_bool_option("DRAW_USE_LLVM", TRUE))
+            return PIPE_MAX_VERTEX_SAMPLERS;
+         else
+            return 0;
+      default:
+         return draw_get_shader_param(shader, param);
+      }
    default:
       return 0;
    }
index 59d2dfafa471649e2cb78a511bc507cc9254dadc..bd405a78f871094ce57a9b6b7be9d52d6b3e4c42 100644 (file)
@@ -77,9 +77,6 @@ static int
 nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
 {
    switch (param) {
-   case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
-   case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
-      return 32;
    case PIPE_CAP_MAX_COMBINED_SAMPLERS:
       return 64;
    case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
@@ -193,6 +190,8 @@ nv50_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,
       return 0; /* please inline, or provide function declarations */
    case PIPE_SHADER_CAP_INTEGERS:
       return 0;
+   case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
+      return 32;
    default:
       NOUVEAU_ERR("unknown PIPE_SHADER_CAP %d\n", param);
       return 0;
index 695144e55108e6b302d37f4c4a588a6e7b61164c..a28c7d76c072643833832101b471a6987d73c7c7 100644 (file)
@@ -68,9 +68,6 @@ static int
 nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
 {
    switch (param) {
-   case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
-   case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
-      return 32;
    case PIPE_CAP_MAX_COMBINED_SAMPLERS:
       return 64;
    case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
@@ -185,6 +182,8 @@ nvc0_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader,
       return 1; /* but inlining everything, we need function declarations */
    case PIPE_SHADER_CAP_INTEGERS:
       return 1;
+   case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
+      return 32;
    default:
       NOUVEAU_ERR("unknown PIPE_SHADER_CAP %d\n", param);
       return 0;
index 49bd93231375342c5d755ce6803b8d935270c0de..50f346700d8f7d08f7a98c0b64c06b9f8ca399f0 100644 (file)
@@ -27,8 +27,6 @@ nvfx_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        struct nvfx_screen *screen = nvfx_screen(pscreen);
 
        switch (param) {
-       case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
-               return 16;
        case PIPE_CAP_NPOT_TEXTURES:
                return screen->advertise_npot;
        case PIPE_CAP_TWO_SIDED_STENCIL:
@@ -60,8 +58,6 @@ nvfx_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
                return 13;
        case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
                return !!screen->use_nv4x;
-       case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
-               return 0; /* We have 4 on nv40 - but unsupported currently */
        case PIPE_CAP_BLEND_EQUATION_SEPARATE:
                return screen->advertise_blend_equation_separate;
        case PIPE_CAP_MAX_COMBINED_SAMPLERS:
@@ -137,6 +133,8 @@ nvfx_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader, enum
                        return 0;
                case PIPE_SHADER_CAP_SUBROUTINES:
                        return screen->use_nv4x ? 1 : 0;
+               case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
+                       return 16;
                default:
                        break;
                }
@@ -179,6 +177,8 @@ nvfx_screen_get_shader_param(struct pipe_screen *pscreen, unsigned shader, enum
                        return 1;
                case PIPE_SHADER_CAP_INTEGERS:
                        return 0;
+               case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
+                       return 0; /* We have 4 on nv40 - but unsupported currently */
                default:
                        break;
                }
index 5e3aeee2efbb2b17f8609e2e7015fa821aaef86d..deb14287df9c71a33d04cd87c997e8ee671988d1 100644 (file)
@@ -138,7 +138,6 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
         case PIPE_CAP_TGSI_INSTANCEID:
         case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
         case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
-        case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
         case PIPE_CAP_SEAMLESS_CUBE_MAP:
         case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE:
         case PIPE_CAP_SCALED_RESOLVE:
@@ -152,7 +151,6 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
             return !r300screen->caps.has_tcl;
 
         /* Texturing. */
-        case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
         case PIPE_CAP_MAX_COMBINED_SAMPLERS:
             return r300screen->caps.num_tex_units;
         case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
@@ -220,6 +218,8 @@ static int r300_get_shader_param(struct pipe_screen *pscreen, unsigned shader, e
         case PIPE_SHADER_CAP_SUBROUTINES:
         case PIPE_SHADER_CAP_INTEGERS:
             return 0;
+        case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
+           return r300screen->caps.num_tex_units;
         }
         break;
     case PIPE_SHADER_VERTEX:
@@ -257,6 +257,7 @@ static int r300_get_shader_param(struct pipe_screen *pscreen, unsigned shader, e
         case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR:
         case PIPE_SHADER_CAP_SUBROUTINES:
         case PIPE_SHADER_CAP_INTEGERS:
+        case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
             return 0;
         }
         break;
index f1d8360d7b2793d6c41a52d023dfee0a8053beae..25e7c43f4dcbced22c4483c0f0c696e78cf4205d 100644 (file)
@@ -389,9 +389,6 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS:
                return rscreen->info.drm_minor >= 9 ?
                        (family >= CHIP_CEDAR ? 16384 : 8192) : 0;
-       case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
-       case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
-               return 16;
        case PIPE_CAP_MAX_COMBINED_SAMPLERS:
                return 32;
 
@@ -491,6 +488,8 @@ static int r600_get_shader_param(struct pipe_screen* pscreen, unsigned shader, e
                return 0;
        case PIPE_SHADER_CAP_INTEGERS:
                return 0;
+       case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
+               return 16;
        default:
                return 0;
        }
index 9c6e4c4c4cae1f7ca81310415f34e9f315b950ce..24852a539764a398822c52a521a8b9e029d8e644 100644 (file)
@@ -64,15 +64,6 @@ static int
 softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
 {
    switch (param) {
-   case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
-      return PIPE_MAX_SAMPLERS;
-   case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
-#ifdef HAVE_LLVM
-      /* Softpipe doesn't yet know how to tell draw/llvm about textures */
-      return 0;
-#else
-      return PIPE_MAX_VERTEX_SAMPLERS;
-#endif
    case PIPE_CAP_MAX_COMBINED_SAMPLERS:
       return PIPE_MAX_SAMPLERS + PIPE_MAX_VERTEX_SAMPLERS;
    case PIPE_CAP_NPOT_TEXTURES:
@@ -147,7 +138,17 @@ softpipe_get_shader_param(struct pipe_screen *screen, unsigned shader, enum pipe
       return tgsi_exec_get_shader_param(param);
    case PIPE_SHADER_VERTEX:
    case PIPE_SHADER_GEOMETRY:
-      return draw_get_shader_param(shader, param);
+      switch (param) {
+      case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
+#ifdef HAVE_LLVM
+         /* Softpipe doesn't yet know how to tell draw/llvm about textures */
+         return 0;
+#else
+         return PIPE_MAX_VERTEX_SAMPLERS;
+#endif
+      default:
+         return draw_get_shader_param(shader, param);
+      }
    default:
       return 0;
    }
index e0027f34798e04676d1ce271f354e4c461cfd531..a624cd996a31cb9a83ab6680814da90304469268 100644 (file)
@@ -122,8 +122,6 @@ svga_get_paramf(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
       return 16.0;
 
-   case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
-      return 16;
    case PIPE_CAP_MAX_COMBINED_SAMPLERS:
       return 16;
    case PIPE_CAP_NPOT_TEXTURES:
@@ -256,6 +254,8 @@ static int svga_get_shader_param(struct pipe_screen *screen, unsigned shader, en
          return 0;
       case PIPE_SHADER_CAP_INTEGERS:
          return 0;
+      case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
+         return 16;
       }
       break;
    case PIPE_SHADER_VERTEX:
index e562e49128416ea0c42f7336f151e8ec294e7ac1..950672c917129a67ff329b78c4e34ea584cacd3f 100644 (file)
@@ -418,7 +418,6 @@ enum pipe_transfer_usage {
  * pipe_screen::get_param() and pipe_screen::get_paramf().
  */
 enum pipe_cap {
-   PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS = 0,
    PIPE_CAP_NPOT_TEXTURES = 1,
    PIPE_CAP_TWO_SIDED_STENCIL = 2,
    PIPE_CAP_GLSL = 3,  /* XXX need something better */
@@ -444,7 +443,6 @@ enum pipe_cap {
    PIPE_CAP_GUARD_BAND_RIGHT = 23,  /*< float */
    PIPE_CAP_GUARD_BAND_BOTTOM = 24,  /*< float */
    PIPE_CAP_TEXTURE_MIRROR_CLAMP = 25,
-   PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS = 27,
    PIPE_CAP_BLEND_EQUATION_SEPARATE = 28,
    PIPE_CAP_SM3 = 29,  /*< Shader Model, supported */
    PIPE_CAP_STREAM_OUTPUT = 30,
@@ -496,7 +494,8 @@ enum pipe_shader_cap
    PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR = 14,
    PIPE_SHADER_CAP_INDIRECT_CONST_ADDR = 15,
    PIPE_SHADER_CAP_SUBROUTINES = 16, /* BGNSUB, ENDSUB, CAL, RET */
-   PIPE_SHADER_CAP_INTEGERS = 17
+   PIPE_SHADER_CAP_INTEGERS = 17,
+   PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS = 18
 };
 
 
index 9d8bbd895370e455d878ba3d44965f367c494974..ca2636cb6bab55ca3bc477c92a2d79ad96c12347 100644 (file)
@@ -102,7 +102,7 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen
                }
 
                screen_caps.stages_with_sampling = (1 << screen_caps.stages) - 1;
-               if(!screen->get_param(screen, PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS))
+               if(!screen->get_shader_param(screen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS))
                        screen_caps.stages_with_sampling &=~ (1 << PIPE_SHADER_VERTEX);
 
                memset(format_support, 0xff, sizeof(format_support));
index 27fff39a8b66fb967901dff09017c2abe192d1cf..2be191cc10e48c3103466f63307c765ac7be9b51 100644 (file)
@@ -90,11 +90,13 @@ void st_init_limits(struct st_context *st)
       = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS);
 
    c->MaxTextureImageUnits
-      = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS),
+      = _min(screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
+                                      PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS),
             MAX_TEXTURE_IMAGE_UNITS);
 
    c->MaxVertexTextureImageUnits
-      = _min(screen->get_param(screen, PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS),
+      = _min(screen->get_shader_param(screen, PIPE_SHADER_VERTEX,
+                                      PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS),
              MAX_VERTEX_TEXTURE_IMAGE_UNITS);
 
    c->MaxCombinedTextureImageUnits