Path: blob/21.2-virgl/src/gallium/auxiliary/draw/draw_pipe.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_PIPE_H33#define DRAW_PIPE_H3435#include "pipe/p_compiler.h"36#include "draw_private.h" /* for sizeof(vertex_header) */37#include "draw_context.h"383940/**41* Basic info for a point/line/triangle primitive.42*/43struct prim_header {44float det; /**< front/back face determinant */45ushort flags;46ushort pad;47struct vertex_header *v[3]; /**< 1 to 3 vertex pointers */48};49505152/**53* Base class for all primitive drawing stages.54*/55struct draw_stage56{57struct draw_context *draw; /**< parent context */5859struct draw_stage *next; /**< next stage in pipeline */60const char *name; /**< for debugging */6162struct vertex_header **tmp; /**< temp vert storage, such as for clipping */63unsigned nr_tmps;6465void (*point)( struct draw_stage *,66struct prim_header * );6768void (*line)( struct draw_stage *,69struct prim_header * );7071void (*tri)( struct draw_stage *,72struct prim_header * );7374void (*flush)( struct draw_stage *,75unsigned flags );7677void (*reset_stipple_counter)( struct draw_stage * );7879void (*destroy)( struct draw_stage * );80};818283extern struct draw_stage *draw_unfilled_stage( struct draw_context *context );84extern struct draw_stage *draw_twoside_stage( struct draw_context *context );85extern struct draw_stage *draw_offset_stage( struct draw_context *context );86extern struct draw_stage *draw_clip_stage( struct draw_context *context );87extern struct draw_stage *draw_flatshade_stage( struct draw_context *context );88extern struct draw_stage *draw_cull_stage( struct draw_context *context );89extern struct draw_stage *draw_user_cull_stage( struct draw_context *draw );90extern struct draw_stage *draw_stipple_stage( struct draw_context *context );91extern struct draw_stage *draw_wide_line_stage( struct draw_context *context );92extern struct draw_stage *draw_wide_point_stage( struct draw_context *context );93extern struct draw_stage *draw_validate_stage( struct draw_context *context );9495extern void draw_free_temp_verts( struct draw_stage *stage );96extern boolean draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr );9798extern void draw_reset_vertex_ids( struct draw_context *draw );99100void draw_pipe_passthrough_tri(struct draw_stage *stage, struct prim_header *header);101void draw_pipe_passthrough_line(struct draw_stage *stage, struct prim_header *header);102void draw_pipe_passthrough_point(struct draw_stage *stage, struct prim_header *header);103104void draw_aapoint_prepare_outputs(struct draw_context *context,105struct draw_stage *stage);106void draw_aaline_prepare_outputs(struct draw_context *context,107struct draw_stage *stage);108void draw_unfilled_prepare_outputs(struct draw_context *context,109struct draw_stage *stage);110111/**112* Get a writeable copy of a vertex.113* \param stage drawing stage info114* \param vert the vertex to copy (source)115* \param idx index into stage's tmp[] array to put the copy (dest)116* \return pointer to the copied vertex117*/118static inline struct vertex_header *119dup_vert( struct draw_stage *stage,120const struct vertex_header *vert,121unsigned idx )122{123struct vertex_header *tmp = stage->tmp[idx];124const uint vsize = sizeof(struct vertex_header)125+ draw_num_shader_outputs(stage->draw) * 4 * sizeof(float);126memcpy(tmp, vert, vsize);127tmp->vertex_id = UNDEFINED_VERTEX_ID;128return tmp;129}130131#endif132133134