Cliff Biffle avatar Cliff Biffle committed 9a7e575

KVRenderer no longer sends useless Z components to the GPU, reducing the size of the transfer by 33%. Actual render times decrease by roughly the same amount.

Comments (0)

Files changed (2)

 @interface KVRenderer : NSObject {
   // The actual scene model.  Alarmingly, gcc generates suboptimal
   // code if we use [480][640].
-  vec3f_t rays[480 * 640];
+  vec2f_t rays[480 * 640];
   
   // The raw RGB samples of the last color image.  These do not
   // map one-to-one onto rays because the cameras are offset.
   glColor3f(1, 1, 1);
   glNormal3f(0, 0, -1);
   glEnableClientState(GL_VERTEX_ARRAY);
-  glVertexPointer(3, GL_FLOAT, 0, &rays);
+  glVertexPointer(2, GL_FLOAT, 0, &rays);
 
   glDrawArrays(GL_POINTS, 0, 640 * 480);
   
   glDisableClientState(GL_VERTEX_ARRAY);
 }
 
-// We pre-fill the X and Y components with distance from the center of
-// the image.  These values never make it to the rasterizer: they are
-// merely input to the vertex shader that performs perspective correction.
+// We pre-fill the X and Y components with distance from the top-left
+// corner of the image.  These values never make it to the rasterizer:
+// they are merely input to the vertex shader that performs perspective
+// correction.
 - (void) fillStaticComponents {
   int vidx = 0;
   for (int y = 0; y < 480; y++) {
     for (int x = 0; x < 640; x++, vidx++) {
       rays[vidx].x = (x / 640.f);
       rays[vidx].y = (y / 480.f);
-      rays[vidx].z = 4;
     }
   }
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.