This commit is contained in:
polymetal0 2025-04-16 20:43:23 -07:00 committed by GitHub
commit eb0ee15d72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 46 additions and 25 deletions

View File

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

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

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

View File

@ -905,21 +905,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));
@ -931,6 +916,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 = {