radv/winsys: start adding support for DMA/compute queue
[mesa.git] / src / amd / vulkan / radv_image.c
index 0dc364cc3960c43c91e7ac62afc4f60ce2446424..c6318f28826dfac47b18da535e9565d18d5ea4df 100644 (file)
@@ -267,17 +267,7 @@ si_make_texture_descriptor(struct radv_device *device,
 
        if (desc->colorspace == VK_FORMAT_COLORSPACE_ZS) {
                const unsigned char swizzle_xxxx[4] = {0, 0, 0, 0};
-               const unsigned char swizzle_yyyy[4] = {1, 1, 1, 1};
-
-               switch (vk_format) {
-               case VK_FORMAT_X8_D24_UNORM_PACK32:
-               case VK_FORMAT_D24_UNORM_S8_UINT:
-               case VK_FORMAT_D32_SFLOAT_S8_UINT:
-                       vk_format_compose_swizzles(mapping, swizzle_yyyy, swizzle);
-                       break;
-               default:
-                       vk_format_compose_swizzles(mapping, swizzle_xxxx, swizzle);
-               }
+               vk_format_compose_swizzles(mapping, swizzle_xxxx, swizzle);
        } else {
                vk_format_compose_swizzles(mapping, desc->swizzle, swizzle);
        }
@@ -562,10 +552,6 @@ radv_image_get_cmask_info(struct radv_device *device,
        /* Each element of CMASK is a nibble. */
        unsigned slice_bytes = slice_elements / 2;
 
-       out->pitch = width;
-       out->height = height;
-       out->xalign = cl_width * 8;
-       out->yalign = cl_height * 8;
        out->slice_tile_max = (width * height) / (128*128);
        if (out->slice_tile_max)
                out->slice_tile_max -= 1;
@@ -698,7 +684,7 @@ radv_image_create(VkDevice _device,
        radv_assert(pCreateInfo->extent.height > 0);
        radv_assert(pCreateInfo->extent.depth > 0);
 
-       image = radv_alloc2(&device->alloc, alloc, sizeof(*image), 8,
+       image = vk_alloc2(&device->alloc, alloc, sizeof(*image), 8,
                            VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
        if (!image)
                return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
@@ -775,8 +761,13 @@ radv_image_view_init(struct radv_image_view *iview,
        iview->vk_format = pCreateInfo->format;
        iview->aspect_mask = pCreateInfo->subresourceRange.aspectMask;
 
-       if (iview->aspect_mask == VK_IMAGE_ASPECT_STENCIL_BIT)
+       if (iview->aspect_mask == VK_IMAGE_ASPECT_STENCIL_BIT) {
                is_stencil = true;
+               iview->vk_format = vk_format_stencil_only(iview->vk_format);
+       } else if (iview->aspect_mask == VK_IMAGE_ASPECT_DEPTH_BIT) {
+               iview->vk_format = vk_format_depth_only(iview->vk_format);
+       }
+
        iview->extent = (VkExtent3D) {
                .width  = radv_minify(image->extent.width , range->baseMipLevel),
                .height = radv_minify(image->extent.height, range->baseMipLevel),
@@ -794,7 +785,7 @@ radv_image_view_init(struct radv_image_view *iview,
 
        si_make_texture_descriptor(device, image, false,
                                   iview->type,
-                                  pCreateInfo->format,
+                                  iview->vk_format,
                                   &pCreateInfo->components,
                                   0, radv_get_levelCount(image, range) - 1,
                                   range->baseArrayLayer,
@@ -836,29 +827,29 @@ void radv_image_set_optimal_micro_tile_mode(struct radv_device *device,
                switch (micro_tile_mode) {
                case 0: /* displayable */
                        switch (image->surface.bpe) {
-                       case 8:
+                       case 1:
                             image->surface.tiling_index[0] = 10;
                             break;
-                       case 16:
+                       case 2:
                             image->surface.tiling_index[0] = 11;
                             break;
-                       default: /* 32, 64 */
+                       default: /* 4, 8 */
                             image->surface.tiling_index[0] = 12;
                             break;
                        }
                        break;
                case 1: /* thin */
                        switch (image->surface.bpe) {
-                       case 8:
+                       case 1:
                                 image->surface.tiling_index[0] = 14;
                                 break;
-                       case 16:
+                       case 2:
                                 image->surface.tiling_index[0] = 15;
                                 break;
-                       case 32:
+                       case 4:
                                 image->surface.tiling_index[0] = 16;
                                 break;
-                       default: /* 64, 128 */
+                       default: /* 8, 16 */
                                 image->surface.tiling_index[0] = 17;
                                 break;
                        }
@@ -923,7 +914,7 @@ radv_DestroyImage(VkDevice _device, VkImage _image,
        if (!_image)
                return;
 
-       radv_free2(&device->alloc, pAllocator, radv_image_from_handle(_image));
+       vk_free2(&device->alloc, pAllocator, radv_image_from_handle(_image));
 }
 
 void radv_GetImageSubresourceLayout(
@@ -955,7 +946,7 @@ radv_CreateImageView(VkDevice _device,
        RADV_FROM_HANDLE(radv_device, device, _device);
        struct radv_image_view *view;
 
-       view = radv_alloc2(&device->alloc, pAllocator, sizeof(*view), 8,
+       view = vk_alloc2(&device->alloc, pAllocator, sizeof(*view), 8,
                           VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
        if (view == NULL)
                return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
@@ -976,7 +967,7 @@ radv_DestroyImageView(VkDevice _device, VkImageView _iview,
 
        if (!iview)
                return;
-       radv_free2(&device->alloc, pAllocator, iview);
+       vk_free2(&device->alloc, pAllocator, iview);
 }
 
 void radv_buffer_view_init(struct radv_buffer_view *view,
@@ -1004,7 +995,7 @@ radv_CreateBufferView(VkDevice _device,
        RADV_FROM_HANDLE(radv_device, device, _device);
        struct radv_buffer_view *view;
 
-       view = radv_alloc2(&device->alloc, pAllocator, sizeof(*view), 8,
+       view = vk_alloc2(&device->alloc, pAllocator, sizeof(*view), 8,
                           VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
        if (!view)
                return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
@@ -1026,5 +1017,5 @@ radv_DestroyBufferView(VkDevice _device, VkBufferView bufferView,
        if (!view)
                return;
 
-       radv_free2(&device->alloc, pAllocator, view);
+       vk_free2(&device->alloc, pAllocator, view);
 }