freedreno: Make the slice pitch be bytes, not pixels.
[mesa.git] / src / gallium / drivers / freedreno / ir3 / ir3_gallium.c
index 9ad67d2ec9b07b01eae943ef03f611613b04534a..04474097f552fc6079bb05279003cb63bd424625 100644 (file)
@@ -51,13 +51,15 @@ dump_shader_info(struct ir3_shader_variant *v, bool binning_pass,
                return;
 
        pipe_debug_message(debug, SHADER_INFO,
-                       "%s shader: %u inst, %u nops, %u non-nops, %u dwords, "
-                       "%u last-baryf, %u half, %u full, %u constlen, "
+                       "%s shader: %u inst, %u nops, %u non-nops, %u mov, %u cov, "
+                       "%u dwords, %u last-baryf, %u half, %u full, %u constlen, "
                        "%u sstall, %u (ss), %u (sy), %d max_sun, %d loops\n",
                        ir3_shader_stage(v),
                        v->info.instrs_count,
                        v->info.nops_count,
                        v->info.instrs_count - v->info.nops_count,
+                       v->info.mov_count,
+                       v->info.cov_count,
                        v->info.sizedwords,
                        v->info.last_baryf,
                        v->info.max_half_reg + 1,
@@ -144,6 +146,7 @@ ir3_shader_create(struct ir3_compiler *compiler,
                if (nir->info.stage != MESA_SHADER_FRAGMENT)
                        ir3_shader_variant(shader, key, true, debug);
        }
+
        return shader;
 }
 
@@ -170,6 +173,15 @@ ir3_shader_create_compute(struct ir3_compiler *compiler,
 
        struct ir3_shader *shader = ir3_shader_from_nir(compiler, nir);
 
+       if (fd_mesa_debug & FD_DBG_SHADERDB) {
+               /* if shader-db run, create a standard variant immediately
+                * (as otherwise nothing will trigger the shader to be
+                * actually compiled)
+                */
+               static struct ir3_shader_key key; /* static is implicitly zeroed */
+               ir3_shader_variant(shader, key, false, debug);
+       }
+
        return shader;
 }
 
@@ -249,9 +261,12 @@ ir3_emit_user_consts(struct fd_screen *screen, const struct ir3_shader_variant *
        struct ir3_ubo_analysis_state *state;
        state = &v->shader->ubo_state;
 
-       uint32_t i;
-       foreach_bit(i, state->enabled & constbuf->enabled_mask) {
-               struct pipe_constant_buffer *cb = &constbuf->cb[i];
+       for (unsigned i = 0; i < state->num_enabled; i++) {
+               assert(!state->range[i].bindless);
+               unsigned ubo = state->range[i].block;
+               if (!(constbuf->enabled_mask & (1 << ubo)))
+                       continue;
+               struct pipe_constant_buffer *cb = &constbuf->cb[ubo];
 
                uint32_t size = state->range[i].end - state->range[i].start;
                uint32_t offset = cb->buffer_offset + state->range[i].start;
@@ -354,7 +369,7 @@ ir3_emit_image_dims(struct fd_screen *screen, const struct ir3_shader_variant *v
                                 * be the same, so use original dimensions for y and z
                                 * stride:
                                 */
-                               dims[off + 1] = slice->pitch * rsc->layout.cpp;
+                               dims[off + 1] = slice->pitch;
                                /* see corresponding logic in fd_resource_offset(): */
                                if (rsc->layout.layer_first) {
                                        dims[off + 2] = rsc->layout.layer_size;
@@ -402,42 +417,6 @@ ir3_emit_immediates(struct fd_screen *screen, const struct ir3_shader_variant *v
        }
 }
 
-static uint32_t
-link_geometry_stages(const struct ir3_shader_variant *producer,
-               const struct ir3_shader_variant *consumer,
-               uint32_t *locs)
-{
-       uint32_t num_loc = 0, factor;
-
-       switch (consumer->type) {
-       case MESA_SHADER_TESS_CTRL:
-       case MESA_SHADER_GEOMETRY:
-               /* These stages load with ldlw, which expects byte offsets. */
-               factor = 4;
-               break;
-       case MESA_SHADER_TESS_EVAL:
-               /* The tess eval shader uses ldg, which takes dword offsets. */
-               factor = 1;
-               break;
-       default:
-               unreachable("bad shader stage");
-       }
-
-       nir_foreach_variable(in_var, &consumer->shader->nir->inputs) {
-               nir_foreach_variable(out_var, &producer->shader->nir->outputs) {
-                       if (in_var->data.location == out_var->data.location) {
-                               locs[in_var->data.driver_location] =
-                                       producer->shader->output_loc[out_var->data.driver_location] * factor;
-
-                               debug_assert(num_loc <= in_var->data.driver_location + 1);
-                               num_loc = in_var->data.driver_location + 1;
-                       }
-               }
-       }
-
-       return num_loc;
-}
-
 void
 ir3_emit_link_map(struct fd_screen *screen,
                const struct ir3_shader_variant *producer,
@@ -447,7 +426,7 @@ ir3_emit_link_map(struct fd_screen *screen,
        uint32_t base = const_state->offsets.primitive_map;
        uint32_t patch_locs[MAX_VARYING] = { }, num_loc;
 
-       num_loc = link_geometry_stages(producer, v, patch_locs);
+       num_loc = ir3_link_geometry_stages(producer, v, patch_locs);
 
        int size = DIV_ROUND_UP(num_loc, 4);