gallium: remove redundant includes
[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 "util/u_memory.h"
30 #include "util/u_simple_screen.h"
31 #include "pipe/p_defines.h"
32 #include "pipe/p_screen.h"
33
34 #include "cell/common.h"
35 #include "cell_context.h"
36 #include "cell_screen.h"
37 #include "cell_texture.h"
38 #include "cell_winsys.h"
39
40
41 static const char *
42 cell_get_vendor(struct pipe_screen *screen)
43 {
44 return "VMware, Inc.";
45 }
46
47
48 static const char *
49 cell_get_name(struct pipe_screen *screen)
50 {
51 return "Cell";
52 }
53
54
55 static int
56 cell_get_param(struct pipe_screen *screen, int param)
57 {
58 switch (param) {
59 case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
60 return CELL_MAX_SAMPLERS;
61 case PIPE_CAP_MAX_COMBINED_SAMPLERS:
62 return CELL_MAX_SAMPLERS;
63 case PIPE_CAP_NPOT_TEXTURES:
64 return 1;
65 case PIPE_CAP_TWO_SIDED_STENCIL:
66 return 1;
67 case PIPE_CAP_GLSL:
68 return 1;
69 case PIPE_CAP_ANISOTROPIC_FILTER:
70 return 0;
71 case PIPE_CAP_POINT_SPRITE:
72 return 1;
73 case PIPE_CAP_MAX_RENDER_TARGETS:
74 return 1;
75 case PIPE_CAP_OCCLUSION_QUERY:
76 return 1;
77 case PIPE_CAP_TEXTURE_SHADOW_MAP:
78 return 10;
79 case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
80 return CELL_MAX_TEXTURE_LEVELS;
81 case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
82 return 8; /* max 128x128x128 */
83 case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
84 return CELL_MAX_TEXTURE_LEVELS;
85 case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
86 return 1; /* XXX not really true */
87 case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
88 return 0; /* XXX to do */
89 case PIPE_CAP_TGSI_CONT_SUPPORTED:
90 return 1;
91 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
92 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
93 return 1;
94 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
95 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
96 return 0;
97 default:
98 return 0;
99 }
100 }
101
102
103 static float
104 cell_get_paramf(struct pipe_screen *screen, int param)
105 {
106 switch (param) {
107 case PIPE_CAP_MAX_LINE_WIDTH:
108 /* fall-through */
109 case PIPE_CAP_MAX_LINE_WIDTH_AA:
110 return 255.0; /* arbitrary */
111
112 case PIPE_CAP_MAX_POINT_WIDTH:
113 /* fall-through */
114 case PIPE_CAP_MAX_POINT_WIDTH_AA:
115 return 255.0; /* arbitrary */
116
117 case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
118 return 0.0;
119
120 case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
121 return 16.0; /* arbitrary */
122
123 default:
124 return 0;
125 }
126 }
127
128
129 static boolean
130 cell_is_format_supported( struct pipe_screen *screen,
131 enum pipe_format format,
132 enum pipe_texture_target target,
133 unsigned tex_usage,
134 unsigned geom_flags )
135 {
136 /* cell supports most formats, XXX for now anyway */
137 if (format == PIPE_FORMAT_DXT5_RGBA ||
138 format == PIPE_FORMAT_A8B8G8R8_SRGB)
139 return FALSE;
140 else
141 return TRUE;
142 }
143
144
145 static void
146 cell_destroy_screen( struct pipe_screen *screen )
147 {
148 struct pipe_winsys *winsys = screen->winsys;
149
150 if(winsys->destroy)
151 winsys->destroy(winsys);
152
153 FREE(screen);
154 }
155
156
157 /**
158 * Create a new pipe_screen object
159 * Note: we're not presently subclassing pipe_screen (no cell_screen) but
160 * that would be the place to put SPU thread/context info...
161 */
162 struct pipe_screen *
163 cell_create_screen(struct pipe_winsys *winsys)
164 {
165 struct pipe_screen *screen = CALLOC_STRUCT(pipe_screen);
166
167 if (!screen)
168 return NULL;
169
170 screen->winsys = winsys;
171
172 screen->destroy = cell_destroy_screen;
173
174 screen->get_name = cell_get_name;
175 screen->get_vendor = cell_get_vendor;
176 screen->get_param = cell_get_param;
177 screen->get_paramf = cell_get_paramf;
178 screen->is_format_supported = cell_is_format_supported;
179 screen->context_create = cell_create_context;
180
181 cell_init_screen_texture_funcs(screen);
182 u_simple_screen_init(screen);
183
184 return screen;
185 }