14a49301eSmrg/**************************************************************************
24a49301eSmrg *
3af69d88dSmrg * Copyright 2007 VMware, Inc.
44a49301eSmrg * All Rights Reserved.
54a49301eSmrg *
64a49301eSmrg * Permission is hereby granted, free of charge, to any person obtaining a
74a49301eSmrg * copy of this software and associated documentation files (the
84a49301eSmrg * "Software"), to deal in the Software without restriction, including
94a49301eSmrg * without limitation the rights to use, copy, modify, merge, publish,
104a49301eSmrg * distribute, sub license, and/or sell copies of the Software, and to
114a49301eSmrg * permit persons to whom the Software is furnished to do so, subject to
124a49301eSmrg * the following conditions:
134a49301eSmrg *
144a49301eSmrg * The above copyright notice and this permission notice (including the
154a49301eSmrg * next paragraph) shall be included in all copies or substantial portions
164a49301eSmrg * of the Software.
174a49301eSmrg *
184a49301eSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
194a49301eSmrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
204a49301eSmrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21af69d88dSmrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
224a49301eSmrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
234a49301eSmrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
244a49301eSmrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
254a49301eSmrg *
264a49301eSmrg **************************************************************************/
274a49301eSmrg
284a49301eSmrg/*
294a49301eSmrg * Functions for specifying the post-transformation vertex layout.
304a49301eSmrg *
314a49301eSmrg * Author:
324a49301eSmrg *    Brian Paul
334a49301eSmrg *    Keith Whitwell
344a49301eSmrg */
354a49301eSmrg
364a49301eSmrg
374a49301eSmrg#include "draw/draw_private.h"
384a49301eSmrg#include "draw/draw_vertex.h"
394a49301eSmrg
404a49301eSmrg
414a49301eSmrg/**
424a49301eSmrg * Compute the size of a vertex, in dwords/floats, to update the
434a49301eSmrg * vinfo->size field.
444a49301eSmrg */
454a49301eSmrgvoid
464a49301eSmrgdraw_compute_vertex_size(struct vertex_info *vinfo)
474a49301eSmrg{
484a49301eSmrg   uint i;
494a49301eSmrg
504a49301eSmrg   vinfo->size = 0;
513464ebd5Sriastradh   for (i = 0; i < vinfo->num_attribs; i++)
523464ebd5Sriastradh      vinfo->size += draw_translate_vinfo_size(vinfo->attrib[i].emit);
533464ebd5Sriastradh
543464ebd5Sriastradh   assert(vinfo->size % 4 == 0);
553464ebd5Sriastradh   /* in dwords */
563464ebd5Sriastradh   vinfo->size /= 4;
574a49301eSmrg}
584a49301eSmrg
594a49301eSmrg
604a49301eSmrgvoid
614a49301eSmrgdraw_dump_emitted_vertex(const struct vertex_info *vinfo, const uint8_t *data)
624a49301eSmrg{
633464ebd5Sriastradh   unsigned i;
644a49301eSmrg
654a49301eSmrg   for (i = 0; i < vinfo->num_attribs; i++) {
664a49301eSmrg      switch (vinfo->attrib[i].emit) {
674a49301eSmrg      case EMIT_OMIT:
684a49301eSmrg         debug_printf("EMIT_OMIT:");
694a49301eSmrg         break;
704a49301eSmrg      case EMIT_1F:
714a49301eSmrg         debug_printf("EMIT_1F:\t");
724a49301eSmrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
734a49301eSmrg         break;
744a49301eSmrg      case EMIT_1F_PSIZE:
754a49301eSmrg         debug_printf("EMIT_1F_PSIZE:\t");
764a49301eSmrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
774a49301eSmrg         break;
784a49301eSmrg      case EMIT_2F:
794a49301eSmrg         debug_printf("EMIT_2F:\t");
804a49301eSmrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
814a49301eSmrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
824a49301eSmrg         break;
834a49301eSmrg      case EMIT_3F:
844a49301eSmrg         debug_printf("EMIT_3F:\t");
854a49301eSmrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
864a49301eSmrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
874a49301eSmrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
884a49301eSmrg         data += sizeof(float);
894a49301eSmrg         break;
904a49301eSmrg      case EMIT_4F:
914a49301eSmrg         debug_printf("EMIT_4F:\t");
924a49301eSmrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
934a49301eSmrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
944a49301eSmrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
954a49301eSmrg         debug_printf("%f ", *(float *)data); data += sizeof(float);
964a49301eSmrg         break;
974a49301eSmrg      case EMIT_4UB:
984a49301eSmrg         debug_printf("EMIT_4UB:\t");
994a49301eSmrg         debug_printf("%u ", *data++);
1004a49301eSmrg         debug_printf("%u ", *data++);
1014a49301eSmrg         debug_printf("%u ", *data++);
1024a49301eSmrg         debug_printf("%u ", *data++);
1034a49301eSmrg         break;
1043464ebd5Sriastradh      case EMIT_4UB_BGRA:
1053464ebd5Sriastradh         debug_printf("EMIT_4UB_BGRA:\t");
1063464ebd5Sriastradh         debug_printf("%u ", *data++);
1073464ebd5Sriastradh         debug_printf("%u ", *data++);
1083464ebd5Sriastradh         debug_printf("%u ", *data++);
1093464ebd5Sriastradh         debug_printf("%u ", *data++);
1103464ebd5Sriastradh         break;
1114a49301eSmrg      default:
1124a49301eSmrg         assert(0);
1134a49301eSmrg      }
1144a49301eSmrg      debug_printf("\n");
1154a49301eSmrg   }
1164a49301eSmrg   debug_printf("\n");
1174a49301eSmrg}
118