summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2011-12-10 15:40:10 -0600
committerSonicadvance1 <sonicadvance1@RH-Live.(none)>2012-10-09 23:41:06 -0500
commit5b06bbf87d75cb3d06dfae6c58c05ade0374a676 (patch)
tree8f7b7f6fe9f0cfdc518230ab642d03c5e581a402 /Source/Core
parent5bcbf92f439663900a8fe60c1fee4eea2d96a192 (diff)
Use UBOs in every shader. I had missed a few. Only cache Uniform locations if we aren't using UBOs.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoCommon/Src/TextureConversionShader.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp
index e4638f8b16..33c6bca038 100644
--- a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp
+++ b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp
@@ -74,6 +74,14 @@ const char* WriteRegister(API_TYPE ApiType, const char *prefix, const u32 num)
sprintf(result, " : register(%s%d)", prefix, num);
return result;
}
+const char *WriteLocation(API_TYPE ApiType)
+{
+ if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
+ return "";
+ static char result[64];
+ sprintf(result, "uniform ");
+ return result;
+}
// block dimensions : widthStride, heightStride
// texture dims : width, height, x offset, y offset
@@ -82,7 +90,13 @@ void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType)
// [0] left, top, right, bottom of source rectangle within source texture
// [1] width and height of destination texture in pixels
// Two were merged for GLSL
- WRITE(p, "uniform float4 "I_COLORS"[2] %s;\n", WriteRegister(ApiType, "c", C_COLORS));
+ 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, "%sfloat4 "I_COLORS"[2] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_COLORS));
+
+ if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
+ WRITE(p, "};\n");
float blkW = (float)TexDecoder_GetBlockWidthInTexels(format);
float blkH = (float)TexDecoder_GetBlockHeightInTexels(format);
@@ -168,7 +182,11 @@ void Write32BitSwizzler(char*& p, u32 format, API_TYPE ApiType)
// [0] left, top, right, bottom of source rectangle within source texture
// [1] width and height of destination texture in pixels
// Two were merged for GLSL
- WRITE(p, "uniform float4 "I_COLORS"[2] %s;\n", WriteRegister(ApiType, "c", C_COLORS));
+ 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, "%sfloat4 "I_COLORS"[2] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_COLORS));
+ if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
+ WRITE(p, "};\n");
float blkW = (float)TexDecoder_GetBlockWidthInTexels(format);
float blkH = (float)TexDecoder_GetBlockHeightInTexels(format);
@@ -839,10 +857,13 @@ const char *GenerateEncodingShader(u32 format,API_TYPE ApiType)
if(ApiType == API_GLSL)
{
// A few required defines and ones that will make our lives a lot easier
- if (g_ActiveConfig.backend_info.bSupportsGLSLBinding)
+ if (g_ActiveConfig.backend_info.bSupportsGLSLBinding || g_ActiveConfig.backend_info.bSupportsGLSLUBO)
{
WRITE(p, "#version 330 compatibility\n");
- WRITE(p, "#extension GL_ARB_shading_language_420pack : enable\n");
+ if (g_ActiveConfig.backend_info.bSupportsGLSLBinding)
+ WRITE(p, "#extension GL_ARB_shading_language_420pack : enable\n");
+ if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
+ WRITE(p, "#extension GL_ARB_uniform_buffer_object : enable\n");
}
else
WRITE(p, "#version 120\n");