st/mesa: add a second pipeline for compute

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 commit is contained in:
Samuel Pitoiset 2016-01-05 21:20:06 +01:00
parent a8328e3a50
commit 08c46025c8
13 changed files with 69 additions and 21 deletions

View file

@ -38,9 +38,9 @@
/**
* 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,
@ -93,6 +93,15 @@ static const struct st_tracked_state *atoms[] =
};
/**
* 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 */
@ -178,20 +187,41 @@ static void check_attrib_edgeflag(struct st_context *st)
* 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;
@ -211,7 +241,7 @@ void st_validate_state( struct st_context *st )
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;
@ -242,7 +272,7 @@ void st_validate_state( struct st_context *st )
}
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 );
}

View file

@ -36,6 +36,9 @@
#include "main/glheader.h"
#include "state_tracker/st_api.h"
#include "state_tracker/st_context.h"
struct st_context;
struct st_tracked_state;
@ -43,7 +46,7 @@ void st_init_atoms( struct st_context *st );
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;

View file

@ -713,7 +713,7 @@ st_Bitmap(struct gl_context *ctx, GLint x, GLint y,
* 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))

View file

@ -470,7 +470,7 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
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++) {

View file

@ -1074,7 +1074,7 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
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
@ -1436,7 +1436,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
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 */

View file

@ -116,7 +116,7 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
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)

View file

@ -44,7 +44,7 @@ st_GetSamplePosition(struct gl_context *ctx,
{
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,

View file

@ -248,7 +248,7 @@ st_RasterPos(struct gl_context *ctx, const GLfloat v[4])
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;

View file

@ -104,7 +104,7 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y,
/* 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) {

View file

@ -138,8 +138,11 @@ void st_invalidate_state(struct gl_context * ctx, GLbitfield new_state)
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.
@ -208,8 +211,11 @@ 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;
/* Create upload manager for vertex data for glBitmap, glDrawPixels,
* glClear, etc.

View file

@ -78,6 +78,14 @@ struct st_tracked_state {
};
/**
* Enumeration of state tracker pipelines.
*/
enum st_pipeline {
ST_PIPELINE_RENDER,
ST_PIPELINE_COMPUTE,
};
struct st_context
{
@ -153,6 +161,7 @@ struct st_context
char renderer[100];
struct st_state_flags dirty;
struct st_state_flags dirty_cp;
GLboolean vertdata_edgeflags;
GLboolean edgeflag_culls_prims;

View file

@ -202,7 +202,7 @@ st_draw_vbo(struct gl_context *ctx,
/* 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) {
@ -315,7 +315,7 @@ st_indirect_draw_vbo(struct gl_context *ctx,
/* 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) {

View file

@ -140,7 +140,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
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);