cso: make most of the cso_save/restore_x() functions static

Users of the CSO save/restore facility all use the new
cso_save/restore_state() functions instead.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
This commit is contained in:
Brian Paul 2016-02-16 10:22:32 -07:00
parent 223ffd8a08
commit ffa1a1dd21
2 changed files with 70 additions and 85 deletions

View File

@ -437,13 +437,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;
@ -500,13 +502,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;
@ -559,13 +563,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;
@ -593,13 +599,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);
@ -627,13 +635,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);
@ -652,12 +662,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);
@ -694,13 +706,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;
@ -726,12 +740,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);
}
@ -744,12 +760,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);
}
@ -763,13 +781,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))) {
@ -794,14 +814,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,
@ -828,7 +850,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;
@ -838,7 +861,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;
@ -871,7 +895,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;
@ -881,7 +906,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;
@ -914,7 +940,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;
@ -924,7 +951,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;
@ -1017,7 +1045,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;
@ -1030,7 +1059,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;
@ -1082,7 +1112,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;
@ -1097,7 +1128,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;
@ -1215,7 +1247,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];
@ -1226,7 +1258,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];
@ -1273,7 +1305,7 @@ cso_set_sampler_views(struct cso_context *ctx,
}
void
static void
cso_save_fragment_sampler_views(struct cso_context *ctx)
{
unsigned i;
@ -1288,7 +1320,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;
@ -1348,7 +1380,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;
@ -1365,7 +1397,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;

View File

@ -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,32 +104,22 @@ 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_compute_shader_handle(struct cso_context *ctx, void *handle);
@ -157,39 +128,27 @@ void cso_delete_compute_shader(struct cso_context *ctx, void *handle);
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
@ -224,12 +183,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 */