Commit d1ee2b37 authored by Marek Olšák's avatar Marek Olšák

st/mesa: remove struct st_tracked_state

It contains only one member: the update function. Let's use the update
function directly.
Tested-by: Edmondo Tommasina's avatarEdmondo Tommasina <edmondo.tommasina@gmail.com>
Reviewed-by: Brian Paul's avatarBrian Paul <brianp@vmware.com>
Reviewed-by: default avatarNicolai Hähnle <nicolai.haehnle@amd.com>
parent cb2ac696
......@@ -36,11 +36,12 @@
#include "st_program.h"
#include "st_manager.h"
typedef void (*update_func_t)(struct st_context *st);
/* The list state update functions. */
static const struct st_tracked_state *atoms[] =
static const update_func_t update_functions[] =
{
#define ST_STATE(FLAG, st_update) &st_update,
#define ST_STATE(FLAG, st_update) st_update,
#include "st_atom_list.h"
#undef ST_STATE
};
......@@ -48,7 +49,7 @@ static const struct st_tracked_state *atoms[] =
void st_init_atoms( struct st_context *st )
{
STATIC_ASSERT(ARRAY_SIZE(atoms) <= 64);
STATIC_ASSERT(ARRAY_SIZE(update_functions) <= 64);
}
......@@ -226,9 +227,9 @@ void st_validate_state( struct st_context *st, enum st_pipeline pipeline )
* Don't use u_bit_scan64, it may be slower on 32-bit.
*/
while (dirty_lo)
atoms[u_bit_scan(&dirty_lo)]->update(st);
update_functions[u_bit_scan(&dirty_lo)](st);
while (dirty_hi)
atoms[32 + u_bit_scan(&dirty_hi)]->update(st);
update_functions[32 + u_bit_scan(&dirty_hi)](st);
/* Clear the render or compute state bits. */
st->dirty &= ~pipeline_mask;
......
......@@ -48,11 +48,6 @@ enum st_pipeline {
ST_PIPELINE_COMPUTE,
};
struct st_tracked_state {
void (*update)( struct st_context *st );
};
void st_init_atoms( struct st_context *st );
void st_destroy_atoms( struct st_context *st );
void st_validate_state( struct st_context *st, enum st_pipeline pipeline );
......@@ -77,8 +72,8 @@ enum {
#include "st_atom_list.h"
#undef ST_STATE
/* Add extern struct declarations. */
#define ST_STATE(FLAG, st_update) extern const struct st_tracked_state st_update;
/* Declare function prototypes. */
#define ST_STATE(FLAG, st_update) void st_update(struct st_context *st);
#include "st_atom_list.h"
#undef ST_STATE
......
......@@ -626,7 +626,7 @@ setup_non_interleaved_attribs(struct st_context *st,
return TRUE;
}
static void update_array(struct st_context *st)
void st_update_array(struct st_context *st)
{
struct gl_context *ctx = st->ctx;
const struct gl_vertex_array **arrays = ctx->Array._DrawArrays;
......@@ -678,8 +678,3 @@ static void update_array(struct st_context *st)
st->last_num_vbuffers = num_vbuffers;
cso_set_vertex_elements(st->cso_context, vpv->num_inputs, velements);
}
const struct st_tracked_state st_update_array = {
update_array /* update */
};
......@@ -69,8 +69,8 @@ st_bind_atomics(struct st_context *st, struct gl_program *prog,
}
}
static void
bind_vs_atomics(struct st_context *st)
void
st_bind_vs_atomics(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
......@@ -78,12 +78,8 @@ bind_vs_atomics(struct st_context *st)
st_bind_atomics(st, prog, PIPE_SHADER_VERTEX);
}
const struct st_tracked_state st_bind_vs_atomics = {
bind_vs_atomics
};
static void
bind_fs_atomics(struct st_context *st)
void
st_bind_fs_atomics(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT];
......@@ -91,12 +87,8 @@ bind_fs_atomics(struct st_context *st)
st_bind_atomics(st, prog, PIPE_SHADER_FRAGMENT);
}
const struct st_tracked_state st_bind_fs_atomics = {
bind_fs_atomics
};
static void
bind_gs_atomics(struct st_context *st)
void
st_bind_gs_atomics(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
......@@ -104,12 +96,8 @@ bind_gs_atomics(struct st_context *st)
st_bind_atomics(st, prog, PIPE_SHADER_GEOMETRY);
}
const struct st_tracked_state st_bind_gs_atomics = {
bind_gs_atomics
};
static void
bind_tcs_atomics(struct st_context *st)
void
st_bind_tcs_atomics(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL];
......@@ -117,12 +105,8 @@ bind_tcs_atomics(struct st_context *st)
st_bind_atomics(st, prog, PIPE_SHADER_TESS_CTRL);
}
const struct st_tracked_state st_bind_tcs_atomics = {
bind_tcs_atomics
};
static void
bind_tes_atomics(struct st_context *st)
void
st_bind_tes_atomics(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
......@@ -130,19 +114,11 @@ bind_tes_atomics(struct st_context *st)
st_bind_atomics(st, prog, PIPE_SHADER_TESS_EVAL);
}
const struct st_tracked_state st_bind_tes_atomics = {
bind_tes_atomics
};
static void
bind_cs_atomics(struct st_context *st)
void
st_bind_cs_atomics(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
st_bind_atomics(st, prog, PIPE_SHADER_COMPUTE);
}
const struct st_tracked_state st_bind_cs_atomics = {
bind_cs_atomics
};
......@@ -186,8 +186,8 @@ blend_per_rt(const struct gl_context *ctx)
return GL_FALSE;
}
static void
update_blend( struct st_context *st )
void
st_update_blend( struct st_context *st )
{
struct pipe_blend_state *blend = &st->state.blend;
const struct gl_context *ctx = st->ctx;
......@@ -283,8 +283,3 @@ update_blend( struct st_context *st )
cso_set_blend_color(st->cso_context, &bc);
}
}
const struct st_tracked_state st_update_blend = {
update_blend, /* update */
};
......@@ -41,7 +41,7 @@
/* Second state atom for user clip planes:
*/
static void update_clip( struct st_context *st )
void st_update_clip( struct st_context *st )
{
struct pipe_clip_state clip;
const struct gl_context *ctx = st->ctx;
......@@ -66,8 +66,3 @@ static void update_clip( struct st_context *st )
st->pipe->set_clip_state(st->pipe, &clip);
}
}
const struct st_tracked_state st_update_clip = {
update_clip /* update */
};
......@@ -139,7 +139,7 @@ void st_upload_constants( struct st_context *st,
/**
* Vertex shader:
*/
static void update_vs_constants(struct st_context *st )
void st_update_vs_constants(struct st_context *st )
{
struct st_vertex_program *vp = st->vp;
struct gl_program_parameter_list *params = vp->Base.Parameters;
......@@ -147,17 +147,10 @@ static void update_vs_constants(struct st_context *st )
st_upload_constants( st, params, MESA_SHADER_VERTEX );
}
const struct st_tracked_state st_update_vs_constants = {
update_vs_constants /* update */
};
/**
* Fragment shader:
*/
static void update_fs_constants(struct st_context *st )
void st_update_fs_constants(struct st_context *st )
{
struct st_fragment_program *fp = st->fp;
struct gl_program_parameter_list *params = fp->Base.Parameters;
......@@ -166,13 +159,9 @@ static void update_fs_constants(struct st_context *st )
}
const struct st_tracked_state st_update_fs_constants = {
update_fs_constants /* update */
};
/* Geometry shader:
*/
static void update_gs_constants(struct st_context *st )
void st_update_gs_constants(struct st_context *st )
{
struct st_geometry_program *gp = st->gp;
struct gl_program_parameter_list *params;
......@@ -183,13 +172,9 @@ static void update_gs_constants(struct st_context *st )
}
}
const struct st_tracked_state st_update_gs_constants = {
update_gs_constants /* update */
};
/* Tessellation control shader:
*/
static void update_tcs_constants(struct st_context *st )
void st_update_tcs_constants(struct st_context *st )
{
struct st_tessctrl_program *tcp = st->tcp;
struct gl_program_parameter_list *params;
......@@ -200,13 +185,9 @@ static void update_tcs_constants(struct st_context *st )
}
}
const struct st_tracked_state st_update_tcs_constants = {
update_tcs_constants /* update */
};
/* Tessellation evaluation shader:
*/
static void update_tes_constants(struct st_context *st )
void st_update_tes_constants(struct st_context *st )
{
struct st_tesseval_program *tep = st->tep;
struct gl_program_parameter_list *params;
......@@ -217,13 +198,9 @@ static void update_tes_constants(struct st_context *st )
}
}
const struct st_tracked_state st_update_tes_constants = {
update_tes_constants /* update */
};
/* Compute shader:
*/
static void update_cs_constants(struct st_context *st )
void st_update_cs_constants(struct st_context *st )
{
struct st_compute_program *cp = st->cp;
struct gl_program_parameter_list *params;
......@@ -234,10 +211,6 @@ static void update_cs_constants(struct st_context *st )
}
}
const struct st_tracked_state st_update_cs_constants = {
update_cs_constants /* update */
};
static void st_bind_ubos(struct st_context *st, struct gl_program *prog,
unsigned shader_type)
{
......@@ -276,7 +249,7 @@ static void st_bind_ubos(struct st_context *st, struct gl_program *prog,
}
}
static void bind_vs_ubos(struct st_context *st)
void st_bind_vs_ubos(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
......@@ -284,11 +257,7 @@ static void bind_vs_ubos(struct st_context *st)
st_bind_ubos(st, prog, PIPE_SHADER_VERTEX);
}
const struct st_tracked_state st_bind_vs_ubos = {
bind_vs_ubos
};
static void bind_fs_ubos(struct st_context *st)
void st_bind_fs_ubos(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT];
......@@ -296,11 +265,7 @@ static void bind_fs_ubos(struct st_context *st)
st_bind_ubos(st, prog, PIPE_SHADER_FRAGMENT);
}
const struct st_tracked_state st_bind_fs_ubos = {
bind_fs_ubos
};
static void bind_gs_ubos(struct st_context *st)
void st_bind_gs_ubos(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
......@@ -308,11 +273,7 @@ static void bind_gs_ubos(struct st_context *st)
st_bind_ubos(st, prog, PIPE_SHADER_GEOMETRY);
}
const struct st_tracked_state st_bind_gs_ubos = {
bind_gs_ubos
};
static void bind_tcs_ubos(struct st_context *st)
void st_bind_tcs_ubos(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL];
......@@ -320,11 +281,7 @@ static void bind_tcs_ubos(struct st_context *st)
st_bind_ubos(st, prog, PIPE_SHADER_TESS_CTRL);
}
const struct st_tracked_state st_bind_tcs_ubos = {
bind_tcs_ubos
};
static void bind_tes_ubos(struct st_context *st)
void st_bind_tes_ubos(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
......@@ -332,18 +289,10 @@ static void bind_tes_ubos(struct st_context *st)
st_bind_ubos(st, prog, PIPE_SHADER_TESS_EVAL);
}
const struct st_tracked_state st_bind_tes_ubos = {
bind_tes_ubos
};
static void bind_cs_ubos(struct st_context *st)
void st_bind_cs_ubos(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
st_bind_ubos(st, prog, PIPE_SHADER_COMPUTE);
}
const struct st_tracked_state st_bind_cs_ubos = {
bind_cs_ubos
};
......@@ -95,8 +95,8 @@ gl_stencil_op_to_pipe(GLenum func)
}
}
static void
update_depth_stencil_alpha(struct st_context *st)
void
st_update_depth_stencil_alpha(struct st_context *st)
{
struct pipe_depth_stencil_alpha_state *dsa = &st->state.depth_stencil;
struct pipe_stencil_ref sr;
......@@ -159,8 +159,3 @@ update_depth_stencil_alpha(struct st_context *st)
cso_set_depth_stencil_alpha(st->cso_context, dsa);
cso_set_stencil_ref(st->cso_context, &sr);
}
const struct st_tracked_state st_update_depth_stencil_alpha = {
update_depth_stencil_alpha /* update */
};
......@@ -104,8 +104,8 @@ framebuffer_quantize_num_samples(struct st_context *st, unsigned num_samples)
/**
* Update framebuffer state (color, depth, stencil, etc. buffers)
*/
static void
update_framebuffer_state( struct st_context *st )
void
st_update_framebuffer_state( struct st_context *st )
{
struct pipe_framebuffer_state *framebuffer = &st->state.framebuffer;
struct gl_framebuffer *fb = st->ctx->DrawBuffer;
......@@ -212,9 +212,3 @@ update_framebuffer_state( struct st_context *st )
cso_set_framebuffer(st->cso_context, framebuffer);
}
const struct st_tracked_state st_update_framebuffer = {
update_framebuffer_state /* update */
};
......@@ -139,7 +139,7 @@ st_bind_images(struct st_context *st, struct gl_program *prog,
c->MaxImageUniforms - prog->info.num_images, NULL);
}
static void bind_vs_images(struct st_context *st)
void st_bind_vs_images(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
......@@ -147,11 +147,7 @@ static void bind_vs_images(struct st_context *st)
st_bind_images(st, prog, PIPE_SHADER_VERTEX);
}
const struct st_tracked_state st_bind_vs_images = {
bind_vs_images
};
static void bind_fs_images(struct st_context *st)
void st_bind_fs_images(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT];
......@@ -159,11 +155,7 @@ static void bind_fs_images(struct st_context *st)
st_bind_images(st, prog, PIPE_SHADER_FRAGMENT);
}
const struct st_tracked_state st_bind_fs_images = {
bind_fs_images
};
static void bind_gs_images(struct st_context *st)
void st_bind_gs_images(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
......@@ -171,11 +163,7 @@ static void bind_gs_images(struct st_context *st)
st_bind_images(st, prog, PIPE_SHADER_GEOMETRY);
}
const struct st_tracked_state st_bind_gs_images = {
bind_gs_images
};
static void bind_tcs_images(struct st_context *st)
void st_bind_tcs_images(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_CTRL];
......@@ -183,11 +171,7 @@ static void bind_tcs_images(struct st_context *st)
st_bind_images(st, prog, PIPE_SHADER_TESS_CTRL);
}
const struct st_tracked_state st_bind_tcs_images = {
bind_tcs_images
};
static void bind_tes_images(struct st_context *st)
void st_bind_tes_images(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
......@@ -195,18 +179,10 @@ static void bind_tes_images(struct st_context *st)
st_bind_images(st, prog, PIPE_SHADER_TESS_EVAL);
}
const struct st_tracked_state st_bind_tes_images = {
bind_tes_images
};
static void bind_cs_images(struct st_context *st)
void st_bind_cs_images(struct st_context *st)
{
struct gl_program *prog =
st->ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
st_bind_images(st, prog, PIPE_SHADER_COMPUTE);
}
const struct st_tracked_state st_bind_cs_images = {
bind_cs_images
};
......@@ -15,18 +15,18 @@ ST_STATE(ST_NEW_SCISSOR, st_update_scissor)
ST_STATE(ST_NEW_WINDOW_RECTANGLES, st_update_window_rectangles)
ST_STATE(ST_NEW_BLEND, st_update_blend)
ST_STATE(ST_NEW_VS_SAMPLER_VIEWS, st_update_vertex_texture)
ST_STATE(ST_NEW_FS_SAMPLER_VIEWS, st_update_fragment_texture)
ST_STATE(ST_NEW_GS_SAMPLER_VIEWS, st_update_geometry_texture)
ST_STATE(ST_NEW_TCS_SAMPLER_VIEWS, st_update_tessctrl_texture)
ST_STATE(ST_NEW_TES_SAMPLER_VIEWS, st_update_tesseval_texture)
ST_STATE(ST_NEW_VS_SAMPLER_VIEWS, st_update_vertex_textures)
ST_STATE(ST_NEW_FS_SAMPLER_VIEWS, st_update_fragment_textures)
ST_STATE(ST_NEW_GS_SAMPLER_VIEWS, st_update_geometry_textures)
ST_STATE(ST_NEW_TCS_SAMPLER_VIEWS, st_update_tessctrl_textures)
ST_STATE(ST_NEW_TES_SAMPLER_VIEWS, st_update_tesseval_textures)
/* Non-compute samplers. */
ST_STATE(ST_NEW_VS_SAMPLERS, st_update_vertex_sampler) /* depends on update_*_texture for swizzle */
ST_STATE(ST_NEW_TCS_SAMPLERS, st_update_tessctrl_sampler) /* depends on update_*_texture for swizzle */
ST_STATE(ST_NEW_TES_SAMPLERS, st_update_tesseval_sampler) /* depends on update_*_texture for swizzle */
ST_STATE(ST_NEW_GS_SAMPLERS, st_update_geometry_sampler) /* depends on update_*_texture for swizzle */
ST_STATE(ST_NEW_FS_SAMPLERS, st_update_fragment_sampler) /* depends on update_*_texture for swizzle */
ST_STATE(ST_NEW_VS_SAMPLERS, st_update_vertex_samplers) /* depends on update_*_texture for swizzle */
ST_STATE(ST_NEW_TCS_SAMPLERS, st_update_tessctrl_samplers) /* depends on update_*_texture for swizzle */
ST_STATE(ST_NEW_TES_SAMPLERS, st_update_tesseval_samplers) /* depends on update_*_texture for swizzle */
ST_STATE(ST_NEW_GS_SAMPLERS, st_update_geometry_samplers) /* depends on update_*_texture for swizzle */
ST_STATE(ST_NEW_FS_SAMPLERS, st_update_fragment_samplers) /* depends on update_*_texture for swizzle */
ST_STATE(ST_NEW_VS_IMAGES, st_bind_vs_images)
ST_STATE(ST_NEW_TCS_IMAGES, st_bind_tcs_images)
......@@ -34,8 +34,8 @@ ST_STATE(ST_NEW_TES_IMAGES, st_bind_tes_images)
ST_STATE(ST_NEW_GS_IMAGES, st_bind_gs_images)
ST_STATE(ST_NEW_FS_IMAGES, st_bind_fs_images)
ST_STATE(ST_NEW_FB_STATE, st_update_framebuffer) /* depends on update_*_texture and bind_*_images */
ST_STATE(ST_NEW_SAMPLE_MASK, st_update_msaa)
ST_STATE(ST_NEW_FB_STATE, st_update_framebuffer_state) /* depends on update_*_texture and bind_*_images */
ST_STATE(ST_NEW_SAMPLE_MASK, st_update_sample_mask)
ST_STATE(ST_NEW_SAMPLE_SHADING, st_update_sample_shading)
ST_STATE(ST_NEW_VS_CONSTANTS, st_update_vs_constants)
......@@ -70,8 +70,8 @@ ST_STATE(ST_NEW_VERTEX_ARRAYS, st_update_array)
/* Compute states must be last. */
ST_STATE(ST_NEW_CS_STATE, st_update_cp)
ST_STATE(ST_NEW_CS_SAMPLER_VIEWS, st_update_compute_texture)
ST_STATE(ST_NEW_CS_SAMPLERS, st_update_compute_sampler) /* depends on update_compute_texture for swizzle */
ST_STATE(ST_NEW_CS_SAMPLER_VIEWS, st_update_compute_textures)
ST_STATE(ST_NEW_CS_SAMPLERS, st_update_compute_samplers) /* depends on update_compute_texture for swizzle */
ST_STATE(ST_NEW_CS_CONSTANTS, st_update_cs_constants)
ST_STATE(ST_NEW_CS_UBOS, st_bind_cs_ubos)
ST_STATE(ST_NEW_CS_ATOMICS, st_bind_cs_atomics)
......
......@@ -38,7 +38,7 @@
/* Update the sample mask for MSAA.
*/
static void update_sample_mask( struct st_context *st )
void st_update_sample_mask( struct st_context *st )
{
unsigned sample_mask = 0xffffffff;
struct pipe_framebuffer_state *framebuffer = &st->state.framebuffer;
......@@ -72,7 +72,7 @@ static void update_sample_mask( struct st_context *st )
}
}
static void update_sample_shading( struct st_context *st )
void st_update_sample_shading( struct st_context *st )
{
if (!st->fp)
return;
......@@ -84,11 +84,3 @@ static void update_sample_shading( struct st_context *st )
st->cso_context,
_mesa_get_min_invocations_per_fragment(st->ctx, &st->fp->Base, false));
}
const struct st_tracked_state st_update_msaa = {
update_sample_mask /* update */
};
const struct st_tracked_state st_update_sample_shading = {
update_sample_shading /* update */
};
......@@ -84,8 +84,8 @@ load_color_map_texture(struct gl_context *ctx, struct pipe_resource *pt)
/**
* Upload the pixel transfer color map texture.
*/
static void
update_pixel_transfer(struct st_context *st)
void
st_update_pixel_transfer(struct st_context *st)
{
struct gl_context *ctx = st->ctx;
......@@ -100,8 +100,3 @@ update_pixel_transfer(struct st_context *st)
load_color_map_texture(ctx, st->pixel_xfer.pixelmap_texture);
}
}
const struct st_tracked_state st_update_pixel_transfer = {
update_pixel_transfer /* update */
};
......@@ -60,7 +60,7 @@ static GLuint translate_fill( GLenum mode )
static void update_raster_state( struct st_context *st )
void st_update_rasterizer( struct st_context *st )
{
struct gl_context *ctx = st->ctx;
struct pipe_rasterizer_state *raster = &st->state.rasterizer;
......@@ -292,7 +292,3 @@ static void update_raster_state( struct st_context *st )
cso_set_rasterizer(st->cso_context, raster);
}
const struct st_tracked_state st_update_rasterizer = {
update_raster_state /* update function */
};
......@@ -334,8 +334,8 @@ update_shader_samplers(struct st_context *st,
}
static void
update_vertex_samplers(struct st_context *st)
void
st_update_vertex_samplers(struct st_context *st)
{
const struct gl_context *ctx = st->ctx;
......@@ -348,8 +348,8 @@ update_vertex_samplers(struct st_context *st)
}
static void
update_tessctrl_samplers(struct st_context *st)
void
st_update_tessctrl_samplers(struct st_context *st)
{
const struct gl_context *ctx = st->ctx;
......@@ -364,8 +364,8 @@ update_tessctrl_samplers(struct st_context *st)
}