2023-08-12 20:10:16 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "gskgpuimageprivate.h"
|
|
|
|
#include "gskvulkandeviceprivate.h"
|
|
|
|
|
2023-10-19 11:36:15 +00:00
|
|
|
#include "gdk/gdkdmabufprivate.h"
|
|
|
|
|
2023-08-12 20:10:16 +00:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
#define GSK_TYPE_VULKAN_IMAGE (gsk_vulkan_image_get_type ())
|
|
|
|
|
|
|
|
G_DECLARE_FINAL_TYPE (GskVulkanImage, gsk_vulkan_image, GSK, VULKAN_IMAGE, GskGpuImage)
|
|
|
|
|
|
|
|
GskGpuImage * gsk_vulkan_image_new_for_swapchain (GskVulkanDevice *device,
|
|
|
|
VkImage image,
|
|
|
|
VkFormat format,
|
|
|
|
gsize width,
|
|
|
|
gsize height);
|
|
|
|
|
|
|
|
GskGpuImage * gsk_vulkan_image_new_for_atlas (GskVulkanDevice *device,
|
|
|
|
gsize width,
|
|
|
|
gsize height);
|
|
|
|
GskGpuImage * gsk_vulkan_image_new_for_offscreen (GskVulkanDevice *device,
|
2023-11-01 05:43:15 +00:00
|
|
|
gboolean with_mipmap,
|
2023-08-12 20:10:16 +00:00
|
|
|
GdkMemoryFormat preferred_format,
|
|
|
|
gsize width,
|
|
|
|
gsize height);
|
|
|
|
GskGpuImage * gsk_vulkan_image_new_for_upload (GskVulkanDevice *device,
|
2023-11-01 05:43:15 +00:00
|
|
|
gboolean with_mipmap,
|
2023-08-12 20:10:16 +00:00
|
|
|
GdkMemoryFormat format,
|
|
|
|
gsize width,
|
|
|
|
gsize height);
|
2023-10-19 11:36:15 +00:00
|
|
|
#ifdef HAVE_DMABUF
|
|
|
|
GskGpuImage * gsk_vulkan_image_new_for_dmabuf (GskVulkanDevice *device,
|
|
|
|
GdkTexture *texture);
|
|
|
|
#endif
|
|
|
|
|
2023-08-12 20:10:16 +00:00
|
|
|
guchar * gsk_vulkan_image_get_data (GskVulkanImage *self,
|
|
|
|
gsize *out_stride);
|
|
|
|
|
2023-10-19 11:30:12 +00:00
|
|
|
VkSampler gsk_vulkan_image_get_vk_sampler (GskVulkanImage *self);
|
2023-08-12 20:10:16 +00:00
|
|
|
VkPipelineStageFlags gsk_vulkan_image_get_vk_pipeline_stage (GskVulkanImage *self);
|
|
|
|
VkImageLayout gsk_vulkan_image_get_vk_image_layout (GskVulkanImage *self);
|
|
|
|
VkAccessFlags gsk_vulkan_image_get_vk_access (GskVulkanImage *self);
|
|
|
|
void gsk_vulkan_image_set_vk_image_layout (GskVulkanImage *self,
|
|
|
|
VkPipelineStageFlags stage,
|
|
|
|
VkImageLayout image_layout,
|
|
|
|
VkAccessFlags access);
|
|
|
|
void gsk_vulkan_image_transition (GskVulkanImage *self,
|
|
|
|
VkCommandBuffer command_buffer,
|
|
|
|
VkPipelineStageFlags stage,
|
|
|
|
VkImageLayout image_layout,
|
|
|
|
VkAccessFlags access);
|
|
|
|
#define gdk_vulkan_image_transition_shader(image) \
|
|
|
|
gsk_vulkan_image_transition ((image), VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, \
|
|
|
|
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_ACCESS_SHADER_READ_BIT)
|
|
|
|
|
|
|
|
VkImage gsk_vulkan_image_get_vk_image (GskVulkanImage *self);
|
2023-08-21 00:18:37 +00:00
|
|
|
VkImageView gsk_vulkan_image_get_vk_image_view (GskVulkanImage *self);
|
2023-08-12 20:10:16 +00:00
|
|
|
VkFormat gsk_vulkan_image_get_vk_format (GskVulkanImage *self);
|
2023-08-21 00:18:37 +00:00
|
|
|
VkFramebuffer gsk_vulkan_image_get_vk_framebuffer (GskVulkanImage *self,
|
2023-08-12 20:10:16 +00:00
|
|
|
VkRenderPass pass);
|
|
|
|
|
2023-11-01 05:43:15 +00:00
|
|
|
static inline guint
|
|
|
|
gsk_vulkan_mipmap_levels (gsize width,
|
|
|
|
gsize height)
|
|
|
|
{
|
|
|
|
return g_bit_nth_msf (MAX (width, height) - 1, -1) + 1;
|
|
|
|
}
|
|
|
|
|
2023-08-12 20:10:16 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|