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.

This commit is contained in:
Ryan Houdek 2011-12-10 07:38:30 -06:00 committed by Sonicadvance1
parent 904adb9e3d
commit 1f75ee49bf
9 changed files with 176 additions and 88 deletions

View File

@ -511,11 +511,11 @@ static void BuildSwapModeTable()
const char* WriteRegister(API_TYPE ApiType, const char *prefix, const u32 num) const char* WriteRegister(API_TYPE ApiType, const char *prefix, const u32 num)
{ {
if(ApiType == API_GLSL) if(ApiType == API_GLSL)
return ""; // Nothing to do here return ""; // Nothing to do here
static char result[64]; static char result[64];
sprintf(result, " : register(%s%d)", prefix, num); sprintf(result, " : register(%s%d)", prefix, num);
return result; return result;
} }
const char* WriteBinding(API_TYPE ApiType, const u32 num) 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) const char *WriteLocation(API_TYPE ApiType)
{ {
static char result[64];
if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO) if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
return ""; return "";
static char result[64];
sprintf(result, "uniform "); sprintf(result, "uniform ");
return result; return result;
} }
@ -620,7 +620,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
WRITE(p, "\n"); WRITE(p, "\n");
if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO) 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_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)); WRITE(p, "%sfloat4 "I_KCOLORS"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_KCOLORS));

View File

@ -28,8 +28,8 @@
#define I_INDTEXSCALE "cindscale" #define I_INDTEXSCALE "cindscale"
#define I_INDTEXMTX "cindmtx" #define I_INDTEXMTX "cindmtx"
#define I_FOG "cfog" #define I_FOG "cfog"
#define I_PLIGHTS "cLights" #define I_PLIGHTS "cPLights"
#define I_PMATERIALS "cmtrl" #define I_PMATERIALS "cPmtrl"
#define C_COLORMATRIX 0 // 0 #define C_COLORMATRIX 0 // 0
#define C_COLORS 0 // 0 #define C_COLORS 0 // 0

View File

@ -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* WriteRegister(API_TYPE ApiType, const char *prefix, const u32 num);
extern const char* WriteBinding(API_TYPE ApiType, const u32 num); extern const char* WriteBinding(API_TYPE ApiType, const u32 num);
const char *WriteLocation(API_TYPE ApiType); 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) const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
{ {
@ -216,21 +222,22 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType)
} }
// uniforms // uniforms
if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO) //if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
WRITE(p, "layout(std140, binding = 5) uniform VSBlock {\n"); //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_POSNORMALMATRIX"[6] %s;\n", WriteLocation2(ApiType), WriteRegister(ApiType, "c", C_POSNORMALMATRIX));
WRITE(p, "%sfloat4 "I_PROJECTION"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_PROJECTION)); //if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO)
WRITE(p, "%sfloat4 "I_MATERIALS"[4] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_MATERIALS)); //WRITE(p, "};\n");
WRITE(p, "%sfloat4 "I_LIGHTS"[40] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_LIGHTS)); WRITE(p, "%sfloat4 "I_PROJECTION"[4] %s;\n", WriteLocation2(ApiType), WriteRegister(ApiType, "c", C_PROJECTION));
WRITE(p, "%sfloat4 "I_TEXMATRICES"[24] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_TEXMATRICES)); // also using tex matrices WRITE(p, "%sfloat4 "I_MATERIALS"[4] %s;\n", WriteLocation2(ApiType), WriteRegister(ApiType, "c", C_MATERIALS));
WRITE(p, "%sfloat4 "I_TRANSFORMMATRICES"[64] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_TRANSFORMMATRICES)); WRITE(p, "%sfloat4 "I_LIGHTS"[40] %s;\n", WriteLocation2(ApiType), WriteRegister(ApiType, "c", C_LIGHTS));
WRITE(p, "%sfloat4 "I_NORMALMATRICES"[32] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_NORMALMATRICES)); WRITE(p, "%sfloat4 "I_TEXMATRICES"[24] %s;\n", WriteLocation2(ApiType), WriteRegister(ApiType, "c", C_TEXMATRICES)); // also using tex matrices
WRITE(p, "%sfloat4 "I_POSTTRANSFORMMATRICES"[64] %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_POSTTRANSFORMMATRICES)); WRITE(p, "%sfloat4 "I_TRANSFORMMATRICES"[64] %s;\n", WriteLocation2(ApiType), WriteRegister(ApiType, "c", C_TRANSFORMMATRICES));
WRITE(p, "%sfloat4 "I_DEPTHPARAMS" %s;\n", WriteLocation(ApiType), WriteRegister(ApiType, "c", C_DEPTHPARAMS)); 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); p = GenerateVSOutputStruct(p, components, ApiType);

View File

@ -55,7 +55,7 @@ const s_svar VSVar_Loc[] = { {I_POSNORMALMATRIX, C_POSNORMALMATRIX, 6 },
{I_TRANSFORMMATRICES , C_TRANSFORMMATRICES, 64 }, {I_TRANSFORMMATRICES , C_TRANSFORMMATRICES, 64 },
{I_NORMALMATRICES , C_NORMALMATRICES, 32 }, {I_NORMALMATRICES , C_NORMALMATRICES, 32 },
{I_POSTTRANSFORMMATRICES, C_POSTTRANSFORMMATRICES, 64 }, {I_POSTTRANSFORMMATRICES, C_POSTTRANSFORMMATRICES, 64 },
{I_DEPTHPARAMS, C_DEPTHPARAMS, 4 }, {I_DEPTHPARAMS, C_DEPTHPARAMS, 1 },
}; };
template<bool safe> template<bool safe>
class _VERTEXSHADERUID class _VERTEXSHADERUID

View File

@ -184,7 +184,7 @@ void VertexShaderManager::Dirty()
// TODO: A cleaner way to control the matricies without making a mess in the parameters field // TODO: A cleaner way to control the matricies without making a mess in the parameters field
void VertexShaderManager::SetConstants() void VertexShaderManager::SetConstants()
{ {
if (g_ActiveConfig.bUseGLSL && !g_ActiveConfig.backend_info.bSupportsGLSLUBO) //if (g_ActiveConfig.bUseGLSL && !g_ActiveConfig.backend_info.bSupportsGLSLUBO)
Dirty(); Dirty();
if (nTransformMatricesChanged[0] >= 0) if (nTransformMatricesChanged[0] >= 0)
{ {

View File

@ -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) void SetGLSLPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{ {
float f[4] = { f1, f2, f3, f4 }; float f[4] = { f1, f2, f3, f4 };
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO) if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
{ {
ProgramShaderCache::SetUniformObjects(0, const_number, f); ProgramShaderCache::SetUniformObjects(0, const_number, f);
//return; //return;
} }
for (unsigned int a = 0; a < 10; ++a) 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) if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
{ {
ProgramShaderCache::SetUniformObjects(0, const_number, f); ProgramShaderCache::SetUniformObjects(0, const_number, f);
//return; //return;
} }
for (unsigned int a = 0; a < 10; ++a) 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) if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
{ {
ProgramShaderCache::SetUniformObjects(0, const_number, f, count); ProgramShaderCache::SetUniformObjects(0, const_number, f, count);
//return; //return;
} }
for (unsigned int a = 0; a < 10; ++a) for (unsigned int a = 0; a < 10; ++a)
{ {

View File

@ -17,12 +17,15 @@
#include "ProgramShaderCache.h" #include "ProgramShaderCache.h"
#include <assert.h> #include <assert.h>
static GLenum checkForGLError(const char * situation) GLuint GLERR(const char *function)
{ {
GLenum error = glGetError(); GLint err = glGetError();
if (error != GL_NO_ERROR) if (err != GL_NO_ERROR)
printf("Error: %d -- %s\n", error, situation); {
return error; printf( "(%s) OpenGL error 0x%x - %s\n",
function, err, gluErrorString(err));
}
return err;
} }
namespace OGL namespace OGL
{ {
@ -98,10 +101,19 @@ namespace OGL
glAttachShader(entry.program.glprogid, entry.program.psid); glAttachShader(entry.program.glprogid, entry.program.psid);
glLinkProgram(entry.program.glprogid); 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); glUseProgram(entry.program.glprogid);
checkForGLError("User");
// We cache our uniform locations for now // We cache our uniform locations for now
// Once we move up to a newer version of GLSL, ~1.30 // 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) void ProgramShaderCache::SetUniformObjects(int Buffer, unsigned int offset, const float *f, unsigned int count)
{ {
GLERR("");
assert(Buffer > 1); 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 // 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 // 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); glBufferSubData(GL_UNIFORM_BUFFER, offset * 4 * 4, count * 4 * 4, f);
glBindBuffer(GL_UNIFORM_BUFFER, 0); GLERR("sub");
} }
GLuint ProgramShaderCache::GetCurrentProgram(void) { return CurrentProgram; } GLuint ProgramShaderCache::GetCurrentProgram(void) { return CurrentProgram; }
@ -156,20 +178,22 @@ namespace OGL
void ProgramShaderCache::Init(void) void ProgramShaderCache::Init(void)
{ {
glGenBuffers(2, UBOBuffers); glGenBuffers(2, UBOBuffers);
glBindBuffer(GL_UNIFORM_BUFFER, UBOBuffers[0]); glBindBuffer(GL_UNIFORM_BUFFER, UBOBuffers[0]);
// We multiply by *4*4 because we need to get down to basic machine units. // 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 // So multiply by four to get how many floats we have from vec4s
// Then once more to get bytes // 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 // Now bind the buffer to the index point
// We know PS is 0 since we have it statically set in the shader // 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 // Repeat for VS shader
glBindBuffer(GL_UNIFORM_BUFFER, UBOBuffers[1]); //glBindBuffer(GL_UNIFORM_BUFFER, UBOBuffers[1]);
glBufferData(GL_UNIFORM_BUFFER, 1024*1024, NULL, GL_DYNAMIC_DRAW); //glBufferData(GL_UNIFORM_BUFFER, C_PENVCONST_END * 4 * 4, NULL, GL_DYNAMIC_DRAW);
glBindBufferBase(GL_UNIFORM_BUFFER, 5, UBOBuffers[1]); //glBindBufferBase(GL_UNIFORM_BUFFER, 2, UBOBuffers[1]);
glBindBuffer(GL_UNIFORM_BUFFER, 0); GLERR("init");
checkForGLError("Init");
} }
void ProgramShaderCache::Shutdown(void) void ProgramShaderCache::Shutdown(void)
{ {

View File

@ -63,26 +63,49 @@ void CreateRgbToYuyvProgram()
// Output is BGRA because that is slightly faster than RGBA. // Output is BGRA because that is slightly faster than RGBA.
if(g_ActiveConfig.bUseGLSL) if(g_ActiveConfig.bUseGLSL)
{ {
const char *FProgram = if(g_ActiveConfig.backend_info.bSupportsGLSLBinding)
"#version 120\n" {
"#ifdef GL_ARB_texture_rectangle\n" const char *FProgram =
"#extension GL_ARB_texture_rectangle : require\n" "#version 330 compatibility\n"
"#endif\n" "#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect samp0;\n" "#extension GL_ARB_shading_language_420pack : enable\n"
"void main()\n" "layout(binding = 0) uniform sampler2DRect samp0;\n"
"{\n" "void main()\n"
" vec2 uv1 = vec2(gl_TexCoord[0].x + 1.0f, gl_TexCoord[0].y);\n" "{\n"
" vec3 c0 = texture2DRect(samp0, gl_TexCoord[0].xy).rgb;\n" " vec2 uv1 = vec2(gl_TexCoord[0].x + 1.0f, gl_TexCoord[0].y);\n"
" vec3 c1 = texture2DRect(samp0, uv1).rgb;\n" " vec3 c0 = texture2DRect(samp0, gl_TexCoord[0].xy).rgb;\n"
" vec3 y_const = vec3(0.257f,0.504f,0.098f);\n" " vec3 c1 = texture2DRect(samp0, uv1).rgb;\n"
" vec3 u_const = vec3(-0.148f,-0.291f,0.439f);\n" " vec3 y_const = vec3(0.257f,0.504f,0.098f);\n"
" vec3 v_const = vec3(0.439f,-0.368f,-0.071f);\n" " vec3 u_const = vec3(-0.148f,-0.291f,0.439f);\n"
" vec4 const3 = vec4(0.0625f,0.5f,0.0625f,0.5f);\n" " vec3 v_const = vec3(0.439f,-0.368f,-0.071f);\n"
" vec3 c01 = (c0 + c1) * 0.5f;\n" " vec4 const3 = vec4(0.0625f,0.5f,0.0625f,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" " vec3 c01 = (c0 + c1) * 0.5f;\n"
"}\n"; " gl_FragData[0] = vec4(dot(c1,y_const),dot(c01,u_const),dot(c0,y_const),dot(c01, v_const)) + const3;\n"
if (!PixelShaderCache::CompilePixelShader(s_rgbToYuyvProgram, FProgram)) "}\n";
ERROR_LOG(VIDEO, "Failed to create RGB to YUYV fragment program."); 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 else
{ {
@ -111,29 +134,57 @@ void CreateYuyvToRgbProgram()
{ {
if(g_ActiveConfig.bUseGLSL) if(g_ActiveConfig.bUseGLSL)
{ {
const char *FProgram = if(g_ActiveConfig.backend_info.bSupportsGLSLBinding)
"#version 120\n" {
"#ifdef GL_ARB_texture_rectangle\n" const char *FProgram =
"#extension GL_ARB_texture_rectangle : require\n" "#version 330 compatibility\n"
"#endif\n" "#extension GL_ARB_texture_rectangle : enable\n"
"uniform sampler2DRect samp0;\n" "#extension GL_ARB_shading_language_420pack : enable\n"
"void main()\n" "layout(binding = 0) uniform sampler2DRect samp0;\n"
"{\n" "void main()\n"
" vec4 c0 = texture2DRect(samp0, gl_TexCoord[0].xy).rgba;\n" "{\n"
" vec4 c0 = texture2DRect(samp0, gl_TexCoord[0].xy).rgba;\n"
" float f = step(0.5, fract(gl_TexCoord[0].x));\n" " float f = step(0.5, fract(gl_TexCoord[0].x));\n"
" float y = mix(c0.b, c0.r, f);\n" " float y = mix(c0.b, c0.r, f);\n"
" float yComp = 1.164f * (y - 0.0625f);\n" " float yComp = 1.164f * (y - 0.0625f);\n"
" float uComp = c0.g - 0.5f;\n" " float uComp = c0.g - 0.5f;\n"
" float vComp = c0.a - 0.5f;\n" " float vComp = c0.a - 0.5f;\n"
" gl_FragData[0] = vec4(yComp + (1.596f * vComp),\n" " gl_FragData[0] = vec4(yComp + (1.596f * vComp),\n"
" yComp - (0.813f * vComp) - (0.391f * uComp),\n" " yComp - (0.813f * vComp) - (0.391f * uComp),\n"
" yComp + (2.018f * uComp),\n" " yComp + (2.018f * uComp),\n"
" 1.0f);\n" " 1.0f);\n"
"}\n"; "}\n";
if (!PixelShaderCache::CompilePixelShader(s_yuyvToRgbProgram, FProgram)) if (!PixelShaderCache::CompilePixelShader(s_yuyvToRgbProgram, FProgram))
ERROR_LOG(VIDEO, "Failed to create YUYV to RGB fragment program."); 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 else
{ {

View File

@ -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) void SetGLSLVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4)
{ {
float buf[4]; float buf[4];
@ -249,7 +250,8 @@ void SetGLSLVSConstant4f(unsigned int const_number, float f1, float f2, float f3
buf[3] = f4; buf[3] = f4;
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO) if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
{ {
ProgramShaderCache::SetUniformObjects(1, const_number, buf); if(const_number < MAX_UNIFORM)
ProgramShaderCache::SetUniformObjects(1, const_number, buf);
//return; //return;
} }
for( unsigned int a = 0; a < 9; ++a) 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 (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
{ {
if(const_number < MAX_UNIFORM)
ProgramShaderCache::SetUniformObjects(1, const_number, f); ProgramShaderCache::SetUniformObjects(1, const_number, f);
//return; //return;
} }
@ -285,6 +288,7 @@ void SetMultiGLSLVSConstant4fv(unsigned int const_number, unsigned int count, co
{ {
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO) if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
{ {
if(const_number < MAX_UNIFORM)
ProgramShaderCache::SetUniformObjects(1, const_number, f, count); ProgramShaderCache::SetUniformObjects(1, const_number, f, count);
//return; //return;
} }
@ -311,6 +315,7 @@ void SetMultiGLSLVSConstant3fv(unsigned int const_number, unsigned int count, co
} }
if (g_ActiveConfig.backend_info.bSupportsGLSLUBO) if (g_ActiveConfig.backend_info.bSupportsGLSLUBO)
{ {
if(const_number < MAX_UNIFORM)
ProgramShaderCache::SetUniformObjects(1, const_number, buf, count); ProgramShaderCache::SetUniformObjects(1, const_number, buf, count);
//return; //return;
} }