From 1f75ee49bf3003b10a41d93c0848573b38a7b440 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sat, 10 Dec 2011 07:38:30 -0600 Subject: [PATCH] UBO works for Pixel Shaders if Binding for UBO is zero, otherwise fails. Probably why Vertex shader UBO is failing. Too tired to investigate right now. --- .../Core/VideoCommon/Src/PixelShaderGen.cpp | 14 +- Source/Core/VideoCommon/Src/PixelShaderGen.h | 4 +- .../Core/VideoCommon/Src/VertexShaderGen.cpp | 33 +++-- Source/Core/VideoCommon/Src/VertexShaderGen.h | 2 +- .../VideoCommon/Src/VertexShaderManager.cpp | 2 +- .../Plugin_VideoOGL/Src/PixelShaderCache.cpp | 13 +- .../Src/ProgramShaderCache.cpp | 56 +++++--- .../Plugin_VideoOGL/Src/TextureConverter.cpp | 133 ++++++++++++------ .../Plugin_VideoOGL/Src/VertexShaderCache.cpp | 7 +- 9 files changed, 176 insertions(+), 88 deletions(-) diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index 05997bd1db..d6a128ac4f 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -511,11 +511,11 @@ static void BuildSwapModeTable() const char* WriteRegister(API_TYPE ApiType, const char *prefix, const u32 num) { - if(ApiType == API_GLSL) - return ""; // Nothing to do here - static char result[64]; - sprintf(result, " : register(%s%d)", prefix, num); - return result; + if(ApiType == API_GLSL) + return ""; // Nothing to do here + static char result[64]; + sprintf(result, " : register(%s%d)", prefix, num); + return result; } const char* WriteBinding(API_TYPE ApiType, const u32 num) { @@ -527,9 +527,9 @@ const char* WriteBinding(API_TYPE ApiType, const u32 num) } const char *WriteLocation(API_TYPE ApiType) { - static char result[64]; if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO) return ""; + static char result[64]; sprintf(result, "uniform "); return result; } @@ -620,7 +620,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, binding = 4) uniform PSBlock {\n"); + WRITE(p, "layout(std140, binding = 0) 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/PixelShaderGen.h b/Source/Core/VideoCommon/Src/PixelShaderGen.h index 589fc927bc..b32b7408c3 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.h +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.h @@ -28,8 +28,8 @@ #define I_INDTEXSCALE "cindscale" #define I_INDTEXMTX "cindmtx" #define I_FOG "cfog" -#define I_PLIGHTS "cLights" -#define I_PMATERIALS "cmtrl" +#define I_PLIGHTS "cPLights" +#define I_PMATERIALS "cPmtrl" #define C_COLORMATRIX 0 // 0 #define C_COLORS 0 // 0 diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp index fc3c73c3c3..6190eacbd0 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp @@ -166,6 +166,12 @@ char* GenerateVSOutputStruct(char* p, u32 components, API_TYPE ApiType) extern const char* WriteRegister(API_TYPE ApiType, const char *prefix, const u32 num); extern const char* WriteBinding(API_TYPE ApiType, const u32 num); const char *WriteLocation(API_TYPE ApiType); +const char *WriteLocation2(API_TYPE ApiType) +{ + static char result[64]; + sprintf(result, "uniform "); + return result; +} const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType) { @@ -216,21 +222,22 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType) } // uniforms - if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO) - WRITE(p, "layout(std140, binding = 5) uniform VSBlock {\n"); + //if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO) + //WRITE(p, "layout(std140, binding = 2) 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)); - WRITE(p, "%sfloat4 "I_MATERIALS"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_MATERIALS)); - WRITE(p, "%sfloat4 "I_LIGHTS"[40] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_LIGHTS)); - WRITE(p, "%sfloat4 "I_TEXMATRICES"[24] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_TEXMATRICES)); // also using tex matrices - WRITE(p, "%sfloat4 "I_TRANSFORMMATRICES"[64] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_TRANSFORMMATRICES)); - WRITE(p, "%sfloat4 "I_NORMALMATRICES"[32] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_NORMALMATRICES)); - WRITE(p, "%sfloat4 "I_POSTTRANSFORMMATRICES"[64] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_POSTTRANSFORMMATRICES)); - WRITE(p, "%sfloat4 "I_DEPTHPARAMS" %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_DEPTHPARAMS)); + WRITE(p, "%sfloat4 "I_POSNORMALMATRIX"[6] %s;\n", WriteLocation2(ApiType), WriteRegister(ApiType, "c", C_POSNORMALMATRIX)); + //if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO) + //WRITE(p, "};\n"); + WRITE(p, "%sfloat4 "I_PROJECTION"[4] %s;\n", WriteLocation2(ApiType), WriteRegister(ApiType, "c", C_PROJECTION)); + WRITE(p, "%sfloat4 "I_MATERIALS"[4] %s;\n", WriteLocation2(ApiType), WriteRegister(ApiType, "c", C_MATERIALS)); + WRITE(p, "%sfloat4 "I_LIGHTS"[40] %s;\n", WriteLocation2(ApiType), WriteRegister(ApiType, "c", C_LIGHTS)); + WRITE(p, "%sfloat4 "I_TEXMATRICES"[24] %s;\n", WriteLocation2(ApiType), WriteRegister(ApiType, "c", C_TEXMATRICES)); // also using tex matrices + WRITE(p, "%sfloat4 "I_TRANSFORMMATRICES"[64] %s;\n", WriteLocation2(ApiType), WriteRegister(ApiType, "c", C_TRANSFORMMATRICES)); + WRITE(p, "%sfloat4 "I_NORMALMATRICES"[32] %s;\n", WriteLocation2(ApiType), WriteRegister(ApiType, "c", C_NORMALMATRICES)); + WRITE(p, "%sfloat4 "I_POSTTRANSFORMMATRICES"[64] %s;\n", WriteLocation2(ApiType), WriteRegister(ApiType, "c", C_POSTTRANSFORMMATRICES)); + WRITE(p, "%sfloat4 "I_DEPTHPARAMS" %s;\n", WriteLocation2(ApiType), WriteRegister(ApiType, "c", C_DEPTHPARAMS)); + - if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO) - WRITE(p, "};\n"); p = GenerateVSOutputStruct(p, components, ApiType); diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.h b/Source/Core/VideoCommon/Src/VertexShaderGen.h index 7e5fc365e6..73decc32bc 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderGen.h +++ b/Source/Core/VideoCommon/Src/VertexShaderGen.h @@ -55,7 +55,7 @@ const s_svar VSVar_Loc[] = { {I_POSNORMALMATRIX, C_POSNORMALMATRIX, 6 }, {I_TRANSFORMMATRICES , C_TRANSFORMMATRICES, 64 }, {I_NORMALMATRICES , C_NORMALMATRICES, 32 }, {I_POSTTRANSFORMMATRICES, C_POSTTRANSFORMMATRICES, 64 }, - {I_DEPTHPARAMS, C_DEPTHPARAMS, 4 }, + {I_DEPTHPARAMS, C_DEPTHPARAMS, 1 }, }; template class _VERTEXSHADERUID diff --git a/Source/Core/VideoCommon/Src/VertexShaderManager.cpp b/Source/Core/VideoCommon/Src/VertexShaderManager.cpp index 5d62686ac9..866674e853 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/Src/VertexShaderManager.cpp @@ -184,7 +184,7 @@ void VertexShaderManager::Dirty() // TODO: A cleaner way to control the matricies without making a mess in the parameters field void VertexShaderManager::SetConstants() { - if (g_ActiveConfig.bUseGLSL && !g_ActiveConfig.backend_info.bSupportsGLSLUBO) + //if (g_ActiveConfig.bUseGLSL && !g_ActiveConfig.backend_info.bSupportsGLSLUBO) Dirty(); if (nTransformMatricesChanged[0] >= 0) { diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp index 7e8c48a872..a248157751 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp @@ -496,14 +496,15 @@ void SetPSConstant4fvByName(const char * name, unsigned int offset, const float } } } + void SetGLSLPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) { float f[4] = { f1, f2, f3, f4 }; if (g_ActiveConfig.backend_info.bSupportsGLSLUBO) { - ProgramShaderCache::SetUniformObjects(0, const_number, f); - //return; + ProgramShaderCache::SetUniformObjects(0, const_number, f); + //return; } for (unsigned int a = 0; a < 10; ++a) { @@ -520,8 +521,8 @@ void SetGLSLPSConstant4fv(unsigned int const_number, const float *f) { if (g_ActiveConfig.backend_info.bSupportsGLSLUBO) { - ProgramShaderCache::SetUniformObjects(0, const_number, f); - //return; + ProgramShaderCache::SetUniformObjects(0, const_number, f); + //return; } for (unsigned int a = 0; a < 10; ++a) { @@ -538,8 +539,8 @@ void SetMultiGLSLPSConstant4fv(unsigned int const_number, unsigned int count, co { if (g_ActiveConfig.backend_info.bSupportsGLSLUBO) { - ProgramShaderCache::SetUniformObjects(0, const_number, f, count); - //return; + ProgramShaderCache::SetUniformObjects(0, const_number, f, count); + //return; } for (unsigned int a = 0; a < 10; ++a) { diff --git a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp index e174cf2641..4b1f8b28d2 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp @@ -17,12 +17,15 @@ #include "ProgramShaderCache.h" #include -static GLenum checkForGLError(const char * situation) +GLuint GLERR(const char *function) { - GLenum error = glGetError(); - if (error != GL_NO_ERROR) - printf("Error: %d -- %s\n", error, situation); - return error; + GLint err = glGetError(); + if (err != GL_NO_ERROR) + { + printf( "(%s) OpenGL error 0x%x - %s\n", + function, err, gluErrorString(err)); + } + return err; } namespace OGL { @@ -98,10 +101,19 @@ namespace OGL glAttachShader(entry.program.glprogid, entry.program.psid); glLinkProgram(entry.program.glprogid); + GLsizei length = 0; + + glGetProgramiv(entry.program.glprogid, GL_INFO_LOG_LENGTH, &length); + if (length > 0) + { + GLsizei charsWritten; + GLchar* infoLog = new GLchar[length]; + glGetProgramInfoLog(entry.program.glprogid, length, &charsWritten, infoLog); + printf("Program info log:\n%s", infoLog); + delete[] infoLog; + } glUseProgram(entry.program.glprogid); - checkForGLError("User"); - // We cache our uniform locations for now // Once we move up to a newer version of GLSL, ~1.30 @@ -136,12 +148,22 @@ namespace OGL } void ProgramShaderCache::SetUniformObjects(int Buffer, unsigned int offset, const float *f, unsigned int count) { + GLERR(""); assert(Buffer > 1); - glBindBuffer(GL_UNIFORM_BUFFER, UBOBuffers[Buffer]); + static int _Buffer = -1; + if(_Buffer != Buffer) + { + _Buffer = Buffer; + GLERR("bind"); + glBindBuffer(GL_UNIFORM_BUFFER, UBOBuffers[_Buffer]); + } + // Query for the offsets of each block variable + // glBufferSubData expects data in bytes, so multiply count by four // Expects the offset in bytes as well, so multiply by *4 *4 since we are passing in a vec4 location glBufferSubData(GL_UNIFORM_BUFFER, offset * 4 * 4, count * 4 * 4, f); - glBindBuffer(GL_UNIFORM_BUFFER, 0); + GLERR("sub"); + } GLuint ProgramShaderCache::GetCurrentProgram(void) { return CurrentProgram; } @@ -156,20 +178,22 @@ namespace OGL void ProgramShaderCache::Init(void) { glGenBuffers(2, UBOBuffers); + + glBindBuffer(GL_UNIFORM_BUFFER, UBOBuffers[0]); // We multiply by *4*4 because we need to get down to basic machine units. // So multiply by four to get how many floats we have from vec4s // Then once more to get bytes - glBufferData(GL_UNIFORM_BUFFER, 1024 *1024, NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_UNIFORM_BUFFER, C_PENVCONST_END * 4 * 4, NULL, GL_DYNAMIC_DRAW); // Now bind the buffer to the index point // We know PS is 0 since we have it statically set in the shader - glBindBufferBase(GL_UNIFORM_BUFFER, 4, UBOBuffers[0]); + glBindBufferBase(GL_UNIFORM_BUFFER, 0, UBOBuffers[0]); + // Repeat for VS shader - glBindBuffer(GL_UNIFORM_BUFFER, UBOBuffers[1]); - glBufferData(GL_UNIFORM_BUFFER, 1024*1024, NULL, GL_DYNAMIC_DRAW); - glBindBufferBase(GL_UNIFORM_BUFFER, 5, UBOBuffers[1]); - glBindBuffer(GL_UNIFORM_BUFFER, 0); - checkForGLError("Init"); + //glBindBuffer(GL_UNIFORM_BUFFER, UBOBuffers[1]); + //glBufferData(GL_UNIFORM_BUFFER, C_PENVCONST_END * 4 * 4, NULL, GL_DYNAMIC_DRAW); + //glBindBufferBase(GL_UNIFORM_BUFFER, 2, UBOBuffers[1]); + GLERR("init"); } void ProgramShaderCache::Shutdown(void) { diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp index c542a64cb9..6a5becae7b 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp @@ -63,26 +63,49 @@ void CreateRgbToYuyvProgram() // Output is BGRA because that is slightly faster than RGBA. if(g_ActiveConfig.bUseGLSL) { - const char *FProgram = - "#version 120\n" - "#ifdef GL_ARB_texture_rectangle\n" - "#extension GL_ARB_texture_rectangle : require\n" - "#endif\n" - "uniform sampler2DRect samp0;\n" - "void main()\n" - "{\n" - " vec2 uv1 = vec2(gl_TexCoord[0].x + 1.0f, gl_TexCoord[0].y);\n" - " vec3 c0 = texture2DRect(samp0, gl_TexCoord[0].xy).rgb;\n" - " vec3 c1 = texture2DRect(samp0, uv1).rgb;\n" - " vec3 y_const = vec3(0.257f,0.504f,0.098f);\n" - " vec3 u_const = vec3(-0.148f,-0.291f,0.439f);\n" - " vec3 v_const = vec3(0.439f,-0.368f,-0.071f);\n" - " vec4 const3 = vec4(0.0625f,0.5f,0.0625f,0.5f);\n" - " vec3 c01 = (c0 + c1) * 0.5f;\n" - " gl_FragData[0] = vec4(dot(c1,y_const),dot(c01,u_const),dot(c0,y_const),dot(c01, v_const)) + const3;\n" - "}\n"; - if (!PixelShaderCache::CompilePixelShader(s_rgbToYuyvProgram, FProgram)) - ERROR_LOG(VIDEO, "Failed to create RGB to YUYV fragment program."); + if(g_ActiveConfig.backend_info.bSupportsGLSLBinding) + { + const char *FProgram = + "#version 330 compatibility\n" + "#extension GL_ARB_texture_rectangle : enable\n" + "#extension GL_ARB_shading_language_420pack : enable\n" + "layout(binding = 0) uniform sampler2DRect samp0;\n" + "void main()\n" + "{\n" + " vec2 uv1 = vec2(gl_TexCoord[0].x + 1.0f, gl_TexCoord[0].y);\n" + " vec3 c0 = texture2DRect(samp0, gl_TexCoord[0].xy).rgb;\n" + " vec3 c1 = texture2DRect(samp0, uv1).rgb;\n" + " vec3 y_const = vec3(0.257f,0.504f,0.098f);\n" + " vec3 u_const = vec3(-0.148f,-0.291f,0.439f);\n" + " vec3 v_const = vec3(0.439f,-0.368f,-0.071f);\n" + " vec4 const3 = vec4(0.0625f,0.5f,0.0625f,0.5f);\n" + " vec3 c01 = (c0 + c1) * 0.5f;\n" + " gl_FragData[0] = vec4(dot(c1,y_const),dot(c01,u_const),dot(c0,y_const),dot(c01, v_const)) + const3;\n" + "}\n"; + if (!PixelShaderCache::CompilePixelShader(s_rgbToYuyvProgram, FProgram)) + ERROR_LOG(VIDEO, "Failed to create RGB to YUYV fragment program."); + } + else + { + const char *FProgram = + "#version 120\n" + "#extension GL_ARB_texture_rectangle : enable\n" + "uniform sampler2DRect samp0;\n" + "void main()\n" + "{\n" + " vec2 uv1 = vec2(gl_TexCoord[0].x + 1.0f, gl_TexCoord[0].y);\n" + " vec3 c0 = texture2DRect(samp0, gl_TexCoord[0].xy).rgb;\n" + " vec3 c1 = texture2DRect(samp0, uv1).rgb;\n" + " vec3 y_const = vec3(0.257f,0.504f,0.098f);\n" + " vec3 u_const = vec3(-0.148f,-0.291f,0.439f);\n" + " vec3 v_const = vec3(0.439f,-0.368f,-0.071f);\n" + " vec4 const3 = vec4(0.0625f,0.5f,0.0625f,0.5f);\n" + " vec3 c01 = (c0 + c1) * 0.5f;\n" + " gl_FragData[0] = vec4(dot(c1,y_const),dot(c01,u_const),dot(c0,y_const),dot(c01, v_const)) + const3;\n" + "}\n"; + if (!PixelShaderCache::CompilePixelShader(s_rgbToYuyvProgram, FProgram)) + ERROR_LOG(VIDEO, "Failed to create RGB to YUYV fragment program."); + } } else { @@ -111,29 +134,57 @@ void CreateYuyvToRgbProgram() { if(g_ActiveConfig.bUseGLSL) { - const char *FProgram = - "#version 120\n" - "#ifdef GL_ARB_texture_rectangle\n" - "#extension GL_ARB_texture_rectangle : require\n" - "#endif\n" - "uniform sampler2DRect samp0;\n" - "void main()\n" - "{\n" - " vec4 c0 = texture2DRect(samp0, gl_TexCoord[0].xy).rgba;\n" + if(g_ActiveConfig.backend_info.bSupportsGLSLBinding) + { + const char *FProgram = + "#version 330 compatibility\n" + "#extension GL_ARB_texture_rectangle : enable\n" + "#extension GL_ARB_shading_language_420pack : enable\n" + "layout(binding = 0) uniform sampler2DRect samp0;\n" + "void main()\n" + "{\n" + " vec4 c0 = texture2DRect(samp0, gl_TexCoord[0].xy).rgba;\n" - " float f = step(0.5, fract(gl_TexCoord[0].x));\n" - " float y = mix(c0.b, c0.r, f);\n" - " float yComp = 1.164f * (y - 0.0625f);\n" - " float uComp = c0.g - 0.5f;\n" - " float vComp = c0.a - 0.5f;\n" + " float f = step(0.5, fract(gl_TexCoord[0].x));\n" + " float y = mix(c0.b, c0.r, f);\n" + " float yComp = 1.164f * (y - 0.0625f);\n" + " float uComp = c0.g - 0.5f;\n" + " float vComp = c0.a - 0.5f;\n" - " gl_FragData[0] = vec4(yComp + (1.596f * vComp),\n" - " yComp - (0.813f * vComp) - (0.391f * uComp),\n" - " yComp + (2.018f * uComp),\n" - " 1.0f);\n" - "}\n"; - if (!PixelShaderCache::CompilePixelShader(s_yuyvToRgbProgram, FProgram)) - ERROR_LOG(VIDEO, "Failed to create YUYV to RGB fragment program."); + " gl_FragData[0] = vec4(yComp + (1.596f * vComp),\n" + " yComp - (0.813f * vComp) - (0.391f * uComp),\n" + " yComp + (2.018f * uComp),\n" + " 1.0f);\n" + "}\n"; + if (!PixelShaderCache::CompilePixelShader(s_yuyvToRgbProgram, FProgram)) + ERROR_LOG(VIDEO, "Failed to create YUYV to RGB fragment program."); + } + else + { + const char *FProgram = + "#version 120\n" + "#ifdef GL_ARB_texture_rectangle\n" + "#extension GL_ARB_texture_rectangle : require\n" + "#endif\n" + "uniform sampler2DRect samp0;\n" + "void main()\n" + "{\n" + " vec4 c0 = texture2DRect(samp0, gl_TexCoord[0].xy).rgba;\n" + + " float f = step(0.5, fract(gl_TexCoord[0].x));\n" + " float y = mix(c0.b, c0.r, f);\n" + " float yComp = 1.164f * (y - 0.0625f);\n" + " float uComp = c0.g - 0.5f;\n" + " float vComp = c0.a - 0.5f;\n" + + " gl_FragData[0] = vec4(yComp + (1.596f * vComp),\n" + " yComp - (0.813f * vComp) - (0.391f * uComp),\n" + " yComp + (2.018f * uComp),\n" + " 1.0f);\n" + "}\n"; + if (!PixelShaderCache::CompilePixelShader(s_yuyvToRgbProgram, FProgram)) + ERROR_LOG(VIDEO, "Failed to create YUYV to RGB fragment program."); + } } else { diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp index e22a2f3be2..0550e99b18 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp @@ -240,6 +240,7 @@ void SetVSConstant4fvByName(const char * name, unsigned int offset, const float } } } +#define MAX_UNIFORM 0 void SetGLSLVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) { float buf[4]; @@ -249,7 +250,8 @@ void SetGLSLVSConstant4f(unsigned int const_number, float f1, float f2, float f3 buf[3] = f4; if (g_ActiveConfig.backend_info.bSupportsGLSLUBO) { - ProgramShaderCache::SetUniformObjects(1, const_number, buf); + if(const_number < MAX_UNIFORM) + ProgramShaderCache::SetUniformObjects(1, const_number, buf); //return; } for( unsigned int a = 0; a < 9; ++a) @@ -267,6 +269,7 @@ void SetGLSLVSConstant4fv(unsigned int const_number, const float *f) { if (g_ActiveConfig.backend_info.bSupportsGLSLUBO) { + if(const_number < MAX_UNIFORM) ProgramShaderCache::SetUniformObjects(1, const_number, f); //return; } @@ -285,6 +288,7 @@ void SetMultiGLSLVSConstant4fv(unsigned int const_number, unsigned int count, co { if (g_ActiveConfig.backend_info.bSupportsGLSLUBO) { + if(const_number < MAX_UNIFORM) ProgramShaderCache::SetUniformObjects(1, const_number, f, count); //return; } @@ -311,6 +315,7 @@ void SetMultiGLSLVSConstant3fv(unsigned int const_number, unsigned int count, co } if (g_ActiveConfig.backend_info.bSupportsGLSLUBO) { + if(const_number < MAX_UNIFORM) ProgramShaderCache::SetUniformObjects(1, const_number, buf, count); //return; }