[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49351] branches/ge_harmony/source/ gameengine/Rasterizer/RAS_OpenGLRasterizer: Cleaned up some OpenGL state queries in the filter manager by caching bind locations .
Daniel Stokes
kupomail at gmail.com
Sun Jul 29 09:44:10 CEST 2012
Revision: 49351
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49351
Author: kupoman
Date: 2012-07-29 07:44:10 +0000 (Sun, 29 Jul 2012)
Log Message:
-----------
Cleaned up some OpenGL state queries in the filter manager by caching bind locations.
Modified Paths:
--------------
branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OGLFilterManager.cpp
branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OGLFilterManager.h
Modified: branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OGLFilterManager.cpp
===================================================================
--- branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OGLFilterManager.cpp 2012-07-29 07:42:43 UTC (rev 49350)
+++ branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OGLFilterManager.cpp 2012-07-29 07:44:10 UTC (rev 49351)
@@ -182,13 +182,18 @@
void RAS_OGLFilterManager::AnalyseShader(int passindex, vector<STR_String>& propNames)
{
+ GLint bind;
texflag[passindex] = 0;
- if (glGetUniformLocationARB(m_filters[passindex], "bgl_DepthTexture") != -1)
+
+ bind = m_uniforms[passindex]["bgl_DepthTexture"].bind = glGetUniformLocationARB(m_filters[passindex], "bgl_DepthTexture");
+ if (bind != -1)
{
if (GLEW_ARB_depth_texture)
texflag[passindex] |= 0x1;
}
- if (glGetUniformLocationARB(m_filters[passindex], "bgl_LuminanceTexture") != -1)
+
+ bind = m_uniforms[passindex]["bgl_LuminanceTexture"].bind = glGetUniformLocationARB(m_filters[passindex], "bgl_LuminanceTexture");
+ if (bind != -1)
{
texflag[passindex] |= 0x2;
}
@@ -200,6 +205,23 @@
for (i=0; i<objProperties; i++)
if (glGetUniformLocationARB(m_filters[passindex], propNames[i]) != -1)
m_properties[passindex].push_back(propNames[i]);
+ }
+
+ m_uniforms[passindex]["bgl_TextureCoordinateOffset"].bind = glGetUniformLocationARB(m_filters[passindex], "bgl_TextureCoordinateOffset");
+ m_uniforms[passindex]["bgl_RenderedTextureWidth"].bind = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTextureWidth");
+ m_uniforms[passindex]["bgl_RenderedTextureHeight"].bind = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTextureHeight");
+
+ int i, objProperties = m_properties[passindex].size();
+ for (i=0; i<objProperties; i++)
+ m_uniforms[passindex][m_properties[passindex][i]].bind = glGetUniformLocationARB(m_filters[passindex], m_properties[passindex][i]);
+ std::map<STR_String, FilterUniform>::iterator it;
+ for (it = m_uniforms[passindex].begin(); it != m_uniforms[passindex].end(); it++)
+ {
+ STR_String name = it->first;
+ FilterUniform uniform = it->second;
+ if (uniform.type == 0)
+ continue;
+ uniform.bind = glGetUniformLocationARB(m_filters[passindex], name);
}
}
@@ -207,7 +229,7 @@
{
GLint uniformLoc;
glUseProgramObjectARB(m_filters[passindex]);
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTexture");
+ uniformLoc = m_uniforms[passindex]["bgl_RenderedTexture"].bind;
glActiveTextureARB(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texname[0]);
@@ -230,7 +252,7 @@
/* send luminance texture to glsl program if it needs */
if (texflag[passindex] & 0x2) {
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_LuminanceTexture");
+ uniformLoc = m_uniforms[passindex]["bgl_LuminanceTexture"].bind;
glActiveTextureARB(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, texname[2]);
@@ -239,18 +261,20 @@
glUniform1iARB(uniformLoc, 2);
}
}
-
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_TextureCoordinateOffset");
+
+ uniformLoc = m_uniforms[passindex]["bgl_TextureCoordinateOffset"].bind;
if (uniformLoc != -1)
{
glUniform2fvARB(uniformLoc, 9, textureoffsets);
}
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTextureWidth");
+
+ uniformLoc = m_uniforms[passindex]["bgl_RenderedTextureWidth"].bind;
if (uniformLoc != -1)
{
glUniform1fARB(uniformLoc,texturewidth);
}
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTextureHeight");
+
+ uniformLoc = m_uniforms[passindex]["bgl_RenderedTextureHeight"].bind;
if (uniformLoc != -1)
{
glUniform1fARB(uniformLoc,textureheight);
@@ -259,7 +283,7 @@
int i, objProperties = m_properties[passindex].size();
for (i=0; i<objProperties; i++)
{
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], m_properties[passindex][i]);
+ uniformLoc = m_uniforms[passindex][m_properties[passindex][i]].bind;
if (uniformLoc != -1)
{
float value = ((CValue*)m_gameObjects[passindex])->GetPropertyNumber(m_properties[passindex][i], 0.0);
@@ -272,8 +296,9 @@
{
STR_String name = it->first;
FilterUniform uniform = it->second;
-
- uniformLoc = glGetUniformLocationARB(m_filters[passindex], name);
+ if (uniform.type == 0)
+ continue;
+ uniformLoc = uniform.bind;
if (uniformLoc != -1)
{
if (uniform.type == RAS_IRasterizer::RAS_FLOAT)
@@ -466,9 +491,9 @@
if (need_depth) {
glActiveTextureARB(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, texname[1]);
- glCopyTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT, rect.GetLeft(), rect.GetBottom(), rect_width, rect_height, 0);
+ //glCopyTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT, rect.GetLeft(), rect.GetBottom(), rect_width, rect_height, 0);
}
-
+
if (need_luminance) {
glActiveTextureARB(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, texname[2]);
@@ -524,7 +549,7 @@
void RAS_OGLFilterManager::UpdateUniform(int pass, STR_String& name, RAS_IRasterizer::RAS_UNIFORM_TYPE type, void *data)
{
- FilterUniform uni = {name, type, data};
+ FilterUniform uni = {name, -1, type, data};
m_uniforms[pass][name] = uni;
}
Modified: branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OGLFilterManager.h
===================================================================
--- branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OGLFilterManager.h 2012-07-29 07:42:43 UTC (rev 49350)
+++ branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OGLFilterManager.h 2012-07-29 07:44:10 UTC (rev 49351)
@@ -44,6 +44,7 @@
typedef struct {
STR_String name;
+ int bind;
RAS_IRasterizer::RAS_UNIFORM_TYPE type;
void *data;
} FilterUniform;
More information about the Bf-blender-cvs
mailing list