This fixes the vertex id fetch in the non-llvm drawing paths.
This vertex id in elt mode comes from the elts not just a linear
value.
Note we don't bad basevertex in the elts case as it's already included
in the elts by the looks of it (at least tests fail if I add it)
Fixes piglit end-primitive tests and some others.
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
draw_vertex_shader_run(struct draw_vertex_shader *vshader,
const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
unsigned const_size[PIPE_MAX_CONSTANT_BUFFERS],
+ const struct draw_fetch_info *fetch_info,
const struct draw_vertex_info *input_verts,
struct draw_vertex_info *output_verts)
{
const_size,
input_verts->count,
input_verts->vertex_size,
- input_verts->vertex_size);
+ input_verts->vertex_size,
+ fetch_info->elts);
}
*/
fetch( fpme->fetch, fetch_info, (char *)fetched_vert_info.verts );
- /* Finished with fetch:
- */
- fetch_info = NULL;
vert_info = &fetched_vert_info;
/* Run the shader, note that this overwrites the data[] parts of
* the pipeline verts.
+ * Need fetch info to get vertex id correct.
*/
if (fpme->opt & PT_SHADE) {
draw_vertex_shader_run(vshader,
draw->pt.user.vs_constants,
draw->pt.user.vs_constants_size,
+ fetch_info,
vert_info,
&vs_vert_info);
vert_info = &vs_vert_info;
}
+ /* Finished with fetch:
+ */
+ fetch_info = NULL;
+
if ((fpme->opt & PT_SHADE) && gshader) {
draw_geometry_shader_run(gshader,
draw->pt.user.gs_constants,
const unsigned const_size[PIPE_MAX_CONSTANT_BUFFERS],
unsigned count,
unsigned input_stride,
- unsigned output_stride );
+ unsigned output_stride,
+ const unsigned *fetch_elts);
void (*delete)( struct draw_vertex_shader * );
const unsigned const_size[PIPE_MAX_CONSTANT_BUFFERS],
unsigned count,
unsigned input_stride,
- unsigned output_stride)
+ unsigned output_stride,
+ const unsigned *fetch_elts)
{
struct exec_vertex_shader *evs = exec_vertex_shader(shader);
struct tgsi_exec_machine *machine = evs->machine;
if (shader->info.uses_vertexid) {
unsigned vid = machine->SysSemanticToIndex[TGSI_SEMANTIC_VERTEXID];
assert(vid < ARRAY_SIZE(machine->SystemValue));
- machine->SystemValue[vid].xyzw[0].i[j] = i + j + basevertex;
+ machine->SystemValue[vid].xyzw[0].i[j] = fetch_elts ? fetch_elts[i + j] : (i + j + basevertex);
}
if (shader->info.uses_basevertex) {
unsigned vid = machine->SysSemanticToIndex[TGSI_SEMANTIC_BASEVERTEX];
if (shader->info.uses_vertexid_nobase) {
unsigned vid = machine->SysSemanticToIndex[TGSI_SEMANTIC_VERTEXID_NOBASE];
assert(vid < ARRAY_SIZE(machine->SystemValue));
- machine->SystemValue[vid].xyzw[0].i[j] = i + j;
+ machine->SystemValue[vid].xyzw[0].i[j] = fetch_elts ? (fetch_elts[i + j] - basevertex) : (i + j);
}
for (slot = 0; slot < shader->info.num_inputs; slot++) {
const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS],
unsigned count,
unsigned input_stride,
- unsigned output_stride )
+ unsigned output_stride,
+ const unsigned *elts)
{
/* we should never get here since the entire pipeline is
* generated in draw_pt_fetch_shade_pipeline_llvm.c */
vsvg->base.vs->draw->pt.user.vs_constants_size,
count,
temp_vertex_stride,
- temp_vertex_stride);
+ temp_vertex_stride, NULL);
/* FIXME: geometry shading? */
vsvg->base.vs->draw->pt.user.vs_constants_size,
count,
temp_vertex_stride,
- temp_vertex_stride);
+ temp_vertex_stride, NULL);
if (vsvg->base.key.clip) {
/* not really handling clipping, just do the rhw so we can