Path: blob/21.2-virgl/src/gallium/drivers/freedreno/a4xx/fd4_emit.h
4574 views
/*1* Copyright (C) 2014 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 FD4_EMIT_H27#define FD4_EMIT_H2829#include "pipe/p_context.h"3031#include "fd4_format.h"32#include "fd4_program.h"33#include "freedreno_context.h"34#include "ir3_gallium.h"3536struct fd_ringbuffer;3738void fd4_emit_gmem_restore_tex(struct fd_ringbuffer *ring, unsigned nr_bufs,39struct pipe_surface **bufs);4041/* grouped together emit-state for prog/vertex/state emit: */42struct fd4_emit {43struct pipe_debug_callback *debug;44const struct fd_vertex_state *vtx;45const struct fd4_program_state *prog;46const struct pipe_draw_info *info;47unsigned drawid_offset;48const struct pipe_draw_indirect_info *indirect;49const struct pipe_draw_start_count_bias *draw;50bool binning_pass;51struct ir3_cache_key key;52enum fd_dirty_3d_state dirty;5354uint32_t sprite_coord_enable; /* bitmask */55bool sprite_coord_mode;56bool rasterflat;57bool no_decode_srgb;58bool skip_consts;5960/* cached to avoid repeated lookups of same variants: */61const struct ir3_shader_variant *vs, *fs;62/* TODO: other shader stages.. */63};6465static inline enum a4xx_color_fmt66fd4_emit_format(struct pipe_surface *surf)67{68if (!surf)69return 0;70return fd4_pipe2color(surf->format);71}7273static inline const struct ir3_shader_variant *74fd4_emit_get_vp(struct fd4_emit *emit)75{76if (!emit->vs) {77emit->vs = emit->binning_pass ? emit->prog->bs : emit->prog->vs;78}79return emit->vs;80}8182static inline const struct ir3_shader_variant *83fd4_emit_get_fp(struct fd4_emit *emit)84{85if (!emit->fs) {86if (emit->binning_pass) {87/* use dummy stateobj to simplify binning vs non-binning: */88static const struct ir3_shader_variant binning_fs = {};89emit->fs = &binning_fs;90} else {91emit->fs = emit->prog->fs;92}93}94return emit->fs;95}9697void fd4_emit_vertex_bufs(struct fd_ringbuffer *ring,98struct fd4_emit *emit) assert_dt;99100void fd4_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,101struct fd4_emit *emit) assert_dt;102103void fd4_emit_restore(struct fd_batch *batch,104struct fd_ringbuffer *ring) assert_dt;105106void fd4_emit_init_screen(struct pipe_screen *pscreen);107void fd4_emit_init(struct pipe_context *pctx);108109static inline void110fd4_emit_ib(struct fd_ringbuffer *ring, struct fd_ringbuffer *target)111{112__OUT_IB(ring, true, target);113}114115#endif /* FD4_EMIT_H */116117118