Path: blob/21.2-virgl/src/gallium/drivers/freedreno/a3xx/fd3_emit.h
4574 views
/*1* Copyright (C) 2013 Rob Clark <[email protected]>2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21*22* Authors:23* Rob Clark <[email protected]>24*/2526#ifndef FD3_EMIT_H27#define FD3_EMIT_H2829#include "pipe/p_context.h"3031#include "fd3_format.h"32#include "fd3_program.h"33#include "freedreno_batch.h"34#include "freedreno_context.h"35#include "ir3_cache.h"36#include "ir3_gallium.h"3738struct fd_ringbuffer;3940void fd3_emit_gmem_restore_tex(struct fd_ringbuffer *ring,41struct pipe_surface **psurf, int bufs);4243/* grouped together emit-state for prog/vertex/state emit: */44struct fd3_emit {45struct pipe_debug_callback *debug;46const struct fd_vertex_state *vtx;47const struct fd3_program_state *prog;48const struct pipe_draw_info *info;49unsigned drawid_offset;50const struct pipe_draw_indirect_info *indirect;51const struct pipe_draw_start_count_bias *draw;52bool binning_pass;53struct ir3_cache_key key;54enum fd_dirty_3d_state dirty;5556uint32_t sprite_coord_enable;57bool sprite_coord_mode;58bool rasterflat;59bool skip_consts;6061/* cached to avoid repeated lookups of same variants: */62const struct ir3_shader_variant *vs, *fs;63};6465static inline const struct ir3_shader_variant *66fd3_emit_get_vp(struct fd3_emit *emit)67{68if (!emit->vs) {69emit->vs = emit->binning_pass ? emit->prog->bs : emit->prog->vs;70}71return emit->vs;72}7374static inline const struct ir3_shader_variant *75fd3_emit_get_fp(struct fd3_emit *emit)76{77if (!emit->fs) {78if (emit->binning_pass) {79/* use dummy stateobj to simplify binning vs non-binning: */80static const struct ir3_shader_variant binning_fs = {};81emit->fs = &binning_fs;82} else {83emit->fs = emit->prog->fs;84}85}86return emit->fs;87}8889void fd3_emit_vertex_bufs(struct fd_ringbuffer *ring,90struct fd3_emit *emit) assert_dt;9192void fd3_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,93struct fd3_emit *emit) assert_dt;9495void fd3_emit_restore(struct fd_batch *batch,96struct fd_ringbuffer *ring) assert_dt;9798void fd3_emit_init_screen(struct pipe_screen *pscreen);99void fd3_emit_init(struct pipe_context *pctx);100101static inline void102fd3_emit_ib(struct fd_ringbuffer *ring, struct fd_ringbuffer *target)103{104__OUT_IB(ring, true, target);105}106107static inline void108fd3_emit_cache_flush(struct fd_batch *batch,109struct fd_ringbuffer *ring) assert_dt110{111fd_wfi(batch, ring);112OUT_PKT0(ring, REG_A3XX_UCHE_CACHE_INVALIDATE0_REG, 2);113OUT_RING(ring, A3XX_UCHE_CACHE_INVALIDATE0_REG_ADDR(0));114OUT_RING(ring, A3XX_UCHE_CACHE_INVALIDATE1_REG_ADDR(0) |115A3XX_UCHE_CACHE_INVALIDATE1_REG_OPCODE(INVALIDATE) |116A3XX_UCHE_CACHE_INVALIDATE1_REG_ENTIRE_CACHE);117}118119#endif /* FD3_EMIT_H */120121122