Path: blob/21.2-virgl/src/gallium/drivers/etnaviv/etnaviv_context.h
4570 views
/*1* Copyright (c) 2012-2015 Etnaviv Project2*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, sub license,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 the11* next paragraph) shall be included in all copies or substantial portions12* of the 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 NON-INFRINGEMENT. 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, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER20* DEALINGS IN THE SOFTWARE.21*22* Authors:23* Wladimir J. van der Laan <[email protected]>24* Christian Gmeiner <[email protected]>25*/2627#ifndef H_ETNAVIV_CONTEXT28#define H_ETNAVIV_CONTEXT2930#include <stdint.h>3132#include "etnaviv_resource.h"33#include "etnaviv_tiling.h"34#include "indices/u_primconvert.h"35#include "pipe/p_context.h"36#include "pipe/p_defines.h"37#include "pipe/p_format.h"38#include "pipe/p_shader_tokens.h"39#include "pipe/p_state.h"40#include "util/slab.h"4142struct pipe_screen;43struct etna_shader_variant;44struct etna_sampler_ts;4546struct etna_index_buffer {47struct etna_reloc FE_INDEX_STREAM_BASE_ADDR;48uint32_t FE_INDEX_STREAM_CONTROL;49uint32_t FE_PRIMITIVE_RESTART_INDEX;50};5152struct etna_shader_input {53int vs_reg; /* VS input register */54};5556enum etna_varying_special {57ETNA_VARYING_VSOUT = 0, /* from VS */58ETNA_VARYING_POINTCOORD, /* point texture coord */59};6061struct etna_shader_varying {62int num_components;63enum etna_varying_special special;64int pa_attributes;65int vs_reg; /* VS output register */66};6768struct etna_transfer {69struct pipe_transfer base;70struct pipe_resource *rsc;71void *staging;72void *mapped;73};7475struct etna_constbuf_state {76struct pipe_constant_buffer cb[ETNA_MAX_CONST_BUF];77uint32_t enabled_mask;78};7980struct etna_vertexbuf_state {81struct pipe_vertex_buffer vb[PIPE_MAX_ATTRIBS];82struct compiled_set_vertex_buffer cvb[PIPE_MAX_ATTRIBS];83unsigned count;84uint32_t enabled_mask;85};8687struct etna_shader_state {88void *bind_vs, *bind_fs;89struct etna_shader_variant *vs, *fs;90};9192enum etna_uniform_contents {93ETNA_UNIFORM_UNUSED = 0,94ETNA_UNIFORM_CONSTANT,95ETNA_UNIFORM_UNIFORM,96ETNA_UNIFORM_TEXRECT_SCALE_X,97ETNA_UNIFORM_TEXRECT_SCALE_Y,98ETNA_UNIFORM_UBO0_ADDR,99ETNA_UNIFORM_UBOMAX_ADDR = ETNA_UNIFORM_UBO0_ADDR + ETNA_MAX_CONST_BUF - 1,100};101102struct etna_shader_uniform_info {103enum etna_uniform_contents *contents;104uint32_t *data;105uint32_t count;106};107108struct etna_context {109struct pipe_context base;110111/* GPU-specific implementation to emit texture state */112void (*emit_texture_state)(struct etna_context *pctx);113/* Get sampler TS pointer for sampler view */114struct etna_sampler_ts *(*ts_for_sampler_view)(struct pipe_sampler_view *pview);115/* GPU-specific blit implementation */116bool (*blit)(struct pipe_context *pipe, const struct pipe_blit_info *info);117118struct etna_screen *screen;119struct etna_cmd_stream *stream;120121/* which state objects need to be re-emit'd: */122enum {123ETNA_DIRTY_BLEND = (1 << 0),124ETNA_DIRTY_SAMPLERS = (1 << 1),125ETNA_DIRTY_RASTERIZER = (1 << 2),126ETNA_DIRTY_ZSA = (1 << 3),127ETNA_DIRTY_VERTEX_ELEMENTS = (1 << 4),128ETNA_DIRTY_BLEND_COLOR = (1 << 6),129ETNA_DIRTY_STENCIL_REF = (1 << 7),130ETNA_DIRTY_SAMPLE_MASK = (1 << 8),131ETNA_DIRTY_VIEWPORT = (1 << 9),132ETNA_DIRTY_FRAMEBUFFER = (1 << 10),133ETNA_DIRTY_SCISSOR = (1 << 11),134ETNA_DIRTY_SAMPLER_VIEWS = (1 << 12),135ETNA_DIRTY_CONSTBUF = (1 << 13),136ETNA_DIRTY_VERTEX_BUFFERS = (1 << 14),137ETNA_DIRTY_INDEX_BUFFER = (1 << 15),138ETNA_DIRTY_SHADER = (1 << 16),139ETNA_DIRTY_TS = (1 << 17),140ETNA_DIRTY_TEXTURE_CACHES = (1 << 18),141ETNA_DIRTY_DERIVE_TS = (1 << 19),142ETNA_DIRTY_SCISSOR_CLIP = (1 << 20),143} dirty;144145uint32_t prim_hwsupport;146struct primconvert_context *primconvert;147148struct slab_child_pool transfer_pool;149struct blitter_context *blitter;150151/* compiled bindable state */152unsigned sample_mask;153struct pipe_blend_state *blend;154unsigned num_fragment_samplers;155uint32_t active_samplers;156struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];157struct pipe_rasterizer_state *rasterizer;158struct pipe_depth_stencil_alpha_state *zsa;159struct compiled_vertex_elements_state *vertex_elements;160struct compiled_shader_state shader_state;161struct pipe_scissor_state clipping;162163/* to simplify the emit process we store pre compiled state objects,164* which got 'compiled' during state change. */165struct compiled_blend_color blend_color;166struct compiled_stencil_ref stencil_ref;167struct compiled_framebuffer_state framebuffer;168struct compiled_viewport_state viewport;169unsigned num_fragment_sampler_views;170uint32_t active_sampler_views;171uint32_t dirty_sampler_views;172struct pipe_sampler_view *sampler_view[PIPE_MAX_SAMPLERS];173struct etna_constbuf_state constant_buffer[PIPE_SHADER_TYPES];174struct etna_vertexbuf_state vertex_buffer;175struct etna_index_buffer index_buffer;176struct etna_shader_state shader;177178/* saved parameter-like state. these are mainly kept around for the blitter */179struct pipe_framebuffer_state framebuffer_s;180struct pipe_stencil_ref stencil_ref_s;181struct pipe_viewport_state viewport_s;182struct pipe_scissor_state scissor;183184/* stats/counters */185struct {186uint64_t prims_generated;187uint64_t draw_calls;188uint64_t rs_operations;189} stats;190191struct pipe_debug_callback debug;192int in_fence_fd;193194/* list of accumulated HW queries */195struct list_head active_acc_queries;196197struct etna_bo *dummy_rt;198struct etna_reloc dummy_rt_reloc;199200/* Dummy texture descriptor (if needed) */201struct etna_bo *dummy_desc_bo;202struct etna_reloc DUMMY_DESC_ADDR;203204/* set of resources used by currently-unsubmitted renders */205struct set *used_resources_read;206struct set *used_resources_write;207208/* resources that must be flushed implicitly at the context flush time */209struct set *flush_resources;210211mtx_t lock;212};213214static inline struct etna_context *215etna_context(struct pipe_context *pctx)216{217return (struct etna_context *)pctx;218}219220static inline struct etna_transfer *221etna_transfer(struct pipe_transfer *p)222{223return (struct etna_transfer *)p;224}225226struct pipe_context *227etna_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags);228229#endif230231232