summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2016-02-29 15:15:03 +1000
committerDave Airlie <airlied@redhat.com>2016-02-29 15:15:39 +1000
commitd413cba1e9ee6702b491f0d077a29294c30b1a7c (patch)
treee39cf8e90a3e2f63c251c3e1f439f975e87dd214
parentd6ade3c0c3701483ce8ecf245a98337a7e24048d (diff)
renderer: handle gaps in vertex shader inputs
We are seeing shaders with 0 and 2 inputs, but no 1, so we need to handle gaps properly. This fixes some regressions in drawpixels after some mesa changes on the guest.
-rw-r--r--src/vrend_renderer.c4
-rw-r--r--src/vrend_shader.c5
-rw-r--r--src/vrend_shader.h2
3 files changed, 9 insertions, 2 deletions
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 2bb3423..2072dfb 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -863,7 +863,9 @@ static struct vrend_linked_shader_program *add_shader_program(struct vrend_conte
sprog->dual_src_linked = false;
if (vrend_state.have_vertex_attrib_binding) {
- for (i = 0; i < vs->sel->sinfo.num_inputs; i++) {
+ uint32_t mask = vs->sel->sinfo.attrib_input_mask;
+ while (mask) {
+ i = u_bit_scan(&mask);
snprintf(name, 10, "in_%d", i);
glBindAttribLocation(prog_id, i, name);
}
diff --git a/src/vrend_shader.c b/src/vrend_shader.c
index 7447ef4..18e66c4 100644
--- a/src/vrend_shader.c
+++ b/src/vrend_shader.c
@@ -83,6 +83,7 @@ struct dump_ctx {
int num_interps;
int num_inputs;
+ uint32_t attrib_input_mask;
struct vrend_shader_io inputs[32];
int num_outputs;
struct vrend_shader_io outputs[32];
@@ -245,6 +246,9 @@ iter_declaration(struct tgsi_iterate_context *iter,
switch (decl->Declaration.File) {
case TGSI_FILE_INPUT:
i = ctx->num_inputs++;
+ if (iter->processor.Processor == TGSI_PROCESSOR_VERTEX) {
+ ctx->attrib_input_mask |= (1 << decl->Range.First);
+ }
ctx->inputs[i].name = decl->Semantic.Name;
ctx->inputs[i].sid = decl->Semantic.Index;
ctx->inputs[i].interpolate = decl->Interp.Interpolate;
@@ -2403,6 +2407,7 @@ char *vrend_convert_shader(struct vrend_shader_cfg *cfg,
sinfo->glsl_ver = ctx.glsl_ver_required;
sinfo->gs_out_prim = ctx.gs_out_prim;
sinfo->so_names = ctx.so_names;
+ sinfo->attrib_input_mask = ctx.attrib_input_mask;
return glsl_final;
fail:
free(ctx.glsl_main);
diff --git a/src/vrend_shader.h b/src/vrend_shader.h
index 5d9bc17..818097b 100644
--- a/src/vrend_shader.h
+++ b/src/vrend_shader.h
@@ -45,7 +45,7 @@ struct vrend_shader_info {
int glsl_ver;
uint32_t shadow_samp_mask;
int gs_out_prim;
-
+ uint32_t attrib_input_mask;
struct pipe_stream_output_info so_info;
struct vrend_interp_info *interpinfo;