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"
48 i915_get_vendor(struct pipe_screen
*screen
)
50 return "VMware, Inc.";
54 i915_get_name(struct pipe_screen
*screen
)
56 static char buffer
[128];
59 switch (i915_screen(screen
)->iws
->pci_id
) {
63 case PCI_CHIP_I915_GM
:
69 case PCI_CHIP_I945_GM
:
72 case PCI_CHIP_I945_GME
:
89 util_snprintf(buffer
, sizeof(buffer
), "i915 (chipset: %s)", chipset
);
94 i915_get_param(struct pipe_screen
*screen
, enum pipe_cap param
)
97 case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS
:
99 case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS
:
101 case PIPE_CAP_MAX_COMBINED_SAMPLERS
:
103 case PIPE_CAP_NPOT_TEXTURES
:
105 case PIPE_CAP_TWO_SIDED_STENCIL
:
109 case PIPE_CAP_ANISOTROPIC_FILTER
:
111 case PIPE_CAP_POINT_SPRITE
:
113 case PIPE_CAP_MAX_RENDER_TARGETS
:
115 case PIPE_CAP_OCCLUSION_QUERY
:
117 case PIPE_CAP_TIMER_QUERY
:
119 case PIPE_CAP_TEXTURE_SHADOW_MAP
:
121 case PIPE_CAP_MAX_TEXTURE_2D_LEVELS
:
122 return I915_MAX_TEXTURE_2D_LEVELS
;
123 case PIPE_CAP_MAX_TEXTURE_3D_LEVELS
:
124 return I915_MAX_TEXTURE_3D_LEVELS
;
125 case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS
:
126 return I915_MAX_TEXTURE_2D_LEVELS
;
127 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT
:
128 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER
:
130 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT
:
131 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER
:
133 case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE
:
134 /* disable for now */
142 i915_get_paramf(struct pipe_screen
*screen
, enum pipe_cap param
)
145 case PIPE_CAP_MAX_LINE_WIDTH
:
147 case PIPE_CAP_MAX_LINE_WIDTH_AA
:
150 case PIPE_CAP_MAX_POINT_WIDTH
:
152 case PIPE_CAP_MAX_POINT_WIDTH_AA
:
155 case PIPE_CAP_MAX_TEXTURE_ANISOTROPY
:
158 case PIPE_CAP_MAX_TEXTURE_LOD_BIAS
:
167 i915_is_format_supported(struct pipe_screen
*screen
,
168 enum pipe_format format
,
169 enum pipe_texture_target target
,
170 unsigned sample_count
,
174 static const enum pipe_format tex_supported
[] = {
175 PIPE_FORMAT_B8G8R8A8_UNORM
,
176 PIPE_FORMAT_B8G8R8X8_UNORM
,
177 PIPE_FORMAT_R8G8B8A8_UNORM
,
179 PIPE_FORMAT_R8G8B8X8_UNORM
,
181 PIPE_FORMAT_B5G6R5_UNORM
,
182 PIPE_FORMAT_L8_UNORM
,
183 PIPE_FORMAT_A8_UNORM
,
184 PIPE_FORMAT_I8_UNORM
,
185 PIPE_FORMAT_L8A8_UNORM
,
189 PIPE_FORMAT_Z16_UNORM, */
190 PIPE_FORMAT_Z24X8_UNORM
,
191 PIPE_FORMAT_Z24_UNORM_S8_USCALED
,
192 PIPE_FORMAT_NONE
/* list terminator */
194 static const enum pipe_format render_supported
[] = {
195 PIPE_FORMAT_B8G8R8A8_UNORM
,
196 PIPE_FORMAT_B5G6R5_UNORM
,
197 PIPE_FORMAT_NONE
/* list terminator */
199 static const enum pipe_format depth_supported
[] = {
201 PIPE_FORMAT_Z16_UNORM, */
202 PIPE_FORMAT_Z24X8_UNORM
,
203 PIPE_FORMAT_Z24_UNORM_S8_USCALED
,
204 PIPE_FORMAT_NONE
/* list terminator */
206 const enum pipe_format
*list
;
209 if (sample_count
> 1)
212 if(tex_usage
& PIPE_BIND_DEPTH_STENCIL
)
213 list
= depth_supported
;
214 else if (tex_usage
& PIPE_BIND_RENDER_TARGET
)
215 list
= render_supported
;
217 list
= tex_supported
;
219 for (i
= 0; list
[i
] != PIPE_FORMAT_NONE
; i
++) {
220 if (list
[i
] == format
)
234 i915_fence_reference(struct pipe_screen
*screen
,
235 struct pipe_fence_handle
**ptr
,
236 struct pipe_fence_handle
*fence
)
238 struct i915_screen
*is
= i915_screen(screen
);
240 is
->iws
->fence_reference(is
->iws
, ptr
, fence
);
244 i915_fence_signalled(struct pipe_screen
*screen
,
245 struct pipe_fence_handle
*fence
,
248 struct i915_screen
*is
= i915_screen(screen
);
250 return is
->iws
->fence_signalled(is
->iws
, fence
);
254 i915_fence_finish(struct pipe_screen
*screen
,
255 struct pipe_fence_handle
*fence
,
258 struct i915_screen
*is
= i915_screen(screen
);
260 return is
->iws
->fence_finish(is
->iws
, fence
);
270 i915_destroy_screen(struct pipe_screen
*screen
)
272 struct i915_screen
*is
= i915_screen(screen
);
275 is
->iws
->destroy(is
->iws
);
281 * Create a new i915_screen object
284 i915_screen_create(struct i915_winsys
*iws
)
286 struct i915_screen
*is
= CALLOC_STRUCT(i915_screen
);
291 switch (iws
->pci_id
) {
292 case PCI_CHIP_I915_G
:
293 case PCI_CHIP_I915_GM
:
297 case PCI_CHIP_I945_G
:
298 case PCI_CHIP_I945_GM
:
299 case PCI_CHIP_I945_GME
:
307 debug_printf("%s: unknown pci id 0x%x, cannot create screen\n",
308 __FUNCTION__
, iws
->pci_id
);
315 is
->base
.winsys
= NULL
;
317 is
->base
.destroy
= i915_destroy_screen
;
319 is
->base
.get_name
= i915_get_name
;
320 is
->base
.get_vendor
= i915_get_vendor
;
321 is
->base
.get_param
= i915_get_param
;
322 is
->base
.get_paramf
= i915_get_paramf
;
323 is
->base
.is_format_supported
= i915_is_format_supported
;
325 is
->base
.context_create
= i915_create_context
;
327 is
->base
.fence_reference
= i915_fence_reference
;
328 is
->base
.fence_signalled
= i915_fence_signalled
;
329 is
->base
.fence_finish
= i915_fence_finish
;
331 i915_init_screen_resource_functions(is
);
332 i915_init_screen_surface_functions(is
);