draw_vertex.h File Reference

Include dependency graph for draw_vertex.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  vertex_info
 Information about hardware/rasterization vertex layout. More...

Enumerations

enum  attrib_emit {
  EMIT_OMIT, EMIT_1F, EMIT_1F_PSIZE, EMIT_2F,
  EMIT_3F, EMIT_4F, EMIT_4UB
}
 Post-transform vertex format info. More...
enum  interp_mode {
  INTERP_NONE, INTERP_POS, INTERP_CONSTANT, INTERP_LINEAR,
  INTERP_PERSPECTIVE
}
 Attribute interpolation mode. More...

Functions

static int draw_vinfo_size (const struct vertex_info *a)
static int draw_vinfo_compare (const struct vertex_info *a, const struct vertex_info *b)
static void draw_vinfo_copy (struct vertex_info *dst, const struct vertex_info *src)
static uint draw_emit_vertex_attr (struct vertex_info *vinfo, enum attrib_emit emit, enum interp_mode interp, uint src_index)
 Add another attribute to the given vertex_info object.
void draw_compute_vertex_size (struct vertex_info *vinfo)
 Compute the size of a vertex, in dwords/floats, to update the vinfo->size field.
void draw_dump_emitted_vertex (const struct vertex_info *vinfo, const uint8_t *data)
static unsigned draw_translate_vinfo_format (unsigned format)


Enumeration Type Documentation

enum attrib_emit

Post-transform vertex format info.

The vertex_info struct is used by the draw_vbuf code to emit hardware-specific vertex layouts into hw vertex buffers.

Author: Brian Paul Vertex attribute emit modes

Enumerator:
EMIT_OMIT  don't emit the attribute
EMIT_1F 
EMIT_1F_PSIZE  insert constant point size
EMIT_2F 
EMIT_3F 
EMIT_4F 
EMIT_4UB  XXX may need variations for RGBA vs BGRA, etc.

Definition at line 48 of file draw_vertex.h.

00048                  {
00049    EMIT_OMIT,      
00050    EMIT_1F,
00051    EMIT_1F_PSIZE,  
00052    EMIT_2F,
00053    EMIT_3F,
00054    EMIT_4F,
00055    EMIT_4UB  
00056 };

enum interp_mode

Attribute interpolation mode.

Enumerator:
INTERP_NONE  never interpolate vertex header info
INTERP_POS  special case for frag position
INTERP_CONSTANT 
INTERP_LINEAR 
INTERP_PERSPECTIVE 

Definition at line 62 of file draw_vertex.h.

00062                  {
00063    INTERP_NONE,      
00064    INTERP_POS,       
00065    INTERP_CONSTANT,
00066    INTERP_LINEAR,
00067    INTERP_PERSPECTIVE
00068 };


Function Documentation

void draw_compute_vertex_size ( struct vertex_info vinfo  ) 

Compute the size of a vertex, in dwords/floats, to update the vinfo->size field.

Definition at line 46 of file draw_vertex.c.

References assert, vertex_info::attrib, vertex_info::emit, EMIT_1F, EMIT_1F_PSIZE, EMIT_2F, EMIT_3F, EMIT_4F, EMIT_4UB, EMIT_OMIT, vertex_info::num_attribs, and vertex_info::size.

00047 {
00048    uint i;
00049 
00050    vinfo->size = 0;
00051    for (i = 0; i < vinfo->num_attribs; i++) {
00052       switch (vinfo->attrib[i].emit) {
00053       case EMIT_OMIT:
00054          break;
00055       case EMIT_4UB:
00056          /* fall-through */
00057       case EMIT_1F_PSIZE:
00058          /* fall-through */
00059       case EMIT_1F:
00060          vinfo->size += 1;
00061          break;
00062       case EMIT_2F:
00063          vinfo->size += 2;
00064          break;
00065       case EMIT_3F:
00066          vinfo->size += 3;
00067          break;
00068       case EMIT_4F:
00069          vinfo->size += 4;
00070          break;
00071       default:
00072          assert(0);
00073       }
00074    }
00075 }

void draw_dump_emitted_vertex ( const struct vertex_info vinfo,
const uint8_t *  data 
)

Definition at line 79 of file draw_vertex.c.

References assert, vertex_info::attrib, debug_printf(), vertex_info::emit, EMIT_1F, EMIT_1F_PSIZE, EMIT_2F, EMIT_3F, EMIT_4F, EMIT_4UB, EMIT_OMIT, vertex_info::num_attribs, and vertex_info::src_index.

00080 {
00081    unsigned i, j;
00082 
00083    for (i = 0; i < vinfo->num_attribs; i++) {
00084       j = vinfo->attrib[i].src_index;
00085       switch (vinfo->attrib[i].emit) {
00086       case EMIT_OMIT:
00087          debug_printf("EMIT_OMIT:");
00088          break;
00089       case EMIT_1F:
00090          debug_printf("EMIT_1F:\t");
00091          debug_printf("%f ", *(float *)data); data += sizeof(float);
00092          break;
00093       case EMIT_1F_PSIZE:
00094          debug_printf("EMIT_1F_PSIZE:\t");
00095          debug_printf("%f ", *(float *)data); data += sizeof(float);
00096          break;
00097       case EMIT_2F:
00098          debug_printf("EMIT_2F:\t");
00099          debug_printf("%f ", *(float *)data); data += sizeof(float);
00100          debug_printf("%f ", *(float *)data); data += sizeof(float);
00101          break;
00102       case EMIT_3F:
00103          debug_printf("EMIT_3F:\t");
00104          debug_printf("%f ", *(float *)data); data += sizeof(float);
00105          debug_printf("%f ", *(float *)data); data += sizeof(float);
00106          debug_printf("%f ", *(float *)data); data += sizeof(float);
00107          data += sizeof(float);
00108          break;
00109       case EMIT_4F:
00110          debug_printf("EMIT_4F:\t");
00111          debug_printf("%f ", *(float *)data); data += sizeof(float);
00112          debug_printf("%f ", *(float *)data); data += sizeof(float);
00113          debug_printf("%f ", *(float *)data); data += sizeof(float);
00114          debug_printf("%f ", *(float *)data); data += sizeof(float);
00115          break;
00116       case EMIT_4UB:
00117          debug_printf("EMIT_4UB:\t");
00118          debug_printf("%u ", *data++);
00119          debug_printf("%u ", *data++);
00120          debug_printf("%u ", *data++);
00121          debug_printf("%u ", *data++);
00122          break;
00123       default:
00124          assert(0);
00125       }
00126       debug_printf("\n");
00127    }
00128    debug_printf("\n");
00129 }

static uint draw_emit_vertex_attr ( struct vertex_info vinfo,
enum attrib_emit  emit,
enum interp_mode  interp,
uint  src_index 
) [static]

Add another attribute to the given vertex_info object.

Parameters:
src_index indicates which post-transformed vertex attrib slot corresponds to this attribute.
Returns:
slot in which the attribute was added

Definition at line 122 of file draw_vertex.h.

References assert, vertex_info::attrib, vertex_info::emit, vertex_info::interp_mode, vertex_info::num_attribs, PIPE_MAX_SHADER_INPUTS, and vertex_info::src_index.

00126 {
00127    const uint n = vinfo->num_attribs;
00128    assert(n < PIPE_MAX_SHADER_INPUTS);
00129    vinfo->attrib[n].emit = emit;
00130    vinfo->attrib[n].interp_mode = interp;
00131    vinfo->attrib[n].src_index = src_index;
00132    vinfo->num_attribs++;
00133    return n;
00134 }

static unsigned draw_translate_vinfo_format ( unsigned  format  )  [static]

Definition at line 143 of file draw_vertex.h.

References EMIT_1F, EMIT_1F_PSIZE, EMIT_2F, EMIT_3F, EMIT_4F, EMIT_4UB, PIPE_FORMAT_NONE, PIPE_FORMAT_R32_FLOAT, PIPE_FORMAT_R32G32_FLOAT, PIPE_FORMAT_R32G32B32_FLOAT, PIPE_FORMAT_R32G32B32A32_FLOAT, and PIPE_FORMAT_R8G8B8A8_UNORM.

00144 {
00145    switch (format) {
00146    case EMIT_1F:
00147    case EMIT_1F_PSIZE:
00148       return PIPE_FORMAT_R32_FLOAT;
00149    case EMIT_2F:
00150       return PIPE_FORMAT_R32G32_FLOAT;
00151    case EMIT_3F:
00152       return PIPE_FORMAT_R32G32B32_FLOAT;
00153    case EMIT_4F:
00154       return PIPE_FORMAT_R32G32B32A32_FLOAT;
00155    case EMIT_4UB:
00156       return PIPE_FORMAT_R8G8B8A8_UNORM;
00157    default:
00158       return PIPE_FORMAT_NONE;
00159    }
00160 }

static int draw_vinfo_compare ( const struct vertex_info a,
const struct vertex_info b 
) [static]

Definition at line 98 of file draw_vertex.h.

References draw_vinfo_size().

00100 {
00101    unsigned sizea = draw_vinfo_size( a );
00102    return memcmp( a, b, sizea );
00103 }

static void draw_vinfo_copy ( struct vertex_info dst,
const struct vertex_info src 
) [static]

Definition at line 106 of file draw_vertex.h.

References draw_vinfo_size().

00108 {
00109    unsigned size = draw_vinfo_size( src );
00110    memcpy( dst, src, size );
00111 }

static int draw_vinfo_size ( const struct vertex_info a  )  [static]

Definition at line 91 of file draw_vertex.h.

References vertex_info::attrib, and vertex_info::num_attribs.

00092 {
00093    return ((const char *)&a->attrib[a->num_attribs] -
00094            (const char *)a);
00095 }


Generated on Tue Sep 29 06:25:21 2009 for Gallium3D by  doxygen 1.5.4