Path: blob/21.2-virgl/src/gallium/drivers/freedreno/a6xx/fd6_context.h
4574 views
/*1* Copyright (C) 2016 Rob Clark <[email protected]>2* Copyright © 2018 Google, Inc.3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* the rights to use, copy, modify, merge, publish, distribute, sublicense,8* and/or sell copies of the Software, and to permit persons to whom the9* Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice (including the next12* paragraph) shall be included in all copies or substantial portions of the13* Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL18* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,20* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE21* SOFTWARE.22*23* Authors:24* Rob Clark <[email protected]>25*/2627#ifndef FD6_CONTEXT_H_28#define FD6_CONTEXT_H_2930#include "util/u_upload_mgr.h"3132#include "freedreno_context.h"33#include "freedreno_resource.h"3435#include "ir3/ir3_shader.h"3637#include "a6xx.xml.h"3839struct fd6_lrz_state {40bool enable : 1;41bool write : 1;42bool test : 1;43enum fd_lrz_direction direction : 2;4445/* this comes from the fs program state, rather than zsa: */46enum a6xx_ztest_mode z_mode : 2;47};4849struct fd6_context {50struct fd_context base;5152/* Two buffers related to hw binning / visibility stream (VSC).53* Compared to previous generations54* (1) we cannot specify individual buffers per VSC, instead55* just a pitch and base address56* (2) there is a second smaller buffer.. we also stash57* VSC_BIN_SIZE at end of 2nd buffer.58*/59struct fd_bo *vsc_draw_strm, *vsc_prim_strm;6061unsigned vsc_draw_strm_pitch, vsc_prim_strm_pitch;6263/* The 'control' mem BO is used for various housekeeping64* functions. See 'struct fd6_control'65*/66struct fd_bo *control_mem;67uint32_t seqno;6869struct u_upload_mgr *border_color_uploader;70struct pipe_resource *border_color_buf;7172/* storage for ctx->last.key: */73struct ir3_shader_key last_key;7475/* Is there current VS driver-param state set? */76bool has_dp_state;7778/* number of active samples-passed queries: */79int samples_passed_queries;8081/* cached stateobjs to avoid hashtable lookup when not dirty: */82const struct fd6_program_state *prog;8384uint16_t tex_seqno;85struct hash_table *tex_cache;8687struct {88/* previous binning/draw lrz state, which is a function of multiple89* gallium stateobjs, but doesn't necessarily change as frequently:90*/91struct fd6_lrz_state lrz[2];92} last;93};9495static inline struct fd6_context *96fd6_context(struct fd_context *ctx)97{98return (struct fd6_context *)ctx;99}100101struct pipe_context *fd6_context_create(struct pipe_screen *pscreen, void *priv,102unsigned flags);103104/* This struct defines the layout of the fd6_context::control buffer: */105struct fd6_control {106uint32_t seqno; /* seqno for async CP_EVENT_WRITE, etc */107uint32_t _pad0;108volatile uint32_t vsc_overflow;109uint32_t _pad1[5];110111/* scratch space for VPC_SO[i].FLUSH_BASE_LO/HI, start on 32 byte boundary. */112struct {113uint32_t offset;114uint32_t pad[7];115} flush_base[4];116};117118#define control_ptr(fd6_ctx, member) \119(fd6_ctx)->control_mem, offsetof(struct fd6_control, member), 0, 0120121static inline void122emit_marker6(struct fd_ringbuffer *ring, int scratch_idx)123{124extern int32_t marker_cnt;125unsigned reg = REG_A6XX_CP_SCRATCH_REG(scratch_idx);126if (__EMIT_MARKER) {127OUT_WFI5(ring);128OUT_PKT4(ring, reg, 1);129OUT_RING(ring, p_atomic_inc_return(&marker_cnt));130}131}132133struct fd6_vertex_stateobj {134struct fd_vertex_stateobj base;135struct fd_ringbuffer *stateobj;136};137138static inline struct fd6_vertex_stateobj *139fd6_vertex_stateobj(void *p)140{141return (struct fd6_vertex_stateobj *)p;142}143144#endif /* FD6_CONTEXT_H_ */145146147