intel_screen.c revision 1ba96651e12b3c74fb9c8f5a61b183ef36a27b1e
177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt/************************************************************************** 277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * 377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. 477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * All Rights Reserved. 577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * 677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * Permission is hereby granted, free of charge, to any person obtaining a 777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * copy of this software and associated documentation files (the 877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * "Software"), to deal in the Software without restriction, including 977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * without limitation the rights to use, copy, modify, merge, publish, 1077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * distribute, sub license, and/or sell copies of the Software, and to 1177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * permit persons to whom the Software is furnished to do so, subject to 1277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * the following conditions: 1377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * 1477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * The above copyright notice and this permission notice (including the 1577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * next paragraph) shall be included in all copies or substantial portions 1677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * of the Software. 1777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * 1877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 1977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 2177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 2277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 2377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 2477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * 2677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt **************************************************************************/ 2777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 28ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/glheader.h" 29ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/context.h" 30ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/framebuffer.h" 31ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/renderbuffer.h" 326c244b0f326504ae6add1ddcb407e73c3e72da78Brian Paul 3377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt#include "utils.h" 3477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt#include "vblank.h" 3577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt#include "xmlpool.h" 3677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 376c244b0f326504ae6add1ddcb407e73c3e72da78Brian Paul#include "intel_batchbuffer.h" 3877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt#include "intel_buffers.h" 396c244b0f326504ae6add1ddcb407e73c3e72da78Brian Paul#include "intel_bufmgr.h" 406c244b0f326504ae6add1ddcb407e73c3e72da78Brian Paul#include "intel_chipset.h" 414006c5e4526a1cdb910500764590e39d32750967Brian Paul#include "intel_extensions.h" 4277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt#include "intel_fbo.h" 436c244b0f326504ae6add1ddcb407e73c3e72da78Brian Paul#include "intel_regions.h" 446fcebbe719eab1f8e292c8dcd6c3e898b0f8d261Brian Paul#include "intel_swapbuffers.h" 456c244b0f326504ae6add1ddcb407e73c3e72da78Brian Paul#include "intel_screen.h" 466c244b0f326504ae6add1ddcb407e73c3e72da78Brian Paul#include "intel_span.h" 476c244b0f326504ae6add1ddcb407e73c3e72da78Brian Paul#include "intel_tex.h" 4877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 49bea6b5fe5aa3138cec8d057766ae48da4aa57deeEric Anholt#include "i915_drm.h" 5077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt#include "i830_dri.h" 516c244b0f326504ae6add1ddcb407e73c3e72da78Brian Paul 521ba96651e12b3c74fb9c8f5a61b183ef36a27b1eEric Anholt#define DRI_CONF_TEXTURE_TILING(def) \ 531ba96651e12b3c74fb9c8f5a61b183ef36a27b1eEric Anholt DRI_CONF_OPT_BEGIN(texture_tiling, bool, def) \ 541ba96651e12b3c74fb9c8f5a61b183ef36a27b1eEric Anholt DRI_CONF_DESC(en, "Enable texture tiling") \ 551ba96651e12b3c74fb9c8f5a61b183ef36a27b1eEric Anholt DRI_CONF_OPT_END \ 5677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 5777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric AnholtPUBLIC const char __driConfigOptions[] = 58a0e453a5eca7ed4b57a7f4c1e418d368815e3957Eric Anholt DRI_CONF_BEGIN 59a0e453a5eca7ed4b57a7f4c1e418d368815e3957Eric Anholt DRI_CONF_SECTION_PERFORMANCE 60a0e453a5eca7ed4b57a7f4c1e418d368815e3957Eric Anholt DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS) 61e9bf3e4cc9a7e4bcd4c45bd707541d26ecdf0409Jesse Barnes DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_ALWAYS_SYNC) 62fe91c05b5494b889c8adda77ff562712116d2e59Eric Anholt /* Options correspond to DRI_CONF_BO_REUSE_DISABLED, 63fe91c05b5494b889c8adda77ff562712116d2e59Eric Anholt * DRI_CONF_BO_REUSE_ALL 64fe91c05b5494b889c8adda77ff562712116d2e59Eric Anholt */ 65f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie DRI_CONF_OPT_BEGIN_V(bo_reuse, enum, 1, "0:1") 66fe91c05b5494b889c8adda77ff562712116d2e59Eric Anholt DRI_CONF_DESC_BEGIN(en, "Buffer object reuse") 67fe91c05b5494b889c8adda77ff562712116d2e59Eric Anholt DRI_CONF_ENUM(0, "Disable buffer object reuse") 68fe91c05b5494b889c8adda77ff562712116d2e59Eric Anholt DRI_CONF_ENUM(1, "Enable reuse of all sizes of buffer objects") 69fe91c05b5494b889c8adda77ff562712116d2e59Eric Anholt DRI_CONF_DESC_END 70fe91c05b5494b889c8adda77ff562712116d2e59Eric Anholt DRI_CONF_OPT_END 711ba96651e12b3c74fb9c8f5a61b183ef36a27b1eEric Anholt 721ba96651e12b3c74fb9c8f5a61b183ef36a27b1eEric Anholt#ifdef I915 731ba96651e12b3c74fb9c8f5a61b183ef36a27b1eEric Anholt DRI_CONF_TEXTURE_TILING(false) 741ba96651e12b3c74fb9c8f5a61b183ef36a27b1eEric Anholt#else 751ba96651e12b3c74fb9c8f5a61b183ef36a27b1eEric Anholt DRI_CONF_TEXTURE_TILING(true) 761ba96651e12b3c74fb9c8f5a61b183ef36a27b1eEric Anholt#endif 771ba96651e12b3c74fb9c8f5a61b183ef36a27b1eEric Anholt 78a0e453a5eca7ed4b57a7f4c1e418d368815e3957Eric Anholt DRI_CONF_SECTION_END 79a0e453a5eca7ed4b57a7f4c1e418d368815e3957Eric Anholt DRI_CONF_SECTION_QUALITY 80a0e453a5eca7ed4b57a7f4c1e418d368815e3957Eric Anholt DRI_CONF_FORCE_S3TC_ENABLE(false) 81acba9c1771d653126fd6f604cb80c050b9e8ffb3Michel Dänzer DRI_CONF_ALLOW_LARGE_TEXTURES(2) 82a0e453a5eca7ed4b57a7f4c1e418d368815e3957Eric Anholt DRI_CONF_SECTION_END 83a0e453a5eca7ed4b57a7f4c1e418d368815e3957Eric Anholt DRI_CONF_SECTION_DEBUG 84a0e453a5eca7ed4b57a7f4c1e418d368815e3957Eric Anholt DRI_CONF_NO_RAST(false) 8540bc2748c2781600c748e546160bcc2aab637825Eric Anholt DRI_CONF_ALWAYS_FLUSH_BATCH(false) 86f3687284c12f34268172b9c60e2effd697162129Eric Anholt DRI_CONF_ALWAYS_FLUSH_CACHE(false) 87a0e453a5eca7ed4b57a7f4c1e418d368815e3957Eric Anholt DRI_CONF_SECTION_END 88a0e453a5eca7ed4b57a7f4c1e418d368815e3957Eric AnholtDRI_CONF_END; 89a0e453a5eca7ed4b57a7f4c1e418d368815e3957Eric Anholt 901ba96651e12b3c74fb9c8f5a61b183ef36a27b1eEric Anholtconst GLuint __driNConfigOptions = 9; 9177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 9277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt#ifdef USE_NEW_INTERFACE 9385063f14ea431b586d710f249563fc73481552c7Eric Anholtstatic PFNGLXCREATECONTEXTMODES create_context_modes = NULL; 9477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt#endif /*USE_NEW_INTERFACE */ 9577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 9677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt/** 9777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * Map all the memory regions described by the screen. 9877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * \return GL_TRUE if success, GL_FALSE if error. 9977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt */ 10077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric AnholtGLboolean 10177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric AnholtintelMapScreenRegions(__DRIscreenPrivate * sPriv) 10277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt{ 10377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private; 10477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 10577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if (0) 10677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt _mesa_printf("TEX 0x%08x ", intelScreen->tex.handle); 10777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if (intelScreen->tex.size != 0) { 10877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if (drmMap(sPriv->fd, 10977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->tex.handle, 11077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->tex.size, 11177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt (drmAddress *) & intelScreen->tex.map) != 0) { 11277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelUnmapScreenRegions(intelScreen); 11377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt return GL_FALSE; 11477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 11577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 11677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 11777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt return GL_TRUE; 11877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt} 11977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 12077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholtvoid 12177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric AnholtintelUnmapScreenRegions(intelScreenPrivate * intelScreen) 12277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt{ 12377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if (intelScreen->tex.map) { 12477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt drmUnmap(intelScreen->tex.map, intelScreen->tex.size); 12577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->tex.map = NULL; 12677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 12777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt} 12877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 12977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 13077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholtstatic void 13177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric AnholtintelPrintDRIInfo(intelScreenPrivate * intelScreen, 13277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt __DRIscreenPrivate * sPriv, I830DRIPtr gDRIPriv) 13377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt{ 13477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt fprintf(stderr, "*** Front size: 0x%x offset: 0x%x pitch: %d\n", 13577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->front.size, intelScreen->front.offset, 13646eb02b60920a920b782bacb15f01b44e18f888dKristian Høgsberg intelScreen->pitch); 13777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt fprintf(stderr, "*** Back size: 0x%x offset: 0x%x pitch: %d\n", 13877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->back.size, intelScreen->back.offset, 13946eb02b60920a920b782bacb15f01b44e18f888dKristian Høgsberg intelScreen->pitch); 14077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt fprintf(stderr, "*** Depth size: 0x%x offset: 0x%x pitch: %d\n", 14177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->depth.size, intelScreen->depth.offset, 14246eb02b60920a920b782bacb15f01b44e18f888dKristian Høgsberg intelScreen->pitch); 14377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt fprintf(stderr, "*** Texture size: 0x%x offset: 0x%x\n", 14477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->tex.size, intelScreen->tex.offset); 14577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt fprintf(stderr, "*** Memory : 0x%x\n", gDRIPriv->mem); 14677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt} 14777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 14877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 14977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholtstatic void 15039e6d0d8108fe6d222865e7bb9de1e3cea18b4c4Timo AaltonenintelPrintSAREA(const drm_i915_sarea_t * sarea) 15177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt{ 15277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt fprintf(stderr, "SAREA: sarea width %d height %d\n", sarea->width, 15377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt sarea->height); 15477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt fprintf(stderr, "SAREA: pitch: %d\n", sarea->pitch); 15577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt fprintf(stderr, 156f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie "SAREA: front offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n", 15777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt sarea->front_offset, sarea->front_size, 158f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie (unsigned) sarea->front_handle, sarea->front_tiled); 15977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt fprintf(stderr, 160f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie "SAREA: back offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n", 16177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt sarea->back_offset, sarea->back_size, 162f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie (unsigned) sarea->back_handle, sarea->back_tiled); 163f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie fprintf(stderr, "SAREA: depth offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n", 16477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt sarea->depth_offset, sarea->depth_size, 165f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie (unsigned) sarea->depth_handle, sarea->depth_tiled); 16677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt fprintf(stderr, "SAREA: tex offset: 0x%08x size: 0x%x handle: 0x%x\n", 16777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt sarea->tex_offset, sarea->tex_size, (unsigned) sarea->tex_handle); 16877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt} 16977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 17077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 17177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt/** 17277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * A number of the screen parameters are obtained/computed from 17377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * information in the SAREA. This function updates those parameters. 17477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt */ 175aae2729aeb3f6eed26e8f7673f47f2b978786bb1Brian Paulstatic void 17677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric AnholtintelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen, 17739e6d0d8108fe6d222865e7bb9de1e3cea18b4c4Timo Aaltonen drm_i915_sarea_t * sarea) 17877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt{ 17977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->width = sarea->width; 18077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->height = sarea->height; 18146eb02b60920a920b782bacb15f01b44e18f888dKristian Høgsberg intelScreen->pitch = sarea->pitch; 18277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 18377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->front.offset = sarea->front_offset; 18477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->front.handle = sarea->front_handle; 18577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->front.size = sarea->front_size; 186f00a64999c197e6a96e65fd00f64224a6f22c9faEric Anholt intelScreen->front.tiled = sarea->front_tiled; 18777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 18877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->back.offset = sarea->back_offset; 18977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->back.handle = sarea->back_handle; 19077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->back.size = sarea->back_size; 191f00a64999c197e6a96e65fd00f64224a6f22c9faEric Anholt intelScreen->back.tiled = sarea->back_tiled; 19277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 19377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->depth.offset = sarea->depth_offset; 19477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->depth.handle = sarea->depth_handle; 19577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->depth.size = sarea->depth_size; 196f00a64999c197e6a96e65fd00f64224a6f22c9faEric Anholt intelScreen->depth.tiled = sarea->depth_tiled; 19777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 19877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if (intelScreen->driScrnPriv->ddx_version.minor >= 9) { 19977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->front.bo_handle = sarea->front_bo_handle; 20077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->back.bo_handle = sarea->back_bo_handle; 20177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->depth.bo_handle = sarea->depth_bo_handle; 20277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } else { 20377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->front.bo_handle = -1; 20477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->back.bo_handle = -1; 20577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->depth.bo_handle = -1; 20677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 20777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 20877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->tex.offset = sarea->tex_offset; 20977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->logTextureGranularity = sarea->log_tex_granularity; 21077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->tex.handle = sarea->tex_handle; 21177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->tex.size = sarea->tex_size; 21277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 21377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if (0) 21477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelPrintSAREA(sarea); 21577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt} 21677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 21777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholtstatic const __DRItexOffsetExtension intelTexOffsetExtension = { 21877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt { __DRI_TEX_OFFSET }, 21977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelSetTexOffset, 22077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt}; 22177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 2226d48779c7e5c9002d1bec4b1266ca05a474218efKristian Høgsbergstatic const __DRItexBufferExtension intelTexBufferExtension = { 2236d48779c7e5c9002d1bec4b1266ca05a474218efKristian Høgsberg { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION }, 2246d48779c7e5c9002d1bec4b1266ca05a474218efKristian Høgsberg intelSetTexBuffer, 22566175aac7609ad314f25fbdff0d3958af310dc24Eric Anholt intelSetTexBuffer2, 2266d48779c7e5c9002d1bec4b1266ca05a474218efKristian Høgsberg}; 2276d48779c7e5c9002d1bec4b1266ca05a474218efKristian Høgsberg 228e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsbergstatic const __DRIextension *intelScreenExtensions[] = { 22977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt &driReadDrawableExtension, 23077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt &driCopySubBufferExtension.base, 23177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt &driSwapControlExtension.base, 23277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt &driFrameTrackingExtension.base, 23377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt &driMediaStreamCounterExtension.base, 23477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt &intelTexOffsetExtension.base, 2356d48779c7e5c9002d1bec4b1266ca05a474218efKristian Høgsberg &intelTexBufferExtension.base, 23677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt NULL 23777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt}; 23877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 23924e7e457680d700e986fd0b0e0f046fadf67caf4Kristian Høgsbergstatic GLboolean 24024e7e457680d700e986fd0b0e0f046fadf67caf4Kristian Høgsbergintel_get_param(__DRIscreenPrivate *psp, int param, int *value) 24124e7e457680d700e986fd0b0e0f046fadf67caf4Kristian Høgsberg{ 24224e7e457680d700e986fd0b0e0f046fadf67caf4Kristian Høgsberg int ret; 2431c718c0d78cf4eae9e02b03a0abbec384db948a6Alan Hourihane struct drm_i915_getparam gp; 24424e7e457680d700e986fd0b0e0f046fadf67caf4Kristian Høgsberg 24524e7e457680d700e986fd0b0e0f046fadf67caf4Kristian Høgsberg gp.param = param; 24624e7e457680d700e986fd0b0e0f046fadf67caf4Kristian Høgsberg gp.value = value; 24724e7e457680d700e986fd0b0e0f046fadf67caf4Kristian Høgsberg 2481c718c0d78cf4eae9e02b03a0abbec384db948a6Alan Hourihane ret = drmCommandWriteRead(psp->fd, DRM_I915_GETPARAM, &gp, sizeof(gp)); 24924e7e457680d700e986fd0b0e0f046fadf67caf4Kristian Høgsberg if (ret) { 250bc3270e99f5c39544aaf831742db14796ab83a6aRobert Ellison _mesa_warning(NULL, "drm_i915_getparam: %d\n", ret); 25124e7e457680d700e986fd0b0e0f046fadf67caf4Kristian Høgsberg return GL_FALSE; 25224e7e457680d700e986fd0b0e0f046fadf67caf4Kristian Høgsberg } 25324e7e457680d700e986fd0b0e0f046fadf67caf4Kristian Høgsberg 25424e7e457680d700e986fd0b0e0f046fadf67caf4Kristian Høgsberg return GL_TRUE; 25524e7e457680d700e986fd0b0e0f046fadf67caf4Kristian Høgsberg} 25677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 25777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholtstatic GLboolean intelInitDriver(__DRIscreenPrivate *sPriv) 25877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt{ 25977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreenPrivate *intelScreen; 26077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt I830DRIPtr gDRIPriv = (I830DRIPtr) sPriv->pDevPriv; 26139e6d0d8108fe6d222865e7bb9de1e3cea18b4c4Timo Aaltonen drm_i915_sarea_t *sarea; 26277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 26377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if (sPriv->devPrivSize != sizeof(I830DRIRec)) { 26477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt fprintf(stderr, 26577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt "\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n"); 26677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt return GL_FALSE; 26777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 26877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 26977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt /* Allocate the private area */ 27077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen = (intelScreenPrivate *) CALLOC(sizeof(intelScreenPrivate)); 27177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if (!intelScreen) { 27277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt fprintf(stderr, "\nERROR! Allocating private area failed\n"); 27377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt return GL_FALSE; 27477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 27577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt /* parse information in __driConfigOptions */ 27677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt driParseOptionInfo(&intelScreen->optionCache, 27777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt __driConfigOptions, __driNConfigOptions); 27877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 27977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->driScrnPriv = sPriv; 28077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt sPriv->private = (void *) intelScreen; 28139e6d0d8108fe6d222865e7bb9de1e3cea18b4c4Timo Aaltonen sarea = (drm_i915_sarea_t *) 2823628185f566e178a12b493fb89abf52b4b281f99Eric Anholt (((GLubyte *) sPriv->pSAREA) + gDRIPriv->sarea_priv_offset); 2833628185f566e178a12b493fb89abf52b4b281f99Eric Anholt intelScreen->sarea = sarea; 28477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 28577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->deviceID = gDRIPriv->deviceID; 28677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 28777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelUpdateScreenFromSAREA(intelScreen, sarea); 28877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 28977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if (!intelMapScreenRegions(sPriv)) { 29077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt fprintf(stderr, "\nERROR! mapping regions\n"); 29177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt _mesa_free(intelScreen); 29277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt sPriv->private = NULL; 29377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt return GL_FALSE; 29477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 29577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 29677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if (0) 29777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelPrintDRIInfo(intelScreen, sPriv, gDRIPriv); 29877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 29977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreen->drmMinor = sPriv->drm_version.minor; 30077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 30177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt /* Determine if IRQs are active? */ 3021c718c0d78cf4eae9e02b03a0abbec384db948a6Alan Hourihane if (!intel_get_param(sPriv, I915_PARAM_IRQ_ACTIVE, 30324e7e457680d700e986fd0b0e0f046fadf67caf4Kristian Høgsberg &intelScreen->irq_active)) 30424e7e457680d700e986fd0b0e0f046fadf67caf4Kristian Høgsberg return GL_FALSE; 30577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 306e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg sPriv->extensions = intelScreenExtensions; 30777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 30877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt return GL_TRUE; 30977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt} 31077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 31177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 31277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholtstatic void 31377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric AnholtintelDestroyScreen(__DRIscreenPrivate * sPriv) 31477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt{ 31577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private; 31677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 317904f31a62444d9f7e9b12ddafaa4beeb7fed6dfaEric Anholt dri_bufmgr_destroy(intelScreen->bufmgr); 31877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelUnmapScreenRegions(intelScreen); 31960953059ea2319eae4d737831824dbce08ee1725Eric Anholt driDestroyOptionCache(&intelScreen->optionCache); 32077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 32177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt FREE(intelScreen); 32277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt sPriv->private = NULL; 32377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt} 32477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 32577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 32677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt/** 32777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * This is called when we need to set up GL rendering to a new X window. 32877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt */ 32977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholtstatic GLboolean 33077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric AnholtintelCreateBuffer(__DRIscreenPrivate * driScrnPriv, 33177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt __DRIdrawablePrivate * driDrawPriv, 33277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt const __GLcontextModes * mesaVis, GLboolean isPixmap) 33377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt{ 33477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if (isPixmap) { 33577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt return GL_FALSE; /* not implemented */ 33677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 33777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt else { 33877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt GLboolean swStencil = (mesaVis->stencilBits > 0 && 33977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt mesaVis->depthBits != 24); 340119f34e2a52d7e074ea51d49acf6c11d83142cccEric Anholt GLenum rgbFormat; 34177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 34277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt struct intel_framebuffer *intel_fb = CALLOC_STRUCT(intel_framebuffer); 34377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 34477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if (!intel_fb) 34577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt return GL_FALSE; 34677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 34777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt _mesa_initialize_framebuffer(&intel_fb->Base, mesaVis); 34877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 349119f34e2a52d7e074ea51d49acf6c11d83142cccEric Anholt if (mesaVis->redBits == 5) 350119f34e2a52d7e074ea51d49acf6c11d83142cccEric Anholt rgbFormat = GL_RGB5; 351119f34e2a52d7e074ea51d49acf6c11d83142cccEric Anholt else if (mesaVis->alphaBits == 0) 352119f34e2a52d7e074ea51d49acf6c11d83142cccEric Anholt rgbFormat = GL_RGB8; 353119f34e2a52d7e074ea51d49acf6c11d83142cccEric Anholt else 354119f34e2a52d7e074ea51d49acf6c11d83142cccEric Anholt rgbFormat = GL_RGBA8; 355119f34e2a52d7e074ea51d49acf6c11d83142cccEric Anholt 35677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt /* setup the hardware-based renderbuffers */ 357f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie intel_fb->color_rb[0] = intel_create_renderbuffer(rgbFormat); 358f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT, 359f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie &intel_fb->color_rb[0]->Base); 36077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 36177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if (mesaVis->doubleBufferMode) { 362f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie intel_fb->color_rb[1] = intel_create_renderbuffer(rgbFormat); 363f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie 36477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT, 36577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt &intel_fb->color_rb[1]->Base); 36677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 36777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 36877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 36938c616260a4c14bf5a1d7831e6349c3e8817d14bEric Anholt if (mesaVis->depthBits == 24) { 37038c616260a4c14bf5a1d7831e6349c3e8817d14bEric Anholt if (mesaVis->stencilBits == 8) { 37138c616260a4c14bf5a1d7831e6349c3e8817d14bEric Anholt /* combined depth/stencil buffer */ 37238c616260a4c14bf5a1d7831e6349c3e8817d14bEric Anholt struct intel_renderbuffer *depthStencilRb 373e131c46b20241737ceba4856dbe01dcca6dd2c03Kristian Høgsberg = intel_create_renderbuffer(GL_DEPTH24_STENCIL8_EXT); 37438c616260a4c14bf5a1d7831e6349c3e8817d14bEric Anholt /* note: bind RB to two attachment points */ 37538c616260a4c14bf5a1d7831e6349c3e8817d14bEric Anholt _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, 37638c616260a4c14bf5a1d7831e6349c3e8817d14bEric Anholt &depthStencilRb->Base); 37738c616260a4c14bf5a1d7831e6349c3e8817d14bEric Anholt _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_STENCIL, 37838c616260a4c14bf5a1d7831e6349c3e8817d14bEric Anholt &depthStencilRb->Base); 37938c616260a4c14bf5a1d7831e6349c3e8817d14bEric Anholt } else { 38038c616260a4c14bf5a1d7831e6349c3e8817d14bEric Anholt struct intel_renderbuffer *depthRb 381e131c46b20241737ceba4856dbe01dcca6dd2c03Kristian Høgsberg = intel_create_renderbuffer(GL_DEPTH_COMPONENT24); 38238c616260a4c14bf5a1d7831e6349c3e8817d14bEric Anholt _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, 38338c616260a4c14bf5a1d7831e6349c3e8817d14bEric Anholt &depthRb->Base); 38438c616260a4c14bf5a1d7831e6349c3e8817d14bEric Anholt } 38577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 38677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt else if (mesaVis->depthBits == 16) { 38777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt /* just 16-bit depth buffer, no hw stencil */ 38877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt struct intel_renderbuffer *depthRb 389f75843a517bd188639e6866db2a7b04de3524e16Dave Airlie = intel_create_renderbuffer(GL_DEPTH_COMPONENT16); 39077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, &depthRb->Base); 39177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 39277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 39377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt /* now add any/all software-based renderbuffers we may need */ 39477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt _mesa_add_soft_renderbuffers(&intel_fb->Base, 39577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt GL_FALSE, /* never sw color */ 39677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt GL_FALSE, /* never sw depth */ 39777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt swStencil, mesaVis->accumRedBits > 0, 39877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt GL_FALSE, /* never sw alpha */ 39977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt GL_FALSE /* never sw aux */ ); 40077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt driDrawPriv->driverPrivate = (void *) intel_fb; 40177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 40277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt return GL_TRUE; 40377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 40477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt} 40577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 40677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholtstatic void 40777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric AnholtintelDestroyBuffer(__DRIdrawablePrivate * driDrawPriv) 40877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt{ 4090f04a1d3f8989b0a391e6dad80abf06ce151d1f1Brian Paul _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL); 41077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt} 41177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 41277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 41377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt/** 41477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * Get information about previous buffer swaps. 41577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt */ 41677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholtstatic int 41777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric AnholtintelGetSwapInfo(__DRIdrawablePrivate * dPriv, __DRIswapInfo * sInfo) 41877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt{ 41977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt struct intel_framebuffer *intel_fb; 42077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 42177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if ((dPriv == NULL) || (dPriv->driverPrivate == NULL) 42277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt || (sInfo == NULL)) { 42377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt return -1; 42477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 42577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 42677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intel_fb = dPriv->driverPrivate; 42777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt sInfo->swap_count = intel_fb->swap_count; 42877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt sInfo->swap_ust = intel_fb->swap_ust; 42977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt sInfo->swap_missed_count = intel_fb->swap_missed_count; 43077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 43177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt sInfo->swap_missed_usage = (sInfo->swap_missed_count != 0) 43277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt ? driCalculateSwapUsage(dPriv, 0, intel_fb->swap_missed_ust) 43377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt : 0.0; 43477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 43577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt return 0; 43677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt} 43777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 43877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 43977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt/* There are probably better ways to do this, such as an 44077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * init-designated function to register chipids and createcontext 44177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * functions. 44277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt */ 44377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholtextern GLboolean i830CreateContext(const __GLcontextModes * mesaVis, 44477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt __DRIcontextPrivate * driContextPriv, 44577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt void *sharedContextPrivate); 44677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 44777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholtextern GLboolean i915CreateContext(const __GLcontextModes * mesaVis, 44877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt __DRIcontextPrivate * driContextPriv, 44977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt void *sharedContextPrivate); 450bea6b5fe5aa3138cec8d057766ae48da4aa57deeEric Anholtextern GLboolean brwCreateContext(const __GLcontextModes * mesaVis, 451bea6b5fe5aa3138cec8d057766ae48da4aa57deeEric Anholt __DRIcontextPrivate * driContextPriv, 452bea6b5fe5aa3138cec8d057766ae48da4aa57deeEric Anholt void *sharedContextPrivate); 45377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 45477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholtstatic GLboolean 45577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric AnholtintelCreateContext(const __GLcontextModes * mesaVis, 45677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt __DRIcontextPrivate * driContextPriv, 45777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt void *sharedContextPrivate) 45877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt{ 45977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; 46077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private; 46177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 462bea6b5fe5aa3138cec8d057766ae48da4aa57deeEric Anholt#ifdef I915 46319420e6c2592e8a31e2ead4bccebc1a9ccca52b1Eric Anholt if (IS_9XX(intelScreen->deviceID)) { 46419420e6c2592e8a31e2ead4bccebc1a9ccca52b1Eric Anholt if (!IS_965(intelScreen->deviceID)) { 46519420e6c2592e8a31e2ead4bccebc1a9ccca52b1Eric Anholt return i915CreateContext(mesaVis, driContextPriv, 466bea6b5fe5aa3138cec8d057766ae48da4aa57deeEric Anholt sharedContextPrivate); 46719420e6c2592e8a31e2ead4bccebc1a9ccca52b1Eric Anholt } 468bea6b5fe5aa3138cec8d057766ae48da4aa57deeEric Anholt } else { 469cd031749a75883a6fbf8fb7bf989b77a7c705819Dave Airlie intelScreen->no_vbo = GL_TRUE; 47077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt return i830CreateContext(mesaVis, driContextPriv, sharedContextPrivate); 47177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 472bea6b5fe5aa3138cec8d057766ae48da4aa57deeEric Anholt#else 473bea6b5fe5aa3138cec8d057766ae48da4aa57deeEric Anholt if (IS_965(intelScreen->deviceID)) 474bea6b5fe5aa3138cec8d057766ae48da4aa57deeEric Anholt return brwCreateContext(mesaVis, driContextPriv, sharedContextPrivate); 475bea6b5fe5aa3138cec8d057766ae48da4aa57deeEric Anholt#endif 476bea6b5fe5aa3138cec8d057766ae48da4aa57deeEric Anholt fprintf(stderr, "Unrecognized deviceID %x\n", intelScreen->deviceID); 477bea6b5fe5aa3138cec8d057766ae48da4aa57deeEric Anholt return GL_FALSE; 47877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt} 47977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 48077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 481e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsbergstatic __DRIconfig ** 4826cb3f5c4d8618a14bb7ad1d9df10ed7e648a7b2bKristian HøgsbergintelFillInModes(__DRIscreenPrivate *psp, 4836cb3f5c4d8618a14bb7ad1d9df10ed7e648a7b2bKristian Høgsberg unsigned pixel_bits, unsigned depth_bits, 48477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt unsigned stencil_bits, GLboolean have_back_buffer) 48577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt{ 486e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg __DRIconfig **configs; 48777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt __GLcontextModes *m; 48877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt unsigned depth_buffer_factor; 48977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt unsigned back_buffer_factor; 490e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg int i; 49177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 49277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't 49377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * support pageflipping at all. 49477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt */ 49577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt static const GLenum back_buffer_modes[] = { 49677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML 49777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt }; 49877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 4995a46e176715b0eae7b8a715e8aec42f5a27214fcKeith Whitwell uint8_t depth_bits_array[3]; 5005a46e176715b0eae7b8a715e8aec42f5a27214fcKeith Whitwell uint8_t stencil_bits_array[3]; 501e13593678f62941db06b7ae1a21b81c643371659Brian Paul uint8_t msaa_samples_array[1]; 50277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 50377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt depth_bits_array[0] = 0; 50477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt depth_bits_array[1] = depth_bits; 50577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt depth_bits_array[2] = depth_bits; 50677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 50777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt /* Just like with the accumulation buffer, always provide some modes 50877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * with a stencil buffer. It will be a sw fallback, but some apps won't 50977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * care about that. 51077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt */ 51177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt stencil_bits_array[0] = 0; 51277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt stencil_bits_array[1] = 0; 51377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if (depth_bits == 24) 51477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits; 51577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 51677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt stencil_bits_array[2] = (stencil_bits == 0) ? 8 : stencil_bits; 51777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 518eaf15db895e3a5c6c5ccc2f23a4f0fa522855868Michel Dänzer msaa_samples_array[0] = 0; 519eaf15db895e3a5c6c5ccc2f23a4f0fa522855868Michel Dänzer 52077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1; 52177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt back_buffer_factor = (have_back_buffer) ? 3 : 1; 52277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 52377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if (pixel_bits == 16) { 5245d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 5255d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt depth_bits_array, stencil_bits_array, 5265d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt depth_buffer_factor, back_buffer_modes, 5275d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt back_buffer_factor, 5285d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt msaa_samples_array, 1); 52977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 53077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt else { 5315d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt __DRIconfig **configs_a8r8g8b8; 5325d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt __DRIconfig **configs_x8r8g8b8; 5335d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt 5345d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt configs_a8r8g8b8 = driCreateConfigs(GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 5355d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt depth_bits_array, 5365d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt stencil_bits_array, 5375d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt depth_buffer_factor, 5385d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt back_buffer_modes, 5395d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt back_buffer_factor, 5405d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt msaa_samples_array, 1); 5415d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt configs_x8r8g8b8 = driCreateConfigs(GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV, 5425d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt depth_bits_array, 5435d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt stencil_bits_array, 5445d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt depth_buffer_factor, 5455d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt back_buffer_modes, 5465d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt back_buffer_factor, 5475d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt msaa_samples_array, 1); 5485d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt configs = driConcatConfigs(configs_a8r8g8b8, configs_x8r8g8b8); 54977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 55077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 551e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg if (configs == NULL) { 552e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, 55377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt __LINE__); 55477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt return NULL; 55577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 55677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 55777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt /* Mark the visual as slow if there are "fake" stencil bits. 55877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt */ 559e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg for (i = 0; configs[i]; i++) { 560e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg m = &configs[i]->modes; 56177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) { 56277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt m->visualRating = GLX_SLOW_CONFIG; 56377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 56477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 56577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 566e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg return configs; 56777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt} 56877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 5697e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholtstatic GLboolean 5707e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholtintel_init_bufmgr(intelScreenPrivate *intelScreen) 5717e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt{ 5727e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt GLboolean gem_disable = getenv("INTEL_NO_GEM") != NULL; 5737e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt int gem_kernel = 0; 5747e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt GLboolean gem_supported; 5757e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt struct drm_i915_getparam gp; 5767e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt __DRIscreenPrivate *spriv = intelScreen->driScrnPriv; 577e7aef006e50d0b859c621267af8376f5a0f43445Eric Anholt int num_fences; 5787e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt 5797e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt intelScreen->no_hw = getenv("INTEL_NO_HW") != NULL; 5807e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt 5817e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt gp.param = I915_PARAM_HAS_GEM; 5827e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt gp.value = &gem_kernel; 5837e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt 5847e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt (void) drmCommandWriteRead(spriv->fd, DRM_I915_GETPARAM, &gp, sizeof(gp)); 5857e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt 5867e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt /* If we've got a new enough DDX that's initializing GEM and giving us 5877e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt * object handles for the shared buffers, use that. 5887e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt */ 5897e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt intelScreen->ttm = GL_FALSE; 5907e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt if (intelScreen->driScrnPriv->dri2.enabled) 5917e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt gem_supported = GL_TRUE; 5927e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt else if (intelScreen->driScrnPriv->ddx_version.minor >= 9 && 5937e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt gem_kernel && 5947e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt intelScreen->front.bo_handle != -1) 5957e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt gem_supported = GL_TRUE; 5967e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt else 5977e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt gem_supported = GL_FALSE; 5987e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt 5997e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt if (!gem_disable && gem_supported) { 6007e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt intelScreen->bufmgr = intel_bufmgr_gem_init(spriv->fd, BATCH_SZ); 6017e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt if (intelScreen->bufmgr != NULL) 6027e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt intelScreen->ttm = GL_TRUE; 6037e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt } 6047e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt /* Otherwise, use the classic buffer manager. */ 6057e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt if (intelScreen->bufmgr == NULL) { 6067e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt if (gem_disable) { 6077e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt fprintf(stderr, "GEM disabled. Using classic.\n"); 6087e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt } else { 6097e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt fprintf(stderr, "Failed to initialize GEM. " 6107e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt "Falling back to classic.\n"); 6117e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt } 6127e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt 6137e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt if (intelScreen->tex.size == 0) { 6147e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt fprintf(stderr, "[%s:%u] Error initializing buffer manager.\n", 6157e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt __func__, __LINE__); 6167e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt return GL_FALSE; 6177e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt } 6187e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt 6193628185f566e178a12b493fb89abf52b4b281f99Eric Anholt intelScreen->bufmgr = 6203628185f566e178a12b493fb89abf52b4b281f99Eric Anholt intel_bufmgr_fake_init(spriv->fd, 6213628185f566e178a12b493fb89abf52b4b281f99Eric Anholt intelScreen->tex.offset, 6223628185f566e178a12b493fb89abf52b4b281f99Eric Anholt intelScreen->tex.map, 6233628185f566e178a12b493fb89abf52b4b281f99Eric Anholt intelScreen->tex.size, 6243628185f566e178a12b493fb89abf52b4b281f99Eric Anholt (unsigned int * volatile) 6253628185f566e178a12b493fb89abf52b4b281f99Eric Anholt &intelScreen->sarea->last_dispatch); 6267e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt } 6277e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt 628e7aef006e50d0b859c621267af8376f5a0f43445Eric Anholt if (intel_get_param(spriv, I915_PARAM_NUM_FENCES_AVAIL, &num_fences)) 629e7aef006e50d0b859c621267af8376f5a0f43445Eric Anholt intelScreen->kernel_exec_fencing = !!num_fences; 630e7aef006e50d0b859c621267af8376f5a0f43445Eric Anholt else 631e7aef006e50d0b859c621267af8376f5a0f43445Eric Anholt intelScreen->kernel_exec_fencing = GL_FALSE; 632e7aef006e50d0b859c621267af8376f5a0f43445Eric Anholt 6337e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt return GL_TRUE; 6347e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt} 6357e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt 63677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt/** 63777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * This is the driver specific part of the createNewScreen entry point. 6388d976aedc4654bc66b80f22690e3674f1ef46183Brian Paul * Called when using legacy DRI. 63977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * 64077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * \todo maybe fold this into intelInitDriver 64177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * 64277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * \return the __GLcontextModes supported by this driver 64377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt */ 644e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsbergstatic const __DRIconfig **intelInitScreen(__DRIscreenPrivate *psp) 64577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt{ 6467e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt intelScreenPrivate *intelScreen; 647bea6b5fe5aa3138cec8d057766ae48da4aa57deeEric Anholt#ifdef I915 64877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt static const __DRIversion ddx_expected = { 1, 5, 0 }; 649bea6b5fe5aa3138cec8d057766ae48da4aa57deeEric Anholt#else 650bea6b5fe5aa3138cec8d057766ae48da4aa57deeEric Anholt static const __DRIversion ddx_expected = { 1, 6, 0 }; 651bea6b5fe5aa3138cec8d057766ae48da4aa57deeEric Anholt#endif 65277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt static const __DRIversion dri_expected = { 4, 0, 0 }; 65377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt static const __DRIversion drm_expected = { 1, 5, 0 }; 65477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv; 65577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 65677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if (!driCheckDriDdxDrmVersions2("i915", 65777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt &psp->dri_version, &dri_expected, 65877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt &psp->ddx_version, &ddx_expected, 65977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt &psp->drm_version, &drm_expected)) { 66077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt return NULL; 66177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 66277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 66377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt /* Calling driInitExtensions here, with a NULL context pointer, 66477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * does not actually enable the extensions. It just makes sure 66577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * that all the dispatch offsets for all the extensions that 66677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * *might* be enables are known. This is needed because the 66777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * dispatch offsets need to be known when _mesa_context_create is 66877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * called, but we can't enable the extensions until we have a 66977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * context pointer. 67077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * 67177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * Hello chicken. Hello egg. How are you two today? 67277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt */ 67360c0f09abb9421de359cd92e094a943d650fc7faKristian Høgsberg intelInitExtensions(NULL, GL_TRUE); 67460c0f09abb9421de359cd92e094a943d650fc7faKristian Høgsberg 67577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if (!intelInitDriver(psp)) 67677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt return NULL; 67777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 678e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg psp->extensions = intelScreenExtensions; 679e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg 6807e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt intelScreen = psp->private; 6817e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt if (!intel_init_bufmgr(intelScreen)) 6827e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt return GL_FALSE; 6837e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt 684e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg return (const __DRIconfig **) 685e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg intelFillInModes(psp, dri_priv->cpp * 8, 686e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg (dri_priv->cpp == 2) ? 16 : 24, 687e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg (dri_priv->cpp == 2) ? 0 : 8, 1); 68877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt} 68977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 69077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholtstruct intel_context *intelScreenContext(intelScreenPrivate *intelScreen) 69177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt{ 69277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt /* 69377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * This should probably change to have the screen allocate a dummy 69477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt * context at screen creation. For now just use the current context. 69577a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt */ 69677a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 69777a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt GET_CURRENT_CONTEXT(ctx); 69877a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt if (ctx == NULL) { 69977a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt _mesa_problem(NULL, "No current context in intelScreenContext\n"); 70077a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt return NULL; 70177a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt } 70277a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt return intel_context(ctx); 70377a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt} 70477a5bcaff43df8d54e0e0ef833726e4b41d7eb36Eric Anholt 705c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg/** 706c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg * This is the driver specific part of the createNewScreen entry point. 7078d976aedc4654bc66b80f22690e3674f1ef46183Brian Paul * Called when using DRI2. 7088d976aedc4654bc66b80f22690e3674f1ef46183Brian Paul * 709c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg * \return the __GLcontextModes supported by this driver 710c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg */ 711e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsbergstatic const 712e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg__DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp) 713c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg{ 714c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg intelScreenPrivate *intelScreen; 7153ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt GLenum fb_format[3]; 7163ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt GLenum fb_type[3]; 7173ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't 7183ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt * support pageflipping at all. 7193ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt */ 7203ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt static const GLenum back_buffer_modes[] = { 7213ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML 7223ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt }; 723e13593678f62941db06b7ae1a21b81c643371659Brian Paul uint8_t depth_bits[4], stencil_bits[4], msaa_samples_array[1]; 7243ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt int color; 7255d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt __DRIconfig **configs = NULL; 726c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg 727c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg /* Calling driInitExtensions here, with a NULL context pointer, 728c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg * does not actually enable the extensions. It just makes sure 729c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg * that all the dispatch offsets for all the extensions that 730c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg * *might* be enables are known. This is needed because the 731c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg * dispatch offsets need to be known when _mesa_context_create is 732c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg * called, but we can't enable the extensions until we have a 733c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg * context pointer. 734c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg * 735c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg * Hello chicken. Hello egg. How are you two today? 736c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg */ 73760c0f09abb9421de359cd92e094a943d650fc7faKristian Høgsberg intelInitExtensions(NULL, GL_TRUE); 738c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg 739c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg /* Allocate the private area */ 740c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg intelScreen = (intelScreenPrivate *) CALLOC(sizeof(intelScreenPrivate)); 741c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg if (!intelScreen) { 742c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg fprintf(stderr, "\nERROR! Allocating private area failed\n"); 743c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg return GL_FALSE; 744c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg } 745c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg /* parse information in __driConfigOptions */ 746c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg driParseOptionInfo(&intelScreen->optionCache, 747c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg __driConfigOptions, __driNConfigOptions); 748c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg 749c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg intelScreen->driScrnPriv = psp; 750c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg psp->private = (void *) intelScreen; 751c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg 752c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg intelScreen->drmMinor = psp->drm_version.minor; 753c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg 754f56b569e9af356c11869ee49a4669bb01b75397eKristian Høgsberg /* Determine chipset ID */ 755c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg if (!intel_get_param(psp, I915_PARAM_CHIPSET_ID, 756c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg &intelScreen->deviceID)) 757c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg return GL_FALSE; 758c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg 7597e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt if (!intel_init_bufmgr(intelScreen)) 7607e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt return GL_FALSE; 7617e0bbdcf033981282978554c2e68ce48b55aa291Eric Anholt 762f56b569e9af356c11869ee49a4669bb01b75397eKristian Høgsberg intelScreen->irq_active = 1; 763e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg psp->extensions = intelScreenExtensions; 764c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg 7653ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt depth_bits[0] = 0; 7663ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt stencil_bits[0] = 0; 7673ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt depth_bits[1] = 16; 7683ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt stencil_bits[1] = 0; 7693ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt depth_bits[2] = 24; 7703ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt stencil_bits[2] = 0; 7713ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt depth_bits[3] = 24; 7723ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt stencil_bits[3] = 8; 7733ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt 774eaf15db895e3a5c6c5ccc2f23a4f0fa522855868Michel Dänzer msaa_samples_array[0] = 0; 775eaf15db895e3a5c6c5ccc2f23a4f0fa522855868Michel Dänzer 7763ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt fb_format[0] = GL_RGB; 7773ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt fb_type[0] = GL_UNSIGNED_SHORT_5_6_5; 7783ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt 77924ff169486e315671c09cd8a57a311a935ccfff5Eric Anholt fb_format[1] = GL_BGR; 7803ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt fb_type[1] = GL_UNSIGNED_INT_8_8_8_8_REV; 7813ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt 78224ff169486e315671c09cd8a57a311a935ccfff5Eric Anholt fb_format[2] = GL_BGRA; 7833ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt fb_type[2] = GL_UNSIGNED_INT_8_8_8_8_REV; 7843ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt 785160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt depth_bits[0] = 0; 786160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt stencil_bits[0] = 0; 787160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt 7883ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt for (color = 0; color < ARRAY_SIZE(fb_format); color++) { 7895d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt __DRIconfig **new_configs; 790160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt int depth_factor; 791160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt 792160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt /* With DRI2 right now, GetBuffers always returns a depth/stencil buffer 793160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt * with the same cpp as the drawable. So we can't support depth cpp != 794160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt * color cpp currently. 795160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt */ 796160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt if (fb_type[color] == GL_UNSIGNED_SHORT_5_6_5) { 797160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt depth_bits[1] = 16; 798160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt stencil_bits[1] = 0; 799160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt 800160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt depth_factor = 2; 801160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt } else { 802160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt depth_bits[1] = 24; 803160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt stencil_bits[1] = 0; 804160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt depth_bits[2] = 24; 805160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt stencil_bits[2] = 8; 8065d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt 807160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt depth_factor = 3; 808160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt } 8095d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt new_configs = driCreateConfigs(fb_format[color], fb_type[color], 8105d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt depth_bits, 8115d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt stencil_bits, 812160c3617fc8867edc445b1ba62fc996c4630cc35Eric Anholt depth_factor, 8135d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt back_buffer_modes, 8145d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt ARRAY_SIZE(back_buffer_modes), 8155d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt msaa_samples_array, 8165d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt ARRAY_SIZE(msaa_samples_array)); 8173ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt if (configs == NULL) 8183ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt configs = new_configs; 8193ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt else 8203ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt configs = driConcatConfigs(configs, new_configs); 8213ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt } 8223ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt 8233ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt if (configs == NULL) { 8243ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, 8253ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt __LINE__); 8263ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt return NULL; 8273ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt } 8283ee21f30cda27e0ee1357f930163526622ba9434Eric Anholt 8295d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt return (const __DRIconfig **)configs; 830c5c73c1b605611faf0f06df9b5d08d8984388238Kristian Høgsberg} 831e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg 832e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsbergconst struct __DriverAPIRec driDriverAPI = { 833e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg .InitScreen = intelInitScreen, 834e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg .DestroyScreen = intelDestroyScreen, 835e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg .CreateContext = intelCreateContext, 836e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg .DestroyContext = intelDestroyContext, 837e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg .CreateBuffer = intelCreateBuffer, 838e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg .DestroyBuffer = intelDestroyBuffer, 839e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg .SwapBuffers = intelSwapBuffers, 840e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg .MakeCurrent = intelMakeCurrent, 841e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg .UnbindContext = intelUnbindContext, 842e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg .GetSwapInfo = intelGetSwapInfo, 843e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg .GetDrawableMSC = driDrawableGetMSC32, 844e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg .WaitForMSC = driWaitForMSC32, 845e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg .CopySubBuffer = intelCopySubBuffer, 846e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg 847e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg .InitScreen2 = intelInitScreen2, 848e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg}; 849