1af69d88dSmrg/* 2af69d88dSmrg * Copyright © 2014 Broadcom 3af69d88dSmrg * 4af69d88dSmrg * Permission is hereby granted, free of charge, to any person obtaining a 5af69d88dSmrg * copy of this software and associated documentation files (the "Software"), 6af69d88dSmrg * to deal in the Software without restriction, including without limitation 7af69d88dSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8af69d88dSmrg * and/or sell copies of the Software, and to permit persons to whom the 9af69d88dSmrg * Software is furnished to do so, subject to the following conditions: 10af69d88dSmrg * 11af69d88dSmrg * The above copyright notice and this permission notice (including the next 12af69d88dSmrg * paragraph) shall be included in all copies or substantial portions of the 13af69d88dSmrg * Software. 14af69d88dSmrg * 15af69d88dSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16af69d88dSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17af69d88dSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19af69d88dSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20af69d88dSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21af69d88dSmrg * IN THE SOFTWARE. 22af69d88dSmrg */ 23af69d88dSmrg 24af69d88dSmrg#ifndef VC4_SCREEN_H 25af69d88dSmrg#define VC4_SCREEN_H 26af69d88dSmrg 27af69d88dSmrg#include "pipe/p_screen.h" 2801e04c3fSmrg#include "renderonly/renderonly.h" 2901e04c3fSmrg#include "os/os_thread.h" 307ec681f3Smrg#include "frontend/drm_driver.h" 3101e04c3fSmrg#include "util/list.h" 3201e04c3fSmrg#include "util/slab.h" 3301e04c3fSmrg 3401e04c3fSmrg#ifndef DRM_VC4_PARAM_SUPPORTS_ETC1 3501e04c3fSmrg#define DRM_VC4_PARAM_SUPPORTS_ETC1 4 3601e04c3fSmrg#endif 37af69d88dSmrg 38af69d88dSmrgstruct vc4_bo; 39af69d88dSmrg 40af69d88dSmrg#define VC4_DEBUG_CL 0x0001 41af69d88dSmrg#define VC4_DEBUG_QPU 0x0002 42af69d88dSmrg#define VC4_DEBUG_QIR 0x0004 43af69d88dSmrg#define VC4_DEBUG_TGSI 0x0008 44af69d88dSmrg#define VC4_DEBUG_SHADERDB 0x0010 45af69d88dSmrg#define VC4_DEBUG_PERF 0x0020 46af69d88dSmrg#define VC4_DEBUG_NORAST 0x0040 4701e04c3fSmrg#define VC4_DEBUG_ALWAYS_FLUSH 0x0080 4801e04c3fSmrg#define VC4_DEBUG_ALWAYS_SYNC 0x0100 4901e04c3fSmrg#define VC4_DEBUG_NIR 0x0200 5001e04c3fSmrg#define VC4_DEBUG_DUMP 0x0400 5101e04c3fSmrg#define VC4_DEBUG_SURFACE 0x0800 52af69d88dSmrg 53af69d88dSmrg#define VC4_MAX_MIP_LEVELS 12 54af69d88dSmrg#define VC4_MAX_TEXTURE_SAMPLERS 16 55af69d88dSmrg 5601e04c3fSmrgstruct vc4_simulator_file; 5701e04c3fSmrg 58af69d88dSmrgstruct vc4_screen { 59af69d88dSmrg struct pipe_screen base; 6001e04c3fSmrg struct renderonly *ro; 6101e04c3fSmrg 62af69d88dSmrg int fd; 63af69d88dSmrg 6401e04c3fSmrg int v3d_ver; 6501e04c3fSmrg 6601e04c3fSmrg const char *name; 6701e04c3fSmrg 6801e04c3fSmrg /** The last seqno we've completed a wait for. 6901e04c3fSmrg * 7001e04c3fSmrg * This lets us slightly optimize our waits by skipping wait syscalls 7101e04c3fSmrg * if we know the job's already done. 7201e04c3fSmrg */ 7301e04c3fSmrg uint64_t finished_seqno; 7401e04c3fSmrg 7501e04c3fSmrg struct slab_parent_pool transfer_pool; 7601e04c3fSmrg 7701e04c3fSmrg struct vc4_bo_cache { 7801e04c3fSmrg /** List of struct vc4_bo freed, by age. */ 7901e04c3fSmrg struct list_head time_list; 8001e04c3fSmrg /** List of struct vc4_bo freed, per size, by age. */ 8101e04c3fSmrg struct list_head *size_list; 8201e04c3fSmrg uint32_t size_list_size; 8301e04c3fSmrg 8401e04c3fSmrg mtx_t lock; 8501e04c3fSmrg 8601e04c3fSmrg uint32_t bo_size; 8701e04c3fSmrg uint32_t bo_count; 8801e04c3fSmrg } bo_cache; 8901e04c3fSmrg 907ec681f3Smrg struct hash_table *bo_handles; 9101e04c3fSmrg mtx_t bo_handles_mutex; 9201e04c3fSmrg 9301e04c3fSmrg uint32_t bo_size; 9401e04c3fSmrg uint32_t bo_count; 957ec681f3Smrg uint32_t prim_types; 9601e04c3fSmrg bool has_control_flow; 9701e04c3fSmrg bool has_etc1; 9801e04c3fSmrg bool has_threaded_fs; 9901e04c3fSmrg bool has_madvise; 10001e04c3fSmrg bool has_tiling_ioctl; 10101e04c3fSmrg bool has_perfmon_ioctl; 10201e04c3fSmrg bool has_syncobj; 10301e04c3fSmrg 10401e04c3fSmrg struct vc4_simulator_file *sim_file; 105af69d88dSmrg}; 106af69d88dSmrg 107af69d88dSmrgstatic inline struct vc4_screen * 108af69d88dSmrgvc4_screen(struct pipe_screen *screen) 109af69d88dSmrg{ 110af69d88dSmrg return (struct vc4_screen *)screen; 111af69d88dSmrg} 112af69d88dSmrg 11301e04c3fSmrgstruct pipe_screen *vc4_screen_create(int fd, struct renderonly *ro); 114af69d88dSmrg 11501e04c3fSmrgconst void * 11601e04c3fSmrgvc4_screen_get_compiler_options(struct pipe_screen *pscreen, 11701e04c3fSmrg enum pipe_shader_ir ir, 11801e04c3fSmrg enum pipe_shader_type shader); 119af69d88dSmrg 120af69d88dSmrgextern uint32_t vc4_debug; 121af69d88dSmrg 12201e04c3fSmrgvoid 12301e04c3fSmrgvc4_fence_screen_init(struct vc4_screen *screen); 12401e04c3fSmrg 12501e04c3fSmrgstruct vc4_fence * 12601e04c3fSmrgvc4_fence_create(struct vc4_screen *screen, uint64_t seqno, int fd); 12701e04c3fSmrg 128af69d88dSmrg#endif /* VC4_SCREEN_H */ 129