vbo: Move vbo_split into the tnl module.

Move the files, adapt to the naming scheme in tnl, update callers
and build system.

Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
This commit is contained in:
Mathias Fröhlich 2018-03-25 19:16:54 +02:00 committed by Mathias Fröhlich
parent 245f9a3977
commit 6e9f00e3fc
12 changed files with 178 additions and 174 deletions

View file

@ -372,6 +372,10 @@ TNL_FILES = \
tnl/t_pipeline.h \
tnl/t_rebase.c \
tnl/t_rebase.h \
tnl/t_split.c \
tnl/t_split_copy.c \
tnl/t_split.h \
tnl/t_split_inplace.c \
tnl/t_vb_cliptmp.h \
tnl/t_vb_fog.c \
tnl/t_vb_light.c \
@ -411,11 +415,7 @@ VBO_FILES = \
vbo/vbo_save.c \
vbo/vbo_save_draw.c \
vbo/vbo_save.h \
vbo/vbo_save_loopback.c \
vbo/vbo_split.c \
vbo/vbo_split_copy.c \
vbo/vbo_split.h \
vbo/vbo_split_inplace.c
vbo/vbo_save_loopback.c
STATETRACKER_FILES = \
state_tracker/st_atifs_to_tgsi.c \

View file

@ -277,8 +277,8 @@ vbo_maybe_split(struct gl_context *ctx, const struct gl_vertex_array *arrays,
.max_vb_size = ~0,
};
vbo_split_prims(ctx, arrays, prims, nr_prims, ib, min_index,
max_index, TAG(vbo_render_prims), &limits);
_tnl_split_prims(ctx, arrays, prims, nr_prims, ib, min_index,
max_index, TAG(vbo_render_prims), &limits);
return GL_TRUE;
}

View file

@ -343,10 +343,6 @@ files_libmesa_common = files(
'vbo/vbo_save_draw.c',
'vbo/vbo_save.h',
'vbo/vbo_save_loopback.c',
'vbo/vbo_split.c',
'vbo/vbo_split_copy.c',
'vbo/vbo_split.h',
'vbo/vbo_split_inplace.c',
'x86/common_x86.c',
)
@ -366,6 +362,10 @@ files_libmesa_classic = files(
'tnl/t_pipeline.c',
'tnl/t_pipeline.h',
'tnl/t_rebase.c',
'tnl/t_split.c',
'tnl/t_split_copy.c',
'tnl/t_split.h',
'tnl/t_split_inplace.c',
'tnl/t_vb_cliptmp.h',
'tnl/t_vb_fog.c',
'tnl/t_vb_light.c',

View file

@ -486,10 +486,10 @@ void _tnl_draw_prims(struct gl_context *ctx,
/* This will split the buffers one way or another and
* recursively call back into this function.
*/
vbo_split_prims( ctx, arrays, prim, nr_prims, ib,
0, max_index + prim->basevertex,
_tnl_draw_prims,
&limits );
_tnl_split_prims( ctx, arrays, prim, nr_prims, ib,
0, max_index + prim->basevertex,
_tnl_draw_prims,
&limits );
}
else {
/* May need to map a vertex buffer object for every attribute plus

View file

@ -51,6 +51,7 @@
#include "main/glheader.h"
#include "main/imports.h"
#include "main/mtypes.h"
#include "vbo/vbo.h"
#include "t_rebase.h"
@ -108,7 +109,7 @@ void t_rebase_prims( struct gl_context *ctx,
const struct _mesa_index_buffer *ib,
GLuint min_index,
GLuint max_index,
vbo_draw_func draw )
tnl_draw_func draw )
{
struct gl_array_attributes tmp_attribs[VERT_ATTRIB_MAX];
struct gl_vertex_array tmp_arrays[VERT_ATTRIB_MAX];

View file

@ -25,7 +25,7 @@
#ifndef _T_REBASE_H_
#define _T_REBASE_H_
#include "vbo/vbo.h"
#include "tnl.h"
void t_rebase_prims( struct gl_context *ctx,
const struct gl_vertex_array *arrays,
@ -34,6 +34,6 @@ void t_rebase_prims( struct gl_context *ctx,
const struct _mesa_index_buffer *ib,
GLuint min_index,
GLuint max_index,
vbo_draw_func draw );
tnl_draw_func draw );
#endif

View file

@ -49,16 +49,16 @@
#include "main/glheader.h"
#include "main/mtypes.h"
#include "vbo/vbo.h"
#include "vbo_split.h"
#include "vbo.h"
#include "t_split.h"
/* True if a primitive can be split without copying of vertices, false
* otherwise.
*/
GLboolean
split_prim_inplace(GLenum mode, GLuint *first, GLuint *incr)
_tnl_split_prim_inplace(GLenum mode, GLuint *first, GLuint *incr)
{
switch (mode) {
case GL_POINTS:
@ -99,15 +99,15 @@ split_prim_inplace(GLenum mode, GLuint *first, GLuint *incr)
void
vbo_split_prims(struct gl_context *ctx,
const struct gl_vertex_array arrays[],
const struct _mesa_prim *prim,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLuint min_index,
GLuint max_index,
vbo_draw_func draw,
const struct split_limits *limits)
_tnl_split_prims(struct gl_context *ctx,
const struct gl_vertex_array arrays[],
const struct _mesa_prim *prim,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLuint min_index,
GLuint max_index,
tnl_draw_func draw,
const struct split_limits *limits)
{
if (ib) {
if (limits->max_indices == 0) {
@ -127,15 +127,15 @@ vbo_split_prims(struct gl_context *ctx,
* in turn. Use a vertex cache to preserve some of the
* sharing from the original index list.
*/
vbo_split_copy(ctx, arrays, prim, nr_prims, ib, draw, limits);
_tnl_split_copy(ctx, arrays, prim, nr_prims, ib, draw, limits);
}
else if (ib->count > limits->max_indices) {
/* The index buffer is too large for hardware. Try to split
* on whole-primitive boundaries, otherwise try to split the
* individual primitives.
*/
vbo_split_inplace(ctx, arrays, prim, nr_prims, ib,
min_index, max_index, draw, limits);
_tnl_split_inplace(ctx, arrays, prim, nr_prims, ib,
min_index, max_index, draw, limits);
}
else {
/* Why were we called? */
@ -148,8 +148,8 @@ vbo_split_prims(struct gl_context *ctx,
* module). Try to split on whole-primitive boundaries,
* otherwise try to split the individual primitives.
*/
vbo_split_inplace(ctx, arrays, prim, nr_prims, ib,
min_index, max_index, draw, limits);
_tnl_split_inplace(ctx, arrays, prim, nr_prims, ib,
min_index, max_index, draw, limits);
}
else {
/* Why were we called? */

View file

@ -29,46 +29,46 @@
/**
* \mainpage The VBO splitter
* \mainpage The TNL splitter
*
* This is the private data used internally to the vbo_split_prims()
* helper function. Nobody outside the vbo_split* files needs to
* This is the private data used internally to the _tnl_split_prims()
* helper function. Nobody outside the _tnl_split* files needs to
* include or know about this structure.
*/
#ifndef _VBO_SPLIT_H
#define _VBO_SPLIT_H
#ifndef _TNL_SPLIT_H
#define _TNL_SPLIT_H
#include "vbo.h"
#include "tnl.h"
/* True if a primitive can be split without copying of vertices, false
* otherwise.
*/
GLboolean
split_prim_inplace(GLenum mode, GLuint *first, GLuint *incr);
_tnl_split_prim_inplace(GLenum mode, GLuint *first, GLuint *incr);
void
vbo_split_inplace(struct gl_context *ctx,
const struct gl_vertex_array arrays[],
const struct _mesa_prim *prim,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLuint min_index,
GLuint max_index,
vbo_draw_func draw,
const struct split_limits *limits);
_tnl_split_inplace(struct gl_context *ctx,
const struct gl_vertex_array arrays[],
const struct _mesa_prim *prim,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLuint min_index,
GLuint max_index,
tnl_draw_func draw,
const struct split_limits *limits);
/* Requires ib != NULL:
*/
void
vbo_split_copy(struct gl_context *ctx,
const struct gl_vertex_array arrays[],
const struct _mesa_prim *prim,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
vbo_draw_func draw,
const struct split_limits *limits);
_tnl_split_copy(struct gl_context *ctx,
const struct gl_vertex_array arrays[],
const struct _mesa_prim *prim,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
tnl_draw_func draw,
const struct split_limits *limits);
#endif

View file

@ -38,9 +38,10 @@
#include "main/macros.h"
#include "main/mtypes.h"
#include "main/varray.h"
#include "vbo/vbo.h"
#include "vbo_split.h"
#include "vbo.h"
#include "t_split.h"
#include "tnl.h"
#define ELT_TABLE_SIZE 16
@ -56,7 +57,7 @@ struct copy_context {
const struct _mesa_prim *prim;
GLuint nr_prims;
const struct _mesa_index_buffer *ib;
vbo_draw_func draw;
tnl_draw_func draw;
const struct split_limits *limits;
@ -383,7 +384,7 @@ replay_elts(struct copy_context *copy)
break;
default:
(void)split_prim_inplace(prim->mode, &first, &incr);
(void)_tnl_split_prim_inplace(prim->mode, &first, &incr);
j = 0;
while (j != prim->count) {
@ -589,13 +590,13 @@ replay_finish(struct copy_context *copy)
* Split VBO into smaller pieces, draw the pieces.
*/
void
vbo_split_copy(struct gl_context *ctx,
const struct gl_vertex_array *arrays,
const struct _mesa_prim *prim,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
vbo_draw_func draw,
const struct split_limits *limits)
_tnl_split_copy(struct gl_context *ctx,
const struct gl_vertex_array *arrays,
const struct _mesa_prim *prim,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
tnl_draw_func draw,
const struct split_limits *limits)
{
struct copy_context copy;
GLuint i, this_nr_prims;

View file

@ -30,7 +30,9 @@
#include "main/mtypes.h"
#include "main/macros.h"
#include "main/enums.h"
#include "vbo_split.h"
#include "vbo/vbo.h"
#include "t_split.h"
#define MAX_PRIM 32
@ -47,7 +49,7 @@ struct split_context {
const struct _mesa_index_buffer *ib;
GLuint min_index;
GLuint max_index;
vbo_draw_func draw;
tnl_draw_func draw;
const struct split_limits *limits;
GLuint limit;
@ -153,7 +155,8 @@ split_prims(struct split_context *split)
for (i = 0; i < split->nr_prims; i++) {
const struct _mesa_prim *prim = &split->prim[i];
GLuint first, incr;
GLboolean split_inplace = split_prim_inplace(prim->mode, &first, &incr);
GLboolean split_inplace =
_tnl_split_prim_inplace(prim->mode, &first, &incr);
GLuint available = get_max_vertices(split, prim);
GLuint count = prim->count - (prim->count - first) % incr;
@ -235,24 +238,24 @@ split_prims(struct split_context *split)
flush_vertex(split);
vbo_split_copy(split->ctx,
split->array,
&tmpprim, 1,
&ib,
split->draw,
split->limits);
_tnl_split_copy(split->ctx,
split->array,
&tmpprim, 1,
&ib,
split->draw,
split->limits);
free(elts);
}
else {
flush_vertex(split);
vbo_split_copy(split->ctx,
split->array,
prim, 1,
split->ib,
split->draw,
split->limits);
_tnl_split_copy(split->ctx,
split->array,
prim, 1,
split->ib,
split->draw,
split->limits);
}
}
@ -261,15 +264,15 @@ split_prims(struct split_context *split)
void
vbo_split_inplace(struct gl_context *ctx,
const struct gl_vertex_array *arrays,
const struct _mesa_prim *prim,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLuint min_index,
GLuint max_index,
vbo_draw_func draw,
const struct split_limits *limits)
_tnl_split_inplace(struct gl_context *ctx,
const struct gl_vertex_array *arrays,
const struct _mesa_prim *prim,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLuint min_index,
GLuint max_index,
tnl_draw_func draw,
const struct split_limits *limits)
{
struct split_context split;

View file

@ -108,4 +108,84 @@ _tnl_RasterPos(struct gl_context *ctx, const GLfloat vObj[4]);
extern void
_tnl_validate_shine_tables( struct gl_context *ctx );
/**
* For indirect array drawing:
*
* typedef struct {
* GLuint count;
* GLuint primCount;
* GLuint first;
* GLuint baseInstance; // in GL 4.2 and later, must be zero otherwise
* } DrawArraysIndirectCommand;
*
* For indirect indexed drawing:
*
* typedef struct {
* GLuint count;
* GLuint primCount;
* GLuint firstIndex;
* GLint baseVertex;
* GLuint baseInstance; // in GL 4.2 and later, must be zero otherwise
* } DrawElementsIndirectCommand;
*/
/**
* Draw a number of primitives.
* \param prims array [nr_prims] describing what to draw (prim type,
* vertex count, first index, instance count, etc).
* \param arrays array of vertex arrays for draw
* \param ib index buffer for indexed drawing, NULL for array drawing
* \param index_bounds_valid are min_index and max_index valid?
* \param min_index lowest vertex index used
* \param max_index highest vertex index used
* \param tfb_vertcount if non-null, indicates which transform feedback
* object has the vertex count.
* \param tfb_stream If called via DrawTransformFeedbackStream, specifies the
* vertex stream buffer from which to get the vertex count.
* \param indirect If any prims are indirect, this specifies the buffer
* to find the "DrawArrays/ElementsIndirectCommand" data.
* This may be deprecated in the future
*/
typedef void (*tnl_draw_func)(struct gl_context *ctx,
const struct gl_vertex_array* arrays,
const struct _mesa_prim *prims,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLboolean index_bounds_valid,
GLuint min_index,
GLuint max_index,
struct gl_transform_feedback_object *tfb_vertcount,
unsigned tfb_stream,
struct gl_buffer_object *indirect);
/* Utility function to cope with various constraints on tnl modules or
* hardware. This can be used to split an incoming set of arrays and
* primitives against the following constraints:
* - Maximum number of indices in index buffer.
* - Maximum number of vertices referenced by index buffer.
* - Maximum hardware vertex buffer size.
*/
struct split_limits
{
GLuint max_verts;
GLuint max_indices;
GLuint max_vb_size; /* bytes */
};
void
_tnl_split_prims(struct gl_context *ctx,
const struct gl_vertex_array *arrays,
const struct _mesa_prim *prim,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLuint min_index,
GLuint max_index,
tnl_draw_func draw,
const struct split_limits *limits);
#endif

View file

@ -119,75 +119,6 @@ void
vbo_save_EndCallList(struct gl_context *ctx);
/**
* For indirect array drawing:
*
* typedef struct {
* GLuint count;
* GLuint primCount;
* GLuint first;
* GLuint baseInstance; // in GL 4.2 and later, must be zero otherwise
* } DrawArraysIndirectCommand;
*
* For indirect indexed drawing:
*
* typedef struct {
* GLuint count;
* GLuint primCount;
* GLuint firstIndex;
* GLint baseVertex;
* GLuint baseInstance; // in GL 4.2 and later, must be zero otherwise
* } DrawElementsIndirectCommand;
*/
/**
* Draw a number of primitives.
* \param prims array [nr_prims] describing what to draw (prim type,
* vertex count, first index, instance count, etc).
* \param arrays array of vertex arrays for draw
* \param ib index buffer for indexed drawing, NULL for array drawing
* \param index_bounds_valid are min_index and max_index valid?
* \param min_index lowest vertex index used
* \param max_index highest vertex index used
* \param tfb_vertcount if non-null, indicates which transform feedback
* object has the vertex count.
* \param tfb_stream If called via DrawTransformFeedbackStream, specifies the
* vertex stream buffer from which to get the vertex count.
* \param indirect If any prims are indirect, this specifies the buffer
* to find the "DrawArrays/ElementsIndirectCommand" data.
* This may be deprecated in the future
*/
typedef void (*vbo_draw_func)(struct gl_context *ctx,
const struct gl_vertex_array* arrays,
const struct _mesa_prim *prims,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLboolean index_bounds_valid,
GLuint min_index,
GLuint max_index,
struct gl_transform_feedback_object *tfb_vertcount,
unsigned tfb_stream,
struct gl_buffer_object *indirect);
/* Utility function to cope with various constraints on tnl modules or
* hardware. This can be used to split an incoming set of arrays and
* primitives against the following constraints:
* - Maximum number of indices in index buffer.
* - Maximum number of vertices referenced by index buffer.
* - Maximum hardware vertex buffer size.
*/
struct split_limits
{
GLuint max_verts;
GLuint max_indices;
GLuint max_vb_size; /* bytes */
};
void
_vbo_draw_indirect(struct gl_context *ctx, GLuint mode,
struct gl_buffer_object *indirect_data,
@ -198,18 +129,6 @@ _vbo_draw_indirect(struct gl_context *ctx, GLuint mode,
const struct _mesa_index_buffer *ib);
void
vbo_split_prims(struct gl_context *ctx,
const struct gl_vertex_array *arrays,
const struct _mesa_prim *prim,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLuint min_index,
GLuint max_index,
vbo_draw_func draw,
const struct split_limits *limits);
void
vbo_delete_minmax_cache(struct gl_buffer_object *bufferObj);