00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00038 #ifndef DRAW_VERTEX_H
00039 #define DRAW_VERTEX_H
00040
00041
00042 #include "pipe/p_state.h"
00043
00044
00048 enum attrib_emit {
00049 EMIT_OMIT,
00050 EMIT_1F,
00051 EMIT_1F_PSIZE,
00052 EMIT_2F,
00053 EMIT_3F,
00054 EMIT_4F,
00055 EMIT_4UB
00056 };
00057
00058
00062 enum interp_mode {
00063 INTERP_NONE,
00064 INTERP_POS,
00065 INTERP_CONSTANT,
00066 INTERP_LINEAR,
00067 INTERP_PERSPECTIVE
00068 };
00069
00070
00074 struct vertex_info
00075 {
00076 uint num_attribs;
00077 uint hwfmt[4];
00078 uint size;
00080
00081
00082
00083 struct {
00084 ubyte interp_mode:4;
00085 ubyte emit:4;
00086 ubyte src_index;
00087 } attrib[PIPE_MAX_SHADER_INPUTS];
00088 };
00089
00090 static INLINE int
00091 draw_vinfo_size( const struct vertex_info *a )
00092 {
00093 return ((const char *)&a->attrib[a->num_attribs] -
00094 (const char *)a);
00095 }
00096
00097 static INLINE int
00098 draw_vinfo_compare( const struct vertex_info *a,
00099 const struct vertex_info *b )
00100 {
00101 unsigned sizea = draw_vinfo_size( a );
00102 return memcmp( a, b, sizea );
00103 }
00104
00105 static INLINE void
00106 draw_vinfo_copy( struct vertex_info *dst,
00107 const struct vertex_info *src )
00108 {
00109 unsigned size = draw_vinfo_size( src );
00110 memcpy( dst, src, size );
00111 }
00112
00113
00114
00121 static INLINE uint
00122 draw_emit_vertex_attr(struct vertex_info *vinfo,
00123 enum attrib_emit emit,
00124 enum interp_mode interp,
00125 uint 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 }
00135
00136
00137 extern void draw_compute_vertex_size(struct vertex_info *vinfo);
00138
00139 void draw_dump_emitted_vertex(const struct vertex_info *vinfo,
00140 const uint8_t *data);
00141
00142
00143 static INLINE unsigned draw_translate_vinfo_format(unsigned format )
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 }
00161
00162
00163 #endif