Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: EmitVertex in Subroutines

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2013
    Posts
    7

    Question EmitVertex in Subroutines

    I'm writing a Geometry-Shader where subroutines are used but it seems that a call to EmitVertex in a subroutine seems not to work - I get no visual output. On the opposite when I make the call to EmitVertex from main everything works fine.

    This piece of code works:
    Code :
    subroutine void layerRendering( int vertexIndex );
     
    subroutine ( layerRendering ) void layerRenderingCube( int vertexIndex )
    {
    	gl_Position = Transforms.projectionMatrix * gl_in[ vertexIndex ].gl_Position;
    }
     
    subroutine ( layerRendering ) void layerRenderingPlanar( int vertexIndex )
    {
    	gl_Position = Transforms.projectionMatrix * gl_in[ vertexIndex ].gl_Position;
    }
     
    subroutine uniform layerRendering layerRenderingSelection;
     
     void main()
    {
    	for( int i = 0; i < gl_in.length(); i++ )
    	{
    		layerRenderingSelection( i );
     
    		EmitVertex();
    	}
    }

    This piece of code produces no output:
    Code :
    subroutine void layerRendering( int vertexIndex );
     
    subroutine ( layerRendering ) void layerRenderingCube( int vertexIndex )
    {
    	gl_Position = Transforms.projectionMatrix * gl_in[ vertexIndex ].gl_Position;
     
    	EmitVertex();
    }
     
    subroutine ( layerRendering ) void layerRenderingPlanar( int vertexIndex )
    {
    	gl_Position = Transforms.projectionMatrix * gl_in[ vertexIndex ].gl_Position;
     
    	EmitVertex();
    }
     
    subroutine uniform layerRendering layerRenderingSelection;
     
     void main()
    {
    	for( int i = 0; i < gl_in.length(); i++ )
    	{
    		layerRenderingSelection( i );
    	}
    }

    I've checked with NVidia Nsight, the subroutines gets called in both scenarios, so this shouldn't be the problem. I couldn't find any limits on where to call EmitVertex. Have I ignored something? Is there a hint in the API?

  2. #2
    Junior Member Newbie
    Join Date
    Nov 2013
    Posts
    7
    I was able to remove the subroutines from the geometry-shader but introduced some in the vertex-shader, again the same result. What I am ultimatively try to achieve is to render a shadow cube-map in a single pass.
    After debugging again with NVidia Nsight I noticed that the matrices for each cube-face are always zero-matrices although I upload always correct matrices (proved by a multi-pass version). Of course this will obviously result in the collapsing of the vertex and thus no output. When I don't call the subroutine-uniform but one of the subroutines directly the matrices show up correctly and everything gets correctly rendered to the cube-faces.
    So the error is another one: EmitVertex() is not the problem but it seems that the uniform matrices of the geometry-shader won't get updated in the case of using a subroutine anywhere in the program. The vertex-shader contains a uniform matrix-array for bones but those are initialized correct.

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2013
    Posts
    7
    OK found the problem, it was burried very elsewhere and VERY hard to track...
    I'm using program-introspection to retrieve all uniform-fields in a program and store them in a program-class at load time. Thus no queries are necessary during frame-renderings about the uniforms.
    The problem is that I used the uniform-index for the calls to glUniform* instead of the uniform-location. The strange thing was that the index actually was almost always the location but when I introduced the geometry-shader this seemed to change and thus the glUniform* call didn't send any data anymore.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •