[Mesa-dev] [PATCH 08/20] radeonsi: gather stream info in nir path

Timothy Arceri tarceri at itsqueeze.com
Fri Nov 10 03:13:42 UTC 2017


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

diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c
index 32f6d86647..847d75ba14 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -241,20 +241,57 @@ void si_nir_scan_shader(const struct nir_shader *nir,
 				&semantic_name, &semantic_index);
 		} else {
 			tgsi_get_gl_varying_semantic(variable->data.location, true,
 						     &semantic_name, &semantic_index);
 		}
 
 		info->output_semantic_name[i] = semantic_name;
 		info->output_semantic_index[i] = semantic_index;
 		info->output_usagemask[i] = TGSI_WRITEMASK_XYZW;
 
+		unsigned num_components = 4;
+		unsigned vector_elements = glsl_get_vector_elements(glsl_without_array(variable->type));
+		if (vector_elements)
+			num_components = vector_elements;
+
+		unsigned gs_out_streams;
+		if (variable->data.stream & (1u << 31)) {
+			gs_out_streams = variable->data.stream & ~(1u << 31);
+		} else {
+			assert(variable->data.stream < 4);
+			gs_out_streams = 0;
+			for (unsigned j = 0; j < num_components; ++j)
+				gs_out_streams |= variable->data.stream << (2 * (variable->data.location_frac + j));
+		}
+
+		unsigned streamx = gs_out_streams & 3;
+		unsigned streamy = (gs_out_streams >> 2) & 3;
+		unsigned streamz = (gs_out_streams >> 4) & 3;
+		unsigned streamw = (gs_out_streams >> 6) & 3;
+
+		if (info->output_usagemask[i] & TGSI_WRITEMASK_X) {
+			info->output_streams[i] |= streamx;
+			info->num_stream_output_components[streamx]++;
+		}
+		if (info->output_usagemask[i] & TGSI_WRITEMASK_Y) {
+			info->output_streams[i] |= streamy << 2;
+			info->num_stream_output_components[streamy]++;
+		}
+		if (info->output_usagemask[i] & TGSI_WRITEMASK_Z) {
+			info->output_streams[i] |= streamz << 4;
+			info->num_stream_output_components[streamz]++;
+		}
+		if (info->output_usagemask[i] & TGSI_WRITEMASK_W) {
+			info->output_streams[i] |= streamw << 6;
+			info->num_stream_output_components[streamw]++;
+		}
+
 		switch (semantic_name) {
 		case TGSI_SEMANTIC_PRIMID:
 			info->writes_primid = true;
 			break;
 		case TGSI_SEMANTIC_VIEWPORT_INDEX:
 			info->writes_viewport_index = true;
 			break;
 		case TGSI_SEMANTIC_LAYER:
 			info->writes_layer = true;
 			break;
-- 
2.14.3



More information about the mesa-dev mailing list