mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
48e1d48e7f
Instead of using the upload vfunc and going via the code in GskVulkanImage, copy/paste the relevant code into the command() vfunc. This is meant to achieve multiple things: 1. Get rid of GskVulkanUploader and its own command buffer and general non-integration with operations. 2. Get rid of GskVulkanOp:upload() 3. Get the upload/download code machinery for GskVulkanImage and put it with the actual operations. The current code can't do direct upload/download, that will follow in a future commit.
105 lines
6.0 KiB
C
105 lines
6.0 KiB
C
#pragma once
|
|
|
|
#include <gdk/gdk.h>
|
|
|
|
#include "gskvulkanbufferprivate.h"
|
|
#include "gskvulkancommandpoolprivate.h"
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
typedef struct _GskVulkanUploader GskVulkanUploader;
|
|
|
|
#define GSK_TYPE_VULKAN_IMAGE (gsk_vulkan_image_get_type ())
|
|
|
|
G_DECLARE_FINAL_TYPE (GskVulkanImage, gsk_vulkan_image, GSK, VULKAN_IMAGE, GObject)
|
|
|
|
GskVulkanUploader * gsk_vulkan_uploader_new (GdkVulkanContext *context,
|
|
GskVulkanCommandPool *command_pool);
|
|
void gsk_vulkan_uploader_free (GskVulkanUploader *self);
|
|
|
|
void gsk_vulkan_uploader_reset (GskVulkanUploader *self);
|
|
void gsk_vulkan_uploader_upload (GskVulkanUploader *self);
|
|
|
|
GskVulkanImage * gsk_vulkan_image_new_for_swapchain (GdkVulkanContext *context,
|
|
VkImage image,
|
|
VkFormat format,
|
|
gsize width,
|
|
gsize height);
|
|
GskVulkanImage * gsk_vulkan_image_new_from_texture (GskVulkanUploader *uploader,
|
|
GdkTexture *texture);
|
|
|
|
typedef struct {
|
|
guchar *data;
|
|
gsize width;
|
|
gsize height;
|
|
gsize stride;
|
|
gsize x;
|
|
gsize y;
|
|
} GskImageRegion;
|
|
|
|
void gsk_vulkan_image_upload_regions (GskVulkanImage *image,
|
|
GskVulkanUploader *uploader,
|
|
guint num_regions,
|
|
GskImageRegion *regions);
|
|
GskVulkanImage * gsk_vulkan_image_new_for_atlas (GdkVulkanContext *context,
|
|
gsize width,
|
|
gsize height);
|
|
GskVulkanImage * gsk_vulkan_image_new_for_offscreen (GdkVulkanContext *context,
|
|
GdkMemoryFormat preferred_format,
|
|
gsize width,
|
|
gsize height);
|
|
|
|
GdkTexture * gsk_vulkan_image_download (GskVulkanImage *self,
|
|
GskVulkanUploader *uploader);
|
|
|
|
typedef struct _GskVulkanImageMap GskVulkanImageMap;
|
|
|
|
struct _GskVulkanImageMap
|
|
{
|
|
guchar *data;
|
|
gsize stride;
|
|
GskVulkanMapMode mode;
|
|
|
|
/* private */
|
|
GskVulkanBuffer *staging_buffer;
|
|
};
|
|
|
|
GskVulkanImage * gsk_vulkan_image_new_for_upload (GdkVulkanContext *context,
|
|
GdkMemoryFormat format,
|
|
gsize width,
|
|
gsize height);
|
|
void gsk_vulkan_image_map_memory (GskVulkanImage *self,
|
|
GskVulkanUploader *uploader,
|
|
GskVulkanMapMode mode,
|
|
GskVulkanImageMap *map);
|
|
void gsk_vulkan_image_unmap_memory (GskVulkanImage *self,
|
|
GskVulkanUploader *uploader,
|
|
GskVulkanImageMap *map);
|
|
|
|
gsize gsk_vulkan_image_get_width (GskVulkanImage *self);
|
|
gsize gsk_vulkan_image_get_height (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,
|
|
VkImageLayout image_layout,
|
|
VkAccessFlags access);
|
|
VkImage gsk_vulkan_image_get_vk_image (GskVulkanImage *self);
|
|
VkImageView gsk_vulkan_image_get_image_view (GskVulkanImage *self);
|
|
VkFormat gsk_vulkan_image_get_vk_format (GskVulkanImage *self);
|
|
GdkMemoryFormat gsk_vulkan_image_get_format (GskVulkanImage *self);
|
|
VkFramebuffer gsk_vulkan_image_get_framebuffer (GskVulkanImage *self,
|
|
VkRenderPass pass);
|
|
|
|
static inline void
|
|
print_image (GString *string,
|
|
GskVulkanImage *image)
|
|
{
|
|
g_string_append_printf (string, "%zux%zu ",
|
|
gsk_vulkan_image_get_width (image),
|
|
gsk_vulkan_image_get_height (image));
|
|
}
|
|
|
|
G_END_DECLS
|
|
|