panvk: Make panvk_image derive from vk_image

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15382>
This commit is contained in:
Jason Ekstrand 2022-03-11 14:01:15 -06:00 committed by Marge Bot
parent 5dbbc0f0a8
commit 1865b7a93e
3 changed files with 14 additions and 56 deletions

View file

@ -71,48 +71,19 @@ panvk_image_create(VkDevice _device,
VK_FROM_HANDLE(panvk_device, device, _device);
const struct panfrost_device *pdev = &device->physical_device->pdev;
struct panvk_image *image = NULL;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO);
assert(pCreateInfo->mipLevels > 0);
assert(pCreateInfo->arrayLayers > 0);
assert(pCreateInfo->samples > 0);
assert(pCreateInfo->extent.width > 0);
assert(pCreateInfo->extent.height > 0);
assert(pCreateInfo->extent.depth > 0);
image = vk_object_zalloc(&device->vk, alloc, sizeof(*image),
VK_OBJECT_TYPE_IMAGE);
image = vk_image_create(&device->vk, pCreateInfo, alloc, sizeof(*image));
if (!image)
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
image->type = pCreateInfo->imageType;
image->vk_format = pCreateInfo->format;
image->tiling = pCreateInfo->tiling;
image->usage = pCreateInfo->usage;
image->flags = pCreateInfo->flags;
image->extent = pCreateInfo->extent;
pan_image_layout_init(pdev, &image->pimage.layout, modifier,
vk_format_to_pipe_format(pCreateInfo->format),
panvk_image_type_to_mali_tex_dim(pCreateInfo->imageType),
pCreateInfo->extent.width, pCreateInfo->extent.height,
pCreateInfo->extent.depth, pCreateInfo->arrayLayers,
pCreateInfo->samples, pCreateInfo->mipLevels,
vk_format_to_pipe_format(image->vk.format),
panvk_image_type_to_mali_tex_dim(image->vk.image_type),
image->vk.extent.width, image->vk.extent.height,
image->vk.extent.depth, image->vk.array_layers,
image->vk.samples, image->vk.mip_levels,
PAN_IMAGE_CRC_NONE, NULL);
image->exclusive = pCreateInfo->sharingMode == VK_SHARING_MODE_EXCLUSIVE;
if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
for (uint32_t i = 0; i < pCreateInfo->queueFamilyIndexCount; ++i) {
if (pCreateInfo->pQueueFamilyIndices[i] == VK_QUEUE_FAMILY_EXTERNAL)
image->queue_family_mask |= (1u << PANVK_MAX_QUEUE_FAMILIES) - 1u;
else
image->queue_family_mask |= 1u << pCreateInfo->pQueueFamilyIndices[i];
}
}
if (vk_find_struct_const(pCreateInfo->pNext, EXTERNAL_MEMORY_IMAGE_CREATE_INFO))
image->shareable = true;
*pImage = panvk_image_to_handle(image);
return VK_SUCCESS;
}
@ -234,7 +205,7 @@ panvk_DestroyImage(VkDevice _device,
if (!image)
return;
vk_object_free(&device->vk, pAllocator, image);
vk_image_destroy(&device->vk, pAllocator, &image->vk);
}
static unsigned
@ -260,7 +231,7 @@ panvk_GetImageSubresourceLayout(VkDevice _device,
{
VK_FROM_HANDLE(panvk_image, image, _image);
unsigned plane = panvk_plane_index(image->vk_format, pSubresource->aspectMask);
unsigned plane = panvk_plane_index(image->vk.format, pSubresource->aspectMask);
assert(plane < PANVK_MAX_PLANES);
const struct pan_image_slice_layout *slice_layout =

View file

@ -52,6 +52,7 @@
#include "vk_command_buffer.h"
#include "vk_command_pool.h"
#include "vk_device.h"
#include "vk_image.h"
#include "vk_instance.h"
#include "vk_log.h"
#include "vk_object.h"
@ -933,23 +934,9 @@ struct panvk_plane_memory {
#define PANVK_MAX_PLANES 1
struct panvk_image {
struct vk_object_base base;
struct vk_image vk;
struct pan_image pimage;
VkImageType type;
/* The original VkFormat provided by the client. This may not match any
* of the actual surface formats.
*/
VkFormat vk_format;
VkImageAspectFlags aspects;
VkImageUsageFlags usage; /**< Superset of VkImageCreateInfo::usage. */
VkImageTiling tiling; /** VkImageCreateInfo::tiling */
VkImageCreateFlags flags; /** VkImageCreateInfo::flags */
VkExtent3D extent;
unsigned queue_family_mask;
bool exclusive;
bool shareable;
};
unsigned
@ -1075,7 +1062,7 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_device_memory, base, VkDeviceMemory, VK_OBJ
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_fence, base, VkFence, VK_OBJECT_TYPE_FENCE)
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_event, base, VkEvent, VK_OBJECT_TYPE_EVENT)
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_framebuffer, base, VkFramebuffer, VK_OBJECT_TYPE_FRAMEBUFFER)
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_image, base, VkImage, VK_OBJECT_TYPE_IMAGE)
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_image, vk.base, VkImage, VK_OBJECT_TYPE_IMAGE)
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_image_view, base, VkImageView, VK_OBJECT_TYPE_IMAGE_VIEW);
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_pipeline_cache, base, VkPipelineCache, VK_OBJECT_TYPE_PIPELINE_CACHE)
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_pipeline, base, VkPipeline, VK_OBJECT_TYPE_PIPELINE)

View file

@ -133,7 +133,7 @@ panvk_per_arch(CreateImageView)(VkDevice _device,
struct panfrost_device *pdev = &device->physical_device->pdev;
if (image->usage &
if (image->vk.usage &
(VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT)) {
unsigned bo_size =
GENX(panfrost_estimate_texture_payload_size)(&view->pview) +
@ -154,7 +154,7 @@ panvk_per_arch(CreateImageView)(VkDevice _device,
GENX(panfrost_new_texture)(pdev, &view->pview, tex_desc, &surf_descs);
}
if (image->usage & VK_IMAGE_USAGE_STORAGE_BIT) {
if (image->vk.usage & VK_IMAGE_USAGE_STORAGE_BIT) {
uint8_t *attrib_buf = (uint8_t *)view->descs.img_attrib_buf;
bool is_3d = image->pimage.layout.dim == MALI_TEXTURE_DIMENSION_3D;
unsigned offset = image->pimage.data.offset;