diff options
-rw-r--r-- | src/gallium/auxiliary/hud/hud_context.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c index 09bd66157de..57d189fbc52 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -98,7 +98,7 @@ struct hud_context { unsigned max_num_vertices; unsigned num_vertices; unsigned buffer_size; - } text, bg, whitelines; + } text, bg, whitelines, color_prims; bool has_srgb; }; @@ -118,7 +118,10 @@ hud_draw_colored_prims(struct hud_context *hud, unsigned prim, int xoffset, int yoffset, float yscale) { struct cso_context *cso = hud->cso; - struct pipe_vertex_buffer vbuffer = {0}; + unsigned size = num_vertices * hud->color_prims.vbuf.stride; + + assert(size <= hud->color_prims.buffer_size); + memcpy(hud->color_prims.vertices, buffer, size); hud->constants.color[0] = r; hud->constants.color[1] = g; @@ -130,13 +133,14 @@ hud_draw_colored_prims(struct hud_context *hud, unsigned prim, hud->constants.scale[1] = yscale; cso_set_constant_buffer(cso, PIPE_SHADER_VERTEX, 0, &hud->constbuf); - vbuffer.user_buffer = buffer; - vbuffer.stride = 2 * sizeof(float); - cso_set_vertex_buffers(cso, cso_get_aux_vertex_buffer_slot(cso), - 1, &vbuffer); + 1, &hud->color_prims.vbuf); 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 @@ -565,6 +569,7 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex) 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. @@ -572,11 +577,13 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex) u_upload_alloc(hud->pipe->stream_uploader, 0, hud->bg.buffer_size + hud->whitelines.buffer_size + - hud->text.buffer_size, + hud->text.buffer_size + + hud->color_prims.buffer_size, 16, &hud->bg.vbuf.buffer_offset, &hud->bg.vbuf.buffer, (void**)&hud->bg.vertices); pipe_resource_reference(&hud->whitelines.vbuf.buffer, hud->bg.vbuf.buffer); pipe_resource_reference(&hud->text.vbuf.buffer, hud->bg.vbuf.buffer); + pipe_resource_reference(&hud->color_prims.vbuf.buffer, hud->bg.vbuf.buffer); hud->whitelines.vbuf.buffer_offset = hud->bg.vbuf.buffer_offset + hud->bg.buffer_size; @@ -588,6 +595,11 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex) 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); |