2019-12-07 09:11:33 +00:00
|
|
|
// Initialize Vulkan and composite stuff with a compute queue
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-12-12 06:44:52 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
typedef uint32_t VulkanTexture_t;
|
|
|
|
|
|
|
|
#define k_nMaxLayers 4
|
|
|
|
|
|
|
|
// These two structs are horrible
|
|
|
|
struct VulkanPipeline_t
|
|
|
|
{
|
|
|
|
struct LayerBinding_t
|
|
|
|
{
|
|
|
|
int surfaceWidth;
|
|
|
|
int surfaceHeight;
|
|
|
|
|
|
|
|
VulkanTexture_t tex;
|
|
|
|
uint32_t fbid;
|
|
|
|
|
2020-01-09 02:34:54 +00:00
|
|
|
int zpos;
|
|
|
|
|
2019-12-12 06:44:52 +00:00
|
|
|
// These fields below count for the sampler cache
|
|
|
|
bool bFilter;
|
|
|
|
bool bBlackBorder;
|
|
|
|
} layerBindings[ k_nMaxLayers ];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Composite_t
|
|
|
|
{
|
2020-01-19 01:24:56 +00:00
|
|
|
int nLayerCount;
|
|
|
|
int nSwapChannels;
|
2019-12-12 06:44:52 +00:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
float flScaleX, flScaleY;
|
|
|
|
float flOffsetX, flOffsetY;
|
|
|
|
float flOpacity;
|
|
|
|
} layers[ k_nMaxLayers ];
|
|
|
|
};
|
|
|
|
|
2019-12-07 09:11:33 +00:00
|
|
|
#include "drm.hpp"
|
|
|
|
|
|
|
|
#ifndef C_SIDE
|
2019-12-11 03:17:33 +00:00
|
|
|
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <vector>
|
|
|
|
|
2019-12-07 09:11:33 +00:00
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <vulkan/vulkan.h>
|
|
|
|
#include <wlr/render/dmabuf.h>
|
|
|
|
#include <drm_fourcc.h>
|
|
|
|
|
|
|
|
#ifndef C_SIDE
|
2019-12-09 02:43:16 +00:00
|
|
|
|
|
|
|
class CVulkanTexture
|
2019-12-07 09:11:33 +00:00
|
|
|
{
|
|
|
|
public:
|
2019-12-09 02:43:16 +00:00
|
|
|
bool BInit(uint32_t width, uint32_t height, VkFormat format, bool bFlippable, bool bTextureable, wlr_dmabuf_attributes *pDMA = nullptr );
|
|
|
|
|
2019-12-17 07:36:40 +00:00
|
|
|
~CVulkanTexture( void );
|
|
|
|
|
2019-12-09 02:43:16 +00:00
|
|
|
bool m_bInitialized = false;
|
2019-12-07 09:11:33 +00:00
|
|
|
|
2019-12-09 02:43:16 +00:00
|
|
|
VkImage m_vkImage = VK_NULL_HANDLE;
|
|
|
|
VkDeviceMemory m_vkImageMemory = VK_NULL_HANDLE;
|
|
|
|
|
|
|
|
VkImageView m_vkImageView = VK_NULL_HANDLE;
|
2019-12-07 09:11:33 +00:00
|
|
|
|
2019-12-09 02:43:16 +00:00
|
|
|
bool m_bFlippable = false;
|
2019-12-08 04:33:58 +00:00
|
|
|
|
2019-12-09 02:43:16 +00:00
|
|
|
wlr_dmabuf_attributes m_DMA = {};
|
|
|
|
uint32_t m_FBID = 0;
|
2019-12-07 09:11:33 +00:00
|
|
|
};
|
2019-12-09 02:43:16 +00:00
|
|
|
|
2019-12-09 10:06:44 +00:00
|
|
|
extern std::vector< const char * > g_vecSDLInstanceExts;
|
|
|
|
|
2019-12-07 09:11:33 +00:00
|
|
|
#endif
|
|
|
|
|
2019-12-09 02:43:16 +00:00
|
|
|
int vulkan_init(void);
|
|
|
|
|
|
|
|
VulkanTexture_t vulkan_create_texture_from_dmabuf( struct wlr_dmabuf_attributes *pDMA );
|
2020-01-01 13:02:33 +00:00
|
|
|
VulkanTexture_t vulkan_create_texture_from_bits( uint32_t width, uint32_t height, VkFormat format, void *bits );
|
2020-01-06 04:22:27 +00:00
|
|
|
|
2020-01-26 03:51:11 +00:00
|
|
|
uint32_t vulkan_get_texture_fence( VulkanTexture_t vulkanTex );
|
|
|
|
void vulkan_wait_for_fence( uint32_t );
|
2020-01-23 08:50:06 +00:00
|
|
|
|
2020-01-06 04:22:27 +00:00
|
|
|
uint32_t vulkan_texture_get_fbid( VulkanTexture_t vulkanTex );
|
|
|
|
|
2019-12-09 02:43:16 +00:00
|
|
|
void vulkan_free_texture( VulkanTexture_t vulkanTex );
|
|
|
|
|
2019-12-10 08:22:43 +00:00
|
|
|
bool vulkan_composite( struct Composite_t *pComposite, struct VulkanPipeline_t *pPipeline );
|
2019-12-09 06:23:08 +00:00
|
|
|
uint32_t vulkan_get_last_composite_fbid( void );
|
2019-12-07 09:11:33 +00:00
|
|
|
|
2019-12-09 10:06:44 +00:00
|
|
|
void vulkan_present_to_window( void );
|
|
|
|
|
2020-01-26 03:51:11 +00:00
|
|
|
void vulkan_garbage_collect( void );
|
2020-01-20 09:32:54 +00:00
|
|
|
bool vulkan_remake_swapchain( void );
|
|
|
|
|
2019-12-07 09:11:33 +00:00
|
|
|
#ifndef C_SIDE
|
|
|
|
}
|
|
|
|
#endif
|