Compute needs a new and different validation path.
Changes from v2:
- make use of unreachable() instead of assert() when the pipeline is
invalid
- move the st_pipeline enumeration to st_context.h instead of st_api.h
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
/**
- * This is used to initialize st->atoms[].
+ * This is used to initialize st->render_atoms[].
*/
-static const struct st_tracked_state *atoms[] =
+static const struct st_tracked_state *render_atoms[] =
{
&st_update_depth_stencil_alpha,
&st_update_clip,
};
+/**
+ * This is used to initialize st->compute_atoms[].
+ */
+static const struct st_tracked_state *compute_atoms[] =
+{
+ /* will be updated in the next commit */
+};
+
+
void st_init_atoms( struct st_context *st )
{
/* no-op */
* Update all derived state:
*/
-void st_validate_state( struct st_context *st )
+void st_validate_state( struct st_context *st, enum st_pipeline pipeline )
{
- struct st_state_flags *state = &st->dirty;
+ const struct st_tracked_state **atoms;
+ struct st_state_flags *state;
+ GLuint num_atoms;
GLuint i;
+ /* Get pipeline state. */
+ switch (pipeline) {
+ case ST_PIPELINE_RENDER:
+ atoms = render_atoms;
+ num_atoms = ARRAY_SIZE(render_atoms);
+ state = &st->dirty;
+ break;
+ case ST_PIPELINE_COMPUTE:
+ atoms = compute_atoms;
+ num_atoms = ARRAY_SIZE(compute_atoms);
+ state = &st->dirty_cp;
+ 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;
- check_attrib_edgeflag(st);
+ if (pipeline == ST_PIPELINE_RENDER) {
+ check_attrib_edgeflag(st);
- check_program_state( st );
+ check_program_state(st);
- st_manager_validate_framebuffers(st);
+ st_manager_validate_framebuffers(st);
+ }
if (state->st == 0 && state->mesa == 0)
return;
memset(&examined, 0, sizeof(examined));
prev = *state;
- for (i = 0; i < ARRAY_SIZE(atoms); i++) {
+ for (i = 0; i < num_atoms; i++) {
const struct st_tracked_state *atom = atoms[i];
struct st_state_flags generated;
}
else {
- for (i = 0; i < ARRAY_SIZE(atoms); i++) {
+ for (i = 0; i < num_atoms; i++) {
if (check_state(state, &atoms[i]->dirty))
atoms[i]->update( st );
}
#include "main/glheader.h"
+#include "state_tracker/st_api.h"
+#include "state_tracker/st_context.h"
+
struct st_context;
struct st_tracked_state;
void st_destroy_atoms( struct st_context *st );
-void st_validate_state( 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;
* explicitly uploaded in the draw_bitmap_quad() function.
*/
if ((st->dirty.mesa & ~_NEW_PROGRAM_CONSTANTS) || st->dirty.st) {
- st_validate_state(st);
+ st_validate_state(st, ST_PIPELINE_RENDER);
}
if (UseBitmapCache && accum_bitmap(ctx, x, y, width, height, unpack, bitmap))
st_flush_bitmap_cache(st);
/* This makes sure the pipe has the latest scissor, etc values */
- st_validate_state( st );
+ st_validate_state( st, ST_PIPELINE_RENDER );
if (mask & BUFFER_BITS_COLOR) {
for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
st_flush_bitmap_cache(st);
- st_validate_state(st);
+ st_validate_state(st, ST_PIPELINE_RENDER);
/* Limit the size of the glDrawPixels to the max texture size.
* Strictly speaking, that's not correct but since we don't handle
st_flush_bitmap_cache(st);
- st_validate_state(st);
+ st_validate_state(st, ST_PIPELINE_RENDER);
if (type == GL_DEPTH_STENCIL) {
/* XXX make this more efficient */
st_flush_bitmap_cache(st);
- st_validate_state(st);
+ st_validate_state(st, ST_PIPELINE_RENDER);
/* determine if we need vertex color */
if (ctx->FragmentProgram._Current->Base.InputsRead & VARYING_BIT_COL0)
{
struct st_context *st = st_context(ctx);
- st_validate_state(st);
+ st_validate_state(st, ST_PIPELINE_RENDER);
if (st->pipe->get_sample_position)
st->pipe->get_sample_position(st->pipe, (unsigned) fb->Visual.samples,
draw_set_rasterize_stage(st->draw, st->rastpos_stage);
/* make sure everything's up to date */
- st_validate_state(st);
+ st_validate_state(st, ST_PIPELINE_RENDER);
/* This will get set only if rastpos_point(), above, gets called */
ctx->Current.RasterPosValid = GL_FALSE;
/* Validate state (to be sure we have up-to-date framebuffer surfaces)
* and flush the bitmap cache prior to reading. */
- st_validate_state(st);
+ st_validate_state(st, ST_PIPELINE_RENDER);
st_flush_bitmap_cache(st);
if (!st->prefer_blit_based_texture_transfer) {
st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
}
+ /* Invalidate render and compute pipelines. */
st->dirty.mesa |= new_state;
st->dirty.st |= ST_NEW_MESA;
+ st->dirty_cp.mesa |= new_state;
+ st->dirty_cp.st |= ST_NEW_MESA;
/* This is the only core Mesa module we depend upon.
* No longer use swrast, swsetup, tnl.
/* 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;
/* Create upload manager for vertex data for glBitmap, glDrawPixels,
* glClear, etc.
};
+/**
+ * Enumeration of state tracker pipelines.
+ */
+enum st_pipeline {
+ ST_PIPELINE_RENDER,
+ ST_PIPELINE_COMPUTE,
+};
+
struct st_context
{
char renderer[100];
struct st_state_flags dirty;
+ struct st_state_flags dirty_cp;
GLboolean vertdata_edgeflags;
GLboolean edgeflag_culls_prims;
/* Validate state. */
if (st->dirty.st || ctx->NewDriverState) {
- st_validate_state(st);
+ st_validate_state(st, ST_PIPELINE_RENDER);
#if 0
if (MESA_VERBOSE & VERBOSE_GLSL) {
/* Validate state. */
if (st->dirty.st || ctx->NewDriverState) {
- st_validate_state(st);
+ st_validate_state(st, ST_PIPELINE_RENDER);
}
if (st->vertex_array_out_of_memory) {
st_flush_bitmap_cache(st);
- st_validate_state(st);
+ st_validate_state(st, ST_PIPELINE_RENDER);
if (!index_bounds_valid)
vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index, nr_prims);