diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-07-02 09:08:18 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-07-10 06:12:05 -0700 |
commit | 5e825f5cad5af4b085cfbaabc765dc42718e4b9e (patch) | |
tree | d7c2b99b58006130d2c5db525b82cd5289a2df17 | |
parent | 27e0c8c15ddab34358524bd072712dd3c6f70c3c (diff) |
panfrost: Handle "blend disabled" blend shaders
Normally, disabled blend can definitely be fixed-function'd away, but
if a blend shader is used merely for format conversion rather than
blending, this code path can be nevertheless hit.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
-rw-r--r-- | src/gallium/drivers/panfrost/pan_blend_shaders.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/gallium/drivers/panfrost/pan_blend_shaders.c b/src/gallium/drivers/panfrost/pan_blend_shaders.c index 91c8fb89688..2b6206545b3 100644 --- a/src/gallium/drivers/panfrost/pan_blend_shaders.c +++ b/src/gallium/drivers/panfrost/pan_blend_shaders.c @@ -89,21 +89,31 @@ nir_make_options(const struct pipe_blend_state *blend, unsigned nr_cbufs) nir_lower_blend_options options; for (unsigned i = 0; i < nr_cbufs; ++i) { + /* If blend is disabled, we just use replace mode */ + nir_lower_blend_channel rgb = { - .func = util_blend_func_to_shader(blend->rt[i].rgb_func), - .src_factor = util_blend_factor_to_shader(blend->rt[i].rgb_src_factor), - .dst_factor = util_blend_factor_to_shader(blend->rt[i].rgb_dst_factor), - .invert_src_factor = util_blend_factor_is_inverted(blend->rt[i].rgb_src_factor), - .invert_dst_factor = util_blend_factor_is_inverted(blend->rt[i].rgb_dst_factor) + .func = BLEND_FUNC_ADD, + .src_factor = BLEND_FACTOR_ZERO, + .invert_src_factor = true, + .dst_factor = BLEND_FACTOR_ZERO, + .invert_dst_factor = false }; - nir_lower_blend_channel alpha = { - .func = util_blend_func_to_shader(blend->rt[i].alpha_func), - .src_factor = util_blend_factor_to_shader(blend->rt[i].alpha_src_factor), - .dst_factor = util_blend_factor_to_shader(blend->rt[i].alpha_dst_factor), - .invert_src_factor = util_blend_factor_is_inverted(blend->rt[i].alpha_src_factor), - .invert_dst_factor = util_blend_factor_is_inverted(blend->rt[i].alpha_dst_factor) - }; + nir_lower_blend_channel alpha = rgb; + + if (blend->rt[i].blend_enable) { + rgb.func = util_blend_func_to_shader(blend->rt[i].rgb_func); + rgb.src_factor = util_blend_factor_to_shader(blend->rt[i].rgb_src_factor); + rgb.dst_factor = util_blend_factor_to_shader(blend->rt[i].rgb_dst_factor); + rgb.invert_src_factor = util_blend_factor_is_inverted(blend->rt[i].rgb_src_factor); + rgb.invert_dst_factor = util_blend_factor_is_inverted(blend->rt[i].rgb_dst_factor); + + alpha.func = util_blend_func_to_shader(blend->rt[i].alpha_func); + alpha.src_factor = util_blend_factor_to_shader(blend->rt[i].alpha_src_factor); + alpha.dst_factor = util_blend_factor_to_shader(blend->rt[i].alpha_dst_factor); + alpha.invert_src_factor = util_blend_factor_is_inverted(blend->rt[i].alpha_src_factor); + alpha.invert_dst_factor = util_blend_factor_is_inverted(blend->rt[i].alpha_dst_factor); + } options.rt[i].rgb = rgb; options.rt[i].alpha = alpha; |