Path: blob/21.2-virgl/src/gallium/drivers/softpipe/sp_context.h
4570 views
/**************************************************************************1*2* Copyright 2007 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627/* Authors: Keith Whitwell <[email protected]>28*/2930#ifndef SP_CONTEXT_H31#define SP_CONTEXT_H3233#include "pipe/p_context.h"34#include "util/u_blitter.h"3536#include "draw/draw_vertex.h"3738#include "sp_quad_pipe.h"39#include "sp_setup.h"404142/** Do polygon stipple in the draw module? */43#define DO_PSTIPPLE_IN_DRAW_MODULE 04445/** Do polygon stipple with the util module? */46#define DO_PSTIPPLE_IN_HELPER_MODULE 1474849struct softpipe_vbuf_render;50struct draw_context;51struct draw_stage;52struct softpipe_tile_cache;53struct softpipe_tex_tile_cache;54struct sp_fragment_shader;55struct sp_vertex_shader;56struct sp_velems_state;57struct sp_so_state;5859struct softpipe_context {60struct pipe_context pipe; /**< base class */6162/** Constant state objects */63struct pipe_blend_state *blend;64struct pipe_sampler_state *samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];65struct pipe_depth_stencil_alpha_state *depth_stencil;66struct pipe_rasterizer_state *rasterizer;67struct sp_fragment_shader *fs;68struct sp_fragment_shader_variant *fs_variant;69struct sp_vertex_shader *vs;70struct sp_geometry_shader *gs;71struct sp_velems_state *velems;72struct sp_so_state *so;73struct sp_compute_shader *cs;7475/** Other rendering state */76struct pipe_blend_color blend_color;77struct pipe_blend_color blend_color_clamped;78struct pipe_stencil_ref stencil_ref;79struct pipe_clip_state clip;80struct pipe_resource *constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];81struct pipe_framebuffer_state framebuffer;82struct pipe_poly_stipple poly_stipple;83struct pipe_scissor_state scissors[PIPE_MAX_VIEWPORTS];84struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS];8586struct pipe_image_view images[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_IMAGES];87struct pipe_shader_buffer buffers[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_BUFFERS];88struct pipe_viewport_state viewports[PIPE_MAX_VIEWPORTS];89struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];90struct pipe_resource *mapped_vs_tex[PIPE_MAX_SHADER_SAMPLER_VIEWS];91struct pipe_resource *mapped_gs_tex[PIPE_MAX_SHADER_SAMPLER_VIEWS];9293struct draw_so_target *so_targets[PIPE_MAX_SO_BUFFERS];94unsigned num_so_targets;9596struct pipe_query_data_so_statistics so_stats[PIPE_MAX_VERTEX_STREAMS];9798struct pipe_query_data_pipeline_statistics pipeline_statistics;99unsigned active_statistics_queries;100101unsigned num_samplers[PIPE_SHADER_TYPES];102unsigned num_sampler_views[PIPE_SHADER_TYPES];103104unsigned num_vertex_buffers;105106unsigned dirty; /**< Mask of SP_NEW_x flags */107108/* Counter for occlusion queries. Note this supports overlapping109* queries.110*/111uint64_t occlusion_count;112unsigned active_query_count;113114/** Mapped vertex buffers */115ubyte *mapped_vbuffer[PIPE_MAX_ATTRIBS];116117/** Mapped constant buffers */118const void *mapped_constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];119unsigned const_buffer_size[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];120121/** Vertex format */122struct sp_setup_info setup_info;123struct vertex_info vertex_info;124125/** Which vertex shader output slot contains point size */126int8_t psize_slot;127128/** Which vertex shader output slot contains viewport index */129int8_t viewport_index_slot;130131/** Which vertex shader output slot contains layer */132int8_t layer_slot;133134/** The reduced version of the primitive supplied by the gallium frontend */135unsigned reduced_api_prim;136137/** Derived information about which winding orders to cull */138unsigned cull_mode;139140/**141* The reduced primitive after unfilled triangles, wide-line decomposition,142* etc, are taken into account. This is the primitive type that's actually143* rasterized.144*/145unsigned reduced_prim;146147/** Derived from scissor and surface bounds: */148struct pipe_scissor_state cliprect[PIPE_MAX_VIEWPORTS];149150/** Conditional query object and mode */151struct pipe_query *render_cond_query;152enum pipe_render_cond_flag render_cond_mode;153bool render_cond_cond;154155/** Polygon stipple items */156struct {157struct pipe_resource *texture;158struct pipe_sampler_state *sampler;159struct pipe_sampler_view *sampler_view;160} pstipple;161162/** Software quad rendering pipeline */163struct {164struct quad_stage *shade;165struct quad_stage *depth_test;166struct quad_stage *blend;167struct quad_stage *pstipple;168struct quad_stage *first; /**< points to one of the above stages */169} quad;170171/** TGSI exec things */172struct {173struct sp_tgsi_sampler *sampler[PIPE_SHADER_TYPES];174struct sp_tgsi_image *image[PIPE_SHADER_TYPES];175struct sp_tgsi_buffer *buffer[PIPE_SHADER_TYPES];176} tgsi;177178struct tgsi_exec_machine *fs_machine;179/** whether early depth testing is enabled */180bool early_depth;181182/** The primitive drawing context */183struct draw_context *draw;184185/** Draw module backend */186struct vbuf_render *vbuf_backend;187struct draw_stage *vbuf;188189struct blitter_context *blitter;190191boolean dirty_render_cache;192193struct softpipe_tile_cache *cbuf_cache[PIPE_MAX_COLOR_BUFS];194struct softpipe_tile_cache *zsbuf_cache;195196unsigned tex_timestamp;197198/*199* Texture caches for vertex, fragment, geometry stages.200* Don't use PIPE_SHADER_TYPES here to avoid allocating unused memory201* for compute shaders.202* XXX wouldn't it make more sense for the tile cache to just be part203* of sp_sampler_view?204*/205struct softpipe_tex_tile_cache *tex_cache[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS];206207struct pipe_debug_callback debug;208};209210211static inline struct softpipe_context *212softpipe_context( struct pipe_context *pipe )213{214return (struct softpipe_context *)pipe;215}216217218struct pipe_context *219softpipe_create_context(struct pipe_screen *, void *priv, unsigned flags);220221struct pipe_resource *222softpipe_user_buffer_create(struct pipe_screen *screen,223void *ptr,224unsigned bytes,225unsigned bind_flags);226227#define SP_UNREFERENCED 0228#define SP_REFERENCED_FOR_READ (1 << 0)229#define SP_REFERENCED_FOR_WRITE (1 << 1)230231unsigned int232softpipe_is_resource_referenced( struct pipe_context *pipe,233struct pipe_resource *texture,234unsigned level, int layer);235236#endif /* SP_CONTEXT_H */237238239