r300g: add blacklist for apps that shouldn't steal hyperz access
[mesa.git] / src / gallium / drivers / r300 / r300_chipset.c
1 /*
2 * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
3 * Copyright 2011 Marek Olšák <maraeo@gmail.com>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
23
24 #include "r300_chipset.h"
25
26 #include "util/u_debug.h"
27 #include "util/u_memory.h"
28
29 #include <stdio.h>
30 #include <errno.h>
31
32 /* r300_chipset: A file all to itself for deducing the various properties of
33 * Radeons. */
34
35 static void r300_apply_hyperz_blacklist(struct r300_capabilities* caps)
36 {
37 static const char *list[] = {
38 "X", /* the DDX or indirect rendering */
39 "Xorg", /* (alternative name) */
40 "check_gl_texture_size", /* compiz */
41 "Compiz",
42 "gnome-session-check-accelerated-helper",
43 "gnome-shell",
44 "kwin_opengl_test",
45 "kwin",
46 "firefox",
47 };
48 int i;
49
50 for (i = 0; i < Elements(list); i++) {
51 if (strcmp(list[i], program_invocation_short_name) == 0) {
52 caps->zmask_ram = 0;
53 caps->hiz_ram = 0;
54 break;
55 }
56 }
57 }
58
59 /* Parse a PCI ID and fill an r300_capabilities struct with information. */
60 void r300_parse_chipset(uint32_t pci_id, struct r300_capabilities* caps)
61 {
62 switch (pci_id) {
63 #define CHIPSET(pci_id, name, chipfamily) \
64 case pci_id: \
65 caps->family = CHIP_FAMILY_##chipfamily; \
66 break;
67 #include "pci_ids/r300_pci_ids.h"
68 #undef CHIPSET
69
70 default:
71 fprintf(stderr, "r300: Warning: Unknown chipset 0x%x\nAborting...",
72 pci_id);
73 abort();
74 }
75
76 /* Defaults. */
77 caps->high_second_pipe = FALSE;
78 caps->num_vert_fpus = 0;
79 caps->hiz_ram = 0;
80 caps->zmask_ram = 0;
81
82
83 switch (caps->family) {
84 case CHIP_FAMILY_R300:
85 case CHIP_FAMILY_R350:
86 caps->high_second_pipe = TRUE;
87 caps->num_vert_fpus = 4;
88 caps->hiz_ram = R300_HIZ_LIMIT;
89 caps->zmask_ram = PIPE_ZMASK_SIZE;
90 break;
91
92 case CHIP_FAMILY_RV350:
93 case CHIP_FAMILY_RV370:
94 caps->high_second_pipe = TRUE;
95 caps->num_vert_fpus = 2;
96 caps->zmask_ram = RV3xx_ZMASK_SIZE;
97 break;
98
99 case CHIP_FAMILY_RV380:
100 caps->high_second_pipe = TRUE;
101 caps->num_vert_fpus = 2;
102 caps->hiz_ram = R300_HIZ_LIMIT;
103 caps->zmask_ram = RV3xx_ZMASK_SIZE;
104 break;
105
106 case CHIP_FAMILY_RS400:
107 case CHIP_FAMILY_RS600:
108 case CHIP_FAMILY_RS690:
109 case CHIP_FAMILY_RS740:
110 break;
111
112 case CHIP_FAMILY_RC410:
113 case CHIP_FAMILY_RS480:
114 caps->zmask_ram = RV3xx_ZMASK_SIZE;
115 break;
116
117 case CHIP_FAMILY_R420:
118 case CHIP_FAMILY_R423:
119 case CHIP_FAMILY_R430:
120 case CHIP_FAMILY_R480:
121 case CHIP_FAMILY_R481:
122 case CHIP_FAMILY_RV410:
123 caps->num_vert_fpus = 6;
124 caps->hiz_ram = R300_HIZ_LIMIT;
125 caps->zmask_ram = PIPE_ZMASK_SIZE;
126 break;
127
128 case CHIP_FAMILY_R520:
129 caps->num_vert_fpus = 8;
130 caps->hiz_ram = R300_HIZ_LIMIT;
131 caps->zmask_ram = PIPE_ZMASK_SIZE;
132 break;
133
134 case CHIP_FAMILY_RV515:
135 caps->num_vert_fpus = 2;
136 caps->hiz_ram = R300_HIZ_LIMIT;
137 caps->zmask_ram = PIPE_ZMASK_SIZE;
138 break;
139
140 case CHIP_FAMILY_RV530:
141 caps->num_vert_fpus = 5;
142 caps->hiz_ram = RV530_HIZ_LIMIT;
143 caps->zmask_ram = PIPE_ZMASK_SIZE;
144 break;
145
146 case CHIP_FAMILY_R580:
147 case CHIP_FAMILY_RV560:
148 case CHIP_FAMILY_RV570:
149 caps->num_vert_fpus = 8;
150 caps->hiz_ram = RV530_HIZ_LIMIT;
151 caps->zmask_ram = PIPE_ZMASK_SIZE;
152 break;
153 }
154
155 caps->num_tex_units = 16;
156 caps->is_r400 = caps->family >= CHIP_FAMILY_R420 && caps->family < CHIP_FAMILY_RV515;
157 caps->is_r500 = caps->family >= CHIP_FAMILY_RV515;
158 caps->is_rv350 = caps->family >= CHIP_FAMILY_RV350;
159 caps->z_compress = caps->is_rv350 ? R300_ZCOMP_8X8 : R300_ZCOMP_4X4;
160 caps->dxtc_swizzle = caps->is_r400 || caps->is_r500;
161 caps->has_us_format = caps->family == CHIP_FAMILY_R520;
162 caps->has_tcl = caps->num_vert_fpus > 0;
163
164 if (caps->has_tcl) {
165 caps->has_tcl = debug_get_bool_option("RADEON_NO_TCL", FALSE) ? FALSE : TRUE;
166 }
167
168 r300_apply_hyperz_blacklist(caps);
169 }