zink: only export necessary xfb outputs to ntv
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Wed, 24 Feb 2021 20:24:39 +0000 (15:24 -0500)
committerMarge Bot <eric+marge@anholt.net>
Tue, 9 Mar 2021 02:52:20 +0000 (02:52 +0000)
the full-variable outputs can be skipped, leaving only the varyings which
actually need explicit emission due to packed layouts or whatever

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9271>

src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
src/gallium/drivers/zink/zink_compiler.c
src/gallium/drivers/zink/zink_compiler.h

index db43787..5055d8d 100644 (file)
@@ -1260,8 +1260,6 @@ emit_so_info(struct ntv_context *ctx, const struct zink_so_info *so_info)
 {
    unsigned output = 0;
    for (unsigned i = 0; i < so_info->so_info.num_outputs; i++) {
-      if (so_info->skip[i])
-         continue;
       struct pipe_stream_output so_output = so_info->so_info.output[i];
       unsigned slot = so_info->so_info_slots[i] << 2 | so_output.start_component;
       SpvId out_type = get_output_type(ctx, slot, so_output.num_components);
@@ -1309,8 +1307,6 @@ emit_so_outputs(struct ntv_context *ctx,
                 const struct zink_so_info *so_info)
 {
    for (unsigned i = 0; i < so_info->so_info.num_outputs; i++) {
-      if (so_info->skip[i])
-         continue;
       uint32_t components[NIR_MAX_VEC_COMPONENTS];
       unsigned slot = so_info->so_info_slots[i];
       struct pipe_stream_output so_output = so_info->so_info.output[i];
index de5ef7f..1f56708 100644 (file)
@@ -424,16 +424,16 @@ update_so_info(struct zink_shader *zs, const struct pipe_stream_output_info *so_
    for (unsigned i = 0; i < so_info->num_outputs; i++) {
       const struct pipe_stream_output *output = &so_info->output[i];
       unsigned slot = reverse_map[output->register_index];
+      /* always set stride to be used during draw */
+      zs->streamout.so_info.stride[output->output_buffer] = so_info->stride[output->output_buffer];
       if ((zs->nir->info.stage != MESA_SHADER_GEOMETRY || util_bitcount(zs->nir->info.gs.active_stream_mask) == 1) &&
           !output->start_component) {
          nir_variable *var = NULL;
          while (!var)
             var = nir_find_variable_with_location(zs->nir, nir_var_shader_out, slot--);
          slot++;
-         if (inlined[slot]) {
-            zs->streamout.skip[i] = true;
+         if (inlined[slot])
             continue;
-         }
          assert(var && var->data.location == slot);
          /* if this is the entire variable, try to blast it out during the initial declaration */
          if (glsl_get_components(var->type) == output->num_components) {
@@ -442,13 +442,13 @@ update_so_info(struct zink_shader *zs, const struct pipe_stream_output_info *so_
             var->data.xfb.stride = so_info->stride[output->output_buffer] * 4;
             var->data.offset = output->dst_offset * 4;
             var->data.stream = output->stream;
-            zs->streamout.skip[i] = true;
             inlined[slot] = true;
             continue;
          }
       }
+      zs->streamout.so_info.output[zs->streamout.so_info.num_outputs] = *output;
       /* Map Gallium's condensed "slots" back to real VARYING_SLOT_* enums */
-      zs->streamout.so_info_slots[i] = reverse_map[output->register_index];
+      zs->streamout.so_info_slots[zs->streamout.so_info.num_outputs++] = reverse_map[output->register_index];
    }
    zs->streamout.have_xfb = true;
 }
@@ -691,11 +691,8 @@ zink_shader_create(struct zink_screen *screen, struct nir_shader *nir,
    }
 
    ret->nir = nir;
-   if (so_info && nir->info.outputs_written && nir->info.has_transform_feedback_varyings) {
-      memcpy(&ret->streamout.so_info, so_info, sizeof(struct pipe_stream_output_info));
+   if (so_info && nir->info.outputs_written && nir->info.has_transform_feedback_varyings)
       update_so_info(ret, so_info, nir->info.outputs_written, have_psiz);
-   }
-
 
    return ret;
 }
index bc2c57d..e61d8ae 100644 (file)
@@ -51,7 +51,6 @@ struct tgsi_token;
 struct zink_so_info {
    struct pipe_stream_output_info so_info;
    unsigned so_info_slots[PIPE_MAX_SO_OUTPUTS];
-   bool skip[PIPE_MAX_SO_OUTPUTS];
    bool have_xfb;
 };