X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fstate_tracker%2Fst_atom_constbuf.c;h=05667a743053b59b2a751fd7b8a3cc220dab67e5;hb=3ea6fdfdf1a6aed5c924cfe52aa0d543c6d58aa3;hp=28439103b23c0d39a8de4007a2301fce3cc81df1;hpb=b0427bedde80e3189524651a327235bdfddbc613;p=mesa.git diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index 28439103b23..05667a74305 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -32,8 +32,8 @@ */ #include "main/imports.h" -#include "shader/prog_parameter.h" -#include "shader/prog_print.h" +#include "program/prog_parameter.h" +#include "program/prog_print.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" @@ -56,24 +56,31 @@ void st_upload_constants( struct st_context *st, unsigned shader_type) { struct pipe_context *pipe = st->pipe; - struct pipe_resource **cbuf = &st->state.constants[shader_type]; assert(shader_type == PIPE_SHADER_VERTEX || - shader_type == PIPE_SHADER_FRAGMENT); + shader_type == PIPE_SHADER_FRAGMENT || + shader_type == PIPE_SHADER_GEOMETRY); /* update constants */ if (params && params->NumParameters) { + struct pipe_resource *cbuf; const uint paramBytes = params->NumParameters * sizeof(GLfloat) * 4; + /* Update the constants which come from fixed-function state, such as + * transformation matrices, fog factors, etc. The rest of the values in + * the parameters list are explicitly set by the user with glUniform, + * glProgramParameter(), etc. + */ _mesa_load_state_parameters(st->ctx, params); /* We always need to get a new buffer, to keep the drivers simple and * avoid gratuitous rendering synchronization. + * Let's use a user buffer to avoid an unnecessary copy. */ - pipe_resource_reference(cbuf, NULL ); - *cbuf = pipe_buffer_create(pipe->screen, - PIPE_BIND_CONSTANT_BUFFER, - paramBytes ); + cbuf = pipe_user_buffer_create(pipe->screen, + params->ParameterValues, + paramBytes, + PIPE_BIND_CONSTANT_BUFFER); if (ST_DEBUG & DEBUG_CONSTANTS) { debug_printf("%s(shader=%d, numParams=%d, stateFlags=0x%x)\n", @@ -82,15 +89,16 @@ void st_upload_constants( struct st_context *st, _mesa_print_parameter_list(params); } - /* load Mesa constants into the constant buffer */ - pipe_buffer_write(st->pipe, *cbuf, - 0, paramBytes, - params->ParameterValues); + st->pipe->set_constant_buffer(st->pipe, shader_type, 0, cbuf); + pipe_resource_reference(&cbuf, NULL); - st->pipe->set_constant_buffer(st->pipe, shader_type, 0, *cbuf); + st->state.constants[shader_type].ptr = params->ParameterValues; + st->state.constants[shader_type].size = paramBytes; } - else { - st->constants.tracked_state[shader_type].dirty.mesa = 0x0; + else if (st->state.constants[shader_type].ptr) { + st->state.constants[shader_type].ptr = NULL; + st->state.constants[shader_type].size = 0; + st->pipe->set_constant_buffer(st->pipe, shader_type, 0, NULL); } } @@ -139,3 +147,24 @@ const struct st_tracked_state st_update_fs_constants = { update_fs_constants /* update */ }; +/* Geometry shader: + */ +static void update_gs_constants(struct st_context *st ) +{ + struct st_geometry_program *gp = st->gp; + struct gl_program_parameter_list *params; + + if (gp) { + params = gp->Base.Base.Parameters; + st_upload_constants( st, params, PIPE_SHADER_GEOMETRY ); + } +} + +const struct st_tracked_state st_update_gs_constants = { + "st_update_gs_constants", /* name */ + { /* dirty */ + (_NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS), /* mesa */ + ST_NEW_GEOMETRY_PROGRAM, /* st */ + }, + update_gs_constants /* update */ +};