freedreno/ir3: debug cleanup
[mesa.git] / src / gallium / drivers / freedreno / freedreno_util.h
index 0017ac5a397a7e82c6adaf25acab255ab3d953fc..4a971d93e7c51880596fd298456193a2a3dce424 100644 (file)
@@ -84,8 +84,7 @@ enum adreno_stencil_op fd_stencil_op(unsigned op);
 #define FD_DBG_HIPRIO 0x100000
 #define FD_DBG_TTILE  0x200000
 #define FD_DBG_PERFC  0x400000
-#define FD_DBG_SOFTPIN 0x800000
-
+#define FD_DBG_NOUBWC 0x800000
 extern int fd_mesa_debug;
 extern bool fd_binning_enabled;
 
@@ -114,15 +113,19 @@ static inline uint32_t DRAW(enum pc_di_primtype prim_type,
 }
 
 static inline uint32_t DRAW_A20X(enum pc_di_primtype prim_type,
+               enum pc_di_face_cull_sel faceness_cull_select,
                enum pc_di_src_sel source_select, enum pc_di_index_size index_size,
-               enum pc_di_vis_cull_mode vis_cull_mode,
+               bool pre_fetch_cull_enable,
+               bool grp_cull_enable,
                uint16_t count)
 {
        return (prim_type         << 0) |
                        (source_select     << 6) |
+                       (faceness_cull_select << 8) |
                        ((index_size & 1)  << 11) |
                        ((index_size >> 1) << 13) |
-                       (vis_cull_mode     << 9) |
+                       (pre_fetch_cull_enable << 14) |
+                       (grp_cull_enable << 15) |
                        (count         << 16);
 }
 
@@ -194,6 +197,18 @@ fd_half_precision(struct pipe_framebuffer_state *pfb)
        return true;
 }
 
+/* Note sure if this is same on all gens, but seems to be same on the later
+ * gen's
+ */
+static inline unsigned
+fd_calc_guardband(unsigned x)
+{
+       float l = log2(x);
+       if (l <= 8)
+               return 511;
+       return 511 - ((l - 8) * 65);
+}
+
 #define LOG_DWORDS 0
 
 static inline void emit_marker(struct fd_ringbuffer *ring, int scratch_idx);
@@ -228,8 +243,8 @@ OUT_RINGP(struct fd_ringbuffer *ring, uint32_t data,
  */
 
 static inline void
-OUT_RELOC(struct fd_ringbuffer *ring, struct fd_bo *bo,
-               uint32_t offset, uint64_t or, int32_t shift)
+__out_reloc(struct fd_ringbuffer *ring, struct fd_bo *bo,
+               uint32_t offset, uint64_t or, int32_t shift, uint32_t flags)
 {
        if (LOG_DWORDS) {
                DBG("ring[%p]: OUT_RELOC   %04x:  %p+%u << %d", ring,
@@ -238,7 +253,7 @@ OUT_RELOC(struct fd_ringbuffer *ring, struct fd_bo *bo,
        debug_assert(offset < fd_bo_size(bo));
        fd_ringbuffer_reloc(ring, &(struct fd_reloc){
                .bo = bo,
-               .flags = FD_RELOC_READ,
+               .flags = flags,
                .offset = offset,
                .or = or,
                .shift = shift,
@@ -246,23 +261,25 @@ OUT_RELOC(struct fd_ringbuffer *ring, struct fd_bo *bo,
        });
 }
 
+static inline void
+OUT_RELOC(struct fd_ringbuffer *ring, struct fd_bo *bo,
+               uint32_t offset, uint64_t or, int32_t shift)
+{
+       __out_reloc(ring, bo, offset, or, shift, FD_RELOC_READ);
+}
+
 static inline void
 OUT_RELOCW(struct fd_ringbuffer *ring, struct fd_bo *bo,
                uint32_t offset, uint64_t or, int32_t shift)
 {
-       if (LOG_DWORDS) {
-               DBG("ring[%p]: OUT_RELOCW  %04x:  %p+%u << %d", ring,
-                               (uint32_t)(ring->cur - ring->start), bo, offset, shift);
-       }
-       debug_assert(offset < fd_bo_size(bo));
-       fd_ringbuffer_reloc(ring, &(struct fd_reloc){
-               .bo = bo,
-               .flags = FD_RELOC_READ | FD_RELOC_WRITE,
-               .offset = offset,
-               .or = or,
-               .shift = shift,
-               .orhi = or >> 32,
-       });
+       __out_reloc(ring, bo, offset, or, shift, FD_RELOC_READ | FD_RELOC_WRITE);
+}
+
+static inline void
+OUT_RELOCD(struct fd_ringbuffer *ring, struct fd_bo *bo,
+               uint32_t offset, uint64_t or, int32_t shift)
+{
+       __out_reloc(ring, bo, offset, or, shift, FD_RELOC_READ | FD_RELOC_DUMP);
 }
 
 static inline void
@@ -411,18 +428,6 @@ emit_marker(struct fd_ringbuffer *ring, int scratch_idx)
        OUT_RING(ring, ++marker_cnt);
 }
 
-/* helper to get numeric value from environment variable..  mostly
- * just leaving this here because it is helpful to brute-force figure
- * out unknown formats, etc, which blob driver does not support:
- */
-static inline uint32_t env2u(const char *envvar)
-{
-       char *str = getenv(envvar);
-       if (str)
-               return strtoul(str, NULL, 0);
-       return 0;
-}
-
 static inline uint32_t
 pack_rgba(enum pipe_format format, const float *rgba)
 {
@@ -453,9 +458,11 @@ fd_msaa_samples(unsigned samples)
        switch (samples) {
        default:
                debug_assert(0);
+       case 0:
        case 1: return MSAA_ONE;
        case 2: return MSAA_TWO;
        case 4: return MSAA_FOUR;
+       case 8: return MSAA_EIGHT;
        }
 }
 
@@ -472,6 +479,7 @@ fd4_stage2shadersb(gl_shader_stage type)
        case MESA_SHADER_FRAGMENT:
                return SB4_FS_SHADER;
        case MESA_SHADER_COMPUTE:
+       case MESA_SHADER_KERNEL:
                return SB4_CS_SHADER;
        default:
                unreachable("bad shader type");
@@ -479,4 +487,17 @@ fd4_stage2shadersb(gl_shader_stage type)
        }
 }
 
+static inline enum a4xx_index_size
+fd4_size2indextype(unsigned index_size)
+{
+       switch (index_size) {
+       case 1: return INDEX4_SIZE_8_BIT;
+       case 2: return INDEX4_SIZE_16_BIT;
+       case 4: return INDEX4_SIZE_32_BIT;
+       }
+       DBG("unsupported index size: %d", index_size);
+       assert(0);
+       return INDEX4_SIZE_32_BIT;
+}
+
 #endif /* FREEDRENO_UTIL_H_ */