1bf215546Sopenharmony_ci/************************************************************************** 2bf215546Sopenharmony_ci * 3bf215546Sopenharmony_ci * Copyright 2018-2019 Alyssa Rosenzweig 4bf215546Sopenharmony_ci * Copyright 2018-2019 Collabora, Ltd. 5bf215546Sopenharmony_ci * All Rights Reserved. 6bf215546Sopenharmony_ci * 7bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 8bf215546Sopenharmony_ci * copy of this software and associated documentation files (the 9bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 10bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 11bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to 12bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 13bf215546Sopenharmony_ci * the following conditions: 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the 16bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions 17bf215546Sopenharmony_ci * of the Software. 18bf215546Sopenharmony_ci * 19bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 22bf215546Sopenharmony_ci * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 23bf215546Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24bf215546Sopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25bf215546Sopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26bf215546Sopenharmony_ci * 27bf215546Sopenharmony_ci **************************************************************************/ 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#ifndef PAN_SCREEN_H 30bf215546Sopenharmony_ci#define PAN_SCREEN_H 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci#include <xf86drm.h> 33bf215546Sopenharmony_ci#include "pipe/p_screen.h" 34bf215546Sopenharmony_ci#include "pipe/p_defines.h" 35bf215546Sopenharmony_ci#include "renderonly/renderonly.h" 36bf215546Sopenharmony_ci#include "util/u_dynarray.h" 37bf215546Sopenharmony_ci#include "util/bitset.h" 38bf215546Sopenharmony_ci#include "util/set.h" 39bf215546Sopenharmony_ci#include "util/log.h" 40bf215546Sopenharmony_ci 41bf215546Sopenharmony_ci#include "pan_device.h" 42bf215546Sopenharmony_ci#include "pan_mempool.h" 43bf215546Sopenharmony_ci 44bf215546Sopenharmony_cistruct panfrost_batch; 45bf215546Sopenharmony_cistruct panfrost_context; 46bf215546Sopenharmony_cistruct panfrost_resource; 47bf215546Sopenharmony_cistruct panfrost_shader_state; 48bf215546Sopenharmony_cistruct pan_fb_info; 49bf215546Sopenharmony_cistruct pan_blend_state; 50bf215546Sopenharmony_ci 51bf215546Sopenharmony_ci/* Virtual table of per-generation (GenXML) functions */ 52bf215546Sopenharmony_ci 53bf215546Sopenharmony_cistruct panfrost_vtable { 54bf215546Sopenharmony_ci /* Prepares the renderer state descriptor or shader program descriptor 55bf215546Sopenharmony_ci * for a given compiled shader, and if desired uploads it as well */ 56bf215546Sopenharmony_ci void (*prepare_shader)(struct panfrost_shader_state *, 57bf215546Sopenharmony_ci struct panfrost_pool *, bool); 58bf215546Sopenharmony_ci 59bf215546Sopenharmony_ci /* Emits a thread local storage descriptor */ 60bf215546Sopenharmony_ci void (*emit_tls)(struct panfrost_batch *); 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_ci /* Emits a framebuffer descriptor */ 63bf215546Sopenharmony_ci void (*emit_fbd)(struct panfrost_batch *, const struct pan_fb_info *); 64bf215546Sopenharmony_ci 65bf215546Sopenharmony_ci /* Emits a fragment job */ 66bf215546Sopenharmony_ci mali_ptr (*emit_fragment_job)(struct panfrost_batch *, const struct pan_fb_info *); 67bf215546Sopenharmony_ci 68bf215546Sopenharmony_ci /* General destructor */ 69bf215546Sopenharmony_ci void (*screen_destroy)(struct pipe_screen *); 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci /* Preload framebuffer */ 72bf215546Sopenharmony_ci void (*preload)(struct panfrost_batch *, struct pan_fb_info *); 73bf215546Sopenharmony_ci 74bf215546Sopenharmony_ci /* Initialize a Gallium context */ 75bf215546Sopenharmony_ci void (*context_init)(struct pipe_context *pipe); 76bf215546Sopenharmony_ci 77bf215546Sopenharmony_ci /* Device-dependent initialization of a panfrost_batch */ 78bf215546Sopenharmony_ci void (*init_batch)(struct panfrost_batch *batch); 79bf215546Sopenharmony_ci 80bf215546Sopenharmony_ci /* Get blend shader */ 81bf215546Sopenharmony_ci struct pan_blend_shader_variant * 82bf215546Sopenharmony_ci (*get_blend_shader)(const struct panfrost_device *, 83bf215546Sopenharmony_ci const struct pan_blend_state *, 84bf215546Sopenharmony_ci nir_alu_type, nir_alu_type, 85bf215546Sopenharmony_ci unsigned rt); 86bf215546Sopenharmony_ci 87bf215546Sopenharmony_ci /* Initialize the polygon list */ 88bf215546Sopenharmony_ci void (*init_polygon_list)(struct panfrost_batch *); 89bf215546Sopenharmony_ci 90bf215546Sopenharmony_ci /* Shader compilation methods */ 91bf215546Sopenharmony_ci const nir_shader_compiler_options *(*get_compiler_options)(void); 92bf215546Sopenharmony_ci void (*compile_shader)(nir_shader *s, 93bf215546Sopenharmony_ci struct panfrost_compile_inputs *inputs, 94bf215546Sopenharmony_ci struct util_dynarray *binary, 95bf215546Sopenharmony_ci struct pan_shader_info *info); 96bf215546Sopenharmony_ci}; 97bf215546Sopenharmony_ci 98bf215546Sopenharmony_cistruct panfrost_screen { 99bf215546Sopenharmony_ci struct pipe_screen base; 100bf215546Sopenharmony_ci struct panfrost_device dev; 101bf215546Sopenharmony_ci struct { 102bf215546Sopenharmony_ci struct panfrost_pool bin_pool; 103bf215546Sopenharmony_ci struct panfrost_pool desc_pool; 104bf215546Sopenharmony_ci } blitter; 105bf215546Sopenharmony_ci struct { 106bf215546Sopenharmony_ci struct panfrost_pool bin_pool; 107bf215546Sopenharmony_ci } indirect_draw; 108bf215546Sopenharmony_ci 109bf215546Sopenharmony_ci struct panfrost_vtable vtbl; 110bf215546Sopenharmony_ci}; 111bf215546Sopenharmony_ci 112bf215546Sopenharmony_cistatic inline struct panfrost_screen * 113bf215546Sopenharmony_cipan_screen(struct pipe_screen *p) 114bf215546Sopenharmony_ci{ 115bf215546Sopenharmony_ci return (struct panfrost_screen *)p; 116bf215546Sopenharmony_ci} 117bf215546Sopenharmony_ci 118bf215546Sopenharmony_cistatic inline struct panfrost_device * 119bf215546Sopenharmony_cipan_device(struct pipe_screen *p) 120bf215546Sopenharmony_ci{ 121bf215546Sopenharmony_ci return &(pan_screen(p)->dev); 122bf215546Sopenharmony_ci} 123bf215546Sopenharmony_ci 124bf215546Sopenharmony_cistruct pipe_fence_handle * 125bf215546Sopenharmony_cipanfrost_fence_create(struct panfrost_context *ctx); 126bf215546Sopenharmony_ci 127bf215546Sopenharmony_civoid panfrost_cmdstream_screen_init_v4(struct panfrost_screen *screen); 128bf215546Sopenharmony_civoid panfrost_cmdstream_screen_init_v5(struct panfrost_screen *screen); 129bf215546Sopenharmony_civoid panfrost_cmdstream_screen_init_v6(struct panfrost_screen *screen); 130bf215546Sopenharmony_civoid panfrost_cmdstream_screen_init_v7(struct panfrost_screen *screen); 131bf215546Sopenharmony_civoid panfrost_cmdstream_screen_init_v9(struct panfrost_screen *screen); 132bf215546Sopenharmony_ci 133bf215546Sopenharmony_ci#define perf_debug(dev, ...) \ 134bf215546Sopenharmony_ci do { \ 135bf215546Sopenharmony_ci if (unlikely((dev)->debug & PAN_DBG_PERF)) \ 136bf215546Sopenharmony_ci mesa_logw(__VA_ARGS__); \ 137bf215546Sopenharmony_ci } while(0) 138bf215546Sopenharmony_ci 139bf215546Sopenharmony_ci#define perf_debug_ctx(ctx, ...) \ 140bf215546Sopenharmony_ci perf_debug(pan_device((ctx)->base.screen), __VA_ARGS__); 141bf215546Sopenharmony_ci 142bf215546Sopenharmony_ci#endif /* PAN_SCREEN_H */ 143