[Mesa-dev] [PATCH 09/70] mesa: store gl_program in gl_transform_feedback_object rather than gl_shader_program
Timothy Arceri
timothy.arceri at collabora.com
Tue Dec 20 10:37:19 UTC 2016
This will allow us to make the CurrentProgram array store gl_program which allows
us to do a bunch of simplifications.
---
src/mesa/drivers/dri/i965/gen6_sol.c | 3 +--
src/mesa/drivers/dri/i965/gen7_sol_state.c | 6 +++---
src/mesa/main/mtypes.h | 4 ++--
src/mesa/main/transformfeedback.c | 23 +++++++++++------------
src/mesa/state_tracker/st_cb_xformfb.c | 8 ++++----
5 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/gen6_sol.c b/src/mesa/drivers/dri/i965/gen6_sol.c
index 8c9ffc5..a683848 100644
--- a/src/mesa/drivers/dri/i965/gen6_sol.c
+++ b/src/mesa/drivers/dri/i965/gen6_sol.c
@@ -45,8 +45,7 @@ gen6_update_sol_surfaces(struct brw_context *brw)
if (xfb_active) {
/* BRW_NEW_TRANSFORM_FEEDBACK */
xfb_obj = ctx->TransformFeedback.CurrentObject;
- linked_xfb_info =
- xfb_obj->shader_program->xfb_program->sh.LinkedTransformFeedback;
+ linked_xfb_info = xfb_obj->program->sh.LinkedTransformFeedback;
}
for (int i = 0; i < BRW_MAX_SOL_BINDINGS; ++i) {
diff --git a/src/mesa/drivers/dri/i965/gen7_sol_state.c b/src/mesa/drivers/dri/i965/gen7_sol_state.c
index 5170f6a..c9f9f1f 100644
--- a/src/mesa/drivers/dri/i965/gen7_sol_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_sol_state.c
@@ -43,7 +43,7 @@ upload_3dstate_so_buffers(struct brw_context *brw)
struct gl_transform_feedback_object *xfb_obj =
ctx->TransformFeedback.CurrentObject;
const struct gl_transform_feedback_info *linked_xfb_info =
- xfb_obj->shader_program->xfb_program->sh.LinkedTransformFeedback;
+ xfb_obj->program->sh.LinkedTransformFeedback;
int i;
/* Set up the up to 4 output buffers. These are the ranges defined in the
@@ -103,7 +103,7 @@ gen7_upload_3dstate_so_decl_list(struct brw_context *brw,
struct gl_transform_feedback_object *xfb_obj =
ctx->TransformFeedback.CurrentObject;
const struct gl_transform_feedback_info *linked_xfb_info =
- xfb_obj->shader_program->xfb_program->sh.LinkedTransformFeedback;
+ xfb_obj->program->sh.LinkedTransformFeedback;
uint16_t so_decl[MAX_VERTEX_STREAMS][128];
int buffer_mask[MAX_VERTEX_STREAMS] = {0, 0, 0, 0};
int next_offset[MAX_VERTEX_STREAMS] = {0, 0, 0, 0};
@@ -229,7 +229,7 @@ upload_3dstate_streamout(struct brw_context *brw, bool active,
struct gl_transform_feedback_object *xfb_obj =
ctx->TransformFeedback.CurrentObject;
const struct gl_transform_feedback_info *linked_xfb_info =
- xfb_obj->shader_program->xfb_program->sh.LinkedTransformFeedback;
+ xfb_obj->program->sh.LinkedTransformFeedback;
uint32_t dw1 = 0, dw2 = 0, dw3 = 0, dw4 = 0;
int i;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 9b736bb..35dd813 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1730,12 +1730,12 @@ struct gl_transform_feedback_object
unsigned GlesRemainingPrims;
/**
- * The shader program active when BeginTransformFeedback() was called.
+ * The program active when BeginTransformFeedback() was called.
* When active and unpaused, this equals ctx->Shader.CurrentProgram[stage],
* where stage is the pipeline stage that is the source of data for
* transform feedback.
*/
- struct gl_shader_program *shader_program;
+ struct gl_program *program;
/** The feedback buffers */
GLuint BufferNames[MAX_FEEDBACK_BUFFERS];
diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c
index 2088c76..771223a 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -45,7 +45,7 @@
struct using_program_tuple
{
- struct gl_shader_program *shProg;
+ struct gl_program *prog;
bool found;
};
@@ -54,7 +54,7 @@ active_xfb_object_references_program(GLuint key, void *data, void *user_data)
{
struct using_program_tuple *callback_data = user_data;
struct gl_transform_feedback_object *obj = data;
- if (obj->Active && obj->shader_program == callback_data->shProg)
+ if (obj->Active && obj->program == callback_data->prog)
callback_data->found = true;
}
@@ -66,8 +66,8 @@ _mesa_transform_feedback_is_using_program(struct gl_context *ctx,
struct gl_shader_program *shProg)
{
struct using_program_tuple callback_data;
- callback_data.shProg = shProg;
callback_data.found = false;
+ callback_data.prog = shProg->xfb_program;
_mesa_HashWalk(ctx->TransformFeedback.Objects,
active_xfb_object_references_program, &callback_data);
@@ -379,18 +379,18 @@ _mesa_compute_max_transform_feedback_vertices(struct gl_context *ctx,
/**
* Figure out which stage of the pipeline is the source of transform feedback
- * data given the current context state, and return its gl_shader_program.
+ * data given the current context state, and return its gl_program.
*
* If no active program can generate transform feedback data (i.e. no vertex
* shader is active), returns NULL.
*/
-static struct gl_shader_program *
+static struct gl_program *
get_xfb_source(struct gl_context *ctx)
{
int i;
for (i = MESA_SHADER_GEOMETRY; i >= MESA_SHADER_VERTEX; i--) {
if (ctx->_Shader->CurrentProgram[i] != NULL)
- return ctx->_Shader->CurrentProgram[i];
+ return ctx->_Shader->CurrentProgram[i]->_LinkedShaders[i]->Program;
}
return NULL;
}
@@ -401,7 +401,6 @@ _mesa_BeginTransformFeedback(GLenum mode)
{
struct gl_transform_feedback_object *obj;
struct gl_transform_feedback_info *info = NULL;
- struct gl_shader_program *source;
GLuint i;
unsigned vertices_per_prim;
GET_CURRENT_CONTEXT(ctx);
@@ -411,14 +410,14 @@ _mesa_BeginTransformFeedback(GLenum mode)
/* Figure out what pipeline stage is the source of data for transform
* feedback.
*/
- source = get_xfb_source(ctx);
+ struct gl_program *source = get_xfb_source(ctx);
if (source == NULL) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glBeginTransformFeedback(no program active)");
return;
}
- info = source->xfb_program->sh.LinkedTransformFeedback;
+ info = source->sh.LinkedTransformFeedback;
if (info->NumOutputs == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
@@ -478,9 +477,9 @@ _mesa_BeginTransformFeedback(GLenum mode)
obj->GlesRemainingPrims = max_vertices / vertices_per_prim;
}
- if (obj->shader_program != source) {
+ if (obj->program != source) {
ctx->NewDriverState |= ctx->DriverFlags.NewTransformFeedbackProg;
- obj->shader_program = source;
+ obj->program = source;
}
assert(ctx->Driver.BeginTransformFeedback);
@@ -1199,7 +1198,7 @@ _mesa_ResumeTransformFeedback(void)
* the program object being used by the current transform feedback object
* is not active."
*/
- if (obj->shader_program != get_xfb_source(ctx)) {
+ if (obj->program != get_xfb_source(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glResumeTransformFeedback(wrong program bound)");
return;
diff --git a/src/mesa/state_tracker/st_cb_xformfb.c b/src/mesa/state_tracker/st_cb_xformfb.c
index bbc9e03..4be9a7f 100644
--- a/src/mesa/state_tracker/st_cb_xformfb.c
+++ b/src/mesa/state_tracker/st_cb_xformfb.c
@@ -124,8 +124,8 @@ st_begin_transform_feedback(struct gl_context *ctx, GLenum mode,
struct st_buffer_object *bo = st_buffer_object(sobj->base.Buffers[i]);
if (bo && bo->buffer) {
- unsigned stream = obj->shader_program->xfb_program->
- sh.LinkedTransformFeedback->Buffers[i].Stream;
+ unsigned stream = obj->program->sh.LinkedTransformFeedback->
+ Buffers[i].Stream;
/* Check whether we need to recreate the target. */
if (!sobj->targets[i] ||
@@ -203,8 +203,8 @@ st_end_transform_feedback(struct gl_context *ctx,
pipe_so_target_reference(&sobj->draw_count[i], NULL);
for (i = 0; i < ARRAY_SIZE(sobj->targets); i++) {
- unsigned stream = obj->shader_program->xfb_program->
- sh.LinkedTransformFeedback->Buffers[i].Stream;
+ unsigned stream = obj->program->sh.LinkedTransformFeedback->
+ Buffers[i].Stream;
/* Is it not bound or already set for this stream? */
if (!sobj->targets[i] || sobj->draw_count[stream])
--
2.9.3
More information about the mesa-dev
mailing list