gallium: add PIPE_CAP_SHAREABLE_SHADERS
[mesa.git] / src / gallium / drivers / freedreno / freedreno_util.h
index ed56817349772747ab43eaa6e8e921af07e232b0..0d2418e1e00c6fe3dce05243a9348616c84380c3 100644 (file)
@@ -57,13 +57,13 @@ enum adreno_stencil_op fd_stencil_op(unsigned op);
 #define A2XX_MAX_RENDER_TARGETS 1
 #define A3XX_MAX_RENDER_TARGETS 4
 #define A4XX_MAX_RENDER_TARGETS 8
-/* for now until a4xx MRT support: */
-#define MAX_RENDER_TARGETS A3XX_MAX_RENDER_TARGETS
+
+#define MAX_RENDER_TARGETS A4XX_MAX_RENDER_TARGETS
 
 #define FD_DBG_MSGS     0x0001
 #define FD_DBG_DISASM   0x0002
 #define FD_DBG_DCLEAR   0x0004
-#define FD_DBG_FLUSH    0x0008
+#define FD_DBG_DDRAW    0x0008
 #define FD_DBG_NOSCIS   0x0010
 #define FD_DBG_DIRECT   0x0020
 #define FD_DBG_NOBYPASS 0x0040
@@ -72,6 +72,7 @@ enum adreno_stencil_op fd_stencil_op(unsigned op);
 #define FD_DBG_OPTMSGS  0x0200
 #define FD_DBG_GLSL120  0x0400
 #define FD_DBG_SHADERDB 0x0800
+#define FD_DBG_FLUSH    0x1000
 
 extern int fd_mesa_debug;
 extern bool fd_binning_enabled;
@@ -116,6 +117,58 @@ pipe_surface_format(struct pipe_surface *psurf)
        return psurf->format;
 }
 
+static inline bool
+fd_surface_half_precision(const struct pipe_surface *psurf)
+{
+       enum pipe_format format;
+
+       if (!psurf)
+               return true;
+
+       format = psurf->format;
+
+       /* colors are provided in consts, which go through cov.f32f16, which will
+        * break these values
+        */
+       if (util_format_is_pure_integer(format))
+               return false;
+
+       /* avoid losing precision on 32-bit float formats */
+       if (util_format_is_float(format) &&
+               util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) == 32)
+               return false;
+
+       return true;
+}
+
+static inline unsigned
+fd_sampler_first_level(const struct pipe_sampler_view *view)
+{
+       if (view->target == PIPE_BUFFER)
+               return 0;
+       return view->u.tex.first_level;
+}
+
+static inline unsigned
+fd_sampler_last_level(const struct pipe_sampler_view *view)
+{
+       if (view->target == PIPE_BUFFER)
+               return 0;
+       return view->u.tex.last_level;
+}
+
+static inline bool
+fd_half_precision(struct pipe_framebuffer_state *pfb)
+{
+       unsigned i;
+
+       for (i = 0; i < pfb->nr_cbufs; i++)
+               if (!fd_surface_half_precision(pfb->cbufs[i]))
+                       return false;
+
+       return true;
+}
+
 #define LOG_DWORDS 0
 
 static inline void emit_marker(struct fd_ringbuffer *ring, int scratch_idx);