Path: blob/21.2-virgl/src/gallium/drivers/llvmpipe/lp_setup_context.h
4570 views
/**************************************************************************1*2* Copyright 2007-2009 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**************************************************************************/262728/**29* The setup code is concerned with point/line/triangle setup and30* putting commands/data into the bins.31*/323334#ifndef LP_SETUP_CONTEXT_H35#define LP_SETUP_CONTEXT_H3637#include "lp_setup.h"38#include "lp_rast.h"39#include "lp_scene.h"40#include "lp_bld_interp.h" /* for struct lp_shader_input */4142#include "draw/draw_vbuf.h"43#include "util/u_rect.h"44#include "util/u_pack_color.h"4546#define LP_SETUP_NEW_FS 0x0147#define LP_SETUP_NEW_CONSTANTS 0x0248#define LP_SETUP_NEW_BLEND_COLOR 0x0449#define LP_SETUP_NEW_SCISSOR 0x0850#define LP_SETUP_NEW_VIEWPORTS 0x1051#define LP_SETUP_NEW_SSBOS 0x205253struct lp_setup_variant;545556/** Max number of scenes */57/* XXX: make multiple scenes per context work, see lp_setup_rasterize_scene */58#define MAX_SCENES 159606162/**63* Point/line/triangle setup context.64* Note: "stored" below indicates data which is stored in the bins,65* not arbitrary malloc'd memory.66*67*68* Subclass of vbuf_render, plugged directly into the draw module as69* the rendering backend.70*/71struct lp_setup_context72{73struct vbuf_render base;7475struct pipe_context *pipe;76struct vertex_info *vertex_info;77uint view_index;78uint prim;79uint vertex_size;80uint nr_vertices;81uint sprite_coord_enable, sprite_coord_origin;82uint vertex_buffer_size;83void *vertex_buffer;8485/* Final pipeline stage for draw module. Draw module should86* create/install this itself now.87*/88struct draw_stage *vbuf;89unsigned num_threads;90unsigned scene_idx;91struct lp_scene *scenes[MAX_SCENES]; /**< all the scenes */92struct lp_scene *scene; /**< current scene being built */9394struct lp_fence *last_fence;95struct llvmpipe_query *active_queries[LP_MAX_ACTIVE_BINNED_QUERIES];96unsigned active_binned_queries;9798boolean flatshade_first;99boolean ccw_is_frontface;100boolean scissor_test;101boolean point_size_per_vertex;102boolean legacy_points;103boolean rasterizer_discard;104boolean multisample;105boolean rectangular_lines;106unsigned cullmode;107unsigned bottom_edge_rule;108float pixel_offset;109float line_width;110float point_size;111int8_t psize_slot;112int8_t viewport_index_slot;113int8_t layer_slot;114int8_t face_slot;115116struct pipe_framebuffer_state fb;117struct u_rect framebuffer;118struct u_rect scissors[PIPE_MAX_VIEWPORTS];119struct u_rect draw_regions[PIPE_MAX_VIEWPORTS]; /* intersection of fb & scissor */120struct lp_jit_viewport viewports[PIPE_MAX_VIEWPORTS];121122struct {123unsigned flags;124union util_color color_val[PIPE_MAX_COLOR_BUFS];125uint64_t zsmask;126uint64_t zsvalue; /**< lp_rast_clear_zstencil() cmd */127} clear;128129enum setup_state {130SETUP_FLUSHED, /**< scene is null */131SETUP_CLEARED, /**< scene exists but has only clears */132SETUP_ACTIVE /**< scene exists and has at least one draw/query */133} state;134135struct {136const struct lp_rast_state *stored; /**< what's in the scene */137struct lp_rast_state current; /**< currently set state */138struct pipe_resource *current_tex[PIPE_MAX_SHADER_SAMPLER_VIEWS];139unsigned current_tex_num;140} fs;141142/** fragment shader constants */143struct {144struct pipe_constant_buffer current;145unsigned stored_size;146const void *stored_data;147} constants[LP_MAX_TGSI_CONST_BUFFERS];148149/** fragment shader buffers */150struct {151struct pipe_shader_buffer current;152} ssbos[LP_MAX_TGSI_SHADER_BUFFERS];153154struct {155struct pipe_image_view current;156} images[LP_MAX_TGSI_SHADER_IMAGES];157158struct {159struct pipe_blend_color current;160uint8_t *stored;161} blend_color;162163164struct {165const struct lp_setup_variant *variant;166} setup;167168unsigned dirty; /**< bitmask of LP_SETUP_NEW_x bits */169170void (*point)( struct lp_setup_context *,171const float (*v0)[4]);172173void (*line)( struct lp_setup_context *,174const float (*v0)[4],175const float (*v1)[4]);176177void (*triangle)( struct lp_setup_context *,178const float (*v0)[4],179const float (*v1)[4],180const float (*v2)[4]);181};182183static inline void184scissor_planes_needed(boolean scis_planes[4], const struct u_rect *bbox,185const struct u_rect *scissor)186{187/* left */188scis_planes[0] = (bbox->x0 < scissor->x0);189/* right */190scis_planes[1] = (bbox->x1 > scissor->x1);191/* top */192scis_planes[2] = (bbox->y0 < scissor->y0);193/* bottom */194scis_planes[3] = (bbox->y1 > scissor->y1);195}196197198void lp_setup_choose_triangle( struct lp_setup_context *setup );199void lp_setup_choose_line( struct lp_setup_context *setup );200void lp_setup_choose_point( struct lp_setup_context *setup );201202void lp_setup_init_vbuf(struct lp_setup_context *setup);203204boolean lp_setup_update_state( struct lp_setup_context *setup,205boolean update_scene);206207void lp_setup_destroy( struct lp_setup_context *setup );208209boolean lp_setup_flush_and_restart(struct lp_setup_context *setup);210211void212lp_setup_print_triangle(struct lp_setup_context *setup,213const float (*v0)[4],214const float (*v1)[4],215const float (*v2)[4]);216217void218lp_setup_print_vertex(struct lp_setup_context *setup,219const char *name,220const float (*v)[4]);221222223struct lp_rast_triangle *224lp_setup_alloc_triangle(struct lp_scene *scene,225unsigned num_inputs,226unsigned nr_planes,227unsigned *tri_size);228229boolean230lp_setup_bin_triangle(struct lp_setup_context *setup,231struct lp_rast_triangle *tri,232const struct u_rect *bboxorig,233const struct u_rect *bbox,234int nr_planes,235unsigned scissor_index);236237#endif238239240