1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright 2019 Advanced Micro Devices, Inc. 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the 6bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 7bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 8bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to 9bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 10bf215546Sopenharmony_ci * the following conditions: 11bf215546Sopenharmony_ci * 12bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 15bf215546Sopenharmony_ci * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 16bf215546Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 17bf215546Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 18bf215546Sopenharmony_ci * USE OR OTHER DEALINGS IN THE SOFTWARE. 19bf215546Sopenharmony_ci * 20bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the 21bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions 22bf215546Sopenharmony_ci * of the Software. 23bf215546Sopenharmony_ci * 24bf215546Sopenharmony_ci */ 25bf215546Sopenharmony_ci 26bf215546Sopenharmony_ci#ifndef AC_LLVM_CULL_H 27bf215546Sopenharmony_ci#define AC_LLVM_CULL_H 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#include "ac_llvm_build.h" 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_cistruct ac_cull_options { 32bf215546Sopenharmony_ci /* In general, I recommend setting all to true except view Z culling, 33bf215546Sopenharmony_ci * which isn't so effective because W culling is cheaper and partially 34bf215546Sopenharmony_ci * replaces near Z culling, and you don't need to set Position.z 35bf215546Sopenharmony_ci * if Z culling is disabled. 36bf215546Sopenharmony_ci * 37bf215546Sopenharmony_ci * If something doesn't work, turn some of these off to find out what. 38bf215546Sopenharmony_ci */ 39bf215546Sopenharmony_ci bool cull_front; 40bf215546Sopenharmony_ci bool cull_back; 41bf215546Sopenharmony_ci bool cull_view_xy; 42bf215546Sopenharmony_ci bool cull_view_near_z; 43bf215546Sopenharmony_ci bool cull_view_far_z; 44bf215546Sopenharmony_ci bool cull_small_prims; 45bf215546Sopenharmony_ci bool cull_zero_area; 46bf215546Sopenharmony_ci bool cull_w; /* cull primitives with all W < 0 */ 47bf215546Sopenharmony_ci 48bf215546Sopenharmony_ci bool use_halfz_clip_space; 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_ci uint8_t num_vertices; /* 1..3 */ 51bf215546Sopenharmony_ci}; 52bf215546Sopenharmony_ci 53bf215546Sopenharmony_ci/* Callback invoked in the inner-most branch where the primitive is accepted. */ 54bf215546Sopenharmony_citypedef void (*ac_cull_accept_func)(struct ac_llvm_context *ctx, LLVMValueRef accepted, 55bf215546Sopenharmony_ci void *userdata); 56bf215546Sopenharmony_ci 57bf215546Sopenharmony_civoid ac_cull_primitive(struct ac_llvm_context *ctx, LLVMValueRef pos[3][4], 58bf215546Sopenharmony_ci LLVMValueRef initially_accepted, LLVMValueRef vp_scale[2], 59bf215546Sopenharmony_ci LLVMValueRef vp_translate[2], LLVMValueRef small_prim_precision, 60bf215546Sopenharmony_ci LLVMValueRef clip_half_line_width[2], struct ac_cull_options *options, 61bf215546Sopenharmony_ci ac_cull_accept_func accept_func, void *userdata); 62bf215546Sopenharmony_ci 63bf215546Sopenharmony_ci#endif 64