cell: return CELL_MAX_SAMPLERS to indicate number of texture units
[mesa.git] / src / gallium / drivers / cell / ppu / cell_screen.c
1 /**************************************************************************
2 *
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * 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
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:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
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 TUNGSTEN GRAPHICS 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.
25 *
26 **************************************************************************/
27
28
29 #include "pipe/p_util.h"
30 #include "pipe/p_winsys.h"
31 #include "pipe/p_defines.h"
32 #include "pipe/p_screen.h"
33
34 #include "cell/common.h"
35 #include "cell_screen.h"
36 #include "cell_texture.h"
37 #include "cell_winsys.h"
38
39
40 static const char *
41 cell_get_vendor(struct pipe_screen *screen)
42 {
43 return "Tungsten Graphics, Inc.";
44 }
45
46
47 static const char *
48 cell_get_name(struct pipe_screen *screen)
49 {
50 return "Cell";
51 }
52
53
54 static int
55 cell_get_param(struct pipe_screen *screen, int param)
56 {
57 switch (param) {
58 case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
59 return CELL_MAX_SAMPLERS;
60 case PIPE_CAP_NPOT_TEXTURES:
61 return 0;
62 case PIPE_CAP_TWO_SIDED_STENCIL:
63 return 0;
64 case PIPE_CAP_GLSL:
65 return 1;
66 case PIPE_CAP_S3TC:
67 return 0;
68 case PIPE_CAP_ANISOTROPIC_FILTER:
69 return 0;
70 case PIPE_CAP_POINT_SPRITE:
71 return 0;
72 case PIPE_CAP_MAX_RENDER_TARGETS:
73 return 1;
74 case PIPE_CAP_OCCLUSION_QUERY:
75 return 0;
76 case PIPE_CAP_TEXTURE_SHADOW_MAP:
77 return 0;
78 case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
79 return 12; /* max 2Kx2K */
80 case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
81 return 8; /* max 128x128x128 */
82 case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
83 return 12; /* max 2Kx2K */
84 default:
85 return 0;
86 }
87 }
88
89
90 static float
91 cell_get_paramf(struct pipe_screen *screen, int param)
92 {
93 switch (param) {
94 case PIPE_CAP_MAX_LINE_WIDTH:
95 /* fall-through */
96 case PIPE_CAP_MAX_LINE_WIDTH_AA:
97 return 255.0; /* arbitrary */
98
99 case PIPE_CAP_MAX_POINT_WIDTH:
100 /* fall-through */
101 case PIPE_CAP_MAX_POINT_WIDTH_AA:
102 return 255.0; /* arbitrary */
103
104 case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
105 return 0.0;
106
107 case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
108 return 16.0; /* arbitrary */
109
110 default:
111 return 0;
112 }
113 }
114
115
116 static boolean
117 cell_is_format_supported( struct pipe_screen *screen,
118 enum pipe_format format, uint type )
119 {
120 switch (type) {
121 case PIPE_TEXTURE:
122 /* cell supports most texture formats, XXX for now anyway */
123 if (format == PIPE_FORMAT_DXT5_RGBA ||
124 format == PIPE_FORMAT_R8G8B8A8_SRGB)
125 return FALSE;
126 else
127 return TRUE;
128 case PIPE_SURFACE:
129 /* cell supports all (off-screen) surface formats, XXX for now */
130 return TRUE;
131 default:
132 assert(0);
133 return FALSE;
134 }
135 }
136
137
138 static void
139 cell_destroy_screen( struct pipe_screen *screen )
140 {
141 FREE(screen);
142 }
143
144
145 /**
146 * Create a new pipe_screen object
147 * Note: we're not presently subclassing pipe_screen (no cell_screen) but
148 * that would be the place to put SPU thread/context info...
149 */
150 struct pipe_screen *
151 cell_create_screen(struct pipe_winsys *winsys)
152 {
153 struct pipe_screen *screen = CALLOC_STRUCT(pipe_screen);
154
155 if (!screen)
156 return NULL;
157
158 screen->winsys = winsys;
159
160 screen->destroy = cell_destroy_screen;
161
162 screen->get_name = cell_get_name;
163 screen->get_vendor = cell_get_vendor;
164 screen->get_param = cell_get_param;
165 screen->get_paramf = cell_get_paramf;
166 screen->is_format_supported = cell_is_format_supported;
167
168 cell_init_screen_texture_funcs(screen);
169
170 return screen;
171 }