17ec681f3Smrg/*
27ec681f3Smrg * Copyright 2019 Advanced Micro Devices, Inc.
37ec681f3Smrg *
47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a
57ec681f3Smrg * copy of this software and associated documentation files (the
67ec681f3Smrg * "Software"), to deal in the Software without restriction, including
77ec681f3Smrg * without limitation the rights to use, copy, modify, merge, publish,
87ec681f3Smrg * distribute, sub license, and/or sell copies of the Software, and to
97ec681f3Smrg * permit persons to whom the Software is furnished to do so, subject to
107ec681f3Smrg * the following conditions:
117ec681f3Smrg *
127ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
137ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
147ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
157ec681f3Smrg * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
167ec681f3Smrg * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
177ec681f3Smrg * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
187ec681f3Smrg * USE OR OTHER DEALINGS IN THE SOFTWARE.
197ec681f3Smrg *
207ec681f3Smrg * The above copyright notice and this permission notice (including the
217ec681f3Smrg * next paragraph) shall be included in all copies or substantial portions
227ec681f3Smrg * of the Software.
237ec681f3Smrg *
247ec681f3Smrg */
257ec681f3Smrg
267ec681f3Smrg#ifndef AC_LLVM_CULL_H
277ec681f3Smrg#define AC_LLVM_CULL_H
287ec681f3Smrg
297ec681f3Smrg#include "ac_llvm_build.h"
307ec681f3Smrg
317ec681f3Smrgstruct ac_cull_options {
327ec681f3Smrg   /* In general, I recommend setting all to true except view Z culling,
337ec681f3Smrg    * which isn't so effective because W culling is cheaper and partially
347ec681f3Smrg    * replaces near Z culling, and you don't need to set Position.z
357ec681f3Smrg    * if Z culling is disabled.
367ec681f3Smrg    *
377ec681f3Smrg    * If something doesn't work, turn some of these off to find out what.
387ec681f3Smrg    */
397ec681f3Smrg   bool cull_front;
407ec681f3Smrg   bool cull_back;
417ec681f3Smrg   bool cull_view_xy;
427ec681f3Smrg   bool cull_view_near_z;
437ec681f3Smrg   bool cull_view_far_z;
447ec681f3Smrg   bool cull_small_prims;
457ec681f3Smrg   bool cull_zero_area;
467ec681f3Smrg   bool cull_w; /* cull primitives with all W < 0 */
477ec681f3Smrg
487ec681f3Smrg   bool use_halfz_clip_space;
497ec681f3Smrg
507ec681f3Smrg   uint8_t num_vertices; /* 1..3 */
517ec681f3Smrg};
527ec681f3Smrg
537ec681f3Smrg/* Callback invoked in the inner-most branch where the primitive is accepted. */
547ec681f3Smrgtypedef void (*ac_cull_accept_func)(struct ac_llvm_context *ctx, LLVMValueRef accepted,
557ec681f3Smrg                                    void *userdata);
567ec681f3Smrg
577ec681f3Smrgvoid ac_cull_primitive(struct ac_llvm_context *ctx, LLVMValueRef pos[3][4],
587ec681f3Smrg                       LLVMValueRef initially_accepted, LLVMValueRef vp_scale[2],
597ec681f3Smrg                       LLVMValueRef vp_translate[2], LLVMValueRef small_prim_precision,
607ec681f3Smrg                       struct ac_cull_options *options, ac_cull_accept_func accept_func,
617ec681f3Smrg                       void *userdata);
627ec681f3Smrg
637ec681f3Smrg#endif
64