diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.h b/Source/Core/VideoCommon/Src/PixelShaderGen.h index 3228d50b99..1a70a3664b 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.h +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.h @@ -49,16 +49,16 @@ // Annoying sure, can be removed once we get up to GLSL ~1.3 const s_svar PSVar_Loc[] = { {I_COLORS, C_COLORS, 4 }, - {I_KCOLORS, C_KCOLORS, 4 }, - {I_ALPHA, C_ALPHA, 1 }, - {I_TEXDIMS, C_TEXDIMS, 8 }, - {I_ZBIAS , C_ZBIAS, 2 }, - {I_INDTEXSCALE , C_INDTEXSCALE, 2 }, - {I_INDTEXMTX, C_INDTEXMTX, 6 }, - {I_FOG, C_FOG, 3 }, - {I_PLIGHTS, C_PLIGHTS, 40 }, - {I_PMATERIALS, C_PMATERIALS, 4 }, - }; + {I_KCOLORS, C_KCOLORS, 4 }, + {I_ALPHA, C_ALPHA, 1 }, + {I_TEXDIMS, C_TEXDIMS, 8 }, + {I_ZBIAS , C_ZBIAS, 2 }, + {I_INDTEXSCALE , C_INDTEXSCALE, 2 }, + {I_INDTEXMTX, C_INDTEXMTX, 6 }, + {I_FOG, C_FOG, 3 }, + {I_PLIGHTS, C_PLIGHTS, 40 }, + {I_PMATERIALS, C_PMATERIALS, 4 }, + }; // DO NOT make anything in this class virtual. template diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp index 2f21c816b7..2d3b642593 100644 --- a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp @@ -69,7 +69,7 @@ u16 GetEncodedSampleCount(u32 format) const char* WriteRegister(API_TYPE ApiType, const char *prefix, const u32 num) { if(ApiType == API_GLSL) - return ""; // Once we switch to GLSL 1.3 we can do something here + return ""; // Once we switch to GLSL 1.3 we can do something here static char result[64]; sprintf(result, " : register(%s%d)", prefix, num); return result; diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.h b/Source/Core/VideoCommon/Src/VertexShaderGen.h index 5cfb9f801d..afd49c65d4 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderGen.h +++ b/Source/Core/VideoCommon/Src/VertexShaderGen.h @@ -48,15 +48,15 @@ #define C_DEPTHPARAMS (C_POSTTRANSFORMMATRICES + 64) #define C_VENVCONST_END (C_DEPTHPARAMS + 1) const s_svar VSVar_Loc[] = { {I_POSNORMALMATRIX, C_POSNORMALMATRIX, 6 }, - {I_PROJECTION , C_PROJECTION, 4 }, - {I_MATERIALS, C_MATERIALS, 4 }, - {I_LIGHTS, C_LIGHTS, 40 }, - {I_TEXMATRICES, C_TEXMATRICES, 24 }, - {I_TRANSFORMMATRICES , C_TRANSFORMMATRICES, 64 }, - {I_NORMALMATRICES , C_NORMALMATRICES, 32 }, - {I_POSTTRANSFORMMATRICES, C_POSTTRANSFORMMATRICES, 64 }, - {I_DEPTHPARAMS, C_DEPTHPARAMS, 1 }, - }; + {I_PROJECTION , C_PROJECTION, 4 }, + {I_MATERIALS, C_MATERIALS, 4 }, + {I_LIGHTS, C_LIGHTS, 40 }, + {I_TEXMATRICES, C_TEXMATRICES, 24 }, + {I_TRANSFORMMATRICES , C_TRANSFORMMATRICES, 64 }, + {I_NORMALMATRICES , C_NORMALMATRICES, 32 }, + {I_POSTTRANSFORMMATRICES, C_POSTTRANSFORMMATRICES, 64 }, + {I_DEPTHPARAMS, C_DEPTHPARAMS, 1 }, + }; template class _VERTEXSHADERUID { diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp index db41f34024..452ff506c3 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp @@ -496,11 +496,11 @@ void PixelShaderCache::SetPSSampler(const char * name, unsigned int Tex) if (!strcmp(name, UniformNames[a])) { if(tmp.UniformLocations[a] == -1) - return; + return; else { - glUniform1i(tmp.UniformLocations[a], Tex); - return; + glUniform1i(tmp.UniformLocations[a], Tex); + return; } } } @@ -511,11 +511,11 @@ void SetPSConstant4fvByName(const char * name, unsigned int offset, const float if (!strcmp(name, UniformNames[a])) { if(tmp.UniformLocations[a] == -1) - return; + return; else { - glUniform4fv(tmp.UniformLocations[a] + offset, count, f); - return; + glUniform4fv(tmp.UniformLocations[a] + offset, count, f); + return; } } } @@ -601,9 +601,9 @@ bool CompileCGPixelShader(FRAGMENTSHADER& ps, const char* pstrprogram) file.close(); PanicAlert("Failed to compile pixel shader %d!\nThis usually happens when trying to use Dolphin with an outdated GPU or integrated GPU like the Intel GMA series.\n\nIf you're sure this is Dolphin's error anyway, post the contents of %s along with this error message at the forums.\n\nDebug info (%d):\n%s", - num_failures - 1, szTemp, - g_cgfProf, - cgGetLastListing(g_cgcontext)); + num_failures - 1, szTemp, + g_cgfProf, + cgGetLastListing(g_cgcontext)); return false; } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp index 15a5ff42a8..e43dfa9798 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.cpp @@ -27,116 +27,116 @@ namespace OGL std::pair ProgramShaderCache::CurrentShaderProgram; const char *UniformNames[NUM_UNIFORMS] = { - // SAMPLERS - "samp0","samp1","samp2","samp3","samp4","samp5","samp6","samp7", - // PIXEL SHADER UNIFORMS - I_COLORS, - I_KCOLORS, - I_ALPHA, - I_TEXDIMS, - I_ZBIAS , - I_INDTEXSCALE , - I_INDTEXMTX, - I_FOG, - I_PLIGHTS, - I_PMATERIALS, - // VERTEX SHADER UNIFORMS - I_POSNORMALMATRIX, - I_PROJECTION , - I_MATERIALS, - I_LIGHTS, - I_TEXMATRICES, - I_TRANSFORMMATRICES , - I_NORMALMATRICES , - I_POSTTRANSFORMMATRICES, - I_DEPTHPARAMS, - }; + // SAMPLERS + "samp0","samp1","samp2","samp3","samp4","samp5","samp6","samp7", + // PIXEL SHADER UNIFORMS + I_COLORS, + I_KCOLORS, + I_ALPHA, + I_TEXDIMS, + I_ZBIAS , + I_INDTEXSCALE , + I_INDTEXMTX, + I_FOG, + I_PLIGHTS, + I_PMATERIALS, + // VERTEX SHADER UNIFORMS + I_POSNORMALMATRIX, + I_PROJECTION , + I_MATERIALS, + I_LIGHTS, + I_TEXMATRICES, + I_TRANSFORMMATRICES , + I_NORMALMATRICES , + I_POSTTRANSFORMMATRICES, + I_DEPTHPARAMS, + }; void ProgramShaderCache::SetBothShaders(GLuint PS, GLuint VS) { - PROGRAMUID uid; - CurrentFShader = PS; - CurrentVShader = VS; + PROGRAMUID uid; + CurrentFShader = PS; + CurrentVShader = VS; - GetProgramShaderId(&uid, CurrentVShader, CurrentFShader); + GetProgramShaderId(&uid, CurrentVShader, CurrentFShader); - if(uid.uid.id == 0) - { - CurrentProgram = 0; - glUseProgram(0); - return; - } + if(uid.uid.id == 0) + { + CurrentProgram = 0; + glUseProgram(0); + return; + } - // Fragment shaders can survive without Vertex Shaders - // We have a valid fragment shader, let's create our program - std::pair ShaderPair = std::make_pair(uid.uid.psid, uid.uid.vsid); - PCache::iterator iter = pshaders.find(ShaderPair); - if (iter != pshaders.end()) - { - PCacheEntry &entry = iter->second; - glUseProgram(entry.program.glprogid); - CurrentShaderProgram = ShaderPair; - CurrentProgram = entry.program.glprogid; - return; - } - PCacheEntry entry; - entry.program.vsid = CurrentVShader; - entry.program.psid = CurrentFShader; - entry.program.glprogid = glCreateProgram(); + // Fragment shaders can survive without Vertex Shaders + // We have a valid fragment shader, let's create our program + std::pair ShaderPair = std::make_pair(uid.uid.psid, uid.uid.vsid); + PCache::iterator iter = pshaders.find(ShaderPair); + if (iter != pshaders.end()) + { + PCacheEntry &entry = iter->second; + glUseProgram(entry.program.glprogid); + CurrentShaderProgram = ShaderPair; + CurrentProgram = entry.program.glprogid; + return; + } + PCacheEntry entry; + entry.program.vsid = CurrentVShader; + entry.program.psid = CurrentFShader; + entry.program.glprogid = glCreateProgram(); - // Right, the program is created now - // Let's attach everything - if(entry.program.vsid != 0) // attaching zero vertex shader makes it freak out - glAttachShader(entry.program.glprogid, entry.program.vsid); - - glAttachShader(entry.program.glprogid, entry.program.psid); - - glLinkProgram(entry.program.glprogid); - - glUseProgram(entry.program.glprogid); + // Right, the program is created now + // Let's attach everything + if(entry.program.vsid != 0) // attaching zero vertex shader makes it freak out + glAttachShader(entry.program.glprogid, entry.program.vsid); + + glAttachShader(entry.program.glprogid, entry.program.psid); + + glLinkProgram(entry.program.glprogid); + + glUseProgram(entry.program.glprogid); - // Dunno why this is needed when I have the binding - // points statically set in the shader source - // We should only need these two functions when we don't support binding but do support UBO - // Driver Bug? Nvidia GTX 570, 290.xx Driver, Linux x64 - //if(!g_ActiveConfig.backend_info.bSupportsGLSLBinding) - { + // Dunno why this is needed when I have the binding + // points statically set in the shader source + // We should only need these two functions when we don't support binding but do support UBO + // Driver Bug? Nvidia GTX 570, 290.xx Driver, Linux x64 + //if(!g_ActiveConfig.backend_info.bSupportsGLSLBinding) + { glUniformBlockBinding( entry.program.glprogid, 0, 1 ); glUniformBlockBinding( entry.program.glprogid, 1, 2 ); } - // We cache our uniform locations for now - // Once we move up to a newer version of GLSL, ~1.30 - // We can remove this - - //For some reason this fails on my hardware - //glGetUniformIndices(entry.program.glprogid, NUM_UNIFORMS, UniformNames, entry.program.UniformLocations); - //Got to do it this crappy way. - if(!g_ActiveConfig.backend_info.bSupportsGLSLUBO) + // We cache our uniform locations for now + // Once we move up to a newer version of GLSL, ~1.30 + // We can remove this + + //For some reason this fails on my hardware + //glGetUniformIndices(entry.program.glprogid, NUM_UNIFORMS, UniformNames, entry.program.UniformLocations); + //Got to do it this crappy way. + if(!g_ActiveConfig.backend_info.bSupportsGLSLUBO) for(int a = 0; a < NUM_UNIFORMS; ++a) entry.program.UniformLocations[a] = glGetUniformLocation(entry.program.glprogid, UniformNames[a]); - // Need to get some attribute locations - if(uid.uid.vsid != 0) // We have no vertex Shader - { - entry.program.attrLoc[0] = glGetAttribLocation(entry.program.glprogid, "rawnorm1"); - entry.program.attrLoc[1] = glGetAttribLocation(entry.program.glprogid, "rawnorm2"); - entry.program.attrLoc[2] = glGetAttribLocation(entry.program.glprogid, "fposmtx"); - if(entry.program.attrLoc[0] > 0) - glEnableVertexAttribArray(entry.program.attrLoc[0]); - if(entry.program.attrLoc[1] > 0) - glEnableVertexAttribArray(entry.program.attrLoc[1]); - if(entry.program.attrLoc[2] > 0) - glEnableVertexAttribArray(entry.program.attrLoc[2]); - } - else - entry.program.attrLoc[0] = entry.program.attrLoc[1] = entry.program.attrLoc[2] = 0; + // Need to get some attribute locations + if(uid.uid.vsid != 0) // We have no vertex Shader + { + entry.program.attrLoc[0] = glGetAttribLocation(entry.program.glprogid, "rawnorm1"); + entry.program.attrLoc[1] = glGetAttribLocation(entry.program.glprogid, "rawnorm2"); + entry.program.attrLoc[2] = glGetAttribLocation(entry.program.glprogid, "fposmtx"); + if(entry.program.attrLoc[0] > 0) + glEnableVertexAttribArray(entry.program.attrLoc[0]); + if(entry.program.attrLoc[1] > 0) + glEnableVertexAttribArray(entry.program.attrLoc[1]); + if(entry.program.attrLoc[2] > 0) + glEnableVertexAttribArray(entry.program.attrLoc[2]); + } + else + entry.program.attrLoc[0] = entry.program.attrLoc[1] = entry.program.attrLoc[2] = 0; - pshaders[ShaderPair] = entry; - CurrentShaderProgram = ShaderPair; - CurrentProgram = entry.program.glprogid; + pshaders[ShaderPair] = entry; + CurrentShaderProgram = ShaderPair; + CurrentProgram = entry.program.glprogid; } void ProgramShaderCache::SetUniformObjects(int Buffer, unsigned int offset, const float *f, unsigned int count) { @@ -158,11 +158,11 @@ namespace OGL GLint ProgramShaderCache::GetAttr(int num) { - return pshaders[CurrentShaderProgram].program.attrLoc[num]; + return pshaders[CurrentShaderProgram].program.attrLoc[num]; } PROGRAMSHADER ProgramShaderCache::GetShaderProgram(void) { - return pshaders[CurrentShaderProgram].program; + return pshaders[CurrentShaderProgram].program; } void ProgramShaderCache::Init(void) { @@ -190,11 +190,11 @@ namespace OGL } void ProgramShaderCache::Shutdown(void) { - PCache::iterator iter = pshaders.begin(); - for (; iter != pshaders.end(); iter++) - iter->second.Destroy(); - pshaders.clear(); - glDeleteBuffers(2, UBOBuffers); + PCache::iterator iter = pshaders.begin(); + for (; iter != pshaders.end(); iter++) + iter->second.Destroy(); + pshaders.clear(); + glDeleteBuffers(2, UBOBuffers); } } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.h b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.h index 1c114551b8..4c356f52d5 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/ProgramShaderCache.h @@ -27,10 +27,10 @@ union PID { - struct { - GLuint vsid, psid; - }; - u64 id; + struct { + GLuint vsid, psid; + }; + u64 id; }; class PROGRAMUID @@ -41,22 +41,22 @@ public: PROGRAMUID() { - uid.id = 0; + uid.id = 0; } PROGRAMUID(const PROGRAMUID& r) { - uid.id = r.uid.id; + uid.id = r.uid.id; } PROGRAMUID(GLuint _v, GLuint _p) { - uid.vsid = _v; - uid.psid = _p; + uid.vsid = _v; + uid.psid = _p; } int GetNumValues() const { - return uid.id; + return uid.id; } }; void GetProgramShaderId(PROGRAMUID *uid, GLuint _v, GLuint _p); @@ -81,13 +81,13 @@ class ProgramShaderCache { struct PCacheEntry { - PROGRAMSHADER program; - int frameCount; - PCacheEntry() : frameCount(0) {} - void Destroy() { - glDeleteProgram(program.glprogid); - program.glprogid = 0; - } + PROGRAMSHADER program; + int frameCount; + PCacheEntry() : frameCount(0) {} + void Destroy() { + glDeleteProgram(program.glprogid); + program.glprogid = 0; + } }; typedef std::map, PCacheEntry> PCache; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp index ff4ecab624..213d92098a 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp @@ -281,7 +281,7 @@ void Shutdown() } void EncodeToRamUsingShader(GLuint srcTexture, const TargetRectangle& sourceRc, - u8* destAddr, int dstWidth, int dstHeight, int readStride, + u8* destAddr, int dstWidth, int dstHeight, int readStride, bool toTexture, bool linearFilter) { diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index 8b25d5c47c..c7a4c0d42f 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -112,19 +112,19 @@ void GetShaders(std::vector &shaders) shaders.clear(); if (File::IsDirectory(File::GetUserPath(D_SHADERS_IDX))) { - File::FSTEntry entry; - File::ScanDirectoryTree(File::GetUserPath(D_SHADERS_IDX), entry); - for (u32 i = 0; i < entry.children.size(); i++) - { - std::string name = entry.children[i].virtualName.c_str(); - if (!strcasecmp(name.substr(name.size() - 4).c_str(), ".txt")) - name = name.substr(0, name.size() - 4); - shaders.push_back(name); - } + File::FSTEntry entry; + File::ScanDirectoryTree(File::GetUserPath(D_SHADERS_IDX), entry); + for (u32 i = 0; i < entry.children.size(); i++) + { + std::string name = entry.children[i].virtualName.c_str(); + if (!strcasecmp(name.substr(name.size() - 4).c_str(), ".txt")) + name = name.substr(0, name.size() - 4); + shaders.push_back(name); + } } else { - File::CreateDir(File::GetUserPath(D_SHADERS_IDX).c_str()); + File::CreateDir(File::GetUserPath(D_SHADERS_IDX).c_str()); } }