#include <stdio.h>
+// Use LDS symbols when supported by LLVM. Can be disabled for testing the old
+// path on newer LLVM for now. Should be removed in the long term.
+#define USE_LDS_SYMBOLS (true)
+
struct nir_shader;
struct si_shader;
struct si_context;
};
/* Fields of driver-defined VS state SGPR. */
-/* Clamp vertex color output (only used in VS as VS). */
#define S_VS_STATE_CLAMP_VERTEX_COLOR(x) (((unsigned)(x) & 0x1) << 0)
#define C_VS_STATE_CLAMP_VERTEX_COLOR 0xFFFFFFFE
#define S_VS_STATE_INDEXED(x) (((unsigned)(x) & 0x1) << 1)
#define C_VS_STATE_INDEXED 0xFFFFFFFD
+#define S_VS_STATE_OUTPRIM(x) (((unsigned)(x) & 0x3) << 2)
+#define C_VS_STATE_OUTPRIM 0xFFFFFFF3
+#define S_VS_STATE_PROVOKING_VTX_INDEX(x) (((unsigned)(x) & 0x3) << 4)
+#define C_VS_STATE_PROVOKING_VTX_INDEX 0xFFFFFFCF
+#define S_VS_STATE_STREAMOUT_QUERY_ENABLED(x) (((unsigned)(x) & 0x1) << 6)
+#define C_VS_STATE_STREAMOUT_QUERY_ENABLED 0xFFFFFFBF
#define S_VS_STATE_LS_OUT_PATCH_SIZE(x) (((unsigned)(x) & 0x1FFF) << 8)
#define C_VS_STATE_LS_OUT_PATCH_SIZE 0xFFE000FF
#define S_VS_STATE_LS_OUT_VERTEX_SIZE(x) (((unsigned)(x) & 0xFF) << 24)
struct si_shader *main_shader_part;
struct si_shader *main_shader_part_ls; /* as_ls is set in the key */
struct si_shader *main_shader_part_es; /* as_es is set in the key */
+ struct si_shader *main_shader_part_ngg; /* as_ngg is set in the key */
struct si_shader *gs_copy_shader;
/* Valid shader configurations:
*
- * API shaders VS | TCS | TES | GS |pass| PS
- * are compiled as: | | | |thru|
- * | | | | |
- * Only VS & PS: VS | | | | | PS
- * GFX6 - with GS: ES | | | GS | VS | PS
- * - with tess: LS | HS | VS | | | PS
- * - with both: LS | HS | ES | GS | VS | PS
- * GFX9 - with GS: -> | | | GS | VS | PS
- * - with tess: -> | HS | VS | | | PS
- * - with both: -> | HS | -> | GS | VS | PS
+ * API shaders VS | TCS | TES | GS |pass| PS
+ * are compiled as: | | | |thru|
+ * | | | | |
+ * Only VS & PS: VS | | | | | PS
+ * GFX6 - with GS: ES | | | GS | VS | PS
+ * - with tess: LS | HS | VS | | | PS
+ * - with both: LS | HS | ES | GS | VS | PS
+ * GFX9 - with GS: -> | | | GS | VS | PS
+ * - with tess: -> | HS | VS | | | PS
+ * - with both: -> | HS | -> | GS | VS | PS
+ * | | | | |
+ * NGG - VS & PS: GS | | | | | PS
+ * (GFX10+) - with GS: -> | | | GS | | PS
+ * - with tess: -> | HS | GS | | | PS
+ * - with both: -> | HS | -> | GS | | PS
*
* -> = merged with the next stage
*/
unsigned last_input:4;
unsigned as_ls:1;
unsigned as_es:1;
+ unsigned as_ngg:1;
/* Prologs for monolithic shaders shouldn't set EXEC. */
unsigned is_monolithic:1;
} vs_prolog;
} ps;
} part;
- /* These two are initially set according to the NEXT_SHADER property,
+ /* These three are initially set according to the NEXT_SHADER property,
* or guessed if the property doesn't seem correct.
*/
unsigned as_es:1; /* export shader, which precedes GS */
unsigned as_ls:1; /* local shader, which precedes TCS */
+ unsigned as_ngg:1; /* VS, TES, or GS compiled as NGG primitive shader */
/* Flags for monolithic compilation only. */
struct {
char *llvm_ir_string;
};
+struct gfx9_gs_info {
+ unsigned es_verts_per_subgroup;
+ unsigned gs_prims_per_subgroup;
+ unsigned gs_inst_prims_in_subgroup;
+ unsigned max_prims_per_subgroup;
+ unsigned esgs_ring_size; /* in bytes */
+};
+
struct si_shader {
struct si_compiler_ctx_state compiler_ctx_state;
struct ac_shader_config config;
struct si_shader_info info;
+ struct {
+ uint16_t ngg_emit_size; /* in dwords */
+ uint16_t hw_max_esverts;
+ uint16_t max_gsprims;
+ uint16_t max_out_verts;
+ uint16_t prim_amp_factor;
+ bool max_vert_out_per_gs_instance;
+ } ngg;
+
/* Shader key + LLVM IR + disassembly + statistics.
* Generated for debug contexts only.
*/
char *shader_log;
size_t shader_log_size;
+ struct gfx9_gs_info gs_info;
+
/* For save precompute context registers values. */
union {
struct {
unsigned vgt_gsvs_ring_offset_1;
unsigned vgt_gsvs_ring_offset_2;
unsigned vgt_gsvs_ring_offset_3;
- unsigned vgt_gs_out_prim_type;
unsigned vgt_gsvs_ring_itemsize;
unsigned vgt_gs_max_vert_out;
unsigned vgt_gs_vert_itemsize;
unsigned vgt_esgs_ring_itemsize;
} gs;
+ struct {
+ unsigned ge_max_output_per_subgroup;
+ unsigned ge_ngg_subgrp_cntl;
+ unsigned vgt_primitiveid_en;
+ unsigned vgt_gs_onchip_cntl;
+ unsigned vgt_gs_instance_cnt;
+ unsigned vgt_esgs_ring_itemsize;
+ unsigned vgt_reuse_off;
+ unsigned spi_vs_out_config;
+ unsigned spi_shader_idx_format;
+ unsigned spi_shader_pos_format;
+ unsigned pa_cl_vte_cntl;
+ unsigned pa_cl_ngg_cntl;
+ unsigned vgt_gs_max_vert_out; /* for API GS */
+ } ngg;
+
struct {
unsigned vgt_gs_mode;
unsigned vgt_primitiveid_en;
/*For save precompute registers value */
unsigned vgt_tf_param; /* VGT_TF_PARAM */
unsigned vgt_vertex_reuse_block_cntl; /* VGT_VERTEX_REUSE_BLOCK_CNTL */
+ unsigned ge_cntl;
};
struct si_shader_part {
unsigned is_varying);
bool si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader,
uint64_t scratch_va);
-void si_shader_dump(struct si_screen *sscreen, const struct si_shader *shader,
+void si_shader_dump(struct si_screen *sscreen, struct si_shader *shader,
struct pipe_debug_callback *debug, unsigned processor,
FILE *f, bool check_debug_option);
-void si_shader_dump_stats_for_shader_db(const struct si_shader *shader,
+void si_shader_dump_stats_for_shader_db(struct si_screen *screen,
+ struct si_shader *shader,
struct pipe_debug_callback *debug);
void si_multiwave_lds_size_workaround(struct si_screen *sscreen,
unsigned *lds_size);
void si_lower_nir(struct si_shader_selector *sel);
void si_nir_opts(struct nir_shader *nir);
+/* si_state_shaders.c */
+void gfx9_get_gs_info(struct si_shader_selector *es,
+ struct si_shader_selector *gs,
+ struct gfx9_gs_info *out);
+
/* Inline helpers. */
/* Return the pointer to the main shader part's pointer. */
return &sel->main_shader_part_ls;
if (key->as_es)
return &sel->main_shader_part_es;
+ if (key->as_ngg)
+ return &sel->main_shader_part_ngg;
return &sel->main_shader_part;
}