summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2011-12-08 05:09:48 -0600
committerRyan Houdek <Sonicadvance1@gmail.com>2011-12-08 05:09:48 -0600
commit0ccba2b581bedc564aa8052d6545e946768d4c70 (patch)
tree0af1d4186c08d415713355a7d83ef8c40fc4bd40 /Source
parent62b9a779c152df45a723d4fbd8c1d75d8d6fc8e3 (diff)
Support Dual Source Blending in OGL plugin with GLSL.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/VideoCommon/Src/PixelShaderGen.cpp23
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp8
2 files changed, 18 insertions, 13 deletions
diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
index 584254e371..4c402e0a9f 100644
--- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
@@ -675,10 +675,18 @@ 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.
-
- WRITE(p, " float4 ocol0;\n");
+
+
if(dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND)
- WRITE(p, " float4 ocol1;\n"); // Will be supported later
+ {
+ // This won't get hit unless we support GL 3.3
+ WRITE(p, " layout(location = 0) out float4 ocol0;\n");
+ WRITE(p, " layout(location = 0, index = 1) out float4 ocol1;\n"); // Will be supported later
+ }
+ else
+ {
+ WRITE(p, " float4 ocol0;\n");
+ }
if(DepthTextureEnable)
WRITE(p, " float depth;\n"); // TODO: Passed to Vertex Shader right?
WRITE(p, " float4 rawpos = gl_FragCoord;\n");
@@ -721,7 +729,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
// alpha test will always fail, so restart the shader and just make it an empty function
WRITE(p, "ocol0 = float4(0);\n");
WRITE(p, "discard;\n");
- if(ApiType == API_GLSL)
+ if(ApiType == API_GLSL && dstAlphaMode != DSTALPHA_DUAL_SOURCE_BLEND)
WRITE(p, "gl_FragData[0] = ocol0;\n");
if(ApiType != API_D3D11)
WRITE(p, "return;\n");
@@ -833,7 +841,8 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
if(ApiType == API_GLSL)
{
// Once we switch to GLSL 1.3 and bind variables, we won't need to do this
- WRITE(p, "gl_FragData[0] = ocol0;\n");
+ if (dstAlphaMode != DSTALPHA_DUAL_SOURCE_BLEND)
+ WRITE(p, "gl_FragData[0] = ocol0;\n");
if(DepthTextureEnable)
WRITE(p, "gl_FragDepth = depth;\n");
if(dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND)
@@ -892,8 +901,8 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
{
if(DepthTextureEnable)
WRITE(p, "gl_FragDepth = depth;\n");
-
- WRITE(p, "gl_FragData[0] = ocol0;\n");
+ if (dstAlphaMode != DSTALPHA_DUAL_SOURCE_BLEND)
+ WRITE(p, "gl_FragData[0] = ocol0;\n");
}
}
WRITE(p, "}\n");
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp
index ebca599fe8..e2723c0c98 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp
@@ -177,8 +177,8 @@ void VertexManager::vFlush()
bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate
&& bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
-#ifdef USE_DUAL_SOURCE_BLEND
- bool dualSourcePossible = GLEW_ARB_blend_func_extended;
+ // Makes sure we can actually do Dual source blending
+ bool dualSourcePossible = g_ActiveConfig.bUseGLSL && g_ActiveConfig.backend_info.bSupportsGLSLBinding;
// finally bind
FRAGMENTSHADER* ps;
@@ -201,10 +201,6 @@ void VertexManager::vFlush()
{
ps = PixelShaderCache::SetShader(DSTALPHA_NONE,g_nativeVertexFmt->m_components);
}
-#else
- bool dualSourcePossible = false;
- FRAGMENTSHADER* ps = PixelShaderCache::SetShader(DSTALPHA_NONE,g_nativeVertexFmt->m_components);
-#endif
VERTEXSHADER* vs = VertexShaderCache::SetShader(g_nativeVertexFmt->m_components);
if(g_ActiveConfig.bUseGLSL)