1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright (C) 2016 Rob Clark <robclark@freedesktop.org> 3bf215546Sopenharmony_ci * Copyright © 2018 Google, Inc. 4bf215546Sopenharmony_ci * 5bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 6bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 7bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 8bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 10bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 11bf215546Sopenharmony_ci * 12bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 13bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 14bf215546Sopenharmony_ci * Software. 15bf215546Sopenharmony_ci * 16bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21bf215546Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22bf215546Sopenharmony_ci * SOFTWARE. 23bf215546Sopenharmony_ci * 24bf215546Sopenharmony_ci * Authors: 25bf215546Sopenharmony_ci * Rob Clark <robclark@freedesktop.org> 26bf215546Sopenharmony_ci */ 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_ci#ifndef FD6_CONTEXT_H_ 29bf215546Sopenharmony_ci#define FD6_CONTEXT_H_ 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci#include "util/u_upload_mgr.h" 32bf215546Sopenharmony_ci 33bf215546Sopenharmony_ci#include "freedreno_context.h" 34bf215546Sopenharmony_ci#include "freedreno_resource.h" 35bf215546Sopenharmony_ci 36bf215546Sopenharmony_ci#include "ir3/ir3_shader.h" 37bf215546Sopenharmony_ci 38bf215546Sopenharmony_ci#include "a6xx.xml.h" 39bf215546Sopenharmony_ci 40bf215546Sopenharmony_cistruct fd6_lrz_state { 41bf215546Sopenharmony_ci bool enable : 1; 42bf215546Sopenharmony_ci bool write : 1; 43bf215546Sopenharmony_ci bool test : 1; 44bf215546Sopenharmony_ci enum fd_lrz_direction direction : 2; 45bf215546Sopenharmony_ci 46bf215546Sopenharmony_ci /* this comes from the fs program state, rather than zsa: */ 47bf215546Sopenharmony_ci enum a6xx_ztest_mode z_mode : 2; 48bf215546Sopenharmony_ci}; 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_cistruct fd6_context { 51bf215546Sopenharmony_ci struct fd_context base; 52bf215546Sopenharmony_ci 53bf215546Sopenharmony_ci /* Two buffers related to hw binning / visibility stream (VSC). 54bf215546Sopenharmony_ci * Compared to previous generations 55bf215546Sopenharmony_ci * (1) we cannot specify individual buffers per VSC, instead 56bf215546Sopenharmony_ci * just a pitch and base address 57bf215546Sopenharmony_ci * (2) there is a second smaller buffer.. we also stash 58bf215546Sopenharmony_ci * VSC_BIN_SIZE at end of 2nd buffer. 59bf215546Sopenharmony_ci */ 60bf215546Sopenharmony_ci struct fd_bo *vsc_draw_strm, *vsc_prim_strm; 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_ci unsigned vsc_draw_strm_pitch, vsc_prim_strm_pitch; 63bf215546Sopenharmony_ci 64bf215546Sopenharmony_ci /* The 'control' mem BO is used for various housekeeping 65bf215546Sopenharmony_ci * functions. See 'struct fd6_control' 66bf215546Sopenharmony_ci */ 67bf215546Sopenharmony_ci struct fd_bo *control_mem; 68bf215546Sopenharmony_ci uint32_t seqno; 69bf215546Sopenharmony_ci 70bf215546Sopenharmony_ci struct u_upload_mgr *border_color_uploader; 71bf215546Sopenharmony_ci struct pipe_resource *border_color_buf; 72bf215546Sopenharmony_ci 73bf215546Sopenharmony_ci /* pre-backed stateobj for stream-out disable: */ 74bf215546Sopenharmony_ci struct fd_ringbuffer *streamout_disable_stateobj; 75bf215546Sopenharmony_ci 76bf215546Sopenharmony_ci /* storage for ctx->last.key: */ 77bf215546Sopenharmony_ci struct ir3_shader_key last_key; 78bf215546Sopenharmony_ci 79bf215546Sopenharmony_ci /* Is there current VS driver-param state set? */ 80bf215546Sopenharmony_ci bool has_dp_state; 81bf215546Sopenharmony_ci 82bf215546Sopenharmony_ci /* number of active samples-passed queries: */ 83bf215546Sopenharmony_ci int samples_passed_queries; 84bf215546Sopenharmony_ci 85bf215546Sopenharmony_ci /* cached stateobjs to avoid hashtable lookup when not dirty: */ 86bf215546Sopenharmony_ci const struct fd6_program_state *prog; 87bf215546Sopenharmony_ci 88bf215546Sopenharmony_ci uint16_t tex_seqno; 89bf215546Sopenharmony_ci struct hash_table *tex_cache; 90bf215546Sopenharmony_ci 91bf215546Sopenharmony_ci struct { 92bf215546Sopenharmony_ci /* previous binning/draw lrz state, which is a function of multiple 93bf215546Sopenharmony_ci * gallium stateobjs, but doesn't necessarily change as frequently: 94bf215546Sopenharmony_ci */ 95bf215546Sopenharmony_ci struct fd6_lrz_state lrz[2]; 96bf215546Sopenharmony_ci } last; 97bf215546Sopenharmony_ci}; 98bf215546Sopenharmony_ci 99bf215546Sopenharmony_cistatic inline struct fd6_context * 100bf215546Sopenharmony_cifd6_context(struct fd_context *ctx) 101bf215546Sopenharmony_ci{ 102bf215546Sopenharmony_ci return (struct fd6_context *)ctx; 103bf215546Sopenharmony_ci} 104bf215546Sopenharmony_ci 105bf215546Sopenharmony_cistruct pipe_context *fd6_context_create(struct pipe_screen *pscreen, void *priv, 106bf215546Sopenharmony_ci unsigned flags); 107bf215546Sopenharmony_ci 108bf215546Sopenharmony_ci/* This struct defines the layout of the fd6_context::control buffer: */ 109bf215546Sopenharmony_cistruct fd6_control { 110bf215546Sopenharmony_ci uint32_t seqno; /* seqno for async CP_EVENT_WRITE, etc */ 111bf215546Sopenharmony_ci uint32_t _pad0; 112bf215546Sopenharmony_ci volatile uint32_t vsc_overflow; 113bf215546Sopenharmony_ci uint32_t _pad1[5]; 114bf215546Sopenharmony_ci 115bf215546Sopenharmony_ci /* scratch space for VPC_SO[i].FLUSH_BASE_LO/HI, start on 32 byte boundary. */ 116bf215546Sopenharmony_ci struct { 117bf215546Sopenharmony_ci uint32_t offset; 118bf215546Sopenharmony_ci uint32_t pad[7]; 119bf215546Sopenharmony_ci } flush_base[4]; 120bf215546Sopenharmony_ci}; 121bf215546Sopenharmony_ci 122bf215546Sopenharmony_ci#define control_ptr(fd6_ctx, member) \ 123bf215546Sopenharmony_ci (fd6_ctx)->control_mem, offsetof(struct fd6_control, member), 0, 0 124bf215546Sopenharmony_ci 125bf215546Sopenharmony_cistatic inline void 126bf215546Sopenharmony_ciemit_marker6(struct fd_ringbuffer *ring, int scratch_idx) 127bf215546Sopenharmony_ci{ 128bf215546Sopenharmony_ci extern int32_t marker_cnt; 129bf215546Sopenharmony_ci unsigned reg = REG_A6XX_CP_SCRATCH_REG(scratch_idx); 130bf215546Sopenharmony_ci if (__EMIT_MARKER) { 131bf215546Sopenharmony_ci OUT_WFI5(ring); 132bf215546Sopenharmony_ci OUT_PKT4(ring, reg, 1); 133bf215546Sopenharmony_ci OUT_RING(ring, p_atomic_inc_return(&marker_cnt)); 134bf215546Sopenharmony_ci } 135bf215546Sopenharmony_ci} 136bf215546Sopenharmony_ci 137bf215546Sopenharmony_cistruct fd6_vertex_stateobj { 138bf215546Sopenharmony_ci struct fd_vertex_stateobj base; 139bf215546Sopenharmony_ci struct fd_ringbuffer *stateobj; 140bf215546Sopenharmony_ci}; 141bf215546Sopenharmony_ci 142bf215546Sopenharmony_cistatic inline struct fd6_vertex_stateobj * 143bf215546Sopenharmony_cifd6_vertex_stateobj(void *p) 144bf215546Sopenharmony_ci{ 145bf215546Sopenharmony_ci return (struct fd6_vertex_stateobj *)p; 146bf215546Sopenharmony_ci} 147bf215546Sopenharmony_ci 148bf215546Sopenharmony_ci#endif /* FD6_CONTEXT_H_ */ 149