st/mesa: completely rewrite state atoms

The goal is to do this in st_validate_state:
   while (dirty)
      atoms[u_bit_scan(&dirty)]->update(st);

That implies that atoms can't specify which flags they consume.
There is exactly one ST_NEW_* flag for each atom. (58 flags in total)

There are macros that combine multiple flags into one for easier use.

All _NEW_* flags are translated into ST_NEW_* flags in st_invalidate_state.
st/mesa doesn't keep the _NEW_* flags after that.

torcs is 2% faster between the previous patch and the end of this series.

v2: - add st_atom_list.h to Makefile.sources

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
This commit is contained in:
Marek Olšák
2016-07-17 18:38:38 +02:00
parent 53bc28920a
commit c8fe3b9dca
33 changed files with 383 additions and 518 deletions

View File

@@ -409,6 +409,7 @@ STATETRACKER_FILES = \
state_tracker/st_atom_depth.c \
state_tracker/st_atom_framebuffer.c \
state_tracker/st_atom.h \
state_tracker/st_atom_list.h \
state_tracker/st_atom_image.c \
state_tracker/st_atom_msaa.c \
state_tracker/st_atom_pixeltransfer.c \

View File

@@ -37,87 +37,18 @@
#include "st_manager.h"
/**
* This is used to initialize st->render_atoms[].
*/
static const struct st_tracked_state *render_atoms[] =
/* The list state update functions. */
static const struct st_tracked_state *atoms[] =
{
&st_update_depth_stencil_alpha,
&st_update_clip,
&st_update_fp,
&st_update_gp,
&st_update_tep,
&st_update_tcp,
&st_update_vp,
&st_update_rasterizer,
&st_update_polygon_stipple,
&st_update_viewport,
&st_update_scissor,
&st_update_window_rectangles,
&st_update_blend,
&st_update_vertex_texture,
&st_update_fragment_texture,
&st_update_geometry_texture,
&st_update_tessctrl_texture,
&st_update_tesseval_texture,
&st_update_sampler, /* depends on update_*_texture for swizzle */
&st_bind_vs_images,
&st_bind_tcs_images,
&st_bind_tes_images,
&st_bind_gs_images,
&st_bind_fs_images,
&st_update_framebuffer, /* depends on update_*_texture and bind_*_images */
&st_update_msaa,
&st_update_sample_shading,
&st_update_vs_constants,
&st_update_tcs_constants,
&st_update_tes_constants,
&st_update_gs_constants,
&st_update_fs_constants,
&st_bind_vs_ubos,
&st_bind_tcs_ubos,
&st_bind_tes_ubos,
&st_bind_fs_ubos,
&st_bind_gs_ubos,
&st_bind_vs_atomics,
&st_bind_tcs_atomics,
&st_bind_tes_atomics,
&st_bind_fs_atomics,
&st_bind_gs_atomics,
&st_bind_vs_ssbos,
&st_bind_tcs_ssbos,
&st_bind_tes_ssbos,
&st_bind_fs_ssbos,
&st_bind_gs_ssbos,
&st_update_pixel_transfer,
&st_update_tess,
/* this must be done after the vertex program update */
&st_update_array
};
/**
* This is used to initialize st->compute_atoms[].
*/
static const struct st_tracked_state *compute_atoms[] =
{
&st_update_cp,
&st_update_compute_texture,
&st_update_sampler, /* depends on update_compute_texture for swizzle */
&st_update_cs_constants,
&st_bind_cs_ubos,
&st_bind_cs_atomics,
&st_bind_cs_ssbos,
&st_bind_cs_images,
#define ST_STATE(FLAG, st_update) &st_update,
#include "st_atom_list.h"
#undef ST_STATE
};
void st_init_atoms( struct st_context *st )
{
/* no-op */
STATIC_ASSERT(ARRAY_SIZE(atoms) <= 64);
}
@@ -127,13 +58,6 @@ void st_destroy_atoms( struct st_context *st )
}
static bool
check_state(const struct st_state_flags *a, const struct st_state_flags *b)
{
return (a->mesa & b->mesa) || (a->st & b->st);
}
/* Too complex to figure out, just check every time:
*/
static void check_program_state( struct st_context *st )
@@ -141,13 +65,13 @@ static void check_program_state( struct st_context *st )
struct gl_context *ctx = st->ctx;
if (ctx->VertexProgram._Current != &st->vp->Base)
st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
st->dirty |= ST_NEW_VERTEX_PROGRAM;
if (ctx->FragmentProgram._Current != &st->fp->Base)
st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
st->dirty |= ST_NEW_FRAGMENT_PROGRAM;
if (ctx->GeometryProgram._Current != &st->gp->Base)
st->dirty.st |= ST_NEW_GEOMETRY_PROGRAM;
st->dirty |= ST_NEW_GEOMETRY_PROGRAM;
}
static void check_attrib_edgeflag(struct st_context *st)
@@ -165,14 +89,14 @@ static void check_attrib_edgeflag(struct st_context *st)
arrays[VERT_ATTRIB_EDGEFLAG]->StrideB != 0;
if (vertdata_edgeflags != st->vertdata_edgeflags) {
st->vertdata_edgeflags = vertdata_edgeflags;
st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
st->dirty |= ST_NEW_VERTEX_PROGRAM;
}
edgeflag_culls_prims = edgeflags_enabled && !vertdata_edgeflags &&
!st->ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0];
if (edgeflag_culls_prims != st->edgeflag_culls_prims) {
st->edgeflag_culls_prims = edgeflag_culls_prims;
st->dirty.st |= ST_NEW_RASTERIZER;
st->dirty |= ST_NEW_RASTERIZER;
}
}
@@ -183,49 +107,45 @@ static void check_attrib_edgeflag(struct st_context *st)
void st_validate_state( struct st_context *st, enum st_pipeline pipeline )
{
const struct st_tracked_state **atoms;
struct st_state_flags *state;
GLuint num_atoms;
GLuint i;
uint64_t dirty, pipeline_mask;
uint32_t dirty_lo, dirty_hi;
/* Get Mesa driver state. */
st->dirty |= st->ctx->NewDriverState & ST_ALL_STATES_MASK;
st->ctx->NewDriverState = 0;
/* Get pipeline state. */
switch (pipeline) {
case ST_PIPELINE_RENDER:
atoms = render_atoms;
num_atoms = ARRAY_SIZE(render_atoms);
state = &st->dirty;
case ST_PIPELINE_RENDER:
check_attrib_edgeflag(st);
check_program_state(st);
st_manager_validate_framebuffers(st);
pipeline_mask = ST_PIPELINE_RENDER_STATE_MASK;
break;
case ST_PIPELINE_COMPUTE:
atoms = compute_atoms;
num_atoms = ARRAY_SIZE(compute_atoms);
state = &st->dirty_cp;
pipeline_mask = ST_PIPELINE_COMPUTE_STATE_MASK;
break;
default:
unreachable("Invalid pipeline specified");
}
/* Get Mesa driver state. */
st->dirty.st |= st->ctx->NewDriverState;
st->dirty_cp.st |= st->ctx->NewDriverState;
st->ctx->NewDriverState = 0;
if (pipeline == ST_PIPELINE_RENDER) {
check_attrib_edgeflag(st);
check_program_state(st);
st_manager_validate_framebuffers(st);
}
if (state->st == 0 && state->mesa == 0)
dirty = st->dirty & pipeline_mask;
if (!dirty)
return;
/*printf("%s %x/%x\n", __func__, state->mesa, state->st);*/
dirty_lo = dirty;
dirty_hi = dirty >> 32;
for (i = 0; i < num_atoms; i++) {
if (check_state(state, &atoms[i]->dirty))
atoms[i]->update( st );
}
/* Update states.
*
* Don't use u_bit_scan64, it may be slower on 32-bit.
*/
while (dirty_lo)
atoms[u_bit_scan(&dirty_lo)]->update(st);
while (dirty_hi)
atoms[32 + u_bit_scan(&dirty_hi)]->update(st);
memset(state, 0, sizeof(*state));
/* Clear the render or compute state bits. */
st->dirty &= ~pipeline_mask;
}

View File

@@ -36,82 +36,160 @@
#include "main/glheader.h"
#include "state_tracker/st_api.h"
#include "state_tracker/st_context.h"
struct st_context;
struct st_tracked_state;
/**
* Enumeration of state tracker pipelines.
*/
enum st_pipeline {
ST_PIPELINE_RENDER,
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 );
extern const struct st_tracked_state st_update_array;
extern const struct st_tracked_state st_update_framebuffer;
extern const struct st_tracked_state st_update_clip;
extern const struct st_tracked_state st_update_depth_stencil_alpha;
extern const struct st_tracked_state st_update_fp;
extern const struct st_tracked_state st_update_gp;
extern const struct st_tracked_state st_update_tep;
extern const struct st_tracked_state st_update_tcp;
extern const struct st_tracked_state st_update_vp;
extern const struct st_tracked_state st_update_cp;
extern const struct st_tracked_state st_update_rasterizer;
extern const struct st_tracked_state st_update_polygon_stipple;
extern const struct st_tracked_state st_update_viewport;
extern const struct st_tracked_state st_update_scissor;
extern const struct st_tracked_state st_update_window_rectangles;
extern const struct st_tracked_state st_update_blend;
extern const struct st_tracked_state st_update_msaa;
extern const struct st_tracked_state st_update_sample_shading;
extern const struct st_tracked_state st_update_sampler;
extern const struct st_tracked_state st_update_fragment_texture;
extern const struct st_tracked_state st_update_vertex_texture;
extern const struct st_tracked_state st_update_geometry_texture;
extern const struct st_tracked_state st_update_tessctrl_texture;
extern const struct st_tracked_state st_update_tesseval_texture;
extern const struct st_tracked_state st_update_compute_texture;
extern const struct st_tracked_state st_update_fs_constants;
extern const struct st_tracked_state st_update_gs_constants;
extern const struct st_tracked_state st_update_tes_constants;
extern const struct st_tracked_state st_update_tcs_constants;
extern const struct st_tracked_state st_update_vs_constants;
extern const struct st_tracked_state st_update_cs_constants;
extern const struct st_tracked_state st_bind_fs_ubos;
extern const struct st_tracked_state st_bind_vs_ubos;
extern const struct st_tracked_state st_bind_gs_ubos;
extern const struct st_tracked_state st_bind_tcs_ubos;
extern const struct st_tracked_state st_bind_tes_ubos;
extern const struct st_tracked_state st_bind_cs_ubos;
extern const struct st_tracked_state st_bind_fs_atomics;
extern const struct st_tracked_state st_bind_vs_atomics;
extern const struct st_tracked_state st_bind_gs_atomics;
extern const struct st_tracked_state st_bind_tcs_atomics;
extern const struct st_tracked_state st_bind_tes_atomics;
extern const struct st_tracked_state st_bind_cs_atomics;
extern const struct st_tracked_state st_bind_fs_ssbos;
extern const struct st_tracked_state st_bind_vs_ssbos;
extern const struct st_tracked_state st_bind_gs_ssbos;
extern const struct st_tracked_state st_bind_tcs_ssbos;
extern const struct st_tracked_state st_bind_tes_ssbos;
extern const struct st_tracked_state st_bind_cs_ssbos;
extern const struct st_tracked_state st_bind_fs_images;
extern const struct st_tracked_state st_bind_vs_images;
extern const struct st_tracked_state st_bind_gs_images;
extern const struct st_tracked_state st_bind_tcs_images;
extern const struct st_tracked_state st_bind_tes_images;
extern const struct st_tracked_state st_bind_cs_images;
extern const struct st_tracked_state st_update_pixel_transfer;
extern const struct st_tracked_state st_update_tess;
GLuint st_compare_func_to_pipe(GLenum func);
enum pipe_format
st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
GLboolean normalized, GLboolean integer);
/* Define ST_NEW_xxx_INDEX */
enum {
#define ST_STATE(FLAG, st_update) FLAG##_INDEX,
#include "st_atom_list.h"
#undef ST_STATE
};
/* Define ST_NEW_xxx */
enum {
#define ST_STATE(FLAG, st_update) FLAG = 1llu << FLAG##_INDEX,
#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;
#include "st_atom_list.h"
#undef ST_STATE
/* Combined state flags. */
#define ST_NEW_SAMPLERS (ST_NEW_RENDER_SAMPLERS | \
ST_NEW_CS_SAMPLERS)
#define ST_NEW_FRAMEBUFFER (ST_NEW_FB_STATE | \
ST_NEW_SAMPLE_MASK | \
ST_NEW_SAMPLE_SHADING)
#define ST_NEW_VERTEX_PROGRAM (ST_NEW_VS_STATE | \
ST_NEW_VS_SAMPLER_VIEWS | \
ST_NEW_VS_IMAGES | \
ST_NEW_VS_CONSTANTS | \
ST_NEW_VS_UBOS | \
ST_NEW_VS_ATOMICS | \
ST_NEW_VS_SSBOS | \
ST_NEW_VERTEX_ARRAYS | \
ST_NEW_CLIP_STATE | \
ST_NEW_RASTERIZER)
#define ST_NEW_TESSCTRL_PROGRAM (ST_NEW_TCS_STATE | \
ST_NEW_TCS_SAMPLER_VIEWS | \
ST_NEW_TCS_IMAGES | \
ST_NEW_TCS_CONSTANTS | \
ST_NEW_TCS_UBOS | \
ST_NEW_TCS_ATOMICS | \
ST_NEW_TCS_SSBOS)
#define ST_NEW_TESSEVAL_PROGRAM (ST_NEW_TES_STATE | \
ST_NEW_TES_SAMPLER_VIEWS | \
ST_NEW_TES_IMAGES | \
ST_NEW_TES_CONSTANTS | \
ST_NEW_TES_UBOS | \
ST_NEW_TES_ATOMICS | \
ST_NEW_TES_SSBOS | \
ST_NEW_RASTERIZER)
#define ST_NEW_GEOMETRY_PROGRAM (ST_NEW_GS_STATE | \
ST_NEW_GS_SAMPLER_VIEWS | \
ST_NEW_GS_IMAGES | \
ST_NEW_GS_CONSTANTS | \
ST_NEW_GS_UBOS | \
ST_NEW_GS_ATOMICS | \
ST_NEW_GS_SSBOS | \
ST_NEW_RASTERIZER)
#define ST_NEW_FRAGMENT_PROGRAM (ST_NEW_FS_STATE | \
ST_NEW_FS_SAMPLER_VIEWS | \
ST_NEW_FS_IMAGES | \
ST_NEW_FS_CONSTANTS | \
ST_NEW_FS_UBOS | \
ST_NEW_FS_ATOMICS | \
ST_NEW_FS_SSBOS | \
ST_NEW_SAMPLE_SHADING)
#define ST_NEW_COMPUTE_PROGRAM (ST_NEW_CS_STATE | \
ST_NEW_CS_SAMPLER_VIEWS | \
ST_NEW_CS_IMAGES | \
ST_NEW_CS_CONSTANTS | \
ST_NEW_CS_UBOS | \
ST_NEW_CS_ATOMICS | \
ST_NEW_CS_SSBOS)
#define ST_NEW_CONSTANTS (ST_NEW_VS_CONSTANTS | \
ST_NEW_TCS_CONSTANTS | \
ST_NEW_TES_CONSTANTS | \
ST_NEW_FS_CONSTANTS | \
ST_NEW_GS_CONSTANTS | \
ST_NEW_CS_CONSTANTS)
#define ST_NEW_UNIFORM_BUFFER (ST_NEW_VS_UBOS | \
ST_NEW_TCS_UBOS | \
ST_NEW_TES_UBOS | \
ST_NEW_FS_UBOS | \
ST_NEW_GS_UBOS | \
ST_NEW_CS_UBOS)
#define ST_NEW_SAMPLER_VIEWS (ST_NEW_VS_SAMPLER_VIEWS | \
ST_NEW_FS_SAMPLER_VIEWS | \
ST_NEW_GS_SAMPLER_VIEWS | \
ST_NEW_TCS_SAMPLER_VIEWS | \
ST_NEW_TES_SAMPLER_VIEWS | \
ST_NEW_CS_SAMPLER_VIEWS)
#define ST_NEW_ATOMIC_BUFFER (ST_NEW_VS_ATOMICS | \
ST_NEW_TCS_ATOMICS | \
ST_NEW_TES_ATOMICS | \
ST_NEW_FS_ATOMICS | \
ST_NEW_GS_ATOMICS | \
ST_NEW_CS_ATOMICS)
#define ST_NEW_STORAGE_BUFFER (ST_NEW_VS_SSBOS | \
ST_NEW_TCS_SSBOS | \
ST_NEW_TES_SSBOS | \
ST_NEW_FS_SSBOS | \
ST_NEW_GS_SSBOS | \
ST_NEW_CS_SSBOS)
#define ST_NEW_IMAGE_UNITS (ST_NEW_VS_IMAGES | \
ST_NEW_TCS_IMAGES | \
ST_NEW_TES_IMAGES | \
ST_NEW_GS_IMAGES | \
ST_NEW_FS_IMAGES | \
ST_NEW_CS_IMAGES)
/* All state flags within each group: */
#define ST_PIPELINE_RENDER_STATE_MASK (ST_NEW_CS_STATE - 1)
#define ST_PIPELINE_COMPUTE_STATE_MASK (ST_NEW_COMPUTE_PROGRAM | \
ST_NEW_CS_SAMPLERS)
#define ST_ALL_STATES_MASK (ST_PIPELINE_RENDER_STATE_MASK | \
ST_PIPELINE_COMPUTE_STATE_MASK)
#endif

View File

@@ -690,9 +690,5 @@ static void update_array(struct st_context *st)
const struct st_tracked_state st_update_array = {
{ /* dirty */
_NEW_CURRENT_ATTRIB, /* mesa */
ST_NEW_VERTEX_ARRAYS | ST_NEW_VERTEX_PROGRAM, /* st */
},
update_array /* update */
};

View File

@@ -79,10 +79,6 @@ bind_vs_atomics(struct st_context *st)
}
const struct st_tracked_state st_bind_vs_atomics = {
{
0,
ST_NEW_VERTEX_PROGRAM | ST_NEW_ATOMIC_BUFFER,
},
bind_vs_atomics
};
@@ -96,10 +92,6 @@ bind_fs_atomics(struct st_context *st)
}
const struct st_tracked_state st_bind_fs_atomics = {
{
0,
ST_NEW_FRAGMENT_PROGRAM | ST_NEW_ATOMIC_BUFFER,
},
bind_fs_atomics
};
@@ -113,10 +105,6 @@ bind_gs_atomics(struct st_context *st)
}
const struct st_tracked_state st_bind_gs_atomics = {
{
0,
ST_NEW_GEOMETRY_PROGRAM | ST_NEW_ATOMIC_BUFFER,
},
bind_gs_atomics
};
@@ -130,10 +118,6 @@ bind_tcs_atomics(struct st_context *st)
}
const struct st_tracked_state st_bind_tcs_atomics = {
{
0,
ST_NEW_TESSCTRL_PROGRAM | ST_NEW_ATOMIC_BUFFER,
},
bind_tcs_atomics
};
@@ -147,10 +131,6 @@ bind_tes_atomics(struct st_context *st)
}
const struct st_tracked_state st_bind_tes_atomics = {
{
0,
ST_NEW_TESSEVAL_PROGRAM | ST_NEW_ATOMIC_BUFFER,
},
bind_tes_atomics
};
@@ -164,9 +144,5 @@ bind_cs_atomics(struct st_context *st)
}
const struct st_tracked_state st_bind_cs_atomics = {
{
0,
ST_NEW_COMPUTE_PROGRAM | ST_NEW_ATOMIC_BUFFER,
},
bind_cs_atomics
};

View File

@@ -283,9 +283,5 @@ update_blend( struct st_context *st )
const struct st_tracked_state st_update_blend = {
{ /* dirty */
(_NEW_COLOR | _NEW_MULTISAMPLE), /* XXX _NEW_BLEND someday? */ /* mesa */
0, /* st */
},
update_blend, /* update */
};

View File

@@ -71,9 +71,5 @@ static void update_clip( struct st_context *st )
const struct st_tracked_state st_update_clip = {
{ /* dirty */
_NEW_TRANSFORM | _NEW_PROJECTION, /* mesa */
ST_NEW_VERTEX_PROGRAM, /* st */
},
update_clip /* update */
};

View File

@@ -145,10 +145,6 @@ static void update_vs_constants(struct st_context *st )
const struct st_tracked_state st_update_vs_constants = {
{ /* dirty */
_NEW_PROGRAM_CONSTANTS, /* mesa */
ST_NEW_VERTEX_PROGRAM, /* st */
},
update_vs_constants /* update */
};
@@ -167,10 +163,6 @@ static void update_fs_constants(struct st_context *st )
const struct st_tracked_state st_update_fs_constants = {
{ /* dirty */
_NEW_PROGRAM_CONSTANTS, /* mesa */
ST_NEW_FRAGMENT_PROGRAM, /* st */
},
update_fs_constants /* update */
};
@@ -188,10 +180,6 @@ static void update_gs_constants(struct st_context *st )
}
const struct st_tracked_state st_update_gs_constants = {
{ /* dirty */
_NEW_PROGRAM_CONSTANTS, /* mesa */
ST_NEW_GEOMETRY_PROGRAM, /* st */
},
update_gs_constants /* update */
};
@@ -209,10 +197,6 @@ static void update_tcs_constants(struct st_context *st )
}
const struct st_tracked_state st_update_tcs_constants = {
{ /* dirty */
_NEW_PROGRAM_CONSTANTS, /* mesa */
ST_NEW_TESSCTRL_PROGRAM, /* st */
},
update_tcs_constants /* update */
};
@@ -230,10 +214,6 @@ static void update_tes_constants(struct st_context *st )
}
const struct st_tracked_state st_update_tes_constants = {
{ /* dirty */
_NEW_PROGRAM_CONSTANTS, /* mesa */
ST_NEW_TESSEVAL_PROGRAM, /* st */
},
update_tes_constants /* update */
};
@@ -251,10 +231,6 @@ static void update_cs_constants(struct st_context *st )
}
const struct st_tracked_state st_update_cs_constants = {
{ /* dirty */
_NEW_PROGRAM_CONSTANTS, /* mesa */
ST_NEW_COMPUTE_PROGRAM, /* st */
},
update_cs_constants /* update */
};
@@ -308,10 +284,6 @@ static void bind_vs_ubos(struct st_context *st)
}
const struct st_tracked_state st_bind_vs_ubos = {
{
0,
ST_NEW_VERTEX_PROGRAM | ST_NEW_UNIFORM_BUFFER,
},
bind_vs_ubos
};
@@ -327,10 +299,6 @@ static void bind_fs_ubos(struct st_context *st)
}
const struct st_tracked_state st_bind_fs_ubos = {
{
0,
ST_NEW_FRAGMENT_PROGRAM | ST_NEW_UNIFORM_BUFFER,
},
bind_fs_ubos
};
@@ -346,10 +314,6 @@ static void bind_gs_ubos(struct st_context *st)
}
const struct st_tracked_state st_bind_gs_ubos = {
{
0,
ST_NEW_GEOMETRY_PROGRAM | ST_NEW_UNIFORM_BUFFER,
},
bind_gs_ubos
};
@@ -365,10 +329,6 @@ static void bind_tcs_ubos(struct st_context *st)
}
const struct st_tracked_state st_bind_tcs_ubos = {
{
0,
ST_NEW_TESSCTRL_PROGRAM | ST_NEW_UNIFORM_BUFFER,
},
bind_tcs_ubos
};
@@ -384,10 +344,6 @@ static void bind_tes_ubos(struct st_context *st)
}
const struct st_tracked_state st_bind_tes_ubos = {
{
0,
ST_NEW_TESSEVAL_PROGRAM | ST_NEW_UNIFORM_BUFFER,
},
bind_tes_ubos
};
@@ -404,9 +360,5 @@ static void bind_cs_ubos(struct st_context *st)
}
const struct st_tracked_state st_bind_cs_ubos = {
{
0,
ST_NEW_COMPUTE_PROGRAM | ST_NEW_UNIFORM_BUFFER,
},
bind_cs_ubos
};

View File

@@ -161,9 +161,5 @@ update_depth_stencil_alpha(struct st_context *st)
const struct st_tracked_state st_update_depth_stencil_alpha = {
{ /* dirty */
(_NEW_DEPTH|_NEW_STENCIL|_NEW_COLOR|_NEW_BUFFERS),/* mesa */
0, /* st */
},
update_depth_stencil_alpha /* update */
};

View File

@@ -215,10 +215,6 @@ update_framebuffer_state( struct st_context *st )
const struct st_tracked_state st_update_framebuffer = {
{ /* dirty */
_NEW_BUFFERS, /* mesa */
ST_NEW_FRAMEBUFFER, /* st */
},
update_framebuffer_state /* update */
};

View File

@@ -146,10 +146,6 @@ static void bind_vs_images(struct st_context *st)
}
const struct st_tracked_state st_bind_vs_images = {
{
_NEW_TEXTURE,
ST_NEW_VERTEX_PROGRAM | ST_NEW_IMAGE_UNITS,
},
bind_vs_images
};
@@ -165,10 +161,6 @@ static void bind_fs_images(struct st_context *st)
}
const struct st_tracked_state st_bind_fs_images = {
{
_NEW_TEXTURE,
ST_NEW_FRAGMENT_PROGRAM | ST_NEW_IMAGE_UNITS,
},
bind_fs_images
};
@@ -184,10 +176,6 @@ static void bind_gs_images(struct st_context *st)
}
const struct st_tracked_state st_bind_gs_images = {
{
_NEW_TEXTURE,
ST_NEW_GEOMETRY_PROGRAM | ST_NEW_IMAGE_UNITS,
},
bind_gs_images
};
@@ -203,10 +191,6 @@ static void bind_tcs_images(struct st_context *st)
}
const struct st_tracked_state st_bind_tcs_images = {
{
_NEW_TEXTURE,
ST_NEW_TESSCTRL_PROGRAM | ST_NEW_IMAGE_UNITS,
},
bind_tcs_images
};
@@ -222,10 +206,6 @@ static void bind_tes_images(struct st_context *st)
}
const struct st_tracked_state st_bind_tes_images = {
{
_NEW_TEXTURE,
ST_NEW_TESSEVAL_PROGRAM | ST_NEW_IMAGE_UNITS,
},
bind_tes_images
};
@@ -241,9 +221,5 @@ static void bind_cs_images(struct st_context *st)
}
const struct st_tracked_state st_bind_cs_images = {
{
_NEW_TEXTURE,
ST_NEW_COMPUTE_PROGRAM | ST_NEW_IMAGE_UNITS,
},
bind_cs_images
};

View File

@@ -0,0 +1,75 @@
/* Render (non-compute) states must be first. */
ST_STATE(ST_NEW_DSA, st_update_depth_stencil_alpha)
ST_STATE(ST_NEW_CLIP_STATE, st_update_clip)
ST_STATE(ST_NEW_FS_STATE, st_update_fp)
ST_STATE(ST_NEW_GS_STATE, st_update_gp)
ST_STATE(ST_NEW_TES_STATE, st_update_tep)
ST_STATE(ST_NEW_TCS_STATE, st_update_tcp)
ST_STATE(ST_NEW_VS_STATE, st_update_vp)
ST_STATE(ST_NEW_RASTERIZER, st_update_rasterizer)
ST_STATE(ST_NEW_POLY_STIPPLE, st_update_polygon_stipple)
ST_STATE(ST_NEW_VIEWPORT, st_update_viewport)
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)
/* Non-compute samplers. */
ST_STATE(ST_NEW_RENDER_SAMPLERS, st_update_sampler) /* 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)
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_SAMPLE_SHADING, st_update_sample_shading)
ST_STATE(ST_NEW_VS_CONSTANTS, st_update_vs_constants)
ST_STATE(ST_NEW_TCS_CONSTANTS, st_update_tcs_constants)
ST_STATE(ST_NEW_TES_CONSTANTS, st_update_tes_constants)
ST_STATE(ST_NEW_GS_CONSTANTS, st_update_gs_constants)
ST_STATE(ST_NEW_FS_CONSTANTS, st_update_fs_constants)
ST_STATE(ST_NEW_VS_UBOS, st_bind_vs_ubos)
ST_STATE(ST_NEW_TCS_UBOS, st_bind_tcs_ubos)
ST_STATE(ST_NEW_TES_UBOS, st_bind_tes_ubos)
ST_STATE(ST_NEW_FS_UBOS, st_bind_fs_ubos)
ST_STATE(ST_NEW_GS_UBOS, st_bind_gs_ubos)
ST_STATE(ST_NEW_VS_ATOMICS, st_bind_vs_atomics)
ST_STATE(ST_NEW_TCS_ATOMICS, st_bind_tcs_atomics)
ST_STATE(ST_NEW_TES_ATOMICS, st_bind_tes_atomics)
ST_STATE(ST_NEW_FS_ATOMICS, st_bind_fs_atomics)
ST_STATE(ST_NEW_GS_ATOMICS, st_bind_gs_atomics)
ST_STATE(ST_NEW_VS_SSBOS, st_bind_vs_ssbos)
ST_STATE(ST_NEW_TCS_SSBOS, st_bind_tcs_ssbos)
ST_STATE(ST_NEW_TES_SSBOS, st_bind_tes_ssbos)
ST_STATE(ST_NEW_FS_SSBOS, st_bind_fs_ssbos)
ST_STATE(ST_NEW_GS_SSBOS, st_bind_gs_ssbos)
ST_STATE(ST_NEW_PIXEL_TRANSFER, st_update_pixel_transfer)
ST_STATE(ST_NEW_TESS_STATE, st_update_tess)
/* this must be done after the vertex program update */
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_sampler) /* 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)
ST_STATE(ST_NEW_CS_SSBOS, st_bind_cs_ssbos)
ST_STATE(ST_NEW_CS_IMAGES, st_bind_cs_images)

View File

@@ -86,17 +86,9 @@ static void update_sample_shading( struct st_context *st )
}
const struct st_tracked_state st_update_msaa = {
{ /* dirty */
(_NEW_MULTISAMPLE | _NEW_BUFFERS), /* mesa */
ST_NEW_FRAMEBUFFER, /* st */
},
update_sample_mask /* update */
};
const struct st_tracked_state st_update_sample_shading = {
{ /* dirty */
(_NEW_MULTISAMPLE | _NEW_PROGRAM | _NEW_BUFFERS), /* mesa */
ST_NEW_FRAGMENT_PROGRAM | ST_NEW_FRAMEBUFFER, /* st */
},
update_sample_shading /* update */
};

View File

@@ -102,9 +102,5 @@ update_pixel_transfer(struct st_context *st)
const struct st_tracked_state st_update_pixel_transfer = {
{ /* dirty */
_NEW_PIXEL, /* mesa */
0, /* st */
},
update_pixel_transfer /* update */
};

View File

@@ -290,21 +290,5 @@ static void update_raster_state( struct st_context *st )
}
const struct st_tracked_state st_update_rasterizer = {
{
(_NEW_BUFFERS |
_NEW_LIGHT |
_NEW_LINE |
_NEW_MULTISAMPLE |
_NEW_POINT |
_NEW_POLYGON |
_NEW_PROGRAM |
_NEW_SCISSOR |
_NEW_FRAG_CLAMP |
_NEW_TRANSFORM), /* mesa state dependencies*/
(ST_NEW_VERTEX_PROGRAM |
ST_NEW_TESSEVAL_PROGRAM |
ST_NEW_GEOMETRY_PROGRAM |
ST_NEW_RASTERIZER), /* state tracker dependencies */
},
update_raster_state /* update function */
};

View File

@@ -334,9 +334,5 @@ update_samplers(struct st_context *st)
const struct st_tracked_state st_update_sampler = {
{ /* dirty */
_NEW_TEXTURE, /* mesa */
0, /* st */
},
update_samplers /* update */
};

View File

@@ -141,17 +141,9 @@ update_window_rectangles(struct st_context *st)
}
const struct st_tracked_state st_update_scissor = {
{ /* dirty */
(_NEW_SCISSOR | _NEW_BUFFERS), /* mesa */
0, /* st */
},
update_scissor /* update */
};
const struct st_tracked_state st_update_window_rectangles = {
{ /* dirty */
(_NEW_SCISSOR | _NEW_BUFFERS), /* mesa */
0, /* st */
},
update_window_rectangles /* update */
};

View File

@@ -152,10 +152,6 @@ update_fp( struct st_context *st )
const struct st_tracked_state st_update_fp = {
{ /* dirty */
_NEW_BUFFERS | _NEW_MULTISAMPLE | _NEW_FOG, /* mesa */
ST_NEW_FRAGMENT_PROGRAM /* st */
},
update_fp /* update */
};
@@ -209,10 +205,6 @@ update_vp( struct st_context *st )
const struct st_tracked_state st_update_vp = {
{ /* dirty */
0, /* mesa */
ST_NEW_VERTEX_PROGRAM /* st */
},
update_vp /* update */
};
@@ -241,10 +233,6 @@ update_gp( struct st_context *st )
}
const struct st_tracked_state st_update_gp = {
{ /* dirty */
0, /* mesa */
ST_NEW_GEOMETRY_PROGRAM /* st */
},
update_gp /* update */
};
@@ -273,10 +261,6 @@ update_tcp( struct st_context *st )
}
const struct st_tracked_state st_update_tcp = {
{ /* dirty */
0, /* mesa */
ST_NEW_TESSCTRL_PROGRAM /* st */
},
update_tcp /* update */
};
@@ -305,10 +289,6 @@ update_tep( struct st_context *st )
}
const struct st_tracked_state st_update_tep = {
{ /* dirty */
0, /* mesa */
ST_NEW_TESSEVAL_PROGRAM /* st */
},
update_tep /* update */
};
@@ -336,9 +316,5 @@ update_cp( struct st_context *st )
}
const struct st_tracked_state st_update_cp = {
{ /* dirty */
0, /* mesa */
ST_NEW_COMPUTE_PROGRAM /* st */
},
update_cp /* update */
};

View File

@@ -84,10 +84,5 @@ update_stipple( struct st_context *st )
/** Update the stipple when the pattern or window height changes */
const struct st_tracked_state st_update_polygon_stipple = {
{ /* dirty */
(_NEW_POLYGONSTIPPLE |
_NEW_BUFFERS), /* mesa */
0, /* st */
},
update_stipple /* update */
};

View File

@@ -103,10 +103,6 @@ static void bind_vs_ssbos(struct st_context *st)
}
const struct st_tracked_state st_bind_vs_ssbos = {
{
0,
ST_NEW_VERTEX_PROGRAM | ST_NEW_STORAGE_BUFFER,
},
bind_vs_ssbos
};
@@ -123,10 +119,6 @@ static void bind_fs_ssbos(struct st_context *st)
}
const struct st_tracked_state st_bind_fs_ssbos = {
{
0,
ST_NEW_FRAGMENT_PROGRAM | ST_NEW_STORAGE_BUFFER,
},
bind_fs_ssbos
};
@@ -143,10 +135,6 @@ static void bind_gs_ssbos(struct st_context *st)
}
const struct st_tracked_state st_bind_gs_ssbos = {
{
0,
ST_NEW_GEOMETRY_PROGRAM | ST_NEW_STORAGE_BUFFER,
},
bind_gs_ssbos
};
@@ -163,10 +151,6 @@ static void bind_tcs_ssbos(struct st_context *st)
}
const struct st_tracked_state st_bind_tcs_ssbos = {
{
0,
ST_NEW_TESSCTRL_PROGRAM | ST_NEW_STORAGE_BUFFER,
},
bind_tcs_ssbos
};
@@ -183,10 +167,6 @@ static void bind_tes_ssbos(struct st_context *st)
}
const struct st_tracked_state st_bind_tes_ssbos = {
{
0,
ST_NEW_TESSEVAL_PROGRAM | ST_NEW_STORAGE_BUFFER,
},
bind_tes_ssbos
};
@@ -203,9 +183,5 @@ static void bind_cs_ssbos(struct st_context *st)
}
const struct st_tracked_state st_bind_cs_ssbos = {
{
0,
ST_NEW_COMPUTE_PROGRAM | ST_NEW_STORAGE_BUFFER,
},
bind_cs_ssbos
};

View File

@@ -53,9 +53,5 @@ update_tess(struct st_context *st)
const struct st_tracked_state st_update_tess = {
{ /* dirty */
0, /* mesa */
ST_NEW_TESS_STATE, /* st */
},
update_tess /* update */
};

View File

@@ -565,54 +565,30 @@ update_compute_textures(struct st_context *st)
const struct st_tracked_state st_update_fragment_texture = {
{ /* dirty */
_NEW_TEXTURE, /* mesa */
ST_NEW_FRAGMENT_PROGRAM | ST_NEW_SAMPLER_VIEWS, /* st */
},
update_fragment_textures /* update */
};
const struct st_tracked_state st_update_vertex_texture = {
{ /* dirty */
_NEW_TEXTURE, /* mesa */
ST_NEW_VERTEX_PROGRAM | ST_NEW_SAMPLER_VIEWS, /* st */
},
update_vertex_textures /* update */
};
const struct st_tracked_state st_update_geometry_texture = {
{ /* dirty */
_NEW_TEXTURE, /* mesa */
ST_NEW_GEOMETRY_PROGRAM | ST_NEW_SAMPLER_VIEWS, /* st */
},
update_geometry_textures /* update */
};
const struct st_tracked_state st_update_tessctrl_texture = {
{ /* dirty */
_NEW_TEXTURE, /* mesa */
ST_NEW_TESSCTRL_PROGRAM | ST_NEW_SAMPLER_VIEWS, /* st */
},
update_tessctrl_textures /* update */
};
const struct st_tracked_state st_update_tesseval_texture = {
{ /* dirty */
_NEW_TEXTURE, /* mesa */
ST_NEW_TESSEVAL_PROGRAM | ST_NEW_SAMPLER_VIEWS, /* st */
},
update_tesseval_textures /* update */
};
const struct st_tracked_state st_update_compute_texture = {
{ /* dirty */
_NEW_TEXTURE, /* mesa */
ST_NEW_COMPUTE_PROGRAM | ST_NEW_SAMPLER_VIEWS, /* st */
},
update_compute_textures /* update */
};

View File

@@ -83,9 +83,5 @@ update_viewport( struct st_context *st )
const struct st_tracked_state st_update_viewport = {
{ /* dirty */
_NEW_BUFFERS | _NEW_VIEWPORT, /* mesa */
0, /* st */
},
update_viewport /* update */
};

View File

@@ -347,7 +347,7 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
restore_render_state(ctx);
/* We uploaded modified constants, need to invalidate them. */
st->dirty.mesa |= _NEW_PROGRAM_CONSTANTS;
st->dirty |= ST_NEW_FS_CONSTANTS;
}
@@ -642,12 +642,12 @@ st_Bitmap(struct gl_context *ctx, GLint x, GLint y,
init_bitmap_state(st);
}
/* We only need to validate state of the st dirty flags are set or
* any non-_NEW_PROGRAM_CONSTANTS mesa flags are set. The VS we use
/* We only need to validate any non-ST_NEW_CONSTANTS state. The VS we use
* for bitmap drawing uses no constants and the FS constants are
* explicitly uploaded in the draw_bitmap_quad() function.
*/
if ((st->dirty.mesa & ~_NEW_PROGRAM_CONSTANTS) || st->dirty.st) {
if ((st->dirty | ctx->NewDriverState) & ~ST_NEW_CONSTANTS &
ST_PIPELINE_RENDER_STATE_MASK) {
st_validate_state(st, ST_PIPELINE_RENDER);
}
@@ -803,7 +803,7 @@ st_DrawAtlasBitmaps(struct gl_context *ctx,
pipe_sampler_view_reference(&sv, NULL);
/* We uploaded modified constants, need to invalidate them. */
st->dirty.mesa |= _NEW_PROGRAM_CONSTANTS;
st->dirty |= ST_NEW_FS_CONSTANTS;
}

View File

@@ -333,15 +333,15 @@ st_bufferobj_data(struct gl_context *ctx,
* might be using it.
*/
/* TODO: Add arrays to usage history */
st->dirty.st |= ST_NEW_VERTEX_ARRAYS;
st->dirty |= ST_NEW_VERTEX_ARRAYS;
if (st_obj->Base.UsageHistory & USAGE_UNIFORM_BUFFER)
st->dirty.st |= ST_NEW_UNIFORM_BUFFER;
st->dirty |= ST_NEW_UNIFORM_BUFFER;
if (st_obj->Base.UsageHistory & USAGE_SHADER_STORAGE_BUFFER)
st->dirty.st |= ST_NEW_STORAGE_BUFFER;
st->dirty |= ST_NEW_STORAGE_BUFFER;
if (st_obj->Base.UsageHistory & USAGE_TEXTURE_BUFFER)
st->dirty.st |= ST_NEW_SAMPLER_VIEWS | ST_NEW_IMAGE_UNITS;
st->dirty |= ST_NEW_SAMPLER_VIEWS | ST_NEW_IMAGE_UNITS;
if (st_obj->Base.UsageHistory & USAGE_ATOMIC_COUNTER_BUFFER)
st->dirty.st |= ST_NEW_ATOMIC_BUFFER;
st->dirty |= ST_NEW_ATOMIC_BUFFER;
return GL_TRUE;
}

View File

@@ -51,7 +51,7 @@ static void st_dispatch_compute_common(struct gl_context *ctx,
if (ctx->NewState)
_mesa_update_state(ctx);
if (st->dirty_cp.st || st->dirty_cp.mesa || ctx->NewDriverState)
if ((st->dirty | ctx->NewDriverState) & ST_PIPELINE_COMPUTE_STATE_MASK)
st_validate_state(st, ST_PIPELINE_COMPUTE);
for (unsigned i = 0; i < 3; i++) {

View File

@@ -294,7 +294,7 @@ st_RenderMode(struct gl_context *ctx, GLenum newMode )
/* Plug in new vbo draw function */
vbo_set_draw_func(ctx, st_feedback_draw_vbo);
/* need to generate/use a vertex program that emits pos/color/tex */
st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
st->dirty |= ST_NEW_VERTEX_PROGRAM;
}
}

View File

@@ -61,22 +61,22 @@ st_bind_program(struct gl_context *ctx, GLenum target, struct gl_program *prog)
switch (target) {
case GL_VERTEX_PROGRAM_ARB:
st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
st->dirty |= ST_NEW_VERTEX_PROGRAM;
break;
case GL_FRAGMENT_PROGRAM_ARB:
st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
st->dirty |= ST_NEW_FRAGMENT_PROGRAM;
break;
case GL_GEOMETRY_PROGRAM_NV:
st->dirty.st |= ST_NEW_GEOMETRY_PROGRAM;
st->dirty |= ST_NEW_GEOMETRY_PROGRAM;
break;
case GL_TESS_CONTROL_PROGRAM_NV:
st->dirty.st |= ST_NEW_TESSCTRL_PROGRAM;
st->dirty |= ST_NEW_TESSCTRL_PROGRAM;
break;
case GL_TESS_EVALUATION_PROGRAM_NV:
st->dirty.st |= ST_NEW_TESSEVAL_PROGRAM;
st->dirty |= ST_NEW_TESSEVAL_PROGRAM;
break;
case GL_COMPUTE_PROGRAM_NV:
st->dirty_cp.st |= ST_NEW_COMPUTE_PROGRAM;
st->dirty |= ST_NEW_COMPUTE_PROGRAM;
break;
}
}
@@ -91,12 +91,12 @@ st_use_program(struct gl_context *ctx, struct gl_shader_program *shProg)
{
struct st_context *st = st_context(ctx);
st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
st->dirty.st |= ST_NEW_GEOMETRY_PROGRAM;
st->dirty.st |= ST_NEW_TESSCTRL_PROGRAM;
st->dirty.st |= ST_NEW_TESSEVAL_PROGRAM;
st->dirty_cp.st |= ST_NEW_COMPUTE_PROGRAM;
st->dirty |= ST_NEW_FRAGMENT_PROGRAM;
st->dirty |= ST_NEW_VERTEX_PROGRAM;
st->dirty |= ST_NEW_GEOMETRY_PROGRAM;
st->dirty |= ST_NEW_TESSCTRL_PROGRAM;
st->dirty |= ST_NEW_TESSEVAL_PROGRAM;
st->dirty |= ST_NEW_COMPUTE_PROGRAM;
}
@@ -245,7 +245,7 @@ st_program_string_notify( struct gl_context *ctx,
return false;
if (st->fp == stfp)
st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
st->dirty |= ST_NEW_FRAGMENT_PROGRAM;
}
else if (target == GL_GEOMETRY_PROGRAM_NV) {
struct st_geometry_program *stgp = (struct st_geometry_program *) prog;
@@ -256,7 +256,7 @@ st_program_string_notify( struct gl_context *ctx,
return false;
if (st->gp == stgp)
st->dirty.st |= ST_NEW_GEOMETRY_PROGRAM;
st->dirty |= ST_NEW_GEOMETRY_PROGRAM;
}
else if (target == GL_VERTEX_PROGRAM_ARB) {
struct st_vertex_program *stvp = (struct st_vertex_program *) prog;
@@ -266,7 +266,7 @@ st_program_string_notify( struct gl_context *ctx,
return false;
if (st->vp == stvp)
st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
st->dirty |= ST_NEW_VERTEX_PROGRAM;
}
else if (target == GL_TESS_CONTROL_PROGRAM_NV) {
struct st_tessctrl_program *sttcp =
@@ -278,7 +278,7 @@ st_program_string_notify( struct gl_context *ctx,
return false;
if (st->tcp == sttcp)
st->dirty.st |= ST_NEW_TESSCTRL_PROGRAM;
st->dirty |= ST_NEW_TESSCTRL_PROGRAM;
}
else if (target == GL_TESS_EVALUATION_PROGRAM_NV) {
struct st_tesseval_program *sttep =
@@ -290,7 +290,7 @@ st_program_string_notify( struct gl_context *ctx,
return false;
if (st->tep == sttep)
st->dirty.st |= ST_NEW_TESSEVAL_PROGRAM;
st->dirty |= ST_NEW_TESSEVAL_PROGRAM;
}
else if (target == GL_COMPUTE_PROGRAM_NV) {
struct st_compute_program *stcp =
@@ -301,7 +301,7 @@ st_program_string_notify( struct gl_context *ctx,
return false;
if (st->cp == stcp)
st->dirty_cp.st |= ST_NEW_COMPUTE_PROGRAM;
st->dirty |= ST_NEW_COMPUTE_PROGRAM;
}
else if (target == GL_FRAGMENT_SHADER_ATI) {
assert(prog);
@@ -317,7 +317,7 @@ st_program_string_notify( struct gl_context *ctx,
return false;
if (st->fp == stfp)
st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
st->dirty |= ST_NEW_FRAGMENT_PROGRAM;
}
if (ST_DEBUG & DEBUG_PRECOMPILE ||

View File

@@ -2540,7 +2540,7 @@ st_finalize_texture(struct gl_context *ctx,
*/
pipe_resource_reference(&stObj->pt, NULL);
st_texture_release_all_sampler_views(st, stObj);
st->dirty.st |= ST_NEW_FRAMEBUFFER;
st->dirty |= ST_NEW_FRAMEBUFFER;
}
}

View File

@@ -130,20 +130,94 @@ void st_invalidate_state(struct gl_context * ctx, GLbitfield new_state)
{
struct st_context *st = st_context(ctx);
/* Replace _NEW_FRAG_CLAMP with ST_NEW_FRAGMENT_PROGRAM for the fallback. */
if (st->clamp_frag_color_in_shader && (new_state & _NEW_FRAG_CLAMP)) {
new_state &= ~_NEW_FRAG_CLAMP;
st->dirty.st |= ST_NEW_FRAGMENT_PROGRAM;
if (new_state & _NEW_BUFFERS) {
st->dirty |= ST_NEW_DSA |
ST_NEW_FB_STATE |
ST_NEW_SAMPLE_MASK |
ST_NEW_SAMPLE_SHADING |
ST_NEW_FS_STATE |
ST_NEW_POLY_STIPPLE |
ST_NEW_VIEWPORT |
ST_NEW_RASTERIZER |
ST_NEW_SCISSOR |
ST_NEW_WINDOW_RECTANGLES;
} else {
/* These set a subset of flags set by _NEW_BUFFERS, so we only have to
* check them when _NEW_BUFFERS isn't set.
*/
if (new_state & (_NEW_DEPTH |
_NEW_STENCIL))
st->dirty |= ST_NEW_DSA;
if (new_state & _NEW_PROGRAM)
st->dirty |= ST_NEW_SAMPLE_SHADING |
ST_NEW_RASTERIZER;
if (new_state & _NEW_SCISSOR)
st->dirty |= ST_NEW_RASTERIZER |
ST_NEW_SCISSOR |
ST_NEW_WINDOW_RECTANGLES;
if (new_state & _NEW_FOG)
st->dirty |= ST_NEW_FS_STATE;
if (new_state & _NEW_POLYGONSTIPPLE)
st->dirty |= ST_NEW_POLY_STIPPLE;
if (new_state & _NEW_VIEWPORT)
st->dirty |= ST_NEW_VIEWPORT;
if (new_state & _NEW_FRAG_CLAMP) {
if (st->clamp_frag_color_in_shader)
st->dirty |= ST_NEW_FS_STATE;
else
st->dirty |= ST_NEW_RASTERIZER;
}
}
if (new_state & _NEW_MULTISAMPLE) {
st->dirty |= ST_NEW_BLEND |
ST_NEW_SAMPLE_MASK |
ST_NEW_SAMPLE_SHADING |
ST_NEW_RASTERIZER |
ST_NEW_FS_STATE;
} else {
/* These set a subset of flags set by _NEW_MULTISAMPLE, so we only
* have to check them when _NEW_MULTISAMPLE isn't set.
*/
if (new_state & (_NEW_LIGHT |
_NEW_LINE |
_NEW_POINT |
_NEW_POLYGON |
_NEW_TRANSFORM))
st->dirty |= ST_NEW_RASTERIZER;
}
if (new_state & (_NEW_PROJECTION |
_NEW_TRANSFORM))
st->dirty |= ST_NEW_CLIP_STATE;
if (new_state & _NEW_COLOR)
st->dirty |= ST_NEW_BLEND |
ST_NEW_DSA;
if (new_state & _NEW_PIXEL)
st->dirty |= ST_NEW_PIXEL_TRANSFER;
if (new_state & _NEW_TEXTURE)
st->dirty |= ST_NEW_SAMPLER_VIEWS |
ST_NEW_SAMPLERS |
ST_NEW_IMAGE_UNITS;
if (new_state & _NEW_CURRENT_ATTRIB)
st->dirty |= ST_NEW_VERTEX_ARRAYS;
if (new_state & _NEW_PROGRAM_CONSTANTS)
st->dirty |= ST_NEW_CONSTANTS;
/* Update the vertex shader if ctx->Light._ClampVertexColor was changed. */
if (st->clamp_vert_color_in_shader && (new_state & _NEW_LIGHT)) {
st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
}
/* Invalidate render and compute pipelines. */
st->dirty.mesa |= new_state;
st->dirty_cp.mesa |= new_state;
if (st->clamp_vert_color_in_shader && (new_state & _NEW_LIGHT))
st->dirty |= ST_NEW_VS_STATE;
/* This is the only core Mesa module we depend upon.
* No longer use swrast, swsetup, tnl.
@@ -214,11 +288,7 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
/* state tracker needs the VBO module */
_vbo_CreateContext(ctx);
/* Initialize render and compute pipelines flags */
st->dirty.mesa = ~0;
st->dirty.st = ~0;
st->dirty_cp.mesa = ~0;
st->dirty_cp.st = ~0;
st->dirty = ST_ALL_STATES_MASK;
/* Create upload manager for vertex data for glBitmap, glDrawPixels,
* glClear, etc.

View File

@@ -32,6 +32,7 @@
#include "pipe/p_state.h"
#include "state_tracker/st_api.h"
#include "main/fbobject.h"
#include "state_tracker/st_atom.h"
#ifdef __cplusplus
@@ -50,44 +51,6 @@ struct st_perf_monitor_group;
struct u_upload_mgr;
/* gap */
#define ST_NEW_FRAGMENT_PROGRAM (1 << 1)
#define ST_NEW_VERTEX_PROGRAM (1 << 2)
#define ST_NEW_FRAMEBUFFER (1 << 3)
#define ST_NEW_TESS_STATE (1 << 4)
#define ST_NEW_GEOMETRY_PROGRAM (1 << 5)
#define ST_NEW_VERTEX_ARRAYS (1 << 6)
#define ST_NEW_RASTERIZER (1 << 7)
#define ST_NEW_UNIFORM_BUFFER (1 << 8)
#define ST_NEW_TESSCTRL_PROGRAM (1 << 9)
#define ST_NEW_TESSEVAL_PROGRAM (1 << 10)
#define ST_NEW_SAMPLER_VIEWS (1 << 11)
#define ST_NEW_ATOMIC_BUFFER (1 << 12)
#define ST_NEW_STORAGE_BUFFER (1 << 13)
#define ST_NEW_COMPUTE_PROGRAM (1 << 14)
#define ST_NEW_IMAGE_UNITS (1 << 15)
struct st_state_flags {
GLbitfield mesa; /**< Mask of _NEW_x flags */
uint32_t st; /**< Mask of ST_NEW_x flags */
};
struct st_tracked_state {
struct st_state_flags dirty;
void (*update)( struct st_context *st );
};
/**
* Enumeration of state tracker pipelines.
*/
enum st_pipeline {
ST_PIPELINE_RENDER,
ST_PIPELINE_COMPUTE,
};
/** For drawing quads for glClear, glDraw/CopyPixels, glBitmap, etc. */
struct st_util_vertex
{
@@ -175,8 +138,7 @@ struct st_context
char vendor[100];
char renderer[100];
struct st_state_flags dirty;
struct st_state_flags dirty_cp;
uint64_t dirty; /**< dirty states */
GLboolean vertdata_edgeflags;
GLboolean edgeflag_culls_prims;

View File

@@ -173,7 +173,7 @@ st_draw_vbo(struct gl_context *ctx,
st_invalidate_readpix_cache(st);
/* Validate state. */
if (st->dirty.st || st->dirty.mesa || ctx->NewDriverState) {
if ((st->dirty | ctx->NewDriverState) & ST_PIPELINE_RENDER_STATE_MASK) {
st_validate_state(st, ST_PIPELINE_RENDER);
}
@@ -278,7 +278,7 @@ st_indirect_draw_vbo(struct gl_context *ctx,
assert(stride);
/* Validate state. */
if (st->dirty.st || st->dirty.mesa || ctx->NewDriverState) {
if ((st->dirty | ctx->NewDriverState) & ST_PIPELINE_RENDER_STATE_MASK) {
st_validate_state(st, ST_PIPELINE_RENDER);
}

View File

@@ -153,7 +153,7 @@ st_context_validate(struct st_context *st,
struct st_framebuffer *stread)
{
if (stdraw && stdraw->stamp != st->draw_stamp) {
st->dirty.st |= ST_NEW_FRAMEBUFFER;
st->dirty |= ST_NEW_FRAMEBUFFER;
_mesa_resize_framebuffer(st->ctx, &stdraw->Base,
stdraw->Base.Width,
stdraw->Base.Height);
@@ -162,7 +162,7 @@ st_context_validate(struct st_context *st,
if (stread && stread->stamp != st->read_stamp) {
if (stread != stdraw) {
st->dirty.st |= ST_NEW_FRAMEBUFFER;
st->dirty |= ST_NEW_FRAMEBUFFER;
_mesa_resize_framebuffer(st->ctx, &stread->Base,
stread->Base.Width,
stread->Base.Height);