aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-11-03 16:00:37 +1100
committerTimothy Arceri <[email protected]>2016-12-30 10:57:16 +1100
commit700bc94dcebf4257740483d2ba467b138234fa1a (patch)
treeda45fbee155479d7692bbe68c534a3c1c67385b3 /src/mesa
parent31c04e4e229bec4e059779b4034cf597ceeadf97 (diff)
mesa/glsl: move LinkedTransformFeedback from gl_shader_program to gl_program
This will help allow us to store gl_program in the CurrentProgram array rather than gl_shader_program which will allow a bunch of simplifications. Note that we make LinkedTransformFeedback a pointer so we don't waste memory creating a struct for each stage. We also store a pointer to the gl_program that will contain the pointer in gl_shader_program so we can get easy access to the correct stage. Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/brw_ff_gs.c2
-rw-r--r--src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp2
-rw-r--r--src/mesa/drivers/dri/i965/gen6_sol.c9
-rw-r--r--src/mesa/drivers/dri/i965/gen7_sol_state.c6
-rw-r--r--src/mesa/main/mtypes.h6
-rw-r--r--src/mesa/main/shader_query.cpp8
-rw-r--r--src/mesa/main/transformfeedback.c2
-rw-r--r--src/mesa/state_tracker/st_cb_xformfb.c8
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp2
-rw-r--r--src/mesa/state_tracker/st_program.c2
10 files changed, 25 insertions, 22 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_ff_gs.c b/src/mesa/drivers/dri/i965/brw_ff_gs.c
index c7129393e54..4934af3fd39 100644
--- a/src/mesa/drivers/dri/i965/brw_ff_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_ff_gs.c
@@ -198,7 +198,7 @@ brw_ff_gs_populate_key(struct brw_context *brw,
const struct gl_shader_program *shaderprog =
ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
const struct gl_transform_feedback_info *linked_xfb_info =
- &shaderprog->LinkedTransformFeedback;
+ shaderprog->xfb_program->sh.LinkedTransformFeedback;
int i;
/* Make sure that the VUE slots won't overflow the unsigned chars in
diff --git a/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp b/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp
index 7254729f41c..4bd37889817 100644
--- a/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/gen6_gs_visitor.cpp
@@ -534,7 +534,7 @@ gen6_gs_visitor::xfb_setup()
};
const struct gl_transform_feedback_info *linked_xfb_info =
- &this->shader_prog->LinkedTransformFeedback;
+ this->shader_prog->xfb_program->sh.LinkedTransformFeedback;
int i;
/* Make sure that the VUE slots won't overflow the unsigned chars in
diff --git a/src/mesa/drivers/dri/i965/gen6_sol.c b/src/mesa/drivers/dri/i965/gen6_sol.c
index 6574749079c..f6a183ad169 100644
--- a/src/mesa/drivers/dri/i965/gen6_sol.c
+++ b/src/mesa/drivers/dri/i965/gen6_sol.c
@@ -45,7 +45,8 @@ 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->LinkedTransformFeedback;
+ linked_xfb_info =
+ xfb_obj->shader_program->xfb_program->sh.LinkedTransformFeedback;
}
for (int i = 0; i < BRW_MAX_SOL_BINDINGS; ++i) {
@@ -116,7 +117,7 @@ brw_gs_upload_binding_table(struct brw_context *brw)
if (shaderprog) {
/* Skip making a binding table if we don't have anything to put in it */
const struct gl_transform_feedback_info *linked_xfb_info =
- &shaderprog->LinkedTransformFeedback;
+ shaderprog->xfb_program->sh.LinkedTransformFeedback;
need_binding_table = linked_xfb_info->NumOutputs > 0;
}
if (!need_binding_table) {
@@ -145,7 +146,7 @@ brw_gs_upload_binding_table(struct brw_context *brw)
/* Skip making a binding table if we don't have anything to put in it */
struct brw_stage_prog_data *prog_data = brw->gs.base.prog_data;
const struct gl_transform_feedback_info *linked_xfb_info =
- &shaderprog->LinkedTransformFeedback;
+ shaderprog->xfb_program->sh.LinkedTransformFeedback;
need_binding_table = linked_xfb_info->NumOutputs > 0 ||
prog_data->binding_table.size_bytes > 0;
}
@@ -241,7 +242,7 @@ brw_begin_transform_feedback(struct gl_context *ctx, GLenum mode,
shaderprog =
ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
}
- linked_xfb_info = &shaderprog->LinkedTransformFeedback;
+ linked_xfb_info = shaderprog->xfb_program->sh.LinkedTransformFeedback;
/* Compute the maximum number of vertices that we can write without
* overflowing any of the buffers currently being used for feedback.
diff --git a/src/mesa/drivers/dri/i965/gen7_sol_state.c b/src/mesa/drivers/dri/i965/gen7_sol_state.c
index 17752742d46..5170f6a16ea 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->LinkedTransformFeedback;
+ xfb_obj->shader_program->xfb_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->LinkedTransformFeedback;
+ xfb_obj->shader_program->xfb_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->LinkedTransformFeedback;
+ xfb_obj->shader_program->xfb_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 8842791913e..9b736bb9a3f 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1950,6 +1950,9 @@ struct gl_program
struct {
struct gl_active_atomic_buffer **AtomicBuffers;
+ /** Post-link transform feedback info. */
+ struct gl_transform_feedback_info *LinkedTransformFeedback;
+
/**
* Number of types for subroutine uniforms.
*/
@@ -2737,8 +2740,7 @@ struct gl_shader_program
GLchar **VaryingNames; /**< Array [NumVarying] of char * */
} TransformFeedback;
- /** Post-link transform feedback info. */
- struct gl_transform_feedback_info LinkedTransformFeedback;
+ struct gl_program *xfb_program;
/** Post-link gl_FragDepth layout for ARB_conservative_depth. */
enum gl_frag_depth_layout FragDepthLayout;
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 2f157733a48..0f4b2829ce4 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -1041,10 +1041,10 @@ get_buffer_property(struct gl_shader_program *shProg,
*val = RESOURCE_XFB(res)->NumVaryings;
return 1;
case GL_ACTIVE_VARIABLES:
- int i = 0;
- for ( ; i < shProg->LinkedTransformFeedback.NumVarying; i++) {
- unsigned index =
- shProg->LinkedTransformFeedback.Varyings[i].BufferIndex;
+ struct gl_transform_feedback_info *linked_xfb =
+ shProg->xfb_program->sh.LinkedTransformFeedback;
+ for (int i = 0; i < linked_xfb->NumVarying; i++) {
+ unsigned index = linked_xfb->Varyings[i].BufferIndex;
struct gl_program_resource *buf_res =
_mesa_program_resource_find_index(shProg,
GL_TRANSFORM_FEEDBACK_BUFFER,
diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c
index 738d63eee37..2088c76e5ea 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -418,7 +418,7 @@ _mesa_BeginTransformFeedback(GLenum mode)
return;
}
- info = &source->LinkedTransformFeedback;
+ info = source->xfb_program->sh.LinkedTransformFeedback;
if (info->NumOutputs == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
diff --git a/src/mesa/state_tracker/st_cb_xformfb.c b/src/mesa/state_tracker/st_cb_xformfb.c
index a5cf3dfd5a9..bbc9e03dd07 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->LinkedTransformFeedback.Buffers[i].Stream;
+ unsigned stream = obj->shader_program->xfb_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->LinkedTransformFeedback.Buffers[i].Stream;
+ unsigned stream = obj->shader_program->xfb_program->
+ sh.LinkedTransformFeedback->Buffers[i].Stream;
/* Is it not bound or already set for this stream? */
if (!sobj->targets[i] || sobj->draw_count[stream])
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index c9ebb5ade8f..95992965ed8 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6919,7 +6919,7 @@ st_translate_stream_output_info(glsl_to_tgsi_visitor *glsl_to_tgsi,
struct pipe_stream_output_info *so)
{
struct gl_transform_feedback_info *info =
- &glsl_to_tgsi->shader_program->LinkedTransformFeedback;
+ glsl_to_tgsi->shader_program->xfb_program->sh.LinkedTransformFeedback;
st_translate_stream_output_info2(info, outputMapping, so);
}
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index bf1503197e0..e9dd5846698 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -390,7 +390,7 @@ st_translate_vertex_program(struct st_context *st,
stvp->tgsi.type = PIPE_SHADER_IR_NIR;
stvp->tgsi.ir.nir = nir;
- st_translate_stream_output_info2(&stvp->shader_program->LinkedTransformFeedback,
+ st_translate_stream_output_info2(stvp->shader_program->xfb_program->sh.LinkedTransformFeedback,
stvp->result_to_output,
&stvp->tgsi.stream_output);
return true;