radv/gfx10: add missing conversions for 16-bit exports

Submitted by Samuel Pitoiset on July 15, 2019, 8:44 a.m.

Details

Message ID 20190715084453.14010-1-samuel.pitoiset@gmail.com
State New
Headers show
Series "radv/gfx10: add missing conversions for 16-bit exports" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Samuel Pitoiset July 15, 2019, 8:44 a.m.
This fixes
dEQP-VK.spirv_assembly.instruction.graphics.16bit_storage.input_output_*

Found with RADV_DEBUG=checkir

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

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 339c9d93423..fa26a450a91 100644
--- a/src/amd/vulkan/radv_nir_to_llvm.c
+++ b/src/amd/vulkan/radv_nir_to_llvm.c
@@ -3691,6 +3691,13 @@  static void gfx10_ngg_gs_emit_epilogue_2(struct radv_shader_context *ctx)
 				gep_idx[2] = LLVMConstInt(ctx->ac.i32, out_idx, false);
 				tmp = LLVMBuildGEP(builder, vertexptr, gep_idx, 3, "");
 				tmp = LLVMBuildLoad(builder, tmp, "");
+
+				LLVMTypeRef type = LLVMGetAllocatedType(ctx->abi.outputs[ac_llvm_reg_index_soa(i, j)]);
+				if (ac_get_type_size(type) == 2) {
+					tmp = LLVMBuildBitCast(ctx->ac.builder, tmp, ctx->ac.i32, "");
+					tmp = LLVMBuildTrunc(ctx->ac.builder, tmp, ctx->ac.i16, "");
+				}
+
 				outputs[noutput].values[j] = ac_to_float(&ctx->ac, tmp);
 			}
 
@@ -3771,6 +3778,8 @@  static void gfx10_ngg_gs_emit_vertex(struct radv_shader_context *ctx,
 			LLVMValueRef ptr = LLVMBuildGEP(builder, vertexptr, gep_idx, 3, "");
 
 			out_val = ac_to_integer(&ctx->ac, out_val);
+			out_val = LLVMBuildZExtOrBitCast(ctx->ac.builder, out_val, ctx->ac.i32, "");
+
 			LLVMBuildStore(builder, out_val, ptr);
 		}
 	}

Comments