[Mesa-dev,1/3] glsl: Fix gl_program::OutputsWritten computation for dual-source blending.

Submitted by Francisco Jerez on Aug. 23, 2016, 1:59 a.m.

Details

Message ID 20160823015945.13004-1-currojerez@riseup.net
State New
Headers show
Series "Series without cover letter" ( rev: 3 2 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Francisco Jerez Aug. 23, 2016, 1:59 a.m.
In the fragment shader OutputsWritten is a bitset of FRAG_RESULT_*
enumerants, which represent the location of each color output written
by the shader.  The secondary and primary color outputs of a given
render target using dual-source blending have the same location, so
the 'idx' computation below will give the wrong bit as result if the
'var->data.index' term is non-zero -- E.g. if the shader writes the
primary and secondary colors of the FRAG_RESULT_COLOR output,
ir_set_program_inouts will think that the shader writes both
FRAG_RESULT_COLOR and FRAG_RESULT_SAMPLE_MASK, which is just bogus.

That would cause the brw_wm_prog_key::nr_color_regions computation
done in the i965 driver during fragment shader precompilation to be
wrong, which currently leads to unnecessary recompilation of shaders
that use dual-source blending, and triggers an assertion failure in
fs_visitor::emit_fb_writes() on my i965-fb-fetch branch.
---
 src/compiler/glsl/ir_set_program_inouts.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/compiler/glsl/ir_set_program_inouts.cpp b/src/compiler/glsl/ir_set_program_inouts.cpp
index fcfbcd4..0292b67 100644
--- a/src/compiler/glsl/ir_set_program_inouts.cpp
+++ b/src/compiler/glsl/ir_set_program_inouts.cpp
@@ -96,7 +96,7 @@  mark(struct gl_program *prog, ir_variable *var, int offset, int len,
    for (int i = 0; i < len; i++) {
       assert(var->data.location != -1);
 
-      int idx = var->data.location + var->data.index + offset + i;
+      int idx = var->data.location + offset + i;
       bool is_patch_generic = var->data.patch &&
                               idx != VARYING_SLOT_TESS_LEVEL_INNER &&
                               idx != VARYING_SLOT_TESS_LEVEL_OUTER;