panfrost: Remove ancient comment
[mesa.git] / src / gallium / drivers / panfrost / include / panfrost-job.h
index 8a4a7644070c2462e3fa9dfe07fad558be2835df..444e5ad9e69a30b312d8d9ab75c9d3b22bee6289 100644 (file)
@@ -2,6 +2,7 @@
  * © Copyright 2017-2018 Alyssa Rosenzweig
  * © Copyright 2017-2018 Connor Abbott
  * © Copyright 2017-2018 Lyude Paul
+ * © Copyright2019 Collabora, Ltd.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -167,9 +168,6 @@ struct mali_stencil_test {
         unsigned zero                  : 4;
 } __attribute__((packed));
 
-/* Blending is a mess, since anything fancy triggers a blend shader, and
- * -those- are not understood whatsover yet */
-
 #define MALI_MASK_R (1 << 0)
 #define MALI_MASK_G (1 << 1)
 #define MALI_MASK_B (1 << 2)
@@ -320,6 +318,7 @@ enum mali_format {
        MALI_RGB32_FIXED    = MALI_FORMAT_SPECIAL | 0x13,
        MALI_RGBA32_FIXED   = MALI_FORMAT_SPECIAL | 0x14,
        MALI_R11F_G11F_B10F = MALI_FORMAT_SPECIAL | 0x19,
+        MALI_R9F_G9F_B9F_E5F = MALI_FORMAT_SPECIAL | 0x1b,
        /* Only used for varyings, to indicate the transformed gl_Position */
        MALI_VARYING_POS    = MALI_FORMAT_SPECIAL | 0x1e,
        /* Only used for varyings, to indicate that the write should be
@@ -401,15 +400,27 @@ enum mali_format {
 #define MALI_ALPHA_COVERAGE(clampf) ((uint16_t) (int) (clampf * 15.0f))
 #define MALI_GET_ALPHA_COVERAGE(nibble) ((float) nibble / 15.0f)
 
-/* Applies to unknown1 */
-#define MALI_NO_ALPHA_TO_COVERAGE (1 << 10)
+/* Applies to midgard1.flags */
+
+/* Should the hardware perform early-Z testing? Normally should be set
+ * for performance reasons. Clear if you use: discard,
+ * alpha-to-coverage... * It's also possible this disables
+ * forward-pixel kill; we're not quite sure which bit is which yet.
+ * TODO: How does this interact with blending?*/
+
+#define MALI_EARLY_Z (1 << 6)
+
+/* Should the hardware calculate derivatives (via helper invocations)? Set in a
+ * fragment shader that uses texturing or derivative functions */
+
+#define MALI_HELPER_INVOCATIONS (1 << 7)
 
 /* Flags denoting the fragment shader's use of tilebuffer readback. If the
  * shader might read any part of the tilebuffer, set MALI_READS_TILEBUFFER. If
  * it might read depth/stencil in particular, also set MALI_READS_ZS */
 
-#define MALI_READS_ZS (1 << 12)
-#define MALI_READS_TILEBUFFER (1 << 16)
+#define MALI_READS_ZS (1 << 8)
+#define MALI_READS_TILEBUFFER (1 << 12)
 
 /* The raw Midgard blend payload can either be an equation or a shader
  * address, depending on the context */
@@ -426,11 +437,14 @@ union midgard_blend {
 /* On MRT Midgard systems (using an MFBD), each render target gets its own
  * blend descriptor */
 
+#define MALI_BLEND_SRGB (0x400)
+
 struct midgard_blend_rt {
         /* Flags base value of 0x200 to enable the render target.
          * OR with 0x1 for blending (anything other than REPLACE).
          * OR with 0x2 for programmable blending with 0-2 registers
          * OR with 0x3 for programmable blending with 2+ registers
+         * OR with MALI_BLEND_SRGB for implicit sRGB
          */
 
         u64 flags;
@@ -525,9 +539,8 @@ struct mali_shader_meta {
                         u32 unk1 : 28; // = 0x800000 for vertex, 0x958020 for tiler
                 } bifrost1;
                 struct {
-                        /* 0x200 except MALI_NO_ALPHA_TO_COVERAGE. Mysterious 1
-                         * other times. Who knows really? */
-                        u16 unknown1;
+                        unsigned uniform_buffer_count : 4;
+                        unsigned flags : 12;
 
                         /* Whole number of uniform registers used, times two;
                          * whole number of work registers used (no scale).
@@ -962,7 +975,8 @@ struct bifrost_tiler_heap_meta {
 
 struct bifrost_tiler_meta {
         u64 zero0;
-        u32 unk; // = 0xf0
+        u16 hierarchy_mask;
+        u16 flags;
         u16 width;
         u16 height;
         u64 zero1;
@@ -1082,9 +1096,6 @@ struct bifrost_payload_fused {
         struct mali_vertex_tiler_postfix vertex_postfix;
 } __attribute__((packed));
 
-/* Pointed to from texture_trampoline, mostly unknown still, haven't
- * managed to replay successfully */
-
 /* Purposeful off-by-one in width, height fields. For example, a (64, 64)
  * texture is stored as (63, 63) in these fields. This adjusts for that.
  * There's an identical pattern in the framebuffer descriptor. Even vertex
@@ -1106,11 +1117,23 @@ enum mali_wrap_mode {
         MALI_WRAP_MIRRORED_REPEAT = 0xC
 };
 
+/* Shared across both command stream and Midgard, and even with Bifrost */
+
+enum mali_texture_type {
+        MALI_TEX_CUBE = 0x0,
+        MALI_TEX_1D = 0x1,
+        MALI_TEX_2D = 0x2,
+        MALI_TEX_3D = 0x3
+};
+
 /* 8192x8192 */
 #define MAX_MIP_LEVELS (13)
 
 /* Cubemap bloats everything up */
-#define MAX_FACES (6)
+#define MAX_CUBE_FACES (6)
+
+/* For each pointer, there is an address and optionally also a stride */
+#define MAX_ELEMENTS (2)
 
 /* Corresponds to the type passed to glTexImage2D and so forth */
 
@@ -1121,8 +1144,11 @@ struct mali_texture_format {
         unsigned swizzle : 12;
         enum mali_format format : 8;
 
-        unsigned usage1 : 3;
-        unsigned is_not_cubemap : 1;
+        unsigned srgb : 1;
+        unsigned unknown1 : 1;
+
+        enum mali_texture_type type : 2;
+
         unsigned usage2 : 8;
 } __attribute__((packed));
 
@@ -1130,8 +1156,7 @@ struct mali_texture_descriptor {
         uint16_t width;
         uint16_t height;
         uint16_t depth;
-
-        uint16_t unknown1;
+        uint16_t array_size;
 
         struct mali_texture_format format;
 
@@ -1155,7 +1180,7 @@ struct mali_texture_descriptor {
         uint32_t unknown6;
         uint32_t unknown7;
 
-        mali_ptr swizzled_bitmaps[MAX_MIP_LEVELS * MAX_FACES];
+        mali_ptr payload[MAX_MIP_LEVELS * MAX_CUBE_FACES * MAX_ELEMENTS];
 } __attribute__((packed));
 
 /* Used as part of filter_mode */
@@ -1207,8 +1232,9 @@ struct mali_sampler_descriptor {
         enum mali_wrap_mode wrap_r : 4;
         enum mali_alt_func compare_func : 3;
 
-        /* A single set bit of unknown, ha! */
-        unsigned unknown2 : 1;
+        /* No effect on 2D textures. For cubemaps, set for ES3 and clear for
+         * ES2, controlling seamless cubemapping */
+        unsigned seamless_cube_map : 1;
 
         unsigned zero : 16;
 
@@ -1358,25 +1384,44 @@ struct mali_single_framebuffer {
 
         u32 zero6[7];
 
-        /* Very weird format, see generation code in trans_builder.c */
-        u32 resolution_check;
+        /* Logically, by symmetry to the MFBD, this ought to be the size of the
+         * polygon list. But this doesn't quite compute up. More investigation
+         * is needed. */
+
+        u32 tiler_resolution_check;
 
-        u32 tiler_flags;
+        u16 tiler_hierarchy_mask;
+        u16 tiler_flags;
 
-        u64 unknown_address_1; /* Pointing towards... a zero buffer? */
-        u64 unknown_address_2;
+        /* See pan_tiler.c */
+        mali_ptr tiler_polygon_list; 
+        mali_ptr tiler_polygon_list_body;
 
         /* See mali_kbase_replay.c */
-        u64 tiler_heap_free;
-        u64 tiler_heap_end;
+        mali_ptr tiler_heap_free;
+        mali_ptr tiler_heap_end;
 
         /* More below this, maybe */
 } __attribute__((packed));
 
+/* On Midgard, this "framebuffer descriptor" is used for the framebuffer field
+ * of compute jobs. Superficially resembles a single framebuffer descriptor */
+
+struct mali_compute_fbd {
+        u32 unknown1[16];
+} __attribute__((packed));
+
 /* Format bits for the render target flags */
 
-#define MALI_MFBD_FORMAT_AFBC    (1 << 5)
-#define MALI_MFBD_FORMAT_MSAA    (1 << 7)
+#define MALI_MFBD_FORMAT_MSAA    (1 << 1)
+#define MALI_MFBD_FORMAT_SRGB    (1 << 2)
+
+enum mali_mfbd_block_format {
+        MALI_MFBD_BLOCK_TILED   = 0x0,
+        MALI_MFBD_BLOCK_UNKNOWN = 0x1,
+        MALI_MFBD_BLOCK_LINEAR  = 0x2,
+        MALI_MFBD_BLOCK_AFBC    = 0x3,
+};
 
 struct mali_rt_format {
         unsigned unk1 : 32;
@@ -1384,7 +1429,9 @@ struct mali_rt_format {
 
         unsigned nr_channels : 2; /* MALI_POSITIVE */
 
-        unsigned flags : 11;
+        unsigned unk3 : 5;
+        enum mali_mfbd_block_format block : 2;
+        unsigned flags : 4;
 
         unsigned swizzle : 12;
 
@@ -1483,7 +1530,7 @@ struct bifrost_fb_extra {
         u64 zero3, zero4;
 } __attribute__((packed));
 
-/* flags for unk3 */
+/* Flags for mfbd_flags */
 
 /* Enables writing depth results back to main memory (rather than keeping them
  * on-chip in the tile buffer and then discarding) */
@@ -1514,20 +1561,33 @@ struct bifrost_framebuffer {
         u32 zero4 : 5;
         /* 0x30 */
         u32 clear_stencil : 8;
-        u32 unk3 : 24; // = 0x100
+        u32 mfbd_flags : 24; // = 0x100
         float clear_depth;
-        mali_ptr tiler_meta;
-        /* 0x40 */
 
-        /* Note: these are guesses! */
-        mali_ptr tiler_scratch_start;
-        mali_ptr tiler_scratch_middle;
 
-        /* These are not, since we see symmetry with replay jobs which name these explicitly */
-        mali_ptr tiler_heap_start;
+        /* Tiler section begins here */
+        u32 tiler_polygon_list_size;
+
+        /* Name known from the replay workaround in the kernel. What exactly is
+         * flagged here is less known. We do that (tiler_hierarchy_mask & 0x1ff)
+         * specifies a mask of hierarchy weights, which explains some of the
+         * performance mysteries around setting it. We also see the bottom bit
+         * of tiler_flags set in the kernel, but no comment why. */
+
+        u16 tiler_hierarchy_mask;
+        u16 tiler_flags;
+
+        /* See mali_tiler.c for an explanation */
+        mali_ptr tiler_polygon_list;
+        mali_ptr tiler_polygon_list_body;
+
+        /* Names based on we see symmetry with replay jobs which name these
+         * explicitly */
+
+        mali_ptr tiler_heap_start; /* tiler heap_free_address */
         mali_ptr tiler_heap_end;
         
-        u64 zero9, zero10, zero11, zero12;
+        u32 tiler_weights[8];
 
         /* optional: struct bifrost_fb_extra extra */
         /* struct bifrost_render_target rts[] */