From c71daec2604f1bac8e94dfcc4856f1b19c1a2273 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 1 Jul 2021 10:52:52 +1000 Subject: [PATCH] crocus: expose ARB_blend_func_extended on gen 45/50 In theory the docs say 965gm can support this but the original 965 can't, but we can't distinguish that yet. Reviewed-by: Adam Jackson Part-of: --- src/gallium/drivers/crocus/crocus_screen.c | 3 ++- src/gallium/drivers/crocus/crocus_state.c | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/crocus/crocus_screen.c b/src/gallium/drivers/crocus/crocus_screen.c index c61bfafc458..6c49fe59933 100644 --- a/src/gallium/drivers/crocus/crocus_screen.c +++ b/src/gallium/drivers/crocus/crocus_screen.c @@ -263,7 +263,8 @@ crocus_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_FBFETCH: return devinfo->verx10 >= 45 ? BRW_MAX_DRAW_BUFFERS : 0; case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS: - return devinfo->ver >= 6 ? 1 : 0; + /* in theory CL (965gm) can do this */ + return devinfo->verx10 >= 45 ? 1 : 0; case PIPE_CAP_MAX_RENDER_TARGETS: return BRW_MAX_DRAW_BUFFERS; case PIPE_CAP_MAX_TEXTURE_2D_SIZE: diff --git a/src/gallium/drivers/crocus/crocus_state.c b/src/gallium/drivers/crocus/crocus_state.c index da5fb7a80c2..de5e60ed751 100644 --- a/src/gallium/drivers/crocus/crocus_state.c +++ b/src/gallium/drivers/crocus/crocus_state.c @@ -1565,6 +1565,23 @@ set_blend_entry_bits(struct crocus_batch *batch, BLEND_ENTRY_GENXML *entry, entry->DestinationBlendFactor = (int) dst_rgb; entry->DestinationAlphaBlendFactor = (int) dst_alpha; } +#if GFX_VER <= 5 + /* + * Gen4/GM45/ILK can't handle have ColorBufferBlendEnable == 0 + * when a dual src blend shader is in use. Setup dummy blending. + */ + struct crocus_compiled_shader *shader = ice->shaders.prog[MESA_SHADER_FRAGMENT]; + struct brw_wm_prog_data *wm_prog_data = (void *) shader->prog_data; + if (idx == 0 && !blend_enabled && wm_prog_data->dual_src_blend) { + entry->ColorBufferBlendEnable = 1; + entry->ColorBlendFunction = PIPE_BLEND_ADD; + entry->AlphaBlendFunction = PIPE_BLEND_ADD; + entry->SourceBlendFactor = PIPE_BLENDFACTOR_ONE; + entry->SourceAlphaBlendFactor = PIPE_BLENDFACTOR_ONE; + entry->DestinationBlendFactor = PIPE_BLENDFACTOR_ZERO; + entry->DestinationAlphaBlendFactor = PIPE_BLENDFACTOR_ZERO; + } +#endif return independent_alpha_blend; } @@ -5341,11 +5358,14 @@ crocus_populate_binding_table(struct crocus_context *ice, #if GFX_VER <= 5 const struct pipe_rt_blend_state *rt = &ice->state.cso_blend->cso.rt[ice->state.cso_blend->cso.independent_blend_enable ? i : 0]; + struct crocus_compiled_shader *shader = ice->shaders.prog[MESA_SHADER_FRAGMENT]; + struct brw_wm_prog_data *wm_prog_data = (void *) shader->prog_data; write_disables |= (rt->colormask & PIPE_MASK_A) ? 0x0 : 0x8; write_disables |= (rt->colormask & PIPE_MASK_R) ? 0x0 : 0x4; write_disables |= (rt->colormask & PIPE_MASK_G) ? 0x0 : 0x2; write_disables |= (rt->colormask & PIPE_MASK_B) ? 0x0 : 0x1; - blend_enable = rt->blend_enable; + /* Gen4/5 can't handle blending off when a dual src blend wm is enabled. */ + blend_enable = rt->blend_enable || wm_prog_data->dual_src_blend; #endif if (cso_fb->cbufs[i]) { surf_offsets[s] = emit_surface(batch,