mesa,st/mesa: add a fast path for non-static VAOs
[mesa.git] / src / mesa / main / cpuinfo.c
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 2009 VMware, Inc. 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 "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26 #include <stdlib.h>
27 #include <string.h>
28 #include <assert.h>
29
30 #include "main/cpuinfo.h"
31
32
33 /**
34 * This function should be called before the various "cpu_has_foo" macros
35 * are used.
36 */
37 void
38 _mesa_get_cpu_features(void)
39 {
40 #if defined USE_X86_ASM || defined USE_X86_64_ASM
41 _mesa_get_x86_features();
42 #endif
43 }
44
45
46 /**
47 * Return a string describing the CPU architexture and extensions that
48 * Mesa is using (such as SSE or Altivec).
49 * \return information string, free it with free()
50 */
51 char *
52 _mesa_get_cpu_string(void)
53 {
54 #define MAX_STRING 50
55 char *buffer;
56
57 buffer = malloc(MAX_STRING);
58 if (!buffer)
59 return NULL;
60
61 buffer[0] = 0;
62
63 #ifdef USE_X86_ASM
64
65 if (_mesa_x86_cpu_features) {
66 strcat(buffer, "x86");
67 }
68
69 # ifdef USE_MMX_ASM
70 if (cpu_has_mmx) {
71 strcat(buffer, (cpu_has_mmxext) ? "/MMX+" : "/MMX");
72 }
73 # endif
74 # ifdef USE_3DNOW_ASM
75 if (cpu_has_3dnow) {
76 strcat(buffer, (cpu_has_3dnowext) ? "/3DNow!+" : "/3DNow!");
77 }
78 # endif
79 # ifdef USE_SSE_ASM
80 if (cpu_has_xmm) {
81 strcat(buffer, (cpu_has_xmm2) ? "/SSE2" : "/SSE");
82 }
83 # endif
84
85 #elif defined(USE_SPARC_ASM)
86
87 strcat(buffer, "SPARC");
88
89 #endif
90
91 assert(strlen(buffer) < MAX_STRING);
92
93 return buffer;
94 }