summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r--src/gallium/auxiliary/util/u_draw.c6
-rw-r--r--src/gallium/auxiliary/util/u_draw.h9
-rw-r--r--src/gallium/auxiliary/util/u_dump.h3
-rw-r--r--src/gallium/auxiliary/util/u_dump_state.c23
-rw-r--r--src/gallium/auxiliary/util/u_helpers.c44
-rw-r--r--src/gallium/auxiliary/util/u_helpers.h11
-rw-r--r--src/gallium/auxiliary/util/u_index_modify.c24
-rw-r--r--src/gallium/auxiliary/util/u_index_modify.h7
-rw-r--r--src/gallium/auxiliary/util/u_prim_restart.c54
-rw-r--r--src/gallium/auxiliary/util/u_prim_restart.h9
-rw-r--r--src/gallium/auxiliary/util/u_vbuf.c135
-rw-r--r--src/gallium/auxiliary/util/u_vbuf.h2
12 files changed, 118 insertions, 209 deletions
diff --git a/src/gallium/auxiliary/util/u_draw.c b/src/gallium/auxiliary/util/u_draw.c
index e7abbfc422b..a7590f7f043 100644
--- a/src/gallium/auxiliary/util/u_draw.c
+++ b/src/gallium/auxiliary/util/u_draw.c
@@ -136,7 +136,7 @@ util_draw_indirect(struct pipe_context *pipe,
struct pipe_draw_info info;
struct pipe_transfer *transfer;
uint32_t *params;
- const unsigned num_params = info_in->indexed ? 5 : 4;
+ const unsigned num_params = info_in->index_size ? 5 : 4;
assert(info_in->indirect);
assert(!info_in->count_from_stream_output);
@@ -158,8 +158,8 @@ util_draw_indirect(struct pipe_context *pipe,
info.count = params[0];
info.instance_count = params[1];
info.start = params[2];
- info.index_bias = info_in->indexed ? params[3] : 0;
- info.start_instance = info_in->indexed ? params[4] : params[3];
+ info.index_bias = info_in->index_size ? params[3] : 0;
+ info.start_instance = info_in->index_size ? params[4] : params[3];
info.indirect = NULL;
pipe_buffer_unmap(pipe, transfer);
diff --git a/src/gallium/auxiliary/util/u_draw.h b/src/gallium/auxiliary/util/u_draw.h
index b6ea3de8905..e8af14051b1 100644
--- a/src/gallium/auxiliary/util/u_draw.h
+++ b/src/gallium/auxiliary/util/u_draw.h
@@ -67,15 +67,15 @@ util_draw_arrays(struct pipe_context *pipe,
}
static inline void
-util_draw_elements(struct pipe_context *pipe, int index_bias,
- enum pipe_prim_type mode,
+util_draw_elements(struct pipe_context *pipe, unsigned index_size,
+ int index_bias, enum pipe_prim_type mode,
uint start,
uint count)
{
struct pipe_draw_info info;
util_draw_init_info(&info);
- info.indexed = TRUE;
+ info.index_size = index_size;
info.mode = mode;
info.start = start;
info.count = count;
@@ -108,6 +108,7 @@ util_draw_arrays_instanced(struct pipe_context *pipe,
static inline void
util_draw_elements_instanced(struct pipe_context *pipe,
+ unsigned index_size,
int index_bias,
enum pipe_prim_type mode,
uint start,
@@ -118,7 +119,7 @@ util_draw_elements_instanced(struct pipe_context *pipe,
struct pipe_draw_info info;
util_draw_init_info(&info);
- info.indexed = TRUE;
+ info.index_size = index_size;
info.mode = mode;
info.start = start;
info.count = count;
diff --git a/src/gallium/auxiliary/util/u_dump.h b/src/gallium/auxiliary/util/u_dump.h
index 3a701ac5be9..408c270040f 100644
--- a/src/gallium/auxiliary/util/u_dump.h
+++ b/src/gallium/auxiliary/util/u_dump.h
@@ -173,9 +173,6 @@ util_dump_constant_buffer(FILE *stream,
const struct pipe_constant_buffer *state);
void
-util_dump_index_buffer(FILE *stream, const struct pipe_index_buffer *state);
-
-void
util_dump_vertex_buffer(FILE *stream,
const struct pipe_vertex_buffer *state);
diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c
index 5e42bdd3028..c62229a5fe1 100644
--- a/src/gallium/auxiliary/util/u_dump_state.c
+++ b/src/gallium/auxiliary/util/u_dump_state.c
@@ -834,25 +834,6 @@ util_dump_constant_buffer(FILE *stream,
void
-util_dump_index_buffer(FILE *stream, const struct pipe_index_buffer *state)
-{
- if (!state) {
- util_dump_null(stream);
- return;
- }
-
- util_dump_struct_begin(stream, "pipe_index_buffer");
-
- util_dump_member(stream, uint, state, index_size);
- util_dump_member(stream, uint, state, offset);
- util_dump_member(stream, ptr, state, buffer);
- util_dump_member(stream, ptr, state, user_buffer);
-
- util_dump_struct_end(stream);
-}
-
-
-void
util_dump_vertex_buffer(FILE *stream, const struct pipe_vertex_buffer *state)
{
if (!state) {
@@ -919,7 +900,8 @@ util_dump_draw_info(FILE *stream, const struct pipe_draw_info *state)
util_dump_struct_begin(stream, "pipe_draw_info");
- util_dump_member(stream, bool, state, indexed);
+ util_dump_member(stream, uint, state, index_size);
+ util_dump_member(stream, uint, state, has_user_indices);
util_dump_member(stream, enum_prim_mode, state, mode);
util_dump_member(stream, uint, state, start);
@@ -939,6 +921,7 @@ util_dump_draw_info(FILE *stream, const struct pipe_draw_info *state)
util_dump_member(stream, bool, state, primitive_restart);
util_dump_member(stream, uint, state, restart_index);
+ util_dump_member(stream, ptr, state, index.resource);
util_dump_member(stream, ptr, state, count_from_stream_output);
if (!state->indirect) {
diff --git a/src/gallium/auxiliary/util/u_helpers.c b/src/gallium/auxiliary/util/u_helpers.c
index f91cb0c158d..e0feade3acd 100644
--- a/src/gallium/auxiliary/util/u_helpers.c
+++ b/src/gallium/auxiliary/util/u_helpers.c
@@ -98,48 +98,24 @@ void util_set_vertex_buffers_count(struct pipe_vertex_buffer *dst,
*dst_count = util_last_bit(enabled_buffers);
}
-
-void
-util_set_index_buffer(struct pipe_index_buffer *dst,
- const struct pipe_index_buffer *src)
-{
- if (src) {
- pipe_resource_reference(&dst->buffer, src->buffer);
- memcpy(dst, src, sizeof(*dst));
- }
- else {
- pipe_resource_reference(&dst->buffer, NULL);
- memset(dst, 0, sizeof(*dst));
- }
-}
-
/**
* Given a user index buffer, save the structure to "saved", and upload it.
*/
bool
-util_save_and_upload_index_buffer(struct pipe_context *pipe,
- const struct pipe_draw_info *info,
- const struct pipe_index_buffer *ib,
- struct pipe_index_buffer *out_saved)
+util_upload_index_buffer(struct pipe_context *pipe,
+ const struct pipe_draw_info *info,
+ struct pipe_resource **out_buffer,
+ unsigned *out_offset)
{
- struct pipe_index_buffer new_ib = {0};
- unsigned start_offset = info->start * ib->index_size;
+ unsigned start_offset = info->start * info->index_size;
u_upload_data(pipe->stream_uploader, start_offset,
- info->count * ib->index_size, 4,
- (char*)ib->user_buffer + start_offset,
- &new_ib.offset, &new_ib.buffer);
- if (!new_ib.buffer)
- return false;
+ info->count * info->index_size, 4,
+ (char*)info->index.user + start_offset,
+ out_offset, out_buffer);
u_upload_unmap(pipe->stream_uploader);
-
- new_ib.offset -= start_offset;
- new_ib.index_size = ib->index_size;
-
- util_set_index_buffer(out_saved, ib);
- pipe->set_index_buffer(pipe, &new_ib);
- pipe_resource_reference(&new_ib.buffer, NULL);
- return true;
+ *out_offset -= start_offset;
+ return *out_buffer != NULL;
}
struct pipe_query *
diff --git a/src/gallium/auxiliary/util/u_helpers.h b/src/gallium/auxiliary/util/u_helpers.h
index 2b382a1a54e..ab970d791b1 100644
--- a/src/gallium/auxiliary/util/u_helpers.h
+++ b/src/gallium/auxiliary/util/u_helpers.h
@@ -45,13 +45,10 @@ void util_set_vertex_buffers_count(struct pipe_vertex_buffer *dst,
const struct pipe_vertex_buffer *src,
unsigned start_slot, unsigned count);
-void util_set_index_buffer(struct pipe_index_buffer *dst,
- const struct pipe_index_buffer *src);
-
-bool util_save_and_upload_index_buffer(struct pipe_context *pipe,
- const struct pipe_draw_info *info,
- const struct pipe_index_buffer *ib,
- struct pipe_index_buffer *out_saved);
+bool util_upload_index_buffer(struct pipe_context *pipe,
+ const struct pipe_draw_info *info,
+ struct pipe_resource **out_buffer,
+ unsigned *out_offset);
struct pipe_query *
util_begin_pipestat_query(struct pipe_context *ctx);
diff --git a/src/gallium/auxiliary/util/u_index_modify.c b/src/gallium/auxiliary/util/u_index_modify.c
index d86be24bcd6..4e9349a7db6 100644
--- a/src/gallium/auxiliary/util/u_index_modify.c
+++ b/src/gallium/auxiliary/util/u_index_modify.c
@@ -27,7 +27,7 @@
/* Ubyte indices. */
void util_shorten_ubyte_elts_to_userptr(struct pipe_context *context,
- const struct pipe_index_buffer *ib,
+ const struct pipe_draw_info *info,
unsigned add_transfer_flags,
int index_bias,
unsigned start,
@@ -39,10 +39,10 @@ void util_shorten_ubyte_elts_to_userptr(struct pipe_context *context,
unsigned short *out_map = out;
unsigned i;
- if (ib->user_buffer) {
- in_map = ib->user_buffer;
+ if (info->has_user_indices) {
+ in_map = info->index.user;
} else {
- in_map = pipe_buffer_map(context, ib->buffer,
+ in_map = pipe_buffer_map(context, info->index.resource,
PIPE_TRANSFER_READ |
add_transfer_flags,
&src_transfer);
@@ -62,7 +62,7 @@ void util_shorten_ubyte_elts_to_userptr(struct pipe_context *context,
/* Ushort indices. */
void util_rebuild_ushort_elts_to_userptr(struct pipe_context *context,
- const struct pipe_index_buffer *ib,
+ const struct pipe_draw_info *info,
unsigned add_transfer_flags,
int index_bias,
unsigned start, unsigned count,
@@ -73,10 +73,10 @@ void util_rebuild_ushort_elts_to_userptr(struct pipe_context *context,
unsigned short *out_map = out;
unsigned i;
- if (ib->user_buffer) {
- in_map = ib->user_buffer;
+ if (info->has_user_indices) {
+ in_map = info->index.user;
} else {
- in_map = pipe_buffer_map(context, ib->buffer,
+ in_map = pipe_buffer_map(context, info->index.resource,
PIPE_TRANSFER_READ |
add_transfer_flags,
&in_transfer);
@@ -96,7 +96,7 @@ void util_rebuild_ushort_elts_to_userptr(struct pipe_context *context,
/* Uint indices. */
void util_rebuild_uint_elts_to_userptr(struct pipe_context *context,
- const struct pipe_index_buffer *ib,
+ const struct pipe_draw_info *info,
unsigned add_transfer_flags,
int index_bias,
unsigned start, unsigned count,
@@ -107,10 +107,10 @@ void util_rebuild_uint_elts_to_userptr(struct pipe_context *context,
unsigned int *out_map = out;
unsigned i;
- if (ib->user_buffer) {
- in_map = ib->user_buffer;
+ if (info->has_user_indices) {
+ in_map = info->index.user;
} else {
- in_map = pipe_buffer_map(context, ib->buffer,
+ in_map = pipe_buffer_map(context, info->index.resource,
PIPE_TRANSFER_READ |
add_transfer_flags,
&in_transfer);
diff --git a/src/gallium/auxiliary/util/u_index_modify.h b/src/gallium/auxiliary/util/u_index_modify.h
index d009199b012..ba96725bedd 100644
--- a/src/gallium/auxiliary/util/u_index_modify.h
+++ b/src/gallium/auxiliary/util/u_index_modify.h
@@ -25,10 +25,9 @@
struct pipe_context;
struct pipe_resource;
-struct pipe_index_buffer;
void util_shorten_ubyte_elts_to_userptr(struct pipe_context *context,
- const struct pipe_index_buffer *ib,
+ const struct pipe_draw_info *info,
unsigned add_transfer_flags,
int index_bias,
unsigned start,
@@ -36,14 +35,14 @@ void util_shorten_ubyte_elts_to_userptr(struct pipe_context *context,
void *out);
void util_rebuild_ushort_elts_to_userptr(struct pipe_context *context,
- const struct pipe_index_buffer *ib,
+ const struct pipe_draw_info *info,
unsigned add_transfer_flags,
int index_bias,
unsigned start, unsigned count,
void *out);
void util_rebuild_uint_elts_to_userptr(struct pipe_context *context,
- const struct pipe_index_buffer *ib,
+ const struct pipe_draw_info *info,
unsigned add_transfer_flags,
int index_bias,
unsigned start, unsigned count,
diff --git a/src/gallium/auxiliary/util/u_prim_restart.c b/src/gallium/auxiliary/util/u_prim_restart.c
index e45aa562a4f..9ff93a7f669 100644
--- a/src/gallium/auxiliary/util/u_prim_restart.c
+++ b/src/gallium/auxiliary/util/u_prim_restart.c
@@ -39,28 +39,26 @@
*/
enum pipe_error
util_translate_prim_restart_ib(struct pipe_context *context,
- struct pipe_index_buffer *src_buffer,
- struct pipe_resource **dst_buffer,
- unsigned num_indexes,
- unsigned restart_index)
+ const struct pipe_draw_info *info,
+ struct pipe_resource **dst_buffer)
{
struct pipe_screen *screen = context->screen;
struct pipe_transfer *src_transfer = NULL, *dst_transfer = NULL;
void *src_map = NULL, *dst_map = NULL;
- const unsigned src_index_size = src_buffer->index_size;
+ const unsigned src_index_size = info->index_size;
unsigned dst_index_size;
/* 1-byte indexes are converted to 2-byte indexes, 4-byte stays 4-byte */
- dst_index_size = MAX2(2, src_buffer->index_size);
+ dst_index_size = MAX2(2, info->index_size);
assert(dst_index_size == 2 || dst_index_size == 4);
/* no user buffers for now */
- assert(src_buffer->user_buffer == NULL);
+ assert(!info->has_user_indices);
/* Create new index buffer */
*dst_buffer = pipe_buffer_create(screen, PIPE_BIND_INDEX_BUFFER,
PIPE_USAGE_STREAM,
- num_indexes * dst_index_size);
+ info->count * dst_index_size);
if (!*dst_buffer)
goto error;
@@ -71,9 +69,9 @@ util_translate_prim_restart_ib(struct pipe_context *context,
goto error;
/* Map original / src index buffer */
- src_map = pipe_buffer_map_range(context, src_buffer->buffer,
- src_buffer->offset,
- num_indexes * src_index_size,
+ src_map = pipe_buffer_map_range(context, info->index.resource,
+ info->start * src_index_size,
+ info->count * src_index_size,
PIPE_TRANSFER_READ,
&src_transfer);
if (!src_map)
@@ -83,16 +81,16 @@ util_translate_prim_restart_ib(struct pipe_context *context,
uint8_t *src = (uint8_t *) src_map;
uint16_t *dst = (uint16_t *) dst_map;
unsigned i;
- for (i = 0; i < num_indexes; i++) {
- dst[i] = (src[i] == restart_index) ? 0xffff : src[i];
+ for (i = 0; i < info->count; i++) {
+ dst[i] = (src[i] == info->restart_index) ? 0xffff : src[i];
}
}
else if (src_index_size == 2 && dst_index_size == 2) {
uint16_t *src = (uint16_t *) src_map;
uint16_t *dst = (uint16_t *) dst_map;
unsigned i;
- for (i = 0; i < num_indexes; i++) {
- dst[i] = (src[i] == restart_index) ? 0xffff : src[i];
+ for (i = 0; i < info->count; i++) {
+ dst[i] = (src[i] == info->restart_index) ? 0xffff : src[i];
}
}
else {
@@ -101,8 +99,8 @@ util_translate_prim_restart_ib(struct pipe_context *context,
unsigned i;
assert(src_index_size == 4);
assert(dst_index_size == 4);
- for (i = 0; i < num_indexes; i++) {
- dst[i] = (src[i] == restart_index) ? 0xffffffff : src[i];
+ for (i = 0; i < info->count; i++) {
+ dst[i] = (src[i] == info->restart_index) ? 0xffffffff : src[i];
}
}
@@ -177,7 +175,6 @@ add_range(struct range_info *info, unsigned start, unsigned count)
*/
enum pipe_error
util_draw_vbo_without_prim_restart(struct pipe_context *context,
- const struct pipe_index_buffer *ib,
const struct pipe_draw_info *info)
{
const void *src_map;
@@ -186,15 +183,15 @@ util_draw_vbo_without_prim_restart(struct pipe_context *context,
struct pipe_transfer *src_transfer = NULL;
unsigned i, start, count;
- assert(info->indexed);
+ assert(info->index_size);
assert(info->primitive_restart);
/* Get pointer to the index data */
- if (ib->buffer) {
+ if (!info->has_user_indices) {
/* map the index buffer (only the range we need to scan) */
- src_map = pipe_buffer_map_range(context, ib->buffer,
- ib->offset + info->start * ib->index_size,
- info->count * ib->index_size,
+ src_map = pipe_buffer_map_range(context, info->index.resource,
+ info->start * info->index_size,
+ info->count * info->index_size,
PIPE_TRANSFER_READ,
&src_transfer);
if (!src_map) {
@@ -202,13 +199,12 @@ util_draw_vbo_without_prim_restart(struct pipe_context *context,
}
}
else {
- if (!ib->user_buffer) {
+ if (!info->index.user) {
debug_printf("User-space index buffer is null!");
return PIPE_ERROR_BAD_INPUT;
}
- src_map = (const uint8_t *) ib->user_buffer
- + ib->offset
- + info->start * ib->index_size;
+ src_map = (const uint8_t *) info->index.user
+ + info->start * info->index_size;
}
#define SCAN_INDEXES(TYPE) \
@@ -231,9 +227,9 @@ util_draw_vbo_without_prim_restart(struct pipe_context *context,
} \
}
- start = info->start;
+ start = 0;
count = 0;
- switch (ib->index_size) {
+ switch (info->index_size) {
case 1:
SCAN_INDEXES(uint8_t);
break;
diff --git a/src/gallium/auxiliary/util/u_prim_restart.h b/src/gallium/auxiliary/util/u_prim_restart.h
index 1e98e0e1b22..0e17ce5eb1a 100644
--- a/src/gallium/auxiliary/util/u_prim_restart.h
+++ b/src/gallium/auxiliary/util/u_prim_restart.h
@@ -38,20 +38,17 @@ extern "C" {
struct pipe_context;
struct pipe_draw_info;
-struct pipe_index_buffer;
+union pipe_index_binding;
struct pipe_resource;
enum pipe_error
util_translate_prim_restart_ib(struct pipe_context *context,
- struct pipe_index_buffer *src_buffer,
- struct pipe_resource **dst_buffer,
- unsigned num_indexes,
- unsigned restart_index);
+ const struct pipe_draw_info *info,
+ struct pipe_resource **dst_buffer);
enum pipe_error
util_draw_vbo_without_prim_restart(struct pipe_context *context,
- const struct pipe_index_buffer *ib,
const struct pipe_draw_info *info);
diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c
index 9d6d5297e6a..8361e649ff4 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -162,9 +162,6 @@ struct u_vbuf {
uint32_t dirty_real_vb_mask; /* which buffers are dirty since the last
call of set_vertex_buffers */
- /* The index buffer. */
- struct pipe_index_buffer index_buffer;
-
/* Vertex elements. */
struct u_vbuf_elements *ve, *ve_saved;
@@ -372,9 +369,6 @@ void u_vbuf_destroy(struct u_vbuf *mgr)
unsigned num_vb = screen->get_shader_param(screen, PIPE_SHADER_VERTEX,
PIPE_SHADER_CAP_MAX_INPUTS);
- mgr->pipe->set_index_buffer(mgr->pipe, NULL);
- pipe_resource_reference(&mgr->index_buffer.buffer, NULL);
-
mgr->pipe->set_vertex_buffers(mgr->pipe, 0, num_vb, NULL);
for (i = 0; i < PIPE_MAX_ATTRIBS; i++)
@@ -391,10 +385,10 @@ void u_vbuf_destroy(struct u_vbuf *mgr)
static enum pipe_error
u_vbuf_translate_buffers(struct u_vbuf *mgr, struct translate_key *key,
+ const struct pipe_draw_info *info,
unsigned vb_mask, unsigned out_vb,
int start_vertex, unsigned num_vertices,
- int start_index, unsigned num_indices, int min_index,
- boolean unroll_indices)
+ int min_index, boolean unroll_indices)
{
struct translate *tr;
struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS] = {0};
@@ -440,38 +434,35 @@ u_vbuf_translate_buffers(struct u_vbuf *mgr, struct translate_key *key,
/* Translate. */
if (unroll_indices) {
- struct pipe_index_buffer *ib = &mgr->index_buffer;
struct pipe_transfer *transfer = NULL;
- unsigned offset = ib->offset + start_index * ib->index_size;
+ unsigned offset = info->start * info->index_size;
uint8_t *map;
- assert((ib->buffer || ib->user_buffer) && ib->index_size);
-
/* Create and map the output buffer. */
u_upload_alloc(mgr->pipe->stream_uploader, 0,
- key->output_stride * num_indices, 4,
+ key->output_stride * info->count, 4,
&out_offset, &out_buffer,
(void**)&out_map);
if (!out_buffer)
return PIPE_ERROR_OUT_OF_MEMORY;
- if (ib->user_buffer) {
- map = (uint8_t*)ib->user_buffer + offset;
+ if (info->has_user_indices) {
+ map = (uint8_t*)info->index.user + offset;
} else {
- map = pipe_buffer_map_range(mgr->pipe, ib->buffer, offset,
- num_indices * ib->index_size,
+ map = pipe_buffer_map_range(mgr->pipe, info->index.resource, offset,
+ info->count * info->index_size,
PIPE_TRANSFER_READ, &transfer);
}
- switch (ib->index_size) {
+ switch (info->index_size) {
case 4:
- tr->run_elts(tr, (unsigned*)map, num_indices, 0, 0, out_map);
+ tr->run_elts(tr, (unsigned*)map, info->count, 0, 0, out_map);
break;
case 2:
- tr->run_elts16(tr, (uint16_t*)map, num_indices, 0, 0, out_map);
+ tr->run_elts16(tr, (uint16_t*)map, info->count, 0, 0, out_map);
break;
case 1:
- tr->run_elts8(tr, map, num_indices, 0, 0, out_map);
+ tr->run_elts8(tr, map, info->count, 0, 0, out_map);
break;
}
@@ -556,10 +547,9 @@ u_vbuf_translate_find_free_vb_slots(struct u_vbuf *mgr,
static boolean
u_vbuf_translate_begin(struct u_vbuf *mgr,
+ const struct pipe_draw_info *info,
int start_vertex, unsigned num_vertices,
- int start_instance, unsigned num_instances,
- int start_index, unsigned num_indices, int min_index,
- boolean unroll_indices)
+ int min_index, boolean unroll_indices)
{
unsigned mask[VB_NUM] = {0};
struct translate_key key[VB_NUM];
@@ -569,15 +559,15 @@ u_vbuf_translate_begin(struct u_vbuf *mgr,
mgr->ve->used_vb_mask;
int start[VB_NUM] = {
- start_vertex, /* VERTEX */
- start_instance, /* INSTANCE */
- 0 /* CONST */
+ start_vertex, /* VERTEX */
+ info->start_instance, /* INSTANCE */
+ 0 /* CONST */
};
unsigned num[VB_NUM] = {
- num_vertices, /* VERTEX */
- num_instances, /* INSTANCE */
- 1 /* CONST */
+ num_vertices, /* VERTEX */
+ info->instance_count, /* INSTANCE */
+ 1 /* CONST */
};
memset(key, 0, sizeof(key));
@@ -664,10 +654,9 @@ u_vbuf_translate_begin(struct u_vbuf *mgr,
for (type = 0; type < VB_NUM; type++) {
if (key[type].nr_elements) {
enum pipe_error err;
- err = u_vbuf_translate_buffers(mgr, &key[type], mask[type],
+ err = u_vbuf_translate_buffers(mgr, &key[type], info, mask[type],
mgr->fallback_vbs[type],
- start[type], num[type],
- start_index, num_indices, min_index,
+ start[type], num[type], min_index,
unroll_indices && type == VB_VERTEX);
if (err != PIPE_OK)
return FALSE;
@@ -889,22 +878,6 @@ void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr,
mgr->dirty_real_vb_mask |= ~mask;
}
-void u_vbuf_set_index_buffer(struct u_vbuf *mgr,
- const struct pipe_index_buffer *ib)
-{
- struct pipe_context *pipe = mgr->pipe;
-
- if (ib) {
- assert(ib->offset % ib->index_size == 0);
- pipe_resource_reference(&mgr->index_buffer.buffer, ib->buffer);
- memcpy(&mgr->index_buffer, ib, sizeof(*ib));
- } else {
- pipe_resource_reference(&mgr->index_buffer.buffer, NULL);
- }
-
- pipe->set_index_buffer(pipe, ib);
-}
-
static enum pipe_error
u_vbuf_upload_buffers(struct u_vbuf *mgr,
int start_vertex, unsigned num_vertices,
@@ -1023,42 +996,38 @@ static boolean u_vbuf_mapping_vertex_buffer_blocks(const struct u_vbuf *mgr)
}
static void u_vbuf_get_minmax_index(struct pipe_context *pipe,
- struct pipe_index_buffer *ib,
- boolean primitive_restart,
- unsigned restart_index,
- unsigned start, unsigned count,
- int *out_min_index,
- int *out_max_index)
+ const struct pipe_draw_info *info,
+ int *out_min_index, int *out_max_index)
{
struct pipe_transfer *transfer = NULL;
const void *indices;
unsigned i;
- if (ib->user_buffer) {
- indices = (uint8_t*)ib->user_buffer +
- ib->offset + start * ib->index_size;
+ if (info->has_user_indices) {
+ indices = (uint8_t*)info->index.user +
+ info->start * info->index_size;
} else {
- indices = pipe_buffer_map_range(pipe, ib->buffer,
- ib->offset + start * ib->index_size,
- count * ib->index_size,
+ indices = pipe_buffer_map_range(pipe, info->index.resource,
+ info->start * info->index_size,
+ info->count * info->index_size,
PIPE_TRANSFER_READ, &transfer);
}
- switch (ib->index_size) {
+ switch (info->index_size) {
case 4: {
const unsigned *ui_indices = (const unsigned*)indices;
unsigned max_ui = 0;
unsigned min_ui = ~0U;
- if (primitive_restart) {
- for (i = 0; i < count; i++) {
- if (ui_indices[i] != restart_index) {
+ if (info->primitive_restart) {
+ for (i = 0; i < info->count; i++) {
+ if (ui_indices[i] != info->restart_index) {
if (ui_indices[i] > max_ui) max_ui = ui_indices[i];
if (ui_indices[i] < min_ui) min_ui = ui_indices[i];
}
}
}
else {
- for (i = 0; i < count; i++) {
+ for (i = 0; i < info->count; i++) {
if (ui_indices[i] > max_ui) max_ui = ui_indices[i];
if (ui_indices[i] < min_ui) min_ui = ui_indices[i];
}
@@ -1071,16 +1040,16 @@ static void u_vbuf_get_minmax_index(struct pipe_context *pipe,
const unsigned short *us_indices = (const unsigned short*)indices;
unsigned max_us = 0;
unsigned min_us = ~0U;
- if (primitive_restart) {
- for (i = 0; i < count; i++) {
- if (us_indices[i] != restart_index) {
+ if (info->primitive_restart) {
+ for (i = 0; i < info->count; i++) {
+ if (us_indices[i] != info->restart_index) {
if (us_indices[i] > max_us) max_us = us_indices[i];
if (us_indices[i] < min_us) min_us = us_indices[i];
}
}
}
else {
- for (i = 0; i < count; i++) {
+ for (i = 0; i < info->count; i++) {
if (us_indices[i] > max_us) max_us = us_indices[i];
if (us_indices[i] < min_us) min_us = us_indices[i];
}
@@ -1093,16 +1062,16 @@ static void u_vbuf_get_minmax_index(struct pipe_context *pipe,
const unsigned char *ub_indices = (const unsigned char*)indices;
unsigned max_ub = 0;
unsigned min_ub = ~0U;
- if (primitive_restart) {
- for (i = 0; i < count; i++) {
- if (ub_indices[i] != restart_index) {
+ if (info->primitive_restart) {
+ for (i = 0; i < info->count; i++) {
+ if (ub_indices[i] != info->restart_index) {
if (ub_indices[i] > max_ub) max_ub = ub_indices[i];
if (ub_indices[i] < min_ub) min_ub = ub_indices[i];
}
}
}
else {
- for (i = 0; i < count; i++) {
+ for (i = 0; i < info->count; i++) {
if (ub_indices[i] > max_ub) max_ub = ub_indices[i];
if (ub_indices[i] < min_ub) min_ub = ub_indices[i];
}
@@ -1167,7 +1136,7 @@ void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info)
struct pipe_transfer *transfer = NULL;
int *data;
- if (new_info.indexed) {
+ if (new_info.index_size) {
data = pipe_buffer_map_range(pipe, new_info.indirect->buffer,
new_info.indirect->offset, 20,
PIPE_TRANSFER_READ, &transfer);
@@ -1188,7 +1157,7 @@ void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info)
new_info.indirect = NULL;
}
- if (new_info.indexed) {
+ if (new_info.index_size) {
/* See if anything needs to be done for per-vertex attribs. */
if (u_vbuf_need_minmax_index(mgr)) {
int max_index;
@@ -1197,10 +1166,8 @@ void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info)
min_index = new_info.min_index;
max_index = new_info.max_index;
} else {
- u_vbuf_get_minmax_index(mgr->pipe, &mgr->index_buffer,
- new_info.primitive_restart,
- new_info.restart_index, new_info.start,
- new_info.count, &min_index, &max_index);
+ u_vbuf_get_minmax_index(mgr->pipe, &new_info,
+ &min_index, &max_index);
}
assert(min_index <= max_index);
@@ -1236,16 +1203,14 @@ void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info)
if (unroll_indices ||
incompatible_vb_mask ||
mgr->ve->incompatible_elem_mask) {
- if (!u_vbuf_translate_begin(mgr, start_vertex, num_vertices,
- new_info.start_instance,
- new_info.instance_count, new_info.start,
- new_info.count, min_index, unroll_indices)) {
+ if (!u_vbuf_translate_begin(mgr, &new_info, start_vertex, num_vertices,
+ min_index, unroll_indices)) {
debug_warn_once("u_vbuf_translate_begin() failed");
return;
}
if (unroll_indices) {
- new_info.indexed = FALSE;
+ new_info.index_size = 0;
new_info.index_bias = 0;
new_info.min_index = 0;
new_info.max_index = new_info.count - 1;
diff --git a/src/gallium/auxiliary/util/u_vbuf.h b/src/gallium/auxiliary/util/u_vbuf.h
index ddfa844d27f..d0704524561 100644
--- a/src/gallium/auxiliary/util/u_vbuf.h
+++ b/src/gallium/auxiliary/util/u_vbuf.h
@@ -72,8 +72,6 @@ void u_vbuf_set_vertex_elements(struct u_vbuf *mgr, unsigned count,
void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr,
unsigned start_slot, unsigned count,
const struct pipe_vertex_buffer *bufs);
-void u_vbuf_set_index_buffer(struct u_vbuf *mgr,
- const struct pipe_index_buffer *ib);
void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info);
/* Save/restore functionality. */