Mesa (master): st/mesa: don't use cso_context to set const bufs, sampler views and images
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jan 15 10:07:39 UTC 2021
Module: Mesa
Branch: master
Commit: 4c52aba41e19d38e9e51005b0408b06b012f8f83
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4c52aba41e19d38e9e51005b0408b06b012f8f83
Author: Marek Olšák <marek.olsak at amd.com>
Date: Sun Dec 20 03:01:37 2020 -0500
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 at anholt.net>
Reviewed-by: Zoltán Böszörményi <zboszor at gmail.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8180>
---
src/mesa/state_tracker/st_atom_constbuf.c | 17 +++++++++++------
src/mesa/state_tracker/st_atom_image.c | 15 +++++++++------
src/mesa/state_tracker/st_atom_texture.c | 14 ++++++++++----
3 files changed, 30 insertions(+), 16 deletions(-)
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
index 5907ed6cee4..bb8d16f1dac 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -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);
}
}
diff --git a/src/mesa/state_tracker/st_atom_image.c b/src/mesa/state_tracker/st_atom_image.c
index a7fd17535a5..f4c0a1ad4cf 100644
--- a/src/mesa/state_tracker/st_atom_image.c
+++ b/src/mesa/state_tracker/st_atom_image.c
@@ -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)
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index b3010c8c02b..90c3007d8f5 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -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;
}
More information about the mesa-commit
mailing list