aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorErik Faye-Lund <[email protected]>2020-06-10 19:56:49 +0200
committerMarge Bot <[email protected]>2020-06-16 08:02:29 +0000
commit7b86920ae2e206ea2f3dc44e110483460cb2936b (patch)
tree74b0c0d1687ecbfe14a7cd8712516e958a451453 /src
parent167fa2887f0928042dcb21bbc2fa89ae9a29897d (diff)
Revert "gallium/hud: don't use user vertex buffers"
The approach taken in this commit only works on drivers that expose the PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT capability. For drivers that don't, the buffer has been unmapped by the time we get to hud_draw_colored_prims, leading to crashes. It's not easy to fix the code, but drivers that do support coherent mapping will most likely do the right think themseleves, so let's just go back to using user-buffers here. This reverts commit 4fe1fd4df40ac91b2783e3604fd81e6a6faf0cd2. Fixes: 4fe1fd4df40 ("gallium/hud: don't use user vertex buffers") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3106 Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5417>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/hud/hud_context.c28
-rw-r--r--src/gallium/auxiliary/hud/hud_private.h2
2 files changed, 8 insertions, 22 deletions
diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index 57f577a3a92..2b84e6f88e6 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -73,13 +73,7 @@ hud_draw_colored_prims(struct hud_context *hud, unsigned prim,
int xoffset, int yoffset, float yscale)
{
struct cso_context *cso = hud->cso;
- unsigned size = num_vertices * hud->color_prims.vbuf.stride;
-
- /* If a recording context is inactive, don't draw anything. */
- if (size > hud->color_prims.buffer_size)
- return;
-
- memcpy(hud->color_prims.vertices, buffer, size);
+ struct pipe_vertex_buffer vbuffer = {0};
hud->constants.color[0] = r;
hud->constants.color[1] = g;
@@ -91,13 +85,13 @@ hud_draw_colored_prims(struct hud_context *hud, unsigned prim,
hud->constants.scale[1] = yscale * hud_scale;
cso_set_constant_buffer(cso, PIPE_SHADER_VERTEX, 0, &hud->constbuf);
- cso_set_vertex_buffers(cso, 0, 1, &hud->color_prims.vbuf);
+ vbuffer.is_user_buffer = true;
+ vbuffer.buffer.user = buffer;
+ vbuffer.stride = 2 * sizeof(float);
+
+ cso_set_vertex_buffers(cso, 0, 1, &vbuffer);
cso_set_fragment_shader_handle(hud->cso, hud->fs_color);
cso_draw_arrays(cso, prim, 0, num_vertices);
-
- hud->color_prims.vertices += size / sizeof(float);
- hud->color_prims.vbuf.buffer_offset += size;
- hud->color_prims.buffer_size -= size;
}
static void
@@ -645,7 +639,6 @@ hud_stop_queries(struct hud_context *hud, struct pipe_context *pipe)
hud_prepare_vertices(hud, &hud->bg, 16 * 256, 2 * sizeof(float));
hud_prepare_vertices(hud, &hud->whitelines, 4 * 256, 2 * sizeof(float));
hud_prepare_vertices(hud, &hud->text, 16 * 1024, 4 * sizeof(float));
- hud_prepare_vertices(hud, &hud->color_prims, 32 * 1024, 2 * sizeof(float));
/* Allocate everything once and divide the storage into 3 portions
* manually, because u_upload_alloc can unmap memory from previous calls.
@@ -653,8 +646,7 @@ hud_stop_queries(struct hud_context *hud, struct pipe_context *pipe)
u_upload_alloc(pipe->stream_uploader, 0,
hud->bg.buffer_size +
hud->whitelines.buffer_size +
- hud->text.buffer_size +
- hud->color_prims.buffer_size,
+ hud->text.buffer_size,
16, &hud->bg.vbuf.buffer_offset, &hud->bg.vbuf.buffer.resource,
(void**)&hud->bg.vertices);
if (!hud->bg.vertices)
@@ -662,7 +654,6 @@ hud_stop_queries(struct hud_context *hud, struct pipe_context *pipe)
pipe_resource_reference(&hud->whitelines.vbuf.buffer.resource, hud->bg.vbuf.buffer.resource);
pipe_resource_reference(&hud->text.vbuf.buffer.resource, hud->bg.vbuf.buffer.resource);
- pipe_resource_reference(&hud->color_prims.vbuf.buffer.resource, hud->bg.vbuf.buffer.resource);
hud->whitelines.vbuf.buffer_offset = hud->bg.vbuf.buffer_offset +
hud->bg.buffer_size;
@@ -674,11 +665,6 @@ hud_stop_queries(struct hud_context *hud, struct pipe_context *pipe)
hud->text.vertices = hud->whitelines.vertices +
hud->whitelines.buffer_size / sizeof(float);
- hud->color_prims.vbuf.buffer_offset = hud->text.vbuf.buffer_offset +
- hud->text.buffer_size;
- hud->color_prims.vertices = hud->text.vertices +
- hud->text.buffer_size / sizeof(float);
-
/* prepare all graphs */
hud_batch_query_update(hud->batch_query, pipe);
diff --git a/src/gallium/auxiliary/hud/hud_private.h b/src/gallium/auxiliary/hud/hud_private.h
index da0b47e498d..c95f4c42b44 100644
--- a/src/gallium/auxiliary/hud/hud_private.h
+++ b/src/gallium/auxiliary/hud/hud_private.h
@@ -90,7 +90,7 @@ struct hud_context {
unsigned max_num_vertices;
unsigned num_vertices;
unsigned buffer_size;
- } text, bg, whitelines, color_prims;
+ } text, bg, whitelines;
bool has_srgb;
};