<div dir="ltr"><div>Thanks for figuring out how to do this properly.<br><br></div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 27, 2015 at 12:06 AM, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We used to loop over all color attachments, and emit FB writes for each<br>
one, even if the shader didn't write to a corresponding output variable.<br>
Those color attachments would be filled with garbage (undefined values).<br>
<br>
Football Manager binds a framebuffer with 4 color attachments, but draws<br>
to it using a shader that only writes to gl_FragData[0..2]. This meant<br>
that color attachment 3 would be filled with garbage, resulting in<br>
rendering artifacts. Now we skip writing to it, fixing rendering.<br>
<br>
Writes to gl_FragColor initialize outputs[0..nr_color_regions-1] to<br>
GRFs, while writes to gl_FragData[i] initialize outputs[i].<br>
<br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=86747" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=86747</a><br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
Cc: <a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.freedesktop.org</a><br>
---<br>
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 12 +++++++++---<br>
1 file changed, 9 insertions(+), 3 deletions(-)<br>
<br>
While this should be much more correct, I wonder if more fixes are needed.<br>
<br>
It seems like the loop condition should be:<br>
<br>
for (int target = 0; target < BRW_MAX_DRAW_BUFFERS; target++)<br>
<br>
Even if we have only 1 color region, it could be attached to<br>
GL_COLOR_ATTACHMENT3. (Ilia mentioned this should be legal.)<br>
It sure looks like that would break here (and probably always has).<br>
Unfortunately, fixing that means binding more NULL render targets,<br>
and that's complex enough I think it's best left to a follow-up series.<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
index 77e1103..dc5c2fe 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
@@ -3646,7 +3646,7 @@ fs_visitor::emit_fb_writes()<br>
do_dual_src = false;<br>
}<br>
<br>
- fs_inst *inst;<br>
+ fs_inst *inst = NULL;<br>
if (do_dual_src) {<br>
this->current_annotation = ralloc_asprintf(this->mem_ctx,<br>
"FB dual-source write");<br>
@@ -3654,8 +3654,12 @@ fs_visitor::emit_fb_writes()<br>
reg_undef, 4);<br>
inst->target = 0;<br>
prog_data->dual_src_blend = true;<br>
- } else if (key->nr_color_regions > 0) {<br>
+ } else {<br>
for (int target = 0; target < key->nr_color_regions; target++) {<br>
+ /* Skip over outputs that weren't written. */<br>
+ if (this->outputs[target].file == BAD_FILE)<br>
+ continue;<br>
+<br>
this->current_annotation = ralloc_asprintf(this->mem_ctx,<br>
"FB write target %d",<br>
target);<br>
@@ -3668,7 +3672,9 @@ fs_visitor::emit_fb_writes()<br>
this->output_components[target]);<br>
inst->target = target;<br>
}<br>
- } else {<br>
+ }<br>
+<br>
+ if (inst == NULL) {<br>
/* Even if there's no color buffers enabled, we still need to send<br>
* alpha out the pipeline to our null renderbuffer to support<br>
* alpha-testing, alpha-to-coverage, and so on.<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.2.2<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>