gallium: remove PIPE_MAX_VERTEX/GEOMETRY_SAMPLERS #define
authorBrian Paul <brianp@vmware.com>
Fri, 10 Aug 2012 02:59:44 +0000 (20:59 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 16 Aug 2012 15:01:31 +0000 (09:01 -0600)
PIPE_MAX_SAMPLERS, PIPE_MAX_VERTEX_SAMPLERS and PIPE_MAX_GEOMETRY_SAMPLERS
were all defined to the same value (16).

In various places we're creating arrays such as
sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS] so we were assuming
the same number of max samplers for all shader stages anyway.

Of course, drivers are still free to advertise different numbers of max
samplers for different shaders.

21 files changed:
src/gallium/auxiliary/cso_cache/cso_context.c
src/gallium/auxiliary/draw/draw_llvm.c
src/gallium/auxiliary/draw/draw_llvm.h
src/gallium/auxiliary/draw/draw_llvm_sample.c
src/gallium/drivers/galahad/glhd_context.c
src/gallium/drivers/i915/i915_context.h
src/gallium/drivers/i915/i915_screen.c
src/gallium/drivers/i915/i915_state.c
src/gallium/drivers/identity/id_context.c
src/gallium/drivers/llvmpipe/lp_context.c
src/gallium/drivers/llvmpipe/lp_context.h
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/llvmpipe/lp_state_sampler.c
src/gallium/drivers/rbug/rbug_context.c
src/gallium/drivers/rbug/rbug_context.h
src/gallium/drivers/softpipe/sp_context.c
src/gallium/drivers/softpipe/sp_context.h
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/drivers/trace/tr_context.c
src/gallium/include/pipe/p_state.h
src/mesa/state_tracker/st_context.h

index 7fb8caf..db4fa01 100644 (file)
@@ -256,8 +256,6 @@ struct cso_context *cso_create_context( struct pipe_context *pipe )
    if (ctx == NULL)
       goto out;
 
-   assert(PIPE_MAX_SAMPLERS == PIPE_MAX_VERTEX_SAMPLERS);
-
    ctx->cache = cso_cache_create();
    if (ctx->cache == NULL)
       goto out;
index 133aa5f..ebfe437 100644 (file)
@@ -164,7 +164,7 @@ create_jit_context_type(struct gallivm_state *gallivm,
                                                  DRAW_TOTAL_CLIP_PLANES), 0);
    elem_types[3] = LLVMPointerType(float_type, 0); /* viewport */
    elem_types[4] = LLVMArrayType(texture_type,
-                                 PIPE_MAX_VERTEX_SAMPLERS); /* textures */
+                                 PIPE_MAX_SAMPLERS); /* textures */
    context_type = LLVMStructTypeInContext(gallivm->context, elem_types,
                                           Elements(elem_types), 0);
 #if HAVE_LLVM < 0x0300
@@ -1371,7 +1371,7 @@ draw_llvm_set_mapped_texture(struct draw_context *draw,
    unsigned j;
    struct draw_jit_texture *jit_tex;
 
-   assert(sampler_idx < PIPE_MAX_VERTEX_SAMPLERS);
+   assert(sampler_idx < Elements(draw->llvm->jit_context.textures));
 
    jit_tex = &draw->llvm->jit_context.textures[sampler_idx];
 
index 39d83cf..9a291a4 100644 (file)
@@ -97,7 +97,7 @@ struct draw_jit_context
    float (*planes) [DRAW_TOTAL_CLIP_PLANES][4];
    float *viewport;
 
-   struct draw_jit_texture textures[PIPE_MAX_VERTEX_SAMPLERS];
+   struct draw_jit_texture textures[PIPE_MAX_SAMPLERS];
 };
 
 
@@ -184,7 +184,7 @@ struct draw_llvm_variant_key
 
 #define DRAW_LLVM_MAX_VARIANT_KEY_SIZE \
    (sizeof(struct draw_llvm_variant_key) +     \
-    PIPE_MAX_VERTEX_SAMPLERS * sizeof(struct lp_sampler_static_state) +        \
+    PIPE_MAX_SAMPLERS * sizeof(struct lp_sampler_static_state) +       \
     (PIPE_MAX_ATTRIBS-1) * sizeof(struct pipe_vertex_element))
 
 
index 1dbe5f5..5331716 100644 (file)
@@ -98,7 +98,7 @@ draw_llvm_texture_member(const struct lp_sampler_dynamic_state *base,
    LLVMValueRef ptr;
    LLVMValueRef res;
 
-   debug_assert(unit < PIPE_MAX_VERTEX_SAMPLERS);
+   debug_assert(unit < PIPE_MAX_SAMPLERS);
 
    /* context[0] */
    indices[0] = lp_build_const_int32(gallivm, 0);
@@ -180,7 +180,7 @@ draw_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base,
 {
    struct draw_llvm_sampler_soa *sampler = (struct draw_llvm_sampler_soa *)base;
 
-   assert(unit < PIPE_MAX_VERTEX_SAMPLERS);
+   assert(unit < PIPE_MAX_SAMPLERS);
 
    lp_build_sample_soa(gallivm,
                        &sampler->dynamic_state.static_state[unit],
@@ -207,7 +207,7 @@ draw_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base,
 {
    struct draw_llvm_sampler_soa *sampler = (struct draw_llvm_sampler_soa *)base;
 
-   assert(unit < PIPE_MAX_VERTEX_SAMPLERS);
+   assert(unit < PIPE_MAX_SAMPLERS);
 
    lp_build_size_query_soa(gallivm,
                            &sampler->dynamic_state.static_state[unit],
index 01ab923..dc7f017 100644 (file)
@@ -208,10 +208,10 @@ galahad_context_bind_vertex_sampler_states(struct pipe_context *_pipe,
    struct galahad_context *glhd_pipe = galahad_context(_pipe);
    struct pipe_context *pipe = glhd_pipe->pipe;
 
-   if (num_samplers > PIPE_MAX_VERTEX_SAMPLERS) {
+   if (num_samplers > PIPE_MAX_SAMPLERS) {
       glhd_error("%u vertex samplers requested, "
          "but only %u are permitted by API",
-         num_samplers, PIPE_MAX_VERTEX_SAMPLERS);
+         num_samplers, PIPE_MAX_SAMPLERS);
    }
 
    pipe->bind_vertex_sampler_states(pipe,
@@ -587,14 +587,14 @@ galahad_context_set_vertex_sampler_views(struct pipe_context *_pipe,
 {
    struct galahad_context *glhd_pipe = galahad_context(_pipe);
    struct pipe_context *pipe = glhd_pipe->pipe;
-   struct pipe_sampler_view *unwrapped_views[PIPE_MAX_VERTEX_SAMPLERS];
+   struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SAMPLERS];
    struct pipe_sampler_view **views = NULL;
    unsigned i;
 
    if (_views) {
       for (i = 0; i < num; i++)
          unwrapped_views[i] = galahad_sampler_view_unwrap(_views[i]);
-      for (; i < PIPE_MAX_VERTEX_SAMPLERS; i++)
+      for (; i < Elements(unwrapped_views); i++)
          unwrapped_views[i] = NULL;
 
       views = unwrapped_views;
index 16b0c57..c9198e2 100644 (file)
@@ -230,7 +230,7 @@ struct i915_context {
     */
    const struct i915_blend_state           *blend;
    const struct i915_sampler_state         *sampler[PIPE_MAX_SAMPLERS];
-   struct pipe_sampler_state *vertex_samplers[PIPE_MAX_VERTEX_SAMPLERS];
+   struct pipe_sampler_state *vertex_samplers[PIPE_MAX_SAMPLERS];
    const struct i915_depth_stencil_state   *depth_stencil;
    const struct i915_rasterizer_state      *rasterizer;
 
@@ -250,8 +250,8 @@ struct i915_context {
 
    unsigned dirty;
 
-   struct pipe_resource *mapped_vs_tex[PIPE_MAX_VERTEX_SAMPLERS];
-   struct i915_winsys_buffer* mapped_vs_tex_buffer[PIPE_MAX_VERTEX_SAMPLERS];
+   struct pipe_resource *mapped_vs_tex[PIPE_MAX_SAMPLERS];
+   struct i915_winsys_buffer* mapped_vs_tex_buffer[PIPE_MAX_SAMPLERS];
 
    unsigned num_samplers;
    unsigned num_fragment_sampler_views;
index 35b343e..579337b 100644 (file)
@@ -107,7 +107,7 @@ i915_get_shader_param(struct pipe_screen *screen, unsigned shader, enum pipe_sha
       switch (cap) {
       case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
          if (debug_get_bool_option("DRAW_USE_LLVM", TRUE))
-            return PIPE_MAX_VERTEX_SAMPLERS;
+            return PIPE_MAX_SAMPLERS;
          else
             return 0;
        default:
index 8af26fa..fdbff8b 100644 (file)
@@ -310,7 +310,7 @@ i915_bind_vertex_sampler_states(struct pipe_context *pipe,
    struct i915_context *i915 = i915_context(pipe);
    unsigned i;
 
-   assert(num_samplers <= PIPE_MAX_VERTEX_SAMPLERS);
+   assert(num_samplers <= Elements(i915->vertex_samplers));
 
    /* Check for no-op */
    if (num_samplers == i915->num_vertex_samplers &&
@@ -319,7 +319,7 @@ i915_bind_vertex_sampler_states(struct pipe_context *pipe,
 
    for (i = 0; i < num_samplers; ++i)
       i915->vertex_samplers[i] = samplers[i];
-   for (i = num_samplers; i < PIPE_MAX_VERTEX_SAMPLERS; ++i)
+   for (i = num_samplers; i < Elements(i915->vertex_samplers); ++i)
       i915->vertex_samplers[i] = NULL;
 
    i915->num_vertex_samplers = num_samplers;
@@ -374,11 +374,11 @@ i915_prepare_vertex_sampling(struct i915_context *i915)
    unsigned num = i915->num_vertex_sampler_views;
    struct pipe_sampler_view **views = i915->vertex_sampler_views;
 
-   assert(num <= PIPE_MAX_VERTEX_SAMPLERS);
+   assert(num <= PIPE_MAX_SAMPLERS);
    if (!num)
       return;
 
-   for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+   for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
       struct pipe_sampler_view *view = i < num ? views[i] : NULL;
 
       if (view) {
@@ -777,7 +777,7 @@ i915_set_vertex_sampler_views(struct pipe_context *pipe,
    struct i915_context *i915 = i915_context(pipe);
    uint i;
 
-   assert(num <= PIPE_MAX_VERTEX_SAMPLERS);
+   assert(num <= Elements(i915->vertex_sampler_views));
 
    /* Check for no-op */
    if (num == i915->num_vertex_sampler_views &&
@@ -785,7 +785,7 @@ i915_set_vertex_sampler_views(struct pipe_context *pipe,
       return;
    }
 
-   for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+   for (i = 0; i < Elements(i915->vertex_sampler_views); i++) {
       struct pipe_sampler_view *view = i < num ? views[i] : NULL;
 
       pipe_sampler_view_reference(&i915->vertex_sampler_views[i], view);
index 2d47296..794e62c 100644 (file)
@@ -517,14 +517,14 @@ identity_set_vertex_sampler_views(struct pipe_context *_pipe,
 {
    struct identity_context *id_pipe = identity_context(_pipe);
    struct pipe_context *pipe = id_pipe->pipe;
-   struct pipe_sampler_view *unwrapped_views[PIPE_MAX_VERTEX_SAMPLERS];
+   struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SAMPLERS];
    struct pipe_sampler_view **views = NULL;
    unsigned i;
 
    if (_views) {
       for (i = 0; i < num; i++)
          unwrapped_views[i] = identity_sampler_view_unwrap(_views[i]);
-      for (; i < PIPE_MAX_VERTEX_SAMPLERS; i++)
+      for (; i < Elements(unwrapped_views); i++)
          unwrapped_views[i] = NULL;
 
       views = unwrapped_views;
index 7d0ca1f..dec3473 100644 (file)
@@ -69,11 +69,11 @@ static void llvmpipe_destroy( struct pipe_context *pipe )
 
    pipe_surface_reference(&llvmpipe->framebuffer.zsbuf, NULL);
 
-   for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
+   for (i = 0; i < Elements(llvmpipe->sampler_views[0]); i++) {
       pipe_sampler_view_reference(&llvmpipe->sampler_views[PIPE_SHADER_FRAGMENT][i], NULL);
    }
 
-   for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+   for (i = 0; i < Elements(llvmpipe->sampler_views[0]); i++) {
       pipe_sampler_view_reference(&llvmpipe->sampler_views[PIPE_SHADER_VERTEX][i], NULL);
    }
 
index f8610ae..b7b7ede 100644 (file)
@@ -86,7 +86,7 @@ struct llvmpipe_context {
       int so_count[PIPE_MAX_SO_BUFFERS];
       int num_buffers;
    } so_target;
-   struct pipe_resource *mapped_vs_tex[PIPE_MAX_VERTEX_SAMPLERS];
+   struct pipe_resource *mapped_vs_tex[PIPE_MAX_SAMPLERS];
 
    unsigned num_samplers[PIPE_SHADER_TYPES];
    unsigned num_sampler_views[PIPE_SHADER_TYPES];
index 61aa192..5f19a47 100644 (file)
@@ -105,7 +105,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
 {
    switch (param) {
    case PIPE_CAP_MAX_COMBINED_SAMPLERS:
-      return PIPE_MAX_SAMPLERS + PIPE_MAX_VERTEX_SAMPLERS;
+      return 2 * PIPE_MAX_SAMPLERS;  /* VS + FS samplers */
    case PIPE_CAP_NPOT_TEXTURES:
       return 1;
    case PIPE_CAP_TWO_SIDED_STENCIL:
@@ -234,7 +234,7 @@ llvmpipe_get_shader_param(struct pipe_screen *screen, unsigned shader, enum pipe
           * the draw module.
           */
          if (debug_get_bool_option("DRAW_USE_LLVM", TRUE))
-            return PIPE_MAX_VERTEX_SAMPLERS;
+            return PIPE_MAX_SAMPLERS;
          else
             return 0;
       default:
index 121569e..8e30b5c 100644 (file)
@@ -234,11 +234,11 @@ llvmpipe_prepare_vertex_sampling(struct llvmpipe_context *lp,
    uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS];
    const void *data[PIPE_MAX_TEXTURE_LEVELS];
 
-   assert(num <= PIPE_MAX_VERTEX_SAMPLERS);
+   assert(num <= PIPE_MAX_SAMPLERS);
    if (!num)
       return;
 
-   for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
+   for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
       struct pipe_sampler_view *view = i < num ? views[i] : NULL;
 
       if (view) {
index 65f0d71..eb6230e 100644 (file)
@@ -753,7 +753,7 @@ rbug_set_vertex_sampler_views(struct pipe_context *_pipe,
 {
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
-   struct pipe_sampler_view *unwrapped_views[PIPE_MAX_VERTEX_SAMPLERS];
+   struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SAMPLERS];
    struct pipe_sampler_view **views = NULL;
    unsigned i;
 
index 80c803d..0a41bbd 100644 (file)
@@ -54,8 +54,8 @@ struct rbug_context {
       struct rbug_resource *fs_texs[PIPE_MAX_SAMPLERS];
       unsigned num_fs_views;
 
-      struct rbug_sampler_view *vs_views[PIPE_MAX_VERTEX_SAMPLERS];
-      struct rbug_resource *vs_texs[PIPE_MAX_VERTEX_SAMPLERS];
+      struct rbug_sampler_view *vs_views[PIPE_MAX_SAMPLERS];
+      struct rbug_resource *vs_texs[PIPE_MAX_SAMPLERS];
       unsigned num_vs_views;
 
       unsigned nr_cbufs;
index e2e32b9..0360b3b 100644 (file)
@@ -216,10 +216,6 @@ softpipe_create_context( struct pipe_screen *screen,
    struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
    uint i, sh;
 
-   /* Check since we have arrays[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS] */
-   STATIC_ASSERT(PIPE_MAX_SAMPLERS == PIPE_MAX_VERTEX_SAMPLERS);
-   STATIC_ASSERT(PIPE_MAX_SAMPLERS == PIPE_MAX_GEOMETRY_SAMPLERS);
-
    util_init_math();
 
    softpipe->dump_fs = debug_get_bool_option( "SOFTPIPE_DUMP_FS", FALSE );
@@ -290,13 +286,13 @@ softpipe_create_context( struct pipe_screen *screen,
 
    draw_texture_samplers(softpipe->draw,
                          PIPE_SHADER_VERTEX,
-                         PIPE_MAX_VERTEX_SAMPLERS,
+                         PIPE_MAX_SAMPLERS,
                          (struct tgsi_sampler **)
                             softpipe->tgsi.samplers_list[PIPE_SHADER_VERTEX]);
 
    draw_texture_samplers(softpipe->draw,
                          PIPE_SHADER_GEOMETRY,
-                         PIPE_MAX_GEOMETRY_SAMPLERS,
+                         PIPE_MAX_SAMPLERS,
                          (struct tgsi_sampler **)
                             softpipe->tgsi.samplers_list[PIPE_SHADER_GEOMETRY]);
 
index 2185fb8..44599dd 100644 (file)
@@ -79,7 +79,7 @@ struct softpipe_context {
    struct pipe_framebuffer_state framebuffer;
    struct pipe_poly_stipple poly_stipple;
    struct pipe_scissor_state scissor;
-   struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_GEOMETRY_SAMPLERS];
+   struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
 
    struct pipe_viewport_state viewport;
    struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
index 5588611..98a3e09 100644 (file)
@@ -67,7 +67,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
 {
    switch (param) {
    case PIPE_CAP_MAX_COMBINED_SAMPLERS:
-      return PIPE_MAX_SAMPLERS + PIPE_MAX_VERTEX_SAMPLERS;
+      return 2 * PIPE_MAX_SAMPLERS;  /* VS + FS */
    case PIPE_CAP_NPOT_TEXTURES:
       return 1;
    case PIPE_CAP_TWO_SIDED_STENCIL:
@@ -190,7 +190,7 @@ softpipe_get_shader_param(struct pipe_screen *screen, unsigned shader, enum pipe
             /* Softpipe doesn't yet know how to tell draw/llvm about textures */
             return 0;
         else
-            return PIPE_MAX_VERTEX_SAMPLERS;
+            return PIPE_MAX_SAMPLERS;
       default:
         if (sp_screen->use_llvm)
             return draw_get_shader_param(shader, param);
index ffaa3d0..17f7e95 100644 (file)
@@ -998,7 +998,7 @@ trace_context_set_vertex_sampler_views(struct pipe_context *_pipe,
    struct trace_context *tr_ctx = trace_context(_pipe);
    struct trace_sampler_view *tr_view;
    struct pipe_context *pipe = tr_ctx->pipe;
-   struct pipe_sampler_view *unwrapped_views[PIPE_MAX_VERTEX_SAMPLERS];
+   struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SAMPLERS];
    unsigned i;
 
    if (!pipe->set_vertex_sampler_views)
index 76559ad..9ea9c0e 100644 (file)
@@ -58,8 +58,6 @@ extern "C" {
 #define PIPE_MAX_COLOR_BUFS        8
 #define PIPE_MAX_CONSTANT_BUFFERS 32
 #define PIPE_MAX_SAMPLERS         16
-#define PIPE_MAX_VERTEX_SAMPLERS  16
-#define PIPE_MAX_GEOMETRY_SAMPLERS  16
 #define PIPE_MAX_SHADER_INPUTS    32
 #define PIPE_MAX_SHADER_OUTPUTS   32
 #define PIPE_MAX_SHADER_SAMPLER_VIEWS 32
index 0dfd81c..8afd776 100644 (file)
@@ -99,7 +99,7 @@ struct st_context
       struct pipe_depth_stencil_alpha_state depth_stencil;
       struct pipe_rasterizer_state          rasterizer;
       struct pipe_sampler_state    fragment_samplers[PIPE_MAX_SAMPLERS];
-      struct pipe_sampler_state    vertex_samplers[PIPE_MAX_VERTEX_SAMPLERS];
+      struct pipe_sampler_state    vertex_samplers[PIPE_MAX_SAMPLERS];
       struct pipe_clip_state clip;
       struct {
          void *ptr;
@@ -107,7 +107,7 @@ struct st_context
       } constants[PIPE_SHADER_TYPES];
       struct pipe_framebuffer_state framebuffer;
       struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
-      struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS];
+      struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_SAMPLERS];
       struct pipe_scissor_state scissor;
       struct pipe_viewport_state viewport;
       unsigned sample_mask;