summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2017-04-30 16:20:10 +0200
committerMarek Olšák <[email protected]>2017-05-08 18:32:00 +0200
commita159d6ed20e3487df37c0d447564d4690d59ccc4 (patch)
tree08ac6728fec44fe6fc4ac782873f2a136c6d8834 /src/mesa
parentbb6e851a1e52599e346112837b93686a90817901 (diff)
st/mesa: simplify update_constants functions
Tested-by: Edmondo Tommasina <[email protected]> Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/state_tracker/st_atom_constbuf.c45
-rw-r--r--src/mesa/state_tracker/st_atom_constbuf.h4
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c2
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c4
4 files changed, 17 insertions, 38 deletions
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
index 6cbfba7e9c0..0c669940660 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -51,12 +51,11 @@
/**
* Pass the given program parameters to the graphics pipe as a
* constant buffer.
- * \param shader_type either PIPE_SHADER_VERTEX or PIPE_SHADER_FRAGMENT
*/
-void st_upload_constants( struct st_context *st,
- struct gl_program_parameter_list *params,
- gl_shader_stage stage)
+void st_upload_constants(struct st_context *st, struct gl_program *prog)
{
+ gl_shader_stage stage = prog->info.stage;
+ struct gl_program_parameter_list *params = prog->Parameters;
enum pipe_shader_type shader_type = st_shader_stage_to_ptarget(stage);
assert(shader_type == PIPE_SHADER_VERTEX ||
@@ -141,10 +140,7 @@ void st_upload_constants( struct st_context *st,
*/
void st_update_vs_constants(struct st_context *st )
{
- struct st_vertex_program *vp = st->vp;
- struct gl_program_parameter_list *params = vp->Base.Parameters;
-
- st_upload_constants( st, params, MESA_SHADER_VERTEX );
+ st_upload_constants(st, &st->vp->Base);
}
/**
@@ -152,10 +148,7 @@ void st_update_vs_constants(struct st_context *st )
*/
void st_update_fs_constants(struct st_context *st )
{
- struct st_fragment_program *fp = st->fp;
- struct gl_program_parameter_list *params = fp->Base.Parameters;
-
- st_upload_constants( st, params, MESA_SHADER_FRAGMENT );
+ st_upload_constants(st, &st->fp->Base);
}
@@ -164,12 +157,9 @@ void st_update_fs_constants(struct st_context *st )
void st_update_gs_constants(struct st_context *st )
{
struct st_common_program *gp = st->gp;
- struct gl_program_parameter_list *params;
- if (gp) {
- params = gp->Base.Parameters;
- st_upload_constants( st, params, MESA_SHADER_GEOMETRY );
- }
+ if (gp)
+ st_upload_constants(st, &gp->Base);
}
/* Tessellation control shader:
@@ -177,12 +167,9 @@ void st_update_gs_constants(struct st_context *st )
void st_update_tcs_constants(struct st_context *st )
{
struct st_common_program *tcp = st->tcp;
- struct gl_program_parameter_list *params;
- if (tcp) {
- params = tcp->Base.Parameters;
- st_upload_constants( st, params, MESA_SHADER_TESS_CTRL );
- }
+ if (tcp)
+ st_upload_constants(st, &tcp->Base);
}
/* Tessellation evaluation shader:
@@ -190,12 +177,9 @@ void st_update_tcs_constants(struct st_context *st )
void st_update_tes_constants(struct st_context *st )
{
struct st_common_program *tep = st->tep;
- struct gl_program_parameter_list *params;
- if (tep) {
- params = tep->Base.Parameters;
- st_upload_constants( st, params, MESA_SHADER_TESS_EVAL );
- }
+ if (tep)
+ st_upload_constants(st, &tep->Base);
}
/* Compute shader:
@@ -203,12 +187,9 @@ void st_update_tes_constants(struct st_context *st )
void st_update_cs_constants(struct st_context *st )
{
struct st_compute_program *cp = st->cp;
- struct gl_program_parameter_list *params;
- if (cp) {
- params = cp->Base.Parameters;
- st_upload_constants( st, params, MESA_SHADER_COMPUTE );
- }
+ if (cp)
+ st_upload_constants(st, &cp->Base);
}
static void st_bind_ubos(struct st_context *st, struct gl_program *prog,
diff --git a/src/mesa/state_tracker/st_atom_constbuf.h b/src/mesa/state_tracker/st_atom_constbuf.h
index df60a627624..e810a24fe60 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.h
+++ b/src/mesa/state_tracker/st_atom_constbuf.h
@@ -35,9 +35,7 @@ struct gl_program_parameter_list;
struct st_context;
-void st_upload_constants( struct st_context *st,
- struct gl_program_parameter_list *params,
- gl_shader_stage stage);
+void st_upload_constants(struct st_context *st, struct gl_program *prog);
#endif /* ST_ATOM_CONSTBUF_H */
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index e0745f4812b..30e23fa259f 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -191,7 +191,7 @@ setup_render_state(struct gl_context *ctx,
GLfloat colorSave[4];
COPY_4V(colorSave, ctx->Current.Attrib[VERT_ATTRIB_COLOR0]);
COPY_4V(ctx->Current.Attrib[VERT_ATTRIB_COLOR0], color);
- st_upload_constants(st, st->fp->Base.Parameters, MESA_SHADER_FRAGMENT);
+ st_upload_constants(st, &st->fp->Base);
COPY_4V(ctx->Current.Attrib[VERT_ATTRIB_COLOR0], colorSave);
}
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index bc4e5338fda..33d10f67e26 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -1123,7 +1123,7 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
/* compiling a new fragment shader variant added new state constants
* into the constant buffer, we need to update them
*/
- st_upload_constants(st, st->fp->Base.Parameters, MESA_SHADER_FRAGMENT);
+ st_upload_constants(st, &st->fp->Base);
}
/* Put glDrawPixels image into a texture */
@@ -1486,7 +1486,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
/* compiling a new fragment shader variant added new state constants
* into the constant buffer, we need to update them
*/
- st_upload_constants(st, st->fp->Base.Parameters, MESA_SHADER_FRAGMENT);
+ st_upload_constants(st, &st->fp->Base);
}
else {
assert(type == GL_DEPTH);