Path: blob/21.2-virgl/src/amd/llvm/ac_shader_abi.h
7355 views
/*1* Copyright 2017 Advanced Micro Devices, Inc.2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* on the rights to use, copy, modify, merge, publish, distribute, sub7* license, and/or sell copies of the Software, and to permit persons to whom8* the Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL17* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,18* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR19* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE20* USE OR OTHER DEALINGS IN THE SOFTWARE.21*/2223#ifndef AC_SHADER_ABI_H24#define AC_SHADER_ABI_H2526#include "ac_shader_args.h"27#include "compiler/shader_enums.h"28#include <llvm-c/Core.h>2930#include <assert.h>3132#define AC_LLVM_MAX_OUTPUTS (VARYING_SLOT_VAR31 + 1)3334#define AC_MAX_INLINE_PUSH_CONSTS 83536enum ac_descriptor_type37{38AC_DESC_IMAGE,39AC_DESC_FMASK,40AC_DESC_SAMPLER,41AC_DESC_BUFFER,42AC_DESC_PLANE_0,43AC_DESC_PLANE_1,44AC_DESC_PLANE_2,45};4647/* Document the shader ABI during compilation. This is what allows radeonsi and48* radv to share a compiler backend.49*/50struct ac_shader_abi {51LLVMValueRef outputs[AC_LLVM_MAX_OUTPUTS * 4];5253/* These input registers sometimes need to be fixed up. */54LLVMValueRef vertex_id;55LLVMValueRef instance_id;56LLVMValueRef persp_centroid, linear_centroid;57LLVMValueRef color0, color1;58LLVMValueRef user_data;5960/* For VS and PS: pre-loaded shader inputs.61*62* Currently only used for NIR shaders; indexed by variables'63* driver_location.64*/65LLVMValueRef *inputs;6667/* Varying -> attribute number mapping. Also NIR-only */68unsigned fs_input_attr_indices[MAX_VARYING];6970void (*emit_outputs)(struct ac_shader_abi *abi, unsigned max_outputs, LLVMValueRef *addrs);7172void (*emit_vertex)(struct ac_shader_abi *abi, unsigned stream, LLVMValueRef *addrs);7374void (*emit_primitive)(struct ac_shader_abi *abi, unsigned stream);7576void (*emit_vertex_with_counter)(struct ac_shader_abi *abi, unsigned stream,77LLVMValueRef vertexidx, LLVMValueRef *addrs);7879LLVMValueRef (*load_inputs)(struct ac_shader_abi *abi,80unsigned driver_location, unsigned component,81unsigned num_components, unsigned vertex_index,82LLVMTypeRef type);8384LLVMValueRef (*load_tess_varyings)(struct ac_shader_abi *abi, LLVMTypeRef type,85LLVMValueRef vertex_index, LLVMValueRef param_index,86unsigned driver_location, unsigned component,87unsigned num_components,88bool load_inputs, bool vertex_index_is_invoc_id);8990void (*store_tcs_outputs)(struct ac_shader_abi *abi,91LLVMValueRef vertex_index, LLVMValueRef param_index,92LLVMValueRef src, unsigned writemask,93unsigned component, unsigned location, unsigned driver_location);9495LLVMValueRef (*load_tess_coord)(struct ac_shader_abi *abi);9697LLVMValueRef (*load_patch_vertices_in)(struct ac_shader_abi *abi);9899LLVMValueRef (*load_ring_tess_offchip)(struct ac_shader_abi *abi);100101LLVMValueRef (*load_ring_tess_factors)(struct ac_shader_abi *abi);102103LLVMValueRef (*load_ring_esgs)(struct ac_shader_abi *abi);104105LLVMValueRef (*load_tess_level)(struct ac_shader_abi *abi, unsigned varying_id,106bool load_default_state);107108LLVMValueRef (*load_ubo)(struct ac_shader_abi *abi,109unsigned desc_set, unsigned binding,110bool valid_binding, LLVMValueRef index);111112/**113* Load the descriptor for the given buffer.114*115* \param buffer the buffer as presented in NIR: this is the descriptor116* in Vulkan, and the buffer index in OpenGL/Gallium117* \param write whether buffer contents will be written118* \param non_uniform whether the buffer descriptor is not assumed to be uniform119*/120LLVMValueRef (*load_ssbo)(struct ac_shader_abi *abi, LLVMValueRef buffer, bool write, bool non_uniform);121122/**123* Load a descriptor associated to a sampler.124*125* \param descriptor_set the descriptor set index (only for Vulkan)126* \param base_index the base index of the sampler variable127* \param constant_index constant part of an array index (or 0, if the128* sampler variable is not an array)129* \param index non-constant part of an array index (may be NULL)130* \param desc_type the type of descriptor to load131* \param image whether the descriptor is loaded for an image operation132*/133LLVMValueRef (*load_sampler_desc)(struct ac_shader_abi *abi, unsigned descriptor_set,134unsigned base_index, unsigned constant_index,135LLVMValueRef index, enum ac_descriptor_type desc_type,136bool image, bool write, bool bindless);137138/**139* Load a Vulkan-specific resource.140*141* \param index resource index142* \param desc_set descriptor set143* \param binding descriptor set binding144*/145LLVMValueRef (*load_resource)(struct ac_shader_abi *abi, LLVMValueRef index, unsigned desc_set,146unsigned binding);147148LLVMValueRef (*load_sample_position)(struct ac_shader_abi *abi, LLVMValueRef sample_id);149150LLVMValueRef (*load_local_group_size)(struct ac_shader_abi *abi);151152LLVMValueRef (*load_sample_mask_in)(struct ac_shader_abi *abi);153154LLVMValueRef (*load_base_vertex)(struct ac_shader_abi *abi, bool non_indexed_is_zero);155156LLVMValueRef (*emit_fbfetch)(struct ac_shader_abi *abi);157158/* Whether to clamp the shadow reference value to [0,1]on GFX8. Radeonsi currently159* uses it due to promoting D16 to D32, but radv needs it off. */160bool clamp_shadow_reference;161bool interp_at_sample_force_center;162163/* Whether bounds checks are required */164bool robust_buffer_access;165166/* Check for Inf interpolation coeff */167bool kill_ps_if_inf_interp;168169/* Whether undef values must be converted to zero */170bool convert_undef_to_zero;171172/* Clamp div by 0 (so it won't produce NaN) */173bool clamp_div_by_zero;174175/* Whether gl_FragCoord.z should be adjusted for VRS due to a hw bug on176* some GFX10.3 chips.177*/178bool adjust_frag_coord_z;179};180181#endif /* AC_SHADER_ABI_H */182183184