freedreno/ir3: set proper dst type for uniform according to the type of nir dest.
authorHyunjun Ko <zzoon@igalia.com>
Tue, 26 Feb 2019 08:33:34 +0000 (08:33 +0000)
committerRob Clark <robdclark@chromium.org>
Mon, 3 Jun 2019 19:44:03 +0000 (12:44 -0700)
eg. uniform mediump vec4 f;

This patch means nothing since there's no mediump lowering pass for now,
but will be meaningful when the pass land in the near future.

Signed-off-by: Rob Clark <robdclark@chromium.org>
src/freedreno/ir3/ir3.h
src/freedreno/ir3/ir3_compiler_nir.c

index ccd102b8e4424cae3f54423c0c2bc8bd8c1883b4..161e78e0febb8bd7d66b4607664547392b7be7e8 100644 (file)
@@ -1061,20 +1061,26 @@ create_immed(struct ir3_block *block, uint32_t val)
 }
 
 static inline struct ir3_instruction *
-create_uniform(struct ir3_block *block, unsigned n)
+create_uniform_typed(struct ir3_block *block, unsigned n, type_t type)
 {
        struct ir3_instruction *mov;
+       unsigned flags = (type_size(type) < 32) ? IR3_REG_HALF : 0;
 
        mov = ir3_instr_create(block, OPC_MOV);
-       /* TODO get types right? */
-       mov->cat1.src_type = TYPE_F32;
-       mov->cat1.dst_type = TYPE_F32;
-       ir3_reg_create(mov, 0, 0);
-       ir3_reg_create(mov, n, IR3_REG_CONST);
+       mov->cat1.src_type = type;
+       mov->cat1.dst_type = type;
+       ir3_reg_create(mov, 0, flags);
+       ir3_reg_create(mov, n, IR3_REG_CONST | flags);
 
        return mov;
 }
 
+static inline struct ir3_instruction *
+create_uniform(struct ir3_block *block, unsigned n)
+{
+       return create_uniform_typed(block, n, TYPE_F32);
+}
+
 static inline struct ir3_instruction *
 create_uniform_indirect(struct ir3_block *block, int n,
                struct ir3_instruction *address)
index 0a97c42159f1fe429122918dd90f3cb5f45bd741..8fbb45c489c7f082904ee8056b1a489ed9d158fc 100644 (file)
@@ -1250,7 +1250,8 @@ emit_intrinsic(struct ir3_context *ctx, nir_intrinsic_instr *intr)
                if (nir_src_is_const(intr->src[0])) {
                        idx += nir_src_as_uint(intr->src[0]);
                        for (int i = 0; i < intr->num_components; i++) {
-                               dst[i] = create_uniform(b, idx + i);
+                               dst[i] = create_uniform_typed(b, idx + i,
+                                       nir_dest_bit_size(intr->dest) < 32 ? TYPE_F16 : TYPE_F32);
                        }
                } else {
                        src = ir3_get_src(ctx, &intr->src[0]);