1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
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 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.
26 **************************************************************************/
29 #include "util/u_inlines.h"
30 #include "util/u_memory.h"
31 #include "util/u_string.h"
34 #include "i915_debug.h"
35 #include "i915_context.h"
36 #include "i915_screen.h"
37 #include "i915_surface.h"
38 #include "i915_resource.h"
39 #include "i915_winsys.h"
40 #include "i915_public.h"
49 i915_get_vendor(struct pipe_screen
*screen
)
51 return "VMware, Inc.";
55 i915_get_name(struct pipe_screen
*screen
)
57 static char buffer
[128];
60 switch (i915_screen(screen
)->iws
->pci_id
) {
64 case PCI_CHIP_I915_GM
:
70 case PCI_CHIP_I945_GM
:
73 case PCI_CHIP_I945_GME
:
90 util_snprintf(buffer
, sizeof(buffer
), "i915 (chipset: %s)", chipset
);
95 i915_get_param(struct pipe_screen
*screen
, enum pipe_cap param
)
98 case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS
:
100 case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS
:
102 case PIPE_CAP_MAX_COMBINED_SAMPLERS
:
104 case PIPE_CAP_NPOT_TEXTURES
:
106 case PIPE_CAP_TWO_SIDED_STENCIL
:
110 case PIPE_CAP_ANISOTROPIC_FILTER
:
112 case PIPE_CAP_POINT_SPRITE
:
114 case PIPE_CAP_MAX_RENDER_TARGETS
:
116 case PIPE_CAP_OCCLUSION_QUERY
:
118 case PIPE_CAP_TIMER_QUERY
:
120 case PIPE_CAP_TEXTURE_SHADOW_MAP
:
122 case PIPE_CAP_MAX_TEXTURE_2D_LEVELS
:
123 return I915_MAX_TEXTURE_2D_LEVELS
;
124 case PIPE_CAP_MAX_TEXTURE_3D_LEVELS
:
125 return I915_MAX_TEXTURE_3D_LEVELS
;
126 case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS
:
127 return I915_MAX_TEXTURE_2D_LEVELS
;
128 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT
:
129 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER
:
131 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT
:
132 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER
:
134 case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE
:
135 /* disable for now */
143 i915_get_paramf(struct pipe_screen
*screen
, enum pipe_cap param
)
146 case PIPE_CAP_MAX_LINE_WIDTH
:
148 case PIPE_CAP_MAX_LINE_WIDTH_AA
:
151 case PIPE_CAP_MAX_POINT_WIDTH
:
153 case PIPE_CAP_MAX_POINT_WIDTH_AA
:
156 case PIPE_CAP_MAX_TEXTURE_ANISOTROPY
:
159 case PIPE_CAP_MAX_TEXTURE_LOD_BIAS
:
168 i915_is_format_supported(struct pipe_screen
*screen
,
169 enum pipe_format format
,
170 enum pipe_texture_target target
,
171 unsigned sample_count
,
175 static const enum pipe_format tex_supported
[] = {
176 PIPE_FORMAT_B8G8R8A8_UNORM
,
177 PIPE_FORMAT_B8G8R8X8_UNORM
,
178 PIPE_FORMAT_R8G8B8A8_UNORM
,
180 PIPE_FORMAT_R8G8B8X8_UNORM
,
182 PIPE_FORMAT_B5G6R5_UNORM
,
183 PIPE_FORMAT_L8_UNORM
,
184 PIPE_FORMAT_A8_UNORM
,
185 PIPE_FORMAT_I8_UNORM
,
186 PIPE_FORMAT_L8A8_UNORM
,
190 PIPE_FORMAT_Z16_UNORM, */
191 PIPE_FORMAT_Z24X8_UNORM
,
192 PIPE_FORMAT_Z24_UNORM_S8_USCALED
,
193 PIPE_FORMAT_NONE
/* list terminator */
195 static const enum pipe_format render_supported
[] = {
196 PIPE_FORMAT_B8G8R8A8_UNORM
,
197 PIPE_FORMAT_B5G6R5_UNORM
,
198 PIPE_FORMAT_NONE
/* list terminator */
200 static const enum pipe_format depth_supported
[] = {
202 PIPE_FORMAT_Z16_UNORM, */
203 PIPE_FORMAT_Z24X8_UNORM
,
204 PIPE_FORMAT_Z24_UNORM_S8_USCALED
,
205 PIPE_FORMAT_NONE
/* list terminator */
207 const enum pipe_format
*list
;
210 if (sample_count
> 1)
213 if(tex_usage
& PIPE_BIND_DEPTH_STENCIL
)
214 list
= depth_supported
;
215 else if (tex_usage
& PIPE_BIND_RENDER_TARGET
)
216 list
= render_supported
;
218 list
= tex_supported
;
220 for (i
= 0; list
[i
] != PIPE_FORMAT_NONE
; i
++) {
221 if (list
[i
] == format
)
235 i915_fence_reference(struct pipe_screen
*screen
,
236 struct pipe_fence_handle
**ptr
,
237 struct pipe_fence_handle
*fence
)
239 struct i915_screen
*is
= i915_screen(screen
);
241 is
->iws
->fence_reference(is
->iws
, ptr
, fence
);
245 i915_fence_signalled(struct pipe_screen
*screen
,
246 struct pipe_fence_handle
*fence
,
249 struct i915_screen
*is
= i915_screen(screen
);
251 return is
->iws
->fence_signalled(is
->iws
, fence
);
255 i915_fence_finish(struct pipe_screen
*screen
,
256 struct pipe_fence_handle
*fence
,
259 struct i915_screen
*is
= i915_screen(screen
);
261 return is
->iws
->fence_finish(is
->iws
, fence
);
271 i915_destroy_screen(struct pipe_screen
*screen
)
273 struct i915_screen
*is
= i915_screen(screen
);
276 is
->iws
->destroy(is
->iws
);
282 * Create a new i915_screen object
285 i915_screen_create(struct i915_winsys
*iws
)
287 struct i915_screen
*is
= CALLOC_STRUCT(i915_screen
);
292 switch (iws
->pci_id
) {
293 case PCI_CHIP_I915_G
:
294 case PCI_CHIP_I915_GM
:
298 case PCI_CHIP_I945_G
:
299 case PCI_CHIP_I945_GM
:
300 case PCI_CHIP_I945_GME
:
308 debug_printf("%s: unknown pci id 0x%x, cannot create screen\n",
309 __FUNCTION__
, iws
->pci_id
);
316 is
->base
.winsys
= NULL
;
318 is
->base
.destroy
= i915_destroy_screen
;
320 is
->base
.get_name
= i915_get_name
;
321 is
->base
.get_vendor
= i915_get_vendor
;
322 is
->base
.get_param
= i915_get_param
;
323 is
->base
.get_paramf
= i915_get_paramf
;
324 is
->base
.is_format_supported
= i915_is_format_supported
;
326 is
->base
.context_create
= i915_create_context
;
328 is
->base
.fence_reference
= i915_fence_reference
;
329 is
->base
.fence_signalled
= i915_fence_signalled
;
330 is
->base
.fence_finish
= i915_fence_finish
;
332 i915_init_screen_resource_functions(is
);
333 i915_init_screen_surface_functions(is
);