zink: slightly rework memoryTypeIndex selection to pre-determine heap
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Thu, 13 Apr 2023 17:50:12 +0000 (13:50 -0400)
committerMarge Bot <emma+marge@anholt.net>
Sun, 16 Apr 2023 23:55:30 +0000 (23:55 +0000)
should be no functional changes

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22479>

src/gallium/drivers/zink/zink_resource.c

index 5922922..253b4a3 100644 (file)
@@ -1066,8 +1066,7 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t
       alignment = MAX2(alignment, screen->info.props.limits.minMemoryMapAlignment);
    obj->alignment = alignment;
 
-   mai.memoryTypeIndex = zink_mem_type_idx_from_bits(screen, heap, reqs.memoryTypeBits);
-   if (mai.memoryTypeIndex == UINT32_MAX) {
+   if (zink_mem_type_idx_from_bits(screen, heap, reqs.memoryTypeBits) == UINT32_MAX) {
       /* not valid based on reqs; demote to more compatible type */
       switch (heap) {
       case ZINK_HEAP_DEVICE_LOCAL_VISIBLE:
@@ -1079,9 +1078,9 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t
       default:
          break;
       }
-      mai.memoryTypeIndex = zink_mem_type_idx_from_bits(screen, heap, reqs.memoryTypeBits);
-      assert(mai.memoryTypeIndex != UINT32_MAX);
+      assert(zink_mem_type_idx_from_bits(screen, heap, reqs.memoryTypeBits) != UINT32_MAX);
    }
+   mai.memoryTypeIndex = zink_mem_type_idx_from_bits(screen, heap, reqs.memoryTypeBits);
    assert(reqs.memoryTypeBits & BITFIELD_BIT(mai.memoryTypeIndex));
 
 retry: