From 126dfa073b70e91aa9482fac1052f71d7be1bcc2 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sat, 10 Dec 2011 01:56:37 -0600 Subject: [PATCH] Firin ma lazer --- .../Core/VideoCommon/Src/PixelShaderGen.cpp | 2 +- .../Core/VideoCommon/Src/VertexShaderGen.cpp | 2 +- .../Src/ProgramShaderCache.cpp | 22 ++++++++++++++----- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index e88a8ca11f..2a5ab11ee6 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -611,7 +611,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 = 0) uniform PSBlock {\n"); + WRITE(p, "layout(std140, binding = 4) 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 c04a2ba1f1..caefa15bc4 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp @@ -217,7 +217,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE ApiType) // uniforms if(ApiType == API_GLSL && g_ActiveConfig.backend_info.bSupportsGLSLUBO) - WRITE(p, "layout(std140, binding = 1) uniform VSBlock {\n"); + WRITE(p, "layout(std140, binding = 5) 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)); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp index 9fd3479e1d..b2bb6b6351 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp @@ -94,7 +94,15 @@ namespace OGL glLinkProgram(entry.program.glprogid); glUseProgram(entry.program.glprogid); - + + GLint Info = -1; + GLuint Indice = 1; + //glGetIntegeri_v(GL_UNIFORM_BLOCK_DATA_SIZE, 4, &Info); + //glGetIntegerv(GL_UNIFORM_BLOCK_DATA_SIZE, &Info); + glGetActiveUniformsiv(entry.program.glprogid, 1, &Indice, + GL_UNIFORM_SIZE, &Info); + printf("Minimum size: %d\n", Info); + // We cache our uniform locations for now // Once we move up to a newer version of GLSL, ~1.30 // We can remove this @@ -132,7 +140,8 @@ namespace OGL glBindBuffer(GL_UNIFORM_BUFFER, UBOBuffers[Buffer]); // 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, (void*)&f[0]); + glBufferSubData(GL_UNIFORM_BUFFER_EXT, offset * 4 * 4, count * 4 * 4, f); + glBindBuffer(GL_UNIFORM_BUFFER, 0); } GLuint ProgramShaderCache::GetCurrentProgram(void) { return CurrentProgram; } @@ -151,14 +160,15 @@ namespace OGL // 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, C_PENVCONST_END * 4 * 4, NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_UNIFORM_BUFFER, 1024 *1024 *1024, 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, 0, UBOBuffers[0]); + glBindBufferRange(GL_UNIFORM_BUFFER, 4, UBOBuffers[0], 0, (C_PENVCONST_END * 4 * 4) - (C_PENVCONST_END * 4 * 4 % 256) + 256); // Repeat for VS shader glBindBuffer(GL_UNIFORM_BUFFER, UBOBuffers[1]); - glBufferData(GL_UNIFORM_BUFFER, C_VENVCONST_END * 4 * 4, NULL, GL_DYNAMIC_DRAW); - glBindBufferBase(GL_UNIFORM_BUFFER, 1, UBOBuffers[1]); + glBufferData(GL_UNIFORM_BUFFER, 1024*1024*1024, NULL, GL_DYNAMIC_DRAW); + glBindBufferRange(GL_UNIFORM_BUFFER, 5, UBOBuffers[1], 0, (C_VENVCONST_END * 4 * 4) - (C_VENVCONST_END * 4 * 4 % 256) + 256); + glBindBuffer(GL_UNIFORM_BUFFER, 0); } void ProgramShaderCache::Shutdown(void) {