radeonsi: Set PIPE_SHADER_CAP_MAX_SHADER_IMAGES
[mesa.git] / src / gallium / drivers / radeonsi / si_shader.h
index 928cb2e18e981c7a28ed5102b6a1544799b061e2..8059edf639561939c32d1853ed33ea9475c9838a 100644 (file)
 struct radeon_shader_binary;
 struct radeon_shader_reloc;
 
+#define SI_MAX_VS_OUTPUTS      40
+
 #define SI_SGPR_RW_BUFFERS     0  /* rings (& stream-out, VS only) */
 #define SI_SGPR_CONST_BUFFERS  2
 #define SI_SGPR_SAMPLERS       4  /* images & sampler states interleaved */
-/* TODO: gap */
+#define SI_SGPR_IMAGES         6
 #define SI_SGPR_VERTEX_BUFFERS 8  /* VS only */
 #define SI_SGPR_BASE_VERTEX    10 /* VS only */
 #define SI_SGPR_START_INSTANCE 11 /* VS only */
@@ -102,7 +104,7 @@ struct radeon_shader_reloc;
 #define SI_PARAM_RW_BUFFERS    0
 #define SI_PARAM_CONST_BUFFERS 1
 #define SI_PARAM_SAMPLERS      2
-#define SI_PARAM_UNUSED                3 /* TODO: use */
+#define SI_PARAM_IMAGES                3
 
 /* VS only parameters */
 #define SI_PARAM_VERTEX_BUFFERS        4
@@ -169,7 +171,7 @@ struct radeon_shader_reloc;
 #define SI_PARAM_SAMPLE_COVERAGE       20
 #define SI_PARAM_POS_FIXED_PT          21
 
-#define SI_NUM_PARAMS (SI_PARAM_POS_FIXED_PT + 1)
+#define SI_NUM_PARAMS (SI_PARAM_POS_FIXED_PT + 9) /* +8 for COLOR[0..1] */
 
 struct si_shader;
 
@@ -181,6 +183,11 @@ struct si_shader_selector {
        struct si_shader        *first_variant; /* immutable after the first variant */
        struct si_shader        *last_variant; /* mutable */
 
+       /* The compiled TGSI shader expecting a prolog and/or epilog (not
+        * uploaded to a buffer).
+        */
+       struct si_shader        *main_shader_part;
+
        struct tgsi_token       *tokens;
        struct pipe_stream_output_info  so;
        struct tgsi_shader_info         info;
@@ -199,6 +206,7 @@ struct si_shader_selector {
        unsigned        max_gsvs_emit_size;
 
        /* PS parameters. */
+       unsigned        color_attr_index[2];
        unsigned        db_shader_control;
        /* Set 0xf or 0x0 (4 bits) per each written output.
         * ANDed with spi_shader_col_format.
@@ -281,6 +289,17 @@ union si_shader_part_key {
        struct {
                struct si_tcs_epilog_bits states;
        } tcs_epilog;
+       struct {
+               struct si_ps_prolog_bits states;
+               unsigned        num_input_sgprs:5;
+               unsigned        num_input_vgprs:5;
+               /* Color interpolation and two-side color selection. */
+               unsigned        colors_read:8; /* color input components read */
+               unsigned        num_interp_inputs:5; /* BCOLOR is at this location */
+               unsigned        face_vgpr_index:5;
+               char            color_attr_index[2];
+               char            color_interp_vgpr_index[2]; /* -1 == constant */
+       } ps_prolog;
        struct {
                struct si_ps_epilog_bits states;
                unsigned        colors_written:8;
@@ -322,6 +341,17 @@ struct si_shader_config {
        unsigned                        rsrc2;
 };
 
+/* GCN-specific shader info. */
+struct si_shader_info {
+       ubyte                   vs_output_param_offset[SI_MAX_VS_OUTPUTS];
+       ubyte                   num_input_sgprs;
+       ubyte                   num_input_vgprs;
+       char                    face_vgpr_index;
+       bool                    uses_instanceid;
+       ubyte                   nr_pos_exports;
+       ubyte                   nr_param_exports;
+};
+
 struct si_shader {
        struct si_shader_selector       *selector;
        struct si_shader                *next_variant;
@@ -334,17 +364,13 @@ struct si_shader {
        struct r600_resource            *bo;
        struct r600_resource            *scratch_bo;
        union si_shader_key             key;
+       bool                            is_binary_shared;
+       unsigned                        z_order;
+
+       /* The following data is all that's needed for binary shaders. */
        struct radeon_shader_binary     binary;
        struct si_shader_config         config;
-
-       ubyte                   num_input_sgprs;
-       ubyte                   num_input_vgprs;
-       char                    face_vgpr_index;
-
-       unsigned                vs_output_param_offset[PIPE_MAX_SHADER_OUTPUTS];
-       bool                    uses_instanceid;
-       unsigned                nr_pos_exports;
-       unsigned                nr_param_exports;
+       struct si_shader_info           info;
 };
 
 struct si_shader_part {
@@ -387,6 +413,11 @@ static inline bool si_vs_exports_prim_id(struct si_shader *shader)
 }
 
 /* si_shader.c */
+int si_compile_tgsi_shader(struct si_screen *sscreen,
+                          LLVMTargetMachineRef tm,
+                          struct si_shader *shader,
+                          bool is_monolithic,
+                          struct pipe_debug_callback *debug);
 int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm,
                     struct si_shader *shader,
                     struct pipe_debug_callback *debug);
@@ -403,7 +434,8 @@ void si_shader_destroy(struct si_shader *shader);
 unsigned si_shader_io_get_unique_index(unsigned semantic_name, unsigned index);
 int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader);
 void si_shader_dump(struct si_screen *sscreen, struct si_shader *shader,
-                   struct pipe_debug_callback *debug, unsigned processor);
+                   struct pipe_debug_callback *debug, unsigned processor,
+                   FILE *f);
 void si_shader_apply_scratch_relocs(struct si_context *sctx,
                        struct si_shader *shader,
                        uint64_t scratch_va);