svga: Remove redundant svga_draw_range_elements.
That is, implement draw_vbo directly. As a result, svga_swtnl_draw_range_elements is also replaced by svga_swtnl_draw_vbo. This commit should not have any functional change.
This commit is contained in:
@@ -146,23 +146,15 @@ retry:
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
svga_draw_range_elements( struct pipe_context *pipe,
|
||||
struct pipe_resource *index_buffer,
|
||||
unsigned index_size,
|
||||
int index_bias,
|
||||
unsigned min_index,
|
||||
unsigned max_index,
|
||||
unsigned prim, unsigned start, unsigned count)
|
||||
svga_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
|
||||
{
|
||||
struct svga_context *svga = svga_context( pipe );
|
||||
unsigned reduced_prim = u_reduced_prim(prim);
|
||||
unsigned reduced_prim = u_reduced_prim( info->mode );
|
||||
unsigned count = info->count;
|
||||
enum pipe_error ret = 0;
|
||||
|
||||
if (!u_trim_pipe_prim( prim, &count ))
|
||||
if (!u_trim_pipe_prim( info->mode, &count ))
|
||||
return;
|
||||
|
||||
/*
|
||||
@@ -187,34 +179,32 @@ svga_draw_range_elements( struct pipe_context *pipe,
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (svga->state.sw.need_swtnl)
|
||||
{
|
||||
ret = svga_swtnl_draw_range_elements( svga,
|
||||
index_buffer,
|
||||
index_size,
|
||||
index_bias,
|
||||
min_index, max_index,
|
||||
prim,
|
||||
start, count );
|
||||
if (svga->state.sw.need_swtnl) {
|
||||
ret = svga_swtnl_draw_vbo( svga, info );
|
||||
}
|
||||
else {
|
||||
if (index_buffer) {
|
||||
if (info->indexed && svga->curr.ib.buffer) {
|
||||
unsigned offset;
|
||||
|
||||
assert(svga->curr.ib.offset % svga->curr.ib.index_size == 0);
|
||||
offset = svga->curr.ib.offset / svga->curr.ib.index_size;
|
||||
|
||||
ret = retry_draw_range_elements( svga,
|
||||
index_buffer,
|
||||
index_size,
|
||||
index_bias,
|
||||
min_index,
|
||||
max_index,
|
||||
prim,
|
||||
start,
|
||||
count,
|
||||
svga->curr.ib.buffer,
|
||||
svga->curr.ib.index_size,
|
||||
info->index_bias,
|
||||
info->min_index,
|
||||
info->max_index,
|
||||
info->mode,
|
||||
info->start + offset,
|
||||
info->count,
|
||||
TRUE );
|
||||
}
|
||||
else {
|
||||
ret = retry_draw_arrays( svga,
|
||||
prim,
|
||||
start,
|
||||
count,
|
||||
ret = retry_draw_arrays( svga,
|
||||
info->mode,
|
||||
info->start,
|
||||
info->count,
|
||||
TRUE );
|
||||
}
|
||||
}
|
||||
@@ -226,30 +216,6 @@ svga_draw_range_elements( struct pipe_context *pipe,
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
svga_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
|
||||
{
|
||||
struct svga_context *svga = svga_context(pipe);
|
||||
|
||||
if (info->indexed && svga->curr.ib.buffer) {
|
||||
unsigned offset;
|
||||
|
||||
assert(svga->curr.ib.offset % svga->curr.ib.index_size == 0);
|
||||
offset = svga->curr.ib.offset / svga->curr.ib.index_size;
|
||||
|
||||
svga_draw_range_elements(pipe, svga->curr.ib.buffer,
|
||||
svga->curr.ib.index_size, info->index_bias,
|
||||
info->min_index, info->max_index,
|
||||
info->mode, info->start + offset, info->count);
|
||||
}
|
||||
else {
|
||||
svga_draw_range_elements(pipe, NULL, 0, 0,
|
||||
info->min_index, info->max_index,
|
||||
info->mode, info->start, info->count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void svga_init_draw_functions( struct svga_context *svga )
|
||||
{
|
||||
svga->pipe.draw_vbo = svga_draw_vbo;
|
||||
|
||||
@@ -38,15 +38,8 @@ void svga_destroy_swtnl( struct svga_context *svga );
|
||||
|
||||
|
||||
enum pipe_error
|
||||
svga_swtnl_draw_range_elements(struct svga_context *svga,
|
||||
struct pipe_resource *indexBuffer,
|
||||
unsigned indexSize,
|
||||
int indexBias,
|
||||
unsigned min_index,
|
||||
unsigned max_index,
|
||||
unsigned prim,
|
||||
unsigned start,
|
||||
unsigned count);
|
||||
svga_swtnl_draw_vbo(struct svga_context *svga,
|
||||
const struct pipe_draw_info *info);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -36,13 +36,8 @@
|
||||
|
||||
|
||||
enum pipe_error
|
||||
svga_swtnl_draw_range_elements(struct svga_context *svga,
|
||||
struct pipe_resource *indexBuffer,
|
||||
unsigned indexSize,
|
||||
int indexBias,
|
||||
unsigned min_index,
|
||||
unsigned max_index,
|
||||
unsigned prim, unsigned start, unsigned count)
|
||||
svga_swtnl_draw_vbo(struct svga_context *svga,
|
||||
const struct pipe_draw_info *info)
|
||||
{
|
||||
struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS];
|
||||
struct pipe_transfer *ib_transfer = NULL;
|
||||
@@ -77,18 +72,22 @@ svga_swtnl_draw_range_elements(struct svga_context *svga,
|
||||
}
|
||||
|
||||
/* Map index buffer, if present */
|
||||
if (indexBuffer) {
|
||||
map = pipe_buffer_map(&svga->pipe, indexBuffer,
|
||||
map = NULL;
|
||||
if (info->indexed && svga->curr.ib.buffer) {
|
||||
map = pipe_buffer_map(&svga->pipe, svga->curr.ib.buffer,
|
||||
PIPE_TRANSFER_READ,
|
||||
&ib_transfer);
|
||||
|
||||
draw_set_mapped_element_buffer_range(draw,
|
||||
indexSize, indexBias,
|
||||
min_index,
|
||||
max_index,
|
||||
map);
|
||||
&ib_transfer);
|
||||
if (map)
|
||||
map = (const void *) ((const char *) map + svga->curr.ib.offset);
|
||||
}
|
||||
|
||||
|
||||
draw_set_mapped_element_buffer_range(draw, (map) ?
|
||||
svga->curr.ib.index_size : 0,
|
||||
info->index_bias,
|
||||
info->min_index,
|
||||
info->max_index,
|
||||
map);
|
||||
|
||||
if (svga->curr.cb[PIPE_SHADER_VERTEX]) {
|
||||
map = pipe_buffer_map(&svga->pipe,
|
||||
svga->curr.cb[PIPE_SHADER_VERTEX],
|
||||
@@ -101,7 +100,7 @@ svga_swtnl_draw_range_elements(struct svga_context *svga,
|
||||
svga->curr.cb[PIPE_SHADER_VERTEX]->width0);
|
||||
}
|
||||
|
||||
draw_arrays(svga->swtnl.draw, prim, start, count);
|
||||
draw_arrays(draw, info->mode, info->start, info->count);
|
||||
|
||||
draw_flush(svga->swtnl.draw);
|
||||
|
||||
@@ -117,8 +116,8 @@ svga_swtnl_draw_range_elements(struct svga_context *svga,
|
||||
draw_set_mapped_vertex_buffer(draw, i, NULL);
|
||||
}
|
||||
|
||||
if (indexBuffer) {
|
||||
pipe_buffer_unmap(&svga->pipe, indexBuffer, ib_transfer);
|
||||
if (ib_transfer) {
|
||||
pipe_buffer_unmap(&svga->pipe, svga->curr.ib.buffer, ib_transfer);
|
||||
draw_set_mapped_element_buffer(draw, 0, 0, NULL);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user