Path: blob/21.2-virgl/src/gallium/drivers/llvmpipe/lp_bld_interp.h
4570 views
/**************************************************************************1*2* Copyright 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**************************************************************************/2627/**28* @file29* Position and shader input interpolation.30*31* Special attention is given to the interpolation of side by side quads.32* Multiplications are made only for the first quad. Interpolation of33* inputs for posterior quads are done exclusively with additions, and34* perspective divide if necessary.35*36* @author Jose Fonseca <[email protected]>37*/3839#ifndef LP_BLD_INTERP_H40#define LP_BLD_INTERP_H414243#include "gallivm/lp_bld.h"44#include "gallivm/lp_bld_type.h"4546#include "tgsi/tgsi_exec.h"4748/**49* Describes how to compute the interpolation coefficients (a0, dadx, dady)50* from the vertices passed into our triangle/line/point functions by the51* draw module.52*53* Vertices are treated as an array of float[4] values, indexed by54* src_index.55*56* LP_INTERP_COLOR is translated to either LP_INTERP_CONSTANT or57* PERSPECTIVE depending on flatshade state.58*/59enum lp_interp {60LP_INTERP_CONSTANT,61LP_INTERP_COLOR,62LP_INTERP_LINEAR,63LP_INTERP_PERSPECTIVE,64LP_INTERP_POSITION,65LP_INTERP_FACING66};6768struct lp_shader_input {69uint interp:4; /* enum lp_interp */70uint usage_mask:4; /* bitmask of TGSI_WRITEMASK_x flags */71uint src_index:8; /* where to find values in incoming vertices */72uint cyl_wrap:4; /* TGSI_CYLINDRICAL_WRAP_x flags */73uint location:2; /* TGSI_INTERPOLOATE_LOC_* */74uint padding:10;75};767778struct lp_build_interp_soa_context79{80/* TGSI_QUAD_SIZE x float */81struct lp_build_context coeff_bld;82struct lp_build_context setup_bld;8384unsigned num_attribs;85unsigned mask[1 + PIPE_MAX_SHADER_INPUTS]; /**< TGSI_WRITE_MASK_x */86enum lp_interp interp[1 + PIPE_MAX_SHADER_INPUTS];87unsigned interp_loc[1 + PIPE_MAX_SHADER_INPUTS];88boolean depth_clamp;8990double pos_offset;91unsigned coverage_samples;92LLVMValueRef num_loop;93LLVMValueRef sample_pos_array;9495LLVMValueRef x;96LLVMValueRef y;9798LLVMValueRef a0_ptr;99LLVMValueRef dadx_ptr;100LLVMValueRef dady_ptr;101102LLVMValueRef a0aos[1 + PIPE_MAX_SHADER_INPUTS];103LLVMValueRef dadxaos[1 + PIPE_MAX_SHADER_INPUTS];104LLVMValueRef dadyaos[1 + PIPE_MAX_SHADER_INPUTS];105106LLVMValueRef attribs[1 + PIPE_MAX_SHADER_INPUTS][TGSI_NUM_CHANNELS];107108LLVMValueRef xoffset_store;109LLVMValueRef yoffset_store;110111/*112* Convenience pointers. Callers may access this one.113*/114const LLVMValueRef *pos;115const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS];116};117118119void120lp_build_interp_soa_init(struct lp_build_interp_soa_context *bld,121struct gallivm_state *gallivm,122unsigned num_inputs,123const struct lp_shader_input *inputs,124boolean pixel_center_integer,125unsigned coverage_samples,126LLVMValueRef sample_pos_array,127LLVMValueRef num_loop,128boolean depth_clamp,129LLVMBuilderRef builder,130struct lp_type type,131LLVMValueRef a0_ptr,132LLVMValueRef dadx_ptr,133LLVMValueRef dady_ptr,134LLVMValueRef x,135LLVMValueRef y);136137void138lp_build_interp_soa_update_inputs_dyn(struct lp_build_interp_soa_context *bld,139struct gallivm_state *gallivm,140LLVMValueRef quad_start_index,141LLVMValueRef mask_store,142LLVMValueRef sample_id);143144void145lp_build_interp_soa_update_pos_dyn(struct lp_build_interp_soa_context *bld,146struct gallivm_state *gallivm,147LLVMValueRef quad_start_index,148LLVMValueRef sample_id);149150LLVMValueRef151lp_build_interp_soa(struct lp_build_interp_soa_context *bld,152struct gallivm_state *gallivm,153LLVMValueRef loop_iter,154LLVMValueRef mask_store,155unsigned attrib, unsigned chan,156unsigned loc,157LLVMValueRef indir_index,158LLVMValueRef offsets[2]);159160#endif /* LP_BLD_INTERP_H */161162163