Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 1 | /************************************************************************** |
| 2 | * |
| 3 | * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. |
| 4 | * All Rights Reserved. |
| 5 | * |
| 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: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice (including the |
| 15 | * next paragraph) shall be included in all copies or substantial portions |
| 16 | * of the Software. |
| 17 | * |
| 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. |
| 25 | * |
| 26 | **************************************************************************/ |
| 27 | |
Eric Anholt | f6ca4a3 | 2011-03-09 12:54:14 -0800 | [diff] [blame] | 28 | #include <errno.h> |
Brian Paul | ecadb51 | 2008-09-18 15:17:05 -0600 | [diff] [blame] | 29 | #include "main/glheader.h" |
| 30 | #include "main/context.h" |
| 31 | #include "main/framebuffer.h" |
Brian Paul | ecadb51 | 2008-09-18 15:17:05 -0600 | [diff] [blame] | 32 | #include "main/renderbuffer.h" |
Kristian Høgsberg | 2d99588 | 2010-02-11 17:18:01 -0500 | [diff] [blame] | 33 | #include "main/hash.h" |
Kristian Høgsberg | d7322c9 | 2010-02-26 14:49:31 -0500 | [diff] [blame] | 34 | #include "main/fbobject.h" |
Vinson Lee | 45a56e4 | 2011-01-09 01:25:54 -0800 | [diff] [blame] | 35 | #include "main/mfeatures.h" |
Brian Paul | 6c244b0 | 2009-01-26 12:38:46 -0700 | [diff] [blame] | 36 | |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 37 | #include "utils.h" |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 38 | #include "xmlpool.h" |
| 39 | |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 40 | PUBLIC const char __driConfigOptions[] = |
Eric Anholt | a0e453a | 2008-01-17 14:23:04 -0800 | [diff] [blame] | 41 | DRI_CONF_BEGIN |
| 42 | DRI_CONF_SECTION_PERFORMANCE |
Jesse Barnes | e9bf3e4 | 2008-07-31 11:50:37 -0700 | [diff] [blame] | 43 | DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_ALWAYS_SYNC) |
Eric Anholt | fe91c05 | 2008-03-05 14:14:54 -0800 | [diff] [blame] | 44 | /* Options correspond to DRI_CONF_BO_REUSE_DISABLED, |
| 45 | * DRI_CONF_BO_REUSE_ALL |
| 46 | */ |
Dave Airlie | f75843a | 2008-08-24 17:59:10 +1000 | [diff] [blame] | 47 | DRI_CONF_OPT_BEGIN_V(bo_reuse, enum, 1, "0:1") |
Eric Anholt | fe91c05 | 2008-03-05 14:14:54 -0800 | [diff] [blame] | 48 | DRI_CONF_DESC_BEGIN(en, "Buffer object reuse") |
| 49 | DRI_CONF_ENUM(0, "Disable buffer object reuse") |
| 50 | DRI_CONF_ENUM(1, "Enable reuse of all sizes of buffer objects") |
| 51 | DRI_CONF_DESC_END |
| 52 | DRI_CONF_OPT_END |
Eric Anholt | 1ba9665 | 2009-06-03 16:40:20 +0000 | [diff] [blame] | 53 | |
Eric Anholt | 8e7a8d6 | 2010-03-03 11:51:51 -0800 | [diff] [blame] | 54 | DRI_CONF_OPT_BEGIN(texture_tiling, bool, true) |
| 55 | DRI_CONF_DESC(en, "Enable texture tiling") |
| 56 | DRI_CONF_OPT_END |
Eric Anholt | 1ba9665 | 2009-06-03 16:40:20 +0000 | [diff] [blame] | 57 | |
Eric Anholt | b30dc2c | 2009-06-09 16:12:43 -0700 | [diff] [blame] | 58 | DRI_CONF_OPT_BEGIN(early_z, bool, false) |
| 59 | DRI_CONF_DESC(en, "Enable early Z in classic mode (unstable, 945-only).") |
| 60 | DRI_CONF_OPT_END |
| 61 | |
Eric Anholt | a58514c | 2010-08-17 15:07:22 -0700 | [diff] [blame] | 62 | DRI_CONF_OPT_BEGIN(fragment_shader, bool, true) |
Eric Anholt | 862a2a5 | 2009-07-29 13:00:09 -0700 | [diff] [blame] | 63 | DRI_CONF_DESC(en, "Enable limited ARB_fragment_shader support on 915/945.") |
| 64 | DRI_CONF_OPT_END |
| 65 | |
Eric Anholt | a0e453a | 2008-01-17 14:23:04 -0800 | [diff] [blame] | 66 | DRI_CONF_SECTION_END |
| 67 | DRI_CONF_SECTION_QUALITY |
| 68 | DRI_CONF_FORCE_S3TC_ENABLE(false) |
Michel Dänzer | acba9c1 | 2008-04-29 18:43:28 +0200 | [diff] [blame] | 69 | DRI_CONF_ALLOW_LARGE_TEXTURES(2) |
Eric Anholt | a0e453a | 2008-01-17 14:23:04 -0800 | [diff] [blame] | 70 | DRI_CONF_SECTION_END |
| 71 | DRI_CONF_SECTION_DEBUG |
| 72 | DRI_CONF_NO_RAST(false) |
Eric Anholt | 40bc274 | 2009-03-05 17:18:49 -0800 | [diff] [blame] | 73 | DRI_CONF_ALWAYS_FLUSH_BATCH(false) |
Eric Anholt | f368728 | 2009-03-05 17:08:36 -0800 | [diff] [blame] | 74 | DRI_CONF_ALWAYS_FLUSH_CACHE(false) |
Eric Anholt | 81aa5d7 | 2009-07-29 13:07:49 -0700 | [diff] [blame] | 75 | |
| 76 | DRI_CONF_OPT_BEGIN(stub_occlusion_query, bool, false) |
| 77 | DRI_CONF_DESC(en, "Enable stub ARB_occlusion_query support on 915/945.") |
| 78 | DRI_CONF_OPT_END |
Eric Anholt | a0e453a | 2008-01-17 14:23:04 -0800 | [diff] [blame] | 79 | DRI_CONF_SECTION_END |
| 80 | DRI_CONF_END; |
| 81 | |
Eric Anholt | 1e4677a | 2009-12-26 18:43:20 -0800 | [diff] [blame] | 82 | const GLuint __driNConfigOptions = 11; |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 83 | |
Eric Anholt | df9f891 | 2010-12-13 11:02:15 -0800 | [diff] [blame] | 84 | #include "intel_batchbuffer.h" |
| 85 | #include "intel_buffers.h" |
| 86 | #include "intel_bufmgr.h" |
| 87 | #include "intel_chipset.h" |
| 88 | #include "intel_fbo.h" |
Chad Versace | da2816a | 2011-11-16 14:04:25 -0800 | [diff] [blame^] | 89 | #include "intel_mipmap_tree.h" |
Eric Anholt | df9f891 | 2010-12-13 11:02:15 -0800 | [diff] [blame] | 90 | #include "intel_screen.h" |
| 91 | #include "intel_tex.h" |
| 92 | #include "intel_regions.h" |
| 93 | |
| 94 | #include "i915_drm.h" |
| 95 | |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 96 | #ifdef USE_NEW_INTERFACE |
Eric Anholt | 85063f1 | 2008-02-13 16:08:19 -0800 | [diff] [blame] | 97 | static PFNGLXCREATECONTEXTMODES create_context_modes = NULL; |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 98 | #endif /*USE_NEW_INTERFACE */ |
| 99 | |
Kristian Høgsberg | 6d48779 | 2008-02-14 22:12:51 -0500 | [diff] [blame] | 100 | static const __DRItexBufferExtension intelTexBufferExtension = { |
| 101 | { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION }, |
| 102 | intelSetTexBuffer, |
Eric Anholt | 66175aa | 2009-03-18 12:07:09 -0700 | [diff] [blame] | 103 | intelSetTexBuffer2, |
Kristian Høgsberg | 6d48779 | 2008-02-14 22:12:51 -0500 | [diff] [blame] | 104 | }; |
| 105 | |
Kristian Høgsberg | 7c50d29 | 2010-01-08 12:35:47 -0500 | [diff] [blame] | 106 | static void |
| 107 | intelDRI2Flush(__DRIdrawable *drawable) |
| 108 | { |
Eric Anholt | dea5e57 | 2011-02-14 18:57:49 -0800 | [diff] [blame] | 109 | GET_CURRENT_CONTEXT(ctx); |
| 110 | struct intel_context *intel = intel_context(ctx); |
Kristian Høgsberg | 7c50d29 | 2010-01-08 12:35:47 -0500 | [diff] [blame] | 111 | |
| 112 | if (intel->gen < 4) |
| 113 | INTEL_FIREVERTICES(intel); |
| 114 | |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 115 | intel->need_throttle = true; |
Kristian Høgsberg | e67c338 | 2010-05-18 21:50:44 -0400 | [diff] [blame] | 116 | |
Chris Wilson | 8d68a90 | 2011-02-10 20:25:51 +0000 | [diff] [blame] | 117 | if (intel->batch.used) |
| 118 | intel_batchbuffer_flush(intel); |
Kristian Høgsberg | 7c50d29 | 2010-01-08 12:35:47 -0500 | [diff] [blame] | 119 | } |
| 120 | |
Kristian Høgsberg | 7c50d29 | 2010-01-08 12:35:47 -0500 | [diff] [blame] | 121 | static const struct __DRI2flushExtensionRec intelFlushExtension = { |
| 122 | { __DRI2_FLUSH, __DRI2_FLUSH_VERSION }, |
| 123 | intelDRI2Flush, |
Kristian Høgsberg | e67c338 | 2010-05-18 21:50:44 -0400 | [diff] [blame] | 124 | dri2InvalidateDrawable, |
Kristian Høgsberg | 7c50d29 | 2010-01-08 12:35:47 -0500 | [diff] [blame] | 125 | }; |
| 126 | |
Kristian Høgsberg | c262471 | 2010-02-11 18:59:40 -0500 | [diff] [blame] | 127 | static __DRIimage * |
Kristian Høgsberg | 9ec0b2a | 2010-09-22 15:07:15 -0400 | [diff] [blame] | 128 | intel_create_image_from_name(__DRIscreen *screen, |
Kristian Høgsberg | c262471 | 2010-02-11 18:59:40 -0500 | [diff] [blame] | 129 | int width, int height, int format, |
| 130 | int name, int pitch, void *loaderPrivate) |
| 131 | { |
George Sapountzis | 875a757 | 2011-11-03 13:04:57 +0200 | [diff] [blame] | 132 | struct intel_screen *intelScreen = screen->driverPrivate; |
Kristian Høgsberg | c262471 | 2010-02-11 18:59:40 -0500 | [diff] [blame] | 133 | __DRIimage *image; |
Kristian Høgsberg | c262471 | 2010-02-11 18:59:40 -0500 | [diff] [blame] | 134 | int cpp; |
| 135 | |
| 136 | image = CALLOC(sizeof *image); |
| 137 | if (image == NULL) |
| 138 | return NULL; |
| 139 | |
| 140 | switch (format) { |
| 141 | case __DRI_IMAGE_FORMAT_RGB565: |
| 142 | image->format = MESA_FORMAT_RGB565; |
| 143 | image->internal_format = GL_RGB; |
| 144 | image->data_type = GL_UNSIGNED_BYTE; |
| 145 | break; |
| 146 | case __DRI_IMAGE_FORMAT_XRGB8888: |
| 147 | image->format = MESA_FORMAT_XRGB8888; |
| 148 | image->internal_format = GL_RGB; |
| 149 | image->data_type = GL_UNSIGNED_BYTE; |
| 150 | break; |
| 151 | case __DRI_IMAGE_FORMAT_ARGB8888: |
| 152 | image->format = MESA_FORMAT_ARGB8888; |
| 153 | image->internal_format = GL_RGBA; |
| 154 | image->data_type = GL_UNSIGNED_BYTE; |
| 155 | break; |
Chia-I Wu | 9fe197c | 2011-08-21 21:36:40 +0800 | [diff] [blame] | 156 | case __DRI_IMAGE_FORMAT_ABGR8888: |
| 157 | image->format = MESA_FORMAT_RGBA8888_REV; |
| 158 | image->internal_format = GL_RGBA; |
| 159 | image->data_type = GL_UNSIGNED_BYTE; |
| 160 | break; |
Kristian Høgsberg | c262471 | 2010-02-11 18:59:40 -0500 | [diff] [blame] | 161 | default: |
| 162 | free(image); |
| 163 | return NULL; |
| 164 | } |
| 165 | |
| 166 | image->data = loaderPrivate; |
| 167 | cpp = _mesa_get_format_bytes(image->format); |
| 168 | |
Kristian Høgsberg | 9ec0b2a | 2010-09-22 15:07:15 -0400 | [diff] [blame] | 169 | image->region = intel_region_alloc_for_handle(intelScreen, |
Kristian Høgsberg | 9087ba1 | 2010-06-03 21:56:21 -0400 | [diff] [blame] | 170 | cpp, width, height, |
Kristian Høgsberg | c262471 | 2010-02-11 18:59:40 -0500 | [diff] [blame] | 171 | pitch, name, "image"); |
| 172 | if (image->region == NULL) { |
| 173 | FREE(image); |
| 174 | return NULL; |
| 175 | } |
| 176 | |
| 177 | return image; |
| 178 | } |
| 179 | |
| 180 | static __DRIimage * |
| 181 | intel_create_image_from_renderbuffer(__DRIcontext *context, |
| 182 | int renderbuffer, void *loaderPrivate) |
| 183 | { |
| 184 | __DRIimage *image; |
| 185 | struct intel_context *intel = context->driverPrivate; |
| 186 | struct gl_renderbuffer *rb; |
| 187 | struct intel_renderbuffer *irb; |
| 188 | |
Kristian Høgsberg | d7322c9 | 2010-02-26 14:49:31 -0500 | [diff] [blame] | 189 | rb = _mesa_lookup_renderbuffer(&intel->ctx, renderbuffer); |
Kristian Høgsberg | c262471 | 2010-02-11 18:59:40 -0500 | [diff] [blame] | 190 | if (!rb) { |
| 191 | _mesa_error(&intel->ctx, |
| 192 | GL_INVALID_OPERATION, "glRenderbufferExternalMESA"); |
| 193 | return NULL; |
| 194 | } |
| 195 | |
| 196 | irb = intel_renderbuffer(rb); |
| 197 | image = CALLOC(sizeof *image); |
| 198 | if (image == NULL) |
| 199 | return NULL; |
| 200 | |
| 201 | image->internal_format = rb->InternalFormat; |
| 202 | image->format = rb->Format; |
| 203 | image->data_type = rb->DataType; |
| 204 | image->data = loaderPrivate; |
Chad Versace | da2816a | 2011-11-16 14:04:25 -0800 | [diff] [blame^] | 205 | intel_region_reference(&image->region, irb->mt->region); |
Kristian Høgsberg | c262471 | 2010-02-11 18:59:40 -0500 | [diff] [blame] | 206 | |
| 207 | return image; |
| 208 | } |
| 209 | |
| 210 | static void |
| 211 | intel_destroy_image(__DRIimage *image) |
| 212 | { |
| 213 | intel_region_release(&image->region); |
| 214 | FREE(image); |
| 215 | } |
| 216 | |
Kristian Høgsberg | f301932 | 2010-06-06 20:39:19 -0400 | [diff] [blame] | 217 | static __DRIimage * |
| 218 | intel_create_image(__DRIscreen *screen, |
| 219 | int width, int height, int format, |
| 220 | unsigned int use, |
| 221 | void *loaderPrivate) |
| 222 | { |
| 223 | __DRIimage *image; |
George Sapountzis | 875a757 | 2011-11-03 13:04:57 +0200 | [diff] [blame] | 224 | struct intel_screen *intelScreen = screen->driverPrivate; |
Kristian Høgsberg | e5169e9 | 2011-05-06 10:31:18 -0400 | [diff] [blame] | 225 | uint32_t tiling; |
Kristian Høgsberg | f301932 | 2010-06-06 20:39:19 -0400 | [diff] [blame] | 226 | int cpp; |
| 227 | |
Kristian Høgsberg | e5169e9 | 2011-05-06 10:31:18 -0400 | [diff] [blame] | 228 | tiling = I915_TILING_X; |
| 229 | if (use & __DRI_IMAGE_USE_CURSOR) { |
| 230 | if (width != 64 || height != 64) |
| 231 | return NULL; |
| 232 | tiling = I915_TILING_NONE; |
| 233 | } |
| 234 | |
Kristian Høgsberg | f301932 | 2010-06-06 20:39:19 -0400 | [diff] [blame] | 235 | image = CALLOC(sizeof *image); |
| 236 | if (image == NULL) |
| 237 | return NULL; |
| 238 | |
| 239 | switch (format) { |
| 240 | case __DRI_IMAGE_FORMAT_RGB565: |
| 241 | image->format = MESA_FORMAT_RGB565; |
| 242 | image->internal_format = GL_RGB; |
| 243 | image->data_type = GL_UNSIGNED_BYTE; |
| 244 | break; |
| 245 | case __DRI_IMAGE_FORMAT_XRGB8888: |
| 246 | image->format = MESA_FORMAT_XRGB8888; |
| 247 | image->internal_format = GL_RGB; |
| 248 | image->data_type = GL_UNSIGNED_BYTE; |
| 249 | break; |
| 250 | case __DRI_IMAGE_FORMAT_ARGB8888: |
| 251 | image->format = MESA_FORMAT_ARGB8888; |
| 252 | image->internal_format = GL_RGBA; |
| 253 | image->data_type = GL_UNSIGNED_BYTE; |
| 254 | break; |
Chia-I Wu | 9fe197c | 2011-08-21 21:36:40 +0800 | [diff] [blame] | 255 | case __DRI_IMAGE_FORMAT_ABGR8888: |
| 256 | image->format = MESA_FORMAT_RGBA8888_REV; |
| 257 | image->internal_format = GL_RGBA; |
| 258 | image->data_type = GL_UNSIGNED_BYTE; |
| 259 | break; |
Kristian Høgsberg | f301932 | 2010-06-06 20:39:19 -0400 | [diff] [blame] | 260 | default: |
| 261 | free(image); |
| 262 | return NULL; |
| 263 | } |
| 264 | |
| 265 | image->data = loaderPrivate; |
| 266 | cpp = _mesa_get_format_bytes(image->format); |
| 267 | |
| 268 | image->region = |
Kristian Høgsberg | e5169e9 | 2011-05-06 10:31:18 -0400 | [diff] [blame] | 269 | intel_region_alloc(intelScreen, tiling, |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 270 | cpp, width, height, true); |
Kristian Høgsberg | f301932 | 2010-06-06 20:39:19 -0400 | [diff] [blame] | 271 | if (image->region == NULL) { |
| 272 | FREE(image); |
| 273 | return NULL; |
| 274 | } |
| 275 | |
| 276 | return image; |
| 277 | } |
| 278 | |
| 279 | static GLboolean |
| 280 | intel_query_image(__DRIimage *image, int attrib, int *value) |
| 281 | { |
| 282 | switch (attrib) { |
| 283 | case __DRI_IMAGE_ATTRIB_STRIDE: |
| 284 | *value = image->region->pitch * image->region->cpp; |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 285 | return true; |
Kristian Høgsberg | f301932 | 2010-06-06 20:39:19 -0400 | [diff] [blame] | 286 | case __DRI_IMAGE_ATTRIB_HANDLE: |
Eric Anholt | 8004a1c | 2011-09-22 11:58:37 -0700 | [diff] [blame] | 287 | *value = image->region->bo->handle; |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 288 | return true; |
Kristian Høgsberg | f301932 | 2010-06-06 20:39:19 -0400 | [diff] [blame] | 289 | case __DRI_IMAGE_ATTRIB_NAME: |
| 290 | return intel_region_flink(image->region, (uint32_t *) value); |
| 291 | default: |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 292 | return false; |
Kristian Høgsberg | f301932 | 2010-06-06 20:39:19 -0400 | [diff] [blame] | 293 | } |
| 294 | } |
| 295 | |
Benjamin Franzke | 3af3c58 | 2011-03-09 20:56:02 +0100 | [diff] [blame] | 296 | static __DRIimage * |
| 297 | intel_dup_image(__DRIimage *orig_image, void *loaderPrivate) |
| 298 | { |
| 299 | __DRIimage *image; |
| 300 | |
| 301 | image = CALLOC(sizeof *image); |
| 302 | if (image == NULL) |
| 303 | return NULL; |
| 304 | |
Benjamin Franzke | 3af3c58 | 2011-03-09 20:56:02 +0100 | [diff] [blame] | 305 | intel_region_reference(&image->region, orig_image->region); |
| 306 | if (image->region == NULL) { |
| 307 | FREE(image); |
| 308 | return NULL; |
| 309 | } |
| 310 | |
| 311 | image->internal_format = orig_image->internal_format; |
| 312 | image->format = orig_image->format; |
| 313 | image->data_type = orig_image->data_type; |
| 314 | image->data = loaderPrivate; |
| 315 | |
| 316 | return image; |
| 317 | } |
| 318 | |
Kristian Høgsberg | c262471 | 2010-02-11 18:59:40 -0500 | [diff] [blame] | 319 | static struct __DRIimageExtensionRec intelImageExtension = { |
| 320 | { __DRI_IMAGE, __DRI_IMAGE_VERSION }, |
| 321 | intel_create_image_from_name, |
| 322 | intel_create_image_from_renderbuffer, |
| 323 | intel_destroy_image, |
Kristian Høgsberg | f301932 | 2010-06-06 20:39:19 -0400 | [diff] [blame] | 324 | intel_create_image, |
Benjamin Franzke | 3af3c58 | 2011-03-09 20:56:02 +0100 | [diff] [blame] | 325 | intel_query_image, |
| 326 | intel_dup_image |
Kristian Høgsberg | c262471 | 2010-02-11 18:59:40 -0500 | [diff] [blame] | 327 | }; |
| 328 | |
Kristian Høgsberg | e82dd8c | 2008-03-26 19:26:59 -0400 | [diff] [blame] | 329 | static const __DRIextension *intelScreenExtensions[] = { |
Kristian Høgsberg | 6d48779 | 2008-02-14 22:12:51 -0500 | [diff] [blame] | 330 | &intelTexBufferExtension.base, |
Kristian Høgsberg | 7c50d29 | 2010-01-08 12:35:47 -0500 | [diff] [blame] | 331 | &intelFlushExtension.base, |
Kristian Høgsberg | c262471 | 2010-02-11 18:59:40 -0500 | [diff] [blame] | 332 | &intelImageExtension.base, |
Jesse Barnes | 234286c | 2010-04-22 12:47:41 -0700 | [diff] [blame] | 333 | &dri2ConfigQueryExtension.base, |
Kristian Høgsberg | ac3e838 | 2007-05-15 15:17:30 -0400 | [diff] [blame] | 334 | NULL |
| 335 | }; |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 336 | |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 337 | static bool |
Kristian Høgsberg | d61f073 | 2010-01-01 17:09:12 -0500 | [diff] [blame] | 338 | intel_get_param(__DRIscreen *psp, int param, int *value) |
Kristian Høgsberg | 24e7e45 | 2008-01-09 18:04:19 -0500 | [diff] [blame] | 339 | { |
| 340 | int ret; |
Alan Hourihane | 1c718c0 | 2008-02-22 00:18:54 +0000 | [diff] [blame] | 341 | struct drm_i915_getparam gp; |
Kristian Høgsberg | 24e7e45 | 2008-01-09 18:04:19 -0500 | [diff] [blame] | 342 | |
| 343 | gp.param = param; |
| 344 | gp.value = value; |
| 345 | |
Alan Hourihane | 1c718c0 | 2008-02-22 00:18:54 +0000 | [diff] [blame] | 346 | ret = drmCommandWriteRead(psp->fd, DRM_I915_GETPARAM, &gp, sizeof(gp)); |
Kristian Høgsberg | 24e7e45 | 2008-01-09 18:04:19 -0500 | [diff] [blame] | 347 | if (ret) { |
Eric Anholt | f6ca4a3 | 2011-03-09 12:54:14 -0800 | [diff] [blame] | 348 | if (ret != -EINVAL) |
| 349 | _mesa_warning(NULL, "drm_i915_getparam: %d", ret); |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 350 | return false; |
Kristian Høgsberg | 24e7e45 | 2008-01-09 18:04:19 -0500 | [diff] [blame] | 351 | } |
| 352 | |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 353 | return true; |
Kristian Høgsberg | 24e7e45 | 2008-01-09 18:04:19 -0500 | [diff] [blame] | 354 | } |
Kristian Høgsberg | ac3e838 | 2007-05-15 15:17:30 -0400 | [diff] [blame] | 355 | |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 356 | static bool |
Chris Wilson | 900a5c9 | 2011-03-01 14:46:50 +0000 | [diff] [blame] | 357 | intel_get_boolean(__DRIscreen *psp, int param) |
| 358 | { |
| 359 | int value = 0; |
| 360 | return intel_get_param(psp, param, &value) && value; |
| 361 | } |
| 362 | |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 363 | static void |
Kristian Høgsberg | 2d99588 | 2010-02-11 17:18:01 -0500 | [diff] [blame] | 364 | nop_callback(GLuint key, void *data, void *userData) |
| 365 | { |
| 366 | } |
| 367 | |
| 368 | static void |
Kristian Høgsberg | d61f073 | 2010-01-01 17:09:12 -0500 | [diff] [blame] | 369 | intelDestroyScreen(__DRIscreen * sPriv) |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 370 | { |
George Sapountzis | 875a757 | 2011-11-03 13:04:57 +0200 | [diff] [blame] | 371 | struct intel_screen *intelScreen = sPriv->driverPrivate; |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 372 | |
Eric Anholt | 904f31a | 2008-09-16 17:01:06 -0700 | [diff] [blame] | 373 | dri_bufmgr_destroy(intelScreen->bufmgr); |
Eric Anholt | 6d66f23 | 2009-07-02 13:30:20 -0700 | [diff] [blame] | 374 | driDestroyOptionInfo(&intelScreen->optionCache); |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 375 | |
Kristian Høgsberg | 2d99588 | 2010-02-11 17:18:01 -0500 | [diff] [blame] | 376 | /* Some regions may still have references to them at this point, so |
| 377 | * flush the hash table to prevent _mesa_DeleteHashTable() from |
| 378 | * complaining about the hash not being empty; */ |
| 379 | _mesa_HashDeleteAll(intelScreen->named_regions, nop_callback, NULL); |
| 380 | _mesa_DeleteHashTable(intelScreen->named_regions); |
| 381 | |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 382 | FREE(intelScreen); |
George Sapountzis | 875a757 | 2011-11-03 13:04:57 +0200 | [diff] [blame] | 383 | sPriv->driverPrivate = NULL; |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | |
| 387 | /** |
| 388 | * This is called when we need to set up GL rendering to a new X window. |
| 389 | */ |
| 390 | static GLboolean |
Kristian Høgsberg | d61f073 | 2010-01-01 17:09:12 -0500 | [diff] [blame] | 391 | intelCreateBuffer(__DRIscreen * driScrnPriv, |
| 392 | __DRIdrawable * driDrawPriv, |
Kristian Høgsberg | d3491e7 | 2010-10-12 11:58:47 -0400 | [diff] [blame] | 393 | const struct gl_config * mesaVis, GLboolean isPixmap) |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 394 | { |
Kristian Høgsberg | d282128 | 2010-01-01 23:21:16 -0500 | [diff] [blame] | 395 | struct intel_renderbuffer *rb; |
George Sapountzis | 875a757 | 2011-11-03 13:04:57 +0200 | [diff] [blame] | 396 | struct intel_screen *screen = (struct intel_screen*) driScrnPriv->driverPrivate; |
Kristian Høgsberg | d282128 | 2010-01-01 23:21:16 -0500 | [diff] [blame] | 397 | |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 398 | if (isPixmap) { |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 399 | return false; /* not implemented */ |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 400 | } |
| 401 | else { |
Brian Paul | 4a25343 | 2009-10-29 19:12:50 -0600 | [diff] [blame] | 402 | gl_format rgbFormat; |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 403 | |
Kristian Høgsberg | d282128 | 2010-01-01 23:21:16 -0500 | [diff] [blame] | 404 | struct gl_framebuffer *fb = CALLOC_STRUCT(gl_framebuffer); |
Michel Dänzer | 6b99caf | 2007-02-15 16:30:40 +0100 | [diff] [blame] | 405 | |
Kristian Høgsberg | d282128 | 2010-01-01 23:21:16 -0500 | [diff] [blame] | 406 | if (!fb) |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 407 | return false; |
Michel Dänzer | 6b99caf | 2007-02-15 16:30:40 +0100 | [diff] [blame] | 408 | |
Francisco Jerez | 2ec50d2 | 2010-02-03 03:21:04 -0800 | [diff] [blame] | 409 | _mesa_initialize_window_framebuffer(fb, mesaVis); |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 410 | |
Eric Anholt | 119f34e | 2009-02-25 22:54:51 -0800 | [diff] [blame] | 411 | if (mesaVis->redBits == 5) |
Brian Paul | 4a25343 | 2009-10-29 19:12:50 -0600 | [diff] [blame] | 412 | rgbFormat = MESA_FORMAT_RGB565; |
Eric Anholt | 119f34e | 2009-02-25 22:54:51 -0800 | [diff] [blame] | 413 | else if (mesaVis->alphaBits == 0) |
Brian Paul | 409469f | 2009-10-30 09:12:11 -0600 | [diff] [blame] | 414 | rgbFormat = MESA_FORMAT_XRGB8888; |
Eric Anholt | 119f34e | 2009-02-25 22:54:51 -0800 | [diff] [blame] | 415 | else |
Brian Paul | 4a25343 | 2009-10-29 19:12:50 -0600 | [diff] [blame] | 416 | rgbFormat = MESA_FORMAT_ARGB8888; |
Eric Anholt | 119f34e | 2009-02-25 22:54:51 -0800 | [diff] [blame] | 417 | |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 418 | /* setup the hardware-based renderbuffers */ |
Kristian Høgsberg | d282128 | 2010-01-01 23:21:16 -0500 | [diff] [blame] | 419 | rb = intel_create_renderbuffer(rgbFormat); |
| 420 | _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &rb->Base); |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 421 | |
| 422 | if (mesaVis->doubleBufferMode) { |
Kristian Høgsberg | d282128 | 2010-01-01 23:21:16 -0500 | [diff] [blame] | 423 | rb = intel_create_renderbuffer(rgbFormat); |
| 424 | _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &rb->Base); |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 425 | } |
| 426 | |
Chad Versace | f4efb7f | 2011-05-26 14:55:54 -0700 | [diff] [blame] | 427 | /* |
| 428 | * Assert here that the gl_config has an expected depth/stencil bit |
| 429 | * combination: one of d24/s8, d16/s0, d0/s0. (See intelInitScreen2(), |
| 430 | * which constructs the advertised configs.) |
| 431 | */ |
Eric Anholt | 38c6162 | 2007-11-08 14:49:37 -0800 | [diff] [blame] | 432 | if (mesaVis->depthBits == 24) { |
Eric Anholt | 800a4b2 | 2010-03-16 12:59:59 -0700 | [diff] [blame] | 433 | assert(mesaVis->stencilBits == 8); |
Chad Versace | aea2236 | 2011-06-03 16:33:32 -0700 | [diff] [blame] | 434 | |
| 435 | if (screen->hw_has_separate_stencil |
| 436 | && screen->dri2_has_hiz != INTEL_DRI2_HAS_HIZ_FALSE) { |
| 437 | /* |
| 438 | * Request a separate stencil buffer even if we do not yet know if |
| 439 | * the screen supports it. (See comments for |
| 440 | * enum intel_dri2_has_hiz). |
| 441 | */ |
| 442 | rb = intel_create_renderbuffer(MESA_FORMAT_X8_Z24); |
| 443 | _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &rb->Base); |
| 444 | rb = intel_create_renderbuffer(MESA_FORMAT_S8); |
| 445 | _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &rb->Base); |
| 446 | } else { |
| 447 | /* |
| 448 | * Use combined depth/stencil. Note that the renderbuffer is |
| 449 | * attached to two attachment points. |
| 450 | */ |
| 451 | rb = intel_create_renderbuffer(MESA_FORMAT_S8_Z24); |
| 452 | _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &rb->Base); |
| 453 | _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &rb->Base); |
| 454 | } |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 455 | } |
| 456 | else if (mesaVis->depthBits == 16) { |
Chad Versace | f4efb7f | 2011-05-26 14:55:54 -0700 | [diff] [blame] | 457 | assert(mesaVis->stencilBits == 0); |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 458 | /* just 16-bit depth buffer, no hw stencil */ |
| 459 | struct intel_renderbuffer *depthRb |
Brian Paul | 4a25343 | 2009-10-29 19:12:50 -0600 | [diff] [blame] | 460 | = intel_create_renderbuffer(MESA_FORMAT_Z16); |
Kristian Høgsberg | d282128 | 2010-01-01 23:21:16 -0500 | [diff] [blame] | 461 | _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 462 | } |
Chad Versace | f4efb7f | 2011-05-26 14:55:54 -0700 | [diff] [blame] | 463 | else { |
| 464 | assert(mesaVis->depthBits == 0); |
| 465 | assert(mesaVis->stencilBits == 0); |
| 466 | } |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 467 | |
| 468 | /* now add any/all software-based renderbuffers we may need */ |
Kristian Høgsberg | d282128 | 2010-01-01 23:21:16 -0500 | [diff] [blame] | 469 | _mesa_add_soft_renderbuffers(fb, |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 470 | false, /* never sw color */ |
| 471 | false, /* never sw depth */ |
| 472 | false, /* never sw stencil */ |
Chad Versace | f4efb7f | 2011-05-26 14:55:54 -0700 | [diff] [blame] | 473 | mesaVis->accumRedBits > 0, |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 474 | false, /* never sw alpha */ |
| 475 | false /* never sw aux */ ); |
Kristian Høgsberg | d282128 | 2010-01-01 23:21:16 -0500 | [diff] [blame] | 476 | driDrawPriv->driverPrivate = fb; |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 477 | |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 478 | return true; |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 479 | } |
| 480 | } |
| 481 | |
| 482 | static void |
Kristian Høgsberg | d61f073 | 2010-01-01 17:09:12 -0500 | [diff] [blame] | 483 | intelDestroyBuffer(__DRIdrawable * driDrawPriv) |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 484 | { |
Kristian Høgsberg | d282128 | 2010-01-01 23:21:16 -0500 | [diff] [blame] | 485 | struct gl_framebuffer *fb = driDrawPriv->driverPrivate; |
| 486 | |
| 487 | _mesa_reference_framebuffer(&fb, NULL); |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 488 | } |
| 489 | |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 490 | /* There are probably better ways to do this, such as an |
| 491 | * init-designated function to register chipids and createcontext |
| 492 | * functions. |
| 493 | */ |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 494 | extern bool |
| 495 | i830CreateContext(const struct gl_config *mesaVis, |
| 496 | __DRIcontext *driContextPriv, |
| 497 | void *sharedContextPrivate); |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 498 | |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 499 | extern bool |
| 500 | i915CreateContext(int api, |
| 501 | const struct gl_config *mesaVis, |
| 502 | __DRIcontext *driContextPriv, |
| 503 | void *sharedContextPrivate); |
| 504 | extern bool |
| 505 | brwCreateContext(int api, |
| 506 | const struct gl_config *mesaVis, |
| 507 | __DRIcontext *driContextPriv, |
| 508 | void *sharedContextPrivate); |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 509 | |
| 510 | static GLboolean |
Kristian Høgsberg | a7a9a91 | 2010-04-27 11:04:51 -0400 | [diff] [blame] | 511 | intelCreateContext(gl_api api, |
Kristian Høgsberg | d3491e7 | 2010-10-12 11:58:47 -0400 | [diff] [blame] | 512 | const struct gl_config * mesaVis, |
Kristian Høgsberg | d61f073 | 2010-01-01 17:09:12 -0500 | [diff] [blame] | 513 | __DRIcontext * driContextPriv, |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 514 | void *sharedContextPrivate) |
| 515 | { |
Kristian Høgsberg | d61f073 | 2010-01-01 17:09:12 -0500 | [diff] [blame] | 516 | __DRIscreen *sPriv = driContextPriv->driScreenPriv; |
George Sapountzis | 875a757 | 2011-11-03 13:04:57 +0200 | [diff] [blame] | 517 | struct intel_screen *intelScreen = sPriv->driverPrivate; |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 518 | |
Eric Anholt | bea6b5f | 2007-12-20 11:29:39 -0800 | [diff] [blame] | 519 | #ifdef I915 |
Eric Anholt | 19420e6 | 2008-02-15 13:16:01 -0800 | [diff] [blame] | 520 | if (IS_9XX(intelScreen->deviceID)) { |
| 521 | if (!IS_965(intelScreen->deviceID)) { |
Kristian Høgsberg | 4b69100 | 2010-04-27 11:04:51 -0400 | [diff] [blame] | 522 | return i915CreateContext(api, mesaVis, driContextPriv, |
Eric Anholt | bea6b5f | 2007-12-20 11:29:39 -0800 | [diff] [blame] | 523 | sharedContextPrivate); |
Eric Anholt | 19420e6 | 2008-02-15 13:16:01 -0800 | [diff] [blame] | 524 | } |
Eric Anholt | bea6b5f | 2007-12-20 11:29:39 -0800 | [diff] [blame] | 525 | } else { |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 526 | intelScreen->no_vbo = true; |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 527 | return i830CreateContext(mesaVis, driContextPriv, sharedContextPrivate); |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 528 | } |
Eric Anholt | bea6b5f | 2007-12-20 11:29:39 -0800 | [diff] [blame] | 529 | #else |
| 530 | if (IS_965(intelScreen->deviceID)) |
Kristian Høgsberg | 4b69100 | 2010-04-27 11:04:51 -0400 | [diff] [blame] | 531 | return brwCreateContext(api, mesaVis, |
| 532 | driContextPriv, sharedContextPrivate); |
Eric Anholt | bea6b5f | 2007-12-20 11:29:39 -0800 | [diff] [blame] | 533 | #endif |
Eric Anholt | 4ac2f09 | 2010-12-02 18:25:45 -0800 | [diff] [blame] | 534 | fprintf(stderr, "Unrecognized deviceID 0x%x\n", intelScreen->deviceID); |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 535 | return false; |
Keith Whitwell | 6b9e31f | 2006-11-01 12:03:11 +0000 | [diff] [blame] | 536 | } |
| 537 | |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 538 | static bool |
Kristian Høgsberg | 5777dee | 2010-02-11 16:44:21 -0500 | [diff] [blame] | 539 | intel_init_bufmgr(struct intel_screen *intelScreen) |
Eric Anholt | 7e0bbdc | 2008-09-04 22:16:31 +0100 | [diff] [blame] | 540 | { |
Kristian Høgsberg | d61f073 | 2010-01-01 17:09:12 -0500 | [diff] [blame] | 541 | __DRIscreen *spriv = intelScreen->driScrnPriv; |
Eric Anholt | cb4ef34 | 2009-07-01 17:08:16 -0700 | [diff] [blame] | 542 | int num_fences = 0; |
Eric Anholt | 7e0bbdc | 2008-09-04 22:16:31 +0100 | [diff] [blame] | 543 | |
Eric Anholt | 4ac2f09 | 2010-12-02 18:25:45 -0800 | [diff] [blame] | 544 | intelScreen->no_hw = (getenv("INTEL_NO_HW") != NULL || |
| 545 | getenv("INTEL_DEVID_OVERRIDE") != NULL); |
Eric Anholt | 7e0bbdc | 2008-09-04 22:16:31 +0100 | [diff] [blame] | 546 | |
Eric Anholt | 827ba44 | 2009-11-18 18:15:25 +0100 | [diff] [blame] | 547 | intelScreen->bufmgr = intel_bufmgr_gem_init(spriv->fd, BATCH_SZ); |
Eric Anholt | 7e0bbdc | 2008-09-04 22:16:31 +0100 | [diff] [blame] | 548 | if (intelScreen->bufmgr == NULL) { |
Eric Anholt | 827ba44 | 2009-11-18 18:15:25 +0100 | [diff] [blame] | 549 | fprintf(stderr, "[%s:%u] Error initializing buffer manager.\n", |
| 550 | __func__, __LINE__); |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 551 | return false; |
Eric Anholt | 7e0bbdc | 2008-09-04 22:16:31 +0100 | [diff] [blame] | 552 | } |
| 553 | |
Eric Anholt | bb35000 | 2010-03-04 15:47:19 -0800 | [diff] [blame] | 554 | if (!intel_get_param(spriv, I915_PARAM_NUM_FENCES_AVAIL, &num_fences) || |
| 555 | num_fences == 0) { |
| 556 | fprintf(stderr, "[%s: %u] Kernel 2.6.29 required.\n", __func__, __LINE__); |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 557 | return false; |
Eric Anholt | bb35000 | 2010-03-04 15:47:19 -0800 | [diff] [blame] | 558 | } |
Eric Anholt | e7aef00 | 2009-04-06 09:38:16 -0700 | [diff] [blame] | 559 | |
Eric Anholt | 06d1472 | 2010-03-02 18:04:40 -0800 | [diff] [blame] | 560 | drm_intel_bufmgr_gem_enable_fenced_relocs(intelScreen->bufmgr); |
| 561 | |
Kristian Høgsberg | 2d99588 | 2010-02-11 17:18:01 -0500 | [diff] [blame] | 562 | intelScreen->named_regions = _mesa_NewHashTable(); |
| 563 | |
Chris Wilson | 900a5c9 | 2011-03-01 14:46:50 +0000 | [diff] [blame] | 564 | intelScreen->relaxed_relocations = 0; |
| 565 | intelScreen->relaxed_relocations |= |
| 566 | intel_get_boolean(spriv, I915_PARAM_HAS_RELAXED_DELTA) << 0; |
| 567 | |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 568 | return true; |
Eric Anholt | 7e0bbdc | 2008-09-04 22:16:31 +0100 | [diff] [blame] | 569 | } |
| 570 | |
Kristian Høgsberg | c5c73c1 | 2008-01-21 17:07:33 -0500 | [diff] [blame] | 571 | /** |
Chad Versace | 6b2bf27 | 2011-05-26 15:24:48 -0700 | [diff] [blame] | 572 | * Override intel_screen.hw_has_hiz with environment variable INTEL_HIZ. |
| 573 | * |
| 574 | * Valid values for INTEL_HIZ are "0" and "1". If an invalid valid value is |
| 575 | * encountered, a warning is emitted and INTEL_HIZ is ignored. |
| 576 | */ |
| 577 | static void |
| 578 | intel_override_hiz(struct intel_screen *intel) |
| 579 | { |
| 580 | const char *s = getenv("INTEL_HIZ"); |
| 581 | if (!s) { |
| 582 | return; |
| 583 | } else if (!strncmp("0", s, 2)) { |
| 584 | intel->hw_has_hiz = false; |
| 585 | } else if (!strncmp("1", s, 2)) { |
| 586 | intel->hw_has_hiz = true; |
| 587 | } else { |
| 588 | fprintf(stderr, |
| 589 | "warning: env variable INTEL_HIZ=\"%s\" has invalid value " |
| 590 | "and is ignored", s); |
| 591 | } |
| 592 | } |
| 593 | |
| 594 | /** |
| 595 | * Override intel_screen.hw_has_separate_stencil with environment variable |
| 596 | * INTEL_SEPARATE_STENCIL. |
| 597 | * |
| 598 | * Valid values for INTEL_SEPARATE_STENCIL are "0" and "1". If an invalid |
| 599 | * valid value is encountered, a warning is emitted and INTEL_SEPARATE_STENCIL |
| 600 | * is ignored. |
| 601 | */ |
| 602 | static void |
| 603 | intel_override_separate_stencil(struct intel_screen *screen) |
| 604 | { |
| 605 | const char *s = getenv("INTEL_SEPARATE_STENCIL"); |
| 606 | if (!s) { |
| 607 | return; |
| 608 | } else if (!strncmp("0", s, 2)) { |
| 609 | screen->hw_has_separate_stencil = false; |
| 610 | } else if (!strncmp("1", s, 2)) { |
| 611 | screen->hw_has_separate_stencil = true; |
| 612 | } else { |
| 613 | fprintf(stderr, |
| 614 | "warning: env variable INTEL_SEPARATE_STENCIL=\"%s\" has " |
| 615 | "invalid value and is ignored", s); |
| 616 | } |
| 617 | } |
| 618 | |
| 619 | /** |
Kristian Høgsberg | c5c73c1 | 2008-01-21 17:07:33 -0500 | [diff] [blame] | 620 | * This is the driver specific part of the createNewScreen entry point. |
Brian Paul | 8d976ae | 2008-06-11 19:33:14 -0600 | [diff] [blame] | 621 | * Called when using DRI2. |
| 622 | * |
Kristian Høgsberg | d3491e7 | 2010-10-12 11:58:47 -0400 | [diff] [blame] | 623 | * \return the struct gl_config supported by this driver |
Kristian Høgsberg | c5c73c1 | 2008-01-21 17:07:33 -0500 | [diff] [blame] | 624 | */ |
Kristian Høgsberg | e82dd8c | 2008-03-26 19:26:59 -0400 | [diff] [blame] | 625 | static const |
Kristian Høgsberg | d61f073 | 2010-01-01 17:09:12 -0500 | [diff] [blame] | 626 | __DRIconfig **intelInitScreen2(__DRIscreen *psp) |
Kristian Høgsberg | c5c73c1 | 2008-01-21 17:07:33 -0500 | [diff] [blame] | 627 | { |
Kristian Høgsberg | 5777dee | 2010-02-11 16:44:21 -0500 | [diff] [blame] | 628 | struct intel_screen *intelScreen; |
Eric Anholt | 3ee21f3 | 2009-01-29 14:57:49 -0800 | [diff] [blame] | 629 | GLenum fb_format[3]; |
| 630 | GLenum fb_type[3]; |
Kristian Høgsberg | 5efee4d | 2010-04-27 21:43:40 -0400 | [diff] [blame] | 631 | unsigned int api_mask; |
Eric Anholt | 4ac2f09 | 2010-12-02 18:25:45 -0800 | [diff] [blame] | 632 | char *devid_override; |
Kristian Høgsberg | 7c50d29 | 2010-01-08 12:35:47 -0500 | [diff] [blame] | 633 | |
Eric Anholt | 3ee21f3 | 2009-01-29 14:57:49 -0800 | [diff] [blame] | 634 | static const GLenum back_buffer_modes[] = { |
Ian Romanick | 6bd9da0 | 2010-02-08 13:11:58 -0800 | [diff] [blame] | 635 | GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML |
Eric Anholt | 3ee21f3 | 2009-01-29 14:57:49 -0800 | [diff] [blame] | 636 | }; |
Brian Paul | e135936 | 2009-02-09 11:16:20 -0700 | [diff] [blame] | 637 | uint8_t depth_bits[4], stencil_bits[4], msaa_samples_array[1]; |
Eric Anholt | 3ee21f3 | 2009-01-29 14:57:49 -0800 | [diff] [blame] | 638 | int color; |
Eric Anholt | 5d5ae37 | 2009-02-10 14:30:38 -0800 | [diff] [blame] | 639 | __DRIconfig **configs = NULL; |
Kristian Høgsberg | c5c73c1 | 2008-01-21 17:07:33 -0500 | [diff] [blame] | 640 | |
Kristian Høgsberg | c5c73c1 | 2008-01-21 17:07:33 -0500 | [diff] [blame] | 641 | /* Allocate the private area */ |
Kristian Høgsberg | 5777dee | 2010-02-11 16:44:21 -0500 | [diff] [blame] | 642 | intelScreen = CALLOC(sizeof *intelScreen); |
Kristian Høgsberg | c5c73c1 | 2008-01-21 17:07:33 -0500 | [diff] [blame] | 643 | if (!intelScreen) { |
| 644 | fprintf(stderr, "\nERROR! Allocating private area failed\n"); |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 645 | return false; |
Kristian Høgsberg | c5c73c1 | 2008-01-21 17:07:33 -0500 | [diff] [blame] | 646 | } |
| 647 | /* parse information in __driConfigOptions */ |
| 648 | driParseOptionInfo(&intelScreen->optionCache, |
| 649 | __driConfigOptions, __driNConfigOptions); |
| 650 | |
| 651 | intelScreen->driScrnPriv = psp; |
George Sapountzis | 875a757 | 2011-11-03 13:04:57 +0200 | [diff] [blame] | 652 | psp->driverPrivate = (void *) intelScreen; |
Kristian Høgsberg | c5c73c1 | 2008-01-21 17:07:33 -0500 | [diff] [blame] | 653 | |
Kristian Høgsberg | f56b569 | 2008-08-13 11:46:25 -0400 | [diff] [blame] | 654 | /* Determine chipset ID */ |
Kristian Høgsberg | c5c73c1 | 2008-01-21 17:07:33 -0500 | [diff] [blame] | 655 | if (!intel_get_param(psp, I915_PARAM_CHIPSET_ID, |
| 656 | &intelScreen->deviceID)) |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 657 | return false; |
Kristian Høgsberg | c5c73c1 | 2008-01-21 17:07:33 -0500 | [diff] [blame] | 658 | |
Eric Anholt | 4ac2f09 | 2010-12-02 18:25:45 -0800 | [diff] [blame] | 659 | /* Allow an override of the device ID for the purpose of making the |
| 660 | * driver produce dumps for debugging of new chipset enablement. |
| 661 | * This implies INTEL_NO_HW, to avoid programming your actual GPU |
| 662 | * incorrectly. |
| 663 | */ |
| 664 | devid_override = getenv("INTEL_DEVID_OVERRIDE"); |
| 665 | if (devid_override) { |
| 666 | intelScreen->deviceID = strtod(devid_override, NULL); |
| 667 | } |
| 668 | |
Kenneth Graunke | 89a82d7 | 2011-05-16 15:19:22 -0700 | [diff] [blame] | 669 | if (IS_GEN7(intelScreen->deviceID)) { |
| 670 | intelScreen->gen = 7; |
| 671 | } else if (IS_GEN6(intelScreen->deviceID)) { |
Kristian Høgsberg | 7363088 | 2011-04-25 09:49:09 -0400 | [diff] [blame] | 672 | intelScreen->gen = 6; |
| 673 | } else if (IS_GEN5(intelScreen->deviceID)) { |
| 674 | intelScreen->gen = 5; |
| 675 | } else if (IS_965(intelScreen->deviceID)) { |
| 676 | intelScreen->gen = 4; |
| 677 | } else if (IS_9XX(intelScreen->deviceID)) { |
| 678 | intelScreen->gen = 3; |
| 679 | } else { |
| 680 | intelScreen->gen = 2; |
| 681 | } |
| 682 | |
Chad Versace | 6b2bf27 | 2011-05-26 15:24:48 -0700 | [diff] [blame] | 683 | /* |
| 684 | * FIXME: The hiz and separate stencil fields need updating once the |
| 685 | * FIXME: features are completely implemented for a given chipset. |
| 686 | */ |
| 687 | intelScreen->hw_has_separate_stencil = intelScreen->gen >= 7; |
| 688 | intelScreen->hw_must_use_separate_stencil = intelScreen->gen >= 7; |
| 689 | intelScreen->hw_has_hiz = false; |
| 690 | intelScreen->dri2_has_hiz = INTEL_DRI2_HAS_HIZ_UNKNOWN; |
| 691 | |
| 692 | intel_override_hiz(intelScreen); |
| 693 | intel_override_separate_stencil(intelScreen); |
| 694 | |
Kristian Høgsberg | 5efee4d | 2010-04-27 21:43:40 -0400 | [diff] [blame] | 695 | api_mask = (1 << __DRI_API_OPENGL); |
| 696 | #if FEATURE_ES1 |
| 697 | api_mask |= (1 << __DRI_API_GLES); |
| 698 | #endif |
| 699 | #if FEATURE_ES2 |
| 700 | api_mask |= (1 << __DRI_API_GLES2); |
| 701 | #endif |
| 702 | |
| 703 | if (IS_9XX(intelScreen->deviceID) || IS_965(intelScreen->deviceID)) |
| 704 | psp->api_mask = api_mask; |
| 705 | |
Eric Anholt | 7e0bbdc | 2008-09-04 22:16:31 +0100 | [diff] [blame] | 706 | if (!intel_init_bufmgr(intelScreen)) |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 707 | return false; |
Eric Anholt | 7e0bbdc | 2008-09-04 22:16:31 +0100 | [diff] [blame] | 708 | |
Kristian Høgsberg | e82dd8c | 2008-03-26 19:26:59 -0400 | [diff] [blame] | 709 | psp->extensions = intelScreenExtensions; |
Kristian Høgsberg | c5c73c1 | 2008-01-21 17:07:33 -0500 | [diff] [blame] | 710 | |
Michel Dänzer | eaf15db | 2009-02-10 13:47:49 +0100 | [diff] [blame] | 711 | msaa_samples_array[0] = 0; |
| 712 | |
Eric Anholt | 3ee21f3 | 2009-01-29 14:57:49 -0800 | [diff] [blame] | 713 | fb_format[0] = GL_RGB; |
| 714 | fb_type[0] = GL_UNSIGNED_SHORT_5_6_5; |
| 715 | |
Eric Anholt | 24ff169 | 2009-01-31 10:32:34 -0800 | [diff] [blame] | 716 | fb_format[1] = GL_BGR; |
Eric Anholt | 3ee21f3 | 2009-01-29 14:57:49 -0800 | [diff] [blame] | 717 | fb_type[1] = GL_UNSIGNED_INT_8_8_8_8_REV; |
| 718 | |
Eric Anholt | 24ff169 | 2009-01-31 10:32:34 -0800 | [diff] [blame] | 719 | fb_format[2] = GL_BGRA; |
Eric Anholt | 3ee21f3 | 2009-01-29 14:57:49 -0800 | [diff] [blame] | 720 | fb_type[2] = GL_UNSIGNED_INT_8_8_8_8_REV; |
| 721 | |
Eric Anholt | 160c361 | 2009-02-26 00:18:46 -0800 | [diff] [blame] | 722 | depth_bits[0] = 0; |
| 723 | stencil_bits[0] = 0; |
| 724 | |
Ian Romanick | bb65a1d | 2010-02-08 11:21:29 -0800 | [diff] [blame] | 725 | /* Generate a rich set of useful configs that do not include an |
| 726 | * accumulation buffer. |
| 727 | */ |
Eric Anholt | 3ee21f3 | 2009-01-29 14:57:49 -0800 | [diff] [blame] | 728 | for (color = 0; color < ARRAY_SIZE(fb_format); color++) { |
Eric Anholt | 5d5ae37 | 2009-02-10 14:30:38 -0800 | [diff] [blame] | 729 | __DRIconfig **new_configs; |
Eric Anholt | 160c361 | 2009-02-26 00:18:46 -0800 | [diff] [blame] | 730 | int depth_factor; |
Eric Anholt | 3ee21f3 | 2009-01-29 14:57:49 -0800 | [diff] [blame] | 731 | |
Ian Romanick | 066f45c | 2010-02-08 10:32:29 -0800 | [diff] [blame] | 732 | /* Starting with DRI2 protocol version 1.1 we can request a depth/stencil |
| 733 | * buffer that has a diffferent number of bits per pixel than the color |
| 734 | * buffer. This isn't yet supported here. |
Eric Anholt | 160c361 | 2009-02-26 00:18:46 -0800 | [diff] [blame] | 735 | */ |
| 736 | if (fb_type[color] == GL_UNSIGNED_SHORT_5_6_5) { |
| 737 | depth_bits[1] = 16; |
| 738 | stencil_bits[1] = 0; |
Eric Anholt | 160c361 | 2009-02-26 00:18:46 -0800 | [diff] [blame] | 739 | } else { |
| 740 | depth_bits[1] = 24; |
Ian Romanick | 73e24cd | 2010-02-08 10:34:52 -0800 | [diff] [blame] | 741 | stencil_bits[1] = 8; |
Eric Anholt | 160c361 | 2009-02-26 00:18:46 -0800 | [diff] [blame] | 742 | } |
Ian Romanick | 73e24cd | 2010-02-08 10:34:52 -0800 | [diff] [blame] | 743 | |
| 744 | depth_factor = 2; |
| 745 | |
Eric Anholt | 5d5ae37 | 2009-02-10 14:30:38 -0800 | [diff] [blame] | 746 | new_configs = driCreateConfigs(fb_format[color], fb_type[color], |
| 747 | depth_bits, |
| 748 | stencil_bits, |
Eric Anholt | 160c361 | 2009-02-26 00:18:46 -0800 | [diff] [blame] | 749 | depth_factor, |
Eric Anholt | 5d5ae37 | 2009-02-10 14:30:38 -0800 | [diff] [blame] | 750 | back_buffer_modes, |
| 751 | ARRAY_SIZE(back_buffer_modes), |
| 752 | msaa_samples_array, |
Ian Romanick | 3cce4a1 | 2010-02-08 11:09:15 -0800 | [diff] [blame] | 753 | ARRAY_SIZE(msaa_samples_array), |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 754 | false); |
Ian Romanick | bb65a1d | 2010-02-08 11:21:29 -0800 | [diff] [blame] | 755 | if (configs == NULL) |
| 756 | configs = new_configs; |
| 757 | else |
| 758 | configs = driConcatConfigs(configs, new_configs); |
| 759 | } |
| 760 | |
| 761 | /* Generate the minimum possible set of configs that include an |
| 762 | * accumulation buffer. |
| 763 | */ |
| 764 | for (color = 0; color < ARRAY_SIZE(fb_format); color++) { |
| 765 | __DRIconfig **new_configs; |
| 766 | |
| 767 | if (fb_type[color] == GL_UNSIGNED_SHORT_5_6_5) { |
| 768 | depth_bits[0] = 16; |
| 769 | stencil_bits[0] = 0; |
| 770 | } else { |
| 771 | depth_bits[0] = 24; |
| 772 | stencil_bits[0] = 8; |
| 773 | } |
| 774 | |
| 775 | new_configs = driCreateConfigs(fb_format[color], fb_type[color], |
| 776 | depth_bits, stencil_bits, 1, |
| 777 | back_buffer_modes + 1, 1, |
| 778 | msaa_samples_array, 1, |
Kenneth Graunke | 2e5a1a2 | 2011-10-07 12:26:50 -0700 | [diff] [blame] | 779 | true); |
Eric Anholt | 3ee21f3 | 2009-01-29 14:57:49 -0800 | [diff] [blame] | 780 | if (configs == NULL) |
| 781 | configs = new_configs; |
| 782 | else |
| 783 | configs = driConcatConfigs(configs, new_configs); |
| 784 | } |
| 785 | |
| 786 | if (configs == NULL) { |
| 787 | fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, |
| 788 | __LINE__); |
| 789 | return NULL; |
| 790 | } |
| 791 | |
Eric Anholt | 5d5ae37 | 2009-02-10 14:30:38 -0800 | [diff] [blame] | 792 | return (const __DRIconfig **)configs; |
Kristian Høgsberg | c5c73c1 | 2008-01-21 17:07:33 -0500 | [diff] [blame] | 793 | } |
Kristian Høgsberg | e82dd8c | 2008-03-26 19:26:59 -0400 | [diff] [blame] | 794 | |
Benjamin Franzke | 2adfde3 | 2011-02-04 12:01:31 +0100 | [diff] [blame] | 795 | struct intel_buffer { |
| 796 | __DRIbuffer base; |
| 797 | struct intel_region *region; |
| 798 | }; |
| 799 | |
Chad Versace | 79653c1 | 2011-11-15 07:08:49 -0800 | [diff] [blame] | 800 | /** |
| 801 | * \brief Get tiling format for a DRI buffer. |
| 802 | * |
| 803 | * \param attachment is the buffer's attachmet point, such as |
| 804 | * __DRI_BUFFER_DEPTH. |
| 805 | * \param out_tiling is the returned tiling format for buffer. |
| 806 | * \return false if attachment is unrecognized or is incompatible with screen. |
| 807 | */ |
| 808 | static bool |
| 809 | intel_get_dri_buffer_tiling(struct intel_screen *screen, |
| 810 | uint32_t attachment, |
| 811 | uint32_t *out_tiling) |
| 812 | { |
| 813 | if (screen->gen < 4) { |
| 814 | *out_tiling = I915_TILING_X; |
| 815 | return true; |
| 816 | } |
| 817 | |
| 818 | switch (attachment) { |
| 819 | case __DRI_BUFFER_DEPTH: |
| 820 | case __DRI_BUFFER_DEPTH_STENCIL: |
| 821 | case __DRI_BUFFER_HIZ: |
| 822 | *out_tiling = I915_TILING_Y; |
| 823 | return true; |
| 824 | case __DRI_BUFFER_ACCUM: |
| 825 | case __DRI_BUFFER_FRONT_LEFT: |
| 826 | case __DRI_BUFFER_FRONT_RIGHT: |
| 827 | case __DRI_BUFFER_BACK_LEFT: |
| 828 | case __DRI_BUFFER_BACK_RIGHT: |
| 829 | case __DRI_BUFFER_FAKE_FRONT_LEFT: |
| 830 | case __DRI_BUFFER_FAKE_FRONT_RIGHT: |
| 831 | *out_tiling = I915_TILING_X; |
| 832 | return true; |
| 833 | case __DRI_BUFFER_STENCIL: |
| 834 | /* The stencil buffer is W tiled. However, we request from the kernel |
| 835 | * a non-tiled buffer because the GTT is incapable of W fencing. |
| 836 | */ |
| 837 | *out_tiling = I915_TILING_NONE; |
| 838 | return true; |
| 839 | default: |
| 840 | if(unlikely(INTEL_DEBUG & DEBUG_DRI)) { |
| 841 | fprintf(stderr, "error: %s: unrecognized DRI buffer attachment 0x%x\n", |
| 842 | __FUNCTION__, attachment); |
| 843 | } |
| 844 | return false; |
| 845 | } |
| 846 | } |
| 847 | |
Benjamin Franzke | 2adfde3 | 2011-02-04 12:01:31 +0100 | [diff] [blame] | 848 | static __DRIbuffer * |
| 849 | intelAllocateBuffer(__DRIscreen *screen, |
| 850 | unsigned attachment, unsigned format, |
| 851 | int width, int height) |
| 852 | { |
| 853 | struct intel_buffer *intelBuffer; |
George Sapountzis | 875a757 | 2011-11-03 13:04:57 +0200 | [diff] [blame] | 854 | struct intel_screen *intelScreen = screen->driverPrivate; |
Chad Versace | 79653c1 | 2011-11-15 07:08:49 -0800 | [diff] [blame] | 855 | |
Kristian Høgsberg | 5dfba09 | 2011-04-25 09:53:22 -0400 | [diff] [blame] | 856 | uint32_t tiling; |
Chad Versace | 79653c1 | 2011-11-15 07:08:49 -0800 | [diff] [blame] | 857 | uint32_t region_width; |
| 858 | uint32_t region_height; |
| 859 | uint32_t region_cpp; |
| 860 | |
| 861 | bool ok = true; |
| 862 | |
| 863 | ok = intel_get_dri_buffer_tiling(intelScreen, attachment, &tiling); |
| 864 | if (!ok) |
| 865 | return NULL; |
Benjamin Franzke | 2adfde3 | 2011-02-04 12:01:31 +0100 | [diff] [blame] | 866 | |
| 867 | intelBuffer = CALLOC(sizeof *intelBuffer); |
| 868 | if (intelBuffer == NULL) |
| 869 | return NULL; |
| 870 | |
Chad Versace | 79653c1 | 2011-11-15 07:08:49 -0800 | [diff] [blame] | 871 | if (attachment == __DRI_BUFFER_STENCIL) { |
| 872 | /* The stencil buffer has quirky pitch requirements. From Vol 2a, |
| 873 | * 11.5.6.2.1 3DSTATE_STENCIL_BUFFER, field "Surface Pitch": |
| 874 | * The pitch must be set to 2x the value computed based on width, as |
| 875 | * the stencil buffer is stored with two rows interleaved. |
| 876 | * To accomplish this, we resort to the nasty hack of doubling the |
| 877 | * region's cpp and halving its height. |
| 878 | */ |
| 879 | region_width = ALIGN(width, 64); |
| 880 | region_height = ALIGN(ALIGN(height, 2) / 2, 64); |
| 881 | region_cpp = format / 4; |
| 882 | } else { |
| 883 | region_width = width; |
| 884 | region_height = height; |
| 885 | region_cpp = format / 8; |
| 886 | } |
Kristian Høgsberg | 5dfba09 | 2011-04-25 09:53:22 -0400 | [diff] [blame] | 887 | |
Chad Versace | 79653c1 | 2011-11-15 07:08:49 -0800 | [diff] [blame] | 888 | intelBuffer->region = intel_region_alloc(intelScreen, |
| 889 | tiling, |
| 890 | region_cpp, |
| 891 | region_width, |
| 892 | region_height, |
| 893 | true); |
Benjamin Franzke | 2adfde3 | 2011-02-04 12:01:31 +0100 | [diff] [blame] | 894 | |
| 895 | if (intelBuffer->region == NULL) { |
| 896 | FREE(intelBuffer); |
| 897 | return NULL; |
| 898 | } |
| 899 | |
| 900 | intel_region_flink(intelBuffer->region, &intelBuffer->base.name); |
| 901 | |
| 902 | intelBuffer->base.attachment = attachment; |
| 903 | intelBuffer->base.cpp = intelBuffer->region->cpp; |
| 904 | intelBuffer->base.pitch = |
| 905 | intelBuffer->region->pitch * intelBuffer->region->cpp; |
| 906 | |
| 907 | return &intelBuffer->base; |
| 908 | } |
| 909 | |
| 910 | static void |
| 911 | intelReleaseBuffer(__DRIscreen *screen, __DRIbuffer *buffer) |
| 912 | { |
| 913 | struct intel_buffer *intelBuffer = (struct intel_buffer *) buffer; |
| 914 | |
| 915 | intel_region_release(&intelBuffer->region); |
| 916 | free(intelBuffer); |
| 917 | } |
| 918 | |
| 919 | |
Kristian Høgsberg | e82dd8c | 2008-03-26 19:26:59 -0400 | [diff] [blame] | 920 | const struct __DriverAPIRec driDriverAPI = { |
George Sapountzis | 7192c37 | 2011-11-03 12:46:08 +0200 | [diff] [blame] | 921 | .InitScreen = intelInitScreen2, |
Kristian Høgsberg | e82dd8c | 2008-03-26 19:26:59 -0400 | [diff] [blame] | 922 | .DestroyScreen = intelDestroyScreen, |
| 923 | .CreateContext = intelCreateContext, |
| 924 | .DestroyContext = intelDestroyContext, |
| 925 | .CreateBuffer = intelCreateBuffer, |
| 926 | .DestroyBuffer = intelDestroyBuffer, |
Kristian Høgsberg | e82dd8c | 2008-03-26 19:26:59 -0400 | [diff] [blame] | 927 | .MakeCurrent = intelMakeCurrent, |
| 928 | .UnbindContext = intelUnbindContext, |
Benjamin Franzke | 2adfde3 | 2011-02-04 12:01:31 +0100 | [diff] [blame] | 929 | .AllocateBuffer = intelAllocateBuffer, |
| 930 | .ReleaseBuffer = intelReleaseBuffer |
Kristian Høgsberg | e82dd8c | 2008-03-26 19:26:59 -0400 | [diff] [blame] | 931 | }; |
Kristian Høgsberg | 39a0e4e | 2010-01-01 17:56:29 -0500 | [diff] [blame] | 932 | |
| 933 | /* This is the table of extensions that the loader will dlsym() for. */ |
| 934 | PUBLIC const __DRIextension *__driDriverExtensions[] = { |
| 935 | &driCoreExtension.base, |
Kristian Høgsberg | 39a0e4e | 2010-01-01 17:56:29 -0500 | [diff] [blame] | 936 | &driDRI2Extension.base, |
| 937 | NULL |
| 938 | }; |