• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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    /* Varying -> attribute number mapping. Also NIR-only */
42    unsigned fs_input_attr_indices[MAX_VARYING];
43 
44    LLVMValueRef (*load_tess_varyings)(struct ac_shader_abi *abi, LLVMTypeRef type,
45                                       LLVMValueRef vertex_index, LLVMValueRef param_index,
46                                       unsigned driver_location, unsigned component,
47                                       unsigned num_components, bool load_inputs);
48 
49    LLVMValueRef (*load_ubo)(struct ac_shader_abi *abi, LLVMValueRef index);
50 
51    /**
52     * Load the descriptor for the given buffer.
53     *
54     * \param buffer the buffer as presented in NIR: this is the descriptor
55     *               in Vulkan, and the buffer index in OpenGL/Gallium
56     * \param write whether buffer contents will be written
57     * \param non_uniform whether the buffer descriptor is not assumed to be uniform
58     */
59    LLVMValueRef (*load_ssbo)(struct ac_shader_abi *abi, LLVMValueRef buffer, bool write, bool non_uniform);
60 
61    /**
62     * Load a descriptor associated to a sampler.
63     *
64     * \param index of the descriptor
65     * \param desc_type the type of descriptor to load
66     */
67    LLVMValueRef (*load_sampler_desc)(struct ac_shader_abi *abi, LLVMValueRef index,
68                                      enum ac_descriptor_type desc_type);
69 
70    LLVMValueRef (*intrinsic_load)(struct ac_shader_abi *abi, nir_intrinsic_instr *intrin);
71 
72    /* Whether to clamp the shadow reference value to [0,1]on GFX8. Radeonsi currently
73     * uses it due to promoting D16 to D32, but radv needs it off. */
74    bool clamp_shadow_reference;
75 
76    /* Whether bounds checks are required */
77    bool robust_buffer_access;
78 
79    /* Check for Inf interpolation coeff */
80    bool kill_ps_if_inf_interp;
81 
82    /* Clamp div by 0 (so it won't produce NaN) */
83    bool clamp_div_by_zero;
84 
85    /* Whether to inline the compute dispatch size in user sgprs. */
86    bool load_grid_size_from_user_sgpr;
87 
88    /* Whether to detect divergent textures/samplers index and apply
89     * waterfall to avoid incorrect rendering. */
90    bool use_waterfall_for_divergent_tex_samplers;
91 
92    /* Whether to disable anisotropic filtering. */
93    bool disable_aniso_single_level;
94 };
95 
96 #endif /* AC_SHADER_ABI_H */
97