radeonsi: declare new user SGPR indices for bindless samplers/images
[mesa.git] / src / gallium / drivers / radeonsi / si_shader_internal.h
index 70004fae68196dd9bc7a0fd4117ed0cd1fe39f30..f304295cb6e5fce2488d99d1590351135e5f536e 100644 (file)
 #define SI_SHADER_PRIVATE_H
 
 #include "si_shader.h"
+#include "gallivm/lp_bld_flow.h"
 #include "gallivm/lp_bld_init.h"
 #include "gallivm/lp_bld_tgsi.h"
 #include "tgsi/tgsi_parse.h"
+#include "ac_shader_abi.h"
 #include "ac_llvm_util.h"
 #include "ac_llvm_build.h"
 
@@ -57,9 +59,17 @@ struct si_shader_context {
 
        unsigned type; /* PIPE_SHADER_* specifies the type of shader. */
 
+       /* For clamping the non-constant index in resource indexing: */
+       unsigned num_const_buffers;
+       unsigned num_shader_buffers;
+       unsigned num_images;
+       unsigned num_samplers;
+
        /* Whether the prolog will be compiled separately. */
        bool separate_prolog;
 
+       struct ac_shader_abi abi;
+
        /** This function is responsible for initilizing the inputs array and will be
          * called once for each input declared in the TGSI shader.
          */
@@ -99,6 +109,8 @@ struct si_shader_context {
        unsigned flow_depth;
        unsigned flow_depth_max;
 
+       struct lp_build_if_state merged_wrap_if_state;
+
        struct tgsi_array_info *temp_arrays;
        LLVMValueRef *temp_array_allocas;
 
@@ -109,22 +121,16 @@ struct si_shader_context {
 
        /* Parameter indices for LLVMGetParam. */
        int param_rw_buffers;
-       int param_const_buffers;
-       int param_samplers;
-       int param_images;
-       int param_shader_buffers;
+       int param_const_and_shader_buffers;
+       int param_samplers_and_images;
+       int param_bindless_samplers_and_images;
        /* Common inputs for merged shaders. */
        int param_merged_wave_info;
        int param_merged_scratch_offset;
        /* API VS */
        int param_vertex_buffers;
-       int param_base_vertex;
-       int param_start_instance;
-       int param_draw_id;
-       int param_vertex_id;
        int param_rel_auto_id;
        int param_vs_prim_id;
-       int param_instance_id;
        int param_vertex_index0;
        /* VS states and layout of LS outputs / TCS inputs at the end
         *   [0] = clamp vertex color
@@ -213,6 +219,7 @@ struct si_shader_context {
 
        LLVMValueRef lds;
        LLVMValueRef gs_next_vertex[4];
+       LLVMValueRef postponed_kill;
        LLVMValueRef return_value;
 
        LLVMTypeRef voidt;
@@ -239,9 +246,14 @@ si_shader_context(struct lp_build_tgsi_context *bld_base)
        return (struct si_shader_context*)bld_base;
 }
 
-void si_llvm_add_attribute(LLVMValueRef F, const char *name, int value);
+static inline struct si_shader_context *
+si_shader_context_from_abi(struct ac_shader_abi *abi)
+{
+       struct si_shader_context *ctx = NULL;
+       return container_of(abi, ctx, abi);
+}
 
-LLVMTargetRef si_llvm_get_amdgpu_target(const char *triple);
+void si_llvm_add_attribute(LLVMValueRef F, const char *name, int value);
 
 unsigned si_llvm_compile(LLVMModuleRef M, struct ac_shader_binary *binary,
                         LLVMTargetMachineRef tm,
@@ -294,10 +306,34 @@ void si_llvm_emit_store(struct lp_build_tgsi_context *bld_base,
 
 void si_emit_waitcnt(struct si_shader_context *ctx, unsigned simm16);
 
+LLVMValueRef si_get_indirect_index(struct si_shader_context *ctx,
+                                  const struct tgsi_ind_register *ind,
+                                  int rel_index);
 LLVMValueRef si_get_bounded_indirect_index(struct si_shader_context *ctx,
                                           const struct tgsi_ind_register *ind,
                                           int rel_index, unsigned num);
 
+LLVMTypeRef si_const_array(LLVMTypeRef elem_type, int num_elements);
+
 void si_shader_context_init_alu(struct lp_build_tgsi_context *bld_base);
+void si_shader_context_init_mem(struct si_shader_context *ctx);
+
+LLVMValueRef si_load_sampler_desc(struct si_shader_context *ctx,
+                                 LLVMValueRef list, LLVMValueRef index,
+                                 enum ac_descriptor_type type);
+LLVMValueRef si_load_image_desc(struct si_shader_context *ctx,
+                               LLVMValueRef list, LLVMValueRef index,
+                               enum ac_descriptor_type desc_type, bool dcc_off);
+
+void si_llvm_load_input_vs(
+       struct si_shader_context *ctx,
+       unsigned input_index,
+       LLVMValueRef out[4]);
+void si_llvm_load_input_fs(
+       struct si_shader_context *ctx,
+       unsigned input_index,
+       LLVMValueRef out[4]);
+
+bool si_nir_build_llvm(struct si_shader_context *ctx, struct nir_shader *nir);
 
 #endif