mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-08-21 16:13:22 +02:00
OpenGL: Support blend equation
This commit is contained in:
parent
f6eb62d062
commit
5864cb7e00
@ -937,6 +937,8 @@ void RasterizerOpenGL::SyncBlendEnabled() {
|
||||
|
||||
void RasterizerOpenGL::SyncBlendFuncs() {
|
||||
const auto& regs = Pica::g_state.regs;
|
||||
state.blend.rgb_equation = PicaToGL::BlendEquation(regs.output_merger.alpha_blending.blend_equation_rgb);
|
||||
state.blend.a_equation = PicaToGL::BlendEquation(regs.output_merger.alpha_blending.blend_equation_a);
|
||||
state.blend.src_rgb_func = PicaToGL::BlendFunc(regs.output_merger.alpha_blending.factor_source_rgb);
|
||||
state.blend.dst_rgb_func = PicaToGL::BlendFunc(regs.output_merger.alpha_blending.factor_dest_rgb);
|
||||
state.blend.src_a_func = PicaToGL::BlendFunc(regs.output_merger.alpha_blending.factor_source_a);
|
||||
|
@ -36,6 +36,8 @@ OpenGLState::OpenGLState() {
|
||||
stencil.action_stencil_fail = GL_KEEP;
|
||||
|
||||
blend.enabled = false;
|
||||
blend.rgb_equation = GL_FUNC_ADD;
|
||||
blend.a_equation = GL_FUNC_ADD;
|
||||
blend.src_rgb_func = GL_ONE;
|
||||
blend.dst_rgb_func = GL_ZERO;
|
||||
blend.src_a_func = GL_ONE;
|
||||
@ -165,6 +167,11 @@ void OpenGLState::Apply() const {
|
||||
blend.src_a_func, blend.dst_a_func);
|
||||
}
|
||||
|
||||
if (blend.rgb_equation != cur_state.blend.rgb_equation ||
|
||||
blend.a_equation != cur_state.blend.a_equation) {
|
||||
glBlendEquationSeparate(blend.rgb_equation, blend.a_equation);
|
||||
}
|
||||
|
||||
if (logic_op != cur_state.logic_op) {
|
||||
glLogicOp(logic_op);
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ public:
|
||||
|
||||
struct {
|
||||
bool enabled; // GL_BLEND
|
||||
GLenum rgb_equation; // GL_BLEND_EQUATION_RGB
|
||||
GLenum a_equation; // GL_BLEND_EQUATION_ALPHA
|
||||
GLenum src_rgb_func; // GL_BLEND_SRC_RGB
|
||||
GLenum dst_rgb_func; // GL_BLEND_DST_RGB
|
||||
GLenum src_a_func; // GL_BLEND_SRC_ALPHA
|
||||
|
@ -78,6 +78,26 @@ inline GLenum WrapMode(Pica::Regs::TextureConfig::WrapMode mode) {
|
||||
return gl_mode;
|
||||
}
|
||||
|
||||
inline GLenum BlendEquation(Pica::Regs::BlendEquation equation) {
|
||||
static const GLenum blend_equation_table[] = {
|
||||
GL_FUNC_ADD, // BlendEquation::Add
|
||||
GL_FUNC_SUBTRACT, // BlendEquation::Subtract
|
||||
GL_FUNC_REVERSE_SUBTRACT, // BlendEquation::ReverseSubtract
|
||||
GL_MIN, // BlendEquation::Min
|
||||
GL_MAX, // BlendEquation::Max
|
||||
};
|
||||
|
||||
// Range check table for input
|
||||
if (static_cast<size_t>(equation) >= ARRAY_SIZE(blend_equation_table)) {
|
||||
LOG_CRITICAL(Render_OpenGL, "Unknown blend equation %d", equation);
|
||||
UNREACHABLE();
|
||||
|
||||
return GL_FUNC_ADD;
|
||||
}
|
||||
|
||||
return blend_equation_table[(unsigned)equation];
|
||||
}
|
||||
|
||||
inline GLenum BlendFunc(Pica::Regs::BlendFactor factor) {
|
||||
static const GLenum blend_func_table[] = {
|
||||
GL_ZERO, // BlendFactor::Zero
|
||||
|
Loading…
Reference in New Issue
Block a user