r600/sfn: Unify semantic name and index query and use TEXCOORD semantic
authorGert Wollny <gert.wollny@collabora.com>
Mon, 18 May 2020 12:36:10 +0000 (14:36 +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_base.cpp
src/gallium/drivers/r600/sfn/sfn_shader_fragment.cpp
src/gallium/drivers/r600/sfn/sfn_shader_geometry.cpp
src/gallium/drivers/r600/sfn/sfn_shaderio.cpp
src/gallium/drivers/r600/sfn/sfn_shaderio.h
src/gallium/drivers/r600/sfn/sfn_vertexstageexport.cpp

index 2e9abfb613626aa3b289ca9acf6f47b44a1b1b4e..4d1d1c15242fdbc22d51281daa553263d7330096 100644 (file)
@@ -256,6 +256,8 @@ void ShaderFromNirProcessor::evaluate_spi_sid(r600_shader_io& io)
       io.spi_sid = 0;
       break;
    case TGSI_SEMANTIC_GENERIC:
+   case TGSI_SEMANTIC_TEXCOORD:
+   case TGSI_SEMANTIC_PCOORD:
       io.spi_sid = io.sid + 1;
       break;
    default:
index 54c45143b1b5c2388ee0953a0e01d227f4add876..6a40b8066ef885ebc2fdb3e9ea46e00296f6a92a 100644 (file)
@@ -66,22 +66,15 @@ bool FragmentShaderFromNir::do_process_inputs(nir_variable *input)
            << " interpolation:" << input->data.interpolation
            << "\n";
 
-   unsigned name, sid;
-
    if (input->data.location == VARYING_SLOT_FACE) {
       m_sv_values.set(es_face);
       return true;
    }
 
-   tgsi_get_gl_varying_semantic(static_cast<gl_varying_slot>(input->data.location),
-                                true, &name, &sid);
-
-   /* Work around the mixed tgsi/nir semantic problems, this fixes
-    * dEQP-GLES2.functional.shaders.builtin_variable.pointcoord */
-   if (input->data.location == VARYING_SLOT_PNTC) {
-      name = TGSI_SEMANTIC_GENERIC;
-      sid = 8;
-   }
+   unsigned name, sid;
+   auto semantic = r600_get_varying_semantic(input->data.location);
+   name = semantic.first;
+   sid = semantic.second;
 
    tgsi_semantic sname = static_cast<tgsi_semantic>(name);
 
index 6bdbb827497ee1e9aee18d3bbf942ef6ed9cfe82..35c22c7299ff7f202fe6a95098b74a38d4e9c6d6 100644 (file)
  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#include "tgsi/tgsi_from_mesa.h"
 #include "sfn_shader_geometry.h"
 #include "sfn_instruction_misc.h"
 #include "sfn_instruction_fetch.h"
+#include "sfn_shaderio.h"
 
 namespace r600 {
 
@@ -95,8 +95,10 @@ bool GeometryShaderFromNir::do_process_inputs(nir_variable *input)
        input->data.location <= VARYING_SLOT_TEX7)) {
 
       r600_shader_io& io = sh_info().input[input->data.driver_location];
-      tgsi_get_gl_varying_semantic(static_cast<gl_varying_slot>( input->data.location),
-                                   true, &io.name, &io.sid);
+      auto semantic = r600_get_varying_semantic(input->data.location);
+      io.name = semantic.first;
+      io.sid = semantic.second;
+
       io.ring_offset = 16 * input->data.driver_location;
       ++sh_info().ninput;
       m_next_input_ring_offset += 16;
@@ -127,8 +129,10 @@ bool GeometryShaderFromNir::do_process_outputs(nir_variable *output)
        output->data.location == VARYING_SLOT_FOGC) {
       r600_shader_io& io = sh_info().output[output->data.driver_location];
 
-      tgsi_get_gl_varying_semantic(static_cast<gl_varying_slot>( output->data.location),
-                                   true, &io.name, &io.sid);
+      auto semantic = r600_get_varying_semantic(output->data.location);
+      io.name = semantic.first;
+      io.sid = semantic.second;
+
       evaluate_spi_sid(io);
       ++sh_info().noutput;
 
index 5526ab447c587febf569463dd2b5cd5ce8703e24..f32288e4de7ced1343e963db54c4660e28c3f88f 100644 (file)
@@ -196,6 +196,8 @@ void ShaderInputVarying::evaluate_spi_sid()
       assert(0 && "System value used as varying");
       break;
    case TGSI_SEMANTIC_GENERIC:
+   case TGSI_SEMANTIC_TEXCOORD:
+   case TGSI_SEMANTIC_PCOORD:
       m_spi_sid = m_sid + 1;
       break;
    default:
@@ -380,5 +382,22 @@ void ShaderIO::set_two_sided()
    m_two_sided = true;
 }
 
+std::pair<unsigned, unsigned>
+r600_get_varying_semantic(unsigned varying_location)
+{
+   std::pair<unsigned, unsigned> result;
+   tgsi_get_gl_varying_semantic(static_cast<gl_varying_slot>(varying_location),
+                                true, &result.first, &result.second);
+
+   if (result.first == TGSI_SEMANTIC_GENERIC) {
+      result.second += 9;
+   } else if (result.first == TGSI_SEMANTIC_PCOORD) {
+      result.second = 8;
+   }
+   return result;
+}
+
+
+
 }
 
index 3c63d56b70686c2437a70f49d597265fd31c4112..e77c44cc25d45ca43d943ed4071523837c8af952 100644 (file)
@@ -161,6 +161,10 @@ private:
 
 };
 
+std::pair<unsigned, unsigned>
+r600_get_varying_semantic(unsigned varying_location);
+
+
 }
 
-#endif // SFN_SHADERIO_H
\ No newline at end of file
+#endif // SFN_SHADERIO_H
index 08c778a2e103853cb1f86d62ecd9747eca12a2e2..013603edbb6d9642f218cb949401aaa5c5c19ee2 100644 (file)
@@ -1,6 +1,6 @@
 #include "sfn_vertexstageexport.h"
 
-#include "tgsi/tgsi_from_mesa.h"
+#include "sfn_shaderio.h"
 
 namespace r600 {
 
@@ -70,8 +70,9 @@ bool VertexStageExportBase::do_process_outputs(nir_variable *output)
        ) {
 
       r600_shader_io& io = m_proc.sh_info().output[output->data.driver_location];
-      tgsi_get_gl_varying_semantic(static_cast<gl_varying_slot>( output->data.location),
-                                   true, &io.name, &io.sid);
+      auto semantic = r600_get_varying_semantic(output->data.location);
+      io.name = semantic.first;
+      io.sid = semantic.second;
 
       m_proc.evaluate_spi_sid(io);
       io.write_mask = ((1 << glsl_get_components(output->type)) - 1)