r600/sfn: Add support for viewport index output
authorGert Wollny <gert.wollny@collabora.com>
Wed, 6 May 2020 21:59:34 +0000 (23:59 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 19 May 2020 07:52:13 +0000 (07:52 +0000)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5085>

src/gallium/drivers/r600/sfn/sfn_shader_geometry.cpp
src/gallium/drivers/r600/sfn/sfn_vertexstageexport.cpp

index 2edc86ff3610c27c1ad6ace1ee2742ca1b10a481..f9993c34120373d1ccb0d470d75f0214ecc15255 100644 (file)
@@ -137,6 +137,11 @@ bool GeometryShaderFromNir::do_process_outputs(nir_variable *output)
           output->data.location == VARYING_SLOT_CLIP_DIST1) {
          m_num_clip_dist += 4;
       }
+
+      if (output->data.location == VARYING_SLOT_VIEWPORT) {
+         sh_info().vs_out_viewport = 1;
+         sh_info().vs_out_misc_write = 1;
+      }
       return true;
    }
    return false;
index 3de3418c7a4947cbcbe99f74ae69be8f2c29b72e..f7ce29a1a98996bbe652f6a7abdf16b9847baf1c 100644 (file)
@@ -81,7 +81,7 @@ bool VertexStageExportBase::do_process_outputs(nir_variable *output)
 
       if (output->data.location == VARYING_SLOT_PSIZ ||
           output->data.location == VARYING_SLOT_EDGE ||
-          output->data.location == VARYING_SLOT_LAYER)
+          output->data.location == VARYING_SLOT_LAYER) // VIEWPORT?
             m_cur_clip_pos = 2;
 
       if (output->data.location != VARYING_SLOT_POS &&
@@ -110,6 +110,11 @@ bool VertexStageExportForFS::store_deref(const nir_variable *out_var, nir_intrin
       std::array<uint32_t, 4> swizzle_override = {7 ,0, 7, 7};
       return emit_varying_pos(out_var, instr, &swizzle_override);
    }
+   case VARYING_SLOT_VIEWPORT: {
+      std::array<uint32_t, 4> swizzle_override = {7, 7, 7, 0};
+      return emit_varying_pos(out_var, instr, &swizzle_override) &&
+            emit_varying_param(out_var, instr);
+   }
    case VARYING_SLOT_CLIP_VERTEX:
       return emit_clip_vertices(out_var, instr);
    case VARYING_SLOT_CLIP_DIST0:
@@ -177,6 +182,11 @@ bool VertexStageExportForFS::emit_varying_pos(const nir_variable *out_var, nir_i
    case VARYING_SLOT_LAYER:
       export_slot = 1;
       break;
+   case VARYING_SLOT_VIEWPORT:
+      m_proc.sh_info().vs_out_misc_write = 1;
+      m_proc.sh_info().vs_out_viewport = 1;
+      export_slot = 1;
+      break;
    case VARYING_SLOT_POS:
       break;
    case VARYING_SLOT_CLIP_DIST0:
@@ -407,8 +417,11 @@ bool VertexStageExportForGS::store_deref(const nir_variable *out_var, nir_intrin
       }
    }
 
-   if (out_var->data.location == VARYING_SLOT_VIEWPORT)
+   if (out_var->data.location == VARYING_SLOT_VIEWPORT) {
+      m_proc.sh_info().vs_out_viewport = 1;
+      m_proc.sh_info().vs_out_misc_write = 1;
       return true;
+   }
 
    if (ring_offset == -1) {
       sfn_log << SfnLog::err << "VS defines output at "