llvmpipe: combine vertex/fragment sampler state into an array
authorBrian Paul <brianp@vmware.com>
Sat, 4 Aug 2012 14:46:42 +0000 (08:46 -0600)
committerBrian Paul <brianp@vmware.com>
Mon, 6 Aug 2012 14:33:17 +0000 (08:33 -0600)
This will allow code consolidation in the next patch.

Reviewed-by: José Fonseca <jfonseca@vmware.com>
src/gallium/drivers/llvmpipe/lp_context.c
src/gallium/drivers/llvmpipe/lp_context.h
src/gallium/drivers/llvmpipe/lp_draw_arrays.c
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_setup.h
src/gallium/drivers/llvmpipe/lp_state_derived.c
src/gallium/drivers/llvmpipe/lp_state_fs.c
src/gallium/drivers/llvmpipe/lp_state_sampler.c

index 07cea9158c33b2af47ab5162fb868a07cf9f9483..7d0ca1f8cd8f0e724369fc961b3dbae56177db6b 100644 (file)
@@ -70,11 +70,11 @@ static void llvmpipe_destroy( struct pipe_context *pipe )
    pipe_surface_reference(&llvmpipe->framebuffer.zsbuf, NULL);
 
    for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
-      pipe_sampler_view_reference(&llvmpipe->fragment_sampler_views[i], NULL);
+      pipe_sampler_view_reference(&llvmpipe->sampler_views[PIPE_SHADER_FRAGMENT][i], NULL);
    }
 
    for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
-      pipe_sampler_view_reference(&llvmpipe->vertex_sampler_views[i], NULL);
+      pipe_sampler_view_reference(&llvmpipe->sampler_views[PIPE_SHADER_VERTEX][i], NULL);
    }
 
    for (i = 0; i < Elements(llvmpipe->constants); i++) {
index d0220e188cfc361b55f62b6cf23af25a97781d47..f8610ae8f0c3774efb265c03a7ff247f59060c6a 100644 (file)
@@ -57,8 +57,8 @@ struct llvmpipe_context {
 
    /** Constant state objects */
    const struct pipe_blend_state *blend;
-   const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
-   struct pipe_sampler_state *vertex_samplers[PIPE_MAX_VERTEX_SAMPLERS];
+   struct pipe_sampler_state *samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
+
    const struct pipe_depth_stencil_alpha_state *depth_stencil;
    const struct pipe_rasterizer_state *rasterizer;
    struct lp_fragment_shader *fs;
@@ -75,8 +75,8 @@ struct llvmpipe_context {
    struct pipe_framebuffer_state framebuffer;
    struct pipe_poly_stipple poly_stipple;
    struct pipe_scissor_state scissor;
-   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 *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
+
    struct pipe_viewport_state viewport;
    struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
    struct pipe_index_buffer index_buffer;
@@ -88,10 +88,9 @@ struct llvmpipe_context {
    } so_target;
    struct pipe_resource *mapped_vs_tex[PIPE_MAX_VERTEX_SAMPLERS];
 
-   unsigned num_samplers;
-   unsigned num_fragment_sampler_views;
-   unsigned num_vertex_samplers;
-   unsigned num_vertex_sampler_views;
+   unsigned num_samplers[PIPE_SHADER_TYPES];
+   unsigned num_sampler_views[PIPE_SHADER_TYPES];
+
    unsigned num_vertex_buffers;
 
    unsigned dirty; /**< Mask of LP_NEW_x flags */
index 96259d7144f4be13899b4ccca6f35d1a75ba6a46..f37b3ca1cea3fcf4e776082c8354da0fad37276c 100644 (file)
@@ -85,8 +85,8 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
    }
 
    llvmpipe_prepare_vertex_sampling(lp,
-                                    lp->num_vertex_sampler_views,
-                                    lp->vertex_sampler_views);
+                                    lp->num_sampler_views[PIPE_SHADER_VERTEX],
+                                    lp->sampler_views[PIPE_SHADER_VERTEX]);
 
    /* draw! */
    draw_vbo(draw, info);
index 4f7d116d4861886e58f0b7b49b604e96eb1be0b8..e5c84bbacdca674aefe4b9a2a19bb3d09d1ca111 100644 (file)
@@ -712,7 +712,7 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
 void
 lp_setup_set_fragment_sampler_state(struct lp_setup_context *setup,
                                     unsigned num,
-                                    const struct pipe_sampler_state **samplers)
+                                    struct pipe_sampler_state **samplers)
 {
    unsigned i;
 
index 8655259d27c72b3249c3f9f9d61fab6bd0e74a12..78b41451e926d5595717e197b3eb5850f7dddf0f 100644 (file)
@@ -127,7 +127,7 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
 void
 lp_setup_set_fragment_sampler_state(struct lp_setup_context *setup,
                                     unsigned num,
-                                    const struct pipe_sampler_state **samplers);
+                                    struct pipe_sampler_state **samplers);
 
 unsigned
 lp_setup_is_resource_referenced( const struct lp_setup_context *setup,
index a8b3142d8cf60a08811f8e00bf5f1a6963238575..056e163f074f8d78b90ae5dbb8be897b151149c7 100644 (file)
@@ -178,13 +178,13 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe )
 
    if (llvmpipe->dirty & (LP_NEW_SAMPLER_VIEW))
       lp_setup_set_fragment_sampler_views(llvmpipe->setup,
-                                          llvmpipe->num_fragment_sampler_views,
-                                          llvmpipe->fragment_sampler_views);
+                                          llvmpipe->num_sampler_views[PIPE_SHADER_FRAGMENT],
+                                          llvmpipe->sampler_views[PIPE_SHADER_FRAGMENT]);
 
    if (llvmpipe->dirty & (LP_NEW_SAMPLER))
       lp_setup_set_fragment_sampler_state(llvmpipe->setup,
-                                          llvmpipe->num_samplers,
-                                          llvmpipe->sampler);
+                                          llvmpipe->num_samplers[PIPE_SHADER_FRAGMENT],
+                                          llvmpipe->samplers[PIPE_SHADER_FRAGMENT]);
 
    llvmpipe->dirty = 0;
 }
index 374544fcf70d1bab985998a618983916db06a3ac..da20dedde3e39b7f756d45dd099a1c23f2d6663b 100644 (file)
@@ -1645,8 +1645,8 @@ make_variant_key(struct llvmpipe_context *lp,
    for(i = 0; i < key->nr_samplers; ++i) {
       if(shader->info.base.file_mask[TGSI_FILE_SAMPLER] & (1 << i)) {
          lp_sampler_static_state(&key->sampler[i],
-                                lp->fragment_sampler_views[i],
-                                lp->sampler[i]);
+                                lp->sampler_views[PIPE_SHADER_FRAGMENT][i],
+                                lp->samplers[PIPE_SHADER_FRAGMENT][i]);
       }
    }
 }
index df9fb89cc8ec38eb983ae9b5f60172d5c580fce7..145153809cfed8b41db4b20e4591114947556191 100644 (file)
@@ -74,18 +74,18 @@ llvmpipe_bind_sampler_states(struct pipe_context *pipe,
    assert(num <= PIPE_MAX_SAMPLERS);
 
    /* Check for no-op */
-   if (num == llvmpipe->num_samplers &&
-       !memcmp(llvmpipe->sampler, sampler, num * sizeof(void *)))
+   if (num == llvmpipe->num_samplers[PIPE_SHADER_FRAGMENT] &&
+       !memcmp(llvmpipe->samplers[PIPE_SHADER_FRAGMENT], sampler, num * sizeof(void *)))
       return;
 
    draw_flush(llvmpipe->draw);
 
    for (i = 0; i < num; ++i)
-      llvmpipe->sampler[i] = sampler[i];
+      llvmpipe->samplers[PIPE_SHADER_FRAGMENT][i] = sampler[i];
    for (i = num; i < PIPE_MAX_SAMPLERS; ++i)
-      llvmpipe->sampler[i] = NULL;
+      llvmpipe->samplers[PIPE_SHADER_FRAGMENT][i] = NULL;
 
-   llvmpipe->num_samplers = num;
+   llvmpipe->num_samplers[PIPE_SHADER_FRAGMENT] = num;
 
    llvmpipe->dirty |= LP_NEW_SAMPLER;
 }
@@ -102,22 +102,22 @@ llvmpipe_bind_vertex_sampler_states(struct pipe_context *pipe,
    assert(num_samplers <= PIPE_MAX_VERTEX_SAMPLERS);
 
    /* Check for no-op */
-   if (num_samplers == llvmpipe->num_vertex_samplers &&
-       !memcmp(llvmpipe->vertex_samplers, samplers, num_samplers * sizeof(void *)))
+   if (num_samplers == llvmpipe->num_samplers[PIPE_SHADER_VERTEX] &&
+       !memcmp(llvmpipe->samplers[PIPE_SHADER_VERTEX], samplers, num_samplers * sizeof(void *)))
       return;
 
    draw_flush(llvmpipe->draw);
 
    for (i = 0; i < num_samplers; ++i)
-      llvmpipe->vertex_samplers[i] = samplers[i];
+      llvmpipe->samplers[PIPE_SHADER_VERTEX][i] = samplers[i];
    for (i = num_samplers; i < PIPE_MAX_VERTEX_SAMPLERS; ++i)
-      llvmpipe->vertex_samplers[i] = NULL;
+      llvmpipe->samplers[PIPE_SHADER_VERTEX][i] = NULL;
 
-   llvmpipe->num_vertex_samplers = num_samplers;
+   llvmpipe->num_samplers[PIPE_SHADER_VERTEX] = num_samplers;
 
    draw_set_samplers(llvmpipe->draw,
-                     llvmpipe->vertex_samplers,
-                     llvmpipe->num_vertex_samplers);
+                     llvmpipe->samplers[PIPE_SHADER_VERTEX],
+                     llvmpipe->num_samplers[PIPE_SHADER_VERTEX]);
 
    llvmpipe->dirty |= LP_NEW_SAMPLER;
 }
@@ -141,8 +141,8 @@ llvmpipe_set_fragment_sampler_views(struct pipe_context *pipe,
    assert(num <= PIPE_MAX_SAMPLERS);
 
    /* Check for no-op */
-   if (num == llvmpipe->num_fragment_sampler_views &&
-       !memcmp(llvmpipe->fragment_sampler_views, views, num * sizeof(struct pipe_sampler_view *)))
+   if (num == llvmpipe->num_sampler_views[PIPE_SHADER_FRAGMENT] &&
+       !memcmp(llvmpipe->sampler_views[PIPE_SHADER_FRAGMENT], views, num * sizeof(struct pipe_sampler_view *)))
       return;
 
    draw_flush(llvmpipe->draw);
@@ -150,10 +150,10 @@ llvmpipe_set_fragment_sampler_views(struct pipe_context *pipe,
    for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
       struct pipe_sampler_view *view = i < num ? views[i] : NULL;
 
-      pipe_sampler_view_reference(&llvmpipe->fragment_sampler_views[i], view);
+      pipe_sampler_view_reference(&llvmpipe->sampler_views[PIPE_SHADER_FRAGMENT][i], view);
    }
 
-   llvmpipe->num_fragment_sampler_views = num;
+   llvmpipe->num_sampler_views[PIPE_SHADER_FRAGMENT] = num;
 
    llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW;
 }
@@ -170,8 +170,8 @@ llvmpipe_set_vertex_sampler_views(struct pipe_context *pipe,
    assert(num <= PIPE_MAX_VERTEX_SAMPLERS);
 
    /* Check for no-op */
-   if (num == llvmpipe->num_vertex_sampler_views &&
-       !memcmp(llvmpipe->vertex_sampler_views, views, num * sizeof(struct pipe_sampler_view *))) {
+   if (num == llvmpipe->num_sampler_views[PIPE_SHADER_VERTEX] &&
+       !memcmp(llvmpipe->sampler_views[PIPE_SHADER_VERTEX], views, num * sizeof(struct pipe_sampler_view *))) {
       return;
    }
 
@@ -180,14 +180,14 @@ llvmpipe_set_vertex_sampler_views(struct pipe_context *pipe,
    for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) {
       struct pipe_sampler_view *view = i < num ? views[i] : NULL;
 
-      pipe_sampler_view_reference(&llvmpipe->vertex_sampler_views[i], view);
+      pipe_sampler_view_reference(&llvmpipe->sampler_views[PIPE_SHADER_VERTEX][i], view);
    }
 
-   llvmpipe->num_vertex_sampler_views = num;
+   llvmpipe->num_sampler_views[PIPE_SHADER_VERTEX] = num;
 
    draw_set_sampler_views(llvmpipe->draw,
-                          llvmpipe->vertex_sampler_views,
-                          llvmpipe->num_vertex_sampler_views);
+                          llvmpipe->sampler_views[PIPE_SHADER_VERTEX],
+                          llvmpipe->num_sampler_views[PIPE_SHADER_VERTEX]);
 
    llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW;
 }