1af69d88dSmrg/* 2af69d88dSmrg * Copyright © 2013 Keith Packard 3af69d88dSmrg * 4af69d88dSmrg * Permission to use, copy, modify, distribute, and sell this software and its 5af69d88dSmrg * documentation for any purpose is hereby granted without fee, provided that 6af69d88dSmrg * the above copyright notice appear in all copies and that both that copyright 7af69d88dSmrg * notice and this permission notice appear in supporting documentation, and 8af69d88dSmrg * that the name of the copyright holders not be used in advertising or 9af69d88dSmrg * publicity pertaining to distribution of the software without specific, 10af69d88dSmrg * written prior permission. The copyright holders make no representations 11af69d88dSmrg * about the suitability of this software for any purpose. It is provided "as 12af69d88dSmrg * is" without express or implied warranty. 13af69d88dSmrg * 14af69d88dSmrg * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 15af69d88dSmrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO 16af69d88dSmrg * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR 17af69d88dSmrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 18af69d88dSmrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 19af69d88dSmrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 20af69d88dSmrg * OF THIS SOFTWARE. 21af69d88dSmrg */ 22af69d88dSmrg 23af69d88dSmrg/* This file was derived from dri2_priv.h which carries the following 24af69d88dSmrg * copyright: 25af69d88dSmrg * 26af69d88dSmrg * Copyright © 2008 Red Hat, Inc. 27af69d88dSmrg * 28af69d88dSmrg * Permission is hereby granted, free of charge, to any person obtaining a 29af69d88dSmrg * copy of this software and associated documentation files (the "Soft- 30af69d88dSmrg * ware"), to deal in the Software without restriction, including without 31af69d88dSmrg * limitation the rights to use, copy, modify, merge, publish, distribute, 32af69d88dSmrg * and/or sell copies of the Software, and to permit persons to whom the 33af69d88dSmrg * Software is furnished to do so, provided that the above copyright 34af69d88dSmrg * notice(s) and this permission notice appear in all copies of the Soft- 35af69d88dSmrg * ware and that both the above copyright notice(s) and this permission 36af69d88dSmrg * notice appear in supporting documentation. 37af69d88dSmrg * 38af69d88dSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 39af69d88dSmrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 40af69d88dSmrg * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY 41af69d88dSmrg * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN 42af69d88dSmrg * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE- 43af69d88dSmrg * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 44af69d88dSmrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 45af69d88dSmrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR- 46af69d88dSmrg * MANCE OF THIS SOFTWARE. 47af69d88dSmrg * 48af69d88dSmrg * Except as contained in this notice, the name of a copyright holder shall 49af69d88dSmrg * not be used in advertising or otherwise to promote the sale, use or 50af69d88dSmrg * other dealings in this Software without prior written authorization of 51af69d88dSmrg * the copyright holder. 52af69d88dSmrg * 53af69d88dSmrg * Authors: 54af69d88dSmrg * Kristian Høgsberg (krh@redhat.com) 55af69d88dSmrg */ 56af69d88dSmrg 57af69d88dSmrg#include <xcb/xcb.h> 58af69d88dSmrg#include <xcb/dri3.h> 59af69d88dSmrg#include <xcb/present.h> 60af69d88dSmrg#include <xcb/sync.h> 61af69d88dSmrg 6201e04c3fSmrg#include "loader_dri3_helper.h" 6301e04c3fSmrg 647ec681f3Smrg/* From driconf.h, user exposed so should be stable */ 65af69d88dSmrg#define DRI_CONF_VBLANK_NEVER 0 66af69d88dSmrg#define DRI_CONF_VBLANK_DEF_INTERVAL_0 1 67af69d88dSmrg#define DRI_CONF_VBLANK_DEF_INTERVAL_1 2 68af69d88dSmrg#define DRI_CONF_VBLANK_ALWAYS_SYNC 3 69af69d88dSmrg 70af69d88dSmrgstruct dri3_display 71af69d88dSmrg{ 72af69d88dSmrg __GLXDRIdisplay base; 73af69d88dSmrg 74af69d88dSmrg const __DRIextension **loader_extensions; 75af69d88dSmrg 76af69d88dSmrg /* DRI3 bits */ 77af69d88dSmrg int dri3Major; 78af69d88dSmrg int dri3Minor; 79af69d88dSmrg 80af69d88dSmrg /* Present bits */ 81af69d88dSmrg int hasPresent; 82af69d88dSmrg int presentMajor; 83af69d88dSmrg int presentMinor; 84af69d88dSmrg}; 85af69d88dSmrg 86af69d88dSmrgstruct dri3_screen { 87af69d88dSmrg struct glx_screen base; 88af69d88dSmrg 89af69d88dSmrg __DRIscreen *driScreen; 90af69d88dSmrg __GLXDRIscreen vtable; 91af69d88dSmrg 927ec681f3Smrg /* DRI screen is created for display GPU in case of prime. 937ec681f3Smrg * This screen is used to allocate linear_buffer from 947ec681f3Smrg * display GPU space in dri3_alloc_render_buffer() function. 957ec681f3Smrg */ 967ec681f3Smrg __DRIscreen *driScreenDisplayGPU; 977ec681f3Smrg 98af69d88dSmrg const __DRIimageExtension *image; 99af69d88dSmrg const __DRIimageDriverExtension *image_driver; 100af69d88dSmrg const __DRIcoreExtension *core; 101af69d88dSmrg const __DRI2flushExtension *f; 102af69d88dSmrg const __DRI2configQueryExtension *config; 103af69d88dSmrg const __DRItexBufferExtension *texBuffer; 104af69d88dSmrg const __DRI2rendererQueryExtension *rendererQuery; 10501e04c3fSmrg const __DRI2interopExtension *interop; 106af69d88dSmrg const __DRIconfig **driver_configs; 107af69d88dSmrg 108af69d88dSmrg void *driver; 109af69d88dSmrg int fd; 11001e04c3fSmrg bool is_different_gpu; 1117ec681f3Smrg bool prefer_back_buffer_reuse; 1127ec681f3Smrg 1137ec681f3Smrg /* fd for display GPU in case of prime */ 1147ec681f3Smrg int fd_display_gpu; 11501e04c3fSmrg 11601e04c3fSmrg int show_fps_interval; 117af69d88dSmrg 11801e04c3fSmrg struct loader_dri3_extensions loader_dri3_ext; 119af69d88dSmrg}; 120af69d88dSmrg 121af69d88dSmrgstruct dri3_context 122af69d88dSmrg{ 123af69d88dSmrg struct glx_context base; 124af69d88dSmrg __DRIcontext *driContext; 125af69d88dSmrg}; 126af69d88dSmrg 127af69d88dSmrgstruct dri3_drawable { 128af69d88dSmrg __GLXDRIdrawable base; 12901e04c3fSmrg struct loader_dri3_drawable loader_drawable; 130af69d88dSmrg 13101e04c3fSmrg /* LIBGL_SHOW_FPS support */ 13201e04c3fSmrg uint64_t previous_ust; 13301e04c3fSmrg unsigned frames; 13401e04c3fSmrg}; 135af69d88dSmrg 136af69d88dSmrg 13701e04c3fSmrg_X_HIDDEN int 13801e04c3fSmrgdri3_query_renderer_integer(struct glx_screen *base, int attribute, 13901e04c3fSmrg unsigned int *value); 140af69d88dSmrg 14101e04c3fSmrg_X_HIDDEN int 14201e04c3fSmrgdri3_query_renderer_string(struct glx_screen *base, int attribute, 14301e04c3fSmrg const char **value); 144af69d88dSmrg 14501e04c3fSmrg_X_HIDDEN int 14601e04c3fSmrgdri3_interop_query_device_info(struct glx_context *ctx, 14701e04c3fSmrg struct mesa_glinterop_device_info *out); 148af69d88dSmrg 14901e04c3fSmrg_X_HIDDEN int 15001e04c3fSmrgdri3_interop_export_object(struct glx_context *ctx, 15101e04c3fSmrg struct mesa_glinterop_export_in *in, 15201e04c3fSmrg struct mesa_glinterop_export_out *out); 153