[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 89463a5c75c448a04c3abdc83e663e34ede8cea8..e1e57431a0b9578713f9f6f3e5d1eed7ea658063 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 484e781f0cb89d3976c300d917a45becaced0efb..2f68ec1704246c5b3822e59514c958a9d15d4929 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 552a0451fef084e3f0e6e330765937b3776efdc4..610f37e1f8947afdde2df628706717ee8a95b58d 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 b8e8766ec507d6ad08b2e3c133ae1b42018eb545..ca06abe202721730dc59c5b3f122f24986593bc3 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);