Re: [osg-users] EXTERNAL: Re: Draw Elements Instanced Shader Help

2011-10-26 Thread Pecoraro, Alexander N
Seems other people have had the same issue as me:

http://forum.openscenegraph.org/viewtopic.php?t=7287

Are there any plans to address the issue in an upcoming release?

Alex

From: Pecoraro, Alexander N
Sent: Wednesday, October 26, 2011 2:17 PM
To: OpenSceneGraph Users
Subject: RE: EXTERNAL: Re: [osg-users] Draw Elements Instanced Shader Help

I think I figured it out. When it links my program for some reason it uses the 
names InstancePositions[0] and InstanceScales[0] when it builds its 
_uniformInfoMap in the function linkeProgram().  It obtains the names of the 
uniforms that my program uses via glGetActiveUniform() (see snippet from 
Program.cpp below):

Program::PerContextProgram::linkProgram(osg::State state)
{
...
for( GLint i = 0; i  numUniforms; ++i )
{

_extensions-glGetActiveUniform( _glProgramHandle,
i, maxLen, 0, size, type, name );

GLint loc = _extensions-glGetUniformLocation( _glProgramHandle, 
name );

if( loc != -1 )
{
_uniformInfoMap[Uniform::getNameID(reinterpret_castconst 
char*(name))] = ActiveVarInfo(loc,type,size);

OSG_INFO  \tUniform \  name  \
  loc= loc
  size= size
  type=  Uniform::getTypename((Uniform::Type)type)
 std::endl;
}
}
...
}

The value of name that is returned is InstancePositions[0] and 
InstanceScales[0] - instead of just InstancePositions and InstanceScales 
(without the square brackets) in my scene graph's StateSet. So when it comes 
time to apply the uniforms it can't find a mapping from my StateSet's Uniform 
to the Program's list of uniforms because the names differ.

Is that normal behavior for glActiveUniform to return array names with square 
brackets appended?

Alex


From: osg-users-boun...@lists.openscenegraph.org 
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Paul Martz
Sent: Wednesday, October 26, 2011 1:55 PM
To: OpenSceneGraph Users
Subject: EXTERNAL: Re: [osg-users] Draw Elements Instanced Shader Help

On 10/26/2011 12:49 PM, Pecoraro, Alexander N wrote:
Any idea what I'm doing wrong?

Have you tried looking at the osgdrawinstanced example to see how your code 
differs from functioning code?

--

  -Paul Martz  Skew Matrix Software

   http://www.skew-matrix.com/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] EXTERNAL: Re: Draw Elements Instanced Shader Help

2011-10-26 Thread Pecoraro, Alexander N
I think I figured it out. When it links my program for some reason it uses the 
names InstancePositions[0] and InstanceScales[0] when it builds its 
_uniformInfoMap in the function linkeProgram().  It obtains the names of the 
uniforms that my program uses via glGetActiveUniform() (see snippet from 
Program.cpp below):

Program::PerContextProgram::linkProgram(osg::State state)
{
...
for( GLint i = 0; i  numUniforms; ++i )
{

_extensions-glGetActiveUniform( _glProgramHandle,
i, maxLen, 0, size, type, name );

GLint loc = _extensions-glGetUniformLocation( _glProgramHandle, 
name );

if( loc != -1 )
{
_uniformInfoMap[Uniform::getNameID(reinterpret_castconst 
char*(name))] = ActiveVarInfo(loc,type,size);

OSG_INFO  \tUniform \  name  \
  loc= loc
  size= size
  type=  Uniform::getTypename((Uniform::Type)type)
 std::endl;
}
}
...
}

The value of name that is returned is InstancePositions[0] and 
InstanceScales[0] - instead of just InstancePositions and InstanceScales 
(without the square brackets) in my scene graph's StateSet. So when it comes 
time to apply the uniforms it can't find a mapping from my StateSet's Uniform 
to the Program's list of uniforms because the names differ.

Is that normal behavior for glActiveUniform to return array names with square 
brackets appended?

Alex


From: osg-users-boun...@lists.openscenegraph.org 
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Paul Martz
Sent: Wednesday, October 26, 2011 1:55 PM
To: OpenSceneGraph Users
Subject: EXTERNAL: Re: [osg-users] Draw Elements Instanced Shader Help

On 10/26/2011 12:49 PM, Pecoraro, Alexander N wrote:
Any idea what I'm doing wrong?

Have you tried looking at the osgdrawinstanced example to see how your code 
differs from functioning code?


--

  -Paul Martz  Skew Matrix Software

   http://www.skew-matrix.com/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] EXTERNAL: Re: Draw Elements Instanced Shader Help

2011-10-26 Thread Paul Martz

  
  
On 10/26/2011 3:16 PM, Pecoraro, Alexander N wrote:

  
  
  
  
The
value of name that is returned is InstancePositions[0] and
InstanceScales[0]  instead of just InstancePositions and
InstanceScales (without the square brackets) in my scene
graphs StateSet. So when it comes time to apply the
uniforms it cant find a mapping from my StateSets Uniform
to the Programs list of uniforms because the names differ.


Is that normal behavior for
glActiveUniform to return array names with square brackets
appended?
  


This has been discussed extensively recently, but I don't recall the
resolution. If you can't find any information by searching the
archives, then you might try posting a new thread (as it has nothing
to do with draw instanced).

It might already be fixed on trunk, so if you aren't on trunk,
perhaps you should try that.
 -Paul


  

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] EXTERNAL: Re: Draw Elements Instanced Shader Help

2011-10-26 Thread Jean-Sébastien Guay

Hi Paul and Alexander,


This has been discussed extensively recently, but I don't recall the
resolution. If you can't find any information by searching the archives,
then you might try posting a new thread (as it has nothing to do with
draw instanced).

It might already be fixed on trunk, so if you aren't on trunk, perhaps
you should try that.


It is. See:

http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/trunk/src/osg/Program.cpp?rev=12816

The change was committed shortly after the 3.0.1 release, so the next 
release should contain it. The commit message was:


Added removal of [..] from names returned from glGetActiveUniform 
results to avoid issues with name lookups when the driver add the [..] 
for uniform arrays.


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.dyndns-web.com/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org