[Mesa-dev] [PATCH 10/13] i965: Make gl_BaseVertex available in a buffer object.
Kenneth Graunke
kenneth at whitecape.org
Fri Aug 8 00:31:14 PDT 2014
This will be used for GL_ARB_shader_draw_parameters, as well as fixing
gl_VertexID, which is supposed to include gl_BaseVertex's value.
For indirect draws, we simply point at the indirect buffer; for normal
draws, we upload the value via the upload buffer.
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
src/mesa/drivers/dri/i965/brw_context.h | 7 +++++++
src/mesa/drivers/dri/i965/brw_draw.c | 14 ++++++++++++++
src/mesa/drivers/dri/i965/brw_draw_upload.c | 10 ++++++++++
3 files changed, 31 insertions(+)
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index eea7938..b5b5e41 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1063,6 +1063,13 @@ struct brw_context
int start_vertex_location;
int base_vertex_location;
+
+ /**
+ * Buffer and offset used for GL_ARB_shader_draw_parameters
+ * (for now, only gl_BaseVertex).
+ */
+ drm_intel_bo *draw_params_bo;
+ uint32_t draw_params_offset;
} draw;
struct {
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index d8e16a7..f0aaec7 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -465,6 +465,20 @@ static bool brw_try_draw_prims( struct gl_context *ctx,
brw->draw.start_vertex_location = prims[i].start;
brw->draw.base_vertex_location = prims[i].basevertex;
+ if (prims[i].is_indirect) {
+ /* Point draw_params_bo at the indirect buffer. */
+ brw->draw.draw_params_bo =
+ intel_buffer_object(ctx->DrawIndirectBuffer)->buffer;
+ brw->draw.draw_params_offset =
+ prims[i].indirect_offset + (prims[i].indexed ? 12 : 8);
+ } else {
+ /* Set draw_params_bo to NULL so brw_prepare_vertices knows it
+ * has to upload gl_BaseVertex and such if they're needed.
+ */
+ brw->draw.draw_params_bo = NULL;
+ brw->draw.draw_params_offset = 0;
+ }
+
if (brw->gen < 6)
brw_set_prim(brw, &prims[i]);
else
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 38b1087..37a65bc 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -607,11 +607,21 @@ brw_prepare_vertices(struct brw_context *brw)
void
brw_prepare_shader_draw_parameters(struct brw_context *brw)
{
+ int *gl_basevertex_value;
if (brw->draw.indexed) {
brw->draw.start_vertex_location += brw->ib.start_vertex_offset;
brw->draw.base_vertex_location += brw->vb.start_vertex_bias;
+ gl_basevertex_value = &brw->draw.base_vertex_location;
} else {
brw->draw.start_vertex_location += brw->vb.start_vertex_bias;
+ gl_basevertex_value = &brw->draw.start_vertex_location;
+ }
+
+ /* For non-indirect draws, upload gl_BaseVertex. */
+ if (brw->vs.prog_data->uses_vertexid && brw->draw.draw_params_bo == NULL) {
+ intel_upload_data(brw, gl_basevertex_value, 4, 4,
+ &brw->draw.draw_params_bo,
+ &brw->draw.draw_params_offset);
}
}
--
2.0.2
More information about the mesa-dev
mailing list