Hi Gerrit,
I'm trying to find a problem with the hardware vertex skinning stuff I'm
working on. I have a HardwareSkinningAlgorithm container that holds a
program and a variables chunk, that are created when rendering for the
first time.
Switching to hardware mode for the second time (which creates a new algo
object) the gl ids returned by glCreateProgram() are the same ones than
the first time around, which I think leads the shader cache to return
cached ShaderExeVarChunk objects instead of creating new ones.
I could use some hints on how the ShaderProgramVariablesChunk (and its
backend rep ShaderExeVarChunk) and the ShaderCache interact:
- the attached patch fixes a small oversight where we activate a program
without updating the draw env. This can result in the SEVarChunk to look
up uniforms in the wrong program.
- looking at the bugle trace of the program when it switches to hardware
mode for the second time I see the following sequence:
glCreateProgram() = 6
glAttachShader(6, 2);
glAttachShader(6, 5);
glAttachShader(6, 4);
glLinkProgram(6);
// error checks
glUseProgram(6);
glUniformMatrix(...);
note the missing getUniformLocation() calls, even though the program was
relinked and locations became invalid.
- part of the problem seems to be that the cache does not add a
destroyed functor to SPVarChunk, so when it dies the entries in the
cache are not evicted. Defining OSG_SHC_REF_CLEANUP helps a bit, but
produces many warnings from Window::validateGLObject:
WARNING: Window::validateGLObject: obj with id XXX is NULL! or
WARNING: Window::validateGLObject: id is 0!
Do you have any info on the status of the code, e.g. what would be the
preferred values for the three defines at the top of OSGShaderCache.h
(OSG_SHC_USE_REF, OSG_SHC_REF_CLEANUP, OSG_ASSERT_TREE)?
I'm not sure I understand how one SEVarChunk can reliably be used with
more than one SEChunk, since the uniform locations seem to be stored in
the former, but can be different for different SEChunks?
In case you want to take a look I'll put the code I currently have into
github and send you an example file offline.
Cheers,
Carsten
diff --git a/Source/System/State/Shader/Chunks/OSGShaderExecutableChunk.cpp b/Source/System/State/Shader/Chunks/OSGShaderExecutableChunk.cpp
index 3a559eb..2cd1856 100644
--- a/Source/System/State/Shader/Chunks/OSGShaderExecutableChunk.cpp
+++ b/Source/System/State/Shader/Chunks/OSGShaderExecutableChunk.cpp
@@ -353,13 +353,15 @@ UInt32 ShaderExecutableChunk::handleGL(DrawEnv *pEnv,
updateParameters(pEnv, uiProgram);
- osgGlUseProgram(uiProgram);
+ pEnv->setActiveShader(uiProgram);
+ osgGlUseProgram (uiProgram);
updateVariables(pEnv, uiProgram);
if(0x0000 == (uiOptions & KeepProgActive))
{
- osgGlUseProgram(0);
+ pEnv->setActiveShader(0);
+ osgGlUseProgram (0);
}
else
{
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
Opensg-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-core