diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-07-02 09:48:19 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-07-10 06:12:06 -0700 |
commit | 5849c8500863a058911df6405cbe4279b0b83d1a (patch) | |
tree | a0ec8465aa65ee51896eabf177faff34eabc6f17 /src/gallium | |
parent | 5e825f5cad5af4b085cfbaabc765dc42718e4b9e (diff) |
panfrost/midgard: Skip blend for REPLACE (shader)
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/panfrost/midgard/nir_lower_blend.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/gallium/drivers/panfrost/midgard/nir_lower_blend.c b/src/gallium/drivers/panfrost/midgard/nir_lower_blend.c index af0a7ac31cf..0fadeba6674 100644 --- a/src/gallium/drivers/panfrost/midgard/nir_lower_blend.c +++ b/src/gallium/drivers/panfrost/midgard/nir_lower_blend.c @@ -200,12 +200,35 @@ nir_blend( return nir_color_mask(b, options.rt[0].colormask, blended, dst); } +static bool +nir_is_blend_channel_replace(nir_lower_blend_channel chan) +{ + return + (chan.src_factor == BLEND_FACTOR_ZERO) && + (chan.dst_factor == BLEND_FACTOR_ZERO) && + (chan.invert_src_factor && !chan.invert_dst_factor) && + (chan.func == BLEND_FUNC_ADD || chan.func == BLEND_FUNC_SUBTRACT || chan.func == BLEND_FUNC_MAX); +} + +static bool +nir_is_blend_replace(nir_lower_blend_options options) +{ + return + nir_is_blend_channel_replace(options.rt[0].rgb) && + nir_is_blend_channel_replace(options.rt[0].alpha); +} + void nir_lower_blend(nir_shader *shader, nir_lower_blend_options options) { /* Blend shaders are represented as special fragment shaders */ assert(shader->info.stage == MESA_SHADER_FRAGMENT); + /* Special case replace, since there's nothing to do and we don't want to + * degrade intermediate precision (e.g. for non-blendable R32F targets) */ + if (nir_is_blend_replace(options)) + return; + nir_foreach_function(func, shader) { nir_foreach_block(block, func->impl) { nir_foreach_instr_safe(instr, block) { |