pan/midgard: Implement flat shading
[mesa.git] / src / panfrost / midgard / midgard_compile.h
index 3b16cbd2bb518cc6de5e1f3b617d85ac7c01014e..317a2b9e4c42762045d2e96a7ee6bbcd7e3011d5 100644 (file)
 
 #include "compiler/nir/nir.h"
 #include "util/u_dynarray.h"
-#include "util/register_allocate.h"
-
-/* To be shoved inside panfrost_screen for the Gallium driver, or somewhere
- * else for Vulkan/standalone. The single compiler "screen" to be shared across
- * all shader compiles, used to store complex initialization (for instance,
- * related to register allocation) */
-
-struct midgard_screen {
-        /* Precomputed register allocation sets for varying numbers of work
-         * registers.  The zeroeth entry corresponds to 8 work registers. The
-         * eighth entry corresponds to 16 work registers. NULL if this set has
-         * not been allocated yet. */
-
-        struct ra_regs *regs[9];
-
-        /* Work register classes corresponds to the above register sets */
-        unsigned reg_classes[9][4];
-};
 
 /* Define the general compiler entry point */
 
@@ -63,6 +45,9 @@ enum {
         PAN_SYSVAL_VIEWPORT_SCALE = 1,
         PAN_SYSVAL_VIEWPORT_OFFSET = 2,
         PAN_SYSVAL_TEXTURE_SIZE = 3,
+        PAN_SYSVAL_SSBO = 4,
+        PAN_SYSVAL_NUM_WORK_GROUPS = 5,
+        PAN_SYSVAL_SAMPLER = 7,
 } pan_sysval;
 
 #define PAN_TXS_SYSVAL_ID(texidx, dim, is_array)          \
@@ -72,14 +57,20 @@ enum {
 #define PAN_SYSVAL_ID_TO_TXS_DIM(id)            (((id) >> 7) & 0x3)
 #define PAN_SYSVAL_ID_TO_TXS_IS_ARRAY(id)       !!((id) & (1 << 9))
 
+/* Special attribute slots for vertex builtins. Sort of arbitrary but let's be
+ * consistent with the blob so we can compare traces easier. */
+
+enum {
+        PAN_VERTEX_ID   = 16,
+        PAN_INSTANCE_ID = 17,
+        PAN_MAX_ATTRIBUTE
+} pan_special_attributes;
+
 typedef struct {
         int work_register_count;
         int uniform_count;
         int uniform_cutoff;
 
-        int attribute_count;
-        int varying_count;
-
         /* Prepended before uniforms, mapping to SYSVAL_ names for the
          * sysval */
 
@@ -88,6 +79,9 @@ typedef struct {
 
         unsigned varyings[32];
 
+        /* Boolean properties of the program */
+        bool writes_point_size;
+
         int first_tag;
 
         struct util_dynarray compiled;
@@ -106,7 +100,7 @@ typedef struct {
 } midgard_program;
 
 int
-midgard_compile_shader_nir(struct midgard_screen *screen, nir_shader *nir, midgard_program *program, bool is_blend);
+midgard_compile_shader_nir(nir_shader *nir, midgard_program *program, bool is_blend, unsigned blend_rt, unsigned gpu_id, bool shaderdb);
 
 /* NIR options are shared between the standalone compiler and the online
  * compiler. Defining it here is the simplest, though maybe not the Right
@@ -125,6 +119,7 @@ static const nir_shader_compiler_options midgard_nir_options = {
         .lower_isign = true,
         .lower_fpow = true,
         .lower_find_lsb = true,
+        .lower_fdph = true,
 
         .lower_wpos_pntc = true,
 
@@ -132,14 +127,27 @@ static const nir_shader_compiler_options midgard_nir_options = {
          * eventually */
         .lower_fsign = true,
 
-        .vertex_id_zero_based = true,
         .lower_extract_byte = true,
         .lower_extract_word = true,
         .lower_rotate = true,
 
+        .lower_pack_half_2x16 = true,
+        .lower_pack_half_2x16_split = true,
+        .lower_pack_unorm_2x16 = true,
+        .lower_pack_snorm_2x16 = true,
+        .lower_pack_unorm_4x8 = true,
+        .lower_pack_snorm_4x8 = true,
+        .lower_unpack_half_2x16 = true,
+        .lower_unpack_half_2x16_split = true,
+        .lower_unpack_unorm_2x16 = true,
+        .lower_unpack_snorm_2x16 = true,
+        .lower_unpack_unorm_4x8 = true,
+        .lower_unpack_snorm_4x8 = true,
+
         .lower_doubles_options = nir_lower_dmod,
 
         .vectorize_io = true,
+        .use_interpolated_input_intrinsics = true
 };
 
 #endif