[Mesa-dev] [Bug 85419] New: Assertion fail with triangle strips

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Fri Oct 24 13:27:05 PDT 2014


https://bugs.freedesktop.org/show_bug.cgi?id=85419

            Bug ID: 85419
           Summary: Assertion fail with triangle strips
           Product: Mesa
           Version: unspecified
          Hardware: x86 (IA32)
                OS: Linux (All)
            Status: NEW
          Severity: normal
          Priority: medium
         Component: Other
          Assignee: mesa-dev at lists.freedesktop.org
          Reporter: jrevans1 at earthlink.net

When using Mesa 10.3.0 and 10.3.1 I get an assertion fail in
'src/gallium/drivers/llvmpipe/lp_setup_tri.c:495'

I am rendering a sphere in software mode (great for debugging, with
MESA_DEBUG=1) using Gallium 0.4 on llvmpipe (LLVM 3.4) and 3.3 Core Profile.

Following is the code I am using to generate and render my sphere:

// m_numLon = 36;
// m_numLat = 18;
// m_radius = 0.5;

const unsigned int RESTART_INDEX = 0xFFFF;

glPrimitiveRestartIndex( RESTART_INDEX );

float deltaLon = TWOPI / m_numLon;
float deltaLat = PI / m_numLat;
float lonTexCoord, latTexCoord;
float r, x, y, z;
GlVec3 vertex, normal;

// The North-Pole
vertex = GlVec3( 0.0, 0.0, m_radius );
normal = vertex.normalized();

lonTexCoord = 0.0;
latTexCoord = 0.0;

m_vertices << vertex << normal << GlVec2( lonTexCoord, latTexCoord );
numVerts++;

// The sphere is composed of numLon triangle strips
for ( unsigned int lonNum = 0; lonNum < m_numLon; lonNum++ )
{
   for ( unsigned int latNum = 1; latNum < m_numLat; latNum++ )
   {
      lonTexCoord = ((float) lonNum) / ((float) m_numLon);
      latTexCoord = ((float) latNum) / ((float) m_numLat);

      r = m_radius * ::sin( latNum * deltaLat );
      z = m_radius * ::cos( latNum * deltaLat );
      y = r * ::sin( lonNum * deltaLon );
      x = r * ::cos( lonNum * deltaLon );
      vertex = GlVec3( x, y, z );
      normal = vertex.normalized();

      m_vertices << vertex << normal << GlVec2( lonTexCoord, latTexCoord );
      numVerts++;
   }
}

// The South-Pole
vertex = GlVec3( 0.0, 0.0, -m_radius );
normal = vertex.normalized();
lonTexCoord = 1.0;
latTexCoord = 1.0;

m_vertices << vertex << normal << GlVec2( lonTexCoord, latTexCoord );
numVerts++;


// generate the indices
for ( unsigned int lonNum = 0; lonNum < m_numLon; lonNum++ )
{
   // index to the north pole
   m_indices << 0;
   for ( unsigned int latNum = 1; latNum < m_numLat; latNum++ )
   {
      m_indices << latNum + lonNum*(m_numLat-1);
      m_indices << latNum + ((lonNum+1) % m_numLon)*(m_numLat-1);
   }

   // index to the south pole
   m_indices << numVerts - 1;

   // signal the renderer that we are done with this primitive and it
   // needs to start a new triangle strip.
   m_indices << RESTART_INDEX;
}

// load vertex data
vbo.bind();
glBufferData( vbo, numVerts*sizeof(float), m_vertices.data(), GL_STATIC_DRAW );

// load index data
ibo.bind();
glBufferData(ibo, m_indices.count()*sizeof(unsigned int), m_indices.data(),
GL_STATIC_DRAW);



// render the data
...
vao.bind();
vbo.bind();
int offset = 0;
glVertexAttribPointer( vLoc, 3, GL_FLOAT, GL_TRUE, 8*sizeof(float),
reinterpret_cast<const void* >(offset) );
glEnableVertexAttribArray( vLoc );
glDrawElements( GL_TRIANGLE_STRIP, 0, numVerts );



Using the same vertices and different index ordering I can draw using
GL_LINE_STRIP and see that the generate vertices are indeed correct.  Printing
out the indices shows that they are also correct.

If I revert to an older Mesa (such as 10.2.8) then I no longer get an assertion
error.  Instead every other triangle strip is culled as though it were facing
the opposite direction (If I turn off culling, then the entire sphere is
rendered).

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20141024/e78970fc/attachment.html>


More information about the mesa-dev mailing list