gsdx-ogl: use integer for blend factor

Integer argument&comparison might be lighter

V2: Forget to change one OMSetBlendState call
This commit is contained in:
Gregory Hainaut 2015-08-07 12:13:50 +02:00
parent 5b57405517
commit df3ade896b
5 changed files with 10 additions and 18 deletions

View File

@ -33,7 +33,7 @@ namespace GLState {
GLenum f_dRGB;
uint32 wrgba;
float bf;
int bf;
bool depth;
GLenum depth_func;
@ -58,14 +58,6 @@ namespace GLState {
GLuint vs;
GLuint program;
bool dirty_prog;
#if 0
struct {
GSVertexBufferStateOGL* vb;
GSDepthStencilOGL* dss;
GSBlendStateOGL* bs;
float bf; // blend factor
} m_state;
#endif
void Clear() {
fbo = 0;
@ -77,7 +69,7 @@ namespace GLState {
f_sRGB = 0;
f_dRGB = 0;
wrgba = 0xF;
bf = 0.0;
bf = 0;
depth = false;
depth_func = 0;

View File

@ -34,7 +34,7 @@ namespace GLState {
extern GLenum f_sRGB;
extern GLenum f_dRGB;
extern uint32 wrgba;
extern float bf;
extern int bf;
extern bool depth;
extern GLenum depth_func;

View File

@ -1332,7 +1332,7 @@ void GSDeviceOGL::OMSetColorMaskState(OMColorMaskSelector sel)
}
}
void GSDeviceOGL::OMSetBlendState(int blend_index, float blend_factor, bool is_blend_constant)
void GSDeviceOGL::OMSetBlendState(int blend_index, int blend_factor, bool is_blend_constant)
{
if (blend_index) {
if (!GLState::blend) {
@ -1342,7 +1342,8 @@ void GSDeviceOGL::OMSetBlendState(int blend_index, float blend_factor, bool is_b
if (is_blend_constant && GLState::bf != blend_factor) {
GLState::bf = blend_factor;
gl_BlendColor(blend_factor, blend_factor, blend_factor, 0);
float bf = (float)blend_factor / 128.0f;
gl_BlendColor(bf, bf, bf, bf);
}
// FIXME test to use uint16 (cache friendly)

View File

@ -527,7 +527,7 @@ class GSDeviceOGL : public GSDevice
void PSSetSamplerState(GLuint ss);
void OMSetDepthStencilState(GSDepthStencilOGL* dss);
void OMSetBlendState(int blend_index = 0, float blend_factor = 0.0f, bool is_blend_constant = false);
void OMSetBlendState(int blend_index = 0, int blend_factor = 0, bool is_blend_constant = false);
void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL);
void OMSetWriteBuffer(GLenum buffer = GL_COLOR_ATTACHMENT0);
void OMSetColorMaskState(OMColorMaskSelector sel = OMColorMaskSelector());

View File

@ -307,7 +307,6 @@ bool GSRendererOGL::EmulateBlending(GSDeviceOGL::PSSelector& ps_sel, bool DATE_G
const GIFRegALPHA& ALPHA = m_context->ALPHA;
bool require_barrier = false;
bool sw_blending = false;
float afix = (float)m_context->ALPHA.FIX / 0x80;
// No blending so early exit
if (!(PRIM->ABE || PRIM->AA1 && m_vt.m_primclass == GS_LINE_CLASS)) {
@ -400,7 +399,7 @@ bool GSRendererOGL::EmulateBlending(GSDeviceOGL::PSSelector& ps_sel, bool DATE_G
// Require the fix alpha vlaue
if (ALPHA.C == 2) {
ps_cb.AlphaCoeff.a = afix;
ps_cb.AlphaCoeff.a = (float)ALPHA.FIX / 128.0f;
}
// No need to flush for every primitive
@ -410,9 +409,9 @@ bool GSRendererOGL::EmulateBlending(GSDeviceOGL::PSSelector& ps_sel, bool DATE_G
if (ps_sel.dfmt == 1 && ALPHA.C == 1) {
// 24 bits doesn't have an alpha channel so use 1.0f fix factor as equivalent
int hacked_blend_index = blend_index + 3; // +3 <=> +1 on C
dev->OMSetBlendState(hacked_blend_index, 1.0f, true);
dev->OMSetBlendState(hacked_blend_index, 128, true);
} else {
dev->OMSetBlendState(blend_index, afix, (ALPHA.C == 2));
dev->OMSetBlendState(blend_index, ALPHA.FIX, (ALPHA.C == 2));
}
}