vc4: use nir two-sided-color lowering
authorBoyan Ding <boyan.j.ding@gmail.com>
Sun, 27 Sep 2015 09:16:57 +0000 (17:16 +0800)
committerEric Anholt <eric@anholt.net>
Tue, 6 Oct 2015 23:34:07 +0000 (16:34 -0700)
Similar to 9ffc1049ca (freedreno/ir3: use nir two-sided-color lowering).
No piglit regression.

Signed-off-by: Boyan Ding <boyan.j.ding@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/gallium/drivers/vc4/vc4_context.h
src/gallium/drivers/vc4/vc4_program.c

index 7502293180a8f8f2f81c95e628f0465c1d659671..c7698422951864b1e6deb45fb5f8e7a20219d1b9 100644 (file)
@@ -103,7 +103,6 @@ struct vc4_uncompiled_shader {
         /** How many variants of this program were compiled, for shader-db. */
         uint32_t compiled_variant_count;
         struct pipe_shader_state base;
-        const struct tgsi_token *twoside_tokens;
 };
 
 struct vc4_ubo_range {
index 01ea75449847a7e9edfbe13a6950bc0980d5a0d9..31c7e28ff57e0efa583f655f9012b3fa87ef15e6 100644 (file)
@@ -1738,27 +1738,6 @@ vc4_shader_ntq(struct vc4_context *vc4, enum qstage stage,
         }
 
         const struct tgsi_token *tokens = key->shader_state->base.tokens;
-        if (c->fs_key && c->fs_key->light_twoside) {
-                if (!key->shader_state->twoside_tokens) {
-                        const struct tgsi_lowering_config lowering_config = {
-                                .color_two_side = true,
-                        };
-                        struct tgsi_shader_info info;
-                        key->shader_state->twoside_tokens =
-                                tgsi_transform_lowering(&lowering_config,
-                                                        key->shader_state->base.tokens,
-                                                        &info);
-
-                        /* If no transformation occurred, then NULL is
-                         * returned and we just use our original tokens.
-                         */
-                        if (!key->shader_state->twoside_tokens) {
-                                key->shader_state->twoside_tokens =
-                                        key->shader_state->base.tokens;
-                        }
-                }
-                tokens = key->shader_state->twoside_tokens;
-        }
 
         if (vc4_debug & VC4_DEBUG_TGSI) {
                 fprintf(stderr, "%s prog %d/%d TGSI:\n",
@@ -1772,6 +1751,8 @@ vc4_shader_ntq(struct vc4_context *vc4, enum qstage stage,
         nir_convert_to_ssa(c->s);
         if (stage == QSTAGE_FRAG)
                 vc4_nir_lower_blend(c);
+        if (c->fs_key && c->fs_key->light_twoside)
+                nir_lower_two_sided_color(c->s);
         vc4_nir_lower_io(c);
         nir_lower_idiv(c->s);
         nir_lower_load_const_to_scalar(c->s);
@@ -2190,8 +2171,6 @@ vc4_shader_state_delete(struct pipe_context *pctx, void *hwcso)
         hash_table_foreach(vc4->vs_cache, entry)
                 delete_from_cache_if_matches(vc4->vs_cache, entry, so);
 
-        if (so->twoside_tokens != so->base.tokens)
-                free((void *)so->twoside_tokens);
         free((void *)so->base.tokens);
         free(so);
 }