Path: blob/21.2-virgl/src/gallium/auxiliary/draw/draw_pt.h
4565 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/*28* Authors:29* Keith Whitwell <[email protected]>30*/3132#ifndef DRAW_PT_H33#define DRAW_PT_H3435#include "pipe/p_compiler.h"3637struct draw_pt_middle_end;38struct draw_context;39struct draw_prim_info;40struct draw_vertex_info;414243#define PT_SHADE 0x144#define PT_CLIPTEST 0x245#define PT_PIPELINE 0x446#define PT_MAX_MIDDLE 0x8474849/* The "front end" - prepare sets of fetch, draw elements for the50* middle end.51*52* The fetch elements are indices to the vertices. The draw elements are53* indices to the fetched vertices. When both arrays of elements are both54* linear, middle->run_linear is called; When only the fetch elements are55* linear, middle->run_linear_elts is called; Otherwise, middle->run is56* called.57*58* When the number of the draw elements exceeds max_vertex of the middle end,59* the draw elements (as well as the fetch elements) are splitted and the60* middle end is called multiple times.61*62* Currenly there is:63* - vsplit - catchall implementation, splits big prims64*/65struct draw_pt_front_end {66void (*prepare)( struct draw_pt_front_end *,67unsigned prim,68struct draw_pt_middle_end *,69unsigned opt );7071void (*run)( struct draw_pt_front_end *,72unsigned start,73unsigned count );7475void (*flush)( struct draw_pt_front_end *, unsigned flags );76void (*destroy)( struct draw_pt_front_end * );77};787980/* The "middle end" - prepares actual hardware vertices for the81* hardware backend.82*83* prim_flags is as defined by pipe_draw_info::flags.84*85* Currently two versions of this:86* - fetch, vertex shade, cliptest, prim-pipeline87* - fetch, emit (ie passthrough)88*/89struct draw_pt_middle_end {90void (*prepare)( struct draw_pt_middle_end *,91unsigned prim,92unsigned opt,93unsigned *max_vertices );9495/**96* Bind/update parameter state such as constants, viewport dims97* and clip planes. Basically, stuff which isn't "baked" into the98* shader or pipeline state.99*/100void (*bind_parameters)(struct draw_pt_middle_end *);101102void (*run)( struct draw_pt_middle_end *,103const unsigned *fetch_elts,104unsigned fetch_count,105const ushort *draw_elts,106unsigned draw_count,107unsigned prim_flags );108109void (*run_linear)(struct draw_pt_middle_end *,110unsigned start,111unsigned count,112unsigned prim_flags );113114/* Transform all vertices in a linear range and then draw them with115* the supplied element list. May fail and return FALSE.116*/117boolean (*run_linear_elts)( struct draw_pt_middle_end *,118unsigned fetch_start,119unsigned fetch_count,120const ushort *draw_elts,121unsigned draw_count,122unsigned prim_flags );123124int (*get_max_vertex_count)( struct draw_pt_middle_end * );125126void (*finish)( struct draw_pt_middle_end * );127void (*destroy)( struct draw_pt_middle_end * );128};129130131/* The "back end" - supplied by the driver, defined in draw_vbuf.h.132*/133struct vbuf_render;134struct vertex_header;135136137/* Frontends:138*139* Currently only the general-purpose vsplit implementation.140*/141struct draw_pt_front_end *draw_pt_vsplit(struct draw_context *draw);142143144/* Middle-ends:145*146* Currently one general-purpose case which can do all possibilities,147* at the slight expense of creating a vertex_header in some cases148* unecessarily.149*/150struct draw_pt_middle_end *draw_pt_middle_fse( struct draw_context *draw );151struct draw_pt_middle_end *draw_pt_fetch_pipeline_or_emit(struct draw_context *draw);152struct draw_pt_middle_end *draw_pt_fetch_pipeline_or_emit_llvm(struct draw_context *draw);153154155156/*******************************************************************************157* HW vertex emit:158*/159struct pt_emit;160161void draw_pt_emit_prepare( struct pt_emit *emit,162unsigned prim,163unsigned *max_vertices );164165void draw_pt_emit( struct pt_emit *emit,166const struct draw_vertex_info *vert_info,167const struct draw_prim_info *prim_info);168169void draw_pt_emit_linear( struct pt_emit *emit,170const struct draw_vertex_info *vert_info,171const struct draw_prim_info *prim_info);172173void draw_pt_emit_destroy( struct pt_emit *emit );174175struct pt_emit *draw_pt_emit_create( struct draw_context *draw );176177/*******************************************************************************178* HW stream output emit:179*/180struct pt_so_emit;181182void draw_pt_so_emit_prepare(struct pt_so_emit *emit, boolean use_pre_clip_pos);183184void draw_pt_so_emit( struct pt_so_emit *emit,185int num_vertex_streams,186const struct draw_vertex_info *vert_info,187const struct draw_prim_info *prim_info );188189void draw_pt_so_emit_destroy( struct pt_so_emit *emit );190191struct pt_so_emit *draw_pt_so_emit_create( struct draw_context *draw );192193/*******************************************************************************194* API vertex fetch:195*/196197struct pt_fetch;198void draw_pt_fetch_prepare( struct pt_fetch *fetch,199unsigned vertex_input_count,200unsigned vertex_size,201unsigned instance_id_index );202203void draw_pt_fetch_run( struct pt_fetch *fetch,204const unsigned *elts,205unsigned count,206char *verts );207208void draw_pt_fetch_run_linear( struct pt_fetch *fetch,209unsigned start,210unsigned count,211char *verts );212213void draw_pt_fetch_destroy( struct pt_fetch *fetch );214215struct pt_fetch *draw_pt_fetch_create( struct draw_context *draw );216217/*******************************************************************************218* Post-VS: cliptest, rhw, viewport219*/220struct pt_post_vs;221222boolean draw_pt_post_vs_run( struct pt_post_vs *pvs,223struct draw_vertex_info *info,224const struct draw_prim_info *prim_info );225226void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,227boolean clip_xy,228boolean clip_z,229boolean clip_user,230boolean guard_band,231boolean bypass_viewport,232boolean clip_halfz,233boolean need_edgeflags );234235struct pt_post_vs *draw_pt_post_vs_create( struct draw_context *draw );236237void draw_pt_post_vs_destroy( struct pt_post_vs *pvs );238239240/*******************************************************************************241* Utils:242*/243void draw_pt_split_prim(unsigned prim, unsigned *first, unsigned *incr);244unsigned draw_pt_trim_count(unsigned count, unsigned first, unsigned incr);245246247#endif248249250