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 "draw/draw_context.h"
30 #include "util/u_inlines.h"
31 #include "util/u_memory.h"
32 #include "util/u_string.h"
35 #include "i915_debug.h"
36 #include "i915_context.h"
37 #include "i915_screen.h"
38 #include "i915_surface.h"
39 #include "i915_resource.h"
40 #include "i915_winsys.h"
41 #include "i915_public.h"
50 i915_get_vendor(struct pipe_screen
*screen
)
52 return "VMware, Inc.";
56 i915_get_name(struct pipe_screen
*screen
)
58 static char buffer
[128];
61 switch (i915_screen(screen
)->iws
->pci_id
) {
65 case PCI_CHIP_I915_GM
:
71 case PCI_CHIP_I945_GM
:
74 case PCI_CHIP_I945_GME
:
86 case PCI_CHIP_PINEVIEW_G
:
87 chipset
= "Pineview G";
89 case PCI_CHIP_PINEVIEW_M
:
90 chipset
= "Pineview M";
97 util_snprintf(buffer
, sizeof(buffer
), "i915 (chipset: %s)", chipset
);
102 i915_get_param(struct pipe_screen
*screen
, enum pipe_cap param
)
105 case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS
:
107 case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS
:
109 case PIPE_CAP_MAX_COMBINED_SAMPLERS
:
111 case PIPE_CAP_NPOT_TEXTURES
:
113 case PIPE_CAP_TWO_SIDED_STENCIL
:
117 case PIPE_CAP_ANISOTROPIC_FILTER
:
119 case PIPE_CAP_POINT_SPRITE
:
121 case PIPE_CAP_MAX_RENDER_TARGETS
:
123 case PIPE_CAP_OCCLUSION_QUERY
:
125 case PIPE_CAP_TIMER_QUERY
:
127 case PIPE_CAP_TEXTURE_SHADOW_MAP
:
129 case PIPE_CAP_MAX_TEXTURE_2D_LEVELS
:
130 return I915_MAX_TEXTURE_2D_LEVELS
;
131 case PIPE_CAP_MAX_TEXTURE_3D_LEVELS
:
132 return I915_MAX_TEXTURE_3D_LEVELS
;
133 case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS
:
134 return I915_MAX_TEXTURE_2D_LEVELS
;
135 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT
:
136 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER
:
138 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT
:
139 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER
:
141 case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE
:
142 /* disable for now */
150 i915_get_shader_param(struct pipe_screen
*screen
, unsigned shader
, enum pipe_shader_cap param
)
153 case PIPE_SHADER_VERTEX
:
154 return draw_get_shader_param(shader
, param
);
155 case PIPE_SHADER_FRAGMENT
:
161 /* XXX: these are just shader model 2.0 values, fix this! */
163 case PIPE_SHADER_CAP_MAX_INSTRUCTIONS
:
165 case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS
:
167 case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS
:
169 case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS
:
171 case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
:
173 case PIPE_SHADER_CAP_MAX_INPUTS
:
175 case PIPE_SHADER_CAP_MAX_CONSTS
:
177 case PIPE_SHADER_CAP_MAX_CONST_BUFFERS
:
179 case PIPE_SHADER_CAP_MAX_TEMPS
:
180 return 12; /* XXX: 12 -> 32 ? */
181 case PIPE_SHADER_CAP_MAX_ADDRS
:
183 case PIPE_SHADER_CAP_MAX_PREDS
:
185 case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED
:
187 case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR
:
188 case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR
:
189 case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR
:
190 case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR
:
199 i915_get_paramf(struct pipe_screen
*screen
, enum pipe_cap param
)
202 case PIPE_CAP_MAX_LINE_WIDTH
:
204 case PIPE_CAP_MAX_LINE_WIDTH_AA
:
207 case PIPE_CAP_MAX_POINT_WIDTH
:
209 case PIPE_CAP_MAX_POINT_WIDTH_AA
:
212 case PIPE_CAP_MAX_TEXTURE_ANISOTROPY
:
215 case PIPE_CAP_MAX_TEXTURE_LOD_BIAS
:
224 i915_is_format_supported(struct pipe_screen
*screen
,
225 enum pipe_format format
,
226 enum pipe_texture_target target
,
227 unsigned sample_count
,
231 static const enum pipe_format tex_supported
[] = {
232 PIPE_FORMAT_B8G8R8A8_UNORM
,
233 PIPE_FORMAT_B8G8R8X8_UNORM
,
234 PIPE_FORMAT_R8G8B8A8_UNORM
,
236 PIPE_FORMAT_R8G8B8X8_UNORM
,
238 PIPE_FORMAT_B5G6R5_UNORM
,
239 PIPE_FORMAT_L8_UNORM
,
240 PIPE_FORMAT_A8_UNORM
,
241 PIPE_FORMAT_I8_UNORM
,
242 PIPE_FORMAT_L8A8_UNORM
,
246 PIPE_FORMAT_Z16_UNORM, */
247 PIPE_FORMAT_Z24X8_UNORM
,
248 PIPE_FORMAT_Z24_UNORM_S8_USCALED
,
249 PIPE_FORMAT_NONE
/* list terminator */
251 static const enum pipe_format render_supported
[] = {
252 PIPE_FORMAT_B8G8R8A8_UNORM
,
253 PIPE_FORMAT_B5G6R5_UNORM
,
254 PIPE_FORMAT_NONE
/* list terminator */
256 static const enum pipe_format depth_supported
[] = {
258 PIPE_FORMAT_Z16_UNORM, */
259 PIPE_FORMAT_Z24X8_UNORM
,
260 PIPE_FORMAT_Z24_UNORM_S8_USCALED
,
261 PIPE_FORMAT_NONE
/* list terminator */
263 const enum pipe_format
*list
;
266 if (sample_count
> 1)
269 if(tex_usage
& PIPE_BIND_DEPTH_STENCIL
)
270 list
= depth_supported
;
271 else if (tex_usage
& PIPE_BIND_RENDER_TARGET
)
272 list
= render_supported
;
274 list
= tex_supported
;
276 for (i
= 0; list
[i
] != PIPE_FORMAT_NONE
; i
++) {
277 if (list
[i
] == format
)
291 i915_fence_reference(struct pipe_screen
*screen
,
292 struct pipe_fence_handle
**ptr
,
293 struct pipe_fence_handle
*fence
)
295 struct i915_screen
*is
= i915_screen(screen
);
297 is
->iws
->fence_reference(is
->iws
, ptr
, fence
);
301 i915_fence_signalled(struct pipe_screen
*screen
,
302 struct pipe_fence_handle
*fence
,
305 struct i915_screen
*is
= i915_screen(screen
);
307 return is
->iws
->fence_signalled(is
->iws
, fence
);
311 i915_fence_finish(struct pipe_screen
*screen
,
312 struct pipe_fence_handle
*fence
,
315 struct i915_screen
*is
= i915_screen(screen
);
317 return is
->iws
->fence_finish(is
->iws
, fence
);
327 i915_destroy_screen(struct pipe_screen
*screen
)
329 struct i915_screen
*is
= i915_screen(screen
);
332 is
->iws
->destroy(is
->iws
);
338 * Create a new i915_screen object
341 i915_screen_create(struct i915_winsys
*iws
)
343 struct i915_screen
*is
= CALLOC_STRUCT(i915_screen
);
348 switch (iws
->pci_id
) {
349 case PCI_CHIP_I915_G
:
350 case PCI_CHIP_I915_GM
:
354 case PCI_CHIP_I945_G
:
355 case PCI_CHIP_I945_GM
:
356 case PCI_CHIP_I945_GME
:
360 case PCI_CHIP_PINEVIEW_G
:
361 case PCI_CHIP_PINEVIEW_M
:
366 debug_printf("%s: unknown pci id 0x%x, cannot create screen\n",
367 __FUNCTION__
, iws
->pci_id
);
374 is
->base
.winsys
= NULL
;
376 is
->base
.destroy
= i915_destroy_screen
;
378 is
->base
.get_name
= i915_get_name
;
379 is
->base
.get_vendor
= i915_get_vendor
;
380 is
->base
.get_param
= i915_get_param
;
381 is
->base
.get_shader_param
= i915_get_shader_param
;
382 is
->base
.get_paramf
= i915_get_paramf
;
383 is
->base
.is_format_supported
= i915_is_format_supported
;
385 is
->base
.context_create
= i915_create_context
;
387 is
->base
.fence_reference
= i915_fence_reference
;
388 is
->base
.fence_signalled
= i915_fence_signalled
;
389 is
->base
.fence_finish
= i915_fence_finish
;
391 i915_init_screen_resource_functions(is
);
392 i915_init_screen_surface_functions(is
);