panfrost: Inline panfrost-misc.h into panfrost-job.h
[mesa.git] / src / panfrost / encoder / pan_device.h
index 19aa2df35bdfc5eaa9494be315793d286d49bc0c..b84c8e7cdaeec84281eb5882e9a5ce63437545cd 100644 (file)
@@ -2,6 +2,7 @@
  *
  * Copyright 2018-2019 Alyssa Rosenzweig
  * Copyright 2018-2019 Collabora, Ltd.
+ * Copyright © 2015 Intel Corporation
  * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
 #include "renderonly/renderonly.h"
 #include "util/u_dynarray.h"
 #include "util/bitset.h"
-#include "util/set.h"
 #include "util/list.h"
+#include "util/sparse_array.h"
 
-#include <panfrost-misc.h>
+#include <panfrost-job.h>
 
 /* Driver limits */
 #define PAN_MAX_CONST_BUFFERS 16
 /* Fencepost problem, hence the off-by-one */
 #define NR_BO_CACHE_BUCKETS (MAX_BO_CACHE_BUCKET - MIN_BO_CACHE_BUCKET + 1)
 
+/* Cache for blit shaders. Defined here so they can be cached with the device */
+
+enum pan_blit_type {
+        PAN_BLIT_FLOAT = 0,
+        PAN_BLIT_UINT,
+        PAN_BLIT_INT,
+        PAN_BLIT_NUM_TYPES,
+};
+
+#define PAN_BLIT_NUM_TARGETS (12)
+
+struct pan_blit_shaders {
+        struct panfrost_bo *bo;
+        mali_ptr loads[PAN_BLIT_NUM_TARGETS][PAN_BLIT_NUM_TYPES][2];
+};
+
 struct panfrost_device {
         /* For ralloc */
         void *memctx;
@@ -79,12 +96,18 @@ struct panfrost_device {
         unsigned thread_tls_alloc;
         unsigned quirks;
 
+        /* Bitmask of supported compressed texture formats */
+        uint32_t compressed_formats;
+
+        /* debug flags, see pan_util.h how to interpret */
+        unsigned debug;
+
         drmVersionPtr kernel_version;
 
         struct renderonly *ro;
 
-        pthread_mutex_t active_bos_lock;
-        struct set *active_bos;
+        pthread_mutex_t bo_map_lock;
+        struct util_sparse_array bo_map;
 
         struct {
                 pthread_mutex_t lock;
@@ -102,6 +125,23 @@ struct panfrost_device {
 
                 struct list_head buckets[NR_BO_CACHE_BUCKETS];
         } bo_cache;
+
+        struct pan_blit_shaders blit_shaders;
 };
 
+void
+panfrost_open_device(void *memctx, int fd, struct panfrost_device *dev);
+
+void
+panfrost_close_device(struct panfrost_device *dev);
+
+bool
+panfrost_supports_compressed_format(struct panfrost_device *dev, unsigned fmt);
+
+static inline struct panfrost_bo *
+pan_lookup_bo(struct panfrost_device *dev, uint32_t gem_handle)
+{
+        return util_sparse_array_get(&dev->bo_map, gem_handle);
+}
+
 #endif