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_format.h"
31 #include "util/u_format_s3tc.h"
32 #include "util/u_inlines.h"
33 #include "util/u_memory.h"
34 #include "util/u_string.h"
37 #include "i915_debug.h"
38 #include "i915_context.h"
39 #include "i915_screen.h"
40 #include "i915_resource.h"
41 #include "i915_winsys.h"
42 #include "i915_public.h"
51 i915_get_vendor(struct pipe_screen
*screen
)
53 return "VMware, Inc.";
57 i915_get_name(struct pipe_screen
*screen
)
59 static char buffer
[128];
62 switch (i915_screen(screen
)->iws
->pci_id
) {
66 case PCI_CHIP_I915_GM
:
72 case PCI_CHIP_I945_GM
:
75 case PCI_CHIP_I945_GME
:
87 case PCI_CHIP_PINEVIEW_G
:
88 chipset
= "Pineview G";
90 case PCI_CHIP_PINEVIEW_M
:
91 chipset
= "Pineview M";
98 util_snprintf(buffer
, sizeof(buffer
), "i915 (chipset: %s)", chipset
);
103 i915_get_param(struct pipe_screen
*screen
, enum pipe_cap cap
)
105 struct i915_screen
*is
= i915_screen(screen
);
108 /* Supported features (boolean caps). */
109 case PIPE_CAP_ANISOTROPIC_FILTER
:
110 case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE
:
111 case PIPE_CAP_NPOT_TEXTURES
:
112 case PIPE_CAP_POINT_SPRITE
:
113 case PIPE_CAP_PRIMITIVE_RESTART
: /* draw module */
114 case PIPE_CAP_TEXTURE_MIRROR_REPEAT
:
115 case PIPE_CAP_TEXTURE_SHADOW_MAP
:
116 case PIPE_CAP_TWO_SIDED_STENCIL
:
119 /* Features that should be supported (boolean caps). */
120 /* XXX: Just test the code */
121 case PIPE_CAP_BLEND_EQUATION_SEPARATE
:
122 /* Also lie about these when asked to (needed for GLSL / GL 2.0) */
123 return is
->debug
.lie
? 1 : 0;
125 /* Unsupported features (boolean caps). */
126 case PIPE_CAP_ARRAY_TEXTURES
:
127 case PIPE_CAP_DEPTH_CLAMP
:
128 case PIPE_CAP_INDEP_BLEND_ENABLE
:
129 case PIPE_CAP_INDEP_BLEND_FUNC
:
130 case PIPE_CAP_TGSI_INSTANCEID
:
131 case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR
:
132 case PIPE_CAP_SHADER_STENCIL_EXPORT
:
133 case PIPE_CAP_TEXTURE_MIRROR_CLAMP
:
134 case PIPE_CAP_TEXTURE_SWIZZLE
:
135 case PIPE_CAP_TIMER_QUERY
:
137 case PIPE_CAP_SEAMLESS_CUBE_MAP
:
138 case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE
:
139 case PIPE_CAP_FRAGMENT_COLOR_CLAMP_CONTROL
:
140 case PIPE_CAP_MIXED_COLORBUFFER_FORMATS
:
143 /* Features we can lie about (boolean caps). */
145 case PIPE_CAP_OCCLUSION_QUERY
:
146 return is
->debug
.lie
? 1 : 0;
149 case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS
:
150 case PIPE_CAP_MAX_COMBINED_SAMPLERS
:
152 case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS
:
154 case PIPE_CAP_MAX_TEXTURE_2D_LEVELS
:
155 return I915_MAX_TEXTURE_2D_LEVELS
;
156 case PIPE_CAP_MAX_TEXTURE_3D_LEVELS
:
157 return I915_MAX_TEXTURE_3D_LEVELS
;
158 case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS
:
159 return I915_MAX_TEXTURE_2D_LEVELS
;
161 /* Render targets. */
162 case PIPE_CAP_MAX_RENDER_TARGETS
:
165 /* Fragment coordinate conventions. */
166 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT
:
167 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER
:
169 case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT
:
170 case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER
:
174 debug_printf("%s: Unknown cap %u.\n", __FUNCTION__
, cap
);
180 i915_get_shader_param(struct pipe_screen
*screen
, unsigned shader
, enum pipe_shader_cap cap
)
183 case PIPE_SHADER_VERTEX
:
184 return draw_get_shader_param(shader
, cap
);
185 case PIPE_SHADER_FRAGMENT
:
191 /* XXX: these are just shader model 2.0 values, fix this! */
193 case PIPE_SHADER_CAP_MAX_INSTRUCTIONS
:
195 case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS
:
197 case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS
:
199 case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS
:
201 case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
:
203 case PIPE_SHADER_CAP_MAX_INPUTS
:
205 case PIPE_SHADER_CAP_MAX_CONSTS
:
207 case PIPE_SHADER_CAP_MAX_CONST_BUFFERS
:
209 case PIPE_SHADER_CAP_MAX_TEMPS
:
210 return 12; /* XXX: 12 -> 32 ? */
211 case PIPE_SHADER_CAP_MAX_ADDRS
:
213 case PIPE_SHADER_CAP_MAX_PREDS
:
215 case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED
:
217 case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR
:
218 case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR
:
219 case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR
:
220 case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR
:
222 case PIPE_SHADER_CAP_SUBROUTINES
:
225 debug_printf("%s: Unknown cap %u.\n", __FUNCTION__
, cap
);
231 i915_get_paramf(struct pipe_screen
*screen
, enum pipe_cap cap
)
234 case PIPE_CAP_MAX_LINE_WIDTH
:
236 case PIPE_CAP_MAX_LINE_WIDTH_AA
:
239 case PIPE_CAP_MAX_POINT_WIDTH
:
241 case PIPE_CAP_MAX_POINT_WIDTH_AA
:
244 case PIPE_CAP_MAX_TEXTURE_ANISOTROPY
:
247 case PIPE_CAP_MAX_TEXTURE_LOD_BIAS
:
251 debug_printf("%s: Unknown cap %u.\n", __FUNCTION__
, cap
);
257 i915_is_format_supported(struct pipe_screen
*screen
,
258 enum pipe_format format
,
259 enum pipe_texture_target target
,
260 unsigned sample_count
,
263 static const enum pipe_format tex_supported
[] = {
264 PIPE_FORMAT_B8G8R8A8_UNORM
,
265 PIPE_FORMAT_B8G8R8X8_UNORM
,
266 PIPE_FORMAT_R8G8B8A8_UNORM
,
267 PIPE_FORMAT_R8G8B8X8_UNORM
,
268 PIPE_FORMAT_B5G6R5_UNORM
,
269 PIPE_FORMAT_L8_UNORM
,
270 PIPE_FORMAT_A8_UNORM
,
271 PIPE_FORMAT_I8_UNORM
,
272 PIPE_FORMAT_L8A8_UNORM
,
276 PIPE_FORMAT_Z16_UNORM, */
278 // AROS Quoke1 fix,seems to work,but probably better to fix SDL so
279 // that some other format is used.
281 PIPE_FORMAT_Z16_UNORM
,
283 PIPE_FORMAT_DXT1_RGB
,
284 PIPE_FORMAT_DXT1_RGBA
,
285 PIPE_FORMAT_DXT3_RGBA
,
286 PIPE_FORMAT_DXT5_RGBA
,
287 PIPE_FORMAT_Z24X8_UNORM
,
288 PIPE_FORMAT_Z24_UNORM_S8_USCALED
,
289 PIPE_FORMAT_NONE
/* list terminator */
291 static const enum pipe_format render_supported
[] = {
292 PIPE_FORMAT_B8G8R8A8_UNORM
,
293 PIPE_FORMAT_R8G8B8A8_UNORM
,
294 PIPE_FORMAT_B5G6R5_UNORM
,
295 PIPE_FORMAT_L8_UNORM
,
296 PIPE_FORMAT_A8_UNORM
,
297 PIPE_FORMAT_I8_UNORM
,
298 PIPE_FORMAT_NONE
/* list terminator */
300 static const enum pipe_format depth_supported
[] = {
302 PIPE_FORMAT_Z16_UNORM, */
303 PIPE_FORMAT_Z16_UNORM
, // AROS quake1 fix
304 PIPE_FORMAT_Z24X8_UNORM
,
305 PIPE_FORMAT_Z24_UNORM_S8_USCALED
,
306 PIPE_FORMAT_NONE
/* list terminator */
308 const enum pipe_format
*list
;
311 if (!util_format_is_supported(format
, tex_usage
))
314 if (sample_count
> 1)
317 if(tex_usage
& PIPE_BIND_DEPTH_STENCIL
)
318 list
= depth_supported
;
319 else if (tex_usage
& PIPE_BIND_RENDER_TARGET
)
320 list
= render_supported
;
322 list
= tex_supported
;
324 for (i
= 0; list
[i
] != PIPE_FORMAT_NONE
; i
++) {
325 if (list
[i
] == format
)
339 i915_fence_reference(struct pipe_screen
*screen
,
340 struct pipe_fence_handle
**ptr
,
341 struct pipe_fence_handle
*fence
)
343 struct i915_screen
*is
= i915_screen(screen
);
345 is
->iws
->fence_reference(is
->iws
, ptr
, fence
);
349 i915_fence_signalled(struct pipe_screen
*screen
,
350 struct pipe_fence_handle
*fence
)
352 struct i915_screen
*is
= i915_screen(screen
);
354 return is
->iws
->fence_signalled(is
->iws
, fence
) == 0;
358 i915_fence_finish(struct pipe_screen
*screen
,
359 struct pipe_fence_handle
*fence
,
362 struct i915_screen
*is
= i915_screen(screen
);
364 return is
->iws
->fence_finish(is
->iws
, fence
) == 0;
374 i915_flush_frontbuffer(struct pipe_screen
*screen
,
375 struct pipe_resource
*resource
,
376 unsigned level
, unsigned layer
,
377 void *winsys_drawable_handle
)
379 /* XXX: Dummy right now. */
384 (void)winsys_drawable_handle
;
388 i915_destroy_screen(struct pipe_screen
*screen
)
390 struct i915_screen
*is
= i915_screen(screen
);
393 is
->iws
->destroy(is
->iws
);
399 * Create a new i915_screen object
402 i915_screen_create(struct i915_winsys
*iws
)
404 struct i915_screen
*is
= CALLOC_STRUCT(i915_screen
);
409 switch (iws
->pci_id
) {
410 case PCI_CHIP_I915_G
:
411 case PCI_CHIP_I915_GM
:
415 case PCI_CHIP_I945_G
:
416 case PCI_CHIP_I945_GM
:
417 case PCI_CHIP_I945_GME
:
421 case PCI_CHIP_PINEVIEW_G
:
422 case PCI_CHIP_PINEVIEW_M
:
427 debug_printf("%s: unknown pci id 0x%x, cannot create screen\n",
428 __FUNCTION__
, iws
->pci_id
);
435 is
->base
.winsys
= NULL
;
437 is
->base
.destroy
= i915_destroy_screen
;
438 is
->base
.flush_frontbuffer
= i915_flush_frontbuffer
;
440 is
->base
.get_name
= i915_get_name
;
441 is
->base
.get_vendor
= i915_get_vendor
;
442 is
->base
.get_param
= i915_get_param
;
443 is
->base
.get_shader_param
= i915_get_shader_param
;
444 is
->base
.get_paramf
= i915_get_paramf
;
445 is
->base
.is_format_supported
= i915_is_format_supported
;
447 is
->base
.context_create
= i915_create_context
;
449 is
->base
.fence_reference
= i915_fence_reference
;
450 is
->base
.fence_signalled
= i915_fence_signalled
;
451 is
->base
.fence_finish
= i915_fence_finish
;
453 i915_init_screen_resource_functions(is
);
457 util_format_s3tc_init();