This is compile-tested.
0, 0);
}
+static INLINE struct pipe_resource *
+pipe_buffer_create_with_data(struct pipe_context *pipe,
+ unsigned bind,
+ unsigned usage,
+ unsigned size,
+ void *ptr)
+{
+ struct pipe_resource *res = pipe_buffer_create(pipe->screen,
+ bind, usage, size);
+ pipe_buffer_write_nooverlap(pipe, res, 0, size, ptr);
+ return res;
+}
+
static INLINE void
pipe_buffer_read(struct pipe_context *pipe,
struct pipe_resource *buf,
vbuf.stride = sizeof(struct vertex);
vbuf.buffer_offset = 0;
- vbuf.buffer = info.screen->user_buffer_create(info.screen,
- vertices,
- sizeof(vertices),
- PIPE_BIND_VERTEX_BUFFER);
+ vbuf.buffer = pipe_buffer_create_with_data(info.ctx,
+ PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STATIC,
+ sizeof(vertices),
+ vertices);
info.ctx->set_vertex_buffers(info.ctx, 1, &vbuf);
}
vbuf.stride = sizeof(struct vertex);
vbuf.buffer_offset = 0;
- vbuf.buffer = info.screen->user_buffer_create(info.screen,
- vertices,
- sizeof(vertices),
- PIPE_BIND_VERTEX_BUFFER);
+ vbuf.buffer = pipe_buffer_create_with_data(info.ctx,
+ PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STATIC,
+ sizeof(vertices),
+ vertices);
info.ctx->set_vertex_buffers(info.ctx, 1, &vbuf);
}
vbuf.stride = sizeof( struct vertex );
vbuf.buffer_offset = 0;
- vbuf.buffer = screen->user_buffer_create(screen,
- vertices,
- sizeof(vertices),
- PIPE_BIND_VERTEX_BUFFER);
+ vbuf.buffer = pipe_buffer_create_with_data(ctx,
+ PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STATIC,
+ sizeof(vertices),
+ vertices);
ctx->set_vertex_buffers(ctx, 1, &vbuf);
}
vbuf.stride = sizeof(struct vertex);
vbuf.buffer_offset = 0;
- vbuf.buffer = info.screen->user_buffer_create(info.screen,
- vertices,
- sizeof(vertices),
- PIPE_BIND_VERTEX_BUFFER);
+ vbuf.buffer = pipe_buffer_create_with_data(info.ctx,
+ PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STATIC,
+ sizeof(vertices),
+ vertices);
info.ctx->set_vertex_buffers(info.ctx, 1, &vbuf);
}
vbuf.stride = sizeof( struct vertex );
vbuf.buffer_offset = 0;
if (draw_strip) {
- vbuf.buffer = screen->user_buffer_create(screen,
- vertices_strip,
- sizeof(vertices_strip),
- PIPE_BIND_VERTEX_BUFFER);
+ vbuf.buffer = pipe_buffer_create_with_data(ctx,
+ PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STATIC,
+ sizeof(vertices_strip),
+ vertices_strip);
} else {
- vbuf.buffer = screen->user_buffer_create(screen,
- vertices,
- sizeof(vertices),
- PIPE_BIND_VERTEX_BUFFER);
+ vbuf.buffer = pipe_buffer_create_with_data(ctx,
+ PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STATIC,
+ sizeof(vertices),
+ vertices);
}
ctx->set_vertex_buffers(ctx, 1, &vbuf);
vbuf.stride = sizeof(struct vertex);
vbuf.buffer_offset = 0;
- vbuf.buffer = info.screen->user_buffer_create(info.screen,
- vertices,
- bytes,
- PIPE_BIND_VERTEX_BUFFER);
+ vbuf.buffer = pipe_buffer_create_with_data(info.ctx,
+ PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STATIC,
+ bytes,
+ vertices);
info.ctx->set_vertex_buffers(info.ctx, 1, &vbuf);
}
vbuf.stride = sizeof( struct vertex );
vbuf.buffer_offset = 0;
- vbuf.buffer = screen->user_buffer_create(screen,
- vertices,
- sizeof(vertices),
- PIPE_BIND_VERTEX_BUFFER);
+ vbuf.buffer = pipe_buffer_create_with_data(ctx,
+ PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STATIC,
+ sizeof(vertices),
+ vertices);
ctx->set_vertex_buffers(ctx, 1, &vbuf);
}
vbuf.stride = sizeof( struct vertex );
vbuf.buffer_offset = 0;
- vbuf.buffer = info.screen->user_buffer_create(info.screen,
- vertices,
- sizeof(vertices),
- PIPE_BIND_VERTEX_BUFFER);
+ vbuf.buffer = pipe_buffer_create_with_data(info.ctx,
+ PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STATIC,
+ sizeof(vertices),
+ vertices);
info.ctx->set_vertex_buffers(info.ctx, 1, &vbuf);
}
#include "util/u_memory.h" /* Offset() */
#include "util/u_draw_quad.h"
+#include "util/u_inlines.h"
static int num_iters = 100;
vbuf.stride = sizeof(struct vertex);
vbuf.buffer_offset = 0;
- vbuf.buffer = screen->user_buffer_create(screen,
- vertices,
- sizeof(vertices),
- PIPE_BIND_VERTEX_BUFFER);
+ vbuf.buffer = pipe_buffer_create_with_data(ctx,
+ PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STATIC,
+ sizeof(vertices),
+ vertices);
ctx->set_vertex_buffers(ctx, 1, &vbuf);
}
vbuf.stride = sizeof(struct vertex);
vbuf.buffer_offset = 0;
- vbuf.buffer = info.screen->user_buffer_create(info.screen,
- verts,
- num_verts *sizeof(struct vertex),
- PIPE_BIND_VERTEX_BUFFER);
+ vbuf.buffer = pipe_buffer_create_with_data(info.ctx,
+ PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STATIC,
+ num_verts * sizeof(struct vertex),
+ verts);
info.ctx->set_vertex_buffers(info.ctx, 1, &vbuf);
}
vbuf.stride = sizeof(struct vertex);
vbuf.buffer_offset = 0;
- vbuf.buffer = info.screen->user_buffer_create(info.screen,
- vertices,
- sizeof(vertices),
- PIPE_BIND_VERTEX_BUFFER);
+ vbuf.buffer = pipe_buffer_create_with_data(info.ctx,
+ PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STATIC,
+ sizeof(vertices),
+ vertices);
info.ctx->set_vertex_buffers(info.ctx, 1, &vbuf);
}
#include "util/u_memory.h" /* Offset() */
#include "util/u_draw_quad.h"
+#include "util/u_inlines.h"
enum pipe_format formats[] = {
PIPE_FORMAT_R8G8B8A8_UNORM,
vbuf.stride = sizeof( struct vertex );
vbuf.buffer_offset = 0;
- vbuf.buffer = screen->user_buffer_create(screen,
- vertices,
- sizeof(vertices),
- PIPE_BIND_VERTEX_BUFFER);
+ vbuf.buffer = pipe_buffer_create_with_data(ctx,
+ PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STATIC,
+ sizeof(vertices),
+ vertices);
ctx->set_vertex_buffers(ctx, 1, &vbuf);
}
#include "util/u_memory.h" /* Offset() */
#include "util/u_draw_quad.h"
+#include "util/u_inlines.h"
enum pipe_format formats[] = {
/* vertex data */
vbuf[0].stride = sizeof( struct vertex );
vbuf[0].buffer_offset = 0;
- vbuf[0].buffer = screen->user_buffer_create(screen,
- vertices,
- sizeof(vertices),
- PIPE_BIND_VERTEX_BUFFER);
+ vbuf[0].buffer = pipe_buffer_create_with_data(ctx,
+ PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STATIC,
+ sizeof(vertices),
+ vertices);
/* instance data */
vbuf[1].stride = sizeof( inst_data[0] );
vbuf[1].buffer_offset = 0;
- vbuf[1].buffer = screen->user_buffer_create(screen,
- inst_data,
- sizeof(inst_data),
- PIPE_BIND_VERTEX_BUFFER);
-
+ vbuf[1].buffer = pipe_buffer_create_with_data(ctx,
+ PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STATIC,
+ sizeof(inst_data),
+ inst_data);
ctx->set_vertex_buffers(ctx, 2, vbuf);
/* index data */
- ibuf.buffer = screen->user_buffer_create(screen,
- indices,
- sizeof(indices),
- PIPE_BIND_VERTEX_BUFFER);
+ ibuf.buffer = pipe_buffer_create_with_data(ctx,
+ PIPE_BIND_INDEX_BUFFER,
+ PIPE_USAGE_STATIC,
+ sizeof(indices),
+ indices);
ibuf.offset = 0;
ibuf.index_size = 2;
vbuf.stride = sizeof( struct vertex );
vbuf.buffer_offset = 0;
- vbuf.buffer = info.screen->user_buffer_create(info.screen,
- vertices,
- sizeof(vertices),
- PIPE_BIND_VERTEX_BUFFER);
+ vbuf.buffer = pipe_buffer_create_with_data(info.ctx,
+ PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STATIC,
+ sizeof(vertices),
+ vertices);
info.ctx->set_vertex_buffers(info.ctx, 1, &vbuf);
}
vbuf.stride = sizeof( struct vertex );
vbuf.buffer_offset = 0;
- vbuf.buffer = screen->user_buffer_create(screen,
- vertices,
- sizeof(vertices),
- PIPE_BIND_VERTEX_BUFFER);
+ vbuf.buffer = pipe_buffer_create_with_data(ctx,
+ PIPE_BIND_VERTEX_BUFFER,
+ PIPE_USAGE_STATIC,
+ sizeof(vertices),
+ vertices);
ctx->set_vertex_buffers(ctx, 1, &vbuf);
}