Path: blob/21.2-virgl/src/gallium/winsys/virgl/drm/virgl_drm_winsys.h
4566 views
/*1* Copyright 2014, 2015 Red Hat.2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* on the rights to use, copy, modify, merge, publish, distribute, sub7* license, and/or sell copies of the Software, and to permit persons to whom8* the Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL17* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,18* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR19* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE20* USE OR OTHER DEALINGS IN THE SOFTWARE.21*/22#ifndef VIRGL_DRM_WINSYS_H23#define VIRGL_DRM_WINSYS_H2425#include <stdint.h>26#include "os/os_thread.h"27#include "pipe/p_state.h"28#include "util/list.h"2930#include "virgl/virgl_winsys.h"31#include "virgl_resource_cache.h"3233struct pipe_fence_handle;34struct hash_table;3536struct virgl_hw_res {37struct pipe_reference reference;38enum pipe_texture_target target;39uint32_t res_handle;40uint32_t bo_handle;41int num_cs_references;42uint32_t size;43void *ptr;4445struct virgl_resource_cache_entry cache_entry;46uint32_t bind;47uint32_t flags;48uint32_t flink_name;4950/* false when the resource is known to be typed */51bool maybe_untyped;5253/* true when the resource is imported or exported */54int external;5556/* false when the resource is known to be idle */57int maybe_busy;58uint32_t blob_mem;59};606162struct param {63uint64_t param;64const char *name;65uint64_t value;66};6768enum param_id {69param_3d_features,70param_capset_fix,71param_resource_blob,72param_host_visible,73param_max,74};7576#define PARAM(x) (struct param) { x, #x, 0 }7778struct param params[] = { PARAM(VIRTGPU_PARAM_3D_FEATURES),79PARAM(VIRTGPU_PARAM_CAPSET_QUERY_FIX),80PARAM(VIRTGPU_PARAM_RESOURCE_BLOB),81PARAM(VIRTGPU_PARAM_HOST_VISIBLE),82PARAM(VIRTGPU_PARAM_CROSS_DEVICE)83};8485struct virgl_drm_winsys86{87struct virgl_winsys base;88int fd;89struct virgl_resource_cache cache;90mtx_t mutex;9192int32_t blob_id;93struct hash_table *bo_handles;94struct hash_table *bo_names;95mtx_t bo_handles_mutex;96};9798struct virgl_drm_fence {99struct pipe_reference reference;100bool external;101int fd;102struct virgl_hw_res *hw_res;103};104105struct virgl_drm_cmd_buf {106struct virgl_cmd_buf base;107108uint32_t *buf;109110int in_fence_fd;111112unsigned nres;113unsigned cres;114struct virgl_hw_res **res_bo;115struct virgl_winsys *ws;116uint32_t *res_hlist;117118char is_handle_added[512];119unsigned reloc_indices_hashlist[512];120121};122123static inline struct virgl_drm_winsys *124virgl_drm_winsys(struct virgl_winsys *iws)125{126return (struct virgl_drm_winsys *)iws;127}128129static inline struct virgl_drm_fence *130virgl_drm_fence(struct pipe_fence_handle *f)131{132return (struct virgl_drm_fence *)f;133}134135static inline struct virgl_drm_cmd_buf *136virgl_drm_cmd_buf(struct virgl_cmd_buf *cbuf)137{138return (struct virgl_drm_cmd_buf *)cbuf;139}140141#endif142143144