radeonsi: declare new user SGPR indices for bindless samplers/images
[mesa.git] / src / gallium / drivers / radeonsi / si_shader_internal.h
index 954b83db20165a1364fc6ed8c89a0d0ac443ba27..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
@@ -195,6 +201,11 @@ struct si_shader_context {
        int param_gs_vtx01_offset; /* in dwords (GFX9) */
        int param_gs_vtx23_offset; /* in dwords (GFX9) */
        int param_gs_vtx45_offset; /* in dwords (GFX9) */
+       /* CS */
+       int param_grid_size;
+       int param_block_size;
+       int param_block_id[3];
+       int param_thread_id;
 
        LLVMTargetMachineRef tm;
 
@@ -208,6 +219,7 @@ struct si_shader_context {
 
        LLVMValueRef lds;
        LLVMValueRef gs_next_vertex[4];
+       LLVMValueRef postponed_kill;
        LLVMValueRef return_value;
 
        LLVMTypeRef voidt;
@@ -217,7 +229,6 @@ struct si_shader_context {
        LLVMTypeRef i64;
        LLVMTypeRef i128;
        LLVMTypeRef f32;
-       LLVMTypeRef v16i8;
        LLVMTypeRef v2i32;
        LLVMTypeRef v4i32;
        LLVMTypeRef v4f32;
@@ -235,10 +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);
-void si_llvm_shader_type(LLVMValueRef F, unsigned type);
+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,
@@ -267,8 +282,7 @@ void si_llvm_create_func(struct si_shader_context *ctx,
 
 void si_llvm_dispose(struct si_shader_context *ctx);
 
-void si_llvm_finalize_module(struct si_shader_context *ctx,
-                            bool run_verifier);
+void si_llvm_optimize_module(struct si_shader_context *ctx);
 
 LLVMValueRef si_llvm_emit_fetch_64bit(struct lp_build_tgsi_context *bld_base,
                                      enum tgsi_opcode_type type,
@@ -285,6 +299,41 @@ void si_llvm_emit_store(struct lp_build_tgsi_context *bld_base,
                        const struct tgsi_opcode_info *info,
                        LLVMValueRef dst[4]);
 
+/* Combine these with & instead of |. */
+#define NOOP_WAITCNT 0xf7f
+#define LGKM_CNT 0x07f
+#define VM_CNT 0xf70
+
+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