[Mesa-dev] [PATCH 07/10] st/mesa: assume that user constant buffers are always supported
Marek Olšák
maraeo at gmail.com
Wed Jan 10 19:49:31 UTC 2018
From: Marek Olšák <marek.olsak at amd.com>
---
src/mesa/state_tracker/st_atom_constbuf.c | 19 +++----------------
src/mesa/state_tracker/st_context.c | 2 --
src/mesa/state_tracker/st_context.h | 1 -
src/mesa/state_tracker/st_pbo.c | 18 +++---------------
4 files changed, 6 insertions(+), 34 deletions(-)
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
index 497d33f..0a6b23a 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -94,36 +94,23 @@ void st_upload_constants(struct st_context *st, struct gl_program *prog)
/* 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.
*/
if (params->StateFlags)
_mesa_load_state_parameters(st->ctx, params);
_mesa_shader_write_subroutine_indices(st->ctx, stage);
- /* 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.
- */
- if (!st->has_user_constbuf) {
- cb.buffer = NULL;
- cb.user_buffer = NULL;
- u_upload_data(st->pipe->const_uploader, 0, paramBytes,
- st->ctx->Const.UniformBufferOffsetAlignment,
- params->ParameterValues, &cb.buffer_offset, &cb.buffer);
- u_upload_unmap(st->pipe->const_uploader);
- } else {
- cb.buffer = NULL;
- cb.user_buffer = params->ParameterValues;
- cb.buffer_offset = 0;
- }
+ cb.buffer = NULL;
+ cb.user_buffer = params->ParameterValues;
+ cb.buffer_offset = 0;
cb.buffer_size = paramBytes;
if (ST_DEBUG & DEBUG_CONSTANTS) {
debug_printf("%s(shader=%d, numParams=%d, stateFlags=0x%x)\n",
__func__, shader_type, params->NumParameters,
params->StateFlags);
_mesa_print_parameter_list(params);
}
cso_set_constant_buffer(st->cso_context, shader_type, 0, &cb);
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 7564a53..0a3de33 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -364,22 +364,20 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
ctx->st = st;
st->ctx = ctx;
st->pipe = pipe;
/* state tracker needs the VBO module */
_vbo_CreateContext(ctx);
st->dirty = ST_ALL_STATES_MASK;
- st->has_user_constbuf =
- screen->get_param(screen, PIPE_CAP_USER_CONSTANT_BUFFERS);
st->can_bind_const_buffer_as_vertex =
screen->get_param(screen, PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX);
/* st/mesa always uploads zero-stride vertex attribs, and other user
* vertex buffers are only possible with a compatibility profile.
* So tell the u_vbuf module that user VBOs are not possible with the Core
* profile, so that u_vbuf is bypassed completely if there is nothing else
* to do.
*/
unsigned vbuf_flags =
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 9f33eed..0258bed 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -103,21 +103,20 @@ struct st_context
boolean has_stencil_export; /**< can do shader stencil export? */
boolean has_time_elapsed;
boolean has_shader_model3;
boolean has_etc1;
boolean has_etc2;
boolean prefer_blit_based_texture_transfer;
boolean force_persample_in_shader;
boolean has_shareable_shaders;
boolean has_half_float_packing;
boolean has_multi_draw_indirect;
- boolean has_user_constbuf;
boolean can_bind_const_buffer_as_vertex;
/**
* If a shader can be created when we get its source.
* This means it has only 1 variant, not counting glBitmap and
* glDrawPixels.
*/
boolean shader_has_one_variant[MESA_SHADER_STAGES];
boolean needs_texcoord_semantic;
diff --git a/src/mesa/state_tracker/st_pbo.c b/src/mesa/state_tracker/st_pbo.c
index 303c853..628e3ca 100644
--- a/src/mesa/state_tracker/st_pbo.c
+++ b/src/mesa/state_tracker/st_pbo.c
@@ -252,35 +252,23 @@ st_pbo_draw(struct st_context *st, const struct st_pbo_addresses *addr,
cso_set_vertex_buffers(cso, velem.vertex_buffer_index, 1, &vbo);
pipe_resource_reference(&vbo.buffer.resource, NULL);
}
/* Upload constants */
{
struct pipe_constant_buffer cb;
- if (!st->has_user_constbuf) {
- cb.buffer = NULL;
- cb.user_buffer = NULL;
- u_upload_data(st->pipe->const_uploader, 0, sizeof(addr->constants),
- st->ctx->Const.UniformBufferOffsetAlignment,
- &addr->constants, &cb.buffer_offset, &cb.buffer);
- if (!cb.buffer)
- return false;
-
- u_upload_unmap(st->pipe->const_uploader);
- } else {
- cb.buffer = NULL;
- cb.user_buffer = &addr->constants;
- cb.buffer_offset = 0;
- }
+ cb.buffer = NULL;
+ cb.user_buffer = &addr->constants;
+ cb.buffer_offset = 0;
cb.buffer_size = sizeof(addr->constants);
cso_set_constant_buffer(cso, PIPE_SHADER_FRAGMENT, 0, &cb);
pipe_resource_reference(&cb.buffer, NULL);
}
/* Rasterizer state */
cso_set_rasterizer(cso, &st->pbo.raster);
--
2.7.4
More information about the mesa-dev
mailing list