summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2016-01-05 21:20:06 +0100
committerSamuel Pitoiset <[email protected]>2016-02-13 15:51:17 +0100
commit08c46025c87654fbc885136a2c8cc4cce902dd37 (patch)
treef90558228e20c56362c3cfa2adf839e02c10da41
parenta8328e3a50169c3c74656df7f63f56f061d9e751 (diff)
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 <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
-rw-r--r--src/mesa/state_tracker/st_atom.c48
-rw-r--r--src/mesa/state_tracker/st_atom.h5
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c2
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c2
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c4
-rw-r--r--src/mesa/state_tracker/st_cb_drawtex.c2
-rw-r--r--src/mesa/state_tracker/st_cb_msaa.c2
-rw-r--r--src/mesa/state_tracker/st_cb_rasterpos.c2
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c2
-rw-r--r--src/mesa/state_tracker/st_context.c6
-rw-r--r--src/mesa/state_tracker/st_context.h9
-rw-r--r--src/mesa/state_tracker/st_draw.c4
-rw-r--r--src/mesa/state_tracker/st_draw_feedback.c2
13 files changed, 69 insertions, 21 deletions
diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c
index 4b89ade1b15..2d89512e854 100644
--- a/src/mesa/state_tracker/st_atom.c
+++ b/src/mesa/state_tracker/st_atom.c
@@ -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 );
}
diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h
index 3a9153c80cb..77e2163e467 100644
--- a/src/mesa/state_tracker/st_atom.h
+++ b/src/mesa/state_tracker/st_atom.h
@@ -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;
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index 627b8cbd598..2b2792e2be6 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -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))
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 7b6d10e76b1..1e965b182ea 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -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++) {
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index fd58886a782..b910d71b735 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -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 */
diff --git a/src/mesa/state_tracker/st_cb_drawtex.c b/src/mesa/state_tracker/st_cb_drawtex.c
index e6ab77fb521..c087266dbf4 100644
--- a/src/mesa/state_tracker/st_cb_drawtex.c
+++ b/src/mesa/state_tracker/st_cb_drawtex.c
@@ -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)
diff --git a/src/mesa/state_tracker/st_cb_msaa.c b/src/mesa/state_tracker/st_cb_msaa.c
index e9955b62b8f..d581f2121b0 100644
--- a/src/mesa/state_tracker/st_cb_msaa.c
+++ b/src/mesa/state_tracker/st_cb_msaa.c
@@ -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,
diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c
index 747b41464ae..eec72f8a412 100644
--- a/src/mesa/state_tracker/st_cb_rasterpos.c
+++ b/src/mesa/state_tracker/st_cb_rasterpos.c
@@ -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;
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index bb36e6969d6..6dc2661b524 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -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) {
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 9016846b148..b73b0abd55a 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -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.
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 9a80f4bae70..b8f7aa9909f 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -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;
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 10e294cd147..80139861fd0 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -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) {
diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c
index b6e6dea5b27..9f48945d74d 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -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);