Mesa (master): svga: skip vertex attribute instruction with zero usage_mask

Brian Paul brianp at kemper.freedesktop.org
Wed Jan 6 23:01:10 UTC 2016


Module: Mesa
Branch: master
Commit: b074a5b02de3dc0e2d0cbb6b9154673153b29525
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b074a5b02de3dc0e2d0cbb6b9154673153b29525

Author: Charmaine Lee <charmainel at vmware.com>
Date:   Mon Jan  4 10:36:48 2016 -0800

svga: skip vertex attribute instruction with zero usage_mask

In emit_input_declarations(), we are skipping declarations for those
registers that are not being used. But in emit_vertex_attrib_instructions(),
we are still emitting instructions to tweak the vertex attributes even if
they are not being used. This causes an assert in the backend because an
input register is not declared in the shader. This patch fixes the problem
by skipping the instruction if the vertex attribute is not being used.
Changes in this patch is originated from the code snippet from Jose as
suggested in bug 1530161.

Tested with piglit, Heaven, Turbine, glretrace.

Reviewed-by: Jose Fonseca <jfonseca at vmware.com>
Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/gallium/drivers/svga/svga_tgsi_vgpu10.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
index c979f4a..c5be11f 100644
--- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
+++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
@@ -6170,6 +6170,11 @@ emit_vertex_attrib_instructions(struct svga_shader_emitter_v10 *emit)
 
       while (adjust_mask) {
          unsigned index = u_bit_scan(&adjust_mask);
+
+         /* skip the instruction if this vertex attribute is not being used */
+         if (emit->info.input_usage_mask[index] == 0)
+            continue;
+
          unsigned tmp = emit->vs.adjusted_input[index];
          struct tgsi_full_src_register input_src =
             make_src_reg(TGSI_FILE_INPUT, index);




More information about the mesa-commit mailing list