Path: blob/21.2-virgl/src/asahi/lib/agx_device.h
4560 views
/*1* Copyright (C) 2021 Alyssa Rosenzweig <[email protected]>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* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* 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 NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21*/2223#ifndef __AGX_DEVICE_H24#define __AGX_DEVICE_H2526#include "util/sparse_array.h"27#include "io.h"28#include "agx_formats.h"2930#if __APPLE__31#include <mach/mach.h>32#include <IOKit/IOKitLib.h>33#endif3435enum agx_dbg {36AGX_DBG_TRACE = BITFIELD_BIT(0),37AGX_DBG_DEQP = BITFIELD_BIT(1),38AGX_DBG_NO16 = BITFIELD_BIT(2),39};4041struct agx_device {42void *memctx;43uint32_t debug;4445/* XXX What to bind to? I don't understand the IOGPU UABI */46struct agx_command_queue queue;47struct agx_bo cmdbuf, memmap;48uint64_t next_global_id, last_global_id;4950/* Device handle */51#if __APPLE__52io_connect_t fd;53#else54int fd;55#endif5657pthread_mutex_t bo_map_lock;58struct util_sparse_array bo_map;5960/* Fixed shaders */61struct {62struct agx_bo *bo;63uint32_t clear;64uint32_t store;65} internal;6667struct {68struct agx_bo *bo;69uint32_t format[AGX_NUM_FORMATS];70} reload;71};7273bool74agx_open_device(void *memctx, struct agx_device *dev);7576void77agx_close_device(struct agx_device *dev);7879static inline struct agx_bo *80agx_lookup_bo(struct agx_device *dev, uint32_t handle)81{82return util_sparse_array_get(&dev->bo_map, handle);83}8485struct agx_bo86agx_shmem_alloc(struct agx_device *dev, size_t size, bool cmdbuf);8788void89agx_shmem_free(struct agx_device *dev, unsigned handle);9091uint64_t92agx_get_global_id(struct agx_device *dev);9394struct agx_command_queue95agx_create_command_queue(struct agx_device *dev);9697void98agx_submit_cmdbuf(struct agx_device *dev, unsigned cmdbuf, unsigned mappings, uint64_t scalar);99100void101agx_wait_queue(struct agx_command_queue queue);102103#endif104105106