by Dan East » Dec 26, 2001 @ 10:03pm
Digby, I don't time to go into the assembly at the moment. I did indeed disable optimization of that function using pragmas, as you suggested, which is what solved the problem. Here is the exact function in which the problem occured:<br>[fixed]<br>void R_SetUpFrustumIndexes ( void )<br>{<br> int i, j, *pindex;<br><br> pindex = r_frustum_indexes;<br><br> for ( i=0 ; i<4 ; i++ ) {<br> for ( j=0 ; j<3 ; j++ ) {<br> if ( view_clipplanes[ i ].normal[j] < 0 ) {<br> pindex[j] = j;<br> pindex[j+3] = j+3;<br> } else {<br> pindex[j] = j+3;<br> pindex[j+3] = j;<br> }<br> }<br> // FIXME: do just once at start<br> pfrustum_indexes[ i ] = pindex;<br> pindex += 6;<br> }<br>}<br>[/fixed]<br><br>r_frustum_indexes is simply a global, fixed-size array large enough to hold the elements. What was occuring is that pindex[3] was being set to an enormous value, while it is very obivous from the source above that the range is restricted to "j" to "j+3", which is from 0 to 5. That value is used as an index elsewhere, which is where the crash would occur. The other odd thing is that this did not occur in all cases, but only when the player entity's yaw was in a certain range. I could find no external factors that could effect this code in such a way, and disabling optimizations fixed the problem. My hunch is that perhaps a register was being read that was not properly initialized, so it contained "garbage" data. I actually "solved" the problem by accident. I built a Release build that included debugging info. The problem with doing that is the optimization of the functions make it impossible at times to step from line to line. So I disabled optimizations to make things conducive for debugging, and then the problem went away. The problem never occured in the emulator, with release or debug builds, and would not occur in the debug ARM build. There were a few similar optimization bugs in the SH3 version of PQ1, which is what held up its release. Can't remember who, but they isolated them, and disabled optimizations for those functions and that solved the problem there.<br><br>Dan East<br><br>[sup][color=blue]Last modification: Dan East - 12/26/01 at 19:03:10