diff --git a/src/imagination/vulkan/pvr_blit.c b/src/imagination/vulkan/pvr_blit.c index 131f6db5d8d..11da2e4480c 100644 --- a/src/imagination/vulkan/pvr_blit.c +++ b/src/imagination/vulkan/pvr_blit.c @@ -32,6 +32,7 @@ #include "pvr_csb.h" #include "pvr_device.h" #include "pvr_formats.h" +#include "pvr_image.h" #include "pvr_job_transfer.h" #include "pvr_private.h" #include "pvr_types.h" diff --git a/src/imagination/vulkan/pvr_cmd_buffer.c b/src/imagination/vulkan/pvr_cmd_buffer.c index 3f3d4dd72b3..65873a75039 100644 --- a/src/imagination/vulkan/pvr_cmd_buffer.c +++ b/src/imagination/vulkan/pvr_cmd_buffer.c @@ -41,6 +41,7 @@ #include "pvr_device_info.h" #include "pvr_formats.h" #include "pvr_hw_pass.h" +#include "pvr_image.h" #include "pvr_job_common.h" #include "pvr_job_render.h" #include "pvr_limits.h" diff --git a/src/imagination/vulkan/pvr_descriptor_set.c b/src/imagination/vulkan/pvr_descriptor_set.c index c4d5b06a3ee..9400f90c074 100644 --- a/src/imagination/vulkan/pvr_descriptor_set.c +++ b/src/imagination/vulkan/pvr_descriptor_set.c @@ -32,6 +32,7 @@ #include "pvr_bo.h" #include "pvr_debug.h" #include "pvr_device.h" +#include "pvr_image.h" #include "pvr_private.h" #include "pvr_types.h" #include "util/compiler.h" diff --git a/src/imagination/vulkan/pvr_device.c b/src/imagination/vulkan/pvr_device.c index 0a9a690d963..2070d6e438e 100644 --- a/src/imagination/vulkan/pvr_device.c +++ b/src/imagination/vulkan/pvr_device.c @@ -55,6 +55,7 @@ #include "pvr_debug.h" #include "pvr_device_info.h" #include "pvr_dump_info.h" +#include "pvr_image.h" #include "pvr_job_render.h" #include "pvr_limits.h" #include "pvr_pds.h" diff --git a/src/imagination/vulkan/pvr_image.c b/src/imagination/vulkan/pvr_image.c index 30f16741d90..10885fd9aeb 100644 --- a/src/imagination/vulkan/pvr_image.c +++ b/src/imagination/vulkan/pvr_image.c @@ -21,6 +21,8 @@ * SOFTWARE. */ +#include "pvr_image.h" + #include #include #include diff --git a/src/imagination/vulkan/pvr_image.h b/src/imagination/vulkan/pvr_image.h new file mode 100644 index 00000000000..d9ea48f5d51 --- /dev/null +++ b/src/imagination/vulkan/pvr_image.h @@ -0,0 +1,93 @@ +/* + * Copyright © 2022 Imagination Technologies Ltd. + * + * based in part on anv driver which is: + * Copyright © 2015 Intel Corporation + * + * based in part on radv driver which is: + * Copyright © 2016 Red Hat. + * Copyright © 2016 Bas Nieuwenhuizen + * + * SPDX-License-Identifier: MIT + */ + +#ifndef PVR_IMAGE_H +#define PVR_IMAGE_H + +#include + +#include "vk_image.h" + +#include "pvr_common.h" +#include "pvr_types.h" + +struct pvr_mip_level { + /* Offset of the mip level in bytes */ + uint32_t offset; + + /* Aligned mip level size in bytes */ + uint32_t size; + + /* Aligned row length in bytes */ + uint32_t pitch; + + /* Aligned height in bytes */ + uint32_t height_pitch; +}; + +struct pvr_image { + struct vk_image vk; + + /* vma this image is bound to */ + struct pvr_winsys_vma *vma; + + /* Device address the image is mapped to in device virtual address space */ + pvr_dev_addr_t dev_addr; + + /* Derived and other state */ + VkExtent3D physical_extent; + enum pvr_memlayout memlayout; + VkDeviceSize layer_size; + VkDeviceSize size; + + VkDeviceSize alignment; + + struct pvr_mip_level mip_levels[14]; +}; + +struct pvr_image_view { + struct vk_image_view vk; + + /* Prepacked Texture Image dword 0 and 1. It will be copied to the + * descriptor info during pvr_UpdateDescriptorSets(). + * + * We create separate texture states for sampling, storage and input + * attachment cases. + */ + struct pvr_image_descriptor image_state[PVR_TEXTURE_STATE_MAX_ENUM]; +}; + +VK_DEFINE_NONDISP_HANDLE_CASTS(pvr_image, vk.base, VkImage, VK_OBJECT_TYPE_IMAGE) + +VK_DEFINE_NONDISP_HANDLE_CASTS(pvr_image_view, + vk.base, + VkImageView, + VK_OBJECT_TYPE_IMAGE_VIEW) + +static inline const struct pvr_image * +vk_to_pvr_image(const struct vk_image *image) +{ + return container_of(image, const struct pvr_image, vk); +} + +static inline const struct pvr_image * +pvr_image_view_get_image(const struct pvr_image_view *const iview) +{ + return vk_to_pvr_image(iview->vk.image); +} + +void pvr_get_image_subresource_layout(const struct pvr_image *image, + const VkImageSubresource *subresource, + VkSubresourceLayout *layout); + +#endif /* PVR_IMAGE_H */ diff --git a/src/imagination/vulkan/pvr_private.h b/src/imagination/vulkan/pvr_private.h index 8a71b29614b..f6291d97117 100644 --- a/src/imagination/vulkan/pvr_private.h +++ b/src/imagination/vulkan/pvr_private.h @@ -66,7 +66,6 @@ #include "vk_command_buffer.h" #include "vk_enum_to_str.h" #include "vk_graphics_state.h" -#include "vk_image.h" #include "vk_log.h" #include "vk_sync.h" #include "wsi_common.h" @@ -91,40 +90,6 @@ struct pvr_vertex_binding { VkDeviceSize size; }; -struct pvr_mip_level { - /* Offset of the mip level in bytes */ - uint32_t offset; - - /* Aligned mip level size in bytes */ - uint32_t size; - - /* Aligned row length in bytes */ - uint32_t pitch; - - /* Aligned height in bytes */ - uint32_t height_pitch; -}; - -struct pvr_image { - struct vk_image vk; - - /* vma this image is bound to */ - struct pvr_winsys_vma *vma; - - /* Device address the image is mapped to in device virtual address space */ - pvr_dev_addr_t dev_addr; - - /* Derived and other state */ - VkExtent3D physical_extent; - enum pvr_memlayout memlayout; - VkDeviceSize layer_size; - VkDeviceSize size; - - VkDeviceSize alignment; - - struct pvr_mip_level mip_levels[14]; -}; - struct pvr_buffer { struct vk_buffer vk; @@ -136,18 +101,6 @@ struct pvr_buffer { pvr_dev_addr_t dev_addr; }; -struct pvr_image_view { - struct vk_image_view vk; - - /* Prepacked Texture Image dword 0 and 1. It will be copied to the - * descriptor info during pvr_UpdateDescriptorSets(). - * - * We create separate texture states for sampling, storage and input - * attachment cases. - */ - struct pvr_image_descriptor image_state[PVR_TEXTURE_STATE_MAX_ENUM]; -}; - #define PVR_BUFFER_VIEW_WIDTH 8192U struct pvr_buffer_view { @@ -1030,10 +983,6 @@ void pvr_calculate_vertex_cam_size(const struct pvr_device_info *dev_info, uint32_t *const cam_size_out, uint32_t *const vs_max_instances_out); -void pvr_get_image_subresource_layout(const struct pvr_image *image, - const VkImageSubresource *subresource, - VkSubresourceLayout *layout); - static inline struct pvr_compute_pipeline * to_pvr_compute_pipeline(struct pvr_pipeline *pipeline) { @@ -1054,18 +1003,6 @@ vk_to_pvr_descriptor_set_layout(struct vk_descriptor_set_layout *layout) return container_of(layout, struct pvr_descriptor_set_layout, vk); } -static inline const struct pvr_image * -vk_to_pvr_image(const struct vk_image *image) -{ - return container_of(image, const struct pvr_image, vk); -} - -static inline const struct pvr_image * -pvr_image_view_get_image(const struct pvr_image_view *const iview) -{ - return vk_to_pvr_image(iview->vk.image); -} - static enum pvr_pipeline_stage_bits pvr_stage_mask(VkPipelineStageFlags2 stage_mask) { @@ -1222,15 +1159,10 @@ VK_DEFINE_HANDLE_CASTS(pvr_cmd_buffer, VkCommandBuffer, VK_OBJECT_TYPE_COMMAND_BUFFER) -VK_DEFINE_NONDISP_HANDLE_CASTS(pvr_image, vk.base, VkImage, VK_OBJECT_TYPE_IMAGE) VK_DEFINE_NONDISP_HANDLE_CASTS(pvr_buffer, vk.base, VkBuffer, VK_OBJECT_TYPE_BUFFER) -VK_DEFINE_NONDISP_HANDLE_CASTS(pvr_image_view, - vk.base, - VkImageView, - VK_OBJECT_TYPE_IMAGE_VIEW) VK_DEFINE_NONDISP_HANDLE_CASTS(pvr_buffer_view, vk.base, VkBufferView,