[Mesa-dev] [PATCH] radeonsi: fix discard-only fragment shaders

Nicolai Hähnle nhaehnle at gmail.com
Tue Jan 19 12:13:41 PST 2016


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

When a fragment shader is used that has no outputs but does conditional
discard (KILL_IF), all fragments are killed without this patch.

By comparing various register settings, my conclusion is that the exec mask
is either not properly forwarded to the DB by NULL exports or ends up being
unused, at least when there is _only_ a NULL export (the ISA documentation
claims that NULL exports can be used to override a previously exported exec
mask).

Of the various approaches I have tried to work around the problem, this one
seems to be the least invasive one.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93761
---
I've condensed the bug reporter's test case to a Piglit test that I will
send out soon.

This should probably go to stable as well, but won't apply as is because of
the many recent changes to fragment shader export handling. I will follow
this mail up with a version that applies to 11.1 and that I've confirmed
fixes the problem there as well.

 src/gallium/drivers/radeonsi/si_state_shaders.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 8ff70b4..0f0cbb2 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -456,6 +456,7 @@ static void si_shader_ps(struct si_shader *shader)
 		       info->writes_samplemask ? V_028710_SPI_SHADER_32_ABGR :
 		       info->writes_stencil ? V_028710_SPI_SHADER_32_GR :
 		       info->writes_z ? V_028710_SPI_SHADER_32_R :
+		       (info->uses_kill && !info->num_outputs) ? V_028710_SPI_SHADER_32_R :
 		       V_028710_SPI_SHADER_ZERO);
 
 	si_pm4_set_reg(pm4, R_028714_SPI_SHADER_COL_FORMAT, spi_shader_col_format);
-- 
2.5.0



More information about the mesa-dev mailing list