panfrost: Remove flush_frontbuffer
[mesa.git] / src / gallium / drivers / panfrost / pan_screen.c
index 9e98cf3375c9b569ba670fa7f918a566b7bdbb18..0ad0c2bf63892b26c48e71596117e4c59285971e 100644 (file)
@@ -28,8 +28,8 @@
 
 #include "util/u_debug.h"
 #include "util/u_memory.h"
-#include "util/u_format.h"
-#include "util/u_format_s3tc.h"
+#include "util/format/u_format.h"
+#include "util/format/u_format_s3tc.h"
 #include "util/u_video.h"
 #include "util/u_screen.h"
 #include "util/os_time.h"
 
 #include "pan_context.h"
 #include "midgard/midgard_compile.h"
+#include "panfrost-quirks.h"
 
 static const struct debug_named_value debug_options[] = {
         {"msgs",      PAN_DBG_MSGS,    "Print debug messages"},
         {"trace",     PAN_DBG_TRACE,    "Trace the command stream"},
         {"deqp",      PAN_DBG_DEQP,     "Hacks for dEQP"},
         {"afbc",      PAN_DBG_AFBC,     "Enable non-conformant AFBC impl"},
+        {"sync",      PAN_DBG_SYNC,     "Wait for each job's completion and check for any GPU fault"},
+        {"precompile", PAN_DBG_PRECOMPILE, "Precompile shaders for shader-db"},
         DEBUG_NAMED_VALUE_END
 };
 
@@ -68,13 +71,13 @@ int pan_debug = 0;
 static const char *
 panfrost_get_name(struct pipe_screen *screen)
 {
-        return "panfrost";
+        return panfrost_model_name(pan_screen(screen)->gpu_id);
 }
 
 static const char *
 panfrost_get_vendor(struct pipe_screen *screen)
 {
-        return "panfrost";
+        return "Panfrost";
 }
 
 static const char *
@@ -116,9 +119,13 @@ panfrost_get_param(struct pipe_screen *screen, enum pipe_cap param)
         case PIPE_CAP_TEXTURE_SWIZZLE:
                 return 1;
 
+        case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
+        case PIPE_CAP_TEXTURE_MIRROR_CLAMP_TO_EDGE:
+                return 1;
+
         case PIPE_CAP_TGSI_INSTANCEID:
         case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR:
-                return is_deqp ? 1 : 0;
+                return 1;
 
         case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS:
                 return is_deqp ? 4 : 0;
@@ -129,7 +136,7 @@ panfrost_get_param(struct pipe_screen *screen, enum pipe_cap param)
                 return 1;
 
         case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS:
-                return is_deqp ? 256 : 0; /* for GL3 */
+                return 256;
 
         case PIPE_CAP_GLSL_FEATURE_LEVEL:
         case PIPE_CAP_GLSL_FEATURE_LEVEL_COMPATIBILITY:
@@ -138,7 +145,7 @@ panfrost_get_param(struct pipe_screen *screen, enum pipe_cap param)
                 return is_deqp ? 300 : 120;
 
         case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
-                return is_deqp ? 16 : 0;
+                return 16;
 
         case PIPE_CAP_CUBE_MAP_ARRAY:
                 return is_deqp;
@@ -238,6 +245,9 @@ panfrost_get_param(struct pipe_screen *screen, enum pipe_cap param)
                 return (int)(system_memory >> 20);
         }
 
+        case PIPE_CAP_SHADER_STENCIL_EXPORT:
+                return 1;
+
         case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT:
                 return 4;
 
@@ -245,6 +255,9 @@ panfrost_get_param(struct pipe_screen *screen, enum pipe_cap param)
                 return 16;
 
         case PIPE_CAP_ALPHA_TEST:
+        case PIPE_CAP_FLATSHADE:
+        case PIPE_CAP_TWO_SIDED_COLOR:
+        case PIPE_CAP_CLIP_PLANES:
                 return 0;
 
         default:
@@ -279,7 +292,7 @@ panfrost_get_shader_param(struct pipe_screen *screen,
                 return 16;
 
         case PIPE_SHADER_CAP_MAX_OUTPUTS:
-                return shader == PIPE_SHADER_FRAGMENT ? 4 : 8;
+                return shader == PIPE_SHADER_FRAGMENT ? 4 : 16;
 
         case PIPE_SHADER_CAP_MAX_TEMPS:
                 return 256; /* GL_MAX_PROGRAM_TEMPORARIES_ARB */
@@ -347,7 +360,7 @@ panfrost_get_shader_param(struct pipe_screen *screen,
                 return 0;
 
         default:
-                fprintf(stderr, "unknown shader param %d\n", param);
+                DBG("unknown shader param %d\n", param);
                 return 0;
         }
 
@@ -417,7 +430,16 @@ panfrost_is_format_supported( struct pipe_screen *screen,
         if (!format_desc)
                 return false;
 
-        if (sample_count > 1)
+        /* MSAA 4x supported, but no more. Technically some revisions of the
+         * hardware can go up to 16x but we don't support higher modes yet. */
+
+        if (sample_count > 1 && !(pan_debug & PAN_DBG_DEQP))
+                return false;
+
+        if (sample_count > 4)
+                return false;
+
+        if (MAX2(sample_count, 1) != MAX2(storage_sample_count, 1))
                 return false;
 
         /* Format wishlist */
@@ -440,10 +462,15 @@ panfrost_is_format_supported( struct pipe_screen *screen,
         if (scanout && renderable && !util_format_is_rgba8_variant(format_desc))
                 return false;
 
-        if (format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN &&
-            format_desc->layout != UTIL_FORMAT_LAYOUT_OTHER) {
-                /* Compressed formats not yet hooked up. */
-                return false;
+        switch (format_desc->layout) {
+                case UTIL_FORMAT_LAYOUT_PLAIN:
+                case UTIL_FORMAT_LAYOUT_OTHER:
+                        break;
+                case UTIL_FORMAT_LAYOUT_ETC:
+                case UTIL_FORMAT_LAYOUT_ASTC:
+                        return true;
+                default:
+                        return false;
         }
 
         /* Internally, formats that are depth/stencil renderable are limited.
@@ -490,8 +517,7 @@ panfrost_get_compute_param(struct pipe_screen *pscreen, enum pipe_shader_ir ir_t
 
        switch (param) {
        case PIPE_COMPUTE_CAP_ADDRESS_BITS:
-                /* TODO: We'll want 64-bit pointers soon */
-               RET((uint32_t []){ 32 });
+               RET((uint32_t []){ 64 });
 
        case PIPE_COMPUTE_CAP_IR_TARGET:
                if (ret)
@@ -553,16 +579,6 @@ panfrost_destroy_screen(struct pipe_screen *pscreen)
         ralloc_free(screen);
 }
 
-static void
-panfrost_flush_frontbuffer(struct pipe_screen *_screen,
-                           struct pipe_resource *resource,
-                           unsigned level, unsigned layer,
-                           void *context_private,
-                           struct pipe_box *sub_box)
-{
-        /* TODO: Display target integration */
-}
-
 static uint64_t
 panfrost_get_timestamp(struct pipe_screen *_screen)
 {
@@ -669,19 +685,6 @@ panfrost_screen_get_compiler_options(struct pipe_screen *pscreen,
         return &midgard_nir_options;
 }
 
-static unsigned
-panfrost_query_gpu_version(struct panfrost_screen *screen)
-{
-        struct drm_panfrost_get_param get_param = {0,};
-        ASSERTED int ret;
-
-        get_param.param = DRM_PANFROST_PARAM_GPU_PROD_ID;
-        ret = drmIoctl(screen->fd, DRM_IOCTL_PANFROST_GET_PARAM, &get_param);
-        assert(!ret);
-
-        return get_param.value;
-}
-
 static uint32_t
 panfrost_active_bos_hash(const void *key)
 {
@@ -724,7 +727,7 @@ panfrost_create_screen(int fd, struct renderonly *ro)
         if (ro) {
                 screen->ro = renderonly_dup(ro);
                 if (!screen->ro) {
-                        fprintf(stderr, "Failed to dup renderonly object\n");
+                        DBG("Failed to dup renderonly object\n");
                         free(screen);
                         return NULL;
                 }
@@ -732,21 +735,23 @@ panfrost_create_screen(int fd, struct renderonly *ro)
 
         screen->fd = fd;
 
-        screen->gpu_id = panfrost_query_gpu_version(screen);
-        screen->require_sfbd = screen->gpu_id < 0x0750; /* T760 is the first to support MFBD */
+        screen->gpu_id = panfrost_query_gpu_version(screen->fd);
+        screen->core_count = panfrost_query_core_count(screen->fd);
+        screen->thread_tls_alloc = panfrost_query_thread_tls_alloc(screen->fd);
+        screen->quirks = panfrost_get_quirks(screen->gpu_id);
         screen->kernel_version = drmGetVersion(fd);
 
         /* Check if we're loading against a supported GPU model. */
 
         switch (screen->gpu_id) {
+        case 0x720: /* T720 */
         case 0x750: /* T760 */
         case 0x820: /* T820 */
         case 0x860: /* T860 */
                 break;
         default:
                 /* Fail to load against untested models */
-                debug_printf("panfrost: Unsupported model %X",
-                             screen->gpu_id);
+                debug_printf("panfrost: Unsupported model %X", screen->gpu_id);
                 return NULL;
         }
 
@@ -755,11 +760,12 @@ panfrost_create_screen(int fd, struct renderonly *ro)
                                               panfrost_active_bos_cmp);
 
         pthread_mutex_init(&screen->bo_cache.lock, NULL);
+        list_inithead(&screen->bo_cache.lru);
         for (unsigned i = 0; i < ARRAY_SIZE(screen->bo_cache.buckets); ++i)
                 list_inithead(&screen->bo_cache.buckets[i]);
 
-        if (pan_debug & PAN_DBG_TRACE)
-                pandecode_initialize();
+        if (pan_debug & (PAN_DBG_TRACE | PAN_DBG_SYNC))
+                pandecode_initialize(!(pan_debug & PAN_DBG_TRACE));
 
         screen->base.destroy = panfrost_destroy_screen;
 
@@ -773,7 +779,6 @@ panfrost_create_screen(int fd, struct renderonly *ro)
         screen->base.get_timestamp = panfrost_get_timestamp;
         screen->base.is_format_supported = panfrost_is_format_supported;
         screen->base.context_create = panfrost_create_context;
-        screen->base.flush_frontbuffer = panfrost_flush_frontbuffer;
         screen->base.get_compiler_options = panfrost_screen_get_compiler_options;
         screen->base.fence_reference = panfrost_fence_reference;
         screen->base.fence_finish = panfrost_fence_finish;