17117f1b4Smrg/* 27117f1b4Smrg * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. 3c1f859d4Smrg * Copyright 2007-2008 Red Hat, Inc. 47117f1b4Smrg * (C) Copyright IBM Corporation 2004 57117f1b4Smrg * All Rights Reserved. 67117f1b4Smrg * 77117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a 87117f1b4Smrg * copy of this software and associated documentation files (the "Software"), 97117f1b4Smrg * to deal in the Software without restriction, including without limitation 107117f1b4Smrg * on the rights to use, copy, modify, merge, publish, distribute, sub 117117f1b4Smrg * license, and/or sell copies of the Software, and to permit persons to whom 127117f1b4Smrg * the Software is furnished to do so, subject to the following conditions: 137117f1b4Smrg * 147117f1b4Smrg * The above copyright notice and this permission notice (including the next 157117f1b4Smrg * paragraph) shall be included in all copies or substantial portions of the 167117f1b4Smrg * Software. 177117f1b4Smrg * 187117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 197117f1b4Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 207117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 217117f1b4Smrg * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 227117f1b4Smrg * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 237117f1b4Smrg * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 247117f1b4Smrg * USE OR OTHER DEALINGS IN THE SOFTWARE. 257117f1b4Smrg */ 267117f1b4Smrg 277117f1b4Smrg/** 287117f1b4Smrg * \file dri_interface.h 297117f1b4Smrg * 307117f1b4Smrg * This file contains all the types and functions that define the interface 317117f1b4Smrg * between a DRI driver and driver loader. Currently, the most common driver 327117f1b4Smrg * loader is the XFree86 libGL.so. However, other loaders do exist, and in 337117f1b4Smrg * the future the server-side libglx.a will also be a loader. 347117f1b4Smrg * 357117f1b4Smrg * \author Kevin E. Martin <kevin@precisioninsight.com> 367117f1b4Smrg * \author Ian Romanick <idr@us.ibm.com> 37c1f859d4Smrg * \author Kristian Høgsberg <krh@redhat.com> 387117f1b4Smrg */ 397117f1b4Smrg 407117f1b4Smrg#ifndef DRI_INTERFACE_H 417117f1b4Smrg#define DRI_INTERFACE_H 427117f1b4Smrg 4301e04c3fSmrg#ifdef HAVE_LIBDRM 447117f1b4Smrg#include <drm.h> 45c1f859d4Smrg#else 467d084a0eSchristos#ifndef _DRM_H_ 47c1f859d4Smrgtypedef unsigned int drm_context_t; 48c1f859d4Smrgtypedef unsigned int drm_drawable_t; 49c1f859d4Smrgtypedef struct drm_clip_rect drm_clip_rect_t; 50c1f859d4Smrg#endif 517d084a0eSchristos#endif 527117f1b4Smrg 5301e04c3fSmrg#include <stdint.h> 5401e04c3fSmrg 557117f1b4Smrg/** 567117f1b4Smrg * \name DRI interface structures 577117f1b4Smrg * 587117f1b4Smrg * The following structures define the interface between the GLX client 597117f1b4Smrg * side library and the DRI (direct rendering infrastructure). 607117f1b4Smrg */ 617117f1b4Smrg/*@{*/ 62c1f859d4Smrgtypedef struct __DRIdisplayRec __DRIdisplay; 63c1f859d4Smrgtypedef struct __DRIscreenRec __DRIscreen; 64c1f859d4Smrgtypedef struct __DRIcontextRec __DRIcontext; 65c1f859d4Smrgtypedef struct __DRIdrawableRec __DRIdrawable; 66c1f859d4Smrgtypedef struct __DRIconfigRec __DRIconfig; 67c1f859d4Smrgtypedef struct __DRIframebufferRec __DRIframebuffer; 68c1f859d4Smrgtypedef struct __DRIversionRec __DRIversion; 69c1f859d4Smrg 70c1f859d4Smrgtypedef struct __DRIcoreExtensionRec __DRIcoreExtension; 71c1f859d4Smrgtypedef struct __DRIextensionRec __DRIextension; 72c1f859d4Smrgtypedef struct __DRIcopySubBufferExtensionRec __DRIcopySubBufferExtension; 73c1f859d4Smrgtypedef struct __DRIswapControlExtensionRec __DRIswapControlExtension; 74c1f859d4Smrgtypedef struct __DRIframeTrackingExtensionRec __DRIframeTrackingExtension; 75c1f859d4Smrgtypedef struct __DRImediaStreamCounterExtensionRec __DRImediaStreamCounterExtension; 76c1f859d4Smrgtypedef struct __DRItexOffsetExtensionRec __DRItexOffsetExtension; 77c1f859d4Smrgtypedef struct __DRItexBufferExtensionRec __DRItexBufferExtension; 78c1f859d4Smrgtypedef struct __DRIlegacyExtensionRec __DRIlegacyExtension; 79c1f859d4Smrgtypedef struct __DRIswrastExtensionRec __DRIswrastExtension; 80c1f859d4Smrgtypedef struct __DRIbufferRec __DRIbuffer; 81c1f859d4Smrgtypedef struct __DRIdri2ExtensionRec __DRIdri2Extension; 82c1f859d4Smrgtypedef struct __DRIdri2LoaderExtensionRec __DRIdri2LoaderExtension; 834a49301eSmrgtypedef struct __DRI2flushExtensionRec __DRI2flushExtension; 84af69d88dSmrgtypedef struct __DRI2throttleExtensionRec __DRI2throttleExtension; 8501e04c3fSmrgtypedef struct __DRI2fenceExtensionRec __DRI2fenceExtension; 8601e04c3fSmrgtypedef struct __DRI2interopExtensionRec __DRI2interopExtension; 8701e04c3fSmrgtypedef struct __DRI2blobExtensionRec __DRI2blobExtension; 881463c08dSmrgtypedef struct __DRI2bufferDamageExtensionRec __DRI2bufferDamageExtension; 89af69d88dSmrg 90af69d88dSmrgtypedef struct __DRIimageLoaderExtensionRec __DRIimageLoaderExtension; 91af69d88dSmrgtypedef struct __DRIimageDriverExtensionRec __DRIimageDriverExtension; 92c1f859d4Smrg 937117f1b4Smrg/*@}*/ 947117f1b4Smrg 957117f1b4Smrg 967117f1b4Smrg/** 97c1f859d4Smrg * Extension struct. Drivers 'inherit' from this struct by embedding 98c1f859d4Smrg * it as the first element in the extension struct. 997117f1b4Smrg * 100c1f859d4Smrg * We never break API in for a DRI extension. If we need to change 101c1f859d4Smrg * the way things work in a non-backwards compatible manner, we 102c1f859d4Smrg * introduce a new extension. During a transition period, we can 103c1f859d4Smrg * leave both the old and the new extension in the driver, which 104c1f859d4Smrg * allows us to move to the new interface without having to update the 105c1f859d4Smrg * loader(s) in lock step. 106c1f859d4Smrg * 107c1f859d4Smrg * However, we can add entry points to an extension over time as long 108c1f859d4Smrg * as we don't break the old ones. As we add entry points to an 109c1f859d4Smrg * extension, we increase the version number. The corresponding 110c1f859d4Smrg * #define can be used to guard code that accesses the new entry 111c1f859d4Smrg * points at compile time and the version field in the extension 112c1f859d4Smrg * struct can be used at run-time to determine how to use the 113c1f859d4Smrg * extension. 1147117f1b4Smrg */ 115c1f859d4Smrgstruct __DRIextensionRec { 116c1f859d4Smrg const char *name; 117c1f859d4Smrg int version; 118c1f859d4Smrg}; 1197117f1b4Smrg 1207117f1b4Smrg/** 121c1f859d4Smrg * The first set of extension are the screen extensions, returned by 122c1f859d4Smrg * __DRIcore::getExtensions(). This entry point will return a list of 123c1f859d4Smrg * extensions and the loader can use the ones it knows about by 124c1f859d4Smrg * casting them to more specific extensions and advertising any GLX 125c1f859d4Smrg * extensions the DRI extensions enables. 1267117f1b4Smrg */ 1277117f1b4Smrg 1287117f1b4Smrg/** 129c1f859d4Smrg * Used by drivers to indicate support for setting the read drawable. 1307117f1b4Smrg */ 131c1f859d4Smrg#define __DRI_READ_DRAWABLE "DRI_ReadDrawable" 132c1f859d4Smrg#define __DRI_READ_DRAWABLE_VERSION 1 1337117f1b4Smrg 1347117f1b4Smrg/** 135c1f859d4Smrg * Used by drivers that implement the GLX_MESA_copy_sub_buffer extension. 1367117f1b4Smrg */ 137c1f859d4Smrg#define __DRI_COPY_SUB_BUFFER "DRI_CopySubBuffer" 138c1f859d4Smrg#define __DRI_COPY_SUB_BUFFER_VERSION 1 139c1f859d4Smrgstruct __DRIcopySubBufferExtensionRec { 140c1f859d4Smrg __DRIextension base; 141c1f859d4Smrg void (*copySubBuffer)(__DRIdrawable *drawable, int x, int y, int w, int h); 142c1f859d4Smrg}; 1437117f1b4Smrg 1447117f1b4Smrg/** 145c1f859d4Smrg * Used by drivers that implement the GLX_SGI_swap_control or 146c1f859d4Smrg * GLX_MESA_swap_control extension. 1477117f1b4Smrg */ 148c1f859d4Smrg#define __DRI_SWAP_CONTROL "DRI_SwapControl" 149c1f859d4Smrg#define __DRI_SWAP_CONTROL_VERSION 1 150c1f859d4Smrgstruct __DRIswapControlExtensionRec { 151c1f859d4Smrg __DRIextension base; 152c1f859d4Smrg void (*setSwapInterval)(__DRIdrawable *drawable, unsigned int inteval); 153c1f859d4Smrg unsigned int (*getSwapInterval)(__DRIdrawable *drawable); 154c1f859d4Smrg}; 1557117f1b4Smrg 156c1f859d4Smrg/** 157c1f859d4Smrg * Used by drivers that implement the GLX_SGI_video_sync extension. 158c1f859d4Smrg */ 159c1f859d4Smrg#define __DRI_MEDIA_STREAM_COUNTER "DRI_MediaStreamCounter" 160c1f859d4Smrg#define __DRI_MEDIA_STREAM_COUNTER_VERSION 1 161c1f859d4Smrgstruct __DRImediaStreamCounterExtensionRec { 162c1f859d4Smrg __DRIextension base; 1637117f1b4Smrg 1647117f1b4Smrg /** 165c1f859d4Smrg * Wait for the MSC to equal target_msc, or, if that has already passed, 166c1f859d4Smrg * the next time (MSC % divisor) is equal to remainder. If divisor is 167c1f859d4Smrg * zero, the function will return as soon as MSC is greater than or equal 168c1f859d4Smrg * to target_msc. 1697117f1b4Smrg */ 170c1f859d4Smrg int (*waitForMSC)(__DRIdrawable *drawable, 171c1f859d4Smrg int64_t target_msc, int64_t divisor, int64_t remainder, 172c1f859d4Smrg int64_t * msc, int64_t * sbc); 1737117f1b4Smrg 1747117f1b4Smrg /** 175c1f859d4Smrg * Get the number of vertical refreshes since some point in time before 176c1f859d4Smrg * this function was first called (i.e., system start up). 1777117f1b4Smrg */ 178c1f859d4Smrg int (*getDrawableMSC)(__DRIscreen *screen, __DRIdrawable *drawable, 179c1f859d4Smrg int64_t *msc); 180c1f859d4Smrg}; 1817117f1b4Smrg 182cdc920a0Smrg/* Valid values for format in the setTexBuffer2 function below. These 183cdc920a0Smrg * values match the GLX tokens for compatibility reasons, but we 184cdc920a0Smrg * define them here since the DRI interface can't depend on GLX. */ 185cdc920a0Smrg#define __DRI_TEXTURE_FORMAT_NONE 0x20D8 186cdc920a0Smrg#define __DRI_TEXTURE_FORMAT_RGB 0x20D9 187cdc920a0Smrg#define __DRI_TEXTURE_FORMAT_RGBA 0x20DA 188cdc920a0Smrg 189c1f859d4Smrg#define __DRI_TEX_BUFFER "DRI_TexBuffer" 190af69d88dSmrg#define __DRI_TEX_BUFFER_VERSION 3 191c1f859d4Smrgstruct __DRItexBufferExtensionRec { 192c1f859d4Smrg __DRIextension base; 1937117f1b4Smrg 1947117f1b4Smrg /** 195c1f859d4Smrg * Method to override base texture image with the contents of a 196c1f859d4Smrg * __DRIdrawable. 197c1f859d4Smrg * 1984a49301eSmrg * For GLX_EXT_texture_from_pixmap with AIGLX. Deprecated in favor of 1994a49301eSmrg * setTexBuffer2 in version 2 of this interface 2007117f1b4Smrg */ 201c1f859d4Smrg void (*setTexBuffer)(__DRIcontext *pDRICtx, 2021463c08dSmrg int target, 203c1f859d4Smrg __DRIdrawable *pDraw); 2044a49301eSmrg 2054a49301eSmrg /** 2064a49301eSmrg * Method to override base texture image with the contents of a 2074a49301eSmrg * __DRIdrawable, including the required texture format attribute. 2084a49301eSmrg * 2094a49301eSmrg * For GLX_EXT_texture_from_pixmap with AIGLX. 210af69d88dSmrg * 211af69d88dSmrg * \since 2 2124a49301eSmrg */ 2134a49301eSmrg void (*setTexBuffer2)(__DRIcontext *pDRICtx, 2141463c08dSmrg int target, 2151463c08dSmrg int format, 2164a49301eSmrg __DRIdrawable *pDraw); 2173464ebd5Sriastradh /** 2183464ebd5Sriastradh * Method to release texture buffer in case some special platform 2193464ebd5Sriastradh * need this. 2203464ebd5Sriastradh * 2213464ebd5Sriastradh * For GLX_EXT_texture_from_pixmap with AIGLX. 222af69d88dSmrg * 223af69d88dSmrg * \since 3 2243464ebd5Sriastradh */ 2253464ebd5Sriastradh void (*releaseTexBuffer)(__DRIcontext *pDRICtx, 2261463c08dSmrg int target, 2273464ebd5Sriastradh __DRIdrawable *pDraw); 2284a49301eSmrg}; 2294a49301eSmrg 2304a49301eSmrg/** 2314a49301eSmrg * Used by drivers that implement DRI2 2324a49301eSmrg */ 2334a49301eSmrg#define __DRI2_FLUSH "DRI2_Flush" 234af69d88dSmrg#define __DRI2_FLUSH_VERSION 4 235af69d88dSmrg 236af69d88dSmrg#define __DRI2_FLUSH_DRAWABLE (1 << 0) /* the drawable should be flushed. */ 237af69d88dSmrg#define __DRI2_FLUSH_CONTEXT (1 << 1) /* glFlush should be called */ 23801e04c3fSmrg#define __DRI2_FLUSH_INVALIDATE_ANCILLARY (1 << 2) 239af69d88dSmrg 240af69d88dSmrgenum __DRI2throttleReason { 241af69d88dSmrg __DRI2_THROTTLE_SWAPBUFFER, 242af69d88dSmrg __DRI2_THROTTLE_COPYSUBBUFFER, 243af69d88dSmrg __DRI2_THROTTLE_FLUSHFRONT 244af69d88dSmrg}; 245af69d88dSmrg 2464a49301eSmrgstruct __DRI2flushExtensionRec { 2474a49301eSmrg __DRIextension base; 2484a49301eSmrg void (*flush)(__DRIdrawable *drawable); 249cdc920a0Smrg 250cdc920a0Smrg /** 251cdc920a0Smrg * Ask the driver to call getBuffers/getBuffersWithFormat before 252cdc920a0Smrg * it starts rendering again. 253cdc920a0Smrg * 254cdc920a0Smrg * \param drawable the drawable to invalidate 255cdc920a0Smrg * 256cdc920a0Smrg * \since 3 257cdc920a0Smrg */ 258cdc920a0Smrg void (*invalidate)(__DRIdrawable *drawable); 259af69d88dSmrg 260af69d88dSmrg /** 261af69d88dSmrg * This function reduces the number of flushes in the driver by combining 262af69d88dSmrg * several operations into one call. 263af69d88dSmrg * 264af69d88dSmrg * It can: 265af69d88dSmrg * - throttle 266af69d88dSmrg * - flush a drawable 267af69d88dSmrg * - flush a context 268af69d88dSmrg * 269af69d88dSmrg * \param context the context 270af69d88dSmrg * \param drawable the drawable to flush 271af69d88dSmrg * \param flags a combination of _DRI2_FLUSH_xxx flags 272af69d88dSmrg * \param throttle_reason the reason for throttling, 0 = no throttling 273af69d88dSmrg * 274af69d88dSmrg * \since 4 275af69d88dSmrg */ 276af69d88dSmrg void (*flush_with_flags)(__DRIcontext *ctx, 277af69d88dSmrg __DRIdrawable *drawable, 278af69d88dSmrg unsigned flags, 279af69d88dSmrg enum __DRI2throttleReason throttle_reason); 280c1f859d4Smrg}; 2817117f1b4Smrg 282c1f859d4Smrg 283c1f859d4Smrg/** 284af69d88dSmrg * Extension that the driver uses to request 285af69d88dSmrg * throttle callbacks. 286c1f859d4Smrg */ 287af69d88dSmrg 288af69d88dSmrg#define __DRI2_THROTTLE "DRI2_Throttle" 289af69d88dSmrg#define __DRI2_THROTTLE_VERSION 1 290af69d88dSmrg 291af69d88dSmrgstruct __DRI2throttleExtensionRec { 292af69d88dSmrg __DRIextension base; 293af69d88dSmrg void (*throttle)(__DRIcontext *ctx, 294af69d88dSmrg __DRIdrawable *drawable, 295af69d88dSmrg enum __DRI2throttleReason reason); 296af69d88dSmrg}; 297c1f859d4Smrg 29801e04c3fSmrg/** 29901e04c3fSmrg * Extension for EGL_ANDROID_blob_cache 30001e04c3fSmrg */ 30101e04c3fSmrg 30201e04c3fSmrg#define __DRI2_BLOB "DRI2_Blob" 30301e04c3fSmrg#define __DRI2_BLOB_VERSION 1 30401e04c3fSmrg 30501e04c3fSmrgtypedef void 30601e04c3fSmrg(*__DRIblobCacheSet) (const void *key, signed long keySize, 30701e04c3fSmrg const void *value, signed long valueSize); 30801e04c3fSmrg 30901e04c3fSmrgtypedef signed long 31001e04c3fSmrg(*__DRIblobCacheGet) (const void *key, signed long keySize, 31101e04c3fSmrg void *value, signed long valueSize); 31201e04c3fSmrg 31301e04c3fSmrgstruct __DRI2blobExtensionRec { 31401e04c3fSmrg __DRIextension base; 31501e04c3fSmrg 31601e04c3fSmrg /** 31701e04c3fSmrg * Set cache functions for setting and getting cache entries. 31801e04c3fSmrg */ 31901e04c3fSmrg void (*set_cache_funcs) (__DRIscreen *screen, 32001e04c3fSmrg __DRIblobCacheSet set, __DRIblobCacheGet get); 32101e04c3fSmrg}; 32201e04c3fSmrg 32301e04c3fSmrg/** 32401e04c3fSmrg * Extension for fences / synchronization objects. 32501e04c3fSmrg */ 32601e04c3fSmrg 32701e04c3fSmrg#define __DRI2_FENCE "DRI2_Fence" 32801e04c3fSmrg#define __DRI2_FENCE_VERSION 2 32901e04c3fSmrg 33001e04c3fSmrg#define __DRI2_FENCE_TIMEOUT_INFINITE 0xffffffffffffffffull 33101e04c3fSmrg 33201e04c3fSmrg#define __DRI2_FENCE_FLAG_FLUSH_COMMANDS (1 << 0) 33301e04c3fSmrg 33401e04c3fSmrg/** 33501e04c3fSmrg * \name Capabilities that might be returned by __DRI2fenceExtensionRec::get_capabilities 33601e04c3fSmrg */ 33701e04c3fSmrg/*@{*/ 33801e04c3fSmrg#define __DRI_FENCE_CAP_NATIVE_FD 1 33901e04c3fSmrg/*@}*/ 34001e04c3fSmrg 34101e04c3fSmrgstruct __DRI2fenceExtensionRec { 34201e04c3fSmrg __DRIextension base; 34301e04c3fSmrg 34401e04c3fSmrg /** 34501e04c3fSmrg * Create and insert a fence into the command stream of the context. 34601e04c3fSmrg */ 34701e04c3fSmrg void *(*create_fence)(__DRIcontext *ctx); 34801e04c3fSmrg 34901e04c3fSmrg /** 35001e04c3fSmrg * Get a fence associated with the OpenCL event object. 35101e04c3fSmrg * This can be NULL, meaning that OpenCL interoperability is not supported. 35201e04c3fSmrg */ 35301e04c3fSmrg void *(*get_fence_from_cl_event)(__DRIscreen *screen, intptr_t cl_event); 35401e04c3fSmrg 35501e04c3fSmrg /** 35601e04c3fSmrg * Destroy a fence. 35701e04c3fSmrg */ 35801e04c3fSmrg void (*destroy_fence)(__DRIscreen *screen, void *fence); 35901e04c3fSmrg 36001e04c3fSmrg /** 36101e04c3fSmrg * This function waits and doesn't return until the fence is signalled 36201e04c3fSmrg * or the timeout expires. It returns true if the fence has been signaled. 36301e04c3fSmrg * 36401e04c3fSmrg * \param ctx the context where commands are flushed 36501e04c3fSmrg * \param fence the fence 36601e04c3fSmrg * \param flags a combination of __DRI2_FENCE_FLAG_xxx flags 36701e04c3fSmrg * \param timeout the timeout in ns or __DRI2_FENCE_TIMEOUT_INFINITE 36801e04c3fSmrg */ 3691463c08dSmrg unsigned char (*client_wait_sync)(__DRIcontext *ctx, void *fence, 3701463c08dSmrg unsigned flags, uint64_t timeout); 37101e04c3fSmrg 37201e04c3fSmrg /** 37301e04c3fSmrg * This function enqueues a wait command into the command stream of 37401e04c3fSmrg * the context and then returns. When the execution reaches the wait 37501e04c3fSmrg * command, no further execution will be done in the context until 37601e04c3fSmrg * the fence is signaled. This is a no-op if the device doesn't support 37701e04c3fSmrg * parallel execution of contexts. 37801e04c3fSmrg * 37901e04c3fSmrg * \param ctx the context where the waiting is done 38001e04c3fSmrg * \param fence the fence 38101e04c3fSmrg * \param flags a combination of __DRI2_FENCE_FLAG_xxx flags that make 38201e04c3fSmrg * sense with this function (right now there are none) 38301e04c3fSmrg */ 38401e04c3fSmrg void (*server_wait_sync)(__DRIcontext *ctx, void *fence, unsigned flags); 38501e04c3fSmrg 38601e04c3fSmrg /** 38701e04c3fSmrg * Query for general capabilities of the driver that concern fences. 38801e04c3fSmrg * Returns a bitmask of __DRI_FENCE_CAP_x 38901e04c3fSmrg * 39001e04c3fSmrg * \since 2 39101e04c3fSmrg */ 39201e04c3fSmrg unsigned (*get_capabilities)(__DRIscreen *screen); 39301e04c3fSmrg 39401e04c3fSmrg /** 39501e04c3fSmrg * Create an fd (file descriptor) associated fence. If the fence fd 39601e04c3fSmrg * is -1, this behaves similarly to create_fence() except that when 39701e04c3fSmrg * rendering is flushed the driver creates a fence fd. Otherwise, 39801e04c3fSmrg * the driver wraps an existing fence fd. 39901e04c3fSmrg * 40001e04c3fSmrg * This is used to implement the EGL_ANDROID_native_fence_sync extension. 40101e04c3fSmrg * 40201e04c3fSmrg * \since 2 40301e04c3fSmrg * 40401e04c3fSmrg * \param ctx the context associated with the fence 40501e04c3fSmrg * \param fd the fence fd or -1 40601e04c3fSmrg */ 40701e04c3fSmrg void *(*create_fence_fd)(__DRIcontext *ctx, int fd); 40801e04c3fSmrg 40901e04c3fSmrg /** 41001e04c3fSmrg * For fences created with create_fence_fd(), after rendering is flushed, 41101e04c3fSmrg * this retrieves the native fence fd. Caller takes ownership of the 41201e04c3fSmrg * fd and will close() it when it is no longer needed. 41301e04c3fSmrg * 41401e04c3fSmrg * \since 2 41501e04c3fSmrg * 41601e04c3fSmrg * \param screen the screen associated with the fence 41701e04c3fSmrg * \param fence the fence 41801e04c3fSmrg */ 41901e04c3fSmrg int (*get_fence_fd)(__DRIscreen *screen, void *fence); 42001e04c3fSmrg}; 42101e04c3fSmrg 42201e04c3fSmrg 42301e04c3fSmrg/** 42401e04c3fSmrg * Extension for API interop. 42501e04c3fSmrg * See GL/mesa_glinterop.h. 42601e04c3fSmrg */ 42701e04c3fSmrg 42801e04c3fSmrg#define __DRI2_INTEROP "DRI2_Interop" 42901e04c3fSmrg#define __DRI2_INTEROP_VERSION 1 43001e04c3fSmrg 43101e04c3fSmrgstruct mesa_glinterop_device_info; 43201e04c3fSmrgstruct mesa_glinterop_export_in; 43301e04c3fSmrgstruct mesa_glinterop_export_out; 43401e04c3fSmrg 43501e04c3fSmrgstruct __DRI2interopExtensionRec { 43601e04c3fSmrg __DRIextension base; 43701e04c3fSmrg 43801e04c3fSmrg /** Same as MesaGLInterop*QueryDeviceInfo. */ 43901e04c3fSmrg int (*query_device_info)(__DRIcontext *ctx, 44001e04c3fSmrg struct mesa_glinterop_device_info *out); 44101e04c3fSmrg 44201e04c3fSmrg /** Same as MesaGLInterop*ExportObject. */ 44301e04c3fSmrg int (*export_object)(__DRIcontext *ctx, 44401e04c3fSmrg struct mesa_glinterop_export_in *in, 44501e04c3fSmrg struct mesa_glinterop_export_out *out); 44601e04c3fSmrg}; 44701e04c3fSmrg 4481463c08dSmrg 4491463c08dSmrg/** 4501463c08dSmrg * Extension for limiting window system back buffer rendering to user-defined 4511463c08dSmrg * scissor region. 4521463c08dSmrg */ 4531463c08dSmrg 4541463c08dSmrg#define __DRI2_BUFFER_DAMAGE "DRI2_BufferDamage" 4551463c08dSmrg#define __DRI2_BUFFER_DAMAGE_VERSION 1 4561463c08dSmrg 4571463c08dSmrgstruct __DRI2bufferDamageExtensionRec { 4581463c08dSmrg __DRIextension base; 4591463c08dSmrg 4601463c08dSmrg /** 4611463c08dSmrg * Provides an array of rectangles representing an overriding scissor region 4621463c08dSmrg * for rendering operations performed to the specified drawable. These 4631463c08dSmrg * rectangles do not replace client API scissor regions or draw 4641463c08dSmrg * co-ordinates, but instead inform the driver of the overall bounds of all 4651463c08dSmrg * operations which will be issued before the next flush. 4661463c08dSmrg * 4671463c08dSmrg * Any rendering operations writing pixels outside this region to the 4681463c08dSmrg * drawable will have an undefined effect on the entire drawable. 4691463c08dSmrg * 4701463c08dSmrg * This entrypoint may only be called after the drawable has either been 4711463c08dSmrg * newly created or flushed, and before any rendering operations which write 4721463c08dSmrg * pixels to the drawable. Calling this entrypoint at any other time will 4731463c08dSmrg * have an undefined effect on the entire drawable. 4741463c08dSmrg * 4751463c08dSmrg * Calling this entrypoint with @nrects 0 and @rects NULL will reset the 4761463c08dSmrg * region to the buffer's full size. This entrypoint may be called once to 4771463c08dSmrg * reset the region, followed by a second call with a populated region, 4781463c08dSmrg * before a rendering call is made. 4791463c08dSmrg * 4801463c08dSmrg * Used to implement EGL_KHR_partial_update. 4811463c08dSmrg * 4821463c08dSmrg * \param drawable affected drawable 4831463c08dSmrg * \param nrects number of rectangles provided 4841463c08dSmrg * \param rects the array of rectangles, lower-left origin 4851463c08dSmrg */ 4861463c08dSmrg void (*set_damage_region)(__DRIdrawable *drawable, unsigned int nrects, 4871463c08dSmrg int *rects); 4881463c08dSmrg}; 4891463c08dSmrg 490c1f859d4Smrg/*@}*/ 491c1f859d4Smrg 492c1f859d4Smrg/** 493c1f859d4Smrg * The following extensions describe loader features that the DRI 494c1f859d4Smrg * driver can make use of. Some of these are mandatory, such as the 495c1f859d4Smrg * getDrawableInfo extension for DRI and the DRI Loader extensions for 496c1f859d4Smrg * DRI2, while others are optional, and if present allow the driver to 497c1f859d4Smrg * expose certain features. The loader pass in a NULL terminated 498c1f859d4Smrg * array of these extensions to the driver in the createNewScreen 499c1f859d4Smrg * constructor. 500c1f859d4Smrg */ 501c1f859d4Smrg 502c1f859d4Smrgtypedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension; 503c1f859d4Smrgtypedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension; 504c1f859d4Smrgtypedef struct __DRIdamageExtensionRec __DRIdamageExtension; 505c1f859d4Smrgtypedef struct __DRIloaderExtensionRec __DRIloaderExtension; 506c1f859d4Smrgtypedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension; 507c1f859d4Smrg 508c1f859d4Smrg/** 509c1f859d4Smrg * Callback to get system time for media stream counter extensions. 510c1f859d4Smrg */ 511c1f859d4Smrg#define __DRI_SYSTEM_TIME "DRI_SystemTime" 512c1f859d4Smrg#define __DRI_SYSTEM_TIME_VERSION 1 513c1f859d4Smrgstruct __DRIsystemTimeExtensionRec { 514c1f859d4Smrg __DRIextension base; 5157117f1b4Smrg 5167117f1b4Smrg /** 5177117f1b4Smrg * Get the 64-bit unadjusted system time (UST). 5187117f1b4Smrg */ 5197117f1b4Smrg int (*getUST)(int64_t * ust); 5207117f1b4Smrg 5217117f1b4Smrg /** 5227117f1b4Smrg * Get the media stream counter (MSC) rate. 5237117f1b4Smrg * 5247117f1b4Smrg * Matching the definition in GLX_OML_sync_control, this function returns 5257117f1b4Smrg * the rate of the "media stream counter". In practical terms, this is 5267117f1b4Smrg * the frame refresh rate of the display. 5277117f1b4Smrg */ 5281463c08dSmrg unsigned char (*getMSCRate)(__DRIdrawable *draw, 529c1f859d4Smrg int32_t * numerator, int32_t * denominator, 530c1f859d4Smrg void *loaderPrivate); 531c1f859d4Smrg}; 532c1f859d4Smrg 533c1f859d4Smrg/** 534c1f859d4Smrg * Damage reporting 535c1f859d4Smrg */ 536c1f859d4Smrg#define __DRI_DAMAGE "DRI_Damage" 537c1f859d4Smrg#define __DRI_DAMAGE_VERSION 1 538c1f859d4Smrgstruct __DRIdamageExtensionRec { 539c1f859d4Smrg __DRIextension base; 5407117f1b4Smrg 5417117f1b4Smrg /** 5427117f1b4Smrg * Reports areas of the given drawable which have been modified by the 5437117f1b4Smrg * driver. 5447117f1b4Smrg * 5457117f1b4Smrg * \param drawable which the drawing was done to. 5467117f1b4Smrg * \param rects rectangles affected, with the drawable origin as the 5477117f1b4Smrg * origin. 5487117f1b4Smrg * \param x X offset of the drawable within the screen (used in the 5497117f1b4Smrg * front_buffer case) 5507117f1b4Smrg * \param y Y offset of the drawable within the screen. 5517117f1b4Smrg * \param front_buffer boolean flag for whether the drawing to the 5527117f1b4Smrg * drawable was actually done directly to the front buffer (instead 5537117f1b4Smrg * of backing storage, for example) 554c1f859d4Smrg * \param loaderPrivate the data passed in at createNewDrawable time 5557117f1b4Smrg */ 556c1f859d4Smrg void (*reportDamage)(__DRIdrawable *draw, 5577117f1b4Smrg int x, int y, 5587117f1b4Smrg drm_clip_rect_t *rects, int num_rects, 5591463c08dSmrg unsigned char front_buffer, 560c1f859d4Smrg void *loaderPrivate); 561c1f859d4Smrg}; 562c1f859d4Smrg 563c1f859d4Smrg#define __DRI_SWRAST_IMAGE_OP_DRAW 1 564c1f859d4Smrg#define __DRI_SWRAST_IMAGE_OP_CLEAR 2 565c1f859d4Smrg#define __DRI_SWRAST_IMAGE_OP_SWAP 3 566c1f859d4Smrg 567c1f859d4Smrg/** 568c1f859d4Smrg * SWRast Loader extension. 569c1f859d4Smrg */ 570c1f859d4Smrg#define __DRI_SWRAST_LOADER "DRI_SWRastLoader" 5711463c08dSmrg#define __DRI_SWRAST_LOADER_VERSION 6 572c1f859d4Smrgstruct __DRIswrastLoaderExtensionRec { 573c1f859d4Smrg __DRIextension base; 574c1f859d4Smrg 575c1f859d4Smrg /* 576c1f859d4Smrg * Drawable position and size 577c1f859d4Smrg */ 578c1f859d4Smrg void (*getDrawableInfo)(__DRIdrawable *drawable, 579c1f859d4Smrg int *x, int *y, int *width, int *height, 580c1f859d4Smrg void *loaderPrivate); 581c1f859d4Smrg 582c1f859d4Smrg /** 583c1f859d4Smrg * Put image to drawable 584c1f859d4Smrg */ 585c1f859d4Smrg void (*putImage)(__DRIdrawable *drawable, int op, 5863464ebd5Sriastradh int x, int y, int width, int height, 5873464ebd5Sriastradh char *data, void *loaderPrivate); 588c1f859d4Smrg 589c1f859d4Smrg /** 5903464ebd5Sriastradh * Get image from readable 591c1f859d4Smrg */ 5923464ebd5Sriastradh void (*getImage)(__DRIdrawable *readable, 5933464ebd5Sriastradh int x, int y, int width, int height, 5943464ebd5Sriastradh char *data, void *loaderPrivate); 595af69d88dSmrg 596af69d88dSmrg /** 597af69d88dSmrg * Put image to drawable 598af69d88dSmrg * 599af69d88dSmrg * \since 2 600af69d88dSmrg */ 601af69d88dSmrg void (*putImage2)(__DRIdrawable *drawable, int op, 602af69d88dSmrg int x, int y, int width, int height, int stride, 603af69d88dSmrg char *data, void *loaderPrivate); 60401e04c3fSmrg 60501e04c3fSmrg /** 60601e04c3fSmrg * Put image to drawable 60701e04c3fSmrg * 60801e04c3fSmrg * \since 3 60901e04c3fSmrg */ 61001e04c3fSmrg void (*getImage2)(__DRIdrawable *readable, 61101e04c3fSmrg int x, int y, int width, int height, int stride, 61201e04c3fSmrg char *data, void *loaderPrivate); 61301e04c3fSmrg 61401e04c3fSmrg /** 61501e04c3fSmrg * Put shm image to drawable 61601e04c3fSmrg * 61701e04c3fSmrg * \since 4 61801e04c3fSmrg */ 61901e04c3fSmrg void (*putImageShm)(__DRIdrawable *drawable, int op, 62001e04c3fSmrg int x, int y, int width, int height, int stride, 62101e04c3fSmrg int shmid, char *shmaddr, unsigned offset, 62201e04c3fSmrg void *loaderPrivate); 62301e04c3fSmrg /** 62401e04c3fSmrg * Get shm image from readable 62501e04c3fSmrg * 62601e04c3fSmrg * \since 4 62701e04c3fSmrg */ 62801e04c3fSmrg void (*getImageShm)(__DRIdrawable *readable, 62901e04c3fSmrg int x, int y, int width, int height, 63001e04c3fSmrg int shmid, void *loaderPrivate); 63101e04c3fSmrg 63201e04c3fSmrg /** 63301e04c3fSmrg * Put shm image to drawable (v2) 63401e04c3fSmrg * 63501e04c3fSmrg * The original version fixes srcx/y to 0, and expected 63601e04c3fSmrg * the offset to be adjusted. This version allows src x,y 63701e04c3fSmrg * to not be included in the offset. This is needed to 63801e04c3fSmrg * avoid certain overflow checks in the X server, that 63901e04c3fSmrg * result in lost rendering. 64001e04c3fSmrg * 64101e04c3fSmrg * \since 5 64201e04c3fSmrg */ 64301e04c3fSmrg void (*putImageShm2)(__DRIdrawable *drawable, int op, 64401e04c3fSmrg int x, int y, 64501e04c3fSmrg int width, int height, int stride, 64601e04c3fSmrg int shmid, char *shmaddr, unsigned offset, 64701e04c3fSmrg void *loaderPrivate); 6481463c08dSmrg 6491463c08dSmrg /** 6501463c08dSmrg * get shm image to drawable (v2) 6511463c08dSmrg * 6521463c08dSmrg * There are some cases where GLX can't use SHM, but DRI 6531463c08dSmrg * still tries, we need to get a return type for when to 6541463c08dSmrg * fallback to the non-shm path. 6551463c08dSmrg * 6561463c08dSmrg * \since 6 6571463c08dSmrg */ 6581463c08dSmrg unsigned char (*getImageShm2)(__DRIdrawable *readable, 6591463c08dSmrg int x, int y, int width, int height, 6601463c08dSmrg int shmid, void *loaderPrivate); 6613464ebd5Sriastradh}; 6623464ebd5Sriastradh 6633464ebd5Sriastradh/** 6643464ebd5Sriastradh * Invalidate loader extension. The presence of this extension 6653464ebd5Sriastradh * indicates to the DRI driver that the loader will call invalidate in 6663464ebd5Sriastradh * the __DRI2_FLUSH extension, whenever the needs to query for new 6673464ebd5Sriastradh * buffers. This means that the DRI driver can drop the polling in 6683464ebd5Sriastradh * glViewport(). 6693464ebd5Sriastradh * 6703464ebd5Sriastradh * The extension doesn't provide any functionality, it's only use to 6713464ebd5Sriastradh * indicate to the driver that it can use the new semantics. A DRI 6723464ebd5Sriastradh * driver can use this to switch between the different semantics or 6733464ebd5Sriastradh * just refuse to initialize if this extension isn't present. 6743464ebd5Sriastradh */ 6753464ebd5Sriastradh#define __DRI_USE_INVALIDATE "DRI_UseInvalidate" 6763464ebd5Sriastradh#define __DRI_USE_INVALIDATE_VERSION 1 6773464ebd5Sriastradh 6783464ebd5Sriastradhtypedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension; 6793464ebd5Sriastradhstruct __DRIuseInvalidateExtensionRec { 6803464ebd5Sriastradh __DRIextension base; 681c1f859d4Smrg}; 682c1f859d4Smrg 683c1f859d4Smrg/** 684c1f859d4Smrg * The remaining extensions describe driver extensions, immediately 685c1f859d4Smrg * available interfaces provided by the driver. To start using the 686c1f859d4Smrg * driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for 687c1f859d4Smrg * the extension you need in the array. 688c1f859d4Smrg */ 689c1f859d4Smrg#define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions" 690c1f859d4Smrg 691af69d88dSmrg/** 692af69d88dSmrg * This symbol replaces the __DRI_DRIVER_EXTENSIONS symbol, and will be 693af69d88dSmrg * suffixed by "_drivername", allowing multiple drivers to be built into one 694af69d88dSmrg * library, and also giving the driver the chance to return a variable driver 695af69d88dSmrg * extensions struct depending on the driver name being loaded or any other 696af69d88dSmrg * system state. 697af69d88dSmrg * 698af69d88dSmrg * The function prototype is: 699af69d88dSmrg * 700af69d88dSmrg * const __DRIextension **__driDriverGetExtensions_drivername(void); 701af69d88dSmrg */ 702af69d88dSmrg#define __DRI_DRIVER_GET_EXTENSIONS "__driDriverGetExtensions" 703af69d88dSmrg 704c1f859d4Smrg/** 705c1f859d4Smrg * Tokens for __DRIconfig attribs. A number of attributes defined by 706c1f859d4Smrg * GLX or EGL standards are not in the table, as they must be provided 707c1f859d4Smrg * by the loader. For example, FBConfig ID or visual ID, drawable type. 708c1f859d4Smrg */ 709c1f859d4Smrg 710c1f859d4Smrg#define __DRI_ATTRIB_BUFFER_SIZE 1 711c1f859d4Smrg#define __DRI_ATTRIB_LEVEL 2 712c1f859d4Smrg#define __DRI_ATTRIB_RED_SIZE 3 713c1f859d4Smrg#define __DRI_ATTRIB_GREEN_SIZE 4 714c1f859d4Smrg#define __DRI_ATTRIB_BLUE_SIZE 5 715c1f859d4Smrg#define __DRI_ATTRIB_LUMINANCE_SIZE 6 716c1f859d4Smrg#define __DRI_ATTRIB_ALPHA_SIZE 7 717c1f859d4Smrg#define __DRI_ATTRIB_ALPHA_MASK_SIZE 8 718c1f859d4Smrg#define __DRI_ATTRIB_DEPTH_SIZE 9 719c1f859d4Smrg#define __DRI_ATTRIB_STENCIL_SIZE 10 720c1f859d4Smrg#define __DRI_ATTRIB_ACCUM_RED_SIZE 11 721c1f859d4Smrg#define __DRI_ATTRIB_ACCUM_GREEN_SIZE 12 722c1f859d4Smrg#define __DRI_ATTRIB_ACCUM_BLUE_SIZE 13 723c1f859d4Smrg#define __DRI_ATTRIB_ACCUM_ALPHA_SIZE 14 724c1f859d4Smrg#define __DRI_ATTRIB_SAMPLE_BUFFERS 15 725c1f859d4Smrg#define __DRI_ATTRIB_SAMPLES 16 726c1f859d4Smrg#define __DRI_ATTRIB_RENDER_TYPE 17 727c1f859d4Smrg#define __DRI_ATTRIB_CONFIG_CAVEAT 18 728c1f859d4Smrg#define __DRI_ATTRIB_CONFORMANT 19 729c1f859d4Smrg#define __DRI_ATTRIB_DOUBLE_BUFFER 20 730c1f859d4Smrg#define __DRI_ATTRIB_STEREO 21 731c1f859d4Smrg#define __DRI_ATTRIB_AUX_BUFFERS 22 732c1f859d4Smrg#define __DRI_ATTRIB_TRANSPARENT_TYPE 23 733c1f859d4Smrg#define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE 24 734c1f859d4Smrg#define __DRI_ATTRIB_TRANSPARENT_RED_VALUE 25 735c1f859d4Smrg#define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE 26 736c1f859d4Smrg#define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE 27 737c1f859d4Smrg#define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE 28 738c1f859d4Smrg#define __DRI_ATTRIB_FLOAT_MODE 29 739c1f859d4Smrg#define __DRI_ATTRIB_RED_MASK 30 740c1f859d4Smrg#define __DRI_ATTRIB_GREEN_MASK 31 741c1f859d4Smrg#define __DRI_ATTRIB_BLUE_MASK 32 742c1f859d4Smrg#define __DRI_ATTRIB_ALPHA_MASK 33 743c1f859d4Smrg#define __DRI_ATTRIB_MAX_PBUFFER_WIDTH 34 744c1f859d4Smrg#define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT 35 745c1f859d4Smrg#define __DRI_ATTRIB_MAX_PBUFFER_PIXELS 36 746c1f859d4Smrg#define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH 37 747c1f859d4Smrg#define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT 38 748c1f859d4Smrg#define __DRI_ATTRIB_VISUAL_SELECT_GROUP 39 749c1f859d4Smrg#define __DRI_ATTRIB_SWAP_METHOD 40 750c1f859d4Smrg#define __DRI_ATTRIB_MAX_SWAP_INTERVAL 41 751c1f859d4Smrg#define __DRI_ATTRIB_MIN_SWAP_INTERVAL 42 752c1f859d4Smrg#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB 43 753c1f859d4Smrg#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA 44 754c1f859d4Smrg#define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE 45 755c1f859d4Smrg#define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS 46 756c1f859d4Smrg#define __DRI_ATTRIB_YINVERTED 47 7573464ebd5Sriastradh#define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE 48 75801e04c3fSmrg#define __DRI_ATTRIB_MUTABLE_RENDER_BUFFER 49 /* EGL_MUTABLE_RENDER_BUFFER_BIT_KHR */ 7591463c08dSmrg#define __DRI_ATTRIB_RED_SHIFT 50 7601463c08dSmrg#define __DRI_ATTRIB_GREEN_SHIFT 51 7611463c08dSmrg#define __DRI_ATTRIB_BLUE_SHIFT 52 7621463c08dSmrg#define __DRI_ATTRIB_ALPHA_SHIFT 53 7631463c08dSmrg#define __DRI_ATTRIB_MAX 54 764c1f859d4Smrg 765c1f859d4Smrg/* __DRI_ATTRIB_RENDER_TYPE */ 766c1f859d4Smrg#define __DRI_ATTRIB_RGBA_BIT 0x01 767c1f859d4Smrg#define __DRI_ATTRIB_COLOR_INDEX_BIT 0x02 768c1f859d4Smrg#define __DRI_ATTRIB_LUMINANCE_BIT 0x04 769af69d88dSmrg#define __DRI_ATTRIB_FLOAT_BIT 0x08 770af69d88dSmrg#define __DRI_ATTRIB_UNSIGNED_FLOAT_BIT 0x10 771c1f859d4Smrg 772c1f859d4Smrg/* __DRI_ATTRIB_CONFIG_CAVEAT */ 773c1f859d4Smrg#define __DRI_ATTRIB_SLOW_BIT 0x01 774c1f859d4Smrg#define __DRI_ATTRIB_NON_CONFORMANT_CONFIG 0x02 775c1f859d4Smrg 776c1f859d4Smrg/* __DRI_ATTRIB_TRANSPARENT_TYPE */ 777c1f859d4Smrg#define __DRI_ATTRIB_TRANSPARENT_RGB 0x00 778c1f859d4Smrg#define __DRI_ATTRIB_TRANSPARENT_INDEX 0x01 779c1f859d4Smrg 780c1f859d4Smrg/* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */ 781c1f859d4Smrg#define __DRI_ATTRIB_TEXTURE_1D_BIT 0x01 782c1f859d4Smrg#define __DRI_ATTRIB_TEXTURE_2D_BIT 0x02 783c1f859d4Smrg#define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT 0x04 784c1f859d4Smrg 78501e04c3fSmrg/* __DRI_ATTRIB_SWAP_METHOD */ 78601e04c3fSmrg/* Note that with the exception of __DRI_ATTRIB_SWAP_NONE, we need to define 78701e04c3fSmrg * the same tokens as GLX. This is because old and current X servers will 78801e04c3fSmrg * transmit the driconf value grabbed from the AIGLX driver untranslated as 78901e04c3fSmrg * the GLX fbconfig value. __DRI_ATTRIB_SWAP_NONE is only used by dri drivers 79001e04c3fSmrg * to signal to the dri core that the driconfig is single-buffer. 79101e04c3fSmrg */ 79201e04c3fSmrg#define __DRI_ATTRIB_SWAP_NONE 0x0000 79301e04c3fSmrg#define __DRI_ATTRIB_SWAP_EXCHANGE 0x8061 79401e04c3fSmrg#define __DRI_ATTRIB_SWAP_COPY 0x8062 79501e04c3fSmrg#define __DRI_ATTRIB_SWAP_UNDEFINED 0x8063 79601e04c3fSmrg 797c1f859d4Smrg/** 798c1f859d4Smrg * This extension defines the core DRI functionality. 79901e04c3fSmrg * 80001e04c3fSmrg * Version >= 2 indicates that getConfigAttrib with __DRI_ATTRIB_SWAP_METHOD 80101e04c3fSmrg * returns a reliable value. 802c1f859d4Smrg */ 803c1f859d4Smrg#define __DRI_CORE "DRI_Core" 80401e04c3fSmrg#define __DRI_CORE_VERSION 2 805c1f859d4Smrg 806c1f859d4Smrgstruct __DRIcoreExtensionRec { 807c1f859d4Smrg __DRIextension base; 808c1f859d4Smrg 809c1f859d4Smrg __DRIscreen *(*createNewScreen)(int screen, int fd, 810c1f859d4Smrg unsigned int sarea_handle, 811c1f859d4Smrg const __DRIextension **extensions, 812c1f859d4Smrg const __DRIconfig ***driverConfigs, 813c1f859d4Smrg void *loaderPrivate); 814c1f859d4Smrg 815c1f859d4Smrg void (*destroyScreen)(__DRIscreen *screen); 816c1f859d4Smrg 817c1f859d4Smrg const __DRIextension **(*getExtensions)(__DRIscreen *screen); 818c1f859d4Smrg 819c1f859d4Smrg int (*getConfigAttrib)(const __DRIconfig *config, 820c1f859d4Smrg unsigned int attrib, 821c1f859d4Smrg unsigned int *value); 822c1f859d4Smrg 823c1f859d4Smrg int (*indexConfigAttrib)(const __DRIconfig *config, int index, 824c1f859d4Smrg unsigned int *attrib, unsigned int *value); 825c1f859d4Smrg 826c1f859d4Smrg __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen, 827c1f859d4Smrg const __DRIconfig *config, 828c1f859d4Smrg unsigned int drawable_id, 829c1f859d4Smrg unsigned int head, 830c1f859d4Smrg void *loaderPrivate); 831c1f859d4Smrg 832c1f859d4Smrg void (*destroyDrawable)(__DRIdrawable *drawable); 833c1f859d4Smrg 834c1f859d4Smrg void (*swapBuffers)(__DRIdrawable *drawable); 835c1f859d4Smrg 836c1f859d4Smrg __DRIcontext *(*createNewContext)(__DRIscreen *screen, 837c1f859d4Smrg const __DRIconfig *config, 838c1f859d4Smrg __DRIcontext *shared, 839c1f859d4Smrg void *loaderPrivate); 840c1f859d4Smrg 841c1f859d4Smrg int (*copyContext)(__DRIcontext *dest, 842c1f859d4Smrg __DRIcontext *src, 843c1f859d4Smrg unsigned long mask); 844c1f859d4Smrg 845c1f859d4Smrg void (*destroyContext)(__DRIcontext *context); 846c1f859d4Smrg 847c1f859d4Smrg int (*bindContext)(__DRIcontext *ctx, 848c1f859d4Smrg __DRIdrawable *pdraw, 849c1f859d4Smrg __DRIdrawable *pread); 850c1f859d4Smrg 851c1f859d4Smrg int (*unbindContext)(__DRIcontext *ctx); 852c1f859d4Smrg}; 853c1f859d4Smrg 854c1f859d4Smrg/** 855c1f859d4Smrg * Stored version of some component (i.e., server-side DRI module, kernel-side 856c1f859d4Smrg * DRM, etc.). 857c1f859d4Smrg * 858c1f859d4Smrg * \todo 859c1f859d4Smrg * There are several data structures that explicitly store a major version, 860c1f859d4Smrg * minor version, and patch level. These structures should be modified to 861c1f859d4Smrg * have a \c __DRIversionRec instead. 862c1f859d4Smrg */ 863c1f859d4Smrgstruct __DRIversionRec { 864c1f859d4Smrg int major; /**< Major version number. */ 865c1f859d4Smrg int minor; /**< Minor version number. */ 866c1f859d4Smrg int patch; /**< Patch-level. */ 8677117f1b4Smrg}; 8687117f1b4Smrg 8697117f1b4Smrg/** 8707117f1b4Smrg * Framebuffer information record. Used by libGL to communicate information 8717117f1b4Smrg * about the framebuffer to the driver's \c __driCreateNewScreen function. 8727117f1b4Smrg * 8737117f1b4Smrg * In XFree86, most of this information is derrived from data returned by 8747117f1b4Smrg * calling \c XF86DRIGetDeviceInfo. 8757117f1b4Smrg * 8767117f1b4Smrg * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen 8777117f1b4Smrg * __driUtilCreateNewScreen CallCreateNewScreen 8787117f1b4Smrg * 8797117f1b4Smrg * \bug This structure could be better named. 8807117f1b4Smrg */ 8817117f1b4Smrgstruct __DRIframebufferRec { 8827117f1b4Smrg unsigned char *base; /**< Framebuffer base address in the CPU's 8837117f1b4Smrg * address space. This value is calculated by 8847117f1b4Smrg * calling \c drmMap on the framebuffer handle 8857117f1b4Smrg * returned by \c XF86DRIGetDeviceInfo (or a 8867117f1b4Smrg * similar function). 8877117f1b4Smrg */ 8887117f1b4Smrg int size; /**< Framebuffer size, in bytes. */ 8897117f1b4Smrg int stride; /**< Number of bytes from one line to the next. */ 8907117f1b4Smrg int width; /**< Pixel width of the framebuffer. */ 8917117f1b4Smrg int height; /**< Pixel height of the framebuffer. */ 8927117f1b4Smrg int dev_priv_size; /**< Size of the driver's dev-priv structure. */ 8937117f1b4Smrg void *dev_priv; /**< Pointer to the driver's dev-priv structure. */ 8947117f1b4Smrg}; 8957117f1b4Smrg 8967117f1b4Smrg 8977117f1b4Smrg/** 898c1f859d4Smrg * This extension provides alternative screen, drawable and context 899c1f859d4Smrg * constructors for legacy DRI functionality. This is used in 900c1f859d4Smrg * conjunction with the core extension. 9017117f1b4Smrg */ 902c1f859d4Smrg#define __DRI_LEGACY "DRI_Legacy" 903c1f859d4Smrg#define __DRI_LEGACY_VERSION 1 904c1f859d4Smrg 905c1f859d4Smrgstruct __DRIlegacyExtensionRec { 906c1f859d4Smrg __DRIextension base; 907c1f859d4Smrg 908c1f859d4Smrg __DRIscreen *(*createNewScreen)(int screen, 909c1f859d4Smrg const __DRIversion *ddx_version, 910c1f859d4Smrg const __DRIversion *dri_version, 911c1f859d4Smrg const __DRIversion *drm_version, 912c1f859d4Smrg const __DRIframebuffer *frame_buffer, 913c1f859d4Smrg void *pSAREA, int fd, 914c1f859d4Smrg const __DRIextension **extensions, 915c1f859d4Smrg const __DRIconfig ***driver_configs, 916c1f859d4Smrg void *loaderPrivate); 917c1f859d4Smrg 918c1f859d4Smrg __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen, 919c1f859d4Smrg const __DRIconfig *config, 920c1f859d4Smrg drm_drawable_t hwDrawable, 921c1f859d4Smrg int renderType, const int *attrs, 922c1f859d4Smrg void *loaderPrivate); 923c1f859d4Smrg 924c1f859d4Smrg __DRIcontext *(*createNewContext)(__DRIscreen *screen, 925c1f859d4Smrg const __DRIconfig *config, 926c1f859d4Smrg int render_type, 927c1f859d4Smrg __DRIcontext *shared, 928c1f859d4Smrg drm_context_t hwContext, 929c1f859d4Smrg void *loaderPrivate); 9307117f1b4Smrg}; 9317117f1b4Smrg 9327117f1b4Smrg/** 933c1f859d4Smrg * This extension provides alternative screen, drawable and context 934c1f859d4Smrg * constructors for swrast DRI functionality. This is used in 935c1f859d4Smrg * conjunction with the core extension. 9367117f1b4Smrg */ 937c1f859d4Smrg#define __DRI_SWRAST "DRI_SWRast" 938af69d88dSmrg#define __DRI_SWRAST_VERSION 4 9397117f1b4Smrg 940c1f859d4Smrgstruct __DRIswrastExtensionRec { 941c1f859d4Smrg __DRIextension base; 9427117f1b4Smrg 943c1f859d4Smrg __DRIscreen *(*createNewScreen)(int screen, 944c1f859d4Smrg const __DRIextension **extensions, 945c1f859d4Smrg const __DRIconfig ***driver_configs, 946c1f859d4Smrg void *loaderPrivate); 9477117f1b4Smrg 948c1f859d4Smrg __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen, 949c1f859d4Smrg const __DRIconfig *config, 950c1f859d4Smrg void *loaderPrivate); 9513464ebd5Sriastradh 9523464ebd5Sriastradh /* Since version 2 */ 9533464ebd5Sriastradh __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen, 9543464ebd5Sriastradh int api, 9553464ebd5Sriastradh const __DRIconfig *config, 9563464ebd5Sriastradh __DRIcontext *shared, 9573464ebd5Sriastradh void *data); 958af69d88dSmrg 959af69d88dSmrg /** 960af69d88dSmrg * Create a context for a particular API with a set of attributes 961af69d88dSmrg * 962af69d88dSmrg * \since version 3 963af69d88dSmrg * 964af69d88dSmrg * \sa __DRIdri2ExtensionRec::createContextAttribs 965af69d88dSmrg */ 966af69d88dSmrg __DRIcontext *(*createContextAttribs)(__DRIscreen *screen, 967af69d88dSmrg int api, 968af69d88dSmrg const __DRIconfig *config, 969af69d88dSmrg __DRIcontext *shared, 970af69d88dSmrg unsigned num_attribs, 971af69d88dSmrg const uint32_t *attribs, 972af69d88dSmrg unsigned *error, 973af69d88dSmrg void *loaderPrivate); 974af69d88dSmrg 975af69d88dSmrg /** 976af69d88dSmrg * createNewScreen() with the driver extensions passed in. 977af69d88dSmrg * 978af69d88dSmrg * \since version 4 979af69d88dSmrg */ 980af69d88dSmrg __DRIscreen *(*createNewScreen2)(int screen, 981af69d88dSmrg const __DRIextension **loader_extensions, 982af69d88dSmrg const __DRIextension **driver_extensions, 983af69d88dSmrg const __DRIconfig ***driver_configs, 984af69d88dSmrg void *loaderPrivate); 985af69d88dSmrg 9867117f1b4Smrg}; 9877117f1b4Smrg 988af69d88dSmrg/** Common DRI function definitions, shared among DRI2 and Image extensions 989af69d88dSmrg */ 990af69d88dSmrg 991af69d88dSmrgtypedef __DRIscreen * 992af69d88dSmrg(*__DRIcreateNewScreen2Func)(int screen, int fd, 993af69d88dSmrg const __DRIextension **extensions, 994af69d88dSmrg const __DRIextension **driver_extensions, 995af69d88dSmrg const __DRIconfig ***driver_configs, 996af69d88dSmrg void *loaderPrivate); 997af69d88dSmrg 998af69d88dSmrgtypedef __DRIdrawable * 999af69d88dSmrg(*__DRIcreateNewDrawableFunc)(__DRIscreen *screen, 1000af69d88dSmrg const __DRIconfig *config, 1001af69d88dSmrg void *loaderPrivate); 1002af69d88dSmrg 1003af69d88dSmrgtypedef __DRIcontext * 1004af69d88dSmrg(*__DRIcreateContextAttribsFunc)(__DRIscreen *screen, 1005af69d88dSmrg int api, 1006af69d88dSmrg const __DRIconfig *config, 1007af69d88dSmrg __DRIcontext *shared, 1008af69d88dSmrg unsigned num_attribs, 1009af69d88dSmrg const uint32_t *attribs, 1010af69d88dSmrg unsigned *error, 1011af69d88dSmrg void *loaderPrivate); 1012af69d88dSmrg 1013af69d88dSmrgtypedef unsigned int 1014af69d88dSmrg(*__DRIgetAPIMaskFunc)(__DRIscreen *screen); 1015af69d88dSmrg 10167117f1b4Smrg/** 1017c1f859d4Smrg * DRI2 Loader extension. 10187117f1b4Smrg */ 1019c1f859d4Smrg#define __DRI_BUFFER_FRONT_LEFT 0 1020c1f859d4Smrg#define __DRI_BUFFER_BACK_LEFT 1 1021c1f859d4Smrg#define __DRI_BUFFER_FRONT_RIGHT 2 1022c1f859d4Smrg#define __DRI_BUFFER_BACK_RIGHT 3 1023c1f859d4Smrg#define __DRI_BUFFER_DEPTH 4 1024c1f859d4Smrg#define __DRI_BUFFER_STENCIL 5 1025c1f859d4Smrg#define __DRI_BUFFER_ACCUM 6 1026c1f859d4Smrg#define __DRI_BUFFER_FAKE_FRONT_LEFT 7 1027c1f859d4Smrg#define __DRI_BUFFER_FAKE_FRONT_RIGHT 8 10284a49301eSmrg#define __DRI_BUFFER_DEPTH_STENCIL 9 /**< Only available with DRI2 1.1 */ 10293464ebd5Sriastradh#define __DRI_BUFFER_HIZ 10 1030c1f859d4Smrg 1031af69d88dSmrg/* Inofficial and for internal use. Increase when adding a new buffer token. */ 1032af69d88dSmrg#define __DRI_BUFFER_COUNT 11 1033af69d88dSmrg 1034c1f859d4Smrgstruct __DRIbufferRec { 1035c1f859d4Smrg unsigned int attachment; 1036c1f859d4Smrg unsigned int name; 1037c1f859d4Smrg unsigned int pitch; 1038c1f859d4Smrg unsigned int cpp; 1039c1f859d4Smrg unsigned int flags; 1040c1f859d4Smrg}; 10417117f1b4Smrg 1042c1f859d4Smrg#define __DRI_DRI2_LOADER "DRI_DRI2Loader" 10431463c08dSmrg#define __DRI_DRI2_LOADER_VERSION 5 104401e04c3fSmrg 104501e04c3fSmrgenum dri_loader_cap { 104601e04c3fSmrg /* Whether the loader handles RGBA channel ordering correctly. If not, 104701e04c3fSmrg * only BGRA ordering can be exposed. 104801e04c3fSmrg */ 104901e04c3fSmrg DRI_LOADER_CAP_RGBA_ORDERING, 10501463c08dSmrg DRI_LOADER_CAP_FP16, 105101e04c3fSmrg}; 105201e04c3fSmrg 1053c1f859d4Smrgstruct __DRIdri2LoaderExtensionRec { 1054c1f859d4Smrg __DRIextension base; 10557117f1b4Smrg 1056c1f859d4Smrg __DRIbuffer *(*getBuffers)(__DRIdrawable *driDrawable, 1057c1f859d4Smrg int *width, int *height, 1058c1f859d4Smrg unsigned int *attachments, int count, 1059c1f859d4Smrg int *out_count, void *loaderPrivate); 10607117f1b4Smrg 10617117f1b4Smrg /** 1062c1f859d4Smrg * Flush pending front-buffer rendering 10637117f1b4Smrg * 1064c1f859d4Smrg * Any rendering that has been performed to the 1065c1f859d4Smrg * \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the 1066c1f859d4Smrg * \c __DRI_BUFFER_FRONT_LEFT. 10677117f1b4Smrg * 1068c1f859d4Smrg * \param driDrawable Drawable whose front-buffer is to be flushed 1069c1f859d4Smrg * \param loaderPrivate Loader's private data that was previously passed 1070c1f859d4Smrg * into __DRIdri2ExtensionRec::createNewDrawable 1071af69d88dSmrg * 1072af69d88dSmrg * \since 2 10737117f1b4Smrg */ 1074c1f859d4Smrg void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate); 10754a49301eSmrg 10764a49301eSmrg 10774a49301eSmrg /** 10784a49301eSmrg * Get list of buffers from the server 10794a49301eSmrg * 10804a49301eSmrg * Gets a list of buffer for the specified set of attachments. Unlike 10814a49301eSmrg * \c ::getBuffers, this function takes a list of attachments paired with 10824a49301eSmrg * opaque \c unsigned \c int value describing the format of the buffer. 10834a49301eSmrg * It is the responsibility of the caller to know what the service that 10844a49301eSmrg * allocates the buffers will expect to receive for the format. 10854a49301eSmrg * 10864a49301eSmrg * \param driDrawable Drawable whose buffers are being queried. 10874a49301eSmrg * \param width Output where the width of the buffers is stored. 10884a49301eSmrg * \param height Output where the height of the buffers is stored. 10894a49301eSmrg * \param attachments List of pairs of attachment ID and opaque format 10904a49301eSmrg * requested for the drawable. 10914a49301eSmrg * \param count Number of attachment / format pairs stored in 10924a49301eSmrg * \c attachments. 10934a49301eSmrg * \param loaderPrivate Loader's private data that was previously passed 10944a49301eSmrg * into __DRIdri2ExtensionRec::createNewDrawable. 1095af69d88dSmrg * 1096af69d88dSmrg * \since 3 10974a49301eSmrg */ 10984a49301eSmrg __DRIbuffer *(*getBuffersWithFormat)(__DRIdrawable *driDrawable, 10994a49301eSmrg int *width, int *height, 11004a49301eSmrg unsigned int *attachments, int count, 11014a49301eSmrg int *out_count, void *loaderPrivate); 110201e04c3fSmrg 110301e04c3fSmrg /** 110401e04c3fSmrg * Return a loader capability value. If the loader doesn't know the enum, 110501e04c3fSmrg * it will return 0. 110601e04c3fSmrg * 110701e04c3fSmrg * \param loaderPrivate The last parameter of createNewScreen or 110801e04c3fSmrg * createNewScreen2. 110901e04c3fSmrg * \param cap See the enum. 111001e04c3fSmrg * 111101e04c3fSmrg * \since 4 111201e04c3fSmrg */ 111301e04c3fSmrg unsigned (*getCapability)(void *loaderPrivate, enum dri_loader_cap cap); 11141463c08dSmrg 11151463c08dSmrg /** 11161463c08dSmrg * Clean up any loader state associated with an image. 11171463c08dSmrg * 11181463c08dSmrg * \param loaderPrivate Loader's private data that was previously passed 11191463c08dSmrg * into a __DRIimageExtensionRec::createImage function 11201463c08dSmrg * \since 5 11211463c08dSmrg */ 11221463c08dSmrg void (*destroyLoaderImageState)(void *loaderPrivate); 1123c1f859d4Smrg}; 11247117f1b4Smrg 1125c1f859d4Smrg/** 1126c1f859d4Smrg * This extension provides alternative screen, drawable and context 1127c1f859d4Smrg * constructors for DRI2. 1128c1f859d4Smrg */ 1129c1f859d4Smrg#define __DRI_DRI2 "DRI_DRI2" 1130af69d88dSmrg#define __DRI_DRI2_VERSION 4 1131af69d88dSmrg 1132af69d88dSmrg#define __DRI_API_OPENGL 0 /**< OpenGL compatibility profile */ 1133af69d88dSmrg#define __DRI_API_GLES 1 /**< OpenGL ES 1.x */ 1134af69d88dSmrg#define __DRI_API_GLES2 2 /**< OpenGL ES 2.x */ 1135af69d88dSmrg#define __DRI_API_OPENGL_CORE 3 /**< OpenGL 3.2+ core profile */ 1136af69d88dSmrg#define __DRI_API_GLES3 4 /**< OpenGL ES 3.x */ 1137af69d88dSmrg 1138af69d88dSmrg#define __DRI_CTX_ATTRIB_MAJOR_VERSION 0 1139af69d88dSmrg#define __DRI_CTX_ATTRIB_MINOR_VERSION 1 1140af69d88dSmrg 11411463c08dSmrg#define __DRI_CTX_ATTRIB_FLAGS 2 1142af69d88dSmrg#define __DRI_CTX_FLAG_DEBUG 0x00000001 1143af69d88dSmrg#define __DRI_CTX_FLAG_FORWARD_COMPATIBLE 0x00000002 1144af69d88dSmrg#define __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS 0x00000004 114501e04c3fSmrg#define __DRI_CTX_FLAG_NO_ERROR 0x00000008 114601e04c3fSmrg 11471463c08dSmrg#define __DRI_CTX_ATTRIB_RESET_STRATEGY 3 1148af69d88dSmrg#define __DRI_CTX_RESET_NO_NOTIFICATION 0 1149af69d88dSmrg#define __DRI_CTX_RESET_LOSE_CONTEXT 1 1150af69d88dSmrg 115101e04c3fSmrg#define __DRI_CTX_ATTRIB_PRIORITY 4 115201e04c3fSmrg#define __DRI_CTX_PRIORITY_LOW 0 115301e04c3fSmrg#define __DRI_CTX_PRIORITY_MEDIUM 1 115401e04c3fSmrg#define __DRI_CTX_PRIORITY_HIGH 2 115501e04c3fSmrg 115601e04c3fSmrg#define __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR 5 115701e04c3fSmrg#define __DRI_CTX_RELEASE_BEHAVIOR_NONE 0 115801e04c3fSmrg#define __DRI_CTX_RELEASE_BEHAVIOR_FLUSH 1 11591463c08dSmrg 11601463c08dSmrg#define __DRI_CTX_NUM_ATTRIBS 6 116101e04c3fSmrg 1162af69d88dSmrg/** 1163af69d88dSmrg * \name Reasons that __DRIdri2Extension::createContextAttribs might fail 1164af69d88dSmrg */ 1165af69d88dSmrg/*@{*/ 1166af69d88dSmrg/** Success! */ 1167af69d88dSmrg#define __DRI_CTX_ERROR_SUCCESS 0 1168af69d88dSmrg 1169af69d88dSmrg/** Memory allocation failure */ 1170af69d88dSmrg#define __DRI_CTX_ERROR_NO_MEMORY 1 1171af69d88dSmrg 1172af69d88dSmrg/** Client requested an API (e.g., OpenGL ES 2.0) that the driver can't do. */ 1173af69d88dSmrg#define __DRI_CTX_ERROR_BAD_API 2 1174af69d88dSmrg 1175af69d88dSmrg/** Client requested an API version that the driver can't do. */ 1176af69d88dSmrg#define __DRI_CTX_ERROR_BAD_VERSION 3 11773464ebd5Sriastradh 1178af69d88dSmrg/** Client requested a flag or combination of flags the driver can't do. */ 1179af69d88dSmrg#define __DRI_CTX_ERROR_BAD_FLAG 4 1180af69d88dSmrg 1181af69d88dSmrg/** Client requested an attribute the driver doesn't understand. */ 1182af69d88dSmrg#define __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE 5 1183af69d88dSmrg 1184af69d88dSmrg/** Client requested a flag the driver doesn't understand. */ 1185af69d88dSmrg#define __DRI_CTX_ERROR_UNKNOWN_FLAG 6 1186af69d88dSmrg/*@}*/ 11877117f1b4Smrg 1188c1f859d4Smrgstruct __DRIdri2ExtensionRec { 1189c1f859d4Smrg __DRIextension base; 11907117f1b4Smrg 1191c1f859d4Smrg __DRIscreen *(*createNewScreen)(int screen, int fd, 1192c1f859d4Smrg const __DRIextension **extensions, 1193c1f859d4Smrg const __DRIconfig ***driver_configs, 1194c1f859d4Smrg void *loaderPrivate); 11957117f1b4Smrg 1196af69d88dSmrg __DRIcreateNewDrawableFunc createNewDrawable; 1197af69d88dSmrg __DRIcontext *(*createNewContext)(__DRIscreen *screen, 1198af69d88dSmrg const __DRIconfig *config, 1199af69d88dSmrg __DRIcontext *shared, 1200af69d88dSmrg void *loaderPrivate); 12017117f1b4Smrg 12023464ebd5Sriastradh /* Since version 2 */ 1203af69d88dSmrg __DRIgetAPIMaskFunc getAPIMask; 12043464ebd5Sriastradh 12053464ebd5Sriastradh __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen, 12063464ebd5Sriastradh int api, 12073464ebd5Sriastradh const __DRIconfig *config, 12083464ebd5Sriastradh __DRIcontext *shared, 12093464ebd5Sriastradh void *data); 12103464ebd5Sriastradh 12113464ebd5Sriastradh __DRIbuffer *(*allocateBuffer)(__DRIscreen *screen, 12123464ebd5Sriastradh unsigned int attachment, 12133464ebd5Sriastradh unsigned int format, 12143464ebd5Sriastradh int width, 12153464ebd5Sriastradh int height); 12163464ebd5Sriastradh void (*releaseBuffer)(__DRIscreen *screen, 12173464ebd5Sriastradh __DRIbuffer *buffer); 1218af69d88dSmrg 1219af69d88dSmrg /** 1220af69d88dSmrg * Create a context for a particular API with a set of attributes 1221af69d88dSmrg * 1222af69d88dSmrg * \since version 3 1223af69d88dSmrg * 1224af69d88dSmrg * \sa __DRIswrastExtensionRec::createContextAttribs 1225af69d88dSmrg */ 1226af69d88dSmrg __DRIcreateContextAttribsFunc createContextAttribs; 1227af69d88dSmrg 1228af69d88dSmrg /** 1229af69d88dSmrg * createNewScreen with the driver's extension list passed in. 1230af69d88dSmrg * 1231af69d88dSmrg * \since version 4 1232af69d88dSmrg */ 1233af69d88dSmrg __DRIcreateNewScreen2Func createNewScreen2; 12347117f1b4Smrg}; 12357117f1b4Smrg 1236cdc920a0Smrg 1237cdc920a0Smrg/** 1238cdc920a0Smrg * This extension provides functionality to enable various EGLImage 1239cdc920a0Smrg * extensions. 1240cdc920a0Smrg */ 1241cdc920a0Smrg#define __DRI_IMAGE "DRI_IMAGE" 12421463c08dSmrg#define __DRI_IMAGE_VERSION 19 1243cdc920a0Smrg 1244cdc920a0Smrg/** 1245cdc920a0Smrg * These formats correspond to the similarly named MESA_FORMAT_* 1246cdc920a0Smrg * tokens, except in the native endian of the CPU. For example, on 1247cdc920a0Smrg * little endian __DRI_IMAGE_FORMAT_XRGB8888 corresponds to 1248cdc920a0Smrg * MESA_FORMAT_XRGB8888, but MESA_FORMAT_XRGB8888_REV on big endian. 1249af69d88dSmrg * 1250af69d88dSmrg * __DRI_IMAGE_FORMAT_NONE is for images that aren't directly usable 1251af69d88dSmrg * by the driver (YUV planar formats) but serve as a base image for 1252af69d88dSmrg * creating sub-images for the different planes within the image. 1253af69d88dSmrg * 125401e04c3fSmrg * R8, GR88 and NONE should not be used with createImageFromName or 1255af69d88dSmrg * createImage, and are returned by query from sub images created with 1256af69d88dSmrg * createImageFromNames (NONE, see above) and fromPlane (R8 & GR88). 1257cdc920a0Smrg */ 1258cdc920a0Smrg#define __DRI_IMAGE_FORMAT_RGB565 0x1001 1259cdc920a0Smrg#define __DRI_IMAGE_FORMAT_XRGB8888 0x1002 1260cdc920a0Smrg#define __DRI_IMAGE_FORMAT_ARGB8888 0x1003 1261af69d88dSmrg#define __DRI_IMAGE_FORMAT_ABGR8888 0x1004 1262af69d88dSmrg#define __DRI_IMAGE_FORMAT_XBGR8888 0x1005 1263af69d88dSmrg#define __DRI_IMAGE_FORMAT_R8 0x1006 /* Since version 5 */ 1264af69d88dSmrg#define __DRI_IMAGE_FORMAT_GR88 0x1007 1265af69d88dSmrg#define __DRI_IMAGE_FORMAT_NONE 0x1008 1266af69d88dSmrg#define __DRI_IMAGE_FORMAT_XRGB2101010 0x1009 1267af69d88dSmrg#define __DRI_IMAGE_FORMAT_ARGB2101010 0x100a 1268af69d88dSmrg#define __DRI_IMAGE_FORMAT_SARGB8 0x100b 126901e04c3fSmrg#define __DRI_IMAGE_FORMAT_ARGB1555 0x100c 127001e04c3fSmrg#define __DRI_IMAGE_FORMAT_R16 0x100d 127101e04c3fSmrg#define __DRI_IMAGE_FORMAT_GR1616 0x100e 127201e04c3fSmrg#define __DRI_IMAGE_FORMAT_YUYV 0x100f 127301e04c3fSmrg#define __DRI_IMAGE_FORMAT_XBGR2101010 0x1010 127401e04c3fSmrg#define __DRI_IMAGE_FORMAT_ABGR2101010 0x1011 127501e04c3fSmrg#define __DRI_IMAGE_FORMAT_SABGR8 0x1012 1276d8407755Smaya#define __DRI_IMAGE_FORMAT_UYVY 0x1013 12771463c08dSmrg#define __DRI_IMAGE_FORMAT_XBGR16161616F 0x1014 12781463c08dSmrg#define __DRI_IMAGE_FORMAT_ABGR16161616F 0x1015 12791463c08dSmrg#define __DRI_IMAGE_FORMAT_SXRGB8 0x1016 12801463c08dSmrg#define __DRI_IMAGE_FORMAT_ABGR16161616 0x1017 1281cdc920a0Smrg 12823464ebd5Sriastradh#define __DRI_IMAGE_USE_SHARE 0x0001 12833464ebd5Sriastradh#define __DRI_IMAGE_USE_SCANOUT 0x0002 128401e04c3fSmrg#define __DRI_IMAGE_USE_CURSOR 0x0004 /* Deprecated */ 1285af69d88dSmrg#define __DRI_IMAGE_USE_LINEAR 0x0008 128601e04c3fSmrg/* The buffer will only be read by an external process after SwapBuffers, 128701e04c3fSmrg * in contrary to gbm buffers, front buffers and fake front buffers, which 128801e04c3fSmrg * could be read after a flush." 128901e04c3fSmrg */ 129001e04c3fSmrg#define __DRI_IMAGE_USE_BACKBUFFER 0x0010 12911463c08dSmrg#define __DRI_IMAGE_USE_PROTECTED 0x0020 1292af69d88dSmrg 1293af69d88dSmrg 129401e04c3fSmrg#define __DRI_IMAGE_TRANSFER_READ 0x1 129501e04c3fSmrg#define __DRI_IMAGE_TRANSFER_WRITE 0x2 129601e04c3fSmrg#define __DRI_IMAGE_TRANSFER_READ_WRITE \ 129701e04c3fSmrg (__DRI_IMAGE_TRANSFER_READ | __DRI_IMAGE_TRANSFER_WRITE) 129801e04c3fSmrg 1299af69d88dSmrg/** 13001463c08dSmrg * Extra fourcc formats used internally to Mesa with createImageFromNames. 13011463c08dSmrg * The externally-available fourccs are defined by drm_fourcc.h (DRM_FORMAT_*) 13021463c08dSmrg * and WL_DRM_FORMAT_* from wayland_drm.h. 1303af69d88dSmrg * 1304af69d88dSmrg * \since 5 1305af69d88dSmrg */ 1306af69d88dSmrg 130701e04c3fSmrg#define __DRI_IMAGE_FOURCC_SARGB8888 0x83324258 130801e04c3fSmrg#define __DRI_IMAGE_FOURCC_SABGR8888 0x84324258 13091463c08dSmrg#define __DRI_IMAGE_FOURCC_SXRGB8888 0x85324258 13101463c08dSmrg#define __DRI_IMAGE_FOURCC_RGBA16161616 0x38344152 /* fourcc_code('R', 'A', '4', '8' ) */ 1311d8407755Smaya 1312af69d88dSmrg/** 1313af69d88dSmrg * Queryable on images created by createImageFromNames. 1314af69d88dSmrg * 13151463c08dSmrg * RGB and RGBA might be usable directly as images, but it's still 1316af69d88dSmrg * recommended to call fromPlanar with plane == 0. 1317af69d88dSmrg * 131801e04c3fSmrg * Y_U_V, Y_UV,Y_XUXV and Y_UXVX all requires call to fromPlanar to create 1319af69d88dSmrg * usable sub-images, sampling from images return raw YUV data and 1320af69d88dSmrg * color conversion needs to be done in the shader. 1321af69d88dSmrg * 1322af69d88dSmrg * \since 5 1323af69d88dSmrg */ 1324af69d88dSmrg 1325af69d88dSmrg#define __DRI_IMAGE_COMPONENTS_RGB 0x3001 1326af69d88dSmrg#define __DRI_IMAGE_COMPONENTS_RGBA 0x3002 1327af69d88dSmrg#define __DRI_IMAGE_COMPONENTS_Y_U_V 0x3003 1328af69d88dSmrg#define __DRI_IMAGE_COMPONENTS_Y_UV 0x3004 1329af69d88dSmrg#define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x3005 133001e04c3fSmrg#define __DRI_IMAGE_COMPONENTS_Y_UXVX 0x3008 1331d8407755Smaya#define __DRI_IMAGE_COMPONENTS_AYUV 0x3009 1332d8407755Smaya#define __DRI_IMAGE_COMPONENTS_XYUV 0x300A 133301e04c3fSmrg#define __DRI_IMAGE_COMPONENTS_R 0x3006 133401e04c3fSmrg#define __DRI_IMAGE_COMPONENTS_RG 0x3007 1335af69d88dSmrg 13363464ebd5Sriastradh 13373464ebd5Sriastradh/** 13383464ebd5Sriastradh * queryImage attributes 13393464ebd5Sriastradh */ 13403464ebd5Sriastradh 13413464ebd5Sriastradh#define __DRI_IMAGE_ATTRIB_STRIDE 0x2000 13423464ebd5Sriastradh#define __DRI_IMAGE_ATTRIB_HANDLE 0x2001 13433464ebd5Sriastradh#define __DRI_IMAGE_ATTRIB_NAME 0x2002 1344af69d88dSmrg#define __DRI_IMAGE_ATTRIB_FORMAT 0x2003 /* available in versions 3+ */ 1345af69d88dSmrg#define __DRI_IMAGE_ATTRIB_WIDTH 0x2004 /* available in versions 4+ */ 1346af69d88dSmrg#define __DRI_IMAGE_ATTRIB_HEIGHT 0x2005 1347af69d88dSmrg#define __DRI_IMAGE_ATTRIB_COMPONENTS 0x2006 /* available in versions 5+ */ 1348af69d88dSmrg#define __DRI_IMAGE_ATTRIB_FD 0x2007 /* available in versions 1349af69d88dSmrg * 7+. Each query will return a 1350af69d88dSmrg * new fd. */ 135101e04c3fSmrg#define __DRI_IMAGE_ATTRIB_FOURCC 0x2008 /* available in versions 11 */ 135201e04c3fSmrg#define __DRI_IMAGE_ATTRIB_NUM_PLANES 0x2009 /* available in versions 11 */ 135301e04c3fSmrg 135401e04c3fSmrg#define __DRI_IMAGE_ATTRIB_OFFSET 0x200A /* available in versions 13 */ 135501e04c3fSmrg#define __DRI_IMAGE_ATTRIB_MODIFIER_LOWER 0x200B /* available in versions 14 */ 135601e04c3fSmrg#define __DRI_IMAGE_ATTRIB_MODIFIER_UPPER 0x200C /* available in versions 14 */ 1357af69d88dSmrg 1358af69d88dSmrgenum __DRIYUVColorSpace { 1359af69d88dSmrg __DRI_YUV_COLOR_SPACE_UNDEFINED = 0, 1360af69d88dSmrg __DRI_YUV_COLOR_SPACE_ITU_REC601 = 0x327F, 1361af69d88dSmrg __DRI_YUV_COLOR_SPACE_ITU_REC709 = 0x3280, 1362af69d88dSmrg __DRI_YUV_COLOR_SPACE_ITU_REC2020 = 0x3281 1363af69d88dSmrg}; 1364af69d88dSmrg 1365af69d88dSmrgenum __DRISampleRange { 1366af69d88dSmrg __DRI_YUV_RANGE_UNDEFINED = 0, 1367af69d88dSmrg __DRI_YUV_FULL_RANGE = 0x3282, 1368af69d88dSmrg __DRI_YUV_NARROW_RANGE = 0x3283 1369af69d88dSmrg}; 1370af69d88dSmrg 1371af69d88dSmrgenum __DRIChromaSiting { 1372af69d88dSmrg __DRI_YUV_CHROMA_SITING_UNDEFINED = 0, 1373af69d88dSmrg __DRI_YUV_CHROMA_SITING_0 = 0x3284, 1374af69d88dSmrg __DRI_YUV_CHROMA_SITING_0_5 = 0x3285 1375af69d88dSmrg}; 1376af69d88dSmrg 1377af69d88dSmrg/** 137801e04c3fSmrg * \name Reasons that __DRIimageExtensionRec::createImageFromTexture or 137901e04c3fSmrg * __DRIimageExtensionRec::createImageFromDmaBufs might fail 1380af69d88dSmrg */ 1381af69d88dSmrg/*@{*/ 1382af69d88dSmrg/** Success! */ 1383af69d88dSmrg#define __DRI_IMAGE_ERROR_SUCCESS 0 1384af69d88dSmrg 1385af69d88dSmrg/** Memory allocation failure */ 1386af69d88dSmrg#define __DRI_IMAGE_ERROR_BAD_ALLOC 1 1387af69d88dSmrg 138801e04c3fSmrg/** Client requested an invalid attribute */ 1389af69d88dSmrg#define __DRI_IMAGE_ERROR_BAD_MATCH 2 1390af69d88dSmrg 1391af69d88dSmrg/** Client requested an invalid texture object */ 1392af69d88dSmrg#define __DRI_IMAGE_ERROR_BAD_PARAMETER 3 139301e04c3fSmrg 139401e04c3fSmrg/** Client requested an invalid pitch and/or offset */ 139501e04c3fSmrg#define __DRI_IMAGE_ERROR_BAD_ACCESS 4 1396af69d88dSmrg/*@}*/ 1397af69d88dSmrg 1398af69d88dSmrg/** 1399af69d88dSmrg * \name Capabilities that might be returned by __DRIimageExtensionRec::getCapabilities 1400af69d88dSmrg */ 1401af69d88dSmrg/*@{*/ 1402af69d88dSmrg#define __DRI_IMAGE_CAP_GLOBAL_NAMES 1 1403af69d88dSmrg/*@}*/ 1404af69d88dSmrg 1405af69d88dSmrg/** 1406af69d88dSmrg * blitImage flags 1407af69d88dSmrg */ 1408af69d88dSmrg 1409af69d88dSmrg#define __BLIT_FLAG_FLUSH 0x0001 1410af69d88dSmrg#define __BLIT_FLAG_FINISH 0x0002 14113464ebd5Sriastradh 14121463c08dSmrg/** 14131463c08dSmrg * Flags for createImageFromDmaBufs3 14141463c08dSmrg */ 14151463c08dSmrg#define __DRI_IMAGE_PROTECTED_CONTENT_FLAG 0x00000001 14161463c08dSmrg 141701e04c3fSmrg/** 141801e04c3fSmrg * queryDmaBufFormatModifierAttribs attributes 141901e04c3fSmrg */ 142001e04c3fSmrg 142101e04c3fSmrg/* Available in version 16 */ 142201e04c3fSmrg#define __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB_PLANE_COUNT 0x0001 142301e04c3fSmrg 1424cdc920a0Smrgtypedef struct __DRIimageRec __DRIimage; 1425cdc920a0Smrgtypedef struct __DRIimageExtensionRec __DRIimageExtension; 1426cdc920a0Smrgstruct __DRIimageExtensionRec { 1427cdc920a0Smrg __DRIextension base; 1428cdc920a0Smrg 14293464ebd5Sriastradh __DRIimage *(*createImageFromName)(__DRIscreen *screen, 1430cdc920a0Smrg int width, int height, int format, 1431cdc920a0Smrg int name, int pitch, 1432cdc920a0Smrg void *loaderPrivate); 1433cdc920a0Smrg 143401e04c3fSmrg /* Deprecated since version 17; see createImageFromRenderbuffer2 */ 1435cdc920a0Smrg __DRIimage *(*createImageFromRenderbuffer)(__DRIcontext *context, 1436cdc920a0Smrg int renderbuffer, 1437cdc920a0Smrg void *loaderPrivate); 1438cdc920a0Smrg 1439cdc920a0Smrg void (*destroyImage)(__DRIimage *image); 14403464ebd5Sriastradh 14413464ebd5Sriastradh __DRIimage *(*createImage)(__DRIscreen *screen, 14423464ebd5Sriastradh int width, int height, int format, 14433464ebd5Sriastradh unsigned int use, 14443464ebd5Sriastradh void *loaderPrivate); 14453464ebd5Sriastradh 14461463c08dSmrg unsigned char (*queryImage)(__DRIimage *image, int attrib, int *value); 14473464ebd5Sriastradh 14483464ebd5Sriastradh /** 14493464ebd5Sriastradh * The new __DRIimage will share the content with the old one, see dup(2). 14503464ebd5Sriastradh */ 14513464ebd5Sriastradh __DRIimage *(*dupImage)(__DRIimage *image, void *loaderPrivate); 1452af69d88dSmrg 1453af69d88dSmrg /** 1454af69d88dSmrg * Validate that a __DRIimage can be used a certain way. 1455af69d88dSmrg * 1456af69d88dSmrg * \since 2 1457af69d88dSmrg */ 14581463c08dSmrg unsigned char (*validateUsage)(__DRIimage *image, unsigned int use); 1459af69d88dSmrg 1460af69d88dSmrg /** 14611463c08dSmrg * Unlike createImageFromName __DRI_IMAGE_FORMAT is not used but instead 14621463c08dSmrg * DRM_FORMAT_*, and strides are in bytes not pixels. Stride is 1463af69d88dSmrg * also per block and not per pixel (for non-RGB, see gallium blocks). 1464af69d88dSmrg * 1465af69d88dSmrg * \since 5 1466af69d88dSmrg */ 1467af69d88dSmrg __DRIimage *(*createImageFromNames)(__DRIscreen *screen, 1468af69d88dSmrg int width, int height, int fourcc, 1469af69d88dSmrg int *names, int num_names, 1470af69d88dSmrg int *strides, int *offsets, 1471af69d88dSmrg void *loaderPrivate); 1472af69d88dSmrg 1473af69d88dSmrg /** 1474af69d88dSmrg * Create an image out of a sub-region of a parent image. This 1475af69d88dSmrg * entry point lets us create individual __DRIimages for different 1476af69d88dSmrg * planes in a planar buffer (typically yuv), for example. While a 1477af69d88dSmrg * sub-image shares the underlying buffer object with the parent 1478af69d88dSmrg * image and other sibling sub-images, the life times of parent and 1479af69d88dSmrg * sub-images are not dependent. Destroying the parent or a 1480af69d88dSmrg * sub-image doesn't affect other images. The underlying buffer 1481af69d88dSmrg * object is free when no __DRIimage remains that references it. 1482af69d88dSmrg * 1483af69d88dSmrg * Sub-images may overlap, but rendering to overlapping sub-images 1484af69d88dSmrg * is undefined. 1485af69d88dSmrg * 1486af69d88dSmrg * \since 5 1487af69d88dSmrg */ 1488af69d88dSmrg __DRIimage *(*fromPlanar)(__DRIimage *image, int plane, 1489af69d88dSmrg void *loaderPrivate); 1490af69d88dSmrg 1491af69d88dSmrg /** 1492af69d88dSmrg * Create image from texture. 1493af69d88dSmrg * 1494af69d88dSmrg * \since 6 1495af69d88dSmrg */ 1496af69d88dSmrg __DRIimage *(*createImageFromTexture)(__DRIcontext *context, 1497af69d88dSmrg int target, 1498af69d88dSmrg unsigned texture, 1499af69d88dSmrg int depth, 1500af69d88dSmrg int level, 1501af69d88dSmrg unsigned *error, 1502af69d88dSmrg void *loaderPrivate); 1503af69d88dSmrg /** 1504af69d88dSmrg * Like createImageFromNames, but takes a prime fd instead. 1505af69d88dSmrg * 1506af69d88dSmrg * \since 7 1507af69d88dSmrg */ 1508af69d88dSmrg __DRIimage *(*createImageFromFds)(__DRIscreen *screen, 1509af69d88dSmrg int width, int height, int fourcc, 1510af69d88dSmrg int *fds, int num_fds, 1511af69d88dSmrg int *strides, int *offsets, 1512af69d88dSmrg void *loaderPrivate); 1513af69d88dSmrg 1514af69d88dSmrg /** 1515af69d88dSmrg * Like createImageFromFds, but takes additional attributes. 1516af69d88dSmrg * 1517af69d88dSmrg * For EGL_EXT_image_dma_buf_import. 1518af69d88dSmrg * 1519af69d88dSmrg * \since 8 1520af69d88dSmrg */ 1521af69d88dSmrg __DRIimage *(*createImageFromDmaBufs)(__DRIscreen *screen, 1522af69d88dSmrg int width, int height, int fourcc, 1523af69d88dSmrg int *fds, int num_fds, 1524af69d88dSmrg int *strides, int *offsets, 1525af69d88dSmrg enum __DRIYUVColorSpace color_space, 1526af69d88dSmrg enum __DRISampleRange sample_range, 1527af69d88dSmrg enum __DRIChromaSiting horiz_siting, 1528af69d88dSmrg enum __DRIChromaSiting vert_siting, 1529af69d88dSmrg unsigned *error, 1530af69d88dSmrg void *loaderPrivate); 1531af69d88dSmrg 1532af69d88dSmrg /** 1533af69d88dSmrg * Blit a part of a __DRIimage to another and flushes 1534af69d88dSmrg * 1535af69d88dSmrg * flush_flag: 1536af69d88dSmrg * 0: no flush 1537af69d88dSmrg * __BLIT_FLAG_FLUSH: flush after the blit operation 1538af69d88dSmrg * __BLIT_FLAG_FINISH: flush and wait the blit finished 1539af69d88dSmrg * 1540af69d88dSmrg * \since 9 1541af69d88dSmrg */ 1542af69d88dSmrg void (*blitImage)(__DRIcontext *context, __DRIimage *dst, __DRIimage *src, 1543af69d88dSmrg int dstx0, int dsty0, int dstwidth, int dstheight, 1544af69d88dSmrg int srcx0, int srcy0, int srcwidth, int srcheight, 1545af69d88dSmrg int flush_flag); 1546af69d88dSmrg 1547af69d88dSmrg /** 1548af69d88dSmrg * Query for general capabilities of the driver that concern 1549af69d88dSmrg * buffer sharing and image importing. 1550af69d88dSmrg * 1551af69d88dSmrg * \since 10 1552af69d88dSmrg */ 1553af69d88dSmrg int (*getCapabilities)(__DRIscreen *screen); 155401e04c3fSmrg 155501e04c3fSmrg /** 155601e04c3fSmrg * Returns a map of the specified region of a __DRIimage for the specified usage. 155701e04c3fSmrg * 155801e04c3fSmrg * flags may include __DRI_IMAGE_TRANSFER_READ, which will populate the 155901e04c3fSmrg * mapping with the current buffer content. If __DRI_IMAGE_TRANSFER_READ 156001e04c3fSmrg * is not included in the flags, the buffer content at map time is 156101e04c3fSmrg * undefined. Users wanting to modify the mapping must include 156201e04c3fSmrg * __DRI_IMAGE_TRANSFER_WRITE; if __DRI_IMAGE_TRANSFER_WRITE is not 156301e04c3fSmrg * included, behaviour when writing the mapping is undefined. 156401e04c3fSmrg * 156501e04c3fSmrg * Returns the byte stride in *stride, and an opaque pointer to data 156601e04c3fSmrg * tracking the mapping in **data, which must be passed to unmapImage(). 156701e04c3fSmrg * 156801e04c3fSmrg * \since 12 156901e04c3fSmrg */ 157001e04c3fSmrg void *(*mapImage)(__DRIcontext *context, __DRIimage *image, 157101e04c3fSmrg int x0, int y0, int width, int height, 157201e04c3fSmrg unsigned int flags, int *stride, void **data); 157301e04c3fSmrg 157401e04c3fSmrg /** 157501e04c3fSmrg * Unmap a previously mapped __DRIimage 157601e04c3fSmrg * 157701e04c3fSmrg * \since 12 157801e04c3fSmrg */ 157901e04c3fSmrg void (*unmapImage)(__DRIcontext *context, __DRIimage *image, void *data); 158001e04c3fSmrg 158101e04c3fSmrg 158201e04c3fSmrg /** 158301e04c3fSmrg * Creates an image with implementation's favorite modifiers. 158401e04c3fSmrg * 158501e04c3fSmrg * This acts like createImage except there is a list of modifiers passed in 158601e04c3fSmrg * which the implementation may selectively use to create the DRIimage. The 158701e04c3fSmrg * result should be the implementation selects one modifier (perhaps it would 158801e04c3fSmrg * hold on to a few and later pick). 158901e04c3fSmrg * 159001e04c3fSmrg * The created image should be destroyed with destroyImage(). 159101e04c3fSmrg * 159201e04c3fSmrg * Returns the new DRIimage. The chosen modifier can be obtained later on 159301e04c3fSmrg * and passed back to things like the kernel's AddFB2 interface. 159401e04c3fSmrg * 159501e04c3fSmrg * \sa __DRIimageRec::createImage 159601e04c3fSmrg * 159701e04c3fSmrg * \since 14 159801e04c3fSmrg */ 159901e04c3fSmrg __DRIimage *(*createImageWithModifiers)(__DRIscreen *screen, 160001e04c3fSmrg int width, int height, int format, 160101e04c3fSmrg const uint64_t *modifiers, 160201e04c3fSmrg const unsigned int modifier_count, 160301e04c3fSmrg void *loaderPrivate); 160401e04c3fSmrg 160501e04c3fSmrg /* 160601e04c3fSmrg * Like createImageFromDmaBufs, but takes also format modifiers. 160701e04c3fSmrg * 160801e04c3fSmrg * For EGL_EXT_image_dma_buf_import_modifiers. 160901e04c3fSmrg * 161001e04c3fSmrg * \since 15 161101e04c3fSmrg */ 161201e04c3fSmrg __DRIimage *(*createImageFromDmaBufs2)(__DRIscreen *screen, 161301e04c3fSmrg int width, int height, int fourcc, 161401e04c3fSmrg uint64_t modifier, 161501e04c3fSmrg int *fds, int num_fds, 161601e04c3fSmrg int *strides, int *offsets, 161701e04c3fSmrg enum __DRIYUVColorSpace color_space, 161801e04c3fSmrg enum __DRISampleRange sample_range, 161901e04c3fSmrg enum __DRIChromaSiting horiz_siting, 162001e04c3fSmrg enum __DRIChromaSiting vert_siting, 162101e04c3fSmrg unsigned *error, 162201e04c3fSmrg void *loaderPrivate); 162301e04c3fSmrg 162401e04c3fSmrg /* 162501e04c3fSmrg * dmabuf format query to support EGL_EXT_image_dma_buf_import_modifiers. 162601e04c3fSmrg * 162701e04c3fSmrg * \param max Maximum number of formats that can be accomodated into 162801e04c3fSmrg * \param formats. If zero, no formats are returned - 162901e04c3fSmrg * instead, the driver returns the total number of 163001e04c3fSmrg * supported dmabuf formats in \param count. 163101e04c3fSmrg * \param formats Buffer to fill formats into. 163201e04c3fSmrg * \param count Count of formats returned, or, total number of 163301e04c3fSmrg * supported formats in case \param max is zero. 163401e04c3fSmrg * 163501e04c3fSmrg * Returns true on success. 163601e04c3fSmrg * 163701e04c3fSmrg * \since 15 163801e04c3fSmrg */ 16391463c08dSmrg unsigned char (*queryDmaBufFormats)(__DRIscreen *screen, int max, 16401463c08dSmrg int *formats, int *count); 164101e04c3fSmrg 164201e04c3fSmrg /* 164301e04c3fSmrg * dmabuf format modifier query for a given format to support 164401e04c3fSmrg * EGL_EXT_image_dma_buf_import_modifiers. 164501e04c3fSmrg * 164601e04c3fSmrg * \param fourcc The format to query modifiers for. If this format 164701e04c3fSmrg * is not supported by the driver, return false. 164801e04c3fSmrg * \param max Maximum number of modifiers that can be accomodated in 164901e04c3fSmrg * \param modifiers. If zero, no modifiers are returned - 165001e04c3fSmrg * instead, the driver returns the total number of 165101e04c3fSmrg * modifiers for \param format in \param count. 165201e04c3fSmrg * \param modifiers Buffer to fill modifiers into. 165301e04c3fSmrg * \param count Count of the modifiers returned, or, total number of 165401e04c3fSmrg * supported modifiers for \param fourcc in case 165501e04c3fSmrg * \param max is zero. 165601e04c3fSmrg * 165701e04c3fSmrg * Returns true upon success. 165801e04c3fSmrg * 165901e04c3fSmrg * \since 15 166001e04c3fSmrg */ 16611463c08dSmrg unsigned char (*queryDmaBufModifiers)(__DRIscreen *screen, int fourcc, 16621463c08dSmrg int max, uint64_t *modifiers, 16631463c08dSmrg unsigned int *external_only, 16641463c08dSmrg int *count); 166501e04c3fSmrg 166601e04c3fSmrg /** 166701e04c3fSmrg * dmabuf format modifier attribute query for a given format and modifier. 166801e04c3fSmrg * 166901e04c3fSmrg * \param fourcc The format to query. If this format is not supported by 167001e04c3fSmrg * the driver, return false. 167101e04c3fSmrg * \param modifier The modifier to query. If this format+modifier is not 167201e04c3fSmrg * supported by the driver, return false. 167301e04c3fSmrg * \param attrib The __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB to query. 167401e04c3fSmrg * \param value A pointer to where to store the result of the query. 167501e04c3fSmrg * 167601e04c3fSmrg * Returns true upon success. 167701e04c3fSmrg * 167801e04c3fSmrg * \since 16 167901e04c3fSmrg */ 16801463c08dSmrg unsigned char (*queryDmaBufFormatModifierAttribs)(__DRIscreen *screen, 16811463c08dSmrg uint32_t fourcc, 16821463c08dSmrg uint64_t modifier, 16831463c08dSmrg int attrib, 16841463c08dSmrg uint64_t *value); 168501e04c3fSmrg 168601e04c3fSmrg /** 168701e04c3fSmrg * Create a DRI image from the given renderbuffer. 168801e04c3fSmrg * 168901e04c3fSmrg * \param context the current DRI context 169001e04c3fSmrg * \param renderbuffer the GL name of the renderbuffer 169101e04c3fSmrg * \param loaderPrivate for callbacks into the loader related to the image 169201e04c3fSmrg * \param error will be set to one of __DRI_IMAGE_ERROR_xxx 169301e04c3fSmrg * \return the newly created image on success, or NULL otherwise 169401e04c3fSmrg * 169501e04c3fSmrg * \since 17 169601e04c3fSmrg */ 169701e04c3fSmrg __DRIimage *(*createImageFromRenderbuffer2)(__DRIcontext *context, 169801e04c3fSmrg int renderbuffer, 169901e04c3fSmrg void *loaderPrivate, 170001e04c3fSmrg unsigned *error); 17011463c08dSmrg 17021463c08dSmrg /* 17031463c08dSmrg * Like createImageFromDmaBufs2, but with an added flags parameter. 17041463c08dSmrg * 17051463c08dSmrg * See __DRI_IMAGE_*_FLAG for valid definitions of flags. 17061463c08dSmrg * 17071463c08dSmrg * \since 18 17081463c08dSmrg */ 17091463c08dSmrg __DRIimage *(*createImageFromDmaBufs3)(__DRIscreen *screen, 17101463c08dSmrg int width, int height, int fourcc, 17111463c08dSmrg uint64_t modifier, 17121463c08dSmrg int *fds, int num_fds, 17131463c08dSmrg int *strides, int *offsets, 17141463c08dSmrg enum __DRIYUVColorSpace color_space, 17151463c08dSmrg enum __DRISampleRange sample_range, 17161463c08dSmrg enum __DRIChromaSiting horiz_siting, 17171463c08dSmrg enum __DRIChromaSiting vert_siting, 17181463c08dSmrg uint32_t flags, 17191463c08dSmrg unsigned *error, 17201463c08dSmrg void *loaderPrivate); 17211463c08dSmrg 17221463c08dSmrg /** 17231463c08dSmrg * Creates an image with implementation's favorite modifiers and the 17241463c08dSmrg * provided usage flags. 17251463c08dSmrg * 17261463c08dSmrg * This acts like createImageWithModifiers except usage is also specified. 17271463c08dSmrg * 17281463c08dSmrg * The created image should be destroyed with destroyImage(). 17291463c08dSmrg * 17301463c08dSmrg * Returns the new DRIimage. The chosen modifier can be obtained later on 17311463c08dSmrg * and passed back to things like the kernel's AddFB2 interface. 17321463c08dSmrg * 17331463c08dSmrg * \sa __DRIimageRec::createImage 17341463c08dSmrg * 17351463c08dSmrg * \since 19 17361463c08dSmrg */ 17371463c08dSmrg __DRIimage *(*createImageWithModifiers2)(__DRIscreen *screen, 17381463c08dSmrg int width, int height, int format, 17391463c08dSmrg const uint64_t *modifiers, 17401463c08dSmrg const unsigned int modifier_count, 17411463c08dSmrg unsigned int use, 17421463c08dSmrg void *loaderPrivate); 1743cdc920a0Smrg}; 1744cdc920a0Smrg 17453464ebd5Sriastradh 1746cdc920a0Smrg/** 1747cdc920a0Smrg * This extension must be implemented by the loader and passed to the 1748cdc920a0Smrg * driver at screen creation time. The EGLImage entry points in the 1749cdc920a0Smrg * various client APIs take opaque EGLImage handles and use this 1750cdc920a0Smrg * extension to map them to a __DRIimage. At version 1, this 1751cdc920a0Smrg * extensions allows mapping EGLImage pointers to __DRIimage pointers, 1752cdc920a0Smrg * but future versions could support other EGLImage-like, opaque types 1753cdc920a0Smrg * with new lookup functions. 1754cdc920a0Smrg */ 1755cdc920a0Smrg#define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP" 17561463c08dSmrg#define __DRI_IMAGE_LOOKUP_VERSION 2 1757cdc920a0Smrg 1758cdc920a0Smrgtypedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension; 1759cdc920a0Smrgstruct __DRIimageLookupExtensionRec { 1760cdc920a0Smrg __DRIextension base; 1761cdc920a0Smrg 17621463c08dSmrg /** 17631463c08dSmrg * Lookup EGLImage without validated. Equivalent to call 17641463c08dSmrg * validateEGLImage() then lookupEGLImageValidated(). 17651463c08dSmrg * 17661463c08dSmrg * \since 1 17671463c08dSmrg */ 17683464ebd5Sriastradh __DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image, 1769cdc920a0Smrg void *loaderPrivate); 17701463c08dSmrg 17711463c08dSmrg /** 17721463c08dSmrg * Check if EGLImage is associated with the EGL display before lookup with 17731463c08dSmrg * lookupEGLImageValidated(). It will hold EGLDisplay.Mutex, so is separated 17741463c08dSmrg * out from lookupEGLImage() to avoid deadlock. 17751463c08dSmrg * 17761463c08dSmrg * \since 2 17771463c08dSmrg */ 17781463c08dSmrg unsigned char (*validateEGLImage)(void *image, void *loaderPrivate); 17791463c08dSmrg 17801463c08dSmrg /** 17811463c08dSmrg * Lookup EGLImage after validateEGLImage(). No lock in this function. 17821463c08dSmrg * 17831463c08dSmrg * \since 2 17841463c08dSmrg */ 17851463c08dSmrg __DRIimage *(*lookupEGLImageValidated)(void *image, void *loaderPrivate); 1786cdc920a0Smrg}; 1787cdc920a0Smrg 17883464ebd5Sriastradh/** 17893464ebd5Sriastradh * This extension allows for common DRI2 options 17903464ebd5Sriastradh */ 17913464ebd5Sriastradh#define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY" 17921463c08dSmrg#define __DRI2_CONFIG_QUERY_VERSION 2 17933464ebd5Sriastradh 17943464ebd5Sriastradhtypedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension; 17953464ebd5Sriastradhstruct __DRI2configQueryExtensionRec { 17963464ebd5Sriastradh __DRIextension base; 17973464ebd5Sriastradh 1798af69d88dSmrg int (*configQueryb)(__DRIscreen *screen, const char *var, unsigned char *val); 1799af69d88dSmrg int (*configQueryi)(__DRIscreen *screen, const char *var, int *val); 1800af69d88dSmrg int (*configQueryf)(__DRIscreen *screen, const char *var, float *val); 18011463c08dSmrg int (*configQuerys)(__DRIscreen *screen, const char *var, char **val); 1802af69d88dSmrg}; 1803af69d88dSmrg 1804af69d88dSmrg/** 1805af69d88dSmrg * Robust context driver extension. 1806af69d88dSmrg * 1807af69d88dSmrg * Existence of this extension means the driver can accept the 1808af69d88dSmrg * \c __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag and the 1809af69d88dSmrg * \c __DRI_CTX_ATTRIB_RESET_STRATEGY attribute in 1810af69d88dSmrg * \c __DRIdri2ExtensionRec::createContextAttribs. 1811af69d88dSmrg */ 1812af69d88dSmrg#define __DRI2_ROBUSTNESS "DRI_Robustness" 1813af69d88dSmrg#define __DRI2_ROBUSTNESS_VERSION 1 1814af69d88dSmrg 1815af69d88dSmrgtypedef struct __DRIrobustnessExtensionRec __DRIrobustnessExtension; 1816af69d88dSmrgstruct __DRIrobustnessExtensionRec { 1817af69d88dSmrg __DRIextension base; 18183464ebd5Sriastradh}; 1819af69d88dSmrg 182001e04c3fSmrg/** 182101e04c3fSmrg * No-error context driver extension. 182201e04c3fSmrg * 182301e04c3fSmrg * Existence of this extension means the driver can accept the 182401e04c3fSmrg * __DRI_CTX_FLAG_NO_ERROR flag. 182501e04c3fSmrg */ 182601e04c3fSmrg#define __DRI2_NO_ERROR "DRI_NoError" 182701e04c3fSmrg#define __DRI2_NO_ERROR_VERSION 1 182801e04c3fSmrg 182901e04c3fSmrgtypedef struct __DRInoErrorExtensionRec { 183001e04c3fSmrg __DRIextension base; 183101e04c3fSmrg} __DRInoErrorExtension; 183201e04c3fSmrg 183301e04c3fSmrg/* 183401e04c3fSmrg * Flush control driver extension. 183501e04c3fSmrg * 183601e04c3fSmrg * Existence of this extension means the driver can accept the 183701e04c3fSmrg * \c __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR attribute in 183801e04c3fSmrg * \c __DRIdri2ExtensionRec::createContextAttribs. 183901e04c3fSmrg */ 184001e04c3fSmrg#define __DRI2_FLUSH_CONTROL "DRI_FlushControl" 184101e04c3fSmrg#define __DRI2_FLUSH_CONTROL_VERSION 1 184201e04c3fSmrg 184301e04c3fSmrgtypedef struct __DRI2flushControlExtensionRec __DRI2flushControlExtension; 184401e04c3fSmrgstruct __DRI2flushControlExtensionRec { 184501e04c3fSmrg __DRIextension base; 184601e04c3fSmrg}; 184701e04c3fSmrg 1848af69d88dSmrg/** 1849af69d88dSmrg * DRI config options extension. 1850af69d88dSmrg * 1851af69d88dSmrg * This extension provides the XML string containing driver options for use by 1852af69d88dSmrg * the loader in supporting the driconf application. 185301e04c3fSmrg * 185401e04c3fSmrg * v2: 185501e04c3fSmrg * - Add the getXml getter function which allows the driver more flexibility in 185601e04c3fSmrg * how the XML is provided. 185701e04c3fSmrg * - Deprecate the direct xml pointer. It is only provided as a fallback for 185801e04c3fSmrg * older versions of libGL and must not be used by clients that are aware of 185901e04c3fSmrg * the newer version. Future driver versions may set it to NULL. 1860af69d88dSmrg */ 1861af69d88dSmrg#define __DRI_CONFIG_OPTIONS "DRI_ConfigOptions" 186201e04c3fSmrg#define __DRI_CONFIG_OPTIONS_VERSION 2 1863af69d88dSmrg 1864af69d88dSmrgtypedef struct __DRIconfigOptionsExtensionRec { 1865af69d88dSmrg __DRIextension base; 186601e04c3fSmrg const char *xml; /**< deprecated since v2, use getXml instead */ 186701e04c3fSmrg 186801e04c3fSmrg /** 186901e04c3fSmrg * Get an XML string that describes available driver options for use by a 187001e04c3fSmrg * config application. 187101e04c3fSmrg * 187201e04c3fSmrg * The returned string must be heap-allocated. The caller is responsible for 187301e04c3fSmrg * freeing it. 187401e04c3fSmrg */ 187501e04c3fSmrg char *(*getXml)(const char *driver_name); 1876af69d88dSmrg} __DRIconfigOptionsExtension; 1877af69d88dSmrg 1878af69d88dSmrg/** 1879af69d88dSmrg * This extension provides a driver vtable to a set of common driver helper 1880af69d88dSmrg * functions (driCoreExtension, driDRI2Extension) within the driver 1881af69d88dSmrg * implementation, as opposed to having to pass them through a global 1882af69d88dSmrg * variable. 1883af69d88dSmrg * 1884af69d88dSmrg * It is not intended to be public API to the actual loader, and the vtable 1885af69d88dSmrg * layout may change at any time. 1886af69d88dSmrg */ 1887af69d88dSmrg#define __DRI_DRIVER_VTABLE "DRI_DriverVtable" 1888af69d88dSmrg#define __DRI_DRIVER_VTABLE_VERSION 1 1889af69d88dSmrg 1890af69d88dSmrgtypedef struct __DRIDriverVtableExtensionRec { 1891af69d88dSmrg __DRIextension base; 1892af69d88dSmrg const struct __DriverAPIRec *vtable; 1893af69d88dSmrg} __DRIDriverVtableExtension; 1894af69d88dSmrg 1895af69d88dSmrg/** 1896af69d88dSmrg * Query renderer driver extension 1897af69d88dSmrg * 1898af69d88dSmrg * This allows the window system layer (either EGL or GLX) to query aspects of 1899af69d88dSmrg * hardware and driver support without creating a context. 1900af69d88dSmrg */ 1901af69d88dSmrg#define __DRI2_RENDERER_QUERY "DRI_RENDERER_QUERY" 1902af69d88dSmrg#define __DRI2_RENDERER_QUERY_VERSION 1 1903af69d88dSmrg 1904af69d88dSmrg#define __DRI2_RENDERER_VENDOR_ID 0x0000 1905af69d88dSmrg#define __DRI2_RENDERER_DEVICE_ID 0x0001 1906af69d88dSmrg#define __DRI2_RENDERER_VERSION 0x0002 1907af69d88dSmrg#define __DRI2_RENDERER_ACCELERATED 0x0003 1908af69d88dSmrg#define __DRI2_RENDERER_VIDEO_MEMORY 0x0004 1909af69d88dSmrg#define __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE 0x0005 1910af69d88dSmrg#define __DRI2_RENDERER_PREFERRED_PROFILE 0x0006 1911af69d88dSmrg#define __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION 0x0007 1912af69d88dSmrg#define __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION 0x0008 1913af69d88dSmrg#define __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION 0x0009 1914af69d88dSmrg#define __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION 0x000a 191501e04c3fSmrg#define __DRI2_RENDERER_HAS_TEXTURE_3D 0x000b 191601e04c3fSmrg/* Whether there is an sRGB format support for every supported 32-bit UNORM 191701e04c3fSmrg * color format. 191801e04c3fSmrg */ 191901e04c3fSmrg#define __DRI2_RENDERER_HAS_FRAMEBUFFER_SRGB 0x000c 192001e04c3fSmrg 192101e04c3fSmrg/* Bitmaks of supported/available context priorities - must match 192201e04c3fSmrg * __EGL_CONTEXT_PRIORITY_LOW_BIT et al 192301e04c3fSmrg */ 192401e04c3fSmrg#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY 0x000d 192501e04c3fSmrg#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_LOW (1 << 0) 192601e04c3fSmrg#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_MEDIUM (1 << 1) 192701e04c3fSmrg#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_HIGH (1 << 2) 1928af69d88dSmrg 19291463c08dSmrg#define __DRI2_RENDERER_HAS_PROTECTED_CONTENT 0x000e 19301463c08dSmrg#define __DRI2_RENDERER_PREFER_BACK_BUFFER_REUSE 0x000f 19311463c08dSmrg 1932af69d88dSmrgtypedef struct __DRI2rendererQueryExtensionRec __DRI2rendererQueryExtension; 1933af69d88dSmrgstruct __DRI2rendererQueryExtensionRec { 1934af69d88dSmrg __DRIextension base; 1935af69d88dSmrg 1936af69d88dSmrg int (*queryInteger)(__DRIscreen *screen, int attribute, unsigned int *val); 1937af69d88dSmrg int (*queryString)(__DRIscreen *screen, int attribute, const char **val); 1938af69d88dSmrg}; 1939af69d88dSmrg 1940af69d88dSmrg/** 1941af69d88dSmrg * Image Loader extension. Drivers use this to allocate color buffers 1942af69d88dSmrg */ 1943af69d88dSmrg 194401e04c3fSmrg/** 194501e04c3fSmrg * See __DRIimageLoaderExtensionRec::getBuffers::buffer_mask. 194601e04c3fSmrg */ 1947af69d88dSmrgenum __DRIimageBufferMask { 1948af69d88dSmrg __DRI_IMAGE_BUFFER_BACK = (1 << 0), 194901e04c3fSmrg __DRI_IMAGE_BUFFER_FRONT = (1 << 1), 195001e04c3fSmrg 195101e04c3fSmrg /** 195201e04c3fSmrg * A buffer shared between application and compositor. The buffer may be 195301e04c3fSmrg * simultaneously accessed by each. 195401e04c3fSmrg * 195501e04c3fSmrg * A shared buffer is equivalent to an EGLSurface whose EGLConfig contains 195601e04c3fSmrg * EGL_MUTABLE_RENDER_BUFFER_BIT_KHR and whose active EGL_RENDER_BUFFER (as 195701e04c3fSmrg * opposed to any pending, requested change to EGL_RENDER_BUFFER) is 195801e04c3fSmrg * EGL_SINGLE_BUFFER. 195901e04c3fSmrg * 196001e04c3fSmrg * If buffer_mask contains __DRI_IMAGE_BUFFER_SHARED, then must contains no 196101e04c3fSmrg * other bits. As a corollary, a __DRIdrawable that has a "shared" buffer 196201e04c3fSmrg * has no front nor back buffer. 196301e04c3fSmrg * 196401e04c3fSmrg * The loader returns __DRI_IMAGE_BUFFER_SHARED in buffer_mask if and only 196501e04c3fSmrg * if: 196601e04c3fSmrg * - The loader supports __DRI_MUTABLE_RENDER_BUFFER_LOADER. 196701e04c3fSmrg * - The driver supports __DRI_MUTABLE_RENDER_BUFFER_DRIVER. 196801e04c3fSmrg * - The EGLConfig of the drawable EGLSurface contains 196901e04c3fSmrg * EGL_MUTABLE_RENDER_BUFFER_BIT_KHR. 197001e04c3fSmrg * - The EGLContext's EGL_RENDER_BUFFER is EGL_SINGLE_BUFFER. 197101e04c3fSmrg * Equivalently, the EGLSurface's active EGL_RENDER_BUFFER (as 197201e04c3fSmrg * opposed to any pending, requested change to EGL_RENDER_BUFFER) is 197301e04c3fSmrg * EGL_SINGLE_BUFFER. (See the EGL 1.5 and 197401e04c3fSmrg * EGL_KHR_mutable_render_buffer spec for details about "pending" vs 197501e04c3fSmrg * "active" EGL_RENDER_BUFFER state). 197601e04c3fSmrg * 197701e04c3fSmrg * A shared buffer is similar to a front buffer in that all rendering to the 197801e04c3fSmrg * buffer should appear promptly on the screen. It is different from 197901e04c3fSmrg * a front buffer in that its behavior is independent from the 198001e04c3fSmrg * GL_DRAW_BUFFER state. Specifically, if GL_DRAW_FRAMEBUFFER is 0 and the 198101e04c3fSmrg * __DRIdrawable's buffer_mask is __DRI_IMAGE_BUFFER_SHARED, then all 198201e04c3fSmrg * rendering should appear promptly on the screen if GL_DRAW_BUFFER is not 198301e04c3fSmrg * GL_NONE. 198401e04c3fSmrg * 198501e04c3fSmrg * The difference between a shared buffer and a front buffer is motivated 198601e04c3fSmrg * by the constraints of Android and OpenGL ES. OpenGL ES does not support 198701e04c3fSmrg * front-buffer rendering. Android's SurfaceFlinger protocol provides the 198801e04c3fSmrg * EGL driver only a back buffer and no front buffer. The shared buffer 198901e04c3fSmrg * mode introduced by EGL_KHR_mutable_render_buffer is a backdoor though 199001e04c3fSmrg * EGL that allows Android OpenGL ES applications to render to what is 199101e04c3fSmrg * effectively the front buffer, a backdoor that required no change to the 199201e04c3fSmrg * OpenGL ES API and little change to the SurfaceFlinger API. 199301e04c3fSmrg */ 199401e04c3fSmrg __DRI_IMAGE_BUFFER_SHARED = (1 << 2), 1995af69d88dSmrg}; 1996af69d88dSmrg 1997af69d88dSmrgstruct __DRIimageList { 1998af69d88dSmrg uint32_t image_mask; 1999af69d88dSmrg __DRIimage *back; 2000af69d88dSmrg __DRIimage *front; 2001af69d88dSmrg}; 2002af69d88dSmrg 2003af69d88dSmrg#define __DRI_IMAGE_LOADER "DRI_IMAGE_LOADER" 20041463c08dSmrg#define __DRI_IMAGE_LOADER_VERSION 4 2005af69d88dSmrg 2006af69d88dSmrgstruct __DRIimageLoaderExtensionRec { 2007af69d88dSmrg __DRIextension base; 2008af69d88dSmrg 2009af69d88dSmrg /** 2010af69d88dSmrg * Allocate color buffers. 2011af69d88dSmrg * 2012af69d88dSmrg * \param driDrawable 2013af69d88dSmrg * \param width Width of allocated buffers 2014af69d88dSmrg * \param height Height of allocated buffers 2015af69d88dSmrg * \param format one of __DRI_IMAGE_FORMAT_* 2016af69d88dSmrg * \param stamp Address of variable to be updated when 2017af69d88dSmrg * getBuffers must be called again 2018af69d88dSmrg * \param loaderPrivate The loaderPrivate for driDrawable 201901e04c3fSmrg * \param buffer_mask Set of buffers to allocate. A bitmask of 202001e04c3fSmrg * __DRIimageBufferMask. 2021af69d88dSmrg * \param buffers Returned buffers 2022af69d88dSmrg */ 2023af69d88dSmrg int (*getBuffers)(__DRIdrawable *driDrawable, 2024af69d88dSmrg unsigned int format, 2025af69d88dSmrg uint32_t *stamp, 2026af69d88dSmrg void *loaderPrivate, 2027af69d88dSmrg uint32_t buffer_mask, 2028af69d88dSmrg struct __DRIimageList *buffers); 2029af69d88dSmrg 2030af69d88dSmrg /** 2031af69d88dSmrg * Flush pending front-buffer rendering 2032af69d88dSmrg * 2033af69d88dSmrg * Any rendering that has been performed to the 2034af69d88dSmrg * fake front will be flushed to the front 2035af69d88dSmrg * 2036af69d88dSmrg * \param driDrawable Drawable whose front-buffer is to be flushed 2037af69d88dSmrg * \param loaderPrivate Loader's private data that was previously passed 2038af69d88dSmrg * into __DRIdri2ExtensionRec::createNewDrawable 2039af69d88dSmrg */ 2040af69d88dSmrg void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate); 204101e04c3fSmrg 204201e04c3fSmrg /** 204301e04c3fSmrg * Return a loader capability value. If the loader doesn't know the enum, 204401e04c3fSmrg * it will return 0. 204501e04c3fSmrg * 204601e04c3fSmrg * \since 2 204701e04c3fSmrg */ 204801e04c3fSmrg unsigned (*getCapability)(void *loaderPrivate, enum dri_loader_cap cap); 204901e04c3fSmrg 205001e04c3fSmrg /** 205101e04c3fSmrg * Flush swap buffers 205201e04c3fSmrg * 205301e04c3fSmrg * Make sure any outstanding swap buffers have been submitted to the 205401e04c3fSmrg * device. 205501e04c3fSmrg * 205601e04c3fSmrg * \param driDrawable Drawable whose swaps need to be flushed 205701e04c3fSmrg * \param loaderPrivate Loader's private data that was previously passed 205801e04c3fSmrg * into __DRIdri2ExtensionRec::createNewDrawable 205901e04c3fSmrg * 206001e04c3fSmrg * \since 3 206101e04c3fSmrg */ 206201e04c3fSmrg void (*flushSwapBuffers)(__DRIdrawable *driDrawable, void *loaderPrivate); 20631463c08dSmrg 20641463c08dSmrg /** 20651463c08dSmrg * Clean up any loader state associated with an image. 20661463c08dSmrg * 20671463c08dSmrg * \param loaderPrivate Loader's private data that was previously passed 20681463c08dSmrg * into a __DRIimageExtensionRec::createImage function 20691463c08dSmrg * \since 4 20701463c08dSmrg */ 20711463c08dSmrg void (*destroyLoaderImageState)(void *loaderPrivate); 2072af69d88dSmrg}; 2073af69d88dSmrg 2074af69d88dSmrg/** 2075af69d88dSmrg * DRI extension. 2076af69d88dSmrg */ 2077af69d88dSmrg 2078af69d88dSmrg#define __DRI_IMAGE_DRIVER "DRI_IMAGE_DRIVER" 2079af69d88dSmrg#define __DRI_IMAGE_DRIVER_VERSION 1 2080af69d88dSmrg 2081af69d88dSmrgstruct __DRIimageDriverExtensionRec { 2082af69d88dSmrg __DRIextension base; 2083af69d88dSmrg 2084af69d88dSmrg /* Common DRI functions, shared with DRI2 */ 2085af69d88dSmrg __DRIcreateNewScreen2Func createNewScreen2; 2086af69d88dSmrg __DRIcreateNewDrawableFunc createNewDrawable; 2087af69d88dSmrg __DRIcreateContextAttribsFunc createContextAttribs; 2088af69d88dSmrg __DRIgetAPIMaskFunc getAPIMask; 2089af69d88dSmrg}; 2090af69d88dSmrg 209101e04c3fSmrg/** 209201e04c3fSmrg * Background callable loader extension. 209301e04c3fSmrg * 209401e04c3fSmrg * Loaders expose this extension to indicate to drivers that they are capable 209501e04c3fSmrg * of handling callbacks from the driver's background drawing threads. 209601e04c3fSmrg */ 209701e04c3fSmrg#define __DRI_BACKGROUND_CALLABLE "DRI_BackgroundCallable" 209801e04c3fSmrg#define __DRI_BACKGROUND_CALLABLE_VERSION 1 209901e04c3fSmrg 210001e04c3fSmrgtypedef struct __DRIbackgroundCallableExtensionRec __DRIbackgroundCallableExtension; 210101e04c3fSmrgstruct __DRIbackgroundCallableExtensionRec { 210201e04c3fSmrg __DRIextension base; 210301e04c3fSmrg 210401e04c3fSmrg /** 210501e04c3fSmrg * Indicate that this thread is being used by the driver as a background 210601e04c3fSmrg * drawing thread which may make callbacks to the loader. 210701e04c3fSmrg * 210801e04c3fSmrg * \param loaderPrivate is the value that was passed to to the driver when 210901e04c3fSmrg * the context was created. This can be used by the loader to identify 211001e04c3fSmrg * which context any callbacks are associated with. 211101e04c3fSmrg * 211201e04c3fSmrg * If this function is called more than once from any given thread, each 211301e04c3fSmrg * subsequent call overrides the loaderPrivate data that was passed in the 211401e04c3fSmrg * previous call. The driver can take advantage of this to re-use a 211501e04c3fSmrg * background thread to perform drawing on behalf of multiple contexts. 211601e04c3fSmrg * 211701e04c3fSmrg * It is permissible for the driver to call this function from a 211801e04c3fSmrg * non-background thread (i.e. a thread that has already been bound to a 211901e04c3fSmrg * context using __DRIcoreExtensionRec::bindContext()); when this happens, 212001e04c3fSmrg * the \c loaderPrivate pointer must be equal to the pointer that was 212101e04c3fSmrg * passed to the driver when the currently bound context was created. 212201e04c3fSmrg * 212301e04c3fSmrg * This call should execute quickly enough that the driver can call it with 212401e04c3fSmrg * impunity whenever a background thread starts performing drawing 212501e04c3fSmrg * operations (e.g. it should just set a thread-local variable). 212601e04c3fSmrg */ 212701e04c3fSmrg void (*setBackgroundContext)(void *loaderPrivate); 212801e04c3fSmrg 212901e04c3fSmrg /** 213001e04c3fSmrg * Indicate that it is multithread safe to use glthread. For GLX/EGL 213101e04c3fSmrg * platforms using Xlib, that involves calling XInitThreads, before 213201e04c3fSmrg * opening an X display. 213301e04c3fSmrg * 213401e04c3fSmrg * Note: only supported if extension version is at least 2. 213501e04c3fSmrg * 213601e04c3fSmrg * \param loaderPrivate is the value that was passed to to the driver when 213701e04c3fSmrg * the context was created. This can be used by the loader to identify 213801e04c3fSmrg * which context any callbacks are associated with. 213901e04c3fSmrg */ 21401463c08dSmrg unsigned char (*isThreadSafe)(void *loaderPrivate); 214101e04c3fSmrg}; 214201e04c3fSmrg 214301e04c3fSmrg/** 214401e04c3fSmrg * The driver portion of EGL_KHR_mutable_render_buffer. 214501e04c3fSmrg * 214601e04c3fSmrg * If the driver creates a __DRIconfig with 214701e04c3fSmrg * __DRI_ATTRIB_MUTABLE_RENDER_BUFFER, then it must support this extension. 214801e04c3fSmrg * 214901e04c3fSmrg * To support this extension: 215001e04c3fSmrg * 215101e04c3fSmrg * - The driver should create at least one __DRIconfig with 215201e04c3fSmrg * __DRI_ATTRIB_MUTABLE_RENDER_BUFFER. This is strongly recommended but 215301e04c3fSmrg * not required. 215401e04c3fSmrg * 215501e04c3fSmrg * - The driver must be able to handle __DRI_IMAGE_BUFFER_SHARED if 215601e04c3fSmrg * returned by __DRIimageLoaderExtension:getBuffers(). 215701e04c3fSmrg * 215801e04c3fSmrg * - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must call 215901e04c3fSmrg * __DRImutableRenderBufferLoaderExtension::displaySharedBuffer() in 216001e04c3fSmrg * response to glFlush and glFinish. (This requirement is not documented 216101e04c3fSmrg * in EGL_KHR_mutable_render_buffer, but is a de-facto requirement in the 216201e04c3fSmrg * Android ecosystem. Android applications expect that glFlush will 216301e04c3fSmrg * immediately display the buffer when in shared buffer mode, and Android 216401e04c3fSmrg * drivers comply with this expectation). It :may: call 216501e04c3fSmrg * displaySharedBuffer() more often than required. 216601e04c3fSmrg * 216701e04c3fSmrg * - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must ensure that the 216801e04c3fSmrg * buffer is always in a format compatible for display because the 216901e04c3fSmrg * display engine (usually SurfaceFlinger or hwcomposer) may display the 217001e04c3fSmrg * image at any time, even concurrently with 3D rendering. For example, 217101e04c3fSmrg * display hardware and the GL hardware may be able to access the buffer 217201e04c3fSmrg * simultaneously. In particular, if the buffer is compressed then take 217301e04c3fSmrg * care that SurfaceFlinger and hwcomposer can consume the compression 217401e04c3fSmrg * format. 217501e04c3fSmrg * 217601e04c3fSmrg * \see __DRI_IMAGE_BUFFER_SHARED 217701e04c3fSmrg * \see __DRI_ATTRIB_MUTABLE_RENDER_BUFFER 217801e04c3fSmrg * \see __DRI_MUTABLE_RENDER_BUFFER_LOADER 217901e04c3fSmrg */ 218001e04c3fSmrg#define __DRI_MUTABLE_RENDER_BUFFER_DRIVER "DRI_MutableRenderBufferDriver" 218101e04c3fSmrg#define __DRI_MUTABLE_RENDER_BUFFER_DRIVER_VERSION 1 218201e04c3fSmrg 218301e04c3fSmrgtypedef struct __DRImutableRenderBufferDriverExtensionRec __DRImutableRenderBufferDriverExtension; 218401e04c3fSmrgstruct __DRImutableRenderBufferDriverExtensionRec { 218501e04c3fSmrg __DRIextension base; 218601e04c3fSmrg}; 218701e04c3fSmrg 218801e04c3fSmrg/** 218901e04c3fSmrg * The loader portion of EGL_KHR_mutable_render_buffer. 219001e04c3fSmrg * 219101e04c3fSmrg * Requires loader extension DRI_IMAGE_LOADER, through which the loader sends 219201e04c3fSmrg * __DRI_IMAGE_BUFFER_SHARED to the driver. 219301e04c3fSmrg * 219401e04c3fSmrg * \see __DRI_MUTABLE_RENDER_BUFFER_DRIVER 219501e04c3fSmrg */ 219601e04c3fSmrg#define __DRI_MUTABLE_RENDER_BUFFER_LOADER "DRI_MutableRenderBufferLoader" 219701e04c3fSmrg#define __DRI_MUTABLE_RENDER_BUFFER_LOADER_VERSION 1 219801e04c3fSmrg 219901e04c3fSmrgtypedef struct __DRImutableRenderBufferLoaderExtensionRec __DRImutableRenderBufferLoaderExtension; 220001e04c3fSmrgstruct __DRImutableRenderBufferLoaderExtensionRec { 220101e04c3fSmrg __DRIextension base; 220201e04c3fSmrg 220301e04c3fSmrg /** 220401e04c3fSmrg * Inform the display engine (that is, SurfaceFlinger and/or hwcomposer) 220501e04c3fSmrg * that the __DRIdrawable has new content. 220601e04c3fSmrg * 220701e04c3fSmrg * The display engine may ignore this call, for example, if it continually 220801e04c3fSmrg * refreshes and displays the buffer on every frame, as in 220901e04c3fSmrg * EGL_ANDROID_front_buffer_auto_refresh. On the other extreme, the display 221001e04c3fSmrg * engine may refresh and display the buffer only in frames in which the 221101e04c3fSmrg * driver calls this. 221201e04c3fSmrg * 221301e04c3fSmrg * If the fence_fd is not -1, then the display engine will display the 221401e04c3fSmrg * buffer only after the fence signals. 221501e04c3fSmrg * 221601e04c3fSmrg * The drawable's current __DRIimageBufferMask, as returned by 221701e04c3fSmrg * __DRIimageLoaderExtension::getBuffers(), must be 221801e04c3fSmrg * __DRI_IMAGE_BUFFER_SHARED. 221901e04c3fSmrg */ 222001e04c3fSmrg void (*displaySharedBuffer)(__DRIdrawable *drawable, int fence_fd, 222101e04c3fSmrg void *loaderPrivate); 222201e04c3fSmrg}; 222301e04c3fSmrg 22247117f1b4Smrg#endif 2225