diff --git a/hw/xbox/nv2a/pgraph/gl/constants.h b/hw/xbox/nv2a/pgraph/gl/constants.h index d78b0054e38..cb789efebdc 100644 --- a/hw/xbox/nv2a/pgraph/gl/constants.h +++ b/hw/xbox/nv2a/pgraph/gl/constants.h @@ -79,8 +79,8 @@ static const GLenum pgraph_blend_equation_gl_map[] = { GL_FUNC_ADD, GL_MIN, GL_MAX, - GL_FUNC_REVERSE_SUBTRACT, GL_FUNC_ADD, + GL_FUNC_REVERSE_SUBTRACT, }; /* FIXME diff --git a/hw/xbox/nv2a/pgraph/gl/draw.c b/hw/xbox/nv2a/pgraph/gl/draw.c index a9032562fa9..03a866e322a 100644 --- a/hw/xbox/nv2a/pgraph/gl/draw.c +++ b/hw/xbox/nv2a/pgraph/gl/draw.c @@ -168,14 +168,6 @@ void pgraph_gl_draw_begin(NV2AState *d) if (pgraph_reg_r(pg, NV_PGRAPH_BLEND) & NV_PGRAPH_BLEND_EN) { glEnable(GL_BLEND); - uint32_t sfactor = GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_BLEND), - NV_PGRAPH_BLEND_SFACTOR); - uint32_t dfactor = GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_BLEND), - NV_PGRAPH_BLEND_DFACTOR); - assert(sfactor < ARRAY_SIZE(pgraph_blend_factor_gl_map)); - assert(dfactor < ARRAY_SIZE(pgraph_blend_factor_gl_map)); - glBlendFunc(pgraph_blend_factor_gl_map[sfactor], - pgraph_blend_factor_gl_map[dfactor]); uint32_t equation = GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_BLEND), NV_PGRAPH_BLEND_EQN); @@ -187,6 +179,23 @@ void pgraph_gl_draw_begin(NV2AState *d) pgraph_argb_pack32_to_rgba_float(blend_color, gl_blend_color); glBlendColor(gl_blend_color[0], gl_blend_color[1], gl_blend_color[2], gl_blend_color[3]); + uint32_t sfactor = GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_BLEND), + NV_PGRAPH_BLEND_SFACTOR); + uint32_t dfactor = GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_BLEND), + NV_PGRAPH_BLEND_DFACTOR); + assert(sfactor < ARRAY_SIZE(pgraph_blend_factor_gl_map)); + assert(dfactor < ARRAY_SIZE(pgraph_blend_factor_gl_map)); + + if (equation < 5) { + glBlendFunc(pgraph_blend_factor_gl_map[sfactor], + pgraph_blend_factor_gl_map[dfactor]); + } else { + glBlendFuncSeparate(pgraph_blend_factor_gl_map[3], + pgraph_blend_factor_gl_map[1], + pgraph_blend_factor_gl_map[sfactor], + pgraph_blend_factor_gl_map[dfactor]); + } + } else { glDisable(GL_BLEND); } diff --git a/hw/xbox/nv2a/pgraph/vk/constants.h b/hw/xbox/nv2a/pgraph/vk/constants.h index eb7e97dbc04..f86f48cb5cb 100644 --- a/hw/xbox/nv2a/pgraph/vk/constants.h +++ b/hw/xbox/nv2a/pgraph/vk/constants.h @@ -77,8 +77,8 @@ static const VkBlendOp pgraph_blend_equation_vk_map[] = { VK_BLEND_OP_ADD, VK_BLEND_OP_MIN, VK_BLEND_OP_MAX, - VK_BLEND_OP_REVERSE_SUBTRACT, VK_BLEND_OP_ADD, + VK_BLEND_OP_REVERSE_SUBTRACT, }; /* FIXME diff --git a/hw/xbox/nv2a/pgraph/vk/draw.c b/hw/xbox/nv2a/pgraph/vk/draw.c index 4cde028b1f4..66978aa8a5b 100644 --- a/hw/xbox/nv2a/pgraph/vk/draw.c +++ b/hw/xbox/nv2a/pgraph/vk/draw.c @@ -909,21 +909,6 @@ static void create_pipeline(PGRAPHState *pg) if (pgraph_reg_r(pg, NV_PGRAPH_BLEND) & NV_PGRAPH_BLEND_EN) { color_blend_attachment.blendEnable = VK_TRUE; - uint32_t sfactor = - GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_BLEND), NV_PGRAPH_BLEND_SFACTOR); - uint32_t dfactor = - GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_BLEND), NV_PGRAPH_BLEND_DFACTOR); - assert(sfactor < ARRAY_SIZE(pgraph_blend_factor_vk_map)); - assert(dfactor < ARRAY_SIZE(pgraph_blend_factor_vk_map)); - color_blend_attachment.srcColorBlendFactor = - pgraph_blend_factor_vk_map[sfactor]; - color_blend_attachment.dstColorBlendFactor = - pgraph_blend_factor_vk_map[dfactor]; - color_blend_attachment.srcAlphaBlendFactor = - pgraph_blend_factor_vk_map[sfactor]; - color_blend_attachment.dstAlphaBlendFactor = - pgraph_blend_factor_vk_map[dfactor]; - uint32_t equation = GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_BLEND), NV_PGRAPH_BLEND_EQN); assert(equation < ARRAY_SIZE(pgraph_blend_equation_vk_map)); @@ -935,6 +920,33 @@ static void create_pipeline(PGRAPHState *pg) uint32_t blend_color = pgraph_reg_r(pg, NV_PGRAPH_BLENDCOLOR); pgraph_argb_pack32_to_rgba_float(blend_color, blend_constant); + + uint32_t sfactor = GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_BLEND), + NV_PGRAPH_BLEND_SFACTOR); + uint32_t dfactor = GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_BLEND), + NV_PGRAPH_BLEND_DFACTOR); + assert(sfactor < ARRAY_SIZE(pgraph_blend_factor_vk_map)); + assert(dfactor < ARRAY_SIZE(pgraph_blend_factor_vk_map)); + + if (equation < 5) { + color_blend_attachment.srcColorBlendFactor = + pgraph_blend_factor_vk_map[sfactor]; + color_blend_attachment.dstColorBlendFactor = + pgraph_blend_factor_vk_map[dfactor]; + color_blend_attachment.srcAlphaBlendFactor = + pgraph_blend_factor_vk_map[sfactor]; + color_blend_attachment.dstAlphaBlendFactor = + pgraph_blend_factor_vk_map[dfactor]; + } else { + color_blend_attachment.srcColorBlendFactor = + pgraph_blend_factor_vk_map[3]; + color_blend_attachment.dstColorBlendFactor = + pgraph_blend_factor_vk_map[1]; + color_blend_attachment.srcAlphaBlendFactor = + pgraph_blend_factor_vk_map[sfactor]; + color_blend_attachment.dstAlphaBlendFactor = + pgraph_blend_factor_vk_map[dfactor]; + } } VkPipelineColorBlendStateCreateInfo color_blending = {