Fix blend tests

This commit is contained in:
polymetal0 2025-02-08 15:55:15 +01:00
parent ac781ea8d1
commit 1f305f5361
3 changed files with 46 additions and 25 deletions

View File

@ -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);
}

View File

@ -1384,9 +1384,9 @@ DEF_METHOD(NV097, SET_BLEND_EQUATION)
equation = 3; break;
case NV097_SET_BLEND_EQUATION_V_MAX:
equation = 4; break;
case NV097_SET_BLEND_EQUATION_V_FUNC_REVERSE_SUBTRACT_SIGNED:
equation = 5; break;
case NV097_SET_BLEND_EQUATION_V_FUNC_ADD_SIGNED:
equation = 5; break;
case NV097_SET_BLEND_EQUATION_V_FUNC_REVERSE_SUBTRACT_SIGNED:
equation = 6; break;
default:
NV2A_DPRINTF("Unknown blend equation: 0x%08x\n", parameter);

View File

@ -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 = {