[Mesa-dev] [RFC] [PATCH] mesa/st: set max_int instance_divisor for constant elements
Luca Barbieri
luca at luca-barbieri.com
Wed Aug 11 07:38:04 PDT 2010
Currently constant elements are specified only with stride = 0.
However, drivers often need to know whether an element is constant
or not when setting up the vertex element CSO instead of when setting
the buffers.
Hence, in addition to stride = 0, also set instance_divisor = ~0 in
the vertex element, in all places where Mesa sets up both at the same time.
Drivers that ignore instancing will behave as before since stride = 0 is
set too.
Drivers that support instancing should continue to behave correctly, and
if not can just ignore this divisor.
Drivers that take advantage of this hint will however perform best.
---
src/mesa/state_tracker/st_draw.c | 4 ++--
src/mesa/state_tracker/st_draw_feedback.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 5b05489..ee69572 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -388,7 +388,7 @@ setup_interleaved_attribs(GLcontext *ctx,
velements[attr].src_offset =
(unsigned) (arrays[mesaAttr]->Ptr - offset0);
- velements[attr].instance_divisor = 0;
+ velements[attr].instance_divisor = stride ? 0 : ~0;
velements[attr].vertex_buffer_index = 0;
velements[attr].src_format =
st_pipe_vertex_format(arrays[mesaAttr]->Type,
@@ -483,7 +483,7 @@ setup_non_interleaved_attribs(GLcontext *ctx,
/* common-case setup */
vbuffer[attr].stride = stride; /* in bytes */
vbuffer[attr].max_index = max_index;
- velements[attr].instance_divisor = 0;
+ velements[attr].instance_divisor = stride ? 0 : ~0;
velements[attr].vertex_buffer_index = attr;
velements[attr].src_format
= st_pipe_vertex_format(arrays[mesaAttr]->Type,
diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c
index 5cf2666..41c9ecc 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -180,7 +180,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
/* common-case setup */
vbuffers[attr].stride = arrays[mesaAttr]->StrideB; /* in bytes */
vbuffers[attr].max_index = max_index;
- velements[attr].instance_divisor = 0;
+ velements[attr].instance_divisor = vbuffers[attr].stride ? 0 : ~0;
velements[attr].vertex_buffer_index = attr;
velements[attr].src_format =
st_pipe_vertex_format(arrays[mesaAttr]->Type,
--
1.7.0.4
More information about the mesa-dev
mailing list