[Mesa-dev] [PATCH 04/10] gallium/hud: use the common uploader
Marek Olšák
maraeo at gmail.com
Fri Jan 27 11:02:07 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
---
src/gallium/auxiliary/hud/hud_context.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index a635797..6caf821 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -53,21 +53,20 @@
#include "util/u_upload_mgr.h"
#include "tgsi/tgsi_text.h"
#include "tgsi/tgsi_dump.h"
/* Control the visibility of all HUD contexts */
static boolean huds_visible = TRUE;
struct hud_context {
struct pipe_context *pipe;
struct cso_context *cso;
- struct u_upload_mgr *uploader;
struct hud_batch_query_context *batch_query;
struct list_head pane_list;
/* states */
struct pipe_blend_state no_blend, alpha_blend;
struct pipe_depth_stencil_alpha_state dsa;
void *fs_color, *fs_text;
struct pipe_rasterizer_state rasterizer, rasterizer_aa_lines;
void *vs;
@@ -456,21 +455,21 @@ hud_pane_draw_colored_objects(struct hud_context *hud,
}
}
static void
hud_alloc_vertices(struct hud_context *hud, struct vertex_queue *v,
unsigned num_vertices, unsigned stride)
{
v->num_vertices = 0;
v->max_num_vertices = num_vertices;
v->vbuf.stride = stride;
- u_upload_alloc(hud->uploader, 0, v->vbuf.stride * v->max_num_vertices,
+ u_upload_alloc(hud->pipe->stream_uploader, 0, v->vbuf.stride * v->max_num_vertices,
16, &v->vbuf.buffer_offset, &v->vbuf.buffer,
(void**)&v->vertices);
}
/**
* Draw the HUD to the texture \p tex.
* The texture is usually the back buffer being displayed.
*/
void
hud_draw(struct hud_context *hud, struct pipe_resource *tex)
@@ -590,21 +589,21 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex)
LIST_DEL(&gr->head);
LIST_ADD(&gr->head, &next->head);
}
}
}
hud_pane_accumulate_vertices(hud, pane);
}
/* unmap the uploader's vertex buffer before drawing */
- u_upload_unmap(hud->uploader);
+ u_upload_unmap(pipe->stream_uploader);
/* draw accumulated vertices for background quads */
cso_set_blend(cso, &hud->alpha_blend);
cso_set_fragment_shader_handle(hud->cso, hud->fs_color);
if (hud->bg.num_vertices) {
hud->constants.color[0] = 0;
hud->constants.color[1] = 0;
hud->constants.color[2] = 0;
hud->constants.color[3] = 0.666f;
@@ -1469,26 +1468,23 @@ hud_create(struct pipe_context *pipe, struct cso_context *cso)
print_help(pipe->screen);
return NULL;
}
hud = CALLOC_STRUCT(hud_context);
if (!hud)
return NULL;
hud->pipe = pipe;
hud->cso = cso;
- hud->uploader = u_upload_create(pipe, 256 * 1024,
- PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM);
/* font */
if (!util_font_create(pipe, UTIL_FONT_FIXED_8X13, &hud->font)) {
- u_upload_destroy(hud->uploader);
FREE(hud);
return NULL;
}
hud->has_srgb = screen->is_format_supported(screen,
PIPE_FORMAT_B8G8R8A8_SRGB,
PIPE_TEXTURE_2D, 0,
PIPE_BIND_RENDER_TARGET) != 0;
/* blend state */
@@ -1524,21 +1520,20 @@ hud_create(struct pipe_context *pipe, struct cso_context *cso)
"MOV OUT[0], TEMP[0].xxxx\n"
"END\n"
};
struct tgsi_token tokens[1000];
struct pipe_shader_state state;
if (!tgsi_text_translate(fragment_shader_text, tokens, ARRAY_SIZE(tokens))) {
assert(0);
pipe_resource_reference(&hud->font.texture, NULL);
- u_upload_destroy(hud->uploader);
FREE(hud);
return NULL;
}
pipe_shader_state_from_tgsi(&state, tokens);
hud->fs_text = pipe->create_fs_state(pipe, &state);
}
/* rasterizer */
hud->rasterizer.half_pixel_center = 1;
hud->rasterizer.bottom_edge_rule = 1;
@@ -1573,21 +1568,20 @@ hud_create(struct pipe_context *pipe, struct cso_context *cso)
"MOV OUT[1], CONST[0]\n"
"MOV OUT[2], IN[1]\n"
"END\n"
};
struct tgsi_token tokens[1000];
struct pipe_shader_state state;
if (!tgsi_text_translate(vertex_shader_text, tokens, ARRAY_SIZE(tokens))) {
assert(0);
pipe_resource_reference(&hud->font.texture, NULL);
- u_upload_destroy(hud->uploader);
FREE(hud);
return NULL;
}
pipe_shader_state_from_tgsi(&state, tokens);
hud->vs = pipe->create_vs_state(pipe, &state);
}
/* vertex elements */
for (i = 0; i < 2; i++) {
hud->velems[i].src_offset = i * 2 * sizeof(float);
@@ -1648,13 +1642,12 @@ hud_destroy(struct hud_context *hud)
LIST_DEL(&pane->head);
FREE(pane);
}
hud_batch_query_cleanup(&hud->batch_query);
pipe->delete_fs_state(pipe, hud->fs_color);
pipe->delete_fs_state(pipe, hud->fs_text);
pipe->delete_vs_state(pipe, hud->vs);
pipe_sampler_view_reference(&hud->font_sampler_view, NULL);
pipe_resource_reference(&hud->font.texture, NULL);
- u_upload_destroy(hud->uploader);
FREE(hud);
}
--
2.7.4
More information about the mesa-dev
mailing list