panfrost/midgard: Drop dependence on mesa/st
[mesa.git] / src / gallium / drivers / panfrost / include / panfrost-job.h
index 3b51fcfddef47afb725dcf64ae5372f35e407b0e..97fcb0380dd2b8bf3b68896d55baef66bd393732 100644 (file)
@@ -69,14 +69,16 @@ enum mali_draw_mode {
 
 /* Applies to tiler_gl_enables */
 
-#define MALI_CULL_FACE_BACK  0x80
-#define MALI_CULL_FACE_FRONT 0x40
 
-#define MALI_FRONT_FACE(v) (v << 5)
+#define MALI_OCCLUSION_QUERY    (1 << 3)
+#define MALI_OCCLUSION_PRECISE  (1 << 4)
+
+#define MALI_FRONT_FACE(v)      (v << 5)
 #define MALI_CCW (0)
 #define MALI_CW  (1)
 
-#define MALI_OCCLUSION_BOOLEAN 0x8
+#define MALI_CULL_FACE_FRONT    (1 << 6)
+#define MALI_CULL_FACE_BACK     (1 << 7)
 
 /* TODO: Might this actually be a finer bitfield? */
 #define MALI_DEPTH_STENCIL_ENABLE 0x6400
@@ -292,6 +294,8 @@ struct mali_channel_swizzle {
  * bits mean.
  */
 
+#define MALI_CHANNEL_4 2
+
 #define MALI_CHANNEL_8 3
 
 #define MALI_CHANNEL_16 4
@@ -304,6 +308,8 @@ struct mali_channel_swizzle {
 #define MALI_CHANNEL_FLOAT 7
 
 enum mali_format {
+       MALI_RGB565         = MALI_FORMAT_SPECIAL | 0x0,
+       MALI_RGB5_A1_UNORM  = MALI_FORMAT_SPECIAL | 0x2,
        MALI_RGB10_A2_UNORM = MALI_FORMAT_SPECIAL | 0x3,
        MALI_RGB10_A2_SNORM = MALI_FORMAT_SPECIAL | 0x5,
        MALI_RGB10_A2UI     = MALI_FORMAT_SPECIAL | 0x7,
@@ -363,6 +369,7 @@ enum mali_format {
        MALI_RGB16_UNORM  = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(3) | MALI_CHANNEL_16,
        MALI_RGB32_UNORM  = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(3) | MALI_CHANNEL_32,
        MALI_RGB32F = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(3) | MALI_CHANNEL_FLOAT,
+       MALI_RGBA4_UNORM  = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(4) | MALI_CHANNEL_4,
        MALI_RGBA8_UNORM  = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(4) | MALI_CHANNEL_8,
        MALI_RGBA16_UNORM = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(4) | MALI_CHANNEL_16,
        MALI_RGBA32_UNORM = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(4) | MALI_CHANNEL_32,
@@ -401,6 +408,13 @@ enum mali_format {
 /* Applies to unknown1 */
 #define MALI_NO_ALPHA_TO_COVERAGE (1 << 10)
 
+/* 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)
+
 struct mali_blend_meta {
 #ifndef BIFROST
         /* Base value of 0x200.
@@ -747,6 +761,13 @@ enum mali_attr_mode {
        MALI_ATTR_NPOT_DIVIDE = 4,
 };
 
+/* This magic "pseudo-address" is used as `elements` to implement
+ * gl_PointCoord. When read from a fragment shader, it generates a point
+ * coordinate per the OpenGL ES 2.0 specification. Flipped coordinate spaces
+ * require an affine transformation in the shader. */
+
+#define MALI_VARYING_POINT_COORD (0x60)
+
 union mali_attr {
        /* This is used for actual attributes. */
        struct {
@@ -813,10 +834,12 @@ struct mali_uniform_buffer_meta {
  */
 
 /* Applies to unknown_draw */
+
 #define MALI_DRAW_INDEXED_UINT8  (0x10)
 #define MALI_DRAW_INDEXED_UINT16 (0x20)
 #define MALI_DRAW_INDEXED_UINT32 (0x30)
 #define MALI_DRAW_VARYING_SIZE   (0x100)
+#define MALI_DRAW_PRIMITIVE_RESTART_FIXED_INDEX (0x10000)
 
 struct mali_vertex_tiler_prefix {
         /* This is a dynamic bitfield containing the following things in this order:
@@ -1184,23 +1207,20 @@ struct mali_sampler_descriptor {
  */
 
 struct mali_viewport {
-        float floats[4];
+        /* XY clipping planes */
+        float clip_minx;
+        float clip_miny;
+        float clip_maxx;
+        float clip_maxy;
 
-        float depth_range_n;
-        float depth_range_f;
+        /* Depth clipping planes */
+        float clip_minz;
+        float clip_maxz;
 
         u16 viewport0[2];
         u16 viewport1[2];
 } __attribute__((packed));
 
-/* TODO: Varying meta is symmetrical with attr_meta, but there is some
- * weirdness associated. Figure it out. */
-
-struct mali_unknown6 {
-        u64 unknown0;
-        u64 unknown1;
-};
-
 /* From presentations, 16x16 tiles externally. Use shift for fast computation
  * of tile numbers. */
 
@@ -1339,15 +1359,26 @@ struct mali_single_framebuffer {
         /* More below this, maybe */
 } __attribute__((packed));
 
-/* Format bits for the render target */
+/* Format bits for the render target flags */
+
+#define MALI_MFBD_FORMAT_AFBC    (1 << 5)
+#define MALI_MFBD_FORMAT_MSAA    (1 << 7)
+
+struct mali_rt_format {
+        unsigned unk1 : 32;
+        unsigned unk2 : 3;
 
-#define MALI_MFBD_FORMAT_AFBC    (1 << 10)
-#define MALI_MFBD_FORMAT_MSAA    (1 << 12)
-#define MALI_MFBD_FORMAT_NO_ALPHA (1 << 25)
+        unsigned nr_channels : 2; /* MALI_POSITIVE */
+
+        unsigned flags : 11;
+
+        unsigned swizzle : 12;
+
+        unsigned unk4 : 4;
+} __attribute__((packed));
 
 struct bifrost_render_target {
-        u32 unk1; // = 0x4000000
-        u32 format;
+        struct mali_rt_format format;
 
         u64 zero1;
 
@@ -1394,12 +1425,19 @@ struct bifrost_render_target {
  * - TODO: Anything else?
  */
 
+/* Flags field: note, these are guesses */
+
+#define MALI_EXTRA_PRESENT      (0x400)
+#define MALI_EXTRA_AFBC         (0x20)
+#define MALI_EXTRA_AFBC_ZS      (0x10)
+#define MALI_EXTRA_ZS           (0x4)
+
 struct bifrost_fb_extra {
         mali_ptr checksum;
         /* Each tile has an 8 byte checksum, so the stride is "width in tiles * 8" */
         u32 checksum_stride;
 
-        u32 unk;
+        u32 flags;
 
         union {
                 /* Note: AFBC is only allowed for 24/8 combined depth/stencil. */
@@ -1432,6 +1470,14 @@ struct bifrost_fb_extra {
 } __attribute__((packed));
 
 /* flags for unk3 */
+
+/* Enables writing depth results back to main memory (rather than keeping them
+ * on-chip in the tile buffer and then discarding) */
+
+#define MALI_MFBD_DEPTH_WRITE (1 << 10)
+
+/* The MFBD contains the extra bifrost_fb_extra section */
+
 #define MALI_MFBD_EXTRA (1 << 13)
 
 struct bifrost_framebuffer {