Mesa (master): ir3: Use shared mediump output lowering

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Apr 27 16:50:48 UTC 2020


Module: Mesa
Branch: master
Commit: 6943eda5c928a323019d48a6d2f401c74a88fb7d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6943eda5c928a323019d48a6d2f401c74a88fb7d

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Thu Apr 23 19:12:43 2020 -0400

ir3: Use shared mediump output lowering

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg at google.com>
Acked-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4716>

---

 src/freedreno/ir3/ir3_shader.c | 50 +-----------------------------------------
 1 file changed, 1 insertion(+), 49 deletions(-)

diff --git a/src/freedreno/ir3/ir3_shader.c b/src/freedreno/ir3/ir3_shader.c
index 1624b889ae0..8d768e21c30 100644
--- a/src/freedreno/ir3/ir3_shader.c
+++ b/src/freedreno/ir3/ir3_shader.c
@@ -289,54 +289,6 @@ ir3_shader_destroy(struct ir3_shader *shader)
 	free(shader);
 }
 
-static bool
-lower_output_var(nir_shader *nir, int location)
-{
-	nir_foreach_variable (var, &nir->outputs) {
-		if (var->data.driver_location == location &&
-				((var->data.precision == GLSL_PRECISION_MEDIUM) ||
-					(var->data.precision == GLSL_PRECISION_LOW))) {
-			if (glsl_get_base_type(var->type) == GLSL_TYPE_FLOAT)
-				var->type = glsl_float16_type(var->type);
-
-			return glsl_get_base_type(var->type) == GLSL_TYPE_FLOAT16;
-		}
-	}
-
-	return false;
-}
-
-static void
-lower_mediump_outputs(nir_shader *nir)
-{
-	nir_function_impl *impl = nir_shader_get_entrypoint(nir);
-	assert(impl);
-
-	/* Get rid of old derefs before we change the types of the variables */
-	nir_opt_dce(nir);
-
-	nir_builder b;
-	nir_builder_init(&b, impl);
-
-	nir_foreach_block_safe (block, impl) {
-		nir_foreach_instr_safe (instr, block) {
-			if (instr->type != nir_instr_type_intrinsic)
-				continue;
-
-			nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
-			if (intr->intrinsic != nir_intrinsic_store_output)
-				continue;
-
-			if (!lower_output_var(nir, nir_intrinsic_base(intr)))
-				continue;
-
-			b.cursor = nir_before_instr(&intr->instr);
-			nir_instr_rewrite_src(&intr->instr, &intr->src[0],
-					nir_src_for_ssa(nir_f2f16(&b, intr->src[0].ssa)));
-		}
-	}
-}
-
 struct ir3_shader *
 ir3_shader_from_nir(struct ir3_compiler *compiler, nir_shader *nir)
 {
@@ -353,7 +305,7 @@ ir3_shader_from_nir(struct ir3_compiler *compiler, nir_shader *nir)
 	if (compiler->gpu_id >= 600 &&
 			nir->info.stage == MESA_SHADER_FRAGMENT &&
 			!(ir3_shader_debug & IR3_DBG_NOFP16))
-		lower_mediump_outputs(nir);
+		NIR_PASS_V(nir, nir_lower_mediump_outputs);
 
 	if (nir->info.stage == MESA_SHADER_FRAGMENT) {
 		/* NOTE: lower load_barycentric_at_sample first, since it



More information about the mesa-commit mailing list