Commit 1cd455b1 authored by Marek Olšák's avatar Marek Olšák Committed by Marge Bot

gallium: extend draw_vbo to support multi draws

Essentially rename multi_draw to draw_vbo and remove start and count
from pipe_draw_info.

This is only an interface change. It doesn't add multi draw support
anywhere.
Acked-by: Pierre-Eric Pelloux-Prayer's avatarPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <!7441>
parent 80b39107
...@@ -1723,7 +1723,8 @@ cso_restore_state(struct cso_context *cso) ...@@ -1723,7 +1723,8 @@ cso_restore_state(struct cso_context *cso)
void void
cso_draw_vbo(struct cso_context *cso, cso_draw_vbo(struct cso_context *cso,
const struct pipe_draw_info *info, const struct pipe_draw_info *info,
const struct pipe_draw_indirect_info *indirect) const struct pipe_draw_indirect_info *indirect,
const struct pipe_draw_start_count draw)
{ {
struct u_vbuf *vbuf = cso->vbuf_current; struct u_vbuf *vbuf = cso->vbuf_current;
...@@ -1738,10 +1739,10 @@ cso_draw_vbo(struct cso_context *cso, ...@@ -1738,10 +1739,10 @@ cso_draw_vbo(struct cso_context *cso,
indirect->count_from_stream_output == NULL); indirect->count_from_stream_output == NULL);
if (vbuf) { if (vbuf) {
u_vbuf_draw_vbo(vbuf, info, indirect); u_vbuf_draw_vbo(vbuf, info, indirect, draw);
} else { } else {
struct pipe_context *pipe = cso->pipe; struct pipe_context *pipe = cso->pipe;
pipe->draw_vbo(pipe, info, indirect); pipe->draw_vbo(pipe, info, indirect, &draw, 1);
} }
} }
...@@ -1749,16 +1750,18 @@ void ...@@ -1749,16 +1750,18 @@ void
cso_draw_arrays(struct cso_context *cso, uint mode, uint start, uint count) cso_draw_arrays(struct cso_context *cso, uint mode, uint start, uint count)
{ {
struct pipe_draw_info info; struct pipe_draw_info info;
struct pipe_draw_start_count draw;
util_draw_init_info(&info); util_draw_init_info(&info);
info.mode = mode; info.mode = mode;
info.start = start;
info.count = count;
info.min_index = start; info.min_index = start;
info.max_index = start + count - 1; info.max_index = start + count - 1;
cso_draw_vbo(cso, &info, NULL); draw.start = start;
draw.count = count;
cso_draw_vbo(cso, &info, NULL, draw);
} }
void void
...@@ -1767,16 +1770,18 @@ cso_draw_arrays_instanced(struct cso_context *cso, uint mode, ...@@ -1767,16 +1770,18 @@ cso_draw_arrays_instanced(struct cso_context *cso, uint mode,
uint start_instance, uint instance_count) uint start_instance, uint instance_count)
{ {
struct pipe_draw_info info; struct pipe_draw_info info;
struct pipe_draw_start_count draw;
util_draw_init_info(&info); util_draw_init_info(&info);
info.mode = mode; info.mode = mode;
info.start = start;
info.count = count;
info.min_index = start; info.min_index = start;
info.max_index = start + count - 1; info.max_index = start + count - 1;
info.start_instance = start_instance; info.start_instance = start_instance;
info.instance_count = instance_count; info.instance_count = instance_count;
cso_draw_vbo(cso, &info, NULL); draw.start = start;
draw.count = count;
cso_draw_vbo(cso, &info, NULL, draw);
} }
...@@ -218,7 +218,8 @@ cso_set_vertex_buffers_and_elements(struct cso_context *ctx, ...@@ -218,7 +218,8 @@ cso_set_vertex_buffers_and_elements(struct cso_context *ctx,
void void
cso_draw_vbo(struct cso_context *cso, cso_draw_vbo(struct cso_context *cso,
const struct pipe_draw_info *info, const struct pipe_draw_info *info,
const struct pipe_draw_indirect_info *indirect); const struct pipe_draw_indirect_info *indirect,
const struct pipe_draw_start_count draw);
void void
cso_draw_arrays_instanced(struct cso_context *cso, uint mode, cso_draw_arrays_instanced(struct cso_context *cso, uint mode,
......
...@@ -324,7 +324,9 @@ draw_set_mapped_so_targets(struct draw_context *draw, ...@@ -324,7 +324,9 @@ draw_set_mapped_so_targets(struct draw_context *draw,
void draw_vbo(struct draw_context *draw, void draw_vbo(struct draw_context *draw,
const struct pipe_draw_info *info, const struct pipe_draw_info *info,
const struct pipe_draw_indirect_info *indirect); const struct pipe_draw_indirect_info *indirect,
const struct pipe_draw_start_count *draws,
unsigned num_draws);
/******************************************************************************* /*******************************************************************************
......
...@@ -382,11 +382,12 @@ draw_print_arrays(struct draw_context *draw, uint prim, int start, uint count) ...@@ -382,11 +382,12 @@ draw_print_arrays(struct draw_context *draw, uint prim, int start, uint count)
*/ */
static void static void
draw_pt_arrays_restart(struct draw_context *draw, draw_pt_arrays_restart(struct draw_context *draw,
const struct pipe_draw_info *info) const struct pipe_draw_info *info,
const struct pipe_draw_start_count *draw_info)
{ {
const unsigned prim = info->mode; const unsigned prim = info->mode;
const unsigned start = info->start; const unsigned start = draw_info->start;
const unsigned count = info->count; const unsigned count = draw_info->count;
const unsigned elt_max = draw->pt.user.eltMax; const unsigned elt_max = draw->pt.user.eltMax;
unsigned i, j, cur_start, cur_count; unsigned i, j, cur_start, cur_count;
/* The largest index within a loop using the i variable as the index. /* The largest index within a loop using the i variable as the index.
...@@ -441,21 +442,24 @@ draw_pt_arrays_restart(struct draw_context *draw, ...@@ -441,21 +442,24 @@ draw_pt_arrays_restart(struct draw_context *draw,
static void static void
resolve_draw_info(const struct pipe_draw_info *raw_info, resolve_draw_info(const struct pipe_draw_info *raw_info,
const struct pipe_draw_indirect_info *indirect, const struct pipe_draw_indirect_info *indirect,
const struct pipe_draw_start_count *raw_draw,
struct pipe_draw_info *info, struct pipe_draw_info *info,
struct pipe_draw_start_count *draw,
struct pipe_vertex_buffer *vertex_buffer) struct pipe_vertex_buffer *vertex_buffer)
{ {
memcpy(info, raw_info, sizeof(struct pipe_draw_info)); memcpy(info, raw_info, sizeof(struct pipe_draw_info));
memcpy(draw, raw_draw, sizeof(struct pipe_draw_start_count));
if (indirect && indirect->count_from_stream_output) { if (indirect && indirect->count_from_stream_output) {
struct draw_so_target *target = struct draw_so_target *target =
(struct draw_so_target *)indirect->count_from_stream_output; (struct draw_so_target *)indirect->count_from_stream_output;
assert(vertex_buffer != NULL); assert(vertex_buffer != NULL);
info->count = vertex_buffer->stride == 0 ? 0 : draw->count = vertex_buffer->stride == 0 ? 0 :
target->internal_offset / vertex_buffer->stride; target->internal_offset / vertex_buffer->stride;
/* Stream output draw can not be indexed */ /* Stream output draw can not be indexed */
debug_assert(!info->index_size); debug_assert(!info->index_size);
info->max_index = info->count - 1; info->max_index = draw->count - 1;
} }
} }
...@@ -468,13 +472,16 @@ resolve_draw_info(const struct pipe_draw_info *raw_info, ...@@ -468,13 +472,16 @@ resolve_draw_info(const struct pipe_draw_info *raw_info,
void void
draw_vbo(struct draw_context *draw, draw_vbo(struct draw_context *draw,
const struct pipe_draw_info *info, const struct pipe_draw_info *info,
const struct pipe_draw_indirect_info *indirect) const struct pipe_draw_indirect_info *indirect,
const struct pipe_draw_start_count *draws,
unsigned num_draws)
{ {
unsigned instance; unsigned instance;
unsigned index_limit; unsigned index_limit;
unsigned count; unsigned count;
unsigned fpstate = util_fpstate_get(); unsigned fpstate = util_fpstate_get();
struct pipe_draw_info resolved_info; struct pipe_draw_info resolved_info;
struct pipe_draw_start_count resolved_draw;
if (info->instance_count == 0) if (info->instance_count == 0)
return; return;
...@@ -484,13 +491,16 @@ draw_vbo(struct draw_context *draw, ...@@ -484,13 +491,16 @@ draw_vbo(struct draw_context *draw,
*/ */
util_fpstate_set_denorms_to_zero(fpstate); util_fpstate_set_denorms_to_zero(fpstate);
resolve_draw_info(info, indirect, &resolved_info, &(draw->pt.vertex_buffer[0])); resolve_draw_info(info, indirect, &draws[0], &resolved_info,
&resolved_draw, &(draw->pt.vertex_buffer[0]));
info = &resolved_info; info = &resolved_info;
draws = &resolved_draw;
num_draws = 1;
if (info->index_size) if (info->index_size)
assert(draw->pt.user.elts); assert(draw->pt.user.elts);
count = info->count; count = draws[0].count;
draw->pt.user.eltBias = info->index_bias; draw->pt.user.eltBias = info->index_bias;
draw->pt.user.min_index = info->min_index; draw->pt.user.min_index = info->min_index;
...@@ -502,7 +512,7 @@ draw_vbo(struct draw_context *draw, ...@@ -502,7 +512,7 @@ draw_vbo(struct draw_context *draw,
if (0) if (0)
debug_printf("draw_vbo(mode=%u start=%u count=%u):\n", debug_printf("draw_vbo(mode=%u start=%u count=%u):\n",
info->mode, info->start, count); info->mode, draws[0].start, count);
if (0) if (0)
tgsi_dump(draw->vs.vertex_shader->state.tokens, 0); tgsi_dump(draw->vs.vertex_shader->state.tokens, 0);
...@@ -530,7 +540,7 @@ draw_vbo(struct draw_context *draw, ...@@ -530,7 +540,7 @@ draw_vbo(struct draw_context *draw,
} }
if (0) if (0)
draw_print_arrays(draw, info->mode, info->start, MIN2(count, 20)); draw_print_arrays(draw, info->mode, draws[0].start, MIN2(count, 20));
index_limit = util_draw_max_index(draw->pt.vertex_buffer, index_limit = util_draw_max_index(draw->pt.vertex_buffer,
draw->pt.vertex_element, draw->pt.vertex_element,
...@@ -554,7 +564,7 @@ draw_vbo(struct draw_context *draw, ...@@ -554,7 +564,7 @@ draw_vbo(struct draw_context *draw,
} }
draw->pt.max_index = index_limit - 1; draw->pt.max_index = index_limit - 1;
draw->start_index = info->start; draw->start_index = draws[0].start;
/* /*
* TODO: We could use draw->pt.max_index to further narrow * TODO: We could use draw->pt.max_index to further narrow
...@@ -575,10 +585,10 @@ draw_vbo(struct draw_context *draw, ...@@ -575,10 +585,10 @@ draw_vbo(struct draw_context *draw,
draw_new_instance(draw); draw_new_instance(draw);
if (info->primitive_restart) { if (info->primitive_restart) {
draw_pt_arrays_restart(draw, info); draw_pt_arrays_restart(draw, info, &draws[0]);
} }
else { else {
draw_pt_arrays(draw, info->mode, info->start, count); draw_pt_arrays(draw, info->mode, draws[0].start, count);
} }
} }
......
...@@ -352,11 +352,13 @@ dd_dump_flush(struct dd_draw_state *dstate, struct call_flush *info, FILE *f) ...@@ -352,11 +352,13 @@ dd_dump_flush(struct dd_draw_state *dstate, struct call_flush *info, FILE *f)
static void static void
dd_dump_draw_vbo(struct dd_draw_state *dstate, struct pipe_draw_info *info, dd_dump_draw_vbo(struct dd_draw_state *dstate, struct pipe_draw_info *info,
const struct pipe_draw_indirect_info *indirect, FILE *f) const struct pipe_draw_indirect_info *indirect,
const struct pipe_draw_start_count *draw, FILE *f)
{ {
int sh, i; int sh, i;
DUMP(draw_info, info); DUMP(draw_info, info);
DUMP(draw_start_count, draw);
if (indirect) { if (indirect) {
if (indirect->buffer) if (indirect->buffer)
DUMP_M(resource, indirect, buffer); DUMP_M(resource, indirect, buffer);
...@@ -633,8 +635,9 @@ dd_dump_call(FILE *f, struct dd_draw_state *state, struct dd_call *call) ...@@ -633,8 +635,9 @@ dd_dump_call(FILE *f, struct dd_draw_state *state, struct dd_call *call)
dd_dump_flush(state, &call->info.flush, f); dd_dump_flush(state, &call->info.flush, f);
break; break;
case CALL_DRAW_VBO: case CALL_DRAW_VBO:
dd_dump_draw_vbo(state, &call->info.draw_vbo.draw, dd_dump_draw_vbo(state, &call->info.draw_vbo.info,
&call->info.draw_vbo.indirect, f); &call->info.draw_vbo.indirect,
&call->info.draw_vbo.draw, f);
break; break;
case CALL_LAUNCH_GRID: case CALL_LAUNCH_GRID:
dd_dump_launch_grid(state, &call->info.launch_grid, f); dd_dump_launch_grid(state, &call->info.launch_grid, f);
...@@ -710,11 +713,11 @@ dd_unreference_copy_of_call(struct dd_call *dst) ...@@ -710,11 +713,11 @@ dd_unreference_copy_of_call(struct dd_call *dst)
pipe_so_target_reference(&dst->info.draw_vbo.indirect.count_from_stream_output, NULL); pipe_so_target_reference(&dst->info.draw_vbo.indirect.count_from_stream_output, NULL);
pipe_resource_reference(&dst->info.draw_vbo.indirect.buffer, NULL); pipe_resource_reference(&dst->info.draw_vbo.indirect.buffer, NULL);
pipe_resource_reference(&dst->info.draw_vbo.indirect.indirect_draw_count, NULL); pipe_resource_reference(&dst->info.draw_vbo.indirect.indirect_draw_count, NULL);
if (dst->info.draw_vbo.draw.index_size && if (dst->info.draw_vbo.info.index_size &&
!dst->info.draw_vbo.draw.has_user_indices) !dst->info.draw_vbo.info.has_user_indices)
pipe_resource_reference(&dst->info.draw_vbo.draw.index.resource, NULL); pipe_resource_reference(&dst->info.draw_vbo.info.index.resource, NULL);
else else
dst->info.draw_vbo.draw.index.user = NULL; dst->info.draw_vbo.info.index.user = NULL;
break; break;
case CALL_LAUNCH_GRID: case CALL_LAUNCH_GRID:
pipe_resource_reference(&dst->info.launch_grid.indirect, NULL); pipe_resource_reference(&dst->info.launch_grid.indirect, NULL);
...@@ -1300,17 +1303,20 @@ dd_context_flush(struct pipe_context *_pipe, ...@@ -1300,17 +1303,20 @@ dd_context_flush(struct pipe_context *_pipe,
static void static void
dd_context_draw_vbo(struct pipe_context *_pipe, dd_context_draw_vbo(struct pipe_context *_pipe,
const struct pipe_draw_info *info, const struct pipe_draw_info *info,
const struct pipe_draw_indirect_info *indirect) const struct pipe_draw_indirect_info *indirect,
const struct pipe_draw_start_count *draws,
unsigned num_draws)
{ {
struct dd_context *dctx = dd_context(_pipe); struct dd_context *dctx = dd_context(_pipe);
struct pipe_context *pipe = dctx->pipe; struct pipe_context *pipe = dctx->pipe;
struct dd_draw_record *record = dd_create_record(dctx); struct dd_draw_record *record = dd_create_record(dctx);
record->call.type = CALL_DRAW_VBO; record->call.type = CALL_DRAW_VBO;
record->call.info.draw_vbo.draw = *info; record->call.info.draw_vbo.info = *info;
record->call.info.draw_vbo.draw = draws[0];
if (info->index_size && !info->has_user_indices) { if (info->index_size && !info->has_user_indices) {
record->call.info.draw_vbo.draw.index.resource = NULL; record->call.info.draw_vbo.info.index.resource = NULL;
pipe_resource_reference(&record->call.info.draw_vbo.draw.index.resource, pipe_resource_reference(&record->call.info.draw_vbo.info.index.resource,
info->index.resource); info->index.resource);
} }
...@@ -1330,7 +1336,7 @@ dd_context_draw_vbo(struct pipe_context *_pipe, ...@@ -1330,7 +1336,7 @@ dd_context_draw_vbo(struct pipe_context *_pipe,
} }
dd_before_draw(dctx, record); dd_before_draw(dctx, record);
pipe->draw_vbo(pipe, info, indirect); pipe->draw_vbo(pipe, info, indirect, draws, num_draws);
dd_after_draw(dctx, record); dd_after_draw(dctx, record);
} }
......
...@@ -122,8 +122,9 @@ struct call_flush { ...@@ -122,8 +122,9 @@ struct call_flush {
}; };
struct call_draw_info { struct call_draw_info {
struct pipe_draw_info draw; struct pipe_draw_info info;
struct pipe_draw_indirect_info indirect; struct pipe_draw_indirect_info indirect;
struct pipe_draw_start_count draw;
}; };
struct call_get_query_result_resource { struct call_get_query_result_resource {
......
...@@ -31,7 +31,9 @@ ...@@ -31,7 +31,9 @@
#include "util/u_transfer.h" #include "util/u_transfer.h"
static void noop_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info, static void noop_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info,
const struct pipe_draw_indirect_info *indirect) const struct pipe_draw_indirect_info *indirect,
const struct pipe_draw_start_count *draws,
unsigned num_draws)
{ {
} }
......
...@@ -115,7 +115,9 @@ rbug_draw_block_locked(struct rbug_context *rb_pipe, int flag) ...@@ -115,7 +115,9 @@ rbug_draw_block_locked(struct rbug_context *rb_pipe, int flag)
static void static void
rbug_draw_vbo(struct pipe_context *_pipe, const struct pipe_draw_info *_info, rbug_draw_vbo(struct pipe_context *_pipe, const struct pipe_draw_info *_info,
const struct pipe_draw_indirect_info *_indirect) const struct pipe_draw_indirect_info *_indirect,
const struct pipe_draw_start_count *draws,
unsigned num_draws)
{ {
struct rbug_context *rb_pipe = rbug_context(_pipe); struct rbug_context *rb_pipe = rbug_context(_pipe);
struct pipe_context *pipe = rb_pipe->pipe; struct pipe_context *pipe = rb_pipe->pipe;
...@@ -133,7 +135,7 @@ rbug_draw_vbo(struct pipe_context *_pipe, const struct pipe_draw_info *_info, ...@@ -133,7 +135,7 @@ rbug_draw_vbo(struct pipe_context *_pipe, const struct pipe_draw_info *_info,
if (!(rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT] && rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT]->disabled) && if (!(rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT] && rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT]->disabled) &&
!(rb_pipe->curr.shader[PIPE_SHADER_GEOMETRY] && rb_pipe->curr.shader[PIPE_SHADER_GEOMETRY]->disabled) && !(rb_pipe->curr.shader[PIPE_SHADER_GEOMETRY] && rb_pipe->curr.shader[PIPE_SHADER_GEOMETRY]->disabled) &&
!(rb_pipe->curr.shader[PIPE_SHADER_VERTEX] && rb_pipe->curr.shader[PIPE_SHADER_VERTEX]->disabled)) !(rb_pipe->curr.shader[PIPE_SHADER_VERTEX] && rb_pipe->curr.shader[PIPE_SHADER_VERTEX]->disabled))
pipe->draw_vbo(pipe, &info, _indirect); pipe->draw_vbo(pipe, &info, _indirect, draws, num_draws);
mtx_unlock(&rb_pipe->call_mutex); mtx_unlock(&rb_pipe->call_mutex);
rbug_draw_block_locked(rb_pipe, RBUG_BLOCK_AFTER); rbug_draw_block_locked(rb_pipe, RBUG_BLOCK_AFTER);
......
...@@ -90,7 +90,9 @@ trace_surface_unwrap(struct trace_context *tr_ctx, ...@@ -90,7 +90,9 @@ trace_surface_unwrap(struct trace_context *tr_ctx,
static void static void
trace_context_draw_vbo(struct pipe_context *_pipe, trace_context_draw_vbo(struct pipe_context *_pipe,
const struct pipe_draw_info *info, const struct pipe_draw_info *info,
const struct pipe_draw_indirect_info *indirect) const struct pipe_draw_indirect_info *indirect,
const struct pipe_draw_start_count *draws,
unsigned num_draws)
{ {
struct trace_context *tr_ctx = trace_context(_pipe); struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe; struct pipe_context *pipe = tr_ctx->pipe;
...@@ -100,10 +102,12 @@ trace_context_draw_vbo(struct pipe_context *_pipe, ...@@ -100,10 +102,12 @@ trace_context_draw_vbo(struct pipe_context *_pipe,
trace_dump_arg(ptr, pipe); trace_dump_arg(ptr, pipe);
trace_dump_arg(draw_info, info); trace_dump_arg(draw_info, info);
trace_dump_arg(draw_indirect_info, indirect); trace_dump_arg(draw_indirect_info, indirect);
trace_dump_struct_array(draw_start_count, draws, num_draws);
trace_dump_arg(uint, num_draws);
trace_dump_trace_flush(); trace_dump_trace_flush();
pipe->draw_vbo(pipe, info, indirect); pipe->draw_vbo(pipe, info, indirect, draws, num_draws);
trace_dump_call_end(); trace_dump_call_end();
} }
......
...@@ -775,11 +775,7 @@ void trace_dump_draw_info(const struct pipe_draw_info *state) ...@@ -775,11 +775,7 @@ void trace_dump_draw_info(const struct pipe_draw_info *state)
trace_dump_member(uint, state, index_size); trace_dump_member(uint, state, index_size);
trace_dump_member(uint, state, has_user_indices); trace_dump_member(uint, state, has_user_indices);
trace_dump_member(uint, state, mode); trace_dump_member(uint, state, mode);
trace_dump_member(uint, state, start);
trace_dump_member(uint, state, count);
trace_dump_member(uint, state, start_instance); trace_dump_member(uint, state, start_instance);
trace_dump_member(uint, state, instance_count); trace_dump_member(uint, state, instance_count);
...@@ -796,6 +792,17 @@ void trace_dump_draw_info(const struct pipe_draw_info *state) ...@@ -796,6 +792,17 @@ void trace_dump_draw_info(const struct pipe_draw_info *state)
trace_dump_struct_end(); trace_dump_struct_end();
} }
void trace_dump_draw_start_count(const struct pipe_draw_start_count *state)
{
if (!trace_dumping_enabled_locked())
return;
trace_dump_struct_begin("pipe_draw_start_count");
trace_dump_member(uint, state, start);
trace_dump_member(uint, state, count);
trace_dump_struct_end();
}
void trace_dump_draw_indirect_info(const struct pipe_draw_indirect_info *state) void trace_dump_draw_indirect_info(const struct pipe_draw_indirect_info *state)