2021-03-25 20:00:19 +08:00
|
|
|
|
#ifndef HGL_GRAPH_VULKAN_DEVICE_INCLUDE
|
|
|
|
|
#define HGL_GRAPH_VULKAN_DEVICE_INCLUDE
|
2019-04-10 21:54:39 +08:00
|
|
|
|
|
|
|
|
|
#include<hgl/type/List.h>
|
2020-09-05 17:54:21 +08:00
|
|
|
|
#include<hgl/type/String.h>
|
2019-04-28 16:06:53 +08:00
|
|
|
|
#include<hgl/type/Map.h>
|
2020-07-29 17:06:43 +08:00
|
|
|
|
#include<hgl/type/RectScope.h>
|
2019-04-30 16:42:59 +08:00
|
|
|
|
#include<hgl/platform/Window.h>
|
2020-07-29 17:06:43 +08:00
|
|
|
|
#include<hgl/graph/Bitmap.h>
|
2020-07-31 18:01:28 +08:00
|
|
|
|
#include<hgl/graph/font/Font.h>
|
2020-10-21 11:43:18 +08:00
|
|
|
|
#include<hgl/graph/VK.h>
|
|
|
|
|
#include<hgl/graph/VKDeviceAttribute.h>
|
|
|
|
|
#include<hgl/graph/VKSwapchain.h>
|
|
|
|
|
#include<hgl/graph/VKRenderTarget.h>
|
2020-07-16 17:08:13 +08:00
|
|
|
|
#include<hgl/graph/VertexAttribData.h>
|
2020-10-21 11:43:18 +08:00
|
|
|
|
#include<hgl/graph/VKShaderModuleMap.h>
|
2021-04-26 20:36:56 +08:00
|
|
|
|
#include<hgl/graph/VKArrayBuffer.h>
|
2023-03-02 20:19:25 +08:00
|
|
|
|
#include<hgl/graph/VKDescriptorSetType.h>
|
2019-04-10 21:54:39 +08:00
|
|
|
|
|
|
|
|
|
VK_NAMESPACE_BEGIN
|
2023-03-26 00:04:31 +08:00
|
|
|
|
|
|
|
|
|
class TileData;
|
|
|
|
|
class TileFont;
|
|
|
|
|
class FontSource;
|
2023-03-28 22:24:22 +08:00
|
|
|
|
class GPUArrayBuffer;
|
2023-03-26 00:04:31 +08:00
|
|
|
|
|
2023-05-10 21:26:15 +08:00
|
|
|
|
struct VulkanHardwareRequirement
|
|
|
|
|
{
|
|
|
|
|
uint min_1d_image_size;
|
|
|
|
|
uint min_2d_image_size;
|
|
|
|
|
uint min_3d_image_size;
|
|
|
|
|
uint min_cube_image_size;
|
|
|
|
|
uint min_array_image_layers;
|
|
|
|
|
|
|
|
|
|
uint min_vertex_input_attribute; ///<最小顶点输入属性数量需求
|
|
|
|
|
uint min_color_attachments; ///<最小颜色输出成份数量需求
|
|
|
|
|
|
|
|
|
|
uint min_push_constant_size; ///<最小push constant大小
|
|
|
|
|
uint min_ubo_range; ///<最小ubo range需求
|
|
|
|
|
uint min_ssbo_range; ///<最小ssbo range需求
|
|
|
|
|
|
|
|
|
|
uint min_draw_indirect_count; ///<最小间接绘制次数需求
|
|
|
|
|
|
|
|
|
|
bool geometry_shader; ///<要求支持几何着色器
|
|
|
|
|
bool tessellation_shader; ///<要求支持细分着色器
|
|
|
|
|
// bool compute_shader; ///<要求支持计算着色器
|
|
|
|
|
|
|
|
|
|
bool multi_draw_indirect; ///<要求支持MultiDrawIndirect
|
|
|
|
|
|
|
|
|
|
bool wide_lines; ///<要求支持宽线条
|
2023-05-10 21:58:36 +08:00
|
|
|
|
bool line_rasterization; ///<要支持线条特性(这功能mac/ios平台不支持)
|
2023-05-10 21:26:15 +08:00
|
|
|
|
bool large_points; ///<要求支持绘制大点
|
|
|
|
|
|
|
|
|
|
bool texture_cube_array; ///<要求支持立方体数组纹理
|
|
|
|
|
|
|
|
|
|
bool uint32_draw_index; ///<要求支持32位索引(不建议使用)
|
|
|
|
|
|
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
bool bc,etc2,astc_ldr,astc_hdr,pvrtc; ///<要求支持的压缩纹理格式
|
|
|
|
|
}texture_compression;
|
|
|
|
|
|
2023-05-10 21:48:26 +08:00
|
|
|
|
//dynamic_state VK_EXT_extended_dynamic_state
|
|
|
|
|
// cull mode
|
|
|
|
|
// front face
|
|
|
|
|
// primitive topology
|
|
|
|
|
// viewport
|
|
|
|
|
// scissor
|
|
|
|
|
// bind vbo
|
|
|
|
|
// depth test
|
|
|
|
|
// depth write
|
|
|
|
|
// depth compare op
|
|
|
|
|
// depth bounds test
|
|
|
|
|
// stencil test
|
|
|
|
|
// stencil op
|
|
|
|
|
//dynamic_state[1] VK_EXT_extended_dynamic_state2
|
|
|
|
|
// patch control points
|
|
|
|
|
// rasterizer discard
|
|
|
|
|
// depth bias
|
|
|
|
|
// logic op
|
|
|
|
|
// primitive restart
|
|
|
|
|
//dynamic_state[2] VK_EXT_extended_dynamic_state3
|
|
|
|
|
// tess domain origin
|
|
|
|
|
// depth clamp
|
|
|
|
|
// discard polygon mode
|
|
|
|
|
// rasterization samples
|
|
|
|
|
// sample mask
|
|
|
|
|
// alpha to coverage
|
|
|
|
|
// alpha to one
|
|
|
|
|
// logic op enable
|
|
|
|
|
// color blend
|
|
|
|
|
// color blend equation
|
|
|
|
|
// color write mask
|
|
|
|
|
// depth clamp
|
|
|
|
|
// Color blend advanced
|
|
|
|
|
// line rasterization mode
|
|
|
|
|
// line stipple
|
|
|
|
|
// depth clip -1 to 1
|
|
|
|
|
// shading rate image enable
|
|
|
|
|
bool dynamic_state[3]; ///<要求支持动态状态
|
|
|
|
|
|
2023-05-10 21:26:15 +08:00
|
|
|
|
// 1.3 特性
|
|
|
|
|
bool dynamic_rendering; ///<要求支持动态渲染
|
|
|
|
|
};
|
|
|
|
|
|
2023-05-11 00:56:26 +08:00
|
|
|
|
constexpr const VkFormat SwapchainPreferFormatsLDR[]=
|
2023-05-10 21:26:15 +08:00
|
|
|
|
{
|
2023-05-11 00:56:26 +08:00
|
|
|
|
PF_RGB5A1,
|
|
|
|
|
PF_BGR5A1,
|
|
|
|
|
PF_A1RGB5,
|
|
|
|
|
PF_RGB565,
|
|
|
|
|
PF_BGR565,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
constexpr const VkFormat SwapchainPreferFormatsSDR[]=
|
|
|
|
|
{
|
|
|
|
|
PF_RGBA8UN,PF_RGBA8s,
|
|
|
|
|
PF_BGRA8UN,PF_BGRA8s,
|
|
|
|
|
PF_ABGR8UN,PF_ABGR8s,
|
|
|
|
|
PF_A2RGB10UN,
|
|
|
|
|
PF_A2BGR10UN,
|
|
|
|
|
PF_B10GR11UF
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
constexpr const VkFormat SwapchainPreferFormatsHDR16[]=
|
|
|
|
|
{
|
|
|
|
|
PF_RGBA16UN,PF_RGBA16SN,PF_RGBA16F
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
constexpr const VkFormat SwapchainPreferFormatsHDR32[]=
|
|
|
|
|
{
|
|
|
|
|
PF_RGB32F,
|
|
|
|
|
PF_RGBA32F
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
constexpr const VkFormat SwapchainPreferFormatsDepth[]=
|
|
|
|
|
{
|
|
|
|
|
PF_D16UN,
|
|
|
|
|
PF_X8_D24UN,
|
|
|
|
|
PF_D16UN_S8U,
|
|
|
|
|
PF_D24UN_S8U,
|
|
|
|
|
PF_D32F,
|
|
|
|
|
PF_D32F_S8U
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct PreferFormats
|
|
|
|
|
{
|
|
|
|
|
//偏好格式需从低质量到高质量排列
|
|
|
|
|
const VkFormat *formats;
|
|
|
|
|
uint count;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
constexpr const PreferFormats PreferLDR {SwapchainPreferFormatsLDR, sizeof(SwapchainPreferFormatsLDR )/sizeof(VkFormat)};
|
|
|
|
|
constexpr const PreferFormats PreferSDR {SwapchainPreferFormatsSDR, sizeof(SwapchainPreferFormatsSDR )/sizeof(VkFormat)};
|
|
|
|
|
constexpr const PreferFormats PreferHDR16{SwapchainPreferFormatsHDR16, sizeof(SwapchainPreferFormatsHDR16 )/sizeof(VkFormat)};
|
|
|
|
|
constexpr const PreferFormats PreferHDR32{SwapchainPreferFormatsHDR32, sizeof(SwapchainPreferFormatsHDR32 )/sizeof(VkFormat)};
|
|
|
|
|
constexpr const PreferFormats PreferDepth{SwapchainPreferFormatsDepth, sizeof(SwapchainPreferFormatsDepth )/sizeof(VkFormat)};
|
|
|
|
|
|
|
|
|
|
class VulkanDeviceCreateInfo
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
|
2023-05-10 21:26:15 +08:00
|
|
|
|
VulkanInstance *instance;
|
|
|
|
|
Window *window;
|
|
|
|
|
const GPUPhysicalDevice *physical_device;
|
|
|
|
|
|
|
|
|
|
VulkanHardwareRequirement require;
|
|
|
|
|
|
2023-05-11 00:56:26 +08:00
|
|
|
|
const PreferFormats *perfer_color_formats;
|
|
|
|
|
const PreferFormats *perfer_depth_formats;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
VulkanDeviceCreateInfo( VulkanInstance *vi,
|
|
|
|
|
Window *win,
|
|
|
|
|
const PreferFormats *spf_color=&PreferSDR,
|
|
|
|
|
const PreferFormats *spf_depth=&PreferDepth)
|
|
|
|
|
{
|
|
|
|
|
instance=vi;
|
|
|
|
|
window=win;
|
|
|
|
|
|
|
|
|
|
physical_device=nullptr;
|
|
|
|
|
|
|
|
|
|
hgl_zero(require);
|
|
|
|
|
|
|
|
|
|
perfer_color_formats=spf_color;
|
|
|
|
|
perfer_depth_formats=spf_depth;
|
|
|
|
|
}
|
2021-12-16 17:27:33 +08:00
|
|
|
|
|
2023-05-11 00:56:26 +08:00
|
|
|
|
virtual bool ChoosePhysicalDevice()
|
|
|
|
|
{
|
|
|
|
|
physical_device=nullptr;
|
|
|
|
|
|
|
|
|
|
if(!physical_device)physical_device=instance->GetDevice(VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU); //先找独显
|
|
|
|
|
if(!physical_device)physical_device=instance->GetDevice(VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU); //再找集显
|
|
|
|
|
if(!physical_device)physical_device=instance->GetDevice(VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU); //最后找虚拟显卡
|
|
|
|
|
|
|
|
|
|
return physical_device;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual bool RequirementCheck();
|
|
|
|
|
};
|
2021-12-16 17:27:33 +08:00
|
|
|
|
|
2020-10-21 12:39:22 +08:00
|
|
|
|
class GPUDevice
|
2019-04-11 02:29:21 +08:00
|
|
|
|
{
|
2020-10-21 12:39:22 +08:00
|
|
|
|
GPUDeviceAttribute *attr;
|
2019-04-10 21:54:39 +08:00
|
|
|
|
|
2023-03-02 20:19:25 +08:00
|
|
|
|
DeviceQueue *texture_queue;
|
2020-11-09 15:37:00 +08:00
|
|
|
|
TextureCmdBuffer *texture_cmd_buf;
|
2019-04-23 00:02:59 +08:00
|
|
|
|
|
2021-09-22 16:28:39 +08:00
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
DeviceRenderPassManage *render_pass_manage;
|
|
|
|
|
RenderPass *device_render_pass;
|
|
|
|
|
|
2019-07-16 19:59:53 +08:00
|
|
|
|
SwapchainRenderTarget *swapchainRT;
|
2019-05-07 12:46:25 +08:00
|
|
|
|
|
2021-12-15 19:59:28 +08:00
|
|
|
|
SwapchainRenderTarget *CreateSwapchainRenderTarget();
|
2021-12-15 19:56:44 +08:00
|
|
|
|
|
2021-09-22 16:28:39 +08:00
|
|
|
|
void InitRenderPassManage();
|
2021-09-22 16:31:35 +08:00
|
|
|
|
void ClearRenderPassManage();
|
2021-09-22 16:28:39 +08:00
|
|
|
|
|
2020-10-28 12:30:44 +08:00
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
VkCommandBuffer CreateCommandBuffer();
|
|
|
|
|
|
2021-12-15 20:52:52 +08:00
|
|
|
|
bool CreateSwapchainFBO(Swapchain *);
|
2019-11-26 00:22:54 +08:00
|
|
|
|
|
2021-12-15 20:46:33 +08:00
|
|
|
|
Swapchain *CreateSwapchain(const VkExtent2D &acquire_extent);
|
2019-11-26 00:22:54 +08:00
|
|
|
|
|
2019-05-07 12:46:25 +08:00
|
|
|
|
private:
|
|
|
|
|
|
2023-05-10 21:26:15 +08:00
|
|
|
|
friend GPUDevice *CreateRenderDevice(VulkanDeviceCreateInfo *,VkSurfaceKHR surface,const VkExtent2D &extent);
|
2019-04-10 21:54:39 +08:00
|
|
|
|
|
2020-10-21 12:39:22 +08:00
|
|
|
|
GPUDevice(GPUDeviceAttribute *da);
|
2019-04-10 21:54:39 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2020-10-21 12:39:22 +08:00
|
|
|
|
virtual ~GPUDevice();
|
2019-04-10 21:54:39 +08:00
|
|
|
|
|
2019-07-13 02:37:19 +08:00
|
|
|
|
operator VkDevice () {return attr->device;}
|
2020-10-21 12:52:32 +08:00
|
|
|
|
GPUDeviceAttribute *GetDeviceAttribute () {return attr;}
|
2019-04-23 00:37:45 +08:00
|
|
|
|
|
2019-07-13 02:37:19 +08:00
|
|
|
|
VkSurfaceKHR GetSurface () {return attr->surface;}
|
2020-10-15 22:13:15 +08:00
|
|
|
|
VkDevice GetDevice ()const {return attr->device;}
|
2021-03-25 20:00:19 +08:00
|
|
|
|
const GPUPhysicalDevice * GetPhysicalDevice ()const {return attr->physical_device;}
|
2019-04-10 21:54:39 +08:00
|
|
|
|
|
2019-07-13 02:37:19 +08:00
|
|
|
|
VkDescriptorPool GetDescriptorPool () {return attr->desc_pool;}
|
|
|
|
|
VkPipelineCache GetPipelineCache () {return attr->pipeline_cache;}
|
2019-04-19 00:46:49 +08:00
|
|
|
|
|
2021-09-23 15:19:09 +08:00
|
|
|
|
const VkFormat GetSurfaceFormat ()const {return attr->surface_format.format;}
|
|
|
|
|
const VkColorSpaceKHR GetColorSpace ()const {return attr->surface_format.colorSpace;}
|
2019-07-13 02:37:19 +08:00
|
|
|
|
VkQueue GetGraphicsQueue () {return attr->graphics_queue;}
|
2019-04-20 02:28:57 +08:00
|
|
|
|
|
2021-09-22 16:28:39 +08:00
|
|
|
|
RenderPass * GetRenderPass () {return device_render_pass;}
|
2019-04-20 16:12:22 +08:00
|
|
|
|
|
2019-07-16 19:59:53 +08:00
|
|
|
|
SwapchainRenderTarget * GetSwapchainRT () {return swapchainRT;}
|
|
|
|
|
|
2021-12-15 20:46:33 +08:00
|
|
|
|
const VkExtent2D & GetSwapchainSize ()const {return swapchainRT->GetExtent();}
|
2019-04-23 00:02:59 +08:00
|
|
|
|
|
2022-03-11 18:27:04 +08:00
|
|
|
|
void WaitIdle ()const {vkDeviceWaitIdle(attr->device);}
|
|
|
|
|
|
2021-12-15 20:46:33 +08:00
|
|
|
|
public:
|
2020-07-03 21:12:33 +08:00
|
|
|
|
|
2019-07-13 02:37:19 +08:00
|
|
|
|
bool Resize (const VkExtent2D &);
|
2019-07-16 10:26:24 +08:00
|
|
|
|
bool Resize (const uint32_t &w,const uint32_t &h)
|
|
|
|
|
{
|
|
|
|
|
VkExtent2D extent={w,h};
|
|
|
|
|
|
|
|
|
|
return Resize(extent);
|
|
|
|
|
}
|
2019-05-07 12:46:25 +08:00
|
|
|
|
|
2019-06-26 15:18:31 +08:00
|
|
|
|
public: //内存相关
|
|
|
|
|
|
2022-10-14 17:52:35 +08:00
|
|
|
|
DeviceMemory *CreateMemory(const VkMemoryRequirements &,const uint32_t properties);
|
|
|
|
|
DeviceMemory *CreateMemory(VkImage,const uint32 flag=VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
2019-11-25 22:05:05 +08:00
|
|
|
|
|
|
|
|
|
private: //Buffer相关
|
|
|
|
|
|
2022-10-14 17:52:35 +08:00
|
|
|
|
bool CreateBuffer(DeviceBufferData *buf,VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size,const void *data,SharingMode sharing_mode);
|
|
|
|
|
bool CreateBuffer(DeviceBufferData *buf,VkBufferUsageFlags buf_usage, VkDeviceSize size,const void *data,SharingMode sharing_mode){return CreateBuffer(buf,buf_usage,size,size,data,sharing_mode);}
|
2019-06-26 15:18:31 +08:00
|
|
|
|
|
2019-05-07 12:46:25 +08:00
|
|
|
|
public: //Buffer相关
|
2019-04-10 21:54:39 +08:00
|
|
|
|
|
2023-02-13 11:48:53 +08:00
|
|
|
|
DeviceBuffer * CreateBuffer(VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size,const void *data, SharingMode sm=SharingMode::Exclusive);
|
|
|
|
|
DeviceBuffer * CreateBuffer(VkBufferUsageFlags buf_usage,VkDeviceSize range,VkDeviceSize size, SharingMode sm=SharingMode::Exclusive){return CreateBuffer(buf_usage,range,size,nullptr,sm);}
|
|
|
|
|
|
|
|
|
|
DeviceBuffer * CreateBuffer(VkBufferUsageFlags buf_usage, VkDeviceSize size,const void *data, SharingMode sm=SharingMode::Exclusive){return CreateBuffer(buf_usage,size,size,data,sm);}
|
|
|
|
|
DeviceBuffer * CreateBuffer(VkBufferUsageFlags buf_usage, VkDeviceSize size, SharingMode sm=SharingMode::Exclusive){return CreateBuffer(buf_usage,size,size,nullptr,sm);}
|
2019-05-05 14:22:58 +08:00
|
|
|
|
|
2021-11-29 15:58:48 +08:00
|
|
|
|
VBO * CreateVBO (VkFormat format, uint32_t count,const void *data, SharingMode sm=SharingMode::Exclusive);
|
|
|
|
|
VBO * CreateVBO (VkFormat format, uint32_t count, SharingMode sm=SharingMode::Exclusive){return CreateVBO(format,count,nullptr,sm);}
|
2023-05-04 19:35:09 +08:00
|
|
|
|
VBO * CreateVBO (const VAD *vad, SharingMode sm=SharingMode::Exclusive){return CreateVBO(vad->GetFormat(),vad->GetCount(),vad->GetData(),sm);}
|
2019-04-16 02:21:35 +08:00
|
|
|
|
|
2021-04-06 19:12:37 +08:00
|
|
|
|
IndexBuffer * CreateIBO (IndexType type, uint32_t count,const void * data, SharingMode sm=SharingMode::Exclusive);
|
|
|
|
|
IndexBuffer * CreateIBO16 ( uint32_t count,const uint16 *data, SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U16, count,(void *)data,sm);}
|
|
|
|
|
IndexBuffer * CreateIBO32 ( uint32_t count,const uint32 *data, SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U32, count,(void *)data,sm);}
|
2019-04-11 22:40:13 +08:00
|
|
|
|
|
2021-04-06 19:12:37 +08:00
|
|
|
|
IndexBuffer * CreateIBO (IndexType type, uint32_t count, SharingMode sm=SharingMode::Exclusive){return CreateIBO(type, count,nullptr,sm);}
|
|
|
|
|
IndexBuffer * CreateIBO16 ( uint32_t count, SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U16, count,nullptr,sm);}
|
|
|
|
|
IndexBuffer * CreateIBO32 ( uint32_t count, SharingMode sm=SharingMode::Exclusive){return CreateIBO(IndexType::U32, count,nullptr,sm);}
|
2019-04-25 14:33:50 +08:00
|
|
|
|
|
2021-06-22 21:33:47 +08:00
|
|
|
|
const VkDeviceSize GetUBOAlign();
|
2023-03-24 22:14:05 +08:00
|
|
|
|
const VkDeviceSize GetSSBOAlign();
|
2023-04-25 11:36:50 +08:00
|
|
|
|
const VkDeviceSize GetUBORange();
|
|
|
|
|
const VkDeviceSize GetSSBORange();
|
2021-06-22 21:33:47 +08:00
|
|
|
|
|
2022-10-14 17:52:35 +08:00
|
|
|
|
#define CREATE_BUFFER_OBJECT(LargeName,type) DeviceBuffer *Create##LargeName( VkDeviceSize size,void *data, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,size ,size,data, sm);} \
|
|
|
|
|
DeviceBuffer *Create##LargeName( VkDeviceSize size, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,size ,size,nullptr, sm);} \
|
|
|
|
|
DeviceBuffer *Create##LargeName(VkDeviceSize range,VkDeviceSize size,void *data, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,range,size,data, sm);} \
|
|
|
|
|
DeviceBuffer *Create##LargeName(VkDeviceSize range,VkDeviceSize size, SharingMode sm=SharingMode::Exclusive) {return CreateBuffer(VK_BUFFER_USAGE_##type##_BUFFER_BIT,range,size,nullptr, sm);}
|
2019-04-11 23:02:38 +08:00
|
|
|
|
|
|
|
|
|
CREATE_BUFFER_OBJECT(UBO,UNIFORM)
|
2019-04-19 21:14:56 +08:00
|
|
|
|
CREATE_BUFFER_OBJECT(SSBO,STORAGE)
|
2019-04-11 23:02:38 +08:00
|
|
|
|
CREATE_BUFFER_OBJECT(INBO,INDIRECT)
|
|
|
|
|
|
|
|
|
|
#undef CREATE_BUFFER_OBJECT
|
2019-04-11 22:40:13 +08:00
|
|
|
|
|
2023-03-28 22:24:22 +08:00
|
|
|
|
GPUArrayBuffer *CreateUBO(const VkDeviceSize &uint_size);
|
|
|
|
|
GPUArrayBuffer *CreateSSBO(const VkDeviceSize &uint_size);
|
|
|
|
|
|
2019-11-25 22:05:05 +08:00
|
|
|
|
public: //Image
|
|
|
|
|
|
2020-09-27 21:18:46 +08:00
|
|
|
|
VkImage CreateImage (VkImageCreateInfo *);
|
2021-09-14 20:31:15 +08:00
|
|
|
|
void DestroyImage (VkImage);
|
2019-05-05 14:22:58 +08:00
|
|
|
|
|
2020-10-25 21:29:18 +08:00
|
|
|
|
private: //texture
|
|
|
|
|
|
2022-10-14 17:52:35 +08:00
|
|
|
|
bool CommitTexture (Texture *,DeviceBuffer *buf,const VkBufferImageCopy *,const int count,const uint32_t layer_count,VkPipelineStageFlags);//=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
2022-01-07 19:39:39 +08:00
|
|
|
|
|
2022-10-14 17:52:35 +08:00
|
|
|
|
bool CommitTexture2D (Texture2D *,DeviceBuffer *buf,VkPipelineStageFlags stage);
|
|
|
|
|
bool CommitTexture2DMipmaps (Texture2D *,DeviceBuffer *buf,const VkExtent3D &,uint32_t);
|
2022-01-07 16:55:39 +08:00
|
|
|
|
|
2022-10-14 17:52:35 +08:00
|
|
|
|
bool CommitTextureCube (TextureCube *,DeviceBuffer *buf,const uint32_t mipmaps_zero_bytes,VkPipelineStageFlags stage);
|
|
|
|
|
bool CommitTextureCubeMipmaps (TextureCube *,DeviceBuffer *buf,const VkExtent3D &,uint32_t);
|
2022-01-07 19:39:39 +08:00
|
|
|
|
|
|
|
|
|
bool SubmitTexture (const VkCommandBuffer *cmd_bufs,const uint32_t count=1); ///<提交纹理处理到队列
|
2021-12-27 16:57:19 +08:00
|
|
|
|
|
2019-11-25 22:05:05 +08:00
|
|
|
|
public: //Texture
|
2019-06-25 21:38:38 +08:00
|
|
|
|
|
2020-10-15 22:13:15 +08:00
|
|
|
|
bool CheckFormatSupport(const VkFormat,const uint32_t bits,ImageTiling tiling=ImageTiling::Optimal)const;
|
2020-10-15 17:33:52 +08:00
|
|
|
|
|
2020-10-15 22:13:15 +08:00
|
|
|
|
bool CheckTextureFormatSupport(const VkFormat fmt,ImageTiling tiling=ImageTiling::Optimal)const{return CheckFormatSupport(fmt,VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT,tiling);}
|
2020-10-15 17:33:52 +08:00
|
|
|
|
|
|
|
|
|
Texture2D *CreateTexture2D(TextureData *);
|
|
|
|
|
Texture2D *CreateTexture2D(TextureCreateInfo *ci);
|
|
|
|
|
|
2022-01-05 18:20:48 +08:00
|
|
|
|
TextureCube *CreateTextureCube(TextureData *);
|
|
|
|
|
TextureCube *CreateTextureCube(TextureCreateInfo *ci);
|
|
|
|
|
|
2020-10-15 17:33:52 +08:00
|
|
|
|
void Clear(TextureCreateInfo *);
|
|
|
|
|
|
2023-03-17 21:06:05 +08:00
|
|
|
|
bool ChangeTexture2D(Texture2D *,DeviceBuffer *buf, const List<Image2DRegion> &, VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
|
|
|
|
bool ChangeTexture2D(Texture2D *,DeviceBuffer *buf, uint32_t left,uint32_t top,uint32_t width,uint32_t height, VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
|
|
|
|
bool ChangeTexture2D(Texture2D *,void *data, uint32_t left,uint32_t top,uint32_t width,uint32_t height,uint32_t size,VkPipelineStageFlags=VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
2019-11-25 22:05:05 +08:00
|
|
|
|
|
2020-07-29 17:06:43 +08:00
|
|
|
|
template<typename T>
|
2022-10-14 17:52:35 +08:00
|
|
|
|
bool ChangeTexture2D(Texture2D *tex,DeviceBuffer *buf,const RectScope2<T> &rs)
|
2020-07-29 17:06:43 +08:00
|
|
|
|
{
|
|
|
|
|
return ChangeTexture2D( tex,
|
|
|
|
|
buf,
|
|
|
|
|
rs.GetLeft(),
|
|
|
|
|
rs.GetTop(),
|
|
|
|
|
rs.GetWidth(),
|
|
|
|
|
rs.GetHeight());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
|
bool ChangeTexture2D(Texture2D *tex,void *data,const RectScope2<T> &rs,uint32_t size)
|
|
|
|
|
{
|
|
|
|
|
return ChangeTexture2D( tex,
|
2020-09-11 17:11:32 +08:00
|
|
|
|
data,
|
2020-07-29 17:06:43 +08:00
|
|
|
|
rs.GetLeft(),
|
|
|
|
|
rs.GetTop(),
|
|
|
|
|
rs.GetWidth(),
|
|
|
|
|
rs.GetHeight(),
|
|
|
|
|
size);
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-25 22:05:05 +08:00
|
|
|
|
public: //
|
|
|
|
|
|
2020-07-07 19:16:23 +08:00
|
|
|
|
Sampler *CreateSampler(VkSamplerCreateInfo *sci=nullptr);
|
2021-11-22 14:06:04 +08:00
|
|
|
|
Sampler *CreateSampler(Texture *);
|
2019-05-18 15:41:49 +08:00
|
|
|
|
|
2020-09-19 23:49:32 +08:00
|
|
|
|
public: //shader & material
|
|
|
|
|
|
2023-03-20 13:55:47 +08:00
|
|
|
|
PipelineLayoutData *CreatePipelineLayoutData(const MaterialDescriptorManager *);
|
2021-09-14 20:31:15 +08:00
|
|
|
|
void Destroy(PipelineLayoutData *);
|
|
|
|
|
|
2023-03-18 17:58:57 +08:00
|
|
|
|
DescriptorSet * CreateDS(const PipelineLayoutData *,const DescriptorSetType &type)const;
|
2023-03-20 13:55:47 +08:00
|
|
|
|
MaterialParameters *CreateMP(const MaterialDescriptorManager *,const PipelineLayoutData *,const DescriptorSetType &);
|
2023-02-22 21:53:51 +08:00
|
|
|
|
MaterialParameters *CreateMP(Material *,const DescriptorSetType &);
|
2020-09-19 23:49:32 +08:00
|
|
|
|
|
2023-03-19 20:18:10 +08:00
|
|
|
|
ShaderModule *CreateShaderModule(VkShaderStageFlagBits,const uint32_t *,const size_t);
|
2020-09-19 23:49:32 +08:00
|
|
|
|
|
2023-03-20 13:55:47 +08:00
|
|
|
|
Material *CreateMaterial(const UTF8String &mtl_name,ShaderModuleMap *shader_maps,MaterialDescriptorManager *,VertexInput *);
|
2019-04-27 21:23:57 +08:00
|
|
|
|
|
2022-10-11 19:16:06 +08:00
|
|
|
|
MaterialInstance *CreateMI(Material *,const VILConfig *vil_cfg=nullptr);
|
2021-09-14 20:31:15 +08:00
|
|
|
|
|
2020-11-09 15:37:00 +08:00
|
|
|
|
public: //Command Buffer 相关
|
2019-04-25 10:09:56 +08:00
|
|
|
|
|
2020-11-09 15:37:00 +08:00
|
|
|
|
RenderCmdBuffer * CreateRenderCommandBuffer();
|
|
|
|
|
TextureCmdBuffer *CreateTextureCommandBuffer();
|
2019-07-02 21:09:20 +08:00
|
|
|
|
|
2021-09-22 15:32:20 +08:00
|
|
|
|
public:
|
2019-07-02 21:09:20 +08:00
|
|
|
|
|
2023-02-13 11:48:53 +08:00
|
|
|
|
RenderPass * AcquireRenderPass( const RenderbufferInfo *,const uint subpass_count=2);
|
2020-10-16 19:24:33 +08:00
|
|
|
|
|
2022-10-14 19:27:29 +08:00
|
|
|
|
Fence * CreateFence(bool);
|
2022-10-14 19:40:16 +08:00
|
|
|
|
Semaphore * CreateGPUSemaphore();
|
2019-07-13 18:23:43 +08:00
|
|
|
|
|
2023-03-02 20:19:25 +08:00
|
|
|
|
DeviceQueue *CreateQueue(const uint32_t fence_count=1,const bool create_signaled=false);
|
2021-12-15 19:56:44 +08:00
|
|
|
|
|
2020-10-16 19:24:33 +08:00
|
|
|
|
public: //FrameBuffer相关
|
|
|
|
|
|
2023-03-18 17:58:57 +08:00
|
|
|
|
Framebuffer *CreateFBO(RenderPass *rp,ImageView **color_list,const uint color_count,ImageView *depth);
|
|
|
|
|
// Framebuffer *CreateFBO(RenderPass *,List<ImageView *> &color,ImageView *depth);
|
|
|
|
|
Framebuffer *CreateFBO(RenderPass *,ImageView *color,ImageView *depth);
|
|
|
|
|
Framebuffer *CreateFBO(RenderPass *,ImageView *);
|
2020-10-16 19:24:33 +08:00
|
|
|
|
|
2019-07-13 18:23:43 +08:00
|
|
|
|
public:
|
2020-10-16 19:24:33 +08:00
|
|
|
|
|
2023-03-18 17:58:57 +08:00
|
|
|
|
RenderTarget *CreateRT( const FramebufferInfo *fbi,RenderPass *,const uint32_t fence_count=1);
|
|
|
|
|
RenderTarget *CreateRT( const FramebufferInfo *fbi,const uint32_t fence_count=1);
|
2020-09-19 23:49:32 +08:00
|
|
|
|
|
2020-10-17 22:13:08 +08:00
|
|
|
|
public:
|
|
|
|
|
|
2020-07-31 18:01:28 +08:00
|
|
|
|
TileData *CreateTileData(const VkFormat video_format,const uint width,const uint height,const uint count); ///<创建一个Tile数据集
|
|
|
|
|
|
2023-03-18 17:58:57 +08:00
|
|
|
|
TileFont *CreateTileFont(FontSource *fs,int limit_count=-1); ///<创建一个Tile字体
|
2020-10-21 12:39:22 +08:00
|
|
|
|
};//class GPUDevice
|
2019-08-23 11:18:09 +08:00
|
|
|
|
|
2023-05-10 21:26:15 +08:00
|
|
|
|
GPUDevice *CreateRenderDevice(VulkanDeviceCreateInfo *);
|
2019-04-10 21:54:39 +08:00
|
|
|
|
VK_NAMESPACE_END
|
2021-03-25 20:00:19 +08:00
|
|
|
|
#endif//HGL_GRAPH_VULKAN_DEVICE_INCLUDE
|