[Mesa-dev] [PATCH 3/4] radeonsi: add assertions to validate interpolation flags

Marek Olšák maraeo at gmail.com
Tue Oct 4 22:35:52 UTC 2016


From: Marek Olšák <marek.olsak at amd.com>

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

diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 9662625..f6bd129 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -686,20 +686,54 @@ static void si_shader_ps(struct si_shader *shader)
 
 	/* we need to enable at least one of them, otherwise we hang the GPU */
 	assert(G_0286CC_PERSP_SAMPLE_ENA(input_ena) ||
 	       G_0286CC_PERSP_CENTER_ENA(input_ena) ||
 	       G_0286CC_PERSP_CENTROID_ENA(input_ena) ||
 	       G_0286CC_PERSP_PULL_MODEL_ENA(input_ena) ||
 	       G_0286CC_LINEAR_SAMPLE_ENA(input_ena) ||
 	       G_0286CC_LINEAR_CENTER_ENA(input_ena) ||
 	       G_0286CC_LINEAR_CENTROID_ENA(input_ena) ||
 	       G_0286CC_LINE_STIPPLE_TEX_ENA(input_ena));
+	/* POS_W_FLOAT_ENA requires one of the perspective weights. */
+	assert(!G_0286CC_POS_W_FLOAT_ENA(input_ena) ||
+	       G_0286CC_PERSP_SAMPLE_ENA(input_ena) ||
+	       G_0286CC_PERSP_CENTER_ENA(input_ena) ||
+	       G_0286CC_PERSP_CENTROID_ENA(input_ena) ||
+	       G_0286CC_PERSP_PULL_MODEL_ENA(input_ena));
+
+	/* Validate interpolation optimization flags (read as implications). */
+	assert(!shader->key.ps.prolog.bc_optimize_for_persp ||
+	       (G_0286CC_PERSP_CENTER_ENA(input_ena) &&
+		G_0286CC_PERSP_CENTROID_ENA(input_ena)));
+	assert(!shader->key.ps.prolog.bc_optimize_for_linear ||
+	       (G_0286CC_LINEAR_CENTER_ENA(input_ena) &&
+		G_0286CC_LINEAR_CENTROID_ENA(input_ena)));
+	assert(!shader->key.ps.prolog.force_persp_center_interp ||
+	       (!G_0286CC_PERSP_SAMPLE_ENA(input_ena) &&
+		!G_0286CC_PERSP_CENTROID_ENA(input_ena)));
+	assert(!shader->key.ps.prolog.force_linear_center_interp ||
+	       (!G_0286CC_LINEAR_SAMPLE_ENA(input_ena) &&
+		!G_0286CC_LINEAR_CENTROID_ENA(input_ena)));
+	assert(!shader->key.ps.prolog.force_persp_sample_interp ||
+	       (!G_0286CC_PERSP_CENTER_ENA(input_ena) &&
+		!G_0286CC_PERSP_CENTROID_ENA(input_ena)));
+	assert(!shader->key.ps.prolog.force_linear_sample_interp ||
+	       (!G_0286CC_LINEAR_CENTER_ENA(input_ena) &&
+		!G_0286CC_LINEAR_CENTROID_ENA(input_ena)));
+
+	/* Validate cases when the optimizations are off (read as implications). */
+	assert(shader->key.ps.prolog.bc_optimize_for_persp ||
+	       !G_0286CC_PERSP_CENTER_ENA(input_ena) ||
+	       !G_0286CC_PERSP_CENTROID_ENA(input_ena));
+	assert(shader->key.ps.prolog.bc_optimize_for_linear ||
+	       !G_0286CC_LINEAR_CENTER_ENA(input_ena) ||
+	       !G_0286CC_LINEAR_CENTROID_ENA(input_ena));
 
 	pm4 = si_get_shader_pm4_state(shader);
 	if (!pm4)
 		return;
 
 	/* SPI_BARYC_CNTL.POS_FLOAT_LOCATION
 	 * Possible vaules:
 	 * 0 -> Position = pixel center
 	 * 1 -> Position = pixel centroid
 	 * 2 -> Position = at sample position
-- 
2.7.4



More information about the mesa-dev mailing list