Merge remote branch 'origin/master' into pipe-video
[mesa.git] / src / mesa / drivers / dri / intel / intel_screen.c
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
28 #include "main/glheader.h"
29 #include "main/context.h"
30 #include "main/framebuffer.h"
31 #include "main/renderbuffer.h"
32 #include "main/hash.h"
33 #include "main/fbobject.h"
34 #include "main/mfeatures.h"
35
36 #include "utils.h"
37 #include "xmlpool.h"
38
39 PUBLIC const char __driConfigOptions[] =
40 DRI_CONF_BEGIN
41 DRI_CONF_SECTION_PERFORMANCE
42 DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_ALWAYS_SYNC)
43 /* Options correspond to DRI_CONF_BO_REUSE_DISABLED,
44 * DRI_CONF_BO_REUSE_ALL
45 */
46 DRI_CONF_OPT_BEGIN_V(bo_reuse, enum, 1, "0:1")
47 DRI_CONF_DESC_BEGIN(en, "Buffer object reuse")
48 DRI_CONF_ENUM(0, "Disable buffer object reuse")
49 DRI_CONF_ENUM(1, "Enable reuse of all sizes of buffer objects")
50 DRI_CONF_DESC_END
51 DRI_CONF_OPT_END
52
53 DRI_CONF_OPT_BEGIN(texture_tiling, bool, true)
54 DRI_CONF_DESC(en, "Enable texture tiling")
55 DRI_CONF_OPT_END
56
57 DRI_CONF_OPT_BEGIN(early_z, bool, false)
58 DRI_CONF_DESC(en, "Enable early Z in classic mode (unstable, 945-only).")
59 DRI_CONF_OPT_END
60
61 DRI_CONF_OPT_BEGIN(fragment_shader, bool, true)
62 DRI_CONF_DESC(en, "Enable limited ARB_fragment_shader support on 915/945.")
63 DRI_CONF_OPT_END
64
65 DRI_CONF_SECTION_END
66 DRI_CONF_SECTION_QUALITY
67 DRI_CONF_FORCE_S3TC_ENABLE(false)
68 DRI_CONF_ALLOW_LARGE_TEXTURES(2)
69 DRI_CONF_SECTION_END
70 DRI_CONF_SECTION_DEBUG
71 DRI_CONF_NO_RAST(false)
72 DRI_CONF_ALWAYS_FLUSH_BATCH(false)
73 DRI_CONF_ALWAYS_FLUSH_CACHE(false)
74
75 DRI_CONF_OPT_BEGIN(stub_occlusion_query, bool, false)
76 DRI_CONF_DESC(en, "Enable stub ARB_occlusion_query support on 915/945.")
77 DRI_CONF_OPT_END
78 DRI_CONF_SECTION_END
79 DRI_CONF_END;
80
81 const GLuint __driNConfigOptions = 11;
82
83 #include "intel_batchbuffer.h"
84 #include "intel_buffers.h"
85 #include "intel_bufmgr.h"
86 #include "intel_chipset.h"
87 #include "intel_fbo.h"
88 #include "intel_screen.h"
89 #include "intel_tex.h"
90 #include "intel_regions.h"
91
92 #include "i915_drm.h"
93
94 #ifdef USE_NEW_INTERFACE
95 static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
96 #endif /*USE_NEW_INTERFACE */
97
98 static const __DRItexBufferExtension intelTexBufferExtension = {
99 { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
100 intelSetTexBuffer,
101 intelSetTexBuffer2,
102 };
103
104 static void
105 intelDRI2Flush(__DRIdrawable *drawable)
106 {
107 GET_CURRENT_CONTEXT(ctx);
108 struct intel_context *intel = intel_context(ctx);
109
110 if (intel->gen < 4)
111 INTEL_FIREVERTICES(intel);
112
113 intel->need_throttle = GL_TRUE;
114
115 if (intel->batch.used)
116 intel_batchbuffer_flush(intel);
117 }
118
119 static const struct __DRI2flushExtensionRec intelFlushExtension = {
120 { __DRI2_FLUSH, __DRI2_FLUSH_VERSION },
121 intelDRI2Flush,
122 dri2InvalidateDrawable,
123 };
124
125 static __DRIimage *
126 intel_create_image_from_name(__DRIscreen *screen,
127 int width, int height, int format,
128 int name, int pitch, void *loaderPrivate)
129 {
130 struct intel_screen *intelScreen = screen->private;
131 __DRIimage *image;
132 int cpp;
133
134 image = CALLOC(sizeof *image);
135 if (image == NULL)
136 return NULL;
137
138 switch (format) {
139 case __DRI_IMAGE_FORMAT_RGB565:
140 image->format = MESA_FORMAT_RGB565;
141 image->internal_format = GL_RGB;
142 image->data_type = GL_UNSIGNED_BYTE;
143 break;
144 case __DRI_IMAGE_FORMAT_XRGB8888:
145 image->format = MESA_FORMAT_XRGB8888;
146 image->internal_format = GL_RGB;
147 image->data_type = GL_UNSIGNED_BYTE;
148 break;
149 case __DRI_IMAGE_FORMAT_ARGB8888:
150 image->format = MESA_FORMAT_ARGB8888;
151 image->internal_format = GL_RGBA;
152 image->data_type = GL_UNSIGNED_BYTE;
153 break;
154 default:
155 free(image);
156 return NULL;
157 }
158
159 image->data = loaderPrivate;
160 cpp = _mesa_get_format_bytes(image->format);
161
162 image->region = intel_region_alloc_for_handle(intelScreen,
163 cpp, width, height,
164 pitch, name, "image");
165 if (image->region == NULL) {
166 FREE(image);
167 return NULL;
168 }
169
170 return image;
171 }
172
173 static __DRIimage *
174 intel_create_image_from_renderbuffer(__DRIcontext *context,
175 int renderbuffer, void *loaderPrivate)
176 {
177 __DRIimage *image;
178 struct intel_context *intel = context->driverPrivate;
179 struct gl_renderbuffer *rb;
180 struct intel_renderbuffer *irb;
181
182 rb = _mesa_lookup_renderbuffer(&intel->ctx, renderbuffer);
183 if (!rb) {
184 _mesa_error(&intel->ctx,
185 GL_INVALID_OPERATION, "glRenderbufferExternalMESA");
186 return NULL;
187 }
188
189 irb = intel_renderbuffer(rb);
190 image = CALLOC(sizeof *image);
191 if (image == NULL)
192 return NULL;
193
194 image->internal_format = rb->InternalFormat;
195 image->format = rb->Format;
196 image->data_type = rb->DataType;
197 image->data = loaderPrivate;
198 intel_region_reference(&image->region, irb->region);
199
200 return image;
201 }
202
203 static void
204 intel_destroy_image(__DRIimage *image)
205 {
206 intel_region_release(&image->region);
207 FREE(image);
208 }
209
210 static __DRIimage *
211 intel_create_image(__DRIscreen *screen,
212 int width, int height, int format,
213 unsigned int use,
214 void *loaderPrivate)
215 {
216 __DRIimage *image;
217 struct intel_screen *intelScreen = screen->private;
218 int cpp;
219
220 image = CALLOC(sizeof *image);
221 if (image == NULL)
222 return NULL;
223
224 switch (format) {
225 case __DRI_IMAGE_FORMAT_RGB565:
226 image->format = MESA_FORMAT_RGB565;
227 image->internal_format = GL_RGB;
228 image->data_type = GL_UNSIGNED_BYTE;
229 break;
230 case __DRI_IMAGE_FORMAT_XRGB8888:
231 image->format = MESA_FORMAT_XRGB8888;
232 image->internal_format = GL_RGB;
233 image->data_type = GL_UNSIGNED_BYTE;
234 break;
235 case __DRI_IMAGE_FORMAT_ARGB8888:
236 image->format = MESA_FORMAT_ARGB8888;
237 image->internal_format = GL_RGBA;
238 image->data_type = GL_UNSIGNED_BYTE;
239 break;
240 default:
241 free(image);
242 return NULL;
243 }
244
245 image->data = loaderPrivate;
246 cpp = _mesa_get_format_bytes(image->format);
247
248 image->region =
249 intel_region_alloc(intelScreen, I915_TILING_NONE,
250 cpp, width, height, GL_TRUE);
251 if (image->region == NULL) {
252 FREE(image);
253 return NULL;
254 }
255
256 return image;
257 }
258
259 static GLboolean
260 intel_query_image(__DRIimage *image, int attrib, int *value)
261 {
262 switch (attrib) {
263 case __DRI_IMAGE_ATTRIB_STRIDE:
264 *value = image->region->pitch * image->region->cpp;
265 return GL_TRUE;
266 case __DRI_IMAGE_ATTRIB_HANDLE:
267 *value = image->region->buffer->handle;
268 return GL_TRUE;
269 case __DRI_IMAGE_ATTRIB_NAME:
270 return intel_region_flink(image->region, (uint32_t *) value);
271 default:
272 return GL_FALSE;
273 }
274 }
275
276 static struct __DRIimageExtensionRec intelImageExtension = {
277 { __DRI_IMAGE, __DRI_IMAGE_VERSION },
278 intel_create_image_from_name,
279 intel_create_image_from_renderbuffer,
280 intel_destroy_image,
281 intel_create_image,
282 intel_query_image
283 };
284
285 static const __DRIextension *intelScreenExtensions[] = {
286 &driReadDrawableExtension,
287 &intelTexBufferExtension.base,
288 &intelFlushExtension.base,
289 &intelImageExtension.base,
290 &dri2ConfigQueryExtension.base,
291 NULL
292 };
293
294 static GLboolean
295 intel_get_param(__DRIscreen *psp, int param, int *value)
296 {
297 int ret;
298 struct drm_i915_getparam gp;
299
300 gp.param = param;
301 gp.value = value;
302
303 ret = drmCommandWriteRead(psp->fd, DRM_I915_GETPARAM, &gp, sizeof(gp));
304 if (ret) {
305 _mesa_warning(NULL, "drm_i915_getparam: %d", ret);
306 return GL_FALSE;
307 }
308
309 return GL_TRUE;
310 }
311
312 static void
313 nop_callback(GLuint key, void *data, void *userData)
314 {
315 }
316
317 static void
318 intelDestroyScreen(__DRIscreen * sPriv)
319 {
320 struct intel_screen *intelScreen = sPriv->private;
321
322 dri_bufmgr_destroy(intelScreen->bufmgr);
323 driDestroyOptionInfo(&intelScreen->optionCache);
324
325 /* Some regions may still have references to them at this point, so
326 * flush the hash table to prevent _mesa_DeleteHashTable() from
327 * complaining about the hash not being empty; */
328 _mesa_HashDeleteAll(intelScreen->named_regions, nop_callback, NULL);
329 _mesa_DeleteHashTable(intelScreen->named_regions);
330
331 FREE(intelScreen);
332 sPriv->private = NULL;
333 }
334
335
336 /**
337 * This is called when we need to set up GL rendering to a new X window.
338 */
339 static GLboolean
340 intelCreateBuffer(__DRIscreen * driScrnPriv,
341 __DRIdrawable * driDrawPriv,
342 const struct gl_config * mesaVis, GLboolean isPixmap)
343 {
344 struct intel_renderbuffer *rb;
345
346 if (isPixmap) {
347 return GL_FALSE; /* not implemented */
348 }
349 else {
350 GLboolean swStencil = (mesaVis->stencilBits > 0 &&
351 mesaVis->depthBits != 24);
352 gl_format rgbFormat;
353
354 struct gl_framebuffer *fb = CALLOC_STRUCT(gl_framebuffer);
355
356 if (!fb)
357 return GL_FALSE;
358
359 _mesa_initialize_window_framebuffer(fb, mesaVis);
360
361 if (mesaVis->redBits == 5)
362 rgbFormat = MESA_FORMAT_RGB565;
363 else if (mesaVis->alphaBits == 0)
364 rgbFormat = MESA_FORMAT_XRGB8888;
365 else
366 rgbFormat = MESA_FORMAT_ARGB8888;
367
368 /* setup the hardware-based renderbuffers */
369 rb = intel_create_renderbuffer(rgbFormat);
370 _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &rb->Base);
371
372 if (mesaVis->doubleBufferMode) {
373 rb = intel_create_renderbuffer(rgbFormat);
374 _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &rb->Base);
375 }
376
377 if (mesaVis->depthBits == 24) {
378 assert(mesaVis->stencilBits == 8);
379 /* combined depth/stencil buffer */
380 struct intel_renderbuffer *depthStencilRb
381 = intel_create_renderbuffer(MESA_FORMAT_S8_Z24);
382 /* note: bind RB to two attachment points */
383 _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthStencilRb->Base);
384 _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &depthStencilRb->Base);
385 }
386 else if (mesaVis->depthBits == 16) {
387 /* just 16-bit depth buffer, no hw stencil */
388 struct intel_renderbuffer *depthRb
389 = intel_create_renderbuffer(MESA_FORMAT_Z16);
390 _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
391 }
392
393 /* now add any/all software-based renderbuffers we may need */
394 _mesa_add_soft_renderbuffers(fb,
395 GL_FALSE, /* never sw color */
396 GL_FALSE, /* never sw depth */
397 swStencil, mesaVis->accumRedBits > 0,
398 GL_FALSE, /* never sw alpha */
399 GL_FALSE /* never sw aux */ );
400 driDrawPriv->driverPrivate = fb;
401
402 return GL_TRUE;
403 }
404 }
405
406 static void
407 intelDestroyBuffer(__DRIdrawable * driDrawPriv)
408 {
409 struct gl_framebuffer *fb = driDrawPriv->driverPrivate;
410
411 _mesa_reference_framebuffer(&fb, NULL);
412 }
413
414 /* There are probably better ways to do this, such as an
415 * init-designated function to register chipids and createcontext
416 * functions.
417 */
418 extern GLboolean i830CreateContext(const struct gl_config * mesaVis,
419 __DRIcontext * driContextPriv,
420 void *sharedContextPrivate);
421
422 extern GLboolean i915CreateContext(int api,
423 const struct gl_config * mesaVis,
424 __DRIcontext * driContextPriv,
425 void *sharedContextPrivate);
426 extern GLboolean brwCreateContext(int api,
427 const struct gl_config * mesaVis,
428 __DRIcontext * driContextPriv,
429 void *sharedContextPrivate);
430
431 static GLboolean
432 intelCreateContext(gl_api api,
433 const struct gl_config * mesaVis,
434 __DRIcontext * driContextPriv,
435 void *sharedContextPrivate)
436 {
437 __DRIscreen *sPriv = driContextPriv->driScreenPriv;
438 struct intel_screen *intelScreen = sPriv->private;
439
440 #ifdef I915
441 if (IS_9XX(intelScreen->deviceID)) {
442 if (!IS_965(intelScreen->deviceID)) {
443 return i915CreateContext(api, mesaVis, driContextPriv,
444 sharedContextPrivate);
445 }
446 } else {
447 intelScreen->no_vbo = GL_TRUE;
448 return i830CreateContext(mesaVis, driContextPriv, sharedContextPrivate);
449 }
450 #else
451 if (IS_965(intelScreen->deviceID))
452 return brwCreateContext(api, mesaVis,
453 driContextPriv, sharedContextPrivate);
454 #endif
455 fprintf(stderr, "Unrecognized deviceID 0x%x\n", intelScreen->deviceID);
456 return GL_FALSE;
457 }
458
459 static GLboolean
460 intel_init_bufmgr(struct intel_screen *intelScreen)
461 {
462 __DRIscreen *spriv = intelScreen->driScrnPriv;
463 int num_fences = 0;
464
465 intelScreen->no_hw = (getenv("INTEL_NO_HW") != NULL ||
466 getenv("INTEL_DEVID_OVERRIDE") != NULL);
467
468 intelScreen->bufmgr = intel_bufmgr_gem_init(spriv->fd, BATCH_SZ);
469 if (intelScreen->bufmgr == NULL) {
470 fprintf(stderr, "[%s:%u] Error initializing buffer manager.\n",
471 __func__, __LINE__);
472 return GL_FALSE;
473 }
474
475 if (!intel_get_param(spriv, I915_PARAM_NUM_FENCES_AVAIL, &num_fences) ||
476 num_fences == 0) {
477 fprintf(stderr, "[%s: %u] Kernel 2.6.29 required.\n", __func__, __LINE__);
478 return GL_FALSE;
479 }
480
481 drm_intel_bufmgr_gem_enable_fenced_relocs(intelScreen->bufmgr);
482
483 intelScreen->named_regions = _mesa_NewHashTable();
484
485 return GL_TRUE;
486 }
487
488 /**
489 * This is the driver specific part of the createNewScreen entry point.
490 * Called when using DRI2.
491 *
492 * \return the struct gl_config supported by this driver
493 */
494 static const
495 __DRIconfig **intelInitScreen2(__DRIscreen *psp)
496 {
497 struct intel_screen *intelScreen;
498 GLenum fb_format[3];
499 GLenum fb_type[3];
500 unsigned int api_mask;
501 char *devid_override;
502
503 static const GLenum back_buffer_modes[] = {
504 GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
505 };
506 uint8_t depth_bits[4], stencil_bits[4], msaa_samples_array[1];
507 int color;
508 __DRIconfig **configs = NULL;
509
510 /* Allocate the private area */
511 intelScreen = CALLOC(sizeof *intelScreen);
512 if (!intelScreen) {
513 fprintf(stderr, "\nERROR! Allocating private area failed\n");
514 return GL_FALSE;
515 }
516 /* parse information in __driConfigOptions */
517 driParseOptionInfo(&intelScreen->optionCache,
518 __driConfigOptions, __driNConfigOptions);
519
520 intelScreen->driScrnPriv = psp;
521 psp->private = (void *) intelScreen;
522
523 /* Determine chipset ID */
524 if (!intel_get_param(psp, I915_PARAM_CHIPSET_ID,
525 &intelScreen->deviceID))
526 return GL_FALSE;
527
528 /* Allow an override of the device ID for the purpose of making the
529 * driver produce dumps for debugging of new chipset enablement.
530 * This implies INTEL_NO_HW, to avoid programming your actual GPU
531 * incorrectly.
532 */
533 devid_override = getenv("INTEL_DEVID_OVERRIDE");
534 if (devid_override) {
535 intelScreen->deviceID = strtod(devid_override, NULL);
536 }
537
538 api_mask = (1 << __DRI_API_OPENGL);
539 #if FEATURE_ES1
540 api_mask |= (1 << __DRI_API_GLES);
541 #endif
542 #if FEATURE_ES2
543 api_mask |= (1 << __DRI_API_GLES2);
544 #endif
545
546 if (IS_9XX(intelScreen->deviceID) || IS_965(intelScreen->deviceID))
547 psp->api_mask = api_mask;
548
549 if (!intel_init_bufmgr(intelScreen))
550 return GL_FALSE;
551
552 psp->extensions = intelScreenExtensions;
553
554 msaa_samples_array[0] = 0;
555
556 fb_format[0] = GL_RGB;
557 fb_type[0] = GL_UNSIGNED_SHORT_5_6_5;
558
559 fb_format[1] = GL_BGR;
560 fb_type[1] = GL_UNSIGNED_INT_8_8_8_8_REV;
561
562 fb_format[2] = GL_BGRA;
563 fb_type[2] = GL_UNSIGNED_INT_8_8_8_8_REV;
564
565 depth_bits[0] = 0;
566 stencil_bits[0] = 0;
567
568 /* Generate a rich set of useful configs that do not include an
569 * accumulation buffer.
570 */
571 for (color = 0; color < ARRAY_SIZE(fb_format); color++) {
572 __DRIconfig **new_configs;
573 int depth_factor;
574
575 /* Starting with DRI2 protocol version 1.1 we can request a depth/stencil
576 * buffer that has a diffferent number of bits per pixel than the color
577 * buffer. This isn't yet supported here.
578 */
579 if (fb_type[color] == GL_UNSIGNED_SHORT_5_6_5) {
580 depth_bits[1] = 16;
581 stencil_bits[1] = 0;
582 } else {
583 depth_bits[1] = 24;
584 stencil_bits[1] = 8;
585 }
586
587 depth_factor = 2;
588
589 new_configs = driCreateConfigs(fb_format[color], fb_type[color],
590 depth_bits,
591 stencil_bits,
592 depth_factor,
593 back_buffer_modes,
594 ARRAY_SIZE(back_buffer_modes),
595 msaa_samples_array,
596 ARRAY_SIZE(msaa_samples_array),
597 GL_FALSE);
598 if (configs == NULL)
599 configs = new_configs;
600 else
601 configs = driConcatConfigs(configs, new_configs);
602 }
603
604 /* Generate the minimum possible set of configs that include an
605 * accumulation buffer.
606 */
607 for (color = 0; color < ARRAY_SIZE(fb_format); color++) {
608 __DRIconfig **new_configs;
609
610 if (fb_type[color] == GL_UNSIGNED_SHORT_5_6_5) {
611 depth_bits[0] = 16;
612 stencil_bits[0] = 0;
613 } else {
614 depth_bits[0] = 24;
615 stencil_bits[0] = 8;
616 }
617
618 new_configs = driCreateConfigs(fb_format[color], fb_type[color],
619 depth_bits, stencil_bits, 1,
620 back_buffer_modes + 1, 1,
621 msaa_samples_array, 1,
622 GL_TRUE);
623 if (configs == NULL)
624 configs = new_configs;
625 else
626 configs = driConcatConfigs(configs, new_configs);
627 }
628
629 if (configs == NULL) {
630 fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
631 __LINE__);
632 return NULL;
633 }
634
635 return (const __DRIconfig **)configs;
636 }
637
638 struct intel_buffer {
639 __DRIbuffer base;
640 struct intel_region *region;
641 };
642
643 static __DRIbuffer *
644 intelAllocateBuffer(__DRIscreen *screen,
645 unsigned attachment, unsigned format,
646 int width, int height)
647 {
648 struct intel_buffer *intelBuffer;
649 struct intel_screen *intelScreen = screen->private;
650
651 intelBuffer = CALLOC(sizeof *intelBuffer);
652 if (intelBuffer == NULL)
653 return NULL;
654
655 intelBuffer->region = intel_region_alloc(intelScreen, I915_TILING_NONE,
656 format / 8, width, height, GL_TRUE);
657
658 if (intelBuffer->region == NULL) {
659 FREE(intelBuffer);
660 return NULL;
661 }
662
663 intel_region_flink(intelBuffer->region, &intelBuffer->base.name);
664
665 intelBuffer->base.attachment = attachment;
666 intelBuffer->base.cpp = intelBuffer->region->cpp;
667 intelBuffer->base.pitch =
668 intelBuffer->region->pitch * intelBuffer->region->cpp;
669
670 return &intelBuffer->base;
671 }
672
673 static void
674 intelReleaseBuffer(__DRIscreen *screen, __DRIbuffer *buffer)
675 {
676 struct intel_buffer *intelBuffer = (struct intel_buffer *) buffer;
677
678 intel_region_release(&intelBuffer->region);
679 free(intelBuffer);
680 }
681
682
683 const struct __DriverAPIRec driDriverAPI = {
684 .DestroyScreen = intelDestroyScreen,
685 .CreateContext = intelCreateContext,
686 .DestroyContext = intelDestroyContext,
687 .CreateBuffer = intelCreateBuffer,
688 .DestroyBuffer = intelDestroyBuffer,
689 .MakeCurrent = intelMakeCurrent,
690 .UnbindContext = intelUnbindContext,
691 .InitScreen2 = intelInitScreen2,
692 .AllocateBuffer = intelAllocateBuffer,
693 .ReleaseBuffer = intelReleaseBuffer
694 };
695
696 /* This is the table of extensions that the loader will dlsym() for. */
697 PUBLIC const __DRIextension *__driDriverExtensions[] = {
698 &driCoreExtension.base,
699 &driDRI2Extension.base,
700 NULL
701 };