summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2011-12-21 01:29:29 -0600
committerSonicadvance1 <sonicadvance1@RH-Live.(none)>2012-10-09 23:42:41 -0500
commit9996f2712046b7d899cc52a0d4ae6f021ef918f5 (patch)
tree063684a39a3be58180a6cbfb2139067dc0084447 /Source/Core/VideoCommon
parentd012c75005a66f0bc1375816fd2155f97516cdde (diff)
Give OSX users more of a chance of supporting Single pass DSB in the future.
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/Src/PixelShaderGen.cpp5
-rw-r--r--Source/Core/VideoCommon/Src/VertexShaderGen.cpp32
-rw-r--r--Source/Core/VideoCommon/Src/VideoConfig.h1
3 files changed, 28 insertions, 10 deletions
diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
index 9bb897dcc9..2cf1a33fed 100644
--- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
+++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp
@@ -572,6 +572,9 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
}
else
WRITE(p, "#version 120\n");
+
+ if(g_ActiveConfig.backend_info.bSupportsGLSLATTRBind)
+ WRITE(p, "#extension GL_ARB_explicit_attrib_location : enable\n");
// Silly differences
WRITE(p, "#define float2 vec2\n");
WRITE(p, "#define float3 vec3\n");
@@ -630,7 +633,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
WRITE(p, "\n");
if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
- WRITE(p, "layout(std140%s) uniform PSBlock {\n", g_ActiveConfig.backend_info.bSupportsGLSLBinding ? ", binding = 1" : "");
+ WRITE(p, "layout(std140) uniform PSBlock {\n");
WRITE(p, "%sfloat4 "I_COLORS"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_COLORS));
WRITE(p, "%sfloat4 "I_KCOLORS"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_KCOLORS));
diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp
index 415ff4614c..5ae3e84f56 100644
--- a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp
+++ b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp
@@ -204,6 +204,8 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
WRITE(p, "#define ATTRIN attribute\n");
WRITE(p, "#define ATTROUT attribute\n");
}
+ if(g_ActiveConfig.backend_info.bSupportsGLSLATTRBind)
+ WRITE(p, "#extension GL_ARB_explicit_attrib_location : enable\n");
// Silly differences
WRITE(p, "#define float2 vec2\n");
WRITE(p, "#define float3 vec3\n");
@@ -217,7 +219,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
// uniforms
if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
- WRITE(p, "layout(std140%s) uniform VSBlock {\n", g_ActiveConfig.backend_info.bSupportsGLSLBinding ? ", binding = 2" : "");
+ WRITE(p, "layout(std140) uniform VSBlock {\n");
WRITE(p, "%sfloat4 "I_POSNORMALMATRIX"[6] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_POSNORMALMATRIX));
WRITE(p, "%sfloat4 "I_PROJECTION"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_PROJECTION));
@@ -241,21 +243,33 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
if (components & VB_HAS_NRM0)
WRITE(p, " float3 rawnorm0 = gl_Normal; // NORMAL0,\n");
- if (components & VB_HAS_POSMTXIDX)
+ if(g_ActiveConfig.backend_info.bSupportsGLSLATTRBind)
+ {
+ if (components & VB_HAS_POSMTXIDX)
+ WRITE(p, "layout(location = %d) ATTRIN float fposmtx;\n", SHADER_POSMTX_ATTRIB);
+ if (components & VB_HAS_NRM1)
+ WRITE(p, "layout(location = %d) ATTRIN float3 rawnorm1;\n", SHADER_NORM1_ATTRIB);
+ if (components & VB_HAS_NRM2)
+ WRITE(p, "layout(location = %d) ATTRIN float3 rawnorm2;\n", SHADER_NORM2_ATTRIB);
+ }
+ else
+ {
+ if (components & VB_HAS_POSMTXIDX)
WRITE(p, "ATTRIN float fposmtx; // ATTR%d,\n", SHADER_POSMTX_ATTRIB);
- if (components & VB_HAS_NRM1)
+ if (components & VB_HAS_NRM1)
WRITE(p, "ATTRIN float3 rawnorm1; // ATTR%d,\n", SHADER_NORM1_ATTRIB);
- if (components & VB_HAS_NRM2)
+ if (components & VB_HAS_NRM2)
WRITE(p, "ATTRIN float3 rawnorm2; // ATTR%d,\n", SHADER_NORM2_ATTRIB);
+ }
if (components & VB_HAS_COL0)
- WRITE(p, " float4 color0 = gl_Color; // COLOR0,\n");
+ WRITE(p, " float4 color0 = gl_Color; // COLOR0,\n");
if (components & VB_HAS_COL1)
- WRITE(p, " float4 color1 = gl_SecondaryColor; // COLOR1,\n");
+ WRITE(p, " float4 color1 = gl_SecondaryColor; // COLOR1,\n");
for (int i = 0; i < 8; ++i) {
- u32 hastexmtx = (components & (VB_HAS_TEXMTXIDX0<<i));
- if ((components & (VB_HAS_UV0<<i)) || hastexmtx)
- WRITE(p, " float%d tex%d = gl_MultiTexCoord%d.xy%s; // TEXCOORD%d,\n", hastexmtx ? 3 : 2, i, i, hastexmtx ? "z" : "", i);
+ u32 hastexmtx = (components & (VB_HAS_TEXMTXIDX0<<i));
+ if ((components & (VB_HAS_UV0<<i)) || hastexmtx)
+ WRITE(p, " float%d tex%d = gl_MultiTexCoord%d.xy%s; // TEXCOORD%d,\n", hastexmtx ? 3 : 2, i, i, hastexmtx ? "z" : "", i);
}
WRITE(p, " float4 rawpos = gl_Vertex;\n") ;
diff --git a/Source/Core/VideoCommon/Src/VideoConfig.h b/Source/Core/VideoCommon/Src/VideoConfig.h
index b27893f0ae..6476317efc 100644
--- a/Source/Core/VideoCommon/Src/VideoConfig.h
+++ b/Source/Core/VideoCommon/Src/VideoConfig.h
@@ -167,6 +167,7 @@ struct VideoConfig
bool bSupportsGLSL;
bool bSupportsGLSLBinding;
bool bSupportsGLSLUBO;
+ bool bSupportsGLSLATTRBind;
bool bSupportsGLSLCache;
} backend_info;
};