[g3dvl] use instanced drawing to reduce the vertex buffer payload
authorChristian König <deathsimple@vodafone.de>
Sat, 5 Mar 2011 15:36:38 +0000 (16:36 +0100)
committerChristian König <deathsimple@vodafone.de>
Sat, 5 Mar 2011 15:36:38 +0000 (16:36 +0100)
src/gallium/auxiliary/vl/vl_idct.c
src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
src/gallium/auxiliary/vl/vl_vertex_buffers.c
src/gallium/auxiliary/vl/vl_vertex_buffers.h

index 89463a5..e1e5743 100644 (file)
@@ -752,7 +752,7 @@ vl_idct_flush(struct vl_idct *idct, struct vl_idct_buffer *buffer)
       idct->pipe->bind_fragment_sampler_states(idct->pipe, 2, idct->samplers.stage[0]);
       idct->pipe->bind_vs_state(idct->pipe, idct->matrix_vs);
       idct->pipe->bind_fs_state(idct->pipe, idct->matrix_fs);
-      util_draw_arrays(idct->pipe, PIPE_PRIM_QUADS, 0, num_verts);
+      util_draw_arrays_instanced(idct->pipe, PIPE_PRIM_QUADS, 0, 4, 0, num_verts);
 
       /* second stage */
       idct->pipe->set_framebuffer_state(idct->pipe, &buffer->fb_state[1]);
@@ -761,6 +761,6 @@ vl_idct_flush(struct vl_idct *idct, struct vl_idct_buffer *buffer)
       idct->pipe->bind_fragment_sampler_states(idct->pipe, 2, idct->samplers.stage[1]);
       idct->pipe->bind_vs_state(idct->pipe, idct->transpose_vs);
       idct->pipe->bind_fs_state(idct->pipe, idct->transpose_fs);
-      util_draw_arrays(idct->pipe, PIPE_PRIM_QUADS, 0, num_verts);
+      util_draw_arrays_instanced(idct->pipe, PIPE_PRIM_QUADS, 0, 4, 0, num_verts);
    }
 }
index 484e781..2f68ec1 100644 (file)
@@ -1080,7 +1080,7 @@ vl_mpeg12_mc_renderer_flush(struct vl_mpeg12_mc_renderer *renderer, struct vl_mp
 
    renderer->pipe->bind_vs_state(renderer->pipe, renderer->vs);
    renderer->pipe->bind_fs_state(renderer->pipe, renderer->fs);
-   util_draw_arrays(renderer->pipe, PIPE_PRIM_QUADS, 0, buffer->num_macroblocks * 4);
+   util_draw_arrays_instanced(renderer->pipe, PIPE_PRIM_QUADS, 0, 4, 0, buffer->num_macroblocks);
 
    renderer->pipe->flush(renderer->pipe, PIPE_FLUSH_RENDER_CACHE, buffer->fence);
 
index 552a045..610f37e 100644 (file)
@@ -106,7 +106,7 @@ vl_vb_element_helper(struct pipe_vertex_element* elements, unsigned num_elements
 
    for ( i = 0; i < num_elements; ++i ) {
       elements[i].src_offset = offset;
-      elements[i].instance_divisor = 0;
+      elements[i].instance_divisor = 1;
       elements[i].vertex_buffer_index = vertex_buffer_index;
       offset += util_format_get_blocksize(elements[i].src_format);
    }
index b8e8766..ca06abe 100644 (file)
@@ -57,16 +57,12 @@ static inline void
 vl_vb_add_block(struct vl_vertex_buffer *buffer, void *elements)
 {
    void *pos;
-   unsigned i;
 
    assert(buffer);
 
    pos = buffer->vectors + buffer->num_verts * buffer->stride;
-   for(i = 0; i < 4; ++i) {
-      memcpy(pos, elements, buffer->stride);
-      pos += buffer->stride;
-      buffer->num_verts++;
-   }
+   memcpy(pos, elements, buffer->stride);
+   buffer->num_verts++;
 }
 
 void vl_vb_unmap(struct vl_vertex_buffer *buffer, struct pipe_context *pipe);