radv: pass output values to radv_emit_stream_output()

Submitted by Samuel Pitoiset on July 14, 2019, 10:55 a.m.

Details

Message ID 20190714105558.10791-1-samuel.pitoiset@gmail.com
State New
Headers show
Series "radv: pass output values to radv_emit_stream_output()" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Samuel Pitoiset July 14, 2019, 10:55 a.m.
For GFX10 stream output.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
---
 src/amd/vulkan/radv_nir_to_llvm.c | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/amd/vulkan/radv_nir_to_llvm.c b/src/amd/vulkan/radv_nir_to_llvm.c
index e4ab5847729..93a8c75b219 100644
--- a/src/amd/vulkan/radv_nir_to_llvm.c
+++ b/src/amd/vulkan/radv_nir_to_llvm.c
@@ -125,6 +125,13 @@  struct radv_shader_context {
 	LLVMValueRef vertexptr; /* GFX10 only */
 };
 
+struct radv_shader_output_values {
+	LLVMValueRef values[4];
+	unsigned slot_name;
+	unsigned slot_index;
+	unsigned usage_mask;
+};
+
 enum radeon_llvm_calling_convention {
 	RADEON_LLVM_AMDGPU_VS = 87,
 	RADEON_LLVM_AMDGPU_GS = 88,
@@ -2615,10 +2622,10 @@  static void
 radv_emit_stream_output(struct radv_shader_context *ctx,
 			 LLVMValueRef const *so_buffers,
 			 LLVMValueRef const *so_write_offsets,
-			 const struct radv_stream_output *output)
+			 const struct radv_stream_output *output,
+			 struct radv_shader_output_values *shader_out)
 {
 	unsigned num_comps = util_bitcount(output->component_mask);
-	unsigned loc = output->location;
 	unsigned buf = output->buffer;
 	unsigned offset = output->offset;
 	unsigned start;
@@ -2633,8 +2640,7 @@  radv_emit_stream_output(struct radv_shader_context *ctx,
 
 	/* Load the output as int. */
 	for (int i = 0; i < num_comps; i++) {
-		out[i] = ac_to_integer(&ctx->ac,
-				       radv_load_output(ctx, loc, start + i));
+		out[i] = ac_to_integer(&ctx->ac, shader_out->values[start + i]);
 	}
 
 	/* Pack the output. */
@@ -2731,26 +2737,25 @@  radv_emit_streamout(struct radv_shader_context *ctx, unsigned stream)
 
 		/* Write streamout data. */
 		for (i = 0; i < ctx->shader_info->info.so.num_outputs; i++) {
+			struct radv_shader_output_values shader_out = {};
 			struct radv_stream_output *output =
 				&ctx->shader_info->info.so.outputs[i];
 
 			if (stream != output->stream)
 				continue;
 
-			radv_emit_stream_output(ctx, so_buffers,
-						so_write_offset, output);
+			for (int j = 0; j < 4; j++) {
+				shader_out.values[j] =
+					radv_load_output(ctx, output->location, j);
+			}
+
+			radv_emit_stream_output(ctx, so_buffers,so_write_offset,
+						output, &shader_out);
 		}
 	}
 	ac_nir_build_endif(&if_ctx);
 }
 
-struct radv_shader_output_values {
-	LLVMValueRef values[4];
-	unsigned slot_name;
-	unsigned slot_index;
-	unsigned usage_mask;
-};
-
 static void
 radv_build_param_exports(struct radv_shader_context *ctx,
 			 struct radv_shader_output_values *outputs,