freedreno/a5xx: use the non-_ZERO_BASE for vertexid
authorRob Clark <robdclark@gmail.com>
Mon, 9 Jan 2017 21:12:59 +0000 (16:12 -0500)
committerRob Clark <robdclark@gmail.com>
Wed, 11 Jan 2017 00:40:00 +0000 (19:40 -0500)
Signed-off-by: Rob Clark <robdclark@gmail.com>
src/gallium/drivers/freedreno/a5xx/fd5_program.c
src/gallium/drivers/freedreno/freedreno_screen.c
src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
src/gallium/drivers/freedreno/ir3/ir3_shader.h

index 3e8c0c83e61137ad39d4d0e2196a0a81eb3f21e9..ee2cd4838b5fe60fd84d40b237da0a4bc34680d9 100644 (file)
@@ -342,8 +342,8 @@ fd5_program_emit(struct fd_ringbuffer *ring, struct fd5_emit *emit)
 
        pos_regid = ir3_find_output_regid(s[VS].v, VARYING_SLOT_POS);
        psize_regid = ir3_find_output_regid(s[VS].v, VARYING_SLOT_PSIZ);
-       vertex_regid = ir3_find_output_regid(s[VS].v, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE);
-       instance_regid = ir3_find_output_regid(s[VS].v, SYSTEM_VALUE_INSTANCE_ID);
+       vertex_regid = ir3_find_sysval_regid(s[VS].v, SYSTEM_VALUE_VERTEX_ID);
+       instance_regid = ir3_find_sysval_regid(s[VS].v, SYSTEM_VALUE_INSTANCE_ID);
 
        if (s[FS].v->color0_mrt) {
                color_regid[0] = color_regid[1] = color_regid[2] = color_regid[3] =
@@ -710,7 +710,7 @@ fd5_program_emit(struct fd_ringbuffer *ring, struct fd5_emit *emit)
        OUT_PKT4(ring, REG_A5XX_VFD_CONTROL_1, 5);
        OUT_RING(ring, A5XX_VFD_CONTROL_1_REGID4VTX(vertex_regid) |
                        A5XX_VFD_CONTROL_1_REGID4INST(instance_regid) |
-                       0xfc);
+                       0xfc0000);
        OUT_RING(ring, 0x0000fcfc);   /* VFD_CONTROL_2 */
        OUT_RING(ring, 0x0000fcfc);   /* VFD_CONTROL_3 */
        OUT_RING(ring, 0x000000fc);   /* VFD_CONTROL_4 */
index 3b631372e9946d4fe913a906c18e9532c92c9e20..63e0d204735ce946eed15a7416fb344342002b16 100644 (file)
@@ -176,11 +176,13 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
        case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
        case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
        case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
-       case PIPE_CAP_VERTEXID_NOBASE:
        case PIPE_CAP_STRING_MARKER:
        case PIPE_CAP_MIXED_COLOR_DEPTH_BITS:
                return 1;
 
+       case PIPE_CAP_VERTEXID_NOBASE:
+               return is_a3xx(screen) || is_a4xx(screen);
+
        case PIPE_CAP_USER_CONSTANT_BUFFERS:
                return is_a4xx(screen) ? 0 : 1;
 
index a68e8246f87b75ade9f69a015d76edd8de833cca..77d86855ddb774dfd2e5eb7d1c67b7e42c448278 100644 (file)
@@ -1246,10 +1246,12 @@ emit_intrinsic(struct ir3_compile *ctx, nir_intrinsic_instr *intr)
                dst[0] = ctx->basevertex;
                break;
        case nir_intrinsic_load_vertex_id_zero_base:
+       case nir_intrinsic_load_vertex_id:
                if (!ctx->vertex_id) {
+                       gl_system_value sv = (intr->intrinsic == nir_intrinsic_load_vertex_id) ?
+                               SYSTEM_VALUE_VERTEX_ID : SYSTEM_VALUE_VERTEX_ID_ZERO_BASE;
                        ctx->vertex_id = create_input(b, 0);
-                       add_sysval_input(ctx, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE,
-                                       ctx->vertex_id);
+                       add_sysval_input(ctx, sv, ctx->vertex_id);
                }
                dst[0] = ctx->vertex_id;
                break;
index 678a6306aeef189928f418e5d85c93e3d4b737d9..052a563b9455a821920a95a3d69abf01ffea8b50 100644 (file)
@@ -391,4 +391,14 @@ ir3_find_output_regid(const struct ir3_shader_variant *so, unsigned slot)
        return regid(63, 0);
 }
 
+static inline uint32_t
+ir3_find_sysval_regid(const struct ir3_shader_variant *so, unsigned slot)
+{
+       int j;
+       for (j = 0; j < so->inputs_count; j++)
+               if (so->inputs[j].sysval && (so->inputs[j].slot == slot))
+                       return so->inputs[j].regid;
+       return regid(63, 0);
+}
+
 #endif /* IR3_SHADER_H_ */