i965g: more work on compiling
[mesa.git] / src / gallium / drivers / i965 / brw_state_debug.c
1 /*
2 Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
4 develop this 3D driver.
5
6 Permission is hereby granted, free of charge, to any person obtaining
7 a 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, sublicense, 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
16 portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
26 **********************************************************************/
27
28
29
30 #include "brw_context.h"
31 #include "brw_state.h"
32
33
34 struct dirty_bit_map {
35 uint32_t bit;
36 char *name;
37 uint32_t count;
38 };
39
40 #define DEFINE_BIT(name) {name, #name, 0}
41
42 static struct dirty_bit_map mesa_bits[] = {
43 DEFINE_BIT(_NEW_MODELVIEW),
44 DEFINE_BIT(_NEW_PROJECTION),
45 DEFINE_BIT(_NEW_TEXTURE_MATRIX),
46 DEFINE_BIT(_NEW_COLOR_MATRIX),
47 DEFINE_BIT(_NEW_ACCUM),
48 DEFINE_BIT(_NEW_COLOR),
49 DEFINE_BIT(_NEW_DEPTH),
50 DEFINE_BIT(_NEW_EVAL),
51 DEFINE_BIT(_NEW_FOG),
52 DEFINE_BIT(_NEW_HINT),
53 DEFINE_BIT(_NEW_LIGHT),
54 DEFINE_BIT(_NEW_LINE),
55 DEFINE_BIT(_NEW_PIXEL),
56 DEFINE_BIT(_NEW_POINT),
57 DEFINE_BIT(_NEW_POLYGON),
58 DEFINE_BIT(_NEW_POLYGONSTIPPLE),
59 DEFINE_BIT(_NEW_SCISSOR),
60 DEFINE_BIT(_NEW_STENCIL),
61 DEFINE_BIT(_NEW_TEXTURE),
62 DEFINE_BIT(_NEW_TRANSFORM),
63 DEFINE_BIT(_NEW_VIEWPORT),
64 DEFINE_BIT(_NEW_PACKUNPACK),
65 DEFINE_BIT(_NEW_ARRAY),
66 DEFINE_BIT(_NEW_RENDERMODE),
67 DEFINE_BIT(_NEW_BUFFERS),
68 DEFINE_BIT(_NEW_MULTISAMPLE),
69 DEFINE_BIT(_NEW_TRACK_MATRIX),
70 DEFINE_BIT(_NEW_PROGRAM),
71 DEFINE_BIT(_NEW_PROGRAM_CONSTANTS),
72 {0, 0, 0}
73 };
74
75 static struct dirty_bit_map brw_bits[] = {
76 DEFINE_BIT(BRW_NEW_URB_FENCE),
77 DEFINE_BIT(BRW_NEW_FRAGMENT_PROGRAM),
78 DEFINE_BIT(BRW_NEW_VERTEX_PROGRAM),
79 DEFINE_BIT(BRW_NEW_INPUT_DIMENSIONS),
80 DEFINE_BIT(BRW_NEW_CURBE_OFFSETS),
81 DEFINE_BIT(BRW_NEW_REDUCED_PRIMITIVE),
82 DEFINE_BIT(BRW_NEW_PRIMITIVE),
83 DEFINE_BIT(BRW_NEW_CONTEXT),
84 DEFINE_BIT(BRW_NEW_WM_INPUT_DIMENSIONS),
85 DEFINE_BIT(BRW_NEW_PSP),
86 DEFINE_BIT(BRW_NEW_FENCE),
87 DEFINE_BIT(BRW_NEW_INDICES),
88 DEFINE_BIT(BRW_NEW_INDEX_BUFFER),
89 DEFINE_BIT(BRW_NEW_VERTICES),
90 DEFINE_BIT(BRW_NEW_BATCH),
91 DEFINE_BIT(BRW_NEW_DEPTH_BUFFER),
92 {0, 0, 0}
93 };
94
95 static struct dirty_bit_map cache_bits[] = {
96 DEFINE_BIT(CACHE_NEW_CC_VP),
97 DEFINE_BIT(CACHE_NEW_CC_UNIT),
98 DEFINE_BIT(CACHE_NEW_WM_PROG),
99 DEFINE_BIT(CACHE_NEW_SAMPLER_DEFAULT_COLOR),
100 DEFINE_BIT(CACHE_NEW_SAMPLER),
101 DEFINE_BIT(CACHE_NEW_WM_UNIT),
102 DEFINE_BIT(CACHE_NEW_SF_PROG),
103 DEFINE_BIT(CACHE_NEW_SF_VP),
104 DEFINE_BIT(CACHE_NEW_SF_UNIT),
105 DEFINE_BIT(CACHE_NEW_VS_UNIT),
106 DEFINE_BIT(CACHE_NEW_VS_PROG),
107 DEFINE_BIT(CACHE_NEW_GS_UNIT),
108 DEFINE_BIT(CACHE_NEW_GS_PROG),
109 DEFINE_BIT(CACHE_NEW_CLIP_VP),
110 DEFINE_BIT(CACHE_NEW_CLIP_UNIT),
111 DEFINE_BIT(CACHE_NEW_CLIP_PROG),
112 DEFINE_BIT(CACHE_NEW_SURFACE),
113 DEFINE_BIT(CACHE_NEW_SURF_BIND),
114 {0, 0, 0}
115 };
116
117
118 static void
119 brw_update_dirty_count(struct dirty_bit_map *bit_map, int32_t bits)
120 {
121 int i;
122
123 for (i = 0; i < 32; i++) {
124 if (bit_map[i].bit == 0)
125 return;
126
127 if (bit_map[i].bit & bits)
128 bit_map[i].count++;
129 }
130 }
131
132 static void
133 brw_print_dirty_count(struct dirty_bit_map *bit_map, int32_t bits)
134 {
135 int i;
136
137 for (i = 0; i < 32; i++) {
138 if (bit_map[i].bit == 0)
139 return;
140
141 fprintf(stderr, "0x%08x: %12d (%s)\n",
142 bit_map[i].bit, bit_map[i].count, bit_map[i].name);
143 }
144 }
145