mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-12 20:00:09 +00:00
9ddae8aebc
For now, it just renders using cairo, uploads the result to the GPU, blits it onto the framebuffer and then is happy. But it can do that using Vulkan and using GL (no idea which version). The most important thing still missing is shaders. It also has a bunch of copy/paste from the Vulkan renderer that isn't used yet. But I didn't want to rip it out and then try to copy it back later
90 lines
3.7 KiB
C
90 lines
3.7 KiB
C
#pragma once
|
|
|
|
#include <gdk/gdk.h>
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
#define GSK_VULKAN_MEMORY_MAPPABLE (VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | \
|
|
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | \
|
|
VK_MEMORY_PROPERTY_HOST_CACHED_BIT)
|
|
|
|
typedef struct _GskVulkanAllocator GskVulkanAllocator;
|
|
typedef struct _GskVulkanAllocation GskVulkanAllocation;
|
|
typedef struct _GskVulkanMemory GskVulkanMemory;
|
|
|
|
struct _GskVulkanAllocation
|
|
{
|
|
VkDeviceMemory vk_memory;
|
|
guchar *map;
|
|
VkDeviceSize offset;
|
|
VkDeviceSize size;
|
|
};
|
|
|
|
struct _GskVulkanAllocator
|
|
{
|
|
int ref_count;
|
|
|
|
void (* free_allocator) (GskVulkanAllocator *allocator);
|
|
|
|
void (* alloc) (GskVulkanAllocator *allocator,
|
|
VkDeviceSize size,
|
|
VkDeviceSize alignment,
|
|
GskVulkanAllocation *out_alloc);
|
|
void (* free) (GskVulkanAllocator *allocator,
|
|
GskVulkanAllocation *alloc);
|
|
};
|
|
|
|
static inline void gsk_vulkan_alloc (GskVulkanAllocator *allocator,
|
|
VkDeviceSize size,
|
|
VkDeviceSize alignment,
|
|
GskVulkanAllocation *out_alloc);
|
|
static inline void gsk_vulkan_free (GskVulkanAllocator *allocator,
|
|
GskVulkanAllocation *alloc);
|
|
|
|
static inline GskVulkanAllocator *
|
|
gsk_vulkan_allocator_ref (GskVulkanAllocator *allocator);
|
|
static inline void gsk_vulkan_allocator_unref (GskVulkanAllocator *allocator);
|
|
|
|
GskVulkanAllocator * gsk_vulkan_direct_allocator_new (VkDevice device,
|
|
uint32_t vk_type_index,
|
|
const VkMemoryType *vk_type);
|
|
GskVulkanAllocator * gsk_vulkan_buddy_allocator_new (GskVulkanAllocator *allocator,
|
|
gsize block_size);
|
|
GskVulkanAllocator * gsk_vulkan_stats_allocator_new (GskVulkanAllocator *allocator);
|
|
|
|
static inline void
|
|
gsk_vulkan_alloc (GskVulkanAllocator *allocator,
|
|
VkDeviceSize size,
|
|
VkDeviceSize alignment,
|
|
GskVulkanAllocation *out_alloc)
|
|
{
|
|
allocator->alloc (allocator, size, alignment, out_alloc);
|
|
}
|
|
|
|
static inline void
|
|
gsk_vulkan_free (GskVulkanAllocator *allocator,
|
|
GskVulkanAllocation *alloc)
|
|
{
|
|
allocator->free (allocator, alloc);
|
|
}
|
|
|
|
static inline GskVulkanAllocator *
|
|
gsk_vulkan_allocator_ref (GskVulkanAllocator *self)
|
|
{
|
|
self->ref_count++;
|
|
return self;
|
|
}
|
|
|
|
static inline void
|
|
gsk_vulkan_allocator_unref (GskVulkanAllocator *self)
|
|
{
|
|
self->ref_count--;
|
|
if (self->ref_count > 0)
|
|
return;
|
|
|
|
self->free_allocator (self);
|
|
}
|
|
|
|
G_END_DECLS
|
|
|