radv/gfx10: add missing conversions for 16-bit exports
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 15 Jul 2019 08:44:53 +0000 (10:44 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 16 Jul 2019 06:12:34 +0000 (08:12 +0200)
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>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_nir_to_llvm.c

index 5ab0d557819a86f00952ac8c3418be9473e9b844..7573292f5c8ef1e15fcac275d78f4fe0bf6020e0 100644 (file)
@@ -3677,6 +3677,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 = ac_to_integer(&ctx->ac, tmp);
+                                       tmp = LLVMBuildTrunc(ctx->ac.builder, tmp, ctx->ac.i16, "");
+                               }
+
                                outputs[noutput].values[j] = ac_to_float(&ctx->ac, tmp);
                        }
 
@@ -3757,6 +3764,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);
                }
        }