Path: blob/21.2-virgl/src/intel/compiler/brw_clip.h
4550 views
/*1Copyright (C) Intel Corp. 2006. All Rights Reserved.2Intel funded Tungsten Graphics to3develop this 3D driver.45Permission is hereby granted, free of charge, to any person obtaining6a copy of this software and associated documentation files (the7"Software"), to deal in the Software without restriction, including8without limitation the rights to use, copy, modify, merge, publish,9distribute, sublicense, and/or sell copies of the Software, and to10permit persons to whom the Software is furnished to do so, subject to11the following conditions:1213The above copyright notice and this permission notice (including the14next paragraph) shall be included in all copies or substantial15portions of the Software.1617THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,18EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.20IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE21LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION22OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION23WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.2425**********************************************************************/26/*27* Authors:28* Keith Whitwell <[email protected]>29*/3031#ifndef BRW_CLIP_H32#define BRW_CLIP_H3334#include "brw_compiler.h"35#include "brw_eu.h"3637/* Initial 3 verts, plus at most 6 additional verts from intersections38* with fixed planes, plus at most 8 additional verts from intersections39* with user clip planes40*/41#define MAX_VERTS (3+6+8)4243#define PRIM_MASK (0x1f)4445struct brw_clip_compile {46struct brw_codegen func;47struct brw_clip_prog_key key;48struct brw_clip_prog_data prog_data;4950struct {51struct brw_reg R0;52struct brw_reg vertex[MAX_VERTS];5354struct brw_reg t;55struct brw_reg t0, t1;56struct brw_reg dp0, dp1;5758struct brw_reg dpPrev;59struct brw_reg dp;60struct brw_reg loopcount;61struct brw_reg nr_verts;62struct brw_reg planemask;6364struct brw_reg inlist;65struct brw_reg outlist;66struct brw_reg freelist;6768struct brw_reg dir;69struct brw_reg tmp0, tmp1;70struct brw_reg offset;7172struct brw_reg fixed_planes;73struct brw_reg plane_equation;7475struct brw_reg ff_sync;7677/* Bitmask indicating which coordinate attribute should be used for78* comparison to each clipping plane. A 0 indicates that VARYING_SLOT_POS79* should be used, because it's one of the fixed +/- x/y/z planes that80* constitute the bounds of the view volume. A 1 indicates that81* VARYING_SLOT_CLIP_VERTEX should be used (if available) since it's a user-82* defined clipping plane.83*/84struct brw_reg vertex_src_mask;8586/* Offset into the vertex of the current plane's clipdistance value */87struct brw_reg clipdistance_offset;88} reg;8990/* Number of registers storing VUE data */91GLuint nr_regs;9293GLuint first_tmp;94GLuint last_tmp;9596bool need_direction;9798struct brw_vue_map vue_map;99};100101/**102* True if the given varying is one of the outputs of the vertex shader.103*/104static inline bool brw_clip_have_varying(struct brw_clip_compile *c,105GLuint varying)106{107return (c->key.attrs & BITFIELD64_BIT(varying)) ? 1 : 0;108}109110/* Points are only culled, so no need for a clip routine, however it111* works out easier to have a dummy one.112*/113void brw_emit_unfilled_clip( struct brw_clip_compile *c );114void brw_emit_tri_clip( struct brw_clip_compile *c );115void brw_emit_line_clip( struct brw_clip_compile *c );116void brw_emit_point_clip( struct brw_clip_compile *c );117118/* brw_clip_tri.c, for use by the unfilled clip routine:119*/120void brw_clip_tri_init_vertices( struct brw_clip_compile *c );121void brw_clip_tri_flat_shade( struct brw_clip_compile *c );122void brw_clip_tri( struct brw_clip_compile *c );123void brw_clip_tri_emit_polygon( struct brw_clip_compile *c );124void brw_clip_tri_alloc_regs( struct brw_clip_compile *c,125GLuint nr_verts );126127128/* Utils:129*/130131void brw_clip_interp_vertex( struct brw_clip_compile *c,132struct brw_indirect dest_ptr,133struct brw_indirect v0_ptr, /* from */134struct brw_indirect v1_ptr, /* to */135struct brw_reg t0,136bool force_edgeflag );137138void brw_clip_init_planes( struct brw_clip_compile *c );139140void brw_clip_emit_vue(struct brw_clip_compile *c,141struct brw_indirect vert,142enum brw_urb_write_flags flags,143GLuint header);144145void brw_clip_kill_thread(struct brw_clip_compile *c);146147struct brw_reg brw_clip_plane_stride( struct brw_clip_compile *c );148struct brw_reg brw_clip_plane0_address( struct brw_clip_compile *c );149150void brw_clip_copy_flatshaded_attributes( struct brw_clip_compile *c,151GLuint to, GLuint from );152153void brw_clip_init_clipmask( struct brw_clip_compile *c );154155struct brw_reg get_tmp( struct brw_clip_compile *c );156157void brw_clip_project_position(struct brw_clip_compile *c,158struct brw_reg pos );159void brw_clip_ff_sync(struct brw_clip_compile *c);160void brw_clip_init_ff_sync(struct brw_clip_compile *c);161162#endif163164165