diff options
| author | Ryan Houdek <Sonicadvance1@gmail.com> | 2011-12-10 15:40:10 -0600 |
|---|---|---|
| committer | Ryan Houdek <Sonicadvance1@gmail.com> | 2011-12-10 15:40:10 -0600 |
| commit | 97c3c156e61b9e8c4882ead53647b554f606dd16 (patch) | |
| tree | dfd2380a5cef1459c76844044c61610a44ce62e9 /Source/Core/VideoCommon/Src/TextureConversionShader.cpp | |
| parent | c72a244809ee9e8a645bd1f200138af727d0474b (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/VideoCommon/Src/TextureConversionShader.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/Src/TextureConversionShader.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp index 550fef2740..262b2cee87 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"); |
