1b8e80941Smrg/************************************************************************** 2b8e80941Smrg * 3b8e80941Smrg * Copyright 2018-2019 Alyssa Rosenzweig 4b8e80941Smrg * Copyright 2018-2019 Collabora 5b8e80941Smrg * All Rights Reserved. 6b8e80941Smrg * 7b8e80941Smrg * Permission is hereby granted, free of charge, to any person obtaining a 8b8e80941Smrg * copy of this software and associated documentation files (the 9b8e80941Smrg * "Software"), to deal in the Software without restriction, including 10b8e80941Smrg * without limitation the rights to use, copy, modify, merge, publish, 11b8e80941Smrg * distribute, sub license, and/or sell copies of the Software, and to 12b8e80941Smrg * permit persons to whom the Software is furnished to do so, subject to 13b8e80941Smrg * the following conditions: 14b8e80941Smrg * 15b8e80941Smrg * The above copyright notice and this permission notice (including the 16b8e80941Smrg * next paragraph) shall be included in all copies or substantial portions 17b8e80941Smrg * of the Software. 18b8e80941Smrg * 19b8e80941Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20b8e80941Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21b8e80941Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 22b8e80941Smrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 23b8e80941Smrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24b8e80941Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25b8e80941Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26b8e80941Smrg * 27b8e80941Smrg **************************************************************************/ 28b8e80941Smrg 29b8e80941Smrg#ifndef PAN_SCREEN_H 30b8e80941Smrg#define PAN_SCREEN_H 31b8e80941Smrg 32b8e80941Smrg#include "pipe/p_screen.h" 33b8e80941Smrg#include "pipe/p_defines.h" 34b8e80941Smrg#include "renderonly/renderonly.h" 35b8e80941Smrg 36b8e80941Smrg#include <panfrost-misc.h> 37b8e80941Smrg#include "pan_allocate.h" 38b8e80941Smrg#include "pan_trace.h" 39b8e80941Smrg 40b8e80941Smrgstruct panfrost_context; 41b8e80941Smrgstruct panfrost_resource; 42b8e80941Smrgstruct panfrost_screen; 43b8e80941Smrg 44b8e80941Smrg/* Flags for allocated memory */ 45b8e80941Smrg#define PAN_ALLOCATE_EXECUTE (1 << 0) 46b8e80941Smrg#define PAN_ALLOCATE_GROWABLE (1 << 1) 47b8e80941Smrg#define PAN_ALLOCATE_INVISIBLE (1 << 2) 48b8e80941Smrg#define PAN_ALLOCATE_COHERENT_LOCAL (1 << 3) 49b8e80941Smrg 50b8e80941Smrgstruct panfrost_driver { 51b8e80941Smrg struct panfrost_bo * (*import_bo) (struct panfrost_screen *screen, struct winsys_handle *whandle); 52b8e80941Smrg int (*export_bo) (struct panfrost_screen *screen, int gem_handle, unsigned int stride, struct winsys_handle *whandle); 53b8e80941Smrg 54b8e80941Smrg int (*submit_vs_fs_job) (struct panfrost_context *ctx, bool has_draws, bool is_scanout); 55b8e80941Smrg void (*force_flush_fragment) (struct panfrost_context *ctx, 56b8e80941Smrg struct pipe_fence_handle **fence); 57b8e80941Smrg void (*allocate_slab) (struct panfrost_screen *screen, 58b8e80941Smrg struct panfrost_memory *mem, 59b8e80941Smrg size_t pages, 60b8e80941Smrg bool same_va, 61b8e80941Smrg int extra_flags, 62b8e80941Smrg int commit_count, 63b8e80941Smrg int extent); 64b8e80941Smrg void (*free_slab) (struct panfrost_screen *screen, 65b8e80941Smrg struct panfrost_memory *mem); 66b8e80941Smrg void (*free_imported_bo) (struct panfrost_screen *screen, 67b8e80941Smrg struct panfrost_bo *bo); 68b8e80941Smrg void (*enable_counters) (struct panfrost_screen *screen); 69b8e80941Smrg void (*dump_counters) (struct panfrost_screen *screen); 70b8e80941Smrg unsigned (*query_gpu_version) (struct panfrost_screen *screen); 71b8e80941Smrg int (*init_context) (struct panfrost_context *ctx); 72b8e80941Smrg void (*fence_reference) (struct pipe_screen *screen, 73b8e80941Smrg struct pipe_fence_handle **ptr, 74b8e80941Smrg struct pipe_fence_handle *fence); 75b8e80941Smrg boolean (*fence_finish) (struct pipe_screen *screen, 76b8e80941Smrg struct pipe_context *ctx, 77b8e80941Smrg struct pipe_fence_handle *fence, 78b8e80941Smrg uint64_t timeout); 79b8e80941Smrg}; 80b8e80941Smrg 81b8e80941Smrgstruct panfrost_screen { 82b8e80941Smrg struct pipe_screen base; 83b8e80941Smrg 84b8e80941Smrg struct renderonly *ro; 85b8e80941Smrg struct panfrost_driver *driver; 86b8e80941Smrg 87b8e80941Smrg struct panfrost_memory perf_counters; 88b8e80941Smrg 89b8e80941Smrg /* Memory management is based on subdividing slabs with AMD's allocator */ 90b8e80941Smrg struct pb_slabs slabs; 91b8e80941Smrg 92b8e80941Smrg /* TODO: Where? */ 93b8e80941Smrg struct panfrost_resource *display_target; 94b8e80941Smrg 95b8e80941Smrg /* While we're busy building up the job for frame N, the GPU is 96b8e80941Smrg * still busy executing frame N-1. So hold a reference to 97b8e80941Smrg * yesterjob */ 98b8e80941Smrg int last_fragment_flushed; 99b8e80941Smrg struct panfrost_job *last_job; 100b8e80941Smrg}; 101b8e80941Smrg 102b8e80941Smrg#endif /* PAN_SCREEN_H */ 103