Added few more stubs so that control reaches to DestroyDevice().
[mesa.git] / src / gallium / drivers / panfrost / pan_blend_cso.c
index b39bfa89aac09c18aefc2f1f42987b8acb9a4d38..46b0832fe06f775d1743d45ea8150b8f69831dbf 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <stdio.h>
 #include "util/u_memory.h"
+#include "gallium/auxiliary/util/u_blend.h"
 #include "pan_blend_shaders.h"
 #include "pan_blending.h"
 #include "pan_bo.h"
@@ -110,29 +111,31 @@ panfrost_create_blend_state(struct pipe_context *pipe,
         assert(!blend->alpha_to_one);
 
         for (unsigned c = 0; c < PIPE_MAX_COLOR_BUFS; ++c) {
-                struct panfrost_blend_rt *rt = &so->rt[c];
-
-                /* There are two paths. First, we would like to try a
-                 * fixed-function if we can */
+                unsigned g = blend->independent_blend_enable ? c : 0;
+                struct pipe_rt_blend_state pipe = blend->rt[g];
 
-                /* Without indep blending, the first RT settings replicate */
+                struct panfrost_blend_rt *rt = &so->rt[c];
+                rt->shaders = _mesa_hash_table_u64_create(so);
 
-                if (!blend->logicop_enable) {
-                        unsigned g =
-                                blend->independent_blend_enable ? c : 0;
+                /* Logic ops are always shader */
+                if (blend->logicop_enable) {
+                        rt->load_dest = true;
+                        continue;
+                }
 
-                        rt->has_fixed_function =
+                rt->has_fixed_function =
                                 panfrost_make_fixed_blend_mode(
-                                        &blend->rt[g],
+                                        pipe,
                                         &rt->equation,
-                                        &rt->constant_mask,
-                                        blend->rt[g].colormask);
-                }
+                                        &rt->constant_mask);
 
-                /* Regardless if that works, we also need to initialize
-                 * the blend shaders */
+                if (rt->has_fixed_function)
+                        rt->opaque = (rt->equation.opaque[0] == 0xf0122122);
 
-                rt->shaders = _mesa_hash_table_u64_create(so);
+                rt->load_dest = util_blend_uses_dest(pipe)
+                        || pipe.colormask != 0xF;
+
+                rt->no_colour = pipe.colormask == 0x0;
         }
 
         return so;
@@ -143,12 +146,7 @@ panfrost_bind_blend_state(struct pipe_context *pipe,
                           void *cso)
 {
         struct panfrost_context *ctx = pan_context(pipe);
-        struct pipe_blend_state *blend = (struct pipe_blend_state *) cso;
-        struct panfrost_blend_state *pblend = (struct panfrost_blend_state *) cso;
-        ctx->blend = pblend;
-
-        if (!blend)
-                return;
+        ctx->blend = (struct panfrost_blend_state *) cso;
 }
 
 static void
@@ -165,7 +163,7 @@ panfrost_delete_blend_state(struct pipe_context *pipe,
 {
         struct panfrost_blend_state *blend = (struct panfrost_blend_state *) cso;
 
-        for (unsigned c = 0; c < 4; ++c) {
+        for (unsigned c = 0; c < PIPE_MAX_COLOR_BUFS; ++c) {
                 struct panfrost_blend_rt *rt = &blend->rt[c];
                 _mesa_hash_table_u64_clear(rt->shaders, panfrost_delete_blend_shader);
         }
@@ -232,18 +230,14 @@ panfrost_get_blend_for_context(struct panfrost_context *ctx, unsigned rti)
                             &constant,
                             ctx->blend_color.color,
                             rt->constant_mask)) {
-                        bool no_blending =
-                                (rt->equation.rgb_mode == 0x122) &&
-                                (rt->equation.alpha_mode == 0x122) &&
-                                (rt->equation.color_mask == 0xf);
-
                         struct panfrost_blend_final final = {
                                 .equation = {
-                                        .equation = &rt->equation,
+                                        .equation = rt->equation,
                                         .constant = constant
                                 },
-                                .no_blending = no_blending,
-                                .no_colour = (rt->equation.color_mask == 0x0)
+                                .load_dest = rt->load_dest,
+                                .opaque = rt->opaque,
+                                .no_colour = rt->no_colour
                         };
 
                         return final;
@@ -275,7 +269,8 @@ panfrost_get_blend_for_context(struct panfrost_context *ctx, unsigned rti)
                         .work_count = shader->work_count,
                         .first_tag = shader->first_tag,
                         .gpu = bo->gpu,
-                }
+                },
+                .load_dest = rt->load_dest,
         };
 
         return final;