From 65d8c692bd7943b5c7b5538d074f486e94b10e08 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Mon, 18 May 2020 14:36:10 +0200 Subject: [PATCH] r600/sfn: Unify semantic name and index query and use TEXCOORD semantic Signed-off-by: Gert Wollny Reviewed-by: Reviewed-by: Dave Airlie Part-of: --- .../drivers/r600/sfn/sfn_shader_base.cpp | 2 ++ .../drivers/r600/sfn/sfn_shader_fragment.cpp | 15 ++++----------- .../drivers/r600/sfn/sfn_shader_geometry.cpp | 14 +++++++++----- src/gallium/drivers/r600/sfn/sfn_shaderio.cpp | 19 +++++++++++++++++++ src/gallium/drivers/r600/sfn/sfn_shaderio.h | 6 +++++- .../r600/sfn/sfn_vertexstageexport.cpp | 7 ++++--- 6 files changed, 43 insertions(+), 20 deletions(-) diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_base.cpp b/src/gallium/drivers/r600/sfn/sfn_shader_base.cpp index 2e9abfb6136..4d1d1c15242 100644 --- a/src/gallium/drivers/r600/sfn/sfn_shader_base.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_shader_base.cpp @@ -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: diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_fragment.cpp b/src/gallium/drivers/r600/sfn/sfn_shader_fragment.cpp index 54c45143b1b..6a40b8066ef 100644 --- a/src/gallium/drivers/r600/sfn/sfn_shader_fragment.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_shader_fragment.cpp @@ -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(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(name); diff --git a/src/gallium/drivers/r600/sfn/sfn_shader_geometry.cpp b/src/gallium/drivers/r600/sfn/sfn_shader_geometry.cpp index 6bdbb827497..35c22c7299f 100644 --- a/src/gallium/drivers/r600/sfn/sfn_shader_geometry.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_shader_geometry.cpp @@ -24,10 +24,10 @@ * 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( 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( 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; diff --git a/src/gallium/drivers/r600/sfn/sfn_shaderio.cpp b/src/gallium/drivers/r600/sfn/sfn_shaderio.cpp index 5526ab447c5..f32288e4de7 100644 --- a/src/gallium/drivers/r600/sfn/sfn_shaderio.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_shaderio.cpp @@ -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 +r600_get_varying_semantic(unsigned varying_location) +{ + std::pair result; + tgsi_get_gl_varying_semantic(static_cast(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; +} + + + } diff --git a/src/gallium/drivers/r600/sfn/sfn_shaderio.h b/src/gallium/drivers/r600/sfn/sfn_shaderio.h index 3c63d56b706..e77c44cc25d 100644 --- a/src/gallium/drivers/r600/sfn/sfn_shaderio.h +++ b/src/gallium/drivers/r600/sfn/sfn_shaderio.h @@ -161,6 +161,10 @@ private: }; +std::pair +r600_get_varying_semantic(unsigned varying_location); + + } -#endif // SFN_SHADERIO_H \ No newline at end of file +#endif // SFN_SHADERIO_H diff --git a/src/gallium/drivers/r600/sfn/sfn_vertexstageexport.cpp b/src/gallium/drivers/r600/sfn/sfn_vertexstageexport.cpp index 08c778a2e10..013603edbb6 100644 --- a/src/gallium/drivers/r600/sfn/sfn_vertexstageexport.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_vertexstageexport.cpp @@ -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( 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) -- 2.30.2