summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/vl/vl_vertex_buffers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/vl/vl_vertex_buffers.c')
-rw-r--r--src/gallium/auxiliary/vl/vl_vertex_buffers.c57
1 files changed, 36 insertions, 21 deletions
diff --git a/src/gallium/auxiliary/vl/vl_vertex_buffers.c b/src/gallium/auxiliary/vl/vl_vertex_buffers.c
index 4e0d704a23d..4647685053b 100644
--- a/src/gallium/auxiliary/vl/vl_vertex_buffers.c
+++ b/src/gallium/auxiliary/vl/vl_vertex_buffers.c
@@ -40,7 +40,7 @@ static const struct quadf const_quad = {
};
struct pipe_vertex_buffer
-vl_vb_upload_quads(struct pipe_context *pipe, unsigned max_blocks, struct pipe_vertex_element* element)
+vl_vb_upload_quads(struct pipe_context *pipe, unsigned max_blocks)
{
struct pipe_vertex_buffer quad;
struct pipe_transfer *buf_transfer;
@@ -50,13 +50,6 @@ vl_vb_upload_quads(struct pipe_context *pipe, unsigned max_blocks, struct pipe_v
assert(pipe);
assert(max_blocks);
- assert(element);
-
- /* setup rectangle element */
- element->src_offset = 0;
- element->instance_divisor = 0;
- element->vertex_buffer_index = 0;
- element->src_format = PIPE_FORMAT_R32G32_FLOAT;
/* create buffer */
quad.stride = sizeof(struct vertex2f);
@@ -89,34 +82,56 @@ vl_vb_upload_quads(struct pipe_context *pipe, unsigned max_blocks, struct pipe_v
return quad;
}
+struct pipe_vertex_element
+vl_vb_get_quad_vertex_element()
+{
+ struct pipe_vertex_element element;
+
+ /* setup rectangle element */
+ element.src_offset = 0;
+ element.instance_divisor = 0;
+ element.vertex_buffer_index = 0;
+ element.src_format = PIPE_FORMAT_R32G32_FLOAT;
+
+ return element;
+}
+
struct pipe_vertex_buffer
-vl_vb_create_buffer(struct pipe_context *pipe, unsigned max_blocks,
- struct pipe_vertex_element *elements, unsigned num_elements,
- unsigned vertex_buffer_index)
+vl_vb_create_buffer(struct pipe_context *pipe, unsigned max_blocks, unsigned stride)
{
struct pipe_vertex_buffer buf;
- unsigned i, size = 0;
-
- for ( i = 0; i < num_elements; ++i ) {
- elements[i].src_offset = size;
- elements[i].instance_divisor = 0;
- elements[i].vertex_buffer_index = vertex_buffer_index;
- size += util_format_get_blocksize(elements[i].src_format);
- }
- buf.stride = size;
+ buf.stride = stride;
buf.max_index = 4 * max_blocks - 1;
buf.buffer_offset = 0;
buf.buffer = pipe_buffer_create
(
pipe->screen,
PIPE_BIND_VERTEX_BUFFER,
- size * 4 * max_blocks
+ stride * 4 * max_blocks
);
return buf;
}
+unsigned
+vl_vb_element_helper(struct pipe_vertex_element* elements, unsigned num_elements,
+ unsigned vertex_buffer_index)
+{
+ unsigned i, offset = 0;
+
+ assert(elements && num_elements);
+
+ for ( i = 0; i < num_elements; ++i ) {
+ elements[i].src_offset = offset;
+ elements[i].instance_divisor = 0;
+ elements[i].vertex_buffer_index = vertex_buffer_index;
+ offset += util_format_get_blocksize(elements[i].src_format);
+ }
+
+ return offset;
+}
+
bool
vl_vb_init(struct vl_vertex_buffer *buffer, unsigned max_blocks, unsigned num_elements)
{