1848b8605Smrg/**************************************************************************
2848b8605Smrg *
3848b8605Smrg * Copyright 2007 VMware, Inc.
4848b8605Smrg * All Rights Reserved.
5848b8605Smrg *
6848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a
7848b8605Smrg * copy of this software and associated documentation files (the
8848b8605Smrg * "Software"), to deal in the Software without restriction, including
9848b8605Smrg * without limitation the rights to use, copy, modify, merge, publish,
10848b8605Smrg * distribute, sub license, and/or sell copies of the Software, and to
11848b8605Smrg * permit persons to whom the Software is furnished to do so, subject to
12848b8605Smrg * the following conditions:
13848b8605Smrg *
14848b8605Smrg * The above copyright notice and this permission notice (including the
15848b8605Smrg * next paragraph) shall be included in all copies or substantial portions
16848b8605Smrg * of the Software.
17848b8605Smrg *
18848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19848b8605Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20848b8605Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21848b8605Smrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22848b8605Smrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23848b8605Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24848b8605Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25848b8605Smrg *
26848b8605Smrg **************************************************************************/
27848b8605Smrg
28848b8605Smrg/*
29848b8605Smrg * Functions for specifying the post-transformation vertex layout.
30848b8605Smrg *
31848b8605Smrg * Author:
32848b8605Smrg *    Brian Paul
33848b8605Smrg *    Keith Whitwell
34848b8605Smrg */
35848b8605Smrg
36848b8605Smrg
37848b8605Smrg#include "draw/draw_private.h"
38848b8605Smrg#include "draw/draw_vertex.h"
39848b8605Smrg
40848b8605Smrg
41848b8605Smrg/**
42848b8605Smrg * Compute the size of a vertex, in dwords/floats, to update the
43848b8605Smrg * vinfo->size field.
44848b8605Smrg */
45848b8605Smrgvoid
46848b8605Smrgdraw_compute_vertex_size(struct vertex_info *vinfo)
47848b8605Smrg{
48848b8605Smrg   uint i;
49848b8605Smrg
50848b8605Smrg   vinfo->size = 0;
51848b8605Smrg   for (i = 0; i < vinfo->num_attribs; i++)
52848b8605Smrg      vinfo->size += draw_translate_vinfo_size(vinfo->attrib[i].emit);
53848b8605Smrg
54848b8605Smrg   assert(vinfo->size % 4 == 0);
55848b8605Smrg   /* in dwords */
56848b8605Smrg   vinfo->size /= 4;
57848b8605Smrg}
58848b8605Smrg
59848b8605Smrg
60848b8605Smrgvoid
61848b8605Smrgdraw_dump_emitted_vertex(const struct vertex_info *vinfo, const uint8_t *data)
62848b8605Smrg{
63848b8605Smrg   unsigned i;
64848b8605Smrg
65848b8605Smrg   for (i = 0; i < vinfo->num_attribs; i++) {
66848b8605Smrg      switch (vinfo->attrib[i].emit) {
67848b8605Smrg      case EMIT_OMIT:
68848b8605Smrg         debug_printf("EMIT_OMIT:");
69848b8605Smrg         break;
70848b8605Smrg      case EMIT_1F:
71848b8605Smrg         debug_printf("EMIT_1F:\t");
72848b8605Smrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
73848b8605Smrg         break;
74848b8605Smrg      case EMIT_1F_PSIZE:
75848b8605Smrg         debug_printf("EMIT_1F_PSIZE:\t");
76848b8605Smrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
77848b8605Smrg         break;
78848b8605Smrg      case EMIT_2F:
79848b8605Smrg         debug_printf("EMIT_2F:\t");
80848b8605Smrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
81848b8605Smrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
82848b8605Smrg         break;
83848b8605Smrg      case EMIT_3F:
84848b8605Smrg         debug_printf("EMIT_3F:\t");
85848b8605Smrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
86848b8605Smrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
87848b8605Smrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
88848b8605Smrg         data += sizeof(float);
89848b8605Smrg         break;
90848b8605Smrg      case EMIT_4F:
91848b8605Smrg         debug_printf("EMIT_4F:\t");
92848b8605Smrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
93848b8605Smrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
94848b8605Smrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
95848b8605Smrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
96848b8605Smrg         break;
97848b8605Smrg      case EMIT_4UB:
98848b8605Smrg         debug_printf("EMIT_4UB:\t");
99848b8605Smrg         debug_printf("%u ", *data++);
100848b8605Smrg         debug_printf("%u ", *data++);
101848b8605Smrg         debug_printf("%u ", *data++);
102848b8605Smrg         debug_printf("%u ", *data++);
103848b8605Smrg         break;
104848b8605Smrg      case EMIT_4UB_BGRA:
105848b8605Smrg         debug_printf("EMIT_4UB_BGRA:\t");
106848b8605Smrg         debug_printf("%u ", *data++);
107848b8605Smrg         debug_printf("%u ", *data++);
108848b8605Smrg         debug_printf("%u ", *data++);
109848b8605Smrg         debug_printf("%u ", *data++);
110848b8605Smrg         break;
111848b8605Smrg      default:
112848b8605Smrg         assert(0);
113848b8605Smrg      }
114848b8605Smrg      debug_printf("\n");
115848b8605Smrg   }
116848b8605Smrg   debug_printf("\n");
117848b8605Smrg}
118