Commits

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.

  • Participants
  • Parent commits 9d18ba9
  • Branches shaders

Comments (0)

Files changed (2)

File KVRenderer.h

 @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.

File KVRenderer.m

   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;
     }
   }
 }