Example #1
0
/**
 * Execute the buffer and save copied verts.
 * \param keep_unmapped  if true, leave the VBO unmapped when we're done.
 */
void
vbo_exec_vtx_flush(struct vbo_exec_context *exec, GLboolean keepUnmapped)
{
   if (0)
      vbo_exec_debug_verts(exec);

   if (exec->vtx.prim_count &&
       exec->vtx.vert_count) {

      exec->vtx.copied.nr = vbo_copy_vertices(exec);

      if (exec->vtx.copied.nr != exec->vtx.vert_count) {
         struct gl_context *ctx = exec->ctx;

         /* Prepare and set the exec draws internal VAO for drawing. */
         vbo_exec_bind_arrays(ctx);

         if (ctx->NewState)
            _mesa_update_state(ctx);

         vbo_exec_vtx_unmap(exec);

         assert(ctx->NewState == 0);

         if (0)
            printf("%s %d %d\n", __func__, exec->vtx.prim_count,
                   exec->vtx.vert_count);

         ctx->Driver.Draw(ctx, exec->vtx.prim, exec->vtx.prim_count,
                          NULL, GL_TRUE, 0, exec->vtx.vert_count - 1,
                          NULL, 0, NULL);

         /* Get new storage -- unless asked not to. */
         if (!keepUnmapped)
            vbo_exec_vtx_map(exec);
      }
   }

   /* May have to unmap explicitly if we didn't draw:
    */
   if (keepUnmapped && exec->vtx.buffer_map) {
      vbo_exec_vtx_unmap(exec);
   }

   if (keepUnmapped || exec->vtx.vertex_size == 0)
      exec->vtx.max_vert = 0;
   else
      exec->vtx.max_vert = vbo_compute_max_verts(exec);

   exec->vtx.buffer_ptr = exec->vtx.buffer_map;
   exec->vtx.prim_count = 0;
   exec->vtx.vert_count = 0;
}
Example #2
0
/**
 * Execute the buffer and save copied verts.
 */
void vbo_exec_vtx_flush( struct vbo_exec_context *exec )
{
   if (0)
      vbo_exec_debug_verts( exec );


   if (exec->vtx.prim_count && 
       exec->vtx.vert_count) {

      exec->vtx.copied.nr = vbo_copy_vertices( exec ); 

      if (exec->vtx.copied.nr != exec->vtx.vert_count) {
	 GLcontext *ctx = exec->ctx;

	 GLenum target = GL_ARRAY_BUFFER_ARB;
	 GLenum access = GL_READ_WRITE_ARB;
	 GLenum usage = GL_STREAM_DRAW_ARB;
	 GLsizei size = VBO_VERT_BUFFER_SIZE * sizeof(GLfloat);
	 
	 /* Before the unmap (why?)
	  */
	 vbo_exec_bind_arrays( ctx );

         /* if using a real VBO, unmap it before drawing */
         if (exec->vtx.bufferobj->Name) {
            ctx->Driver.UnmapBuffer(ctx, target, exec->vtx.bufferobj);
            exec->vtx.buffer_map = NULL;
         }

	 vbo_context(ctx)->draw_prims( ctx, 
				       exec->vtx.inputs, 
				       exec->vtx.prim, 
				       exec->vtx.prim_count,
				       NULL,
				       0,
				       exec->vtx.vert_count - 1);

	 /* If using a real VBO, get new storage */
         if (exec->vtx.bufferobj->Name) {
            ctx->Driver.BufferData(ctx, target, size, NULL, usage, exec->vtx.bufferobj);
            exec->vtx.buffer_map = 
               ctx->Driver.MapBuffer(ctx, target, access, exec->vtx.bufferobj);
         }
      }
   }

   exec->vtx.prim_count = 0;
   exec->vtx.vert_count = 0;
   exec->vtx.vbptr = (GLfloat *)exec->vtx.buffer_map;
}
Example #3
0
/**
 * Execute the buffer and save copied verts.
 * \param keep_unmapped  if true, leave the VBO unmapped when we're done.
 */
void
vbo_exec_vtx_flush(struct vbo_exec_context *exec, GLboolean keepUnmapped)
{
   if (0)
      vbo_exec_debug_verts( exec );

   if (exec->vtx.prim_count && 
       exec->vtx.vert_count) {

      exec->vtx.copied.nr = vbo_copy_vertices( exec ); 

      if (exec->vtx.copied.nr != exec->vtx.vert_count) {
	 struct gl_context *ctx = exec->ctx;
	 
	 /* Before the update_state() as this may raise _NEW_ARRAY
          * from _mesa_set_varying_vp_inputs().
	  */
	 vbo_exec_bind_arrays( ctx );

         if (ctx->NewState)
            _mesa_update_state( ctx );

         if (_mesa_is_bufferobj(exec->vtx.bufferobj)) {
            vbo_exec_vtx_unmap( exec );
         }

         if (0)
            printf("%s %d %d\n", __FUNCTION__, exec->vtx.prim_count,
		   exec->vtx.vert_count);

	 vbo_context(ctx)->draw_prims( ctx, 
				       exec->vtx.inputs, 
				       exec->vtx.prim, 
				       exec->vtx.prim_count,
				       NULL,
				       GL_TRUE,
				       0,
				       exec->vtx.vert_count - 1,
				       NULL);

	 /* If using a real VBO, get new storage -- unless asked not to.
          */
         if (_mesa_is_bufferobj(exec->vtx.bufferobj) && !keepUnmapped) {
            vbo_exec_vtx_map( exec );
         }
      }
   }

   /* May have to unmap explicitly if we didn't draw:
    */
   if (keepUnmapped &&
       _mesa_is_bufferobj(exec->vtx.bufferobj) &&
       exec->vtx.buffer_map) {
      vbo_exec_vtx_unmap( exec );
   }

   if (keepUnmapped || exec->vtx.vertex_size == 0)
      exec->vtx.max_vert = 0;
   else
      exec->vtx.max_vert = ((VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used) / 
                            (exec->vtx.vertex_size * sizeof(GLfloat)));

   exec->vtx.buffer_ptr = exec->vtx.buffer_map;
   exec->vtx.prim_count = 0;
   exec->vtx.vert_count = 0;
}