19f464c52Smaya/************************************************************************** 29f464c52Smaya * 39f464c52Smaya * Copyright 2018-2019 Alyssa Rosenzweig 47ec681f3Smrg * Copyright 2018-2019 Collabora, Ltd. 59f464c52Smaya * All Rights Reserved. 69f464c52Smaya * 79f464c52Smaya * Permission is hereby granted, free of charge, to any person obtaining a 89f464c52Smaya * copy of this software and associated documentation files (the 99f464c52Smaya * "Software"), to deal in the Software without restriction, including 109f464c52Smaya * without limitation the rights to use, copy, modify, merge, publish, 119f464c52Smaya * distribute, sub license, and/or sell copies of the Software, and to 129f464c52Smaya * permit persons to whom the Software is furnished to do so, subject to 139f464c52Smaya * the following conditions: 149f464c52Smaya * 159f464c52Smaya * The above copyright notice and this permission notice (including the 169f464c52Smaya * next paragraph) shall be included in all copies or substantial portions 179f464c52Smaya * of the Software. 189f464c52Smaya * 199f464c52Smaya * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 209f464c52Smaya * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 219f464c52Smaya * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 229f464c52Smaya * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 239f464c52Smaya * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 249f464c52Smaya * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 259f464c52Smaya * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 269f464c52Smaya * 279f464c52Smaya **************************************************************************/ 289f464c52Smaya 299f464c52Smaya#ifndef PAN_SCREEN_H 309f464c52Smaya#define PAN_SCREEN_H 319f464c52Smaya 327ec681f3Smrg#include <xf86drm.h> 339f464c52Smaya#include "pipe/p_screen.h" 349f464c52Smaya#include "pipe/p_defines.h" 359f464c52Smaya#include "renderonly/renderonly.h" 367ec681f3Smrg#include "util/u_dynarray.h" 377ec681f3Smrg#include "util/bitset.h" 387ec681f3Smrg#include "util/set.h" 397ec681f3Smrg#include "util/log.h" 409f464c52Smaya 417ec681f3Smrg#include "pan_device.h" 427ec681f3Smrg#include "pan_mempool.h" 439f464c52Smaya 447ec681f3Smrgstruct panfrost_batch; 459f464c52Smayastruct panfrost_context; 469f464c52Smayastruct panfrost_resource; 477ec681f3Smrgstruct panfrost_shader_state; 487ec681f3Smrgstruct pan_fb_info; 497ec681f3Smrgstruct pan_blend_state; 507ec681f3Smrg 517ec681f3Smrg/* Virtual table of per-generation (GenXML) functions */ 527ec681f3Smrg 537ec681f3Smrgstruct panfrost_vtable { 547ec681f3Smrg /* Prepares the renderer state descriptor for a given compiled shader, 557ec681f3Smrg * and if desired uploads it as well */ 567ec681f3Smrg void (*prepare_rsd)(struct panfrost_shader_state *, 577ec681f3Smrg struct panfrost_pool *, bool); 587ec681f3Smrg 597ec681f3Smrg /* Emits a thread local storage descriptor */ 607ec681f3Smrg void (*emit_tls)(struct panfrost_batch *); 617ec681f3Smrg 627ec681f3Smrg /* Emits a framebuffer descriptor */ 637ec681f3Smrg void (*emit_fbd)(struct panfrost_batch *, const struct pan_fb_info *); 647ec681f3Smrg 657ec681f3Smrg /* Emits a fragment job */ 667ec681f3Smrg mali_ptr (*emit_fragment_job)(struct panfrost_batch *, const struct pan_fb_info *); 677ec681f3Smrg 687ec681f3Smrg /* General destructor */ 697ec681f3Smrg void (*screen_destroy)(struct pipe_screen *); 707ec681f3Smrg 717ec681f3Smrg /* Preload framebuffer */ 727ec681f3Smrg void (*preload)(struct panfrost_batch *, struct pan_fb_info *); 737ec681f3Smrg 747ec681f3Smrg /* Initialize a Gallium context */ 757ec681f3Smrg void (*context_init)(struct pipe_context *pipe); 767ec681f3Smrg 777ec681f3Smrg /* Device-dependent initialization of a panfrost_batch */ 787ec681f3Smrg void (*init_batch)(struct panfrost_batch *batch); 797ec681f3Smrg 807ec681f3Smrg /* Get blend shader */ 817ec681f3Smrg struct pan_blend_shader_variant * 827ec681f3Smrg (*get_blend_shader)(const struct panfrost_device *, 837ec681f3Smrg const struct pan_blend_state *, 847ec681f3Smrg nir_alu_type, nir_alu_type, 857ec681f3Smrg unsigned rt); 867ec681f3Smrg 877ec681f3Smrg /* Initialize the polygon list */ 887ec681f3Smrg void (*init_polygon_list)(struct panfrost_batch *); 897ec681f3Smrg 907ec681f3Smrg /* Shader compilation methods */ 917ec681f3Smrg const nir_shader_compiler_options *(*get_compiler_options)(void); 927ec681f3Smrg void (*compile_shader)(nir_shader *s, 937ec681f3Smrg struct panfrost_compile_inputs *inputs, 947ec681f3Smrg struct util_dynarray *binary, 957ec681f3Smrg struct pan_shader_info *info); 969f464c52Smaya}; 979f464c52Smaya 989f464c52Smayastruct panfrost_screen { 999f464c52Smaya struct pipe_screen base; 1007ec681f3Smrg struct panfrost_device dev; 1017ec681f3Smrg struct { 1027ec681f3Smrg struct panfrost_pool bin_pool; 1037ec681f3Smrg struct panfrost_pool desc_pool; 1047ec681f3Smrg } blitter; 1057ec681f3Smrg struct { 1067ec681f3Smrg struct panfrost_pool bin_pool; 1077ec681f3Smrg } indirect_draw; 1087ec681f3Smrg 1097ec681f3Smrg struct panfrost_vtable vtbl; 1107ec681f3Smrg}; 1119f464c52Smaya 1127ec681f3Smrgstatic inline struct panfrost_screen * 1137ec681f3Smrgpan_screen(struct pipe_screen *p) 1147ec681f3Smrg{ 1157ec681f3Smrg return (struct panfrost_screen *)p; 1167ec681f3Smrg} 1179f464c52Smaya 1187ec681f3Smrgstatic inline struct panfrost_device * 1197ec681f3Smrgpan_device(struct pipe_screen *p) 1207ec681f3Smrg{ 1217ec681f3Smrg return &(pan_screen(p)->dev); 1227ec681f3Smrg} 1239f464c52Smaya 1247ec681f3Smrgstruct pipe_fence_handle * 1257ec681f3Smrgpanfrost_fence_create(struct panfrost_context *ctx); 1269f464c52Smaya 1277ec681f3Smrgvoid panfrost_cmdstream_screen_init_v4(struct panfrost_screen *screen); 1287ec681f3Smrgvoid panfrost_cmdstream_screen_init_v5(struct panfrost_screen *screen); 1297ec681f3Smrgvoid panfrost_cmdstream_screen_init_v6(struct panfrost_screen *screen); 1307ec681f3Smrgvoid panfrost_cmdstream_screen_init_v7(struct panfrost_screen *screen); 1317ec681f3Smrg 1327ec681f3Smrg#define perf_debug(dev, ...) \ 1337ec681f3Smrg do { \ 1347ec681f3Smrg if (unlikely((dev)->debug & PAN_DBG_PERF)) \ 1357ec681f3Smrg mesa_logw(__VA_ARGS__); \ 1367ec681f3Smrg } while(0) 1377ec681f3Smrg 1387ec681f3Smrg#define perf_debug_ctx(ctx, ...) \ 1397ec681f3Smrg perf_debug(pan_device((ctx)->base.screen), __VA_ARGS__); 1409f464c52Smaya 1419f464c52Smaya#endif /* PAN_SCREEN_H */ 142