1 /* 2 * Copyright 2017 Advanced Micro Devices, Inc. 3 * 4 * SPDX-License-Identifier: MIT 5 */ 6 7 #ifndef AC_SHADER_ABI_H 8 #define AC_SHADER_ABI_H 9 10 #include "ac_shader_args.h" 11 #include "ac_shader_util.h" 12 #include "compiler/shader_enums.h" 13 #include "nir.h" 14 #include <llvm-c/Core.h> 15 16 #include <assert.h> 17 18 #define AC_LLVM_MAX_OUTPUTS (VARYING_SLOT_VAR31 + 1) 19 20 /* Document the shader ABI during compilation. This is what allows radeonsi and 21 * radv to share a compiler backend. 22 */ 23 struct ac_shader_abi { 24 /* Each entry is a pointer to a f32 or a f16 value (only possible for FS) */ 25 LLVMValueRef outputs[AC_LLVM_MAX_OUTPUTS * 4]; 26 bool is_16bit[AC_LLVM_MAX_OUTPUTS * 4]; 27 28 /* These input registers sometimes need to be fixed up. */ 29 LLVMValueRef vertex_id; 30 LLVMValueRef vs_rel_patch_id; 31 LLVMValueRef instance_id; 32 33 /* replaced registers when culling enabled */ 34 LLVMValueRef vertex_id_replaced; 35 LLVMValueRef instance_id_replaced; 36 LLVMValueRef tes_u_replaced; 37 LLVMValueRef tes_v_replaced; 38 LLVMValueRef tes_rel_patch_id_replaced; 39 LLVMValueRef tes_patch_id_replaced; 40 41 LLVMValueRef (*load_tess_varyings)(struct ac_shader_abi *abi, LLVMTypeRef type, 42 unsigned driver_location, unsigned component, 43 unsigned num_components); 44 45 LLVMValueRef (*load_ubo)(struct ac_shader_abi *abi, LLVMValueRef index); 46 47 /** 48 * Load the descriptor for the given buffer. 49 * 50 * \param buffer the buffer as presented in NIR: this is the descriptor 51 * in Vulkan, and the buffer index in OpenGL/Gallium 52 * \param write whether buffer contents will be written 53 * \param non_uniform whether the buffer descriptor is not assumed to be uniform 54 */ 55 LLVMValueRef (*load_ssbo)(struct ac_shader_abi *abi, LLVMValueRef buffer, bool write, bool non_uniform); 56 57 /** 58 * Load a descriptor associated to a sampler. 59 * 60 * \param index of the descriptor 61 * \param desc_type the type of descriptor to load 62 */ 63 LLVMValueRef (*load_sampler_desc)(struct ac_shader_abi *abi, LLVMValueRef index, 64 enum ac_descriptor_type desc_type); 65 66 LLVMValueRef (*intrinsic_load)(struct ac_shader_abi *abi, nir_intrinsic_instr *intrin); 67 68 /* Whether to clamp the shadow reference value to [0,1]on GFX8. Radeonsi currently 69 * uses it due to promoting D16 to D32, but radv needs it off. */ 70 bool clamp_shadow_reference; 71 72 /* Whether bounds checks are required */ 73 bool robust_buffer_access; 74 75 /* Check for Inf interpolation coeff */ 76 bool kill_ps_if_inf_interp; 77 78 /* Clamp div by 0 (so it won't produce NaN) */ 79 bool clamp_div_by_zero; 80 81 /* Whether to inline the compute dispatch size in user sgprs. */ 82 bool load_grid_size_from_user_sgpr; 83 84 /* Whether to disable anisotropic filtering. */ 85 bool disable_aniso_single_level; 86 }; 87 88 #endif /* AC_SHADER_ABI_H */ 89