1 /**************************************************************************
3 * Copyright 2010 Vmware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * 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, sub license, 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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 #include "pipe/p_screen.h"
29 #include "util/u_format.h"
30 #include "util/u_debug.h"
34 util_check_caps_out(struct pipe_screen
*screen
, unsigned *list
, int *out
)
39 for (i
= 0; list
[i
];) {
41 case UTIL_CAPS_CHECK_CAP
:
42 if (!screen
->get_param(screen
, list
[i
++])) {
47 case UTIL_CAPS_CHECK_INT
:
48 tmpi
= screen
->get_param(screen
, list
[i
++]);
49 if (tmpi
< (int)list
[i
++]) {
54 case UTIL_CAPS_CHECK_FLOAT
:
55 tmpf
= screen
->get_paramf(screen
, list
[i
++]);
56 if (tmpf
< (float)list
[i
++]) {
61 case UTIL_CAPS_CHECK_FORMAT
:
62 if (!screen
->is_format_supported(screen
,
65 PIPE_BIND_SAMPLER_VIEW
,
72 assert(!"Unsupported check");
80 util_check_caps(struct pipe_screen
*screen
, unsigned *list
)
83 return util_check_caps_out(screen
, list
, &out
);
87 static unsigned caps_dx_9_1
[] = {
88 UTIL_CHECK_INT(MAX_RENDER_TARGETS
, 1),
89 UTIL_CHECK_INT(MAX_TEXTURE_2D_LEVELS
, 12), /* 2048 */
90 UTIL_CHECK_INT(MAX_TEXTURE_3D_LEVELS
, 9), /* 256 */
91 UTIL_CHECK_INT(MAX_TEXTURE_CUBE_LEVELS
, 10), /* 512 */
92 UTIL_CHECK_FLOAT(MAX_TEXTURE_ANISOTROPY
, 2),
97 static unsigned caps_dx_9_2
[] = {
98 UTIL_CHECK_CAP(OCCLUSION_QUERY
),
99 UTIL_CHECK_CAP(BLEND_EQUATION_SEPARATE
),
100 UTIL_CHECK_INT(MAX_RENDER_TARGETS
, 1),
101 UTIL_CHECK_INT(MAX_TEXTURE_2D_LEVELS
, 12), /* 2048 */
102 UTIL_CHECK_INT(MAX_TEXTURE_3D_LEVELS
, 9), /* 256 */
103 UTIL_CHECK_INT(MAX_TEXTURE_CUBE_LEVELS
, 10), /* 512 */
104 UTIL_CHECK_FLOAT(MAX_TEXTURE_ANISOTROPY
, 16),
109 static unsigned caps_dx_9_3
[] = {
111 //UTIL_CHECK_CAP(INSTANCING),
112 UTIL_CHECK_CAP(OCCLUSION_QUERY
),
113 UTIL_CHECK_INT(MAX_RENDER_TARGETS
, 4),
114 UTIL_CHECK_INT(MAX_TEXTURE_2D_LEVELS
, 13), /* 4096 */
115 UTIL_CHECK_INT(MAX_TEXTURE_3D_LEVELS
, 9), /* 256 */
116 UTIL_CHECK_INT(MAX_TEXTURE_CUBE_LEVELS
, 10), /* 512 */
117 UTIL_CHECK_FLOAT(MAX_TEXTURE_ANISOTROPY
, 16),
122 static unsigned caps_dx_10
[] = {
124 //UTIL_CHECK_CAP(INSTANCING),
125 UTIL_CHECK_CAP(OCCLUSION_QUERY
),
126 UTIL_CHECK_INT(MAX_RENDER_TARGETS
, 8),
127 UTIL_CHECK_INT(MAX_TEXTURE_2D_LEVELS
, 14), /* 8192 */
128 UTIL_CHECK_INT(MAX_TEXTURE_3D_LEVELS
, 12), /* 2048 */
129 UTIL_CHECK_INT(MAX_TEXTURE_CUBE_LEVELS
, 14), /* 8192 */
130 UTIL_CHECK_FLOAT(MAX_TEXTURE_ANISOTROPY
, 16),
135 static unsigned caps_dx_11
[] = {
137 //UTIL_CHECK_CAP(INSTANCING),
138 UTIL_CHECK_CAP(OCCLUSION_QUERY
),
139 UTIL_CHECK_INT(MAX_RENDER_TARGETS
, 8),
140 UTIL_CHECK_INT(MAX_TEXTURE_2D_LEVELS
, 14), /* 16384 */
141 UTIL_CHECK_INT(MAX_TEXTURE_3D_LEVELS
, 12), /* 2048 */
142 UTIL_CHECK_INT(MAX_TEXTURE_CUBE_LEVELS
, 14), /* 16384 */
143 UTIL_CHECK_FLOAT(MAX_TEXTURE_ANISOTROPY
, 16),
144 UTIL_CHECK_FORMAT(B8G8R8A8_UNORM
),
149 static unsigned caps_opengl_2_1
[] = {
150 UTIL_CHECK_CAP(GLSL
),
151 UTIL_CHECK_CAP(OCCLUSION_QUERY
),
152 UTIL_CHECK_CAP(TWO_SIDED_STENCIL
),
153 UTIL_CHECK_CAP(BLEND_EQUATION_SEPARATE
),
154 UTIL_CHECK_INT(MAX_RENDER_TARGETS
, 2), /* XXX 4? */
158 void util_caps_print_debug(struct pipe_screen
*screen
)
164 {"DX 9.1", caps_dx_9_1
},
165 {"DX 9.2", caps_dx_9_2
},
166 {"DX 9.3", caps_dx_9_3
},
167 {"DX 10", caps_dx_10
},
168 {"DX 11", caps_dx_11
},
169 {"OpenGL 2.1", caps_opengl_2_1
},
174 for (i
= 0; list
[i
].name
; i
++) {
175 if (util_check_caps_out(screen
, list
[i
].list
, &out
)) {
176 debug_printf("%s: %s yes\n", __func__
, list
[i
].name
);
179 switch (list
[i
].list
[out
]) {
180 case UTIL_CAPS_CHECK_CAP
:
181 debug_printf("%s: %s no (cap %u not supported)\n", __func__
,
183 list
[i
].list
[out
+ 1]);
185 case UTIL_CAPS_CHECK_INT
:
186 debug_printf("%s: %s no (cap %u less then %u)\n", __func__
,
188 list
[i
].list
[out
+ 1],
189 list
[i
].list
[out
+ 2]);
191 case UTIL_CAPS_CHECK_FLOAT
:
192 debug_printf("%s: %s no (cap %u less then %f)\n", __func__
,
194 list
[i
].list
[out
+ 1],
195 (double)(int)list
[i
].list
[out
+ 2]);
197 case UTIL_CAPS_CHECK_FORMAT
:
198 debug_printf("%s: %s no (format %s not supported)\n", __func__
,
200 util_format_name(list
[i
].list
[out
+ 1]) + 12);
203 assert(!"Unsupported check");