freedreno: Remove the "active" member of queries.
[mesa.git] / src / gallium / drivers / freedreno / freedreno_resource.c
index 748664384eb98c84f644bc4a5455490cff3e54e7..56f5c478b275edfc43c9c73b29f690bf1a7ee7a2 100644 (file)
@@ -977,6 +977,8 @@ fd_resource_create_with_modifiers(struct pipe_screen *pscreen,
 
        rsc->internal_format = format;
 
+       rsc->layout.ubwc = rsc->layout.tile_mode && is_a6xx(screen) && allow_ubwc;
+
        if (prsc->target == PIPE_BUFFER) {
                assert(prsc->format == PIPE_FORMAT_R8_UNORM);
                size = prsc->width0;
@@ -985,9 +987,6 @@ fd_resource_create_with_modifiers(struct pipe_screen *pscreen,
                size = screen->setup_slices(rsc);
        }
 
-       if (allow_ubwc && screen->fill_ubwc_buffer_sizes && rsc->layout.tile_mode)
-               size += screen->fill_ubwc_buffer_sizes(rsc);
-
        /* special case for hw-query buffer, which we need to allocate before we
         * know the size:
         */
@@ -1024,26 +1023,6 @@ fd_resource_create(struct pipe_screen *pscreen,
        return fd_resource_create_with_modifiers(pscreen, tmpl, &mod, 1);
 }
 
-static bool
-is_supported_modifier(struct pipe_screen *pscreen, enum pipe_format pfmt,
-               uint64_t mod)
-{
-       int count;
-
-       /* Get the count of supported modifiers: */
-       pscreen->query_dmabuf_modifiers(pscreen, pfmt, 0, NULL, NULL, &count);
-
-       /* Get the supported modifiers: */
-       uint64_t modifiers[count];
-       pscreen->query_dmabuf_modifiers(pscreen, pfmt, count, modifiers, NULL, &count);
-
-       for (int i = 0; i < count; i++)
-               if (modifiers[i] == mod)
-                       return true;
-
-       return false;
-}
-
 /**
  * Create a texture from a winsys_handle. The handle is often created in
  * another process by first creating a pipe texture and then calling
@@ -1092,21 +1071,11 @@ fd_resource_from_handle(struct pipe_screen *pscreen,
                        (slice->pitch & (pitchalign - 1)))
                goto fail;
 
-       if (handle->modifier == DRM_FORMAT_MOD_QCOM_COMPRESSED) {
-               if (!is_supported_modifier(pscreen, tmpl->format,
-                               DRM_FORMAT_MOD_QCOM_COMPRESSED)) {
-                       DBG("bad modifier: %"PRIx64, handle->modifier);
-                       goto fail;
-               }
-               debug_assert(screen->fill_ubwc_buffer_sizes);
-               screen->fill_ubwc_buffer_sizes(rsc);
-       } else if (handle->modifier &&
-                       (handle->modifier != DRM_FORMAT_MOD_INVALID)) {
-               goto fail;
-       }
-
        assert(rsc->layout.cpp);
 
+       if (screen->layout_resource_for_modifier(rsc, handle->modifier) < 0)
+               goto fail;
+
        if (screen->ro) {
                rsc->scanout =
                        renderonly_create_gpu_import_for_resource(prsc, screen->ro, NULL);
@@ -1208,6 +1177,21 @@ static const struct u_transfer_vtbl transfer_vtbl = {
                .get_stencil              = fd_resource_get_stencil,
 };
 
+static const uint64_t supported_modifiers[] = {
+       DRM_FORMAT_MOD_LINEAR,
+};
+
+static int
+fd_layout_resource_for_modifier(struct fd_resource *rsc, uint64_t modifier)
+{
+       switch (modifier) {
+       case DRM_FORMAT_MOD_LINEAR:
+               return 0;
+       default:
+               return -1;
+       }
+}
+
 void
 fd_resource_screen_init(struct pipe_screen *pscreen)
 {
@@ -1228,6 +1212,12 @@ fd_resource_screen_init(struct pipe_screen *pscreen)
 
        if (!screen->setup_slices)
                screen->setup_slices = fd_setup_slices;
+       if (!screen->layout_resource_for_modifier)
+               screen->layout_resource_for_modifier = fd_layout_resource_for_modifier;
+       if (!screen->supported_modifiers) {
+               screen->supported_modifiers = supported_modifiers;
+               screen->num_supported_modifiers = ARRAY_SIZE(supported_modifiers);
+       }
 }
 
 static void