summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2018-05-08 17:31:46 -0400
committerMarek Olšák <[email protected]>2018-05-12 21:08:09 -0400
commit86d63b53a20a747e3de769549572d895c7fbb736 (patch)
tree0b4aa27d8a617070daa5894a6cf9577b193758f3
parentce188813bfe63068119cbf3d0f76e1ea3d27b722 (diff)
gallium: remove aux_vertex_buffer_slot code
The slot index is always 0, and is pretty unlikely to change in the future. Reviewed-by: Brian Paul <[email protected]>
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.c52
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.h5
-rw-r--r--src/gallium/auxiliary/hud/hud_context.c14
-rw-r--r--src/gallium/auxiliary/util/u_blit.c5
-rw-r--r--src/gallium/auxiliary/util/u_vbuf.c22
-rw-r--r--src/gallium/auxiliary/util/u_vbuf.h7
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c5
-rw-r--r--src/mesa/state_tracker/st_cb_drawtex.c3
-rw-r--r--src/mesa/state_tracker/st_context.c15
-rw-r--r--src/mesa/state_tracker/st_draw.c10
-rw-r--r--src/mesa/state_tracker/st_pbo.c2
11 files changed, 45 insertions, 95 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index 3a3a63a3327..e3d46f3c8de 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -87,9 +87,8 @@ struct cso_context {
*/
int max_sampler_seen;
- struct pipe_vertex_buffer aux_vertex_buffer_current;
- struct pipe_vertex_buffer aux_vertex_buffer_saved;
- unsigned aux_vertex_buffer_index;
+ struct pipe_vertex_buffer vertex_buffer0_current;
+ struct pipe_vertex_buffer vertex_buffer0_saved;
struct pipe_constant_buffer aux_constbuf_current[PIPE_SHADER_TYPES];
struct pipe_constant_buffer aux_constbuf_saved[PIPE_SHADER_TYPES];
@@ -291,8 +290,7 @@ static void cso_init_vbuf(struct cso_context *cso, unsigned flags)
/* Install u_vbuf if there is anything unsupported. */
if (u_vbuf_get_caps(cso->pipe->screen, &caps, flags)) {
- cso->vbuf = u_vbuf_create(cso->pipe, &caps,
- cso->aux_vertex_buffer_index);
+ cso->vbuf = u_vbuf_create(cso->pipe, &caps);
}
}
@@ -313,8 +311,6 @@ cso_create_context(struct pipe_context *pipe, unsigned u_vbuf_flags)
ctx->pipe = pipe;
ctx->sample_mask = ~0;
- ctx->aux_vertex_buffer_index = 0; /* 0 for now */
-
cso_init_vbuf(ctx, u_vbuf_flags);
/* Enable for testing: */
@@ -417,8 +413,8 @@ void cso_destroy_context( struct cso_context *ctx )
util_unreference_framebuffer_state(&ctx->fb);
util_unreference_framebuffer_state(&ctx->fb_saved);
- pipe_vertex_buffer_unreference(&ctx->aux_vertex_buffer_current);
- pipe_vertex_buffer_unreference(&ctx->aux_vertex_buffer_saved);
+ pipe_vertex_buffer_unreference(&ctx->vertex_buffer0_current);
+ pipe_vertex_buffer_unreference(&ctx->vertex_buffer0_saved);
for (i = 0; i < PIPE_SHADER_TYPES; i++) {
pipe_resource_reference(&ctx->aux_constbuf_current[i].buffer, NULL);
@@ -1158,15 +1154,12 @@ void cso_set_vertex_buffers(struct cso_context *ctx,
/* Save what's in the auxiliary slot, so that we can save and restore it
* for meta ops. */
- if (start_slot <= ctx->aux_vertex_buffer_index &&
- start_slot+count > ctx->aux_vertex_buffer_index) {
+ if (start_slot == 0) {
if (buffers) {
- const struct pipe_vertex_buffer *vb =
- buffers + (ctx->aux_vertex_buffer_index - start_slot);
-
- pipe_vertex_buffer_reference(&ctx->aux_vertex_buffer_current, vb);
+ pipe_vertex_buffer_reference(&ctx->vertex_buffer0_current,
+ buffers);
} else {
- pipe_vertex_buffer_unreference(&ctx->aux_vertex_buffer_current);
+ pipe_vertex_buffer_unreference(&ctx->vertex_buffer0_current);
}
}
@@ -1174,41 +1167,34 @@ void cso_set_vertex_buffers(struct cso_context *ctx,
}
static void
-cso_save_aux_vertex_buffer_slot(struct cso_context *ctx)
+cso_save_vertex_buffer0(struct cso_context *ctx)
{
struct u_vbuf *vbuf = ctx->vbuf;
if (vbuf) {
- u_vbuf_save_aux_vertex_buffer_slot(vbuf);
+ u_vbuf_save_vertex_buffer0(vbuf);
return;
}
- pipe_vertex_buffer_reference(&ctx->aux_vertex_buffer_saved,
- &ctx->aux_vertex_buffer_current);
+ pipe_vertex_buffer_reference(&ctx->vertex_buffer0_saved,
+ &ctx->vertex_buffer0_current);
}
static void
-cso_restore_aux_vertex_buffer_slot(struct cso_context *ctx)
+cso_restore_vertex_buffer0(struct cso_context *ctx)
{
struct u_vbuf *vbuf = ctx->vbuf;
if (vbuf) {
- u_vbuf_restore_aux_vertex_buffer_slot(vbuf);
+ u_vbuf_restore_vertex_buffer0(vbuf);
return;
}
- cso_set_vertex_buffers(ctx, ctx->aux_vertex_buffer_index, 1,
- &ctx->aux_vertex_buffer_saved);
- pipe_vertex_buffer_unreference(&ctx->aux_vertex_buffer_saved);
-}
-
-unsigned cso_get_aux_vertex_buffer_slot(struct cso_context *ctx)
-{
- return ctx->aux_vertex_buffer_index;
+ cso_set_vertex_buffers(ctx, 0, 1, &ctx->vertex_buffer0_saved);
+ pipe_vertex_buffer_unreference(&ctx->vertex_buffer0_saved);
}
-
void
cso_single_sampler(struct cso_context *ctx, enum pipe_shader_type shader_stage,
unsigned idx, const struct pipe_sampler_state *templ)
@@ -1595,7 +1581,7 @@ cso_save_state(struct cso_context *cso, unsigned state_mask)
cso->saved_state = state_mask;
if (state_mask & CSO_BIT_AUX_VERTEX_BUFFER_SLOT)
- cso_save_aux_vertex_buffer_slot(cso);
+ cso_save_vertex_buffer0(cso);
if (state_mask & CSO_BIT_BLEND)
cso_save_blend(cso);
if (state_mask & CSO_BIT_DEPTH_STENCIL_ALPHA)
@@ -1650,7 +1636,7 @@ cso_restore_state(struct cso_context *cso)
assert(state_mask);
if (state_mask & CSO_BIT_AUX_VERTEX_BUFFER_SLOT)
- cso_restore_aux_vertex_buffer_slot(cso);
+ cso_restore_vertex_buffer0(cso);
if (state_mask & CSO_BIT_BLEND)
cso_restore_blend(cso);
if (state_mask & CSO_BIT_DEPTH_STENCIL_ALPHA)
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h
index 3a4e808f0c0..d3501fb92e9 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -87,11 +87,6 @@ void cso_set_vertex_buffers(struct cso_context *ctx,
unsigned start_slot, unsigned count,
const struct pipe_vertex_buffer *buffers);
-/* One vertex buffer slot is provided with the save/restore functionality.
- * cso_context chooses the slot, it can be non-zero. */
-unsigned cso_get_aux_vertex_buffer_slot(struct cso_context *ctx);
-
-
void cso_set_stream_outputs(struct cso_context *ctx,
unsigned num_targets,
struct pipe_stream_output_target **targets,
diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index 1baaabbb38e..6ed9ccffdbc 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -90,8 +90,7 @@ 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);
- cso_set_vertex_buffers(cso, cso_get_aux_vertex_buffer_slot(cso),
- 1, &hud->color_prims.vbuf);
+ cso_set_vertex_buffers(cso, 0, 1, &hud->color_prims.vbuf);
cso_set_fragment_shader_handle(hud->cso, hud->fs_color);
cso_draw_arrays(cso, prim, 0, num_vertices);
@@ -561,16 +560,14 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex)
hud->constants.scale[1] = 1;
cso_set_constant_buffer(cso, PIPE_SHADER_VERTEX, 0, &hud->constbuf);
- cso_set_vertex_buffers(cso, cso_get_aux_vertex_buffer_slot(cso), 1,
- &hud->bg.vbuf);
+ cso_set_vertex_buffers(cso, 0, 1, &hud->bg.vbuf);
cso_draw_arrays(cso, PIPE_PRIM_QUADS, 0, hud->bg.num_vertices);
}
pipe_resource_reference(&hud->bg.vbuf.buffer.resource, NULL);
/* draw accumulated vertices for text */
if (hud->text.num_vertices) {
- cso_set_vertex_buffers(cso, cso_get_aux_vertex_buffer_slot(cso), 1,
- &hud->text.vbuf);
+ cso_set_vertex_buffers(cso, 0, 1, &hud->text.vbuf);
cso_set_fragment_shader_handle(hud->cso, hud->fs_text);
cso_draw_arrays(cso, PIPE_PRIM_QUADS, 0, hud->text.num_vertices);
}
@@ -598,8 +595,7 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex)
cso_set_constant_buffer(cso, PIPE_SHADER_VERTEX, 0, &hud->constbuf);
if (hud->whitelines.num_vertices) {
- cso_set_vertex_buffers(cso, cso_get_aux_vertex_buffer_slot(cso), 1,
- &hud->whitelines.vbuf);
+ cso_set_vertex_buffers(cso, 0, 1, &hud->whitelines.vbuf);
cso_set_fragment_shader_handle(hud->cso, hud->fs_color);
cso_draw_arrays(cso, PIPE_PRIM_LINES, 0, hud->whitelines.num_vertices);
}
@@ -1868,7 +1864,7 @@ hud_create(struct cso_context *cso, struct hud_context *share)
for (i = 0; i < 2; i++) {
hud->velems[i].src_offset = i * 2 * sizeof(float);
hud->velems[i].src_format = PIPE_FORMAT_R32G32_FLOAT;
- hud->velems[i].vertex_buffer_index = cso_get_aux_vertex_buffer_slot(cso);
+ hud->velems[i].vertex_buffer_index = 0;
}
/* sampler state (for font drawing) */
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index d1571cd1f56..9a43c2f6556 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -112,7 +112,7 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso)
for (i = 0; i < 2; i++) {
ctx->velem[i].src_offset = i * 4 * sizeof(float);
ctx->velem[i].instance_divisor = 0;
- ctx->velem[i].vertex_buffer_index = cso_get_aux_vertex_buffer_slot(cso);
+ ctx->velem[i].vertex_buffer_index = 0;
ctx->velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
}
@@ -631,8 +631,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
s0, t0, s1, t1,
z);
- util_draw_vertex_buffer(ctx->pipe, ctx->cso, ctx->vbuf,
- cso_get_aux_vertex_buffer_slot(ctx->cso),
+ util_draw_vertex_buffer(ctx->pipe, ctx->cso, ctx->vbuf, 0,
offset,
PIPE_PRIM_TRIANGLE_FAN,
4, /* verts */
diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c
index 8a680d60a68..42f37c75742 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -154,8 +154,7 @@ struct u_vbuf {
uint32_t enabled_vb_mask;
/* Saved vertex buffer. */
- unsigned aux_vertex_buffer_slot;
- struct pipe_vertex_buffer aux_vertex_buffer_saved;
+ struct pipe_vertex_buffer vertex_buffer0_saved;
/* Vertex buffers for the driver.
* There are usually no user buffers. */
@@ -300,13 +299,11 @@ boolean u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps,
}
struct u_vbuf *
-u_vbuf_create(struct pipe_context *pipe,
- struct u_vbuf_caps *caps, unsigned aux_vertex_buffer_index)
+u_vbuf_create(struct pipe_context *pipe, struct u_vbuf_caps *caps)
{
struct u_vbuf *mgr = CALLOC_STRUCT(u_vbuf);
mgr->caps = *caps;
- mgr->aux_vertex_buffer_slot = aux_vertex_buffer_index;
mgr->pipe = pipe;
mgr->cso_cache = cso_cache_create();
mgr->translate_cache = translate_cache_create();
@@ -381,7 +378,7 @@ void u_vbuf_destroy(struct u_vbuf *mgr)
for (i = 0; i < PIPE_MAX_ATTRIBS; i++)
pipe_vertex_buffer_unreference(&mgr->real_vertex_buffer[i]);
- pipe_vertex_buffer_unreference(&mgr->aux_vertex_buffer_saved);
+ pipe_vertex_buffer_unreference(&mgr->vertex_buffer0_saved);
translate_cache_destroy(mgr->translate_cache);
cso_cache_delete(mgr->cso_cache);
@@ -1313,15 +1310,14 @@ void u_vbuf_restore_vertex_elements(struct u_vbuf *mgr)
mgr->ve_saved = NULL;
}
-void u_vbuf_save_aux_vertex_buffer_slot(struct u_vbuf *mgr)
+void u_vbuf_save_vertex_buffer0(struct u_vbuf *mgr)
{
- pipe_vertex_buffer_reference(&mgr->aux_vertex_buffer_saved,
- &mgr->vertex_buffer[mgr->aux_vertex_buffer_slot]);
+ pipe_vertex_buffer_reference(&mgr->vertex_buffer0_saved,
+ &mgr->vertex_buffer[0]);
}
-void u_vbuf_restore_aux_vertex_buffer_slot(struct u_vbuf *mgr)
+void u_vbuf_restore_vertex_buffer0(struct u_vbuf *mgr)
{
- u_vbuf_set_vertex_buffers(mgr, mgr->aux_vertex_buffer_slot, 1,
- &mgr->aux_vertex_buffer_saved);
- pipe_vertex_buffer_unreference(&mgr->aux_vertex_buffer_saved);
+ u_vbuf_set_vertex_buffers(mgr, 0, 1, &mgr->vertex_buffer0_saved);
+ pipe_vertex_buffer_unreference(&mgr->vertex_buffer0_saved);
}
diff --git a/src/gallium/auxiliary/util/u_vbuf.h b/src/gallium/auxiliary/util/u_vbuf.h
index d0704524561..a6139834575 100644
--- a/src/gallium/auxiliary/util/u_vbuf.h
+++ b/src/gallium/auxiliary/util/u_vbuf.h
@@ -61,8 +61,7 @@ boolean u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps,
unsigned flags);
struct u_vbuf *
-u_vbuf_create(struct pipe_context *pipe,
- struct u_vbuf_caps *caps, unsigned aux_vertex_buffer_index);
+u_vbuf_create(struct pipe_context *pipe, struct u_vbuf_caps *caps);
void u_vbuf_destroy(struct u_vbuf *mgr);
@@ -77,7 +76,7 @@ void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info);
/* Save/restore functionality. */
void u_vbuf_save_vertex_elements(struct u_vbuf *mgr);
void u_vbuf_restore_vertex_elements(struct u_vbuf *mgr);
-void u_vbuf_save_aux_vertex_buffer_slot(struct u_vbuf *mgr);
-void u_vbuf_restore_aux_vertex_buffer_slot(struct u_vbuf *mgr);
+void u_vbuf_save_vertex_buffer0(struct u_vbuf *mgr);
+void u_vbuf_restore_vertex_buffer0(struct u_vbuf *mgr);
#endif
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index b25ae5f80eb..1bfc82db43e 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -774,10 +774,7 @@ st_DrawAtlasBitmaps(struct gl_context *ctx,
u_upload_unmap(pipe->stream_uploader);
- cso_set_vertex_buffers(st->cso_context,
- cso_get_aux_vertex_buffer_slot(st->cso_context),
- 1, &vb);
-
+ cso_set_vertex_buffers(st->cso_context, 0, 1, &vb);
cso_draw_arrays(st->cso_context, PIPE_PRIM_QUADS, 0, num_verts);
out:
diff --git a/src/mesa/state_tracker/st_cb_drawtex.c b/src/mesa/state_tracker/st_cb_drawtex.c
index f18925ecfe6..b6bf71d4cd1 100644
--- a/src/mesa/state_tracker/st_cb_drawtex.c
+++ b/src/mesa/state_tracker/st_cb_drawtex.c
@@ -276,8 +276,7 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
cso_set_viewport(cso, &vp);
}
- util_draw_vertex_buffer(pipe, cso, vbuffer,
- cso_get_aux_vertex_buffer_slot(cso),
+ util_draw_vertex_buffer(pipe, cso, vbuffer, 0,
offset, /* offset */
PIPE_PRIM_TRIANGLE_FAN,
4, /* verts */
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 061b8b9c4c2..50c8b2e6549 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -395,26 +395,17 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
/* Setup vertex element info for 'struct st_util_vertex'.
*/
{
- const unsigned slot = cso_get_aux_vertex_buffer_slot(st->cso_context);
-
- /* If this assertion ever fails all state tracker calls to
- * cso_get_aux_vertex_buffer_slot() should be audited. This
- * particular call would have to be moved to just before each
- * drawing call.
- */
- assert(slot == 0);
-
STATIC_ASSERT(sizeof(struct st_util_vertex) == 9 * sizeof(float));
memset(&st->util_velems, 0, sizeof(st->util_velems));
st->util_velems[0].src_offset = 0;
- st->util_velems[0].vertex_buffer_index = slot;
+ st->util_velems[0].vertex_buffer_index = 0;
st->util_velems[0].src_format = PIPE_FORMAT_R32G32B32_FLOAT;
st->util_velems[1].src_offset = 3 * sizeof(float);
- st->util_velems[1].vertex_buffer_index = slot;
+ st->util_velems[1].vertex_buffer_index = 0;
st->util_velems[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
st->util_velems[2].src_offset = 7 * sizeof(float);
- st->util_velems[2].vertex_buffer_index = slot;
+ st->util_velems[2].vertex_buffer_index = 0;
st->util_velems[2].src_format = PIPE_FORMAT_R32G32_FLOAT;
}
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 12cae85f408..208ea735a78 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -419,15 +419,7 @@ st_draw_quad(struct st_context *st,
u_upload_unmap(st->pipe->stream_uploader);
- /* At the time of writing, cso_get_aux_vertex_buffer_slot() always returns
- * zero. If that ever changes we need to audit the calls to that function
- * and make sure the slot number is used consistently everywhere.
- */
- assert(cso_get_aux_vertex_buffer_slot(st->cso_context) == 0);
-
- cso_set_vertex_buffers(st->cso_context,
- cso_get_aux_vertex_buffer_slot(st->cso_context),
- 1, &vb);
+ cso_set_vertex_buffers(st->cso_context, 0, 1, &vb);
if (num_instances > 1) {
cso_draw_arrays_instanced(st->cso_context, PIPE_PRIM_TRIANGLE_FAN, 0, 4,
diff --git a/src/mesa/state_tracker/st_pbo.c b/src/mesa/state_tracker/st_pbo.c
index 628e3ca64a5..6c55e85f069 100644
--- a/src/mesa/state_tracker/st_pbo.c
+++ b/src/mesa/state_tracker/st_pbo.c
@@ -245,7 +245,7 @@ st_pbo_draw(struct st_context *st, const struct st_pbo_addresses *addr,
velem.src_offset = 0;
velem.instance_divisor = 0;
- velem.vertex_buffer_index = cso_get_aux_vertex_buffer_slot(cso);
+ velem.vertex_buffer_index = 0;
velem.src_format = PIPE_FORMAT_R32G32_FLOAT;
cso_set_vertex_elements(cso, 1, &velem);