summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/vl/vl_vertex_buffers.h
diff options
context:
space:
mode:
authorChristian König <deathsimple@vodafone.de>2010-11-28 14:48:31 +0100
committerChristian König <deathsimple@vodafone.de>2010-12-03 19:04:00 +0100
commit4abe7382882a451a7750ccc451b8568768d122cb (patch)
tree273068eec7f3f16aa6fde6ac89e2f2e2f0e30e48 /src/gallium/auxiliary/vl/vl_vertex_buffers.h
parenta984c67b316ac2ca9aaf6d38a3127cf3d61a249e (diff)
downloadexternal_mesa3d-4abe7382882a451a7750ccc451b8568768d122cb.zip
external_mesa3d-4abe7382882a451a7750ccc451b8568768d122cb.tar.gz
external_mesa3d-4abe7382882a451a7750ccc451b8568768d122cb.tar.bz2
use a shadow buffer for vertex data to optimize memory access
Diffstat (limited to 'src/gallium/auxiliary/vl/vl_vertex_buffers.h')
-rw-r--r--src/gallium/auxiliary/vl/vl_vertex_buffers.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/vl/vl_vertex_buffers.h b/src/gallium/auxiliary/vl/vl_vertex_buffers.h
new file mode 100644
index 0000000..43ddc34
--- /dev/null
+++ b/src/gallium/auxiliary/vl/vl_vertex_buffers.h
@@ -0,0 +1,75 @@
+/**************************************************************************
+ *
+ * Copyright 2010 Christian König
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+#ifndef vl_vertex_buffers_h
+#define vl_vertex_buffers_h
+
+#include <assert.h>
+#include <pipe/p_state.h>
+#include "vl_types.h"
+
+struct vl_vertex_buffer
+{
+ unsigned num_blocks;
+ struct quadf *blocks;
+};
+
+struct pipe_vertex_buffer vl_vb_upload_quads(struct pipe_context *pipe, unsigned max_blocks);
+
+bool vl_vb_init(struct vl_vertex_buffer *buffer, unsigned max_blocks);
+
+static inline bool
+vl_vb_add_block(struct vl_vertex_buffer *buffer, bool allow_merge, signed x, signed y)
+{
+ struct quadf *quad;
+
+ assert(buffer);
+
+ allow_merge &= buffer->num_blocks > 0;
+ if (allow_merge) {
+
+ quad = buffer->blocks + buffer->num_blocks - 1;
+ if(quad->tr.x == (x - 1) && quad->br.x == (x - 1) &&
+ quad->tr.y == y && quad->br.y == y) {
+
+ quad->tr.x = quad->br.x = x;
+ quad->tr.y = quad->br.y = y;
+ return true;
+ }
+ }
+
+ quad = buffer->blocks + buffer->num_blocks;
+ quad->bl.x = quad->tl.x = quad->tr.x = quad->br.x = x;
+ quad->bl.y = quad->tl.y = quad->tr.y = quad->br.y = y;
+ buffer->num_blocks++;
+ return false;
+}
+
+unsigned vl_vb_upload(struct vl_vertex_buffer *buffer, struct quadf *dst);
+
+void vl_vb_cleanup(struct vl_vertex_buffer *buffer);
+
+#endif