[Mesa-dev] [PATCH 7/7] cso: make most of the cso_save/restore_x() functions static

Brian Paul brianp at vmware.com
Fri Feb 12 15:44:36 UTC 2016


Users of the CSO save/restore facility all use the new
cso_save/restore_state() functions instead.
---
 src/gallium/auxiliary/cso_cache/cso_context.c | 108 +++++++++++++++++---------
 src/gallium/auxiliary/cso_cache/cso_context.h |  47 -----------
 2 files changed, 70 insertions(+), 85 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index cbddb06..37a214d 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -427,13 +427,15 @@ enum pipe_error cso_set_blend(struct cso_context *ctx,
    return PIPE_OK;
 }
 
-void cso_save_blend(struct cso_context *ctx)
+static void
+cso_save_blend(struct cso_context *ctx)
 {
    assert(!ctx->blend_saved);
    ctx->blend_saved = ctx->blend;
 }
 
-void cso_restore_blend(struct cso_context *ctx)
+static void
+cso_restore_blend(struct cso_context *ctx)
 {
    if (ctx->blend != ctx->blend_saved) {
       ctx->blend = ctx->blend_saved;
@@ -490,13 +492,15 @@ cso_set_depth_stencil_alpha(struct cso_context *ctx,
    return PIPE_OK;
 }
 
-void cso_save_depth_stencil_alpha(struct cso_context *ctx)
+static void
+cso_save_depth_stencil_alpha(struct cso_context *ctx)
 {
    assert(!ctx->depth_stencil_saved);
    ctx->depth_stencil_saved = ctx->depth_stencil;
 }
 
-void cso_restore_depth_stencil_alpha(struct cso_context *ctx)
+static void
+cso_restore_depth_stencil_alpha(struct cso_context *ctx)
 {
    if (ctx->depth_stencil != ctx->depth_stencil_saved) {
       ctx->depth_stencil = ctx->depth_stencil_saved;
@@ -549,13 +553,15 @@ enum pipe_error cso_set_rasterizer(struct cso_context *ctx,
    return PIPE_OK;
 }
 
-void cso_save_rasterizer(struct cso_context *ctx)
+static void
+cso_save_rasterizer(struct cso_context *ctx)
 {
    assert(!ctx->rasterizer_saved);
    ctx->rasterizer_saved = ctx->rasterizer;
 }
 
-void cso_restore_rasterizer(struct cso_context *ctx)
+static void
+cso_restore_rasterizer(struct cso_context *ctx)
 {
    if (ctx->rasterizer != ctx->rasterizer_saved) {
       ctx->rasterizer = ctx->rasterizer_saved;
@@ -583,13 +589,15 @@ void cso_delete_fragment_shader(struct cso_context *ctx, void *handle )
    ctx->pipe->delete_fs_state(ctx->pipe, handle);
 }
 
-void cso_save_fragment_shader(struct cso_context *ctx)
+static void
+cso_save_fragment_shader(struct cso_context *ctx)
 {
    assert(!ctx->fragment_shader_saved);
    ctx->fragment_shader_saved = ctx->fragment_shader;
 }
 
-void cso_restore_fragment_shader(struct cso_context *ctx)
+static void
+cso_restore_fragment_shader(struct cso_context *ctx)
 {
    if (ctx->fragment_shader_saved != ctx->fragment_shader) {
       ctx->pipe->bind_fs_state(ctx->pipe, ctx->fragment_shader_saved);
@@ -617,13 +625,15 @@ void cso_delete_vertex_shader(struct cso_context *ctx, void *handle )
    ctx->pipe->delete_vs_state(ctx->pipe, handle);
 }
 
-void cso_save_vertex_shader(struct cso_context *ctx)
+static void
+cso_save_vertex_shader(struct cso_context *ctx)
 {
    assert(!ctx->vertex_shader_saved);
    ctx->vertex_shader_saved = ctx->vertex_shader;
 }
 
-void cso_restore_vertex_shader(struct cso_context *ctx)
+static void
+cso_restore_vertex_shader(struct cso_context *ctx)
 {
    if (ctx->vertex_shader_saved != ctx->vertex_shader) {
       ctx->pipe->bind_vs_state(ctx->pipe, ctx->vertex_shader_saved);
@@ -642,12 +652,14 @@ void cso_set_framebuffer(struct cso_context *ctx,
    }
 }
 
-void cso_save_framebuffer(struct cso_context *ctx)
+static void
+cso_save_framebuffer(struct cso_context *ctx)
 {
    util_copy_framebuffer_state(&ctx->fb_saved, &ctx->fb);
 }
 
-void cso_restore_framebuffer(struct cso_context *ctx)
+static void
+cso_restore_framebuffer(struct cso_context *ctx)
 {
    if (memcmp(&ctx->fb, &ctx->fb_saved, sizeof(ctx->fb))) {
       util_copy_framebuffer_state(&ctx->fb, &ctx->fb_saved);
@@ -684,13 +696,15 @@ cso_set_viewport_dims(struct cso_context *ctx,
    cso_set_viewport(ctx, &vp);
 }
 
-void cso_save_viewport(struct cso_context *ctx)
+static void
+cso_save_viewport(struct cso_context *ctx)
 {
    ctx->vp_saved = ctx->vp;
 }
 
 
-void cso_restore_viewport(struct cso_context *ctx)
+static void
+cso_restore_viewport(struct cso_context *ctx)
 {
    if (memcmp(&ctx->vp, &ctx->vp_saved, sizeof(ctx->vp))) {
       ctx->vp = ctx->vp_saved;
@@ -716,12 +730,14 @@ void cso_set_sample_mask(struct cso_context *ctx, unsigned sample_mask)
    }
 }
 
-void cso_save_sample_mask(struct cso_context *ctx)
+static void
+cso_save_sample_mask(struct cso_context *ctx)
 {
    ctx->sample_mask_saved = ctx->sample_mask;
 }
 
-void cso_restore_sample_mask(struct cso_context *ctx)
+static void
+cso_restore_sample_mask(struct cso_context *ctx)
 {
    cso_set_sample_mask(ctx, ctx->sample_mask_saved);
 }
@@ -734,12 +750,14 @@ void cso_set_min_samples(struct cso_context *ctx, unsigned min_samples)
    }
 }
 
-void cso_save_min_samples(struct cso_context *ctx)
+static void
+cso_save_min_samples(struct cso_context *ctx)
 {
    ctx->min_samples_saved = ctx->min_samples;
 }
 
-void cso_restore_min_samples(struct cso_context *ctx)
+static void
+cso_restore_min_samples(struct cso_context *ctx)
 {
    cso_set_min_samples(ctx, ctx->min_samples_saved);
 }
@@ -753,13 +771,15 @@ void cso_set_stencil_ref(struct cso_context *ctx,
    }
 }
 
-void cso_save_stencil_ref(struct cso_context *ctx)
+static void
+cso_save_stencil_ref(struct cso_context *ctx)
 {
    ctx->stencil_ref_saved = ctx->stencil_ref;
 }
 
 
-void cso_restore_stencil_ref(struct cso_context *ctx)
+static void
+cso_restore_stencil_ref(struct cso_context *ctx)
 {
    if (memcmp(&ctx->stencil_ref, &ctx->stencil_ref_saved,
               sizeof(ctx->stencil_ref))) {
@@ -784,14 +804,16 @@ void cso_set_render_condition(struct cso_context *ctx,
    }
 }
 
-void cso_save_render_condition(struct cso_context *ctx)
+static void
+cso_save_render_condition(struct cso_context *ctx)
 {
    ctx->render_condition_saved = ctx->render_condition;
    ctx->render_condition_cond_saved = ctx->render_condition_cond;
    ctx->render_condition_mode_saved = ctx->render_condition_mode;
 }
 
-void cso_restore_render_condition(struct cso_context *ctx)
+static void
+cso_restore_render_condition(struct cso_context *ctx)
 {
    cso_set_render_condition(ctx, ctx->render_condition_saved,
                             ctx->render_condition_cond_saved,
@@ -818,7 +840,8 @@ void cso_delete_geometry_shader(struct cso_context *ctx, void *handle)
    ctx->pipe->delete_gs_state(ctx->pipe, handle);
 }
 
-void cso_save_geometry_shader(struct cso_context *ctx)
+static void
+cso_save_geometry_shader(struct cso_context *ctx)
 {
    if (!ctx->has_geometry_shader) {
       return;
@@ -828,7 +851,8 @@ void cso_save_geometry_shader(struct cso_context *ctx)
    ctx->geometry_shader_saved = ctx->geometry_shader;
 }
 
-void cso_restore_geometry_shader(struct cso_context *ctx)
+static void
+cso_restore_geometry_shader(struct cso_context *ctx)
 {
    if (!ctx->has_geometry_shader) {
       return;
@@ -861,7 +885,8 @@ void cso_delete_tessctrl_shader(struct cso_context *ctx, void *handle)
    ctx->pipe->delete_tcs_state(ctx->pipe, handle);
 }
 
-void cso_save_tessctrl_shader(struct cso_context *ctx)
+static void
+cso_save_tessctrl_shader(struct cso_context *ctx)
 {
    if (!ctx->has_tessellation) {
       return;
@@ -871,7 +896,8 @@ void cso_save_tessctrl_shader(struct cso_context *ctx)
    ctx->tessctrl_shader_saved = ctx->tessctrl_shader;
 }
 
-void cso_restore_tessctrl_shader(struct cso_context *ctx)
+static void
+cso_restore_tessctrl_shader(struct cso_context *ctx)
 {
    if (!ctx->has_tessellation) {
       return;
@@ -904,7 +930,8 @@ void cso_delete_tesseval_shader(struct cso_context *ctx, void *handle)
    ctx->pipe->delete_tes_state(ctx->pipe, handle);
 }
 
-void cso_save_tesseval_shader(struct cso_context *ctx)
+static void
+cso_save_tesseval_shader(struct cso_context *ctx)
 {
    if (!ctx->has_tessellation) {
       return;
@@ -914,7 +941,8 @@ void cso_save_tesseval_shader(struct cso_context *ctx)
    ctx->tesseval_shader_saved = ctx->tesseval_shader;
 }
 
-void cso_restore_tesseval_shader(struct cso_context *ctx)
+static void
+cso_restore_tesseval_shader(struct cso_context *ctx)
 {
    if (!ctx->has_tessellation) {
       return;
@@ -987,7 +1015,8 @@ cso_set_vertex_elements(struct cso_context *ctx,
    return PIPE_OK;
 }
 
-void cso_save_vertex_elements(struct cso_context *ctx)
+static void
+cso_save_vertex_elements(struct cso_context *ctx)
 {
    struct u_vbuf *vbuf = ctx->vbuf;
 
@@ -1000,7 +1029,8 @@ void cso_save_vertex_elements(struct cso_context *ctx)
    ctx->velements_saved = ctx->velements;
 }
 
-void cso_restore_vertex_elements(struct cso_context *ctx)
+static void
+cso_restore_vertex_elements(struct cso_context *ctx)
 {
    struct u_vbuf *vbuf = ctx->vbuf;
 
@@ -1052,7 +1082,8 @@ void cso_set_vertex_buffers(struct cso_context *ctx,
    ctx->pipe->set_vertex_buffers(ctx->pipe, start_slot, count, buffers);
 }
 
-void cso_save_aux_vertex_buffer_slot(struct cso_context *ctx)
+static void
+cso_save_aux_vertex_buffer_slot(struct cso_context *ctx)
 {
    struct u_vbuf *vbuf = ctx->vbuf;
 
@@ -1067,7 +1098,8 @@ void cso_save_aux_vertex_buffer_slot(struct cso_context *ctx)
           sizeof(struct pipe_vertex_buffer));
 }
 
-void cso_restore_aux_vertex_buffer_slot(struct cso_context *ctx)
+static void
+cso_restore_aux_vertex_buffer_slot(struct cso_context *ctx)
 {
    struct u_vbuf *vbuf = ctx->vbuf;
 
@@ -1185,7 +1217,7 @@ cso_set_samplers(struct cso_context *ctx,
    return error;
 }
 
-void
+static void
 cso_save_fragment_samplers(struct cso_context *ctx)
 {
    struct sampler_info *info = &ctx->samplers[PIPE_SHADER_FRAGMENT];
@@ -1196,7 +1228,7 @@ cso_save_fragment_samplers(struct cso_context *ctx)
 }
 
 
-void
+static void
 cso_restore_fragment_samplers(struct cso_context *ctx)
 {
    struct sampler_info *info = &ctx->samplers[PIPE_SHADER_FRAGMENT];
@@ -1243,7 +1275,7 @@ cso_set_sampler_views(struct cso_context *ctx,
 }
 
 
-void
+static void
 cso_save_fragment_sampler_views(struct cso_context *ctx)
 {
    unsigned i;
@@ -1258,7 +1290,7 @@ cso_save_fragment_sampler_views(struct cso_context *ctx)
 }
 
 
-void
+static void
 cso_restore_fragment_sampler_views(struct cso_context *ctx)
 {
    unsigned i, nr_saved = ctx->nr_fragment_views_saved;
@@ -1318,7 +1350,7 @@ cso_set_stream_outputs(struct cso_context *ctx,
    ctx->nr_so_targets = num_targets;
 }
 
-void
+static void
 cso_save_stream_outputs(struct cso_context *ctx)
 {
    uint i;
@@ -1335,7 +1367,7 @@ cso_save_stream_outputs(struct cso_context *ctx)
    }
 }
 
-void
+static void
 cso_restore_stream_outputs(struct cso_context *ctx)
 {
    struct pipe_context *pipe = ctx->pipe;
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h
index fa6fb18..a7f9dd9 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -47,22 +47,15 @@ void cso_destroy_context( struct cso_context *cso );
 
 enum pipe_error cso_set_blend( struct cso_context *cso,
                                const struct pipe_blend_state *blend );
-void cso_save_blend(struct cso_context *cso);
-void cso_restore_blend(struct cso_context *cso);
-
 
 
 enum pipe_error cso_set_depth_stencil_alpha( struct cso_context *cso,
                                              const struct pipe_depth_stencil_alpha_state *dsa );
-void cso_save_depth_stencil_alpha(struct cso_context *cso);
-void cso_restore_depth_stencil_alpha(struct cso_context *cso);
 
 
 
 enum pipe_error cso_set_rasterizer( struct cso_context *cso,
                                     const struct pipe_rasterizer_state *rasterizer );
-void cso_save_rasterizer(struct cso_context *cso);
-void cso_restore_rasterizer(struct cso_context *cso);
 
 
 enum pipe_error
@@ -71,11 +64,6 @@ cso_set_samplers(struct cso_context *cso,
                  unsigned count,
                  const struct pipe_sampler_state **states);
 
-void
-cso_save_fragment_samplers(struct cso_context *cso);
-
-void
-cso_restore_fragment_samplers(struct cso_context *cso);
 
 /* Alternate interface to support state trackers that like to modify
  * samplers one at a time:
@@ -91,9 +79,6 @@ cso_single_sampler_done(struct cso_context *cso, unsigned shader_stage);
 enum pipe_error cso_set_vertex_elements(struct cso_context *ctx,
                                         unsigned count,
                                         const struct pipe_vertex_element *states);
-void cso_save_vertex_elements(struct cso_context *ctx);
-void cso_restore_vertex_elements(struct cso_context *ctx);
-
 
 void cso_set_vertex_buffers(struct cso_context *ctx,
                             unsigned start_slot, unsigned count,
@@ -101,8 +86,6 @@ void cso_set_vertex_buffers(struct cso_context *ctx,
 
 /* One vertex buffer slot is provided with the save/restore functionality.
  * cso_context chooses the slot, it can be non-zero. */
-void cso_save_aux_vertex_buffer_slot(struct cso_context *ctx);
-void cso_restore_aux_vertex_buffer_slot(struct cso_context *ctx);
 unsigned cso_get_aux_vertex_buffer_slot(struct cso_context *ctx);
 
 
@@ -110,8 +93,6 @@ void cso_set_stream_outputs(struct cso_context *ctx,
                             unsigned num_targets,
                             struct pipe_stream_output_target **targets,
                             const unsigned *offsets);
-void cso_save_stream_outputs(struct cso_context *ctx);
-void cso_restore_stream_outputs(struct cso_context *ctx);
 
 
 /*
@@ -123,69 +104,47 @@ void cso_restore_stream_outputs(struct cso_context *ctx);
 
 void cso_set_fragment_shader_handle(struct cso_context *ctx, void *handle);
 void cso_delete_fragment_shader(struct cso_context *ctx, void *handle );
-void cso_save_fragment_shader(struct cso_context *cso);
-void cso_restore_fragment_shader(struct cso_context *cso);
 
 
 void cso_set_vertex_shader_handle(struct cso_context *ctx, void *handle);
 void cso_delete_vertex_shader(struct cso_context *ctx, void *handle );
-void cso_save_vertex_shader(struct cso_context *cso);
-void cso_restore_vertex_shader(struct cso_context *cso);
 
 
 void cso_set_geometry_shader_handle(struct cso_context *ctx, void *handle);
 void cso_delete_geometry_shader(struct cso_context *ctx, void *handle);
-void cso_save_geometry_shader(struct cso_context *cso);
-void cso_restore_geometry_shader(struct cso_context *cso);
 
 
 void cso_set_tessctrl_shader_handle(struct cso_context *ctx, void *handle);
 void cso_delete_tessctrl_shader(struct cso_context *ctx, void *handle);
-void cso_save_tessctrl_shader(struct cso_context *cso);
-void cso_restore_tessctrl_shader(struct cso_context *cso);
 
 
 void cso_set_tesseval_shader_handle(struct cso_context *ctx, void *handle);
 void cso_delete_tesseval_shader(struct cso_context *ctx, void *handle);
-void cso_save_tesseval_shader(struct cso_context *cso);
-void cso_restore_tesseval_shader(struct cso_context *cso);
 
 
 void cso_set_framebuffer(struct cso_context *cso,
                          const struct pipe_framebuffer_state *fb);
-void cso_save_framebuffer(struct cso_context *cso);
-void cso_restore_framebuffer(struct cso_context *cso);
 
 
 void cso_set_viewport(struct cso_context *cso,
                       const struct pipe_viewport_state *vp);
 void cso_set_viewport_dims(struct cso_context *ctx,
                            float width, float height, boolean invert);
-void cso_save_viewport(struct cso_context *cso);
-void cso_restore_viewport(struct cso_context *cso);
 
 
 void cso_set_blend_color(struct cso_context *cso,
                          const struct pipe_blend_color *bc);
 
 void cso_set_sample_mask(struct cso_context *cso, unsigned stencil_mask);
-void cso_save_sample_mask(struct cso_context *ctx);
-void cso_restore_sample_mask(struct cso_context *ctx);
 
 void cso_set_min_samples(struct cso_context *cso, unsigned min_samples);
-void cso_save_min_samples(struct cso_context *ctx);
-void cso_restore_min_samples(struct cso_context *ctx);
 
 void cso_set_stencil_ref(struct cso_context *cso,
                          const struct pipe_stencil_ref *sr);
-void cso_save_stencil_ref(struct cso_context *cso);
-void cso_restore_stencil_ref(struct cso_context *cso);
 
 void cso_set_render_condition(struct cso_context *cso,
                               struct pipe_query *query,
                               boolean condition, uint mode);
-void cso_save_render_condition(struct cso_context *cso);
-void cso_restore_render_condition(struct cso_context *cso);
 
 
 #define CSO_BIT_AUX_VERTEX_BUFFER_SLOT    0x1
@@ -220,12 +179,6 @@ cso_set_sampler_views(struct cso_context *cso,
                       unsigned count,
                       struct pipe_sampler_view **views);
 
-void
-cso_save_fragment_sampler_views(struct cso_context *ctx);
-
-void
-cso_restore_fragment_sampler_views(struct cso_context *ctx);
-
 
 /* constant buffers */
 
-- 
1.9.1



More information about the mesa-dev mailing list