1bf215546Sopenharmony_ci/************************************************************************** 2bf215546Sopenharmony_ci * 3bf215546Sopenharmony_ci * Copyright 2009, VMware, Inc. 4bf215546Sopenharmony_ci * All Rights Reserved. 5bf215546Sopenharmony_ci * 6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the 8bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 9bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 10bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to 11bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 12bf215546Sopenharmony_ci * the following conditions: 13bf215546Sopenharmony_ci * 14bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the 15bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions 16bf215546Sopenharmony_ci * of the Software. 17bf215546Sopenharmony_ci * 18bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21bf215546Sopenharmony_ci * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22bf215546Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23bf215546Sopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24bf215546Sopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25bf215546Sopenharmony_ci * 26bf215546Sopenharmony_ci **************************************************************************/ 27bf215546Sopenharmony_ci/* 28bf215546Sopenharmony_ci * Author: Keith Whitwell <keithw@vmware.com> 29bf215546Sopenharmony_ci * Author: Jakob Bornecrantz <wallbraker@gmail.com> 30bf215546Sopenharmony_ci */ 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci#ifndef DRI_SCREEN_H 33bf215546Sopenharmony_ci#define DRI_SCREEN_H 34bf215546Sopenharmony_ci 35bf215546Sopenharmony_ci#include "dri_util.h" 36bf215546Sopenharmony_ci 37bf215546Sopenharmony_ci#include "pipe/p_compiler.h" 38bf215546Sopenharmony_ci#include "pipe/p_context.h" 39bf215546Sopenharmony_ci#include "pipe/p_state.h" 40bf215546Sopenharmony_ci#include "frontend/api.h" 41bf215546Sopenharmony_ci#include "frontend/opencl_interop.h" 42bf215546Sopenharmony_ci#include "os/os_thread.h" 43bf215546Sopenharmony_ci#include "postprocess/filters.h" 44bf215546Sopenharmony_ci#include "kopper_interface.h" 45bf215546Sopenharmony_ci 46bf215546Sopenharmony_cistruct dri_context; 47bf215546Sopenharmony_cistruct dri_drawable; 48bf215546Sopenharmony_cistruct pipe_loader_device; 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_cistruct dri_screen 51bf215546Sopenharmony_ci{ 52bf215546Sopenharmony_ci /* st_api */ 53bf215546Sopenharmony_ci struct st_manager base; 54bf215546Sopenharmony_ci struct st_api *st_api; 55bf215546Sopenharmony_ci 56bf215546Sopenharmony_ci /* dri */ 57bf215546Sopenharmony_ci __DRIscreen *sPriv; 58bf215546Sopenharmony_ci boolean throttle; 59bf215546Sopenharmony_ci 60bf215546Sopenharmony_ci struct st_config_options options; 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_ci /* Which postprocessing filters are enabled. */ 63bf215546Sopenharmony_ci unsigned pp_enabled[PP_FILTERS]; 64bf215546Sopenharmony_ci 65bf215546Sopenharmony_ci /* drm */ 66bf215546Sopenharmony_ci int fd; 67bf215546Sopenharmony_ci boolean can_share_buffer; 68bf215546Sopenharmony_ci 69bf215546Sopenharmony_ci struct pipe_loader_device *dev; 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci /* gallium */ 72bf215546Sopenharmony_ci boolean d_depth_bits_last; 73bf215546Sopenharmony_ci boolean sd_depth_bits_last; 74bf215546Sopenharmony_ci boolean auto_fake_front; 75bf215546Sopenharmony_ci boolean has_reset_status_query; 76bf215546Sopenharmony_ci enum pipe_texture_target target; 77bf215546Sopenharmony_ci 78bf215546Sopenharmony_ci boolean swrast_no_present; 79bf215546Sopenharmony_ci 80bf215546Sopenharmony_ci /* hooks filled in by dri2 & drisw */ 81bf215546Sopenharmony_ci __DRIimage * (*lookup_egl_image)(struct dri_screen *ctx, void *handle); 82bf215546Sopenharmony_ci boolean (*validate_egl_image)(struct dri_screen *ctx, void *handle); 83bf215546Sopenharmony_ci __DRIimage * (*lookup_egl_image_validated)(struct dri_screen *ctx, void *handle); 84bf215546Sopenharmony_ci 85bf215546Sopenharmony_ci /* DRI exts that vary based on gallium pipe_screen caps. */ 86bf215546Sopenharmony_ci __DRIimageExtension image_extension; 87bf215546Sopenharmony_ci __DRI2bufferDamageExtension buffer_damage_extension; 88bf215546Sopenharmony_ci 89bf215546Sopenharmony_ci /* DRI exts on this screen. Populated at init time based on device caps. */ 90bf215546Sopenharmony_ci const __DRIextension *screen_extensions[14]; 91bf215546Sopenharmony_ci 92bf215546Sopenharmony_ci /* OpenCL interop */ 93bf215546Sopenharmony_ci mtx_t opencl_func_mutex; 94bf215546Sopenharmony_ci opencl_dri_event_add_ref_t opencl_dri_event_add_ref; 95bf215546Sopenharmony_ci opencl_dri_event_release_t opencl_dri_event_release; 96bf215546Sopenharmony_ci opencl_dri_event_wait_t opencl_dri_event_wait; 97bf215546Sopenharmony_ci opencl_dri_event_get_fence_t opencl_dri_event_get_fence; 98bf215546Sopenharmony_ci}; 99bf215546Sopenharmony_ci 100bf215546Sopenharmony_ci/** cast wrapper */ 101bf215546Sopenharmony_cistatic inline struct dri_screen * 102bf215546Sopenharmony_cidri_screen(__DRIscreen * sPriv) 103bf215546Sopenharmony_ci{ 104bf215546Sopenharmony_ci return (struct dri_screen *)sPriv->driverPrivate; 105bf215546Sopenharmony_ci} 106bf215546Sopenharmony_ci 107bf215546Sopenharmony_cistatic inline const __DRIkopperLoaderExtension * 108bf215546Sopenharmony_cidri_screen_get_kopper(struct dri_screen *screen) 109bf215546Sopenharmony_ci{ 110bf215546Sopenharmony_ci return screen->sPriv->kopper_loader; 111bf215546Sopenharmony_ci} 112bf215546Sopenharmony_ci 113bf215546Sopenharmony_cistruct __DRIimageRec { 114bf215546Sopenharmony_ci struct pipe_resource *texture; 115bf215546Sopenharmony_ci unsigned level; 116bf215546Sopenharmony_ci unsigned layer; 117bf215546Sopenharmony_ci uint32_t dri_format; 118bf215546Sopenharmony_ci uint32_t dri_fourcc; 119bf215546Sopenharmony_ci uint32_t dri_components; 120bf215546Sopenharmony_ci /* Provided by eglCreateImageKHR if creating from a 121bf215546Sopenharmony_ci * texture or a renderbuffer. 0 otherwise. 122bf215546Sopenharmony_ci */ 123bf215546Sopenharmony_ci uint32_t internal_format; 124bf215546Sopenharmony_ci unsigned use; 125bf215546Sopenharmony_ci unsigned plane; 126bf215546Sopenharmony_ci 127bf215546Sopenharmony_ci int in_fence_fd; 128bf215546Sopenharmony_ci 129bf215546Sopenharmony_ci void *loader_private; 130bf215546Sopenharmony_ci 131bf215546Sopenharmony_ci boolean imported_dmabuf; 132bf215546Sopenharmony_ci /** 133bf215546Sopenharmony_ci * Provided by EGL_EXT_image_dma_buf_import. 134bf215546Sopenharmony_ci */ 135bf215546Sopenharmony_ci enum __DRIYUVColorSpace yuv_color_space; 136bf215546Sopenharmony_ci enum __DRISampleRange sample_range; 137bf215546Sopenharmony_ci enum __DRIChromaSiting horizontal_siting; 138bf215546Sopenharmony_ci enum __DRIChromaSiting vertical_siting; 139bf215546Sopenharmony_ci 140bf215546Sopenharmony_ci /* DRI loader screen */ 141bf215546Sopenharmony_ci __DRIscreen *sPriv; 142bf215546Sopenharmony_ci}; 143bf215546Sopenharmony_ci 144bf215546Sopenharmony_cistatic inline boolean 145bf215546Sopenharmony_cidri_with_format(__DRIscreen * sPriv) 146bf215546Sopenharmony_ci{ 147bf215546Sopenharmony_ci const __DRIdri2LoaderExtension *loader = sPriv->dri2.loader; 148bf215546Sopenharmony_ci 149bf215546Sopenharmony_ci return loader 150bf215546Sopenharmony_ci && (loader->base.version >= 3) 151bf215546Sopenharmony_ci && (loader->getBuffersWithFormat != NULL); 152bf215546Sopenharmony_ci} 153bf215546Sopenharmony_ci 154bf215546Sopenharmony_civoid 155bf215546Sopenharmony_cidri_fill_st_visual(struct st_visual *stvis, 156bf215546Sopenharmony_ci const struct dri_screen *screen, 157bf215546Sopenharmony_ci const struct gl_config *mode); 158bf215546Sopenharmony_ci 159bf215546Sopenharmony_civoid 160bf215546Sopenharmony_cidri_init_options(struct dri_screen *screen); 161bf215546Sopenharmony_ci 162bf215546Sopenharmony_ciconst __DRIconfig ** 163bf215546Sopenharmony_cidri_init_screen_helper(struct dri_screen *screen, 164bf215546Sopenharmony_ci struct pipe_screen *pscreen); 165bf215546Sopenharmony_ci 166bf215546Sopenharmony_civoid 167bf215546Sopenharmony_cidri_destroy_screen_helper(struct dri_screen * screen); 168bf215546Sopenharmony_ci 169bf215546Sopenharmony_civoid 170bf215546Sopenharmony_cidri_destroy_screen(__DRIscreen * sPriv); 171bf215546Sopenharmony_ci 172bf215546Sopenharmony_ciextern const struct __DriverAPIRec dri_swrast_kms_driver_api; 173bf215546Sopenharmony_ciextern const __DRIextension *dri_swrast_kms_driver_extensions[]; 174bf215546Sopenharmony_ciextern const struct __DriverAPIRec galliumdrm_driver_api; 175bf215546Sopenharmony_ciextern const __DRIextension *galliumdrm_driver_extensions[]; 176bf215546Sopenharmony_ciextern const struct __DriverAPIRec galliumsw_driver_api; 177bf215546Sopenharmony_ciextern const __DRIextension *galliumsw_driver_extensions[]; 178bf215546Sopenharmony_ciextern const struct __DriverAPIRec galliumvk_driver_api; 179bf215546Sopenharmony_ciextern const __DRIextension *galliumvk_driver_extensions[]; 180bf215546Sopenharmony_ciextern const __DRIconfigOptionsExtension gallium_config_options; 181bf215546Sopenharmony_ci 182bf215546Sopenharmony_ci#endif 183bf215546Sopenharmony_ci 184bf215546Sopenharmony_ci/* vim: set sw=3 ts=8 sts=3 expandtab: */ 185