<br><br>---------- Forwarded message ----------<br><span class="gmail_quote">From: <b class="gmail_sendername">James Trotter</b> &lt;<a href="mailto:james.trotter@gmail.com">james.trotter@gmail.com</a>&gt;<br>Date: Apr 4, 2006 8:16 PM
<br>Subject: Re: Wined3d/OpenGL question<br>To: Jason Green &lt;<a href="mailto:jave27@gmail.com">jave27@gmail.com</a>&gt;<br><br></span><div style="direction: ltr;"><span class="e" id="q_10a661e6edb75955_0">On 4/4/06, <b class="gmail_sendername">
Jason Green</b> &lt;<a href="mailto:jave27@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">jave27@gmail.com</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

I may be barking up the wrong tree here, but I'm trying to debug the<br>cause of a 502 error ( GL_INVALID_OPERATION ) from glDrawElements() in<br>drawprim.c (line 1251).&nbsp;&nbsp;This is for Civilization 4 using both<br>hardware vertex &amp; pixel shaders.&nbsp;&nbsp;I've only noticed this error when it
<br>is passed GL_TRIANGLES with a large number of vertices.<br><br>Here's a sample output with a little extra debugging info, and cleaned<br>up a little:<br><br>trace:d3d_draw:primitiveToGl TRIANGLES<br>trace:d3d_draw:drawPrimitiveDrawStrided begin number of indices6144,
<br>number of vertices1156<br>trace:d3d_draw:drawPrimitiveDrawStrided end number of indices6144,<br>number of vertices1156<br>...<br>trace:d3d_draw:drawPrimitiveDrawStrided Using pixel shader<br>trace:d3d_draw:drawPrimitiveDrawStrided
<br>glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, pixelShader-&gt;prgId); call ok<br>drawprim.c / 1846<br>trace:d3d_draw:drawPrimitiveDrawStrided<br>glEnable(GL_FRAGMENT_PROGRAM_ARB); call ok drawprim.c / 1850<br>trace:d3d_draw:drawStridedFast (0x7fd98890) : glElements(4, 6144, 0, ...)
<br>fixme:d3d_draw:drawStridedFast &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; 502 from<br>glDrawRangeElements @ drawprim.c / 1251<br><br>Often, a series of these errors will result in an unhandled exception
<br>in libglcore.so.1 (nvidia binary 8178 driver for a 6600GT, <a href="http://2.6.16.1" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">2.6.16.1</a><br>kernel).<br><br>I read up on the glDrawElements() function and it refered to the
<br>GetIntegerv() function for GL_MAX_ELEMENTS_VERTICES.&nbsp;&nbsp; When I call
<br>that function, it returns 4096, and the number of vertices that it's<br>trying to pass is larger than that.&nbsp;&nbsp;I've tried doing a min() of the<br>max and the actual # of vertices, but the results are the same.<br><br>So, the question is:&nbsp;&nbsp;Could this be one of the causes of the graphical
<br>glitches I'm seeing?&nbsp;&nbsp;I can toy around with these functions all day,<br>but I don't really understand them all that well.&nbsp;&nbsp;Does that routine<br>need to be reworked to split up a D3DPT_TRIANGLELIST into multiple<br>calls if the calculated number of vertices/indices is too high for the
<br>user's graphics card?&nbsp;&nbsp;Or, am I way off base thinking this has any<br>bearing on my real issues?<br><br>Thanks,<br>Jason<br><br><br></blockquote></div><br></span></div><div style="direction: ltr;">
GL_MAX_ELEMENTS_VERTICES and GL_MAX_ELEMENTS_INDICES are just
performance hints, and not actual limits to how many vertices or
indices that the driver can handle.<br>
<br>
>From <a href="http://pyopengl.sourceforge.net/documentation/manual/glDrawRangeElements.3G.html" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://pyopengl.sourceforge.net/documentation/manual/glDrawRangeElements.3G.html
</a>:<br>
<br>
&quot;Implementations denote recommended maximum amounts of vertex and index
data, which may be queried by calling glGet with argument
GL_MAX_ELEMENTS_VERTICES and GL_MAX_ELEMENTS_INDICES. If end - start +
1 is greater than the value of GL_MAX_ELEMENTS_VERTICES, or if count is
greater than the value of GL_MAX_ELEMENTS_INDICES, then the call may
operate at reduced performance. There is no requirement that all
vertices in the range [start,end] be referenced. However, the
implementation may partially process unused vertices, reducing
performance from what could be achieved with an optimal index set.&quot;<br>
<br>
Also,<br>
<br>
&quot;GL_INVALID_OPERATION is generated if glDrawRangeElements is executed
between the execution of glBegin and the corresponding glEnd.&quot;<br>
<br>

</div>