1 /**************************************************************************
3 * Copyright 2003 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 **************************************************************************/
31 #include "state_tracker/st_public.h"
32 #include "i915simple/i915_screen.h"
34 #include "intel_context.h"
35 #include "intel_device.h"
36 #include "intel_batchbuffer.h"
37 #include "intel_egl.h"
40 extern const struct dri_extension card_extensions
[];
44 intel_create_device(struct egl_drm_device
*device
)
46 struct intel_device
*intel_device
;
48 /* Allocate the private area */
49 intel_device
= CALLOC_STRUCT(intel_device
);
53 device
->priv
= (void *)intel_device
;
54 intel_device
->device
= device
;
56 intel_device
->deviceID
= device
->deviceID
;
58 intel_be_init_device(&intel_device
->base
, device
->drmFD
, intel_device
->deviceID
);
60 intel_device
->pipe
= i915_create_screen(&intel_device
->base
.base
, intel_device
->deviceID
);
63 driInitExtensions(NULL
, card_extensions
, GL_FALSE
);
69 intel_destroy_device(struct egl_drm_device
*device
)
71 struct intel_device
*intel_device
= (struct intel_device
*)device
->priv
;
73 intel_be_destroy_device(&intel_device
->base
);
82 intel_create_drawable(struct egl_drm_drawable
*drawable
,
83 const __GLcontextModes
* visual
)
85 enum pipe_format colorFormat
, depthFormat
, stencilFormat
;
86 struct intel_framebuffer
*intelfb
= CALLOC_STRUCT(intel_framebuffer
);
91 intelfb
->device
= drawable
->device
->priv
;
93 if (visual
->redBits
== 5)
94 colorFormat
= PIPE_FORMAT_R5G6B5_UNORM
;
96 colorFormat
= PIPE_FORMAT_A8R8G8B8_UNORM
;
98 if (visual
->depthBits
== 16)
99 depthFormat
= PIPE_FORMAT_Z16_UNORM
;
100 else if (visual
->depthBits
== 24)
101 depthFormat
= PIPE_FORMAT_S8Z24_UNORM
;
103 depthFormat
= PIPE_FORMAT_NONE
;
105 if (visual
->stencilBits
== 8)
106 stencilFormat
= PIPE_FORMAT_S8Z24_UNORM
;
108 stencilFormat
= PIPE_FORMAT_NONE
;
110 intelfb
->stfb
= st_create_framebuffer(visual
,
118 if (!intelfb
->stfb
) {
123 drawable
->priv
= (void *) intelfb
;
128 intel_destroy_drawable(struct egl_drm_drawable
*drawable
)
130 struct intel_framebuffer
*intelfb
= (struct intel_framebuffer
*)drawable
->priv
;
131 drawable
->priv
= NULL
;
133 assert(intelfb
->stfb
);
134 st_unreference_framebuffer(&intelfb
->stfb
);