panfrost: Drop unused mali_channel_swizzle
[mesa.git] / src / panfrost / include / panfrost-job.h
index 720420f8ed176923f037e930c1084aa25fe12d22..1adfbb2c0dc96ec3b16ac759968d2a9b84e9c308 100644 (file)
 
 #include <stdint.h>
 #include <stdbool.h>
-#include <panfrost-misc.h>
-
-enum mali_job_type {
-        JOB_NOT_STARTED        = 0,
-        JOB_TYPE_NULL = 1,
-        JOB_TYPE_WRITE_VALUE = 2,
-        JOB_TYPE_CACHE_FLUSH = 3,
-        JOB_TYPE_COMPUTE = 4,
-        JOB_TYPE_VERTEX = 5,
-        JOB_TYPE_GEOMETRY = 6,
-        JOB_TYPE_TILER = 7,
-        JOB_TYPE_FUSED = 8,
-        JOB_TYPE_FRAGMENT = 9,
-};
+#include <inttypes.h>
 
-enum mali_draw_mode {
-        MALI_DRAW_NONE      = 0x0,
-        MALI_POINTS         = 0x1,
-        MALI_LINES          = 0x2,
-        MALI_LINE_STRIP     = 0x4,
-        MALI_LINE_LOOP      = 0x6,
-        MALI_TRIANGLES      = 0x8,
-        MALI_TRIANGLE_STRIP = 0xA,
-        MALI_TRIANGLE_FAN   = 0xC,
-        MALI_POLYGON        = 0xD,
-        MALI_QUADS          = 0xE,
-        MALI_QUAD_STRIP     = 0xF,
-
-        /* All other modes invalid */
-};
+typedef uint8_t  u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+typedef uint64_t u64;
+typedef uint64_t mali_ptr;
 
 /* Applies to tiler_gl_enables */
 
@@ -76,22 +53,13 @@ enum mali_draw_mode {
 #define MALI_CULL_FACE_FRONT    (1 << 6)
 #define MALI_CULL_FACE_BACK     (1 << 7)
 
-/* Used in stencil and depth tests */
-
-enum mali_func {
-        MALI_FUNC_NEVER    = 0,
-        MALI_FUNC_LESS     = 1,
-        MALI_FUNC_EQUAL    = 2,
-        MALI_FUNC_LEQUAL   = 3,
-        MALI_FUNC_GREATER  = 4,
-        MALI_FUNC_NOTEQUAL = 5,
-        MALI_FUNC_GEQUAL   = 6,
-        MALI_FUNC_ALWAYS   = 7
-};
-
 /* Flags apply to unknown2_3? */
 
 #define MALI_HAS_MSAA          (1 << 0)
+
+/* Execute fragment shader per-sample if set (e.g. to implement gl_SampleID
+ * reads) */
+#define MALI_PER_SAMPLE         (1 << 2)
 #define MALI_CAN_DISCARD       (1 << 5)
 
 /* Applies on SFBD systems, specifying that programmable blending is in use */
@@ -117,30 +85,6 @@ enum mali_func {
 #define MALI_DEPTH_RANGE_B     (1 << 13)
 #define MALI_NO_MSAA           (1 << 14)
 
-/* Stencil test state is all encoded in a single u32, just with a lot of
- * enums... */
-
-enum mali_stencil_op {
-        MALI_STENCIL_KEEP      = 0,
-        MALI_STENCIL_REPLACE   = 1,
-        MALI_STENCIL_ZERO      = 2,
-        MALI_STENCIL_INVERT    = 3,
-        MALI_STENCIL_INCR_WRAP         = 4,
-        MALI_STENCIL_DECR_WRAP         = 5,
-        MALI_STENCIL_INCR      = 6,
-        MALI_STENCIL_DECR      = 7
-};
-
-struct mali_stencil_test {
-        unsigned ref                   : 8;
-        unsigned mask                  : 8;
-        enum mali_func func            : 3;
-        enum mali_stencil_op sfail     : 3;
-        enum mali_stencil_op dpfail    : 3;
-        enum mali_stencil_op dppass    : 3;
-        unsigned zero                  : 4;
-} __attribute__((packed));
-
 #define MALI_MASK_R (1 << 0)
 #define MALI_MASK_G (1 << 1)
 #define MALI_MASK_B (1 << 2)
@@ -215,13 +159,6 @@ enum mali_channel {
        MALI_CHANNEL_RESERVED_1 = 7,
 };
 
-struct mali_channel_swizzle {
-       enum mali_channel r : 3;
-       enum mali_channel g : 3;
-       enum mali_channel b : 3;
-       enum mali_channel a : 3;
-} __attribute__((packed));
-
 /* Compressed per-pixel formats. Each of these formats expands to one to four
  * floating-point or integer numbers, as defined by the OpenGL specification.
  * There are various places in OpenGL where the user can specify a compressed
@@ -633,8 +570,8 @@ struct mali_shader_meta {
         u8 stencil_mask_back;
         u16 unknown2_4;
 
-        struct mali_stencil_test stencil_front;
-        struct mali_stencil_test stencil_back;
+        struct mali_stencil_packed stencil_front;
+        struct mali_stencil_packed stencil_back;
 
         union {
                 struct {
@@ -950,24 +887,6 @@ struct mali_attr_meta {
 /* ORed into an MFBD address to specify the fbx section is included */
 #define MALI_MFBD_TAG_EXTRA (0x2)
 
-/* Uniform buffer objects are 64-bit fields divided as:
- *
- *      u64 size : 10;
- *      mali_ptr ptr : 64 - 10;
- *
- * The size is actually the size minus 1 (MALI_POSITIVE), in units of 16 bytes.
- * This gives a maximum of 2^14 bytes, which just so happens to be the GL
- * minimum-maximum for GL_MAX_UNIFORM_BLOCK_SIZE.
- *
- * The pointer is missing the bottom 2 bits and top 8 bits. The top 8 bits
- * should be 0 for userspace pointers, according to
- * https://lwn.net/Articles/718895/. By reusing these bits, we can make each
- * entry in the table only 64 bits.
- */
-
-#define MALI_MAKE_UBO(elements, ptr) \
-        (MALI_POSITIVE((elements)) | (((ptr) >> 2) << 10))
-
 /* On Bifrost, these fields are the same between the vertex and tiler payloads.
  * They also seem to be the same between Bifrost and Midgard. They're shared in
  * fused payloads.
@@ -1213,28 +1132,6 @@ struct bifrost_payload_fused {
 
 #define MALI_POSITIVE(dim) (dim - 1)
 
-/* Used with wrapping. Unclear what top bit conveys */
-
-enum mali_wrap_mode {
-        MALI_WRAP_REPEAT                   = 0x8 |       0x0,
-        MALI_WRAP_CLAMP_TO_EDGE            = 0x8 |       0x1,
-        MALI_WRAP_CLAMP                    = 0x8 |       0x2,
-        MALI_WRAP_CLAMP_TO_BORDER          = 0x8 |       0x3,
-        MALI_WRAP_MIRRORED_REPEAT          = 0x8 | 0x4 | 0x0,
-        MALI_WRAP_MIRRORED_CLAMP_TO_EDGE   = 0x8 | 0x4 | 0x1,
-        MALI_WRAP_MIRRORED_CLAMP           = 0x8 | 0x4 | 0x2,
-        MALI_WRAP_MIRRORED_CLAMP_TO_BORDER = 0x8 | 0x4 | 0x3,
-};
-
-/* 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)
 
@@ -1244,118 +1141,6 @@ enum mali_texture_type {
 /* For each pointer, there is an address and optionally also a stride */
 #define MAX_ELEMENTS (2)
 
-/* It's not known why there are 4-bits allocated -- this enum is almost
- * certainly incomplete */
-
-enum mali_texture_layout {
-        /* For a Z/S texture, this is linear */
-        MALI_TEXTURE_TILED = 0x1,
-
-        /* Z/S textures cannot be tiled */
-        MALI_TEXTURE_LINEAR = 0x2,
-
-        /* 16x16 sparse */
-        MALI_TEXTURE_AFBC = 0xC
-};
-
-/* Corresponds to the type passed to glTexImage2D and so forth */
-
-struct mali_texture_format {
-        unsigned swizzle : 12;
-        enum mali_format format : 8;
-
-        unsigned srgb : 1;
-        unsigned unknown1 : 1;
-
-        enum mali_texture_type type : 2;
-        enum mali_texture_layout layout : 4;
-
-        /* Always set */
-        unsigned unknown2 : 1;
-
-        /* Set to allow packing an explicit stride */
-        unsigned manual_stride : 1;
-
-        unsigned zero : 2;
-} __attribute__((packed));
-
-struct mali_texture_descriptor {
-        uint16_t width;
-        uint16_t height;
-        uint16_t depth;
-        uint16_t array_size;
-
-        struct mali_texture_format format;
-
-        uint16_t unknown3;
-
-        /* One for non-mipmapped, zero for mipmapped */
-        uint8_t unknown3A;
-
-        /* Zero for non-mipmapped, (number of levels - 1) for mipmapped */
-        uint8_t levels;
-
-        /* Swizzling is a single 32-bit word, broken up here for convenience.
-         * Here, swizzling refers to the ES 3.0 texture parameters for channel
-         * level swizzling, not the internal pixel-level swizzling which is
-         * below OpenGL's reach */
-
-        unsigned swizzle : 12;
-        unsigned swizzle_zero       : 20;
-
-        uint32_t unknown5;
-        uint32_t unknown6;
-        uint32_t unknown7;
-} __attribute__((packed));
-
-/* While Midgard texture descriptors are variable length, Bifrost descriptors
- * are fixed like samplers with more pointers to expand if necessary */
-
-struct bifrost_texture_descriptor {
-        unsigned format_unk : 4; /* 2 */
-        enum mali_texture_type type : 2;
-        unsigned zero : 4;
-        unsigned format_swizzle : 12;
-        enum mali_format format : 8;
-        unsigned srgb : 1;
-        unsigned format_unk3 : 1; /* 0 */
-
-        uint16_t width; /* MALI_POSITIVE */
-        uint16_t height; /* MALI_POSITIVE */
-
-        /* OpenGL swizzle */
-        unsigned swizzle : 12;
-        enum mali_texture_layout layout : 4;
-        uint8_t levels : 8; /* Number of levels-1 if mipmapped, 0 if not */
-        unsigned unk1 : 8;
-
-        unsigned levels_unk : 24; /* 0 */
-        unsigned level_2 : 8; /* Number of levels, again? */
-
-        mali_ptr payload;
-
-        uint16_t array_size;
-        uint16_t unk4;
-
-        uint16_t depth;
-        uint16_t unk5;
-} __attribute__((packed));
-
-/* filter_mode */
-
-#define MALI_SAMP_MAG_NEAREST (1 << 0)
-#define MALI_SAMP_MIN_NEAREST (1 << 1)
-
-/* TODO: What do these bits mean individually? Only seen set together */
-
-#define MALI_SAMP_MIP_LINEAR_1 (1 << 3)
-#define MALI_SAMP_MIP_LINEAR_2 (1 << 4)
-
-/* Flag in filter_mode, corresponding to OpenCL's NORMALIZED_COORDS_TRUE
- * sampler_t flag. For typical OpenGL textures, this is always set. */
-
-#define MALI_SAMP_NORM_COORDS (1 << 5)
-
 /* Used for lod encoding. Thanks @urjaman for pointing out these routines can
  * be cleaned up a lot. */
 
@@ -1373,83 +1158,6 @@ FIXED_16(float x, bool allow_negative)
         return (int) (x * 256.0);
 }
 
-struct mali_sampler_descriptor {
-        uint16_t filter_mode;
-
-        /* Fixed point, signed.
-         * Upper 7 bits before the decimal point, although it caps [0-31].
-         * Lower 8 bits after the decimal point: int(round(x * 256)) */
-
-        int16_t lod_bias;
-        int16_t min_lod;
-        int16_t max_lod;
-
-        /* All one word in reality, but packed a bit. Comparisons are flipped
-         * from OpenGL. */
-
-        enum mali_wrap_mode wrap_s : 4;
-        enum mali_wrap_mode wrap_t : 4;
-        enum mali_wrap_mode wrap_r : 4;
-        enum mali_func compare_func : 3;
-
-        /* 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;
-
-        uint32_t zero2;
-        float border_color[4];
-} __attribute__((packed));
-
-/* Bifrost sampler descriptors look pretty similar */
-
-#define BIFROST_SAMP_MIN_NEAREST        (1)
-#define BIFROST_SAMP_MAG_LINEAR         (1)
-
-struct bifrost_sampler_descriptor {
-        uint8_t unk1;
-
-        enum mali_wrap_mode wrap_r : 4;
-        enum mali_wrap_mode wrap_t : 4;
-        enum mali_wrap_mode wrap_s : 4;
-        uint8_t unk8 : 4;
-
-        uint8_t unk2 : 1;
-        uint8_t norm_coords : 1;
-        uint8_t unk3 : 1;
-        uint8_t min_filter : 1;
-        uint8_t zero1 : 1;
-        uint8_t mag_filter : 1;
-        uint8_t mip_filter : 1;
-
-        int16_t min_lod;
-        int16_t max_lod;
-
-        uint64_t zero2;
-        uint64_t zero3;
-        uint64_t zero4;
-} __attribute__((packed));
-
-/* viewport0/viewport1 form the arguments to glViewport. viewport1 is
- * modified by MALI_POSITIVE; viewport0 is as-is.
- */
-
-struct mali_viewport {
-        /* XY clipping planes */
-        float clip_minx;
-        float clip_miny;
-        float clip_maxx;
-        float clip_maxy;
-
-        /* Depth clipping planes */
-        float clip_minz;
-        float clip_maxz;
-
-        u16 viewport0[2];
-        u16 viewport1[2];
-} __attribute__((packed));
-
 /* From presentations, 16x16 tiles externally. Use shift for fast computation
  * of tile numbers. */
 
@@ -1689,14 +1397,22 @@ struct mali_single_framebuffer {
         /* More below this, maybe */
 } __attribute__((packed));
 
-/* Format bits for the render target flags. Setting MSAA alone works for on
- * chip MSAA. Setting MSAA with the LAYERED flag works for MSAA where each
- * sample is its own image (implements the ES3 spec directly but inefficient on
- * mobile). */
 
-#define MALI_MFBD_FORMAT_LAYERED  (1 << 0)
-#define MALI_MFBD_FORMAT_MSAA    (1 << 1)
-#define MALI_MFBD_FORMAT_SRGB    (1 << 2)
+/* SINGLE to disable multisampling, AVERAGE for
+ * EXT_multisampled_render_to_texture operation where multiple tilebuffer
+ * samples are implicitly resolved before writeout, MULTIPLE to write multiple
+ * samples inline, and LAYERED for ES3-style multisampling with each sample in
+ * a different buffer.
+ */
+
+enum mali_msaa_mode {
+        MALI_MSAA_SINGLE = 0,
+        MALI_MSAA_AVERAGE = 1,
+        MALI_MSAA_MULTIPLE = 2,
+        MALI_MSAA_LAYERED = 3,
+};
+
+#define MALI_MFBD_FORMAT_SRGB    (1 << 0)
 
 struct mali_rt_format {
         unsigned unk1 : 32;
@@ -1707,7 +1423,8 @@ struct mali_rt_format {
         unsigned unk3 : 4;
         unsigned unk4 : 1;
         enum mali_block_format block : 2;
-        unsigned flags : 4;
+        enum mali_msaa_mode msaa : 2;
+        unsigned flags : 2;
 
         unsigned swizzle : 12;
 
@@ -1773,7 +1490,7 @@ struct mali_render_target {
  */
 
 /* flags_hi */
-#define MALI_EXTRA_PRESENT      (0x10)
+#define MALI_EXTRA_PRESENT      (0x1)
 
 /* flags_lo */
 #define MALI_EXTRA_ZS           (0x4)
@@ -1785,7 +1502,11 @@ struct mali_framebuffer_extra  {
 
         unsigned flags_lo : 4;
         enum mali_block_format zs_block : 2;
-        unsigned flags_hi : 26;
+
+        /* Number of samples in Z/S attachment, MALI_POSITIVE. So zero for
+         * 1-sample (non-MSAA), 0x3 for MSAA 4x, etc */
+        unsigned zs_samples : 4;
+        unsigned flags_hi : 22;
 
         union {
                 /* Note: AFBC is only allowed for 24/8 combined depth/stencil. */
@@ -1841,8 +1562,8 @@ struct mali_framebuffer {
         u32 zero3;
         u16 width2, height2;
         u32 unk1 : 19; // = 0x01000
-        u32 rt_count_1 : 2; // off-by-one (use MALI_POSITIVE)
-        u32 unk2 : 3; // = 0
+        u32 rt_count_1 : 3; // off-by-one (use MALI_POSITIVE)
+        u32 unk2 : 2; // = 0
         u32 rt_count_2 : 3; // no off-by-one
         u32 zero4 : 5;
         /* 0x30 */