Define attrib_format and interp_mode enum typedefs and use where appropriate.
This commit is contained in:
@@ -89,16 +89,6 @@ void draw_set_setup_state( struct draw_context *draw,
|
|||||||
void draw_set_setup_stage( struct draw_context *draw,
|
void draw_set_setup_stage( struct draw_context *draw,
|
||||||
struct draw_stage *stage );
|
struct draw_stage *stage );
|
||||||
|
|
||||||
void draw_set_vertex_attributes( struct draw_context *draw,
|
|
||||||
const uint *attrs, const uint *interp_mode,
|
|
||||||
unsigned nr_attrs );
|
|
||||||
|
|
||||||
void draw_set_twoside_attributes(struct draw_context *draw,
|
|
||||||
uint front0, uint back0,
|
|
||||||
uint front1, uint back1);
|
|
||||||
|
|
||||||
void draw_compute_vertex_size(struct vertex_info *vinfo);
|
|
||||||
|
|
||||||
unsigned draw_prim_info( unsigned prim, unsigned *first, unsigned *incr );
|
unsigned draw_prim_info( unsigned prim, unsigned *first, unsigned *incr );
|
||||||
|
|
||||||
unsigned draw_trim( unsigned count, unsigned first, unsigned incr );
|
unsigned draw_trim( unsigned count, unsigned first, unsigned incr );
|
||||||
|
@@ -56,12 +56,12 @@ static INLINE void copy_colors( struct draw_stage *stage,
|
|||||||
const struct vertex_header *src )
|
const struct vertex_header *src )
|
||||||
{
|
{
|
||||||
const uint num_attribs = stage->draw->vertex_info.num_attribs;
|
const uint num_attribs = stage->draw->vertex_info.num_attribs;
|
||||||
const uint *interp_mode = stage->draw->vertex_info.interp_mode;
|
const interp_mode *interp = stage->draw->vertex_info.interp_mode;
|
||||||
uint i;
|
uint i;
|
||||||
|
|
||||||
/* Look for constant/flat attribs and duplicate from src to dst vertex */
|
/* Look for constant/flat attribs and duplicate from src to dst vertex */
|
||||||
for (i = 1; i < num_attribs - 2; i++) {
|
for (i = 1; i < num_attribs - 2; i++) {
|
||||||
if (interp_mode[i + 2] == INTERP_CONSTANT) {
|
if (interp[i + 2] == INTERP_CONSTANT) {
|
||||||
copy_attr( i, dst, src );
|
copy_attr( i, dst, src );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,8 +45,8 @@
|
|||||||
|
|
||||||
|
|
||||||
static INLINE void
|
static INLINE void
|
||||||
emit_vertex_attr(struct vertex_info *vinfo, uint vfAttr, uint format,
|
emit_vertex_attr(struct vertex_info *vinfo, uint vfAttr,
|
||||||
uint interp)
|
attrib_format format, interp_mode interp)
|
||||||
{
|
{
|
||||||
const uint n = vinfo->num_attribs;
|
const uint n = vinfo->num_attribs;
|
||||||
vinfo->attr_mask |= (1 << vfAttr);
|
vinfo->attr_mask |= (1 << vfAttr);
|
||||||
@@ -59,7 +59,6 @@ emit_vertex_attr(struct vertex_info *vinfo, uint vfAttr, uint format,
|
|||||||
vinfo->interp_mode[n] = interp;
|
vinfo->interp_mode[n] = interp;
|
||||||
vinfo->format[n] = format;
|
vinfo->format[n] = format;
|
||||||
vinfo->num_attribs++;
|
vinfo->num_attribs++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -89,6 +88,7 @@ draw_compute_vertex_size(struct vertex_info *vinfo)
|
|||||||
vinfo->size += 3;
|
vinfo->size += 3;
|
||||||
break;
|
break;
|
||||||
case FORMAT_4F:
|
case FORMAT_4F:
|
||||||
|
case FORMAT_4F_VIEWPORT:
|
||||||
vinfo->size += 4;
|
vinfo->size += 4;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -104,7 +104,7 @@ draw_compute_vertex_size(struct vertex_info *vinfo)
|
|||||||
void
|
void
|
||||||
draw_set_vertex_attributes( struct draw_context *draw,
|
draw_set_vertex_attributes( struct draw_context *draw,
|
||||||
const uint *slot_to_vf_attr,
|
const uint *slot_to_vf_attr,
|
||||||
const uint *interp_mode,
|
const interp_mode *interps,
|
||||||
unsigned nr_attrs )
|
unsigned nr_attrs )
|
||||||
{
|
{
|
||||||
struct vertex_info *vinfo = &draw->vertex_info;
|
struct vertex_info *vinfo = &draw->vertex_info;
|
||||||
@@ -125,7 +125,7 @@ draw_set_vertex_attributes( struct draw_context *draw,
|
|||||||
* Remaining attribs (color, texcoords, etc)
|
* Remaining attribs (color, texcoords, etc)
|
||||||
*/
|
*/
|
||||||
for (i = 1; i < nr_attrs; i++) {
|
for (i = 1; i < nr_attrs; i++) {
|
||||||
emit_vertex_attr(vinfo, slot_to_vf_attr[i], FORMAT_4F, interp_mode[i]);
|
emit_vertex_attr(vinfo, slot_to_vf_attr[i], FORMAT_4F, interps[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_compute_vertex_size(vinfo);
|
draw_compute_vertex_size(vinfo);
|
||||||
|
@@ -38,21 +38,34 @@
|
|||||||
|
|
||||||
#define MAX_VERT_ATTRIBS 12 /* OK? */
|
#define MAX_VERT_ATTRIBS 12 /* OK? */
|
||||||
|
|
||||||
#define FORMAT_OMIT 0
|
|
||||||
#define FORMAT_1F 1
|
struct draw_context;
|
||||||
#define FORMAT_2F 2
|
|
||||||
#define FORMAT_3F 3
|
|
||||||
#define FORMAT_4F 4
|
|
||||||
#define FORMAT_4F_VIEWPORT 4
|
|
||||||
#define FORMAT_4UB 5
|
|
||||||
|
|
||||||
|
|
||||||
enum interp_mode {
|
|
||||||
|
/**
|
||||||
|
* Vertex attribute format
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
FORMAT_OMIT,
|
||||||
|
FORMAT_1F,
|
||||||
|
FORMAT_2F,
|
||||||
|
FORMAT_3F,
|
||||||
|
FORMAT_4F,
|
||||||
|
FORMAT_4F_VIEWPORT,
|
||||||
|
FORMAT_4UB
|
||||||
|
} attrib_format;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute interpolation mode
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
INTERP_NONE, /**< never interpolate vertex header info */
|
INTERP_NONE, /**< never interpolate vertex header info */
|
||||||
INTERP_CONSTANT,
|
INTERP_CONSTANT,
|
||||||
INTERP_LINEAR,
|
INTERP_LINEAR,
|
||||||
INTERP_PERSPECTIVE
|
INTERP_PERSPECTIVE
|
||||||
};
|
} interp_mode;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -63,8 +76,8 @@ struct vertex_info
|
|||||||
uint attr_mask; /**< mask of VF_ATTR_ bits */
|
uint attr_mask; /**< mask of VF_ATTR_ bits */
|
||||||
uint slot_to_attrib[MAX_VERT_ATTRIBS];
|
uint slot_to_attrib[MAX_VERT_ATTRIBS];
|
||||||
uint attrib_to_slot[TGSI_ATTRIB_MAX];
|
uint attrib_to_slot[TGSI_ATTRIB_MAX];
|
||||||
uint interp_mode[MAX_VERT_ATTRIBS];
|
interp_mode interp_mode[MAX_VERT_ATTRIBS];
|
||||||
uint format[MAX_VERT_ATTRIBS]; /**< FORMAT_x */
|
attrib_format format[MAX_VERT_ATTRIBS]; /**< FORMAT_x */
|
||||||
uint size; /**< total vertex size in dwords */
|
uint size; /**< total vertex size in dwords */
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -75,10 +88,11 @@ struct vertex_info
|
|||||||
* \return slot in which the attribute was added
|
* \return slot in which the attribute was added
|
||||||
*/
|
*/
|
||||||
static INLINE uint
|
static INLINE uint
|
||||||
draw_emit_vertex_attr(struct vertex_info *vinfo, uint vfAttr, uint format,
|
draw_emit_vertex_attr(struct vertex_info *vinfo, uint vfAttr,
|
||||||
uint interp)
|
attrib_format format, interp_mode interp)
|
||||||
{
|
{
|
||||||
const uint n = vinfo->num_attribs;
|
const uint n = vinfo->num_attribs;
|
||||||
|
assert(n < MAX_VERT_ATTRIBS);
|
||||||
vinfo->attr_mask |= (1 << vfAttr);
|
vinfo->attr_mask |= (1 << vfAttr);
|
||||||
vinfo->slot_to_attrib[n] = vfAttr;
|
vinfo->slot_to_attrib[n] = vfAttr;
|
||||||
vinfo->format[n] = format;
|
vinfo->format[n] = format;
|
||||||
@@ -88,8 +102,17 @@ draw_emit_vertex_attr(struct vertex_info *vinfo, uint vfAttr, uint format,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
extern void draw_set_vertex_attributes( struct draw_context *draw,
|
||||||
|
const uint *attrs,
|
||||||
|
const interp_mode *interps,
|
||||||
|
unsigned nr_attrs );
|
||||||
|
|
||||||
|
extern void draw_set_twoside_attributes(struct draw_context *draw,
|
||||||
|
uint front0, uint back0,
|
||||||
|
uint front1, uint back1);
|
||||||
|
|
||||||
|
extern void draw_compute_vertex_size(struct vertex_info *vinfo);
|
||||||
|
|
||||||
struct draw_context;
|
|
||||||
|
|
||||||
extern int draw_vertex_cache_check_space( struct draw_context *draw,
|
extern int draw_vertex_cache_check_space( struct draw_context *draw,
|
||||||
unsigned nr_verts );
|
unsigned nr_verts );
|
||||||
|
@@ -42,8 +42,8 @@
|
|||||||
*/
|
*/
|
||||||
static void calculate_vertex_layout( struct i915_context *i915 )
|
static void calculate_vertex_layout( struct i915_context *i915 )
|
||||||
{
|
{
|
||||||
const unsigned inputsRead = i915->fs.inputs_read;
|
const uint inputsRead = i915->fs.inputs_read;
|
||||||
const uint colorInterp
|
const interp_mode colorInterp
|
||||||
= i915->setup.flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
|
= i915->setup.flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
|
||||||
struct vertex_info *vinfo = &i915->current.vertex_info;
|
struct vertex_info *vinfo = &i915->current.vertex_info;
|
||||||
uint front0 = 0, back0 = 0, front1 = 0, back1 = 0;
|
uint front0 = 0, back0 = 0, front1 = 0, back1 = 0;
|
||||||
|
@@ -38,9 +38,9 @@
|
|||||||
#include "sp_quad.h"
|
#include "sp_quad.h"
|
||||||
#include "sp_prim_setup.h"
|
#include "sp_prim_setup.h"
|
||||||
#include "pipe/draw/draw_private.h"
|
#include "pipe/draw/draw_private.h"
|
||||||
|
#include "pipe/draw/draw_vertex.h"
|
||||||
#include "pipe/p_util.h"
|
#include "pipe/p_util.h"
|
||||||
|
|
||||||
#include "pipe/draw/draw_vertex.h"
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -461,7 +461,7 @@ static void tri_persp_coeff( struct setup_stage *setup,
|
|||||||
*/
|
*/
|
||||||
static void setup_tri_coefficients( struct setup_stage *setup )
|
static void setup_tri_coefficients( struct setup_stage *setup )
|
||||||
{
|
{
|
||||||
const enum interp_mode *interp = setup->softpipe->vertex_info.interp_mode;
|
const interp_mode *interp = setup->softpipe->vertex_info.interp_mode;
|
||||||
unsigned slot, j;
|
unsigned slot, j;
|
||||||
|
|
||||||
/* z and w are done by linear interpolation:
|
/* z and w are done by linear interpolation:
|
||||||
@@ -680,7 +680,7 @@ line_persp_coeff(struct setup_stage *setup, unsigned slot, unsigned i)
|
|||||||
static INLINE void
|
static INLINE void
|
||||||
setup_line_coefficients(struct setup_stage *setup, struct prim_header *prim)
|
setup_line_coefficients(struct setup_stage *setup, struct prim_header *prim)
|
||||||
{
|
{
|
||||||
const enum interp_mode *interp = setup->softpipe->vertex_info.interp_mode;
|
const interp_mode *interp = setup->softpipe->vertex_info.interp_mode;
|
||||||
unsigned slot, j;
|
unsigned slot, j;
|
||||||
|
|
||||||
/* use setup->vmin, vmax to point to vertices */
|
/* use setup->vmin, vmax to point to vertices */
|
||||||
|
@@ -43,8 +43,8 @@
|
|||||||
*/
|
*/
|
||||||
static void calculate_vertex_layout( struct softpipe_context *softpipe )
|
static void calculate_vertex_layout( struct softpipe_context *softpipe )
|
||||||
{
|
{
|
||||||
const unsigned inputsRead = softpipe->fs.inputs_read;
|
const uint inputsRead = softpipe->fs.inputs_read;
|
||||||
const uint colorInterp
|
const interp_mode colorInterp
|
||||||
= softpipe->setup.flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
|
= softpipe->setup.flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
|
||||||
struct vertex_info *vinfo = &softpipe->vertex_info;
|
struct vertex_info *vinfo = &softpipe->vertex_info;
|
||||||
uint front0 = 0, back0 = 0, front1 = 0, back1 = 0;
|
uint front0 = 0, back0 = 0, front1 = 0, back1 = 0;
|
||||||
|
Reference in New Issue
Block a user