tree-wide: replace MAYBE_UNUSED with ASSERTED
[mesa.git] / src / intel / compiler / brw_compiler.h
index 560f2c3c6ba673c96d5cb1d7b804a6c8ae54a51e..736d85669dc3411972e26339bb41f722a72d91aa 100644 (file)
@@ -93,6 +93,7 @@ struct brw_compiler {
    void (*shader_perf_log)(void *, const char *str, ...) PRINTFLIKE(2, 3);
 
    bool scalar_stage[MESA_SHADER_STAGES];
+   bool use_tcs_8_patch;
    struct gl_shader_compiler_options glsl_compiler_options[MESA_SHADER_STAGES];
 
    /**
@@ -196,11 +197,36 @@ struct brw_sampler_prog_key_data {
    uint32_t yx_xuxv_image_mask;
    uint32_t xy_uxvx_image_mask;
    uint32_t ayuv_image_mask;
+   uint32_t xyuv_image_mask;
 
    /* Scale factor for each texture. */
    float scale_factors[32];
 };
 
+/** An enum representing what kind of input gl_SubgroupSize is. */
+enum PACKED brw_subgroup_size_type
+{
+   BRW_SUBGROUP_SIZE_API_CONSTANT,     /**< Default Vulkan behavior */
+   BRW_SUBGROUP_SIZE_UNIFORM,          /**< OpenGL behavior */
+   BRW_SUBGROUP_SIZE_VARYING,          /**< VK_EXT_subgroup_size_control */
+
+   /* These enums are specifically chosen so that the value of the enum is
+    * also the subgroup size.  If any new values are added, they must respect
+    * this invariant.
+    */
+   BRW_SUBGROUP_SIZE_REQUIRE_8   = 8,  /**< VK_EXT_subgroup_size_control */
+   BRW_SUBGROUP_SIZE_REQUIRE_16  = 16, /**< VK_EXT_subgroup_size_control */
+   BRW_SUBGROUP_SIZE_REQUIRE_32  = 32, /**< VK_EXT_subgroup_size_control */
+};
+
+struct brw_base_prog_key {
+   unsigned program_string_id;
+
+   enum brw_subgroup_size_type subgroup_size_type;
+
+   struct brw_sampler_prog_key_data tex;
+};
+
 /**
  * The VF can't natively handle certain types of attributes, such as GL_FIXED
  * or most 10_10_10_2 types.  These flags enable various VS workarounds to
@@ -223,7 +249,7 @@ struct brw_sampler_prog_key_data {
 
 /** The program key for Vertex Shaders. */
 struct brw_vs_prog_key {
-   unsigned program_string_id;
+   struct brw_base_prog_key base;
 
    /**
     * Per-attribute workaround flags
@@ -261,14 +287,12 @@ struct brw_vs_prog_key {
     * the VUE, even if they aren't written by the vertex shader.
     */
    uint8_t point_coord_replace;
-
-   struct brw_sampler_prog_key_data tex;
 };
 
 /** The program key for Tessellation Control Shaders. */
 struct brw_tcs_prog_key
 {
-   unsigned program_string_id;
+   struct brw_base_prog_key base;
 
    GLenum tes_primitive_mode;
 
@@ -281,30 +305,24 @@ struct brw_tcs_prog_key
    uint64_t outputs_written;
 
    bool quads_workaround;
-
-   struct brw_sampler_prog_key_data tex;
 };
 
 /** The program key for Tessellation Evaluation Shaders. */
 struct brw_tes_prog_key
 {
-   unsigned program_string_id;
+   struct brw_base_prog_key base;
 
    /** A bitfield of per-patch inputs read. */
    uint32_t patch_inputs_read;
 
    /** A bitfield of per-vertex inputs read. */
    uint64_t inputs_read;
-
-   struct brw_sampler_prog_key_data tex;
 };
 
 /** The program key for Geometry Shaders. */
 struct brw_gs_prog_key
 {
-   unsigned program_string_id;
-
-   struct brw_sampler_prog_key_data tex;
+   struct brw_base_prog_key base;
 };
 
 enum brw_sf_primitive {
@@ -392,12 +410,15 @@ enum brw_wm_aa_enable {
 
 /** The program key for Fragment/Pixel Shaders. */
 struct brw_wm_prog_key {
+   struct brw_base_prog_key base;
+
    /* Some collection of BRW_WM_IZ_* */
    uint8_t iz_lookup;
    bool stats_wm:1;
    bool flat_shade:1;
    unsigned nr_color_regions:5;
-   bool replicate_alpha:1;
+   bool alpha_test_replicate_alpha:1;
+   bool alpha_to_coverage:1;
    bool clamp_fragment_color:1;
    bool persample_interp:1;
    bool multisample_fbo:1;
@@ -409,20 +430,17 @@ struct brw_wm_prog_key {
 
    uint8_t color_outputs_valid;
    uint64_t input_slots_valid;
-   unsigned program_string_id;
    GLenum alpha_test_func;          /* < For Gen4/5 MRT alpha test */
    float alpha_test_ref;
-
-   struct brw_sampler_prog_key_data tex;
 };
 
 struct brw_cs_prog_key {
-   uint32_t program_string_id;
-   struct brw_sampler_prog_key_data tex;
+   struct brw_base_prog_key base;
 };
 
 /* brw_any_prog_key is any of the keys that map to an API stage */
 union brw_any_prog_key {
+   struct brw_base_prog_key base;
    struct brw_vs_prog_key vs;
    struct brw_tcs_prog_key tcs;
    struct brw_tes_prog_key tes;
@@ -567,6 +585,8 @@ enum brw_param_builtin {
    BRW_PARAM_BUILTIN_TESS_LEVEL_INNER_X,
    BRW_PARAM_BUILTIN_TESS_LEVEL_INNER_Y,
 
+   BRW_PARAM_BUILTIN_PATCH_VERTICES_IN,
+
    BRW_PARAM_BUILTIN_BASE_WORK_GROUP_ID_X,
    BRW_PARAM_BUILTIN_BASE_WORK_GROUP_ID_Y,
    BRW_PARAM_BUILTIN_BASE_WORK_GROUP_ID_Z,
@@ -704,6 +724,7 @@ struct brw_wm_prog_data {
    bool dispatch_16;
    bool dispatch_32;
    bool dual_src_blend;
+   bool replicate_alpha;
    bool persample_dispatch;
    bool uses_pos_offset;
    bool uses_omask;
@@ -990,14 +1011,16 @@ void brw_compute_tess_vue_map(struct brw_vue_map *const vue_map,
 /* brw_interpolation_map.c */
 void brw_setup_vue_interpolation(struct brw_vue_map *vue_map,
                                  struct nir_shader *nir,
-                                 struct brw_wm_prog_data *prog_data,
-                                 const struct gen_device_info *devinfo);
+                                 struct brw_wm_prog_data *prog_data);
 
 enum shader_dispatch_mode {
    DISPATCH_MODE_4X1_SINGLE = 0,
    DISPATCH_MODE_4X2_DUAL_INSTANCE = 1,
    DISPATCH_MODE_4X2_DUAL_OBJECT = 2,
    DISPATCH_MODE_SIMD8 = 3,
+
+   DISPATCH_MODE_TCS_SINGLE_PATCH = 0,
+   DISPATCH_MODE_TCS_8_PATCH = 2,
 };
 
 /**
@@ -1070,6 +1093,9 @@ struct brw_tcs_prog_data
 {
    struct brw_vue_prog_data base;
 
+   /** Should the non-SINGLE_PATCH payload provide primitive ID? */
+   bool include_primitive_id;
+
    /** Number vertices in output patch */
    int instances;
 };
@@ -1219,6 +1245,9 @@ brw_prog_data_size(gl_shader_stage stage);
 unsigned
 brw_prog_key_size(gl_shader_stage stage);
 
+void
+brw_prog_key_set_id(union brw_any_prog_key *key, gl_shader_stage, unsigned id);
+
 /**
  * Compile a vertex shader.
  *
@@ -1344,6 +1373,11 @@ brw_compile_cs(const struct brw_compiler *compiler, void *log_data,
                int shader_time_index,
                char **error_str);
 
+void brw_debug_key_recompile(const struct brw_compiler *c, void *log,
+                             gl_shader_stage stage,
+                             const struct brw_base_prog_key *old_key,
+                             const struct brw_base_prog_key *key);
+
 static inline uint32_t
 encode_slm_size(unsigned gen, uint32_t bytes)
 {
@@ -1383,7 +1417,7 @@ encode_slm_size(unsigned gen, uint32_t bytes)
  * '2^n - 1' for some n.
  */
 static inline bool
-brw_stage_has_packed_dispatch(MAYBE_UNUSED const struct gen_device_info *devinfo,
+brw_stage_has_packed_dispatch(ASSERTED const struct gen_device_info *devinfo,
                               gl_shader_stage stage,
                               const struct brw_stage_prog_data *prog_data)
 {