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_context.h"
35 #include "i915_screen.h"
36 #include "i915_buffer.h"
37 #include "i915_texture.h"
38 #include "intel_winsys.h"
47 i915_get_vendor(struct pipe_screen
*screen
)
49 return "VMware, Inc.";
53 i915_get_name(struct pipe_screen
*screen
)
55 static char buffer
[128];
58 switch (i915_screen(screen
)->pci_id
) {
62 case PCI_CHIP_I915_GM
:
68 case PCI_CHIP_I945_GM
:
71 case PCI_CHIP_I945_GME
:
88 util_snprintf(buffer
, sizeof(buffer
), "i915 (chipset: %s)", chipset
);
93 i915_get_param(struct pipe_screen
*screen
, int param
)
96 case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS
:
98 case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS
:
100 case PIPE_CAP_MAX_COMBINED_SAMPLERS
:
102 case PIPE_CAP_NPOT_TEXTURES
:
104 case PIPE_CAP_TWO_SIDED_STENCIL
:
108 case PIPE_CAP_ANISOTROPIC_FILTER
:
110 case PIPE_CAP_POINT_SPRITE
:
112 case PIPE_CAP_MAX_RENDER_TARGETS
:
114 case PIPE_CAP_OCCLUSION_QUERY
:
116 case PIPE_CAP_TEXTURE_SHADOW_MAP
:
118 case PIPE_CAP_MAX_TEXTURE_2D_LEVELS
:
119 return I915_MAX_TEXTURE_2D_LEVELS
;
120 case PIPE_CAP_MAX_TEXTURE_3D_LEVELS
:
121 return I915_MAX_TEXTURE_3D_LEVELS
;
122 case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS
:
123 return I915_MAX_TEXTURE_2D_LEVELS
;
124 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT
:
125 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER
:
127 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT
:
128 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER
:
136 i915_get_paramf(struct pipe_screen
*screen
, int param
)
139 case PIPE_CAP_MAX_LINE_WIDTH
:
141 case PIPE_CAP_MAX_LINE_WIDTH_AA
:
144 case PIPE_CAP_MAX_POINT_WIDTH
:
146 case PIPE_CAP_MAX_POINT_WIDTH_AA
:
149 case PIPE_CAP_MAX_TEXTURE_ANISOTROPY
:
152 case PIPE_CAP_MAX_TEXTURE_LOD_BIAS
:
161 i915_is_format_supported(struct pipe_screen
*screen
,
162 enum pipe_format format
,
163 enum pipe_texture_target target
,
167 static const enum pipe_format tex_supported
[] = {
168 PIPE_FORMAT_A8B8G8R8_UNORM
,
169 PIPE_FORMAT_B8G8R8A8_UNORM
,
170 PIPE_FORMAT_B5G6R5_UNORM
,
171 PIPE_FORMAT_L8_UNORM
,
172 PIPE_FORMAT_A8_UNORM
,
173 PIPE_FORMAT_I8_UNORM
,
174 PIPE_FORMAT_L8A8_UNORM
,
177 PIPE_FORMAT_Z24S8_UNORM
,
178 PIPE_FORMAT_NONE
/* list terminator */
180 static const enum pipe_format surface_supported
[] = {
181 PIPE_FORMAT_B8G8R8A8_UNORM
,
182 PIPE_FORMAT_B5G6R5_UNORM
,
183 PIPE_FORMAT_Z24S8_UNORM
,
184 PIPE_FORMAT_NONE
/* list terminator */
186 const enum pipe_format
*list
;
189 if(tex_usage
& PIPE_TEXTURE_USAGE_RENDER_TARGET
)
190 list
= surface_supported
;
192 list
= tex_supported
;
194 for (i
= 0; list
[i
] != PIPE_FORMAT_NONE
; i
++) {
195 if (list
[i
] == format
)
209 i915_fence_reference(struct pipe_screen
*screen
,
210 struct pipe_fence_handle
**ptr
,
211 struct pipe_fence_handle
*fence
)
213 struct i915_screen
*is
= i915_screen(screen
);
215 is
->iws
->fence_reference(is
->iws
, ptr
, fence
);
219 i915_fence_signalled(struct pipe_screen
*screen
,
220 struct pipe_fence_handle
*fence
,
223 struct i915_screen
*is
= i915_screen(screen
);
225 return is
->iws
->fence_signalled(is
->iws
, fence
);
229 i915_fence_finish(struct pipe_screen
*screen
,
230 struct pipe_fence_handle
*fence
,
233 struct i915_screen
*is
= i915_screen(screen
);
235 return is
->iws
->fence_finish(is
->iws
, fence
);
245 i915_destroy_screen(struct pipe_screen
*screen
)
247 struct i915_screen
*is
= i915_screen(screen
);
250 is
->iws
->destroy(is
->iws
);
256 * Create a new i915_screen object
259 i915_create_screen(struct intel_winsys
*iws
, uint pci_id
)
261 struct i915_screen
*is
= CALLOC_STRUCT(i915_screen
);
267 case PCI_CHIP_I915_G
:
268 case PCI_CHIP_I915_GM
:
272 case PCI_CHIP_I945_G
:
273 case PCI_CHIP_I945_GM
:
274 case PCI_CHIP_I945_GME
:
282 debug_printf("%s: unknown pci id 0x%x, cannot create screen\n",
283 __FUNCTION__
, pci_id
);
291 is
->base
.winsys
= NULL
;
293 is
->base
.destroy
= i915_destroy_screen
;
295 is
->base
.get_name
= i915_get_name
;
296 is
->base
.get_vendor
= i915_get_vendor
;
297 is
->base
.get_param
= i915_get_param
;
298 is
->base
.get_paramf
= i915_get_paramf
;
299 is
->base
.is_format_supported
= i915_is_format_supported
;
301 is
->base
.context_create
= i915_create_context
;
303 is
->base
.fence_reference
= i915_fence_reference
;
304 is
->base
.fence_signalled
= i915_fence_signalled
;
305 is
->base
.fence_finish
= i915_fence_finish
;
307 i915_init_screen_texture_functions(is
);
308 i915_init_screen_buffer_functions(is
);