1 /**************************************************************************
2 *
3 * Copyright 2007 VMware, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 /*
29 * Functions for specifying the post-transformation vertex layout.
30 *
31 * Author:
32 * Brian Paul
33 * Keith Whitwell
34 */
35
36
37 #include "draw/draw_private.h"
38 #include "draw/draw_vertex.h"
39
40
41 /**
42 * Compute the size of a vertex, in dwords/floats, to update the
43 * vinfo->size field.
44 */
45 void
draw_compute_vertex_size(struct vertex_info * vinfo)46 draw_compute_vertex_size(struct vertex_info *vinfo)
47 {
48 vinfo->size = 0;
49 for (unsigned i = 0; i < vinfo->num_attribs; i++)
50 vinfo->size += draw_translate_vinfo_size(vinfo->attrib[i].emit);
51
52 assert(vinfo->size % 4 == 0);
53 /* in dwords */
54 vinfo->size /= 4;
55 }
56
57
58 void
draw_dump_emitted_vertex(const struct vertex_info * vinfo,const uint8_t * data)59 draw_dump_emitted_vertex(const struct vertex_info *vinfo, const uint8_t *data)
60 {
61 for (unsigned i = 0; i < vinfo->num_attribs; i++) {
62 switch (vinfo->attrib[i].emit) {
63 case EMIT_OMIT:
64 debug_printf("EMIT_OMIT:");
65 break;
66 case EMIT_1F:
67 debug_printf("EMIT_1F:\t");
68 debug_printf("%f ", *(float *)data); data += sizeof(float);
69 break;
70 case EMIT_1F_PSIZE:
71 debug_printf("EMIT_1F_PSIZE:\t");
72 debug_printf("%f ", *(float *)data); data += sizeof(float);
73 break;
74 case EMIT_2F:
75 debug_printf("EMIT_2F:\t");
76 debug_printf("%f ", *(float *)data); data += sizeof(float);
77 debug_printf("%f ", *(float *)data); data += sizeof(float);
78 break;
79 case EMIT_3F:
80 debug_printf("EMIT_3F:\t");
81 debug_printf("%f ", *(float *)data); data += sizeof(float);
82 debug_printf("%f ", *(float *)data); data += sizeof(float);
83 debug_printf("%f ", *(float *)data); data += sizeof(float);
84 data += sizeof(float);
85 break;
86 case EMIT_4F:
87 debug_printf("EMIT_4F:\t");
88 debug_printf("%f ", *(float *)data); data += sizeof(float);
89 debug_printf("%f ", *(float *)data); data += sizeof(float);
90 debug_printf("%f ", *(float *)data); data += sizeof(float);
91 debug_printf("%f ", *(float *)data); data += sizeof(float);
92 break;
93 case EMIT_4UB:
94 debug_printf("EMIT_4UB:\t");
95 debug_printf("%u ", *data++);
96 debug_printf("%u ", *data++);
97 debug_printf("%u ", *data++);
98 debug_printf("%u ", *data++);
99 break;
100 case EMIT_4UB_BGRA:
101 debug_printf("EMIT_4UB_BGRA:\t");
102 debug_printf("%u ", *data++);
103 debug_printf("%u ", *data++);
104 debug_printf("%u ", *data++);
105 debug_printf("%u ", *data++);
106 break;
107 default:
108 assert(0);
109 }
110 debug_printf("\n");
111 }
112 debug_printf("\n");
113 }
114