intel_screen.h revision f172eae8b23d0612865895c52af745021ae20a4c
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#ifndef _INTEL_INIT_H_ 29#define _INTEL_INIT_H_ 30 31#include <stdbool.h> 32#include <sys/time.h> 33#include "dri_util.h" 34#include "intel_bufmgr.h" 35#include "i915_drm.h" 36#include "xmlconfig.h" 37 38/** 39 * \brief Does X driver support DRI2BufferHiz and DRI2BufferStencil? 40 * 41 * (Here, "X driver" referes to the DDX driver, xf86-video-intel). 42 * 43 * The DRI2 protocol does not allow us to query the X driver's version nor 44 * query for a list of buffer formats that the driver supports. So, to 45 * determine if the X driver supports DRI2BufferHiz and DRI2BufferStencil we 46 * must resort to a handshake. 47 * 48 * If the hardware lacks support for separate stencil (and consequently, lacks 49 * support for hiz also), then the X driver's separate stencil and hiz support 50 * is irrelevant and the handshake never occurs. 51 * 52 * Complications 53 * ------------- 54 * The handshake is complicated by a bug in xf86-video-intel 2.15. Even though 55 * that version of the X driver did not supppot requests for DRI2BufferHiz or 56 * DRI2BufferStencil, if requested one it still allocated and returned one. 57 * The returned buffer, however, was incorrectly X tiled. 58 * 59 * How the handshake works 60 * ----------------------- 61 * Initially, intel_screen.dri2_has_hiz is set to unknown. The first time the 62 * user requests a depth and stencil buffer, intelCreateBuffers() creates a 63 * framebuffer with separate depth and stencil attachments (with formats 64 * x8_z24 and s8). 65 * 66 * Eventually, intel_update_renderbuffers() makes a DRI2 request for 67 * DRI2BufferStencil and DRI2BufferHiz. If the stencil buffer's tiling is 68 * I915_TILING_NONE [1], then we joyfully set intel_screen.dri2_has_hiz to 69 * true and continue as if nothing happend. 70 * 71 * [1] The stencil buffer is actually W tiled. However, we request from the 72 * kernel a non-tiled buffer because the GTT is incapable of W fencing. 73 * 74 * If the buffers are X tiled, however, the handshake has failed and we must 75 * clean up. 76 * 1. Angrily set intel_screen.dri2_has_hiz to false. 77 * 2. Discard the framebuffer's depth and stencil attachments. 78 * 3. Attach a packed depth/stencil buffer to the framebuffer (with format 79 * s8_z24). 80 * 4. Make a DRI2 request for the new buffer, using attachment type 81 * DRI2BufferDepthStencil). 82 * 83 * Future Considerations 84 * --------------------- 85 * On a sunny day in the far future, when we are certain that no one has an 86 * xf86-video-intel installed without hiz and separate stencil support, then 87 * this enumerant and the handshake should die. 88 */ 89enum intel_dri2_has_hiz { 90 INTEL_DRI2_HAS_HIZ_UNKNOWN, 91 INTEL_DRI2_HAS_HIZ_TRUE, 92 INTEL_DRI2_HAS_HIZ_FALSE, 93}; 94 95struct intel_screen 96{ 97 int deviceID; 98 int gen; 99 100 int logTextureGranularity; 101 102 __DRIscreen *driScrnPriv; 103 104 bool no_hw; 105 GLuint relaxed_relocations; 106 107 /* 108 * The hardware hiz and separate stencil fields are needed in intel_screen, 109 * rather than solely in intel_context, because glXCreatePbuffer and 110 * glXCreatePixmap are not passed a GLXContext. 111 */ 112 bool hw_has_separate_stencil; 113 bool hw_must_use_separate_stencil; 114 bool hw_has_hiz; 115 enum intel_dri2_has_hiz dri2_has_hiz; 116 117 bool kernel_has_gen7_sol_reset; 118 119 bool hw_has_llc; 120 bool hw_has_swizzling; 121 122 bool no_vbo; 123 dri_bufmgr *bufmgr; 124 struct _mesa_HashTable *named_regions; 125 126 /** 127 * Configuration cache with default values for all contexts 128 */ 129 driOptionCache optionCache; 130}; 131 132extern bool intelMapScreenRegions(__DRIscreen * sPriv); 133 134extern void intelDestroyContext(__DRIcontext * driContextPriv); 135 136extern GLboolean intelUnbindContext(__DRIcontext * driContextPriv); 137 138extern GLboolean 139intelMakeCurrent(__DRIcontext * driContextPriv, 140 __DRIdrawable * driDrawPriv, 141 __DRIdrawable * driReadPriv); 142 143#endif 144