mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 16:08:04 +02:00
st/mesa: don't use cso_context to set const bufs, sampler views and images
These cso_context functions will be removed and they are no longer needed by st/mesa. They also cause CPU overhead because they save states. Reviewed-by: Eric Anholt <eric@anholt.net> Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com> Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8180>
This commit is contained in:
parent
d107eef04f
commit
4c52aba41e
3 changed files with 30 additions and 16 deletions
|
|
@ -102,6 +102,7 @@ st_upload_constants(struct st_context *st, struct gl_program *prog)
|
|||
cb.buffer_size = paramBytes;
|
||||
|
||||
if (st->prefer_real_buffer_in_constbuf0) {
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
uint32_t *ptr;
|
||||
/* fetch_state always stores 4 components (16 bytes) per matrix row,
|
||||
* but matrix rows are sometimes allocated partially, so add 12
|
||||
|
|
@ -121,7 +122,7 @@ st_upload_constants(struct st_context *st, struct gl_program *prog)
|
|||
_mesa_upload_state_parameters(st->ctx, params, ptr);
|
||||
|
||||
u_upload_unmap(st->pipe->const_uploader);
|
||||
cso_set_constant_buffer(st->cso_context, shader_type, 0, &cb);
|
||||
pipe->set_constant_buffer(pipe, shader_type, 0, &cb);
|
||||
pipe_resource_reference(&cb.buffer, NULL);
|
||||
|
||||
/* Set inlinable constants. This is more involved because state
|
||||
|
|
@ -131,7 +132,6 @@ st_upload_constants(struct st_context *st, struct gl_program *prog)
|
|||
*/
|
||||
unsigned num_inlinable_uniforms = prog->info.num_inlinable_uniforms;
|
||||
if (num_inlinable_uniforms) {
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
uint32_t values[MAX_INLINABLE_UNIFORMS];
|
||||
gl_constant_value *constbuf = params->ParameterValues;
|
||||
bool loaded_state_vars = false;
|
||||
|
|
@ -152,6 +152,8 @@ st_upload_constants(struct st_context *st, struct gl_program *prog)
|
|||
values);
|
||||
}
|
||||
} else {
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
|
||||
cb.user_buffer = params->ParameterValues;
|
||||
|
||||
/* Update the constants which come from fixed-function state, such as
|
||||
|
|
@ -160,12 +162,11 @@ st_upload_constants(struct st_context *st, struct gl_program *prog)
|
|||
if (params->StateFlags)
|
||||
_mesa_load_state_parameters(st->ctx, params);
|
||||
|
||||
cso_set_constant_buffer(st->cso_context, shader_type, 0, &cb);
|
||||
pipe->set_constant_buffer(pipe, shader_type, 0, &cb);
|
||||
|
||||
/* Set inlinable constants. */
|
||||
unsigned num_inlinable_uniforms = prog->info.num_inlinable_uniforms;
|
||||
if (num_inlinable_uniforms) {
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
uint32_t values[MAX_INLINABLE_UNIFORMS];
|
||||
gl_constant_value *constbuf = params->ParameterValues;
|
||||
|
||||
|
|
@ -181,7 +182,9 @@ st_upload_constants(struct st_context *st, struct gl_program *prog)
|
|||
st->state.constbuf0_enabled_shader_mask |= 1 << shader_type;
|
||||
} else if (st->state.constbuf0_enabled_shader_mask & (1 << shader_type)) {
|
||||
/* Unbind. */
|
||||
cso_set_constant_buffer(st->cso_context, shader_type, 0, NULL);
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
|
||||
pipe->set_constant_buffer(pipe, shader_type, 0, NULL);
|
||||
st->state.constbuf0_enabled_shader_mask &= ~(1 << shader_type);
|
||||
}
|
||||
}
|
||||
|
|
@ -260,6 +263,8 @@ st_bind_ubos(struct st_context *st, struct gl_program *prog,
|
|||
if (!prog)
|
||||
return;
|
||||
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
|
||||
for (i = 0; i < prog->sh.NumUniformBlocks; i++) {
|
||||
struct gl_buffer_binding *binding;
|
||||
struct st_buffer_object *st_obj;
|
||||
|
|
@ -285,7 +290,7 @@ st_bind_ubos(struct st_context *st, struct gl_program *prog,
|
|||
cb.buffer_size = 0;
|
||||
}
|
||||
|
||||
cso_set_constant_buffer(st->cso_context, shader_type, 1 + i, &cb);
|
||||
pipe->set_constant_buffer(pipe, shader_type, 1 + i, &cb);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -174,13 +174,16 @@ st_bind_images(struct st_context *st, struct gl_program *prog,
|
|||
st_convert_image_from_unit(st, img, prog->sh.ImageUnits[i],
|
||||
prog->sh.ImageAccess[i]);
|
||||
}
|
||||
cso_set_shader_images(st->cso_context, shader_type, 0,
|
||||
prog->info.num_images, images);
|
||||
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
pipe->set_shader_images(pipe, shader_type, 0,
|
||||
prog->info.num_images, images);
|
||||
/* clear out any stale shader images */
|
||||
if (prog->info.num_images < c->MaxImageUniforms)
|
||||
cso_set_shader_images(
|
||||
st->cso_context, shader_type, prog->info.num_images,
|
||||
c->MaxImageUniforms - prog->info.num_images, NULL);
|
||||
if (prog->info.num_images < c->MaxImageUniforms) {
|
||||
pipe->set_shader_images(pipe, shader_type, prog->info.num_images,
|
||||
c->MaxImageUniforms - prog->info.num_images,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void st_bind_vs_images(struct st_context *st)
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ update_textures(struct st_context *st,
|
|||
const struct gl_program *prog,
|
||||
struct pipe_sampler_view **sampler_views)
|
||||
{
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
const GLuint old_max = st->state.num_sampler_views[shader_stage];
|
||||
GLbitfield samplers_used = prog->SamplersUsed;
|
||||
GLbitfield texel_fetch_samplers = prog->info.textures_used_by_txf;
|
||||
|
|
@ -244,10 +245,15 @@ update_textures(struct st_context *st,
|
|||
num_textures = MAX2(num_textures, extra + 1);
|
||||
}
|
||||
|
||||
cso_set_sampler_views(st->cso_context,
|
||||
shader_stage,
|
||||
num_textures,
|
||||
sampler_views);
|
||||
/* Unbind old textures. */
|
||||
unsigned old_num_textures = st->state.num_sampler_views[shader_stage];
|
||||
unsigned num_unbind = old_num_textures > num_textures ?
|
||||
old_num_textures - num_textures : 0;
|
||||
for (unsigned i = 0; i < num_unbind; i++)
|
||||
pipe_sampler_view_reference(&sampler_views[num_textures + i], NULL);
|
||||
|
||||
pipe->set_sampler_views(pipe, shader_stage, 0, num_textures + num_unbind,
|
||||
sampler_views);
|
||||
st->state.num_sampler_views[shader_stage] = num_textures;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue