summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorBrian <[email protected]>2008-02-25 14:46:42 -0700
committerBrian <[email protected]>2008-02-25 14:46:42 -0700
commitd6c7f7e314ee9f034402c919d142bf6ba9844ec9 (patch)
tree5a51a49ea77136caa1177ddb66a76635a33a6475 /src/gallium
parentea02342c11eaeb700495b403caecc13a129333e8 (diff)
gallium: modify draw_find_vs_output() to search vertex shader outputs
This simplifies drivers using the draw module and removes the last dependency on vertex-shader "internals". Since the draw module is producing the post-transformed vertices, it makes sense to ask it where specific vertex attributes are located. This could also simplify some things in the state tracker code for selection, feedback, rasterpos...
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index c28e78d33a3..6e5e4d64d11 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -244,14 +244,32 @@ draw_convert_wide_lines(struct draw_context *draw, boolean enable)
/**
- * The draw module may sometimes generate vertices with extra attributes
- * (such as texcoords for AA lines). The driver can call this function
- * to find those attributes.
+ * Ask the draw module for the location/slot of the given vertex attribute in
+ * a post-transformed vertex.
+ *
+ * With this function, drivers that use the draw module should have no reason
+ * to track the current vertex shader.
+ *
+ * Note that the draw module may sometimes generate vertices with extra
+ * attributes (such as texcoords for AA lines). The driver can call this
+ * function to find those attributes.
+ *
+ * Zero is returned if the attribute is not found since this is
+ * a don't care / undefined situtation. Returning -1 would be a bit more
+ * work for the drivers.
*/
int
draw_find_vs_output(struct draw_context *draw,
uint semantic_name, uint semantic_index)
{
+ const struct pipe_shader_state *vs = &draw->vertex_shader->state;
+ uint i;
+ for (i = 0; i < vs->num_outputs; i++) {
+ if (vs->output_semantic_name[i] == semantic_name &&
+ vs->output_semantic_index[i] == semantic_index)
+ return i;
+ }
+
/* XXX there may be more than one extra vertex attrib.
* For example, simulated gl_FragCoord and gl_PointCoord.
*/