st/mesa: simplify update_constants functions
Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com> Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
parent
bb6e851a1e
commit
a159d6ed20
|
@ -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,
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue