freedreno/gmem: split out helper to calc # of bins
[mesa.git] / src / gallium / drivers / lima / lima_screen.c
index 0995ac86e6d0d8444ada9367a9ed920203a9087e..1a6ff22dc447526029edf52a5216f39518418fa8 100644 (file)
 #include "lima_bo.h"
 #include "lima_fence.h"
 #include "lima_format.h"
-#include "lima_util.h"
 #include "ir/lima_ir.h"
 
 #include "xf86drm.h"
 
 int lima_plb_max_blk = 0;
+int lima_plb_pp_stream_cache_size = 0;
 
 static void
 lima_screen_destroy(struct pipe_screen *pscreen)
 {
    struct lima_screen *screen = lima_screen(pscreen);
 
-   lima_dump_file_close();
-
    slab_destroy_parent(&screen->transfer_pool);
 
    if (screen->ro)
@@ -149,6 +147,9 @@ lima_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_CLIP_PLANES:
       return 0;
 
+   case PIPE_CAP_FRAGMENT_SHADER_DERIVATIVES:
+      return 1;
+
    default:
       return u_pipe_screen_get_param_defaults(pscreen, param);
    }
@@ -311,7 +312,6 @@ lima_screen_is_format_supported(struct pipe_screen *pscreen,
 
    if (usage & PIPE_BIND_DEPTH_STENCIL) {
       switch (format) {
-      case PIPE_FORMAT_Z16_UNORM:
       case PIPE_FORMAT_Z24_UNORM_S8_UINT:
       case PIPE_FORMAT_Z24X8_UNORM:
          break;
@@ -469,6 +469,8 @@ static const struct debug_named_value debug_options[] = {
           "don't use tiled buffers" },
         { "nogrowheap",   LIMA_DEBUG_NO_GROW_HEAP,
           "disable growable heap buffer" },
+        { "singlejob", LIMA_DEBUG_SINGLE_JOB,
+          "disable multi job optimization" },
         { NULL }
 };
 
@@ -480,9 +482,6 @@ lima_screen_parse_env(void)
 {
    lima_debug = debug_get_option_lima_debug();
 
-   if (lima_debug & LIMA_DEBUG_DUMP)
-      lima_dump_file_open();
-
    lima_ctx_num_plb = debug_get_num_option("LIMA_CTX_NUM_PLB", LIMA_CTX_PLB_DEF_NUM);
    if (lima_ctx_num_plb > LIMA_CTX_PLB_MAX_NUM ||
        lima_ctx_num_plb < LIMA_CTX_PLB_MIN_NUM) {
@@ -505,11 +504,19 @@ lima_screen_parse_env(void)
               "reset to default 0\n", lima_ppir_force_spilling);
       lima_ppir_force_spilling = 0;
    }
+
+   lima_plb_pp_stream_cache_size = debug_get_num_option("LIMA_PLB_PP_STREAM_CACHE_SIZE", 0);
+   if (lima_plb_pp_stream_cache_size < 0) {
+      fprintf(stderr, "lima: LIMA_PLB_PP_STREAM_CACHE_SIZE %d less than 0, "
+              "reset to default 0\n", lima_plb_pp_stream_cache_size);
+      lima_plb_pp_stream_cache_size = 0;
+   }
 }
 
 struct pipe_screen *
 lima_screen_create(int fd, struct renderonly *ro)
 {
+   uint64_t system_memory;
    struct lima_screen *screen;
 
    screen = rzalloc(NULL, struct lima_screen);
@@ -520,6 +527,15 @@ lima_screen_create(int fd, struct renderonly *ro)
 
    lima_screen_parse_env();
 
+   /* Limit PP PLB stream cache size to 0.1% of system memory */
+   if (!lima_plb_pp_stream_cache_size &&
+       os_get_total_physical_memory(&system_memory))
+      lima_plb_pp_stream_cache_size = system_memory >> 10;
+
+   /* Set lower limit on PP PLB cache size */
+   lima_plb_pp_stream_cache_size = MAX2(128 * 1024 * lima_ctx_num_plb,
+                                        lima_plb_pp_stream_cache_size);
+
    if (!lima_screen_query_info(screen))
       goto err_out0;