gallium: always upload cbuf0 when cap is set
Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36715>
This commit is contained in:
committed by
Marge Bot
parent
203ac73374
commit
b8cd48e8e8
@@ -106,7 +106,7 @@ hud_draw_colored_prims(struct hud_context *hud, unsigned prim,
|
||||
hud->constants.translate[1] = (float) (yoffset * hud_scale);
|
||||
hud->constants.scale[0] = hud_scale;
|
||||
hud->constants.scale[1] = yscale * hud_scale;
|
||||
pipe->set_constant_buffer(pipe, MESA_SHADER_VERTEX, 0, false, &hud->constbuf);
|
||||
pipe_upload_constant_buffer0(pipe, MESA_SHADER_VERTEX, &hud->constbuf);
|
||||
|
||||
u_upload_data(hud->pipe->stream_uploader, 0,
|
||||
num_vertices * 2 * sizeof(float), 16, buffer,
|
||||
@@ -580,7 +580,7 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex)
|
||||
pipe->set_sampler_views(pipe, MESA_SHADER_FRAGMENT, 0, 1, 0,
|
||||
&hud->font_sampler_view);
|
||||
cso_set_samplers(cso, MESA_SHADER_FRAGMENT, 1, sampler_states);
|
||||
pipe->set_constant_buffer(pipe, MESA_SHADER_VERTEX, 0, false, &hud->constbuf);
|
||||
pipe_upload_constant_buffer0(pipe, MESA_SHADER_VERTEX, &hud->constbuf);
|
||||
|
||||
/* draw accumulated vertices for background quads */
|
||||
cso_set_blend(cso, &hud->alpha_blend);
|
||||
@@ -596,7 +596,7 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex)
|
||||
hud->constants.scale[0] = hud_scale;
|
||||
hud->constants.scale[1] = hud_scale;
|
||||
|
||||
pipe->set_constant_buffer(pipe, MESA_SHADER_VERTEX, 0, false, &hud->constbuf);
|
||||
pipe_upload_constant_buffer0(pipe, MESA_SHADER_VERTEX, &hud->constbuf);
|
||||
|
||||
cso_set_vertex_buffers(cso, 1, true, &hud->bg.vbuf);
|
||||
cso_draw_arrays(cso, MESA_PRIM_QUADS, 0, hud->bg.num_vertices);
|
||||
@@ -632,7 +632,7 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex)
|
||||
hud->constants.translate[1] = 0;
|
||||
hud->constants.scale[0] = hud_scale;
|
||||
hud->constants.scale[1] = hud_scale;
|
||||
pipe->set_constant_buffer(pipe, MESA_SHADER_VERTEX, 0, false, &hud->constbuf);
|
||||
pipe_upload_constant_buffer0(pipe, MESA_SHADER_VERTEX, &hud->constbuf);
|
||||
|
||||
if (hud->whitelines.num_vertices) {
|
||||
cso_set_vertex_shader_handle(cso, hud->vs_color);
|
||||
|
||||
@@ -104,8 +104,8 @@ pp_jimenezmlaa_run(struct pp_queue_t *ppq, struct pipe_resource *in,
|
||||
cb.user_buffer = constants;
|
||||
|
||||
struct pipe_context *pipe = ppq->p->pipe;
|
||||
pipe->set_constant_buffer(pipe, MESA_SHADER_VERTEX, 0, false, &cb);
|
||||
pipe->set_constant_buffer(pipe, MESA_SHADER_FRAGMENT, 0, false, &cb);
|
||||
pipe_upload_constant_buffer0(pipe, MESA_SHADER_VERTEX, &cb);
|
||||
pipe_upload_constant_buffer0(pipe, MESA_SHADER_FRAGMENT, &cb);
|
||||
|
||||
mstencil.stencil[0].enabled = 1;
|
||||
mstencil.stencil[0].valuemask = mstencil.stencil[0].writemask = ~0;
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "util/u_debug_describe.h"
|
||||
#include "util/u_debug_refcnt.h"
|
||||
#include "util/u_atomic.h"
|
||||
#include "util/u_upload_mgr.h"
|
||||
#include "util/box.h"
|
||||
#include "util/u_math.h"
|
||||
|
||||
@@ -691,6 +692,26 @@ pipe_set_constant_buffer(struct pipe_context *pipe,
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
pipe_upload_constant_buffer0(struct pipe_context *pipe, mesa_shader_stage stage, struct pipe_constant_buffer *cb)
|
||||
{
|
||||
struct pipe_constant_buffer cbuf = *cb;
|
||||
cbuf.buffer = NULL;
|
||||
const unsigned alignment = MAX2(pipe->screen->caps.constant_buffer_offset_alignment, 64);
|
||||
void *ptr;
|
||||
|
||||
if (pipe->screen->caps.prefer_real_buffer_in_constbuf0) {
|
||||
u_upload_alloc(pipe->const_uploader, 0, cbuf.buffer_size,
|
||||
alignment, &cbuf.buffer_offset, &cbuf.buffer, (void**)&ptr);
|
||||
memcpy(ptr, cbuf.user_buffer, cbuf.buffer_size);
|
||||
cbuf.user_buffer = NULL;
|
||||
|
||||
u_upload_unmap(pipe->const_uploader);
|
||||
pipe->set_constant_buffer(pipe, stage, 0, true, &cbuf);
|
||||
} else {
|
||||
pipe->set_constant_buffer(pipe, stage, 0, false, cb);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the polygon offset enable/disable flag for the given polygon fill mode.
|
||||
|
||||
@@ -118,6 +118,7 @@ st_upload_constants(struct st_context *st, struct gl_program *prog, mesa_shader_
|
||||
cb.buffer_offset = 0;
|
||||
cb.buffer_size = paramBytes;
|
||||
|
||||
/* this path cannot be used with select/feedback draws */
|
||||
if (st->prefer_real_buffer_in_constbuf0) {
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
uint32_t *ptr;
|
||||
|
||||
@@ -113,8 +113,7 @@ set_clearcolor_fs(struct st_context *st, union pipe_color_union *color)
|
||||
.user_buffer = color->f,
|
||||
.buffer_size = 4 * sizeof(float),
|
||||
};
|
||||
st->pipe->set_constant_buffer(st->pipe, MESA_SHADER_FRAGMENT, 0,
|
||||
false, &cb);
|
||||
pipe_upload_constant_buffer0(st->pipe, MESA_SHADER_FRAGMENT, &cb);
|
||||
|
||||
if (!st->clear.fs) {
|
||||
st->clear.fs = st_nir_make_clearcolor_shader(st);
|
||||
|
||||
@@ -691,14 +691,14 @@ st_draw_hw_select_prepare_common(struct gl_context *ctx)
|
||||
cb.buffer_size = sizeof(consts) - (MAX_CLIP_PLANES - num_planes) * 4 * sizeof(float);
|
||||
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
pipe->set_constant_buffer(pipe, MESA_SHADER_GEOMETRY, 0, false, &cb);
|
||||
pipe_upload_constant_buffer0(pipe, MESA_SHADER_GEOMETRY, &cb);
|
||||
|
||||
struct pipe_shader_buffer buffer;
|
||||
memset(&buffer, 0, sizeof(buffer));
|
||||
buffer.buffer = ctx->Select.Result->buffer;
|
||||
buffer.buffer_size = MAX_NAME_STACK_RESULT_NUM * 3 * sizeof(int);
|
||||
|
||||
pipe->set_shader_buffers(pipe, MESA_SHADER_GEOMETRY, 0, 1, &buffer, 0x1);
|
||||
pipe->set_shader_buffers(st->pipe, MESA_SHADER_GEOMETRY, 0, 1, &buffer, 0x1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -188,7 +188,6 @@ st_pbo_draw(struct st_context *st, const struct st_pbo_addresses *addr,
|
||||
unsigned surface_width, unsigned surface_height)
|
||||
{
|
||||
struct cso_context *cso = st->cso_context;
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
|
||||
/* Setup vertex and geometry shaders */
|
||||
if (!st->pbo.vs) {
|
||||
@@ -260,9 +259,7 @@ st_pbo_draw(struct st_context *st, const struct st_pbo_addresses *addr,
|
||||
cb.buffer_offset = 0;
|
||||
cb.buffer_size = sizeof(addr->constants);
|
||||
|
||||
pipe->set_constant_buffer(pipe, MESA_SHADER_FRAGMENT, 0, false, &cb);
|
||||
|
||||
pipe_resource_reference(&cb.buffer, NULL);
|
||||
pipe_upload_constant_buffer0(st->pipe, MESA_SHADER_FRAGMENT, &cb);
|
||||
}
|
||||
|
||||
/* Rasterizer state */
|
||||
|
||||
@@ -1004,7 +1004,7 @@ download_texture_compute(struct st_context *st,
|
||||
assert(cs);
|
||||
struct cso_context *cso = st->cso_context;
|
||||
|
||||
pipe->set_constant_buffer(pipe, MESA_SHADER_COMPUTE, 0, false, &cb);
|
||||
pipe_upload_constant_buffer0(st->pipe, MESA_SHADER_COMPUTE, &cb);
|
||||
|
||||
cso_save_compute_state(cso, CSO_BIT_COMPUTE_SHADER | CSO_BIT_COMPUTE_SAMPLERS);
|
||||
cso_set_compute_shader_handle(cso, cs);
|
||||
|
||||
Reference in New Issue
Block a user