diff options
author | Icecream95 <ixn@disroot.org> | 2021-01-13 02:18:10 +1300 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2021-01-12 21:05:01 +0000 |
commit | 041261c6b300586fb622a46f42afbafd717782f8 (patch) | |
tree | 90fbed0ac8087e84dfbbb85bb4ebba75c708d1ae /src | |
parent | 4956f6d0bf477568731f3965125299b8857d5835 (diff) |
panfrost: Dual-source blending on Bifrost
Tested with the arb_blend_func_extended Piglit tests and Alacritty.
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8455>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/panfrost/pan_screen.c | 2 | ||||
-rw-r--r-- | src/panfrost/bifrost/bifrost_compile.c | 27 |
2 files changed, 23 insertions, 6 deletions
diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index 1bf78f39518..4aea02e3566 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -123,7 +123,7 @@ panfrost_get_param(struct pipe_screen *screen, enum pipe_cap param) return has_mrt ? 8 : 1; case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS: - return is_bifrost ? 0 : 1; + return 1; case PIPE_CAP_SAMPLE_SHADING: /* WIP */ diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 7aa5caba16c..40034ae5d79 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -302,15 +302,20 @@ bi_emit_load_blend_input(bi_builder *b, nir_intrinsic_instr *instr) { ASSERTED nir_io_semantics sem = nir_intrinsic_io_semantics(instr); - /* We don't support dual-source blending yet. */ - assert(sem.location == VARYING_SLOT_COL0); - - /* Source color is passed through r0-r3. TODO: Precolour instead */ + /* Source color is passed through r0-r3, or r4-r7 for the second + * source when dual-source blending. TODO: Precolour instead */ bi_index srcs[] = { bi_register(0), bi_register(1), bi_register(2), bi_register(3) }; + bi_index srcs2[] = { + bi_register(4), bi_register(5), bi_register(6), bi_register(7) + }; - bi_make_vec_to(b, bi_dest_index(&instr->dest), srcs, NULL, 4, 32); + bool second_source = (sem.location == VARYING_SLOT_VAR0); + + bi_make_vec_to(b, bi_dest_index(&instr->dest), + second_source ? srcs2 : srcs, + NULL, 4, 32); } static void @@ -355,6 +360,18 @@ bi_emit_fragment_out(bi_builder *b, nir_intrinsic_instr *instr) nir_var_shader_out, nir_intrinsic_base(instr)); assert(var); + /* Dual-source blending is implemented by putting the color in + * registers r4-r7. */ + if (var->data.index) { + bi_index color = bi_src_index(&instr->src[0]); + unsigned count = nir_src_num_components(instr->src[0]); + + for (unsigned i = 0; i < count; ++i) + bi_mov_i32_to(b, bi_register(4 + i), + bi_word(color, i)); + return; + } + /* Emit ATEST if we have to, note ATEST requires a floating-point alpha * value, but render target #0 might not be floating point. However the * alpha value is only used for alpha-to-coverage, a stage which is |