Add support for Dual source blending to older ATI cards that don't support 420pack but do support GL_ARB_blend_func_extended. This is more proper as well anyways.
This commit is contained in:
parent
fbbea9bb9b
commit
8a48b42e4c
|
@ -568,6 +568,8 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
|||
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLATTRBind)
|
||||
WRITE(p, "#extension GL_ARB_explicit_attrib_location : enable\n");
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLBlend)
|
||||
WRITE(p, "#extension GL_ARB_blend_func_extended : enable\n");
|
||||
// Silly differences
|
||||
WRITE(p, "#define float2 vec2\n");
|
||||
WRITE(p, "#define float3 vec3\n");
|
||||
|
@ -694,12 +696,19 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
|
|||
// GLSL doesn't do main arguments
|
||||
// Once we switch to GLSL 1.3 we will bind a lot of these.
|
||||
|
||||
|
||||
if (dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND)
|
||||
{
|
||||
// This won't get hit unless we support GL 3.3
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLBinding)
|
||||
{
|
||||
WRITE(p, " layout(location = 0) out float4 ocol0;\n");
|
||||
WRITE(p, " layout(location = 0, index = 1) out float4 ocol1;\n"); // Will be supported later
|
||||
WRITE(p, " layout(location = 0, index = 1) out float4 ocol1;\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITE(p, " out float4 ocol0;\n");
|
||||
WRITE(p, " out float4 ocol1;\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -170,6 +170,7 @@ struct VideoConfig
|
|||
|
||||
bool bSupportsGLSL;
|
||||
bool bSupportsGLSLBinding;
|
||||
bool bSupportsGLSLBlend;
|
||||
bool bSupportsGLSLUBO;
|
||||
bool bSupportsGLSLATTRBind;
|
||||
bool bSupportsGLSLCache;
|
||||
|
|
|
@ -406,7 +406,6 @@ bool CompileGLSLPixelShader(FRAGMENTSHADER& ps, const char* pstrprogram)
|
|||
FILE *fp = fopen(szTemp, "wb");
|
||||
fwrite(pstrprogram, strlen(pstrprogram), 1, fp);
|
||||
fclose(fp);
|
||||
|
||||
delete[] infoLog;
|
||||
}
|
||||
// Don't try to use this shader
|
||||
|
|
|
@ -91,6 +91,14 @@ void ProgramShaderCache::SetProgramVariables(PCacheEntry &entry)
|
|||
if (entry.UniformLocations[a] != -1)
|
||||
glUniform1i(entry.UniformLocations[a], a);
|
||||
}
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLBlend)
|
||||
{
|
||||
// So we don't support binding, but we do support extended blending
|
||||
// So we need to set a few more things here.
|
||||
// Bind our out locations
|
||||
glBindFragDataLocationIndexed(entry.prog_id, 0, 0, "ocol0");
|
||||
glBindFragDataLocationIndexed(entry.prog_id, 0, 1, "ocol1");
|
||||
}
|
||||
}
|
||||
|
||||
// Need to get some attribute locations
|
||||
|
|
|
@ -316,6 +316,8 @@ Renderer::Renderer()
|
|||
// TODO: Switch over to using glew once 1.6/1.7 becomes more mainstream, seems most people are stuck in 1.5
|
||||
if (strstr((const char*)glGetString(GL_EXTENSIONS), "GL_ARB_shading_language_420pack") != NULL)
|
||||
g_Config.backend_info.bSupportsGLSLBinding = true;
|
||||
if (glewIsSupported("GL_ARB_blend_func_extended"))
|
||||
g_Config.backend_info.bSupportsGLSLBlend = true;
|
||||
if (strstr((const char*)glGetString(GL_EXTENSIONS), "GL_ARB_uniform_buffer_object") != NULL)
|
||||
g_Config.backend_info.bSupportsGLSLUBO = true;
|
||||
if ((g_Config.backend_info.bSupportsGLSLBinding || g_Config.backend_info.bSupportsGLSLUBO) && strstr((const char*)glGetString(GL_EXTENSIONS), "GL_ARB_explicit_attrib_location") != NULL)
|
||||
|
@ -963,7 +965,7 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
|||
|
||||
bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate
|
||||
&& bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
|
||||
bool useDualSource = useDstAlpha && g_ActiveConfig.bUseGLSL && g_ActiveConfig.backend_info.bSupportsGLSLBinding;
|
||||
bool useDualSource = useDstAlpha && g_ActiveConfig.bUseGLSL && g_ActiveConfig.backend_info.bSupportsGLSLBlend;
|
||||
|
||||
if (changes & 1)
|
||||
// blend enable change
|
||||
|
@ -974,10 +976,16 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
|||
// subtract enable change
|
||||
GLenum equation = newval & 4 ? GL_FUNC_REVERSE_SUBTRACT : GL_FUNC_ADD;
|
||||
GLenum equationAlpha = useDualSource ? GL_FUNC_ADD : equation;
|
||||
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLBlend)
|
||||
glBlendEquationSeparate(equation, equationAlpha);
|
||||
else
|
||||
glBlendEquation(newval & 4 ? GL_FUNC_REVERSE_SUBTRACT : GL_FUNC_ADD);
|
||||
}
|
||||
|
||||
if (changes & 0x1F8)
|
||||
{
|
||||
if (g_ActiveConfig.backend_info.bSupportsGLSLBlend)
|
||||
{
|
||||
GLenum srcFactor = glSrcFactors[(newval >> 3) & 7];
|
||||
GLenum srcFactorAlpha = srcFactor;
|
||||
|
@ -1002,6 +1010,9 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
|||
// blend RGB change
|
||||
glBlendFuncSeparate(srcFactor, dstFactor, srcFactorAlpha, dstFactorAlpha);
|
||||
}
|
||||
else
|
||||
glBlendFunc(glSrcFactors[(newval >> 3) & 7], glDestFactors[(newval >> 6) & 7]);
|
||||
}
|
||||
|
||||
s_blendMode = newval;
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ void VertexManager::vFlush()
|
|||
&& bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
|
||||
|
||||
// Makes sure we can actually do Dual source blending
|
||||
bool dualSourcePossible = g_ActiveConfig.bUseGLSL && g_ActiveConfig.backend_info.bSupportsGLSLBinding;
|
||||
bool dualSourcePossible = g_ActiveConfig.bUseGLSL && g_ActiveConfig.backend_info.bSupportsGLSLBlend;
|
||||
|
||||
// finally bind
|
||||
FRAGMENTSHADER* ps;
|
||||
|
|
|
@ -204,14 +204,12 @@ bool CompileGLSLVertexShader(VERTEXSHADER& vs, const char* pstrprogram)
|
|||
FILE *fp = fopen(szTemp, "wb");
|
||||
fwrite(pstrprogram, strlen(pstrprogram), 1, fp);
|
||||
fclose(fp);
|
||||
|
||||
delete[] infoLog;
|
||||
}
|
||||
// Don't try to use this shader
|
||||
glDeleteShader(result);
|
||||
return false;
|
||||
}
|
||||
|
||||
(void)GL_REPORT_ERROR();
|
||||
vs.glprogid = result;
|
||||
vs.bGLSL = true;
|
||||
|
|
Loading…
Reference in New Issue