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

View File

@ -34,7 +34,7 @@ namespace GLState {
extern GLenum f_sRGB; extern GLenum f_sRGB;
extern GLenum f_dRGB; extern GLenum f_dRGB;
extern uint32 wrgba; extern uint32 wrgba;
extern float bf; extern int bf;
extern bool depth; extern bool depth;
extern GLenum depth_func; 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 (blend_index) {
if (!GLState::blend) { 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) { if (is_blend_constant && GLState::bf != blend_factor) {
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) // FIXME test to use uint16 (cache friendly)

View File

@ -527,7 +527,7 @@ class GSDeviceOGL : public GSDevice
void PSSetSamplerState(GLuint ss); void PSSetSamplerState(GLuint ss);
void OMSetDepthStencilState(GSDepthStencilOGL* dss); 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 OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL);
void OMSetWriteBuffer(GLenum buffer = GL_COLOR_ATTACHMENT0); void OMSetWriteBuffer(GLenum buffer = GL_COLOR_ATTACHMENT0);
void OMSetColorMaskState(OMColorMaskSelector sel = OMColorMaskSelector()); 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; const GIFRegALPHA& ALPHA = m_context->ALPHA;
bool require_barrier = false; bool require_barrier = false;
bool sw_blending = false; bool sw_blending = false;
float afix = (float)m_context->ALPHA.FIX / 0x80;
// No blending so early exit // No blending so early exit
if (!(PRIM->ABE || PRIM->AA1 && m_vt.m_primclass == GS_LINE_CLASS)) { 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 // Require the fix alpha vlaue
if (ALPHA.C == 2) { 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 // 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) { if (ps_sel.dfmt == 1 && ALPHA.C == 1) {
// 24 bits doesn't have an alpha channel so use 1.0f fix factor as equivalent // 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 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 { } else {
dev->OMSetBlendState(blend_index, afix, (ALPHA.C == 2)); dev->OMSetBlendState(blend_index, ALPHA.FIX, (ALPHA.C == 2));
} }
} }