2019-08-15 11:00:15 +08:00
|
|
|
|
#include<iostream>
|
2023-05-12 00:31:20 +08:00
|
|
|
|
#include<iomanip>
|
2020-10-21 11:43:18 +08:00
|
|
|
|
#include<hgl/graph/VK.h>
|
|
|
|
|
#include<hgl/graph/VKDevice.h>
|
|
|
|
|
#include<hgl/graph/VKInstance.h>
|
2019-08-15 11:00:15 +08:00
|
|
|
|
|
|
|
|
|
using namespace hgl;
|
|
|
|
|
using namespace hgl::graph;
|
2019-08-13 17:08:37 +08:00
|
|
|
|
|
|
|
|
|
VK_NAMESPACE_USING;
|
|
|
|
|
|
2019-08-14 16:36:02 +08:00
|
|
|
|
|
2020-10-21 12:47:06 +08:00
|
|
|
|
VulkanInstance *InitVulkanInstance()
|
2019-08-13 17:08:37 +08:00
|
|
|
|
{
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
if(!CheckStrideBytesByFormat())
|
|
|
|
|
{
|
|
|
|
|
std::cerr<<"check stride bytes by format failed."<<std::endl;
|
2019-11-13 19:55:13 +08:00
|
|
|
|
return(nullptr);
|
2019-08-13 17:08:37 +08:00
|
|
|
|
}
|
|
|
|
|
#endif//_DEBUG
|
|
|
|
|
|
2019-08-15 11:00:15 +08:00
|
|
|
|
InitNativeWindowSystem();
|
|
|
|
|
|
2020-11-05 14:18:05 +08:00
|
|
|
|
//InitVulkanProperties();
|
2019-11-06 20:52:09 +08:00
|
|
|
|
|
2019-11-13 19:55:13 +08:00
|
|
|
|
CreateInstanceLayerInfo cili;
|
|
|
|
|
|
|
|
|
|
memset(&cili,0,sizeof(CreateInstanceLayerInfo));
|
|
|
|
|
|
|
|
|
|
cili.lunarg.standard_validation=true;
|
|
|
|
|
cili.khronos.validation=true;
|
|
|
|
|
|
2020-10-21 12:47:06 +08:00
|
|
|
|
return CreateInstance("VulkanTest",nullptr,&cili);
|
2019-11-13 19:55:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int,char **)
|
|
|
|
|
{
|
2020-11-05 14:18:05 +08:00
|
|
|
|
Window * win =nullptr;
|
|
|
|
|
VulkanInstance * inst =nullptr;
|
|
|
|
|
GPUDevice * device =nullptr;
|
|
|
|
|
const GPUPhysicalDevice * physical_device =nullptr;
|
2019-11-13 19:55:13 +08:00
|
|
|
|
|
|
|
|
|
inst=InitVulkanInstance();
|
2019-08-15 11:00:15 +08:00
|
|
|
|
|
|
|
|
|
if(!inst)
|
2019-11-13 19:55:13 +08:00
|
|
|
|
{
|
|
|
|
|
std::cerr<<"[VULKAN FATAL ERROR] Create Vulkan Instance failed.";
|
2019-08-15 11:00:15 +08:00
|
|
|
|
return(false);
|
2019-11-13 19:55:13 +08:00
|
|
|
|
}
|
2019-08-15 11:00:15 +08:00
|
|
|
|
|
2019-11-13 16:01:13 +08:00
|
|
|
|
physical_device=inst->GetDevice(VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU);
|
2019-08-15 11:00:15 +08:00
|
|
|
|
|
2019-11-13 16:01:13 +08:00
|
|
|
|
if(!physical_device)
|
|
|
|
|
physical_device=inst->GetDevice(VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU);
|
2019-08-15 11:00:15 +08:00
|
|
|
|
|
2019-08-14 16:36:02 +08:00
|
|
|
|
uint32_t count;
|
|
|
|
|
const VulkanFormat *vf=GetVulkanFormatList(count);
|
|
|
|
|
|
|
|
|
|
if(!count)return(255);
|
|
|
|
|
|
|
|
|
|
for(uint32_t i=0;i<count;i++)
|
2019-08-13 17:08:37 +08:00
|
|
|
|
{
|
2023-05-12 00:31:20 +08:00
|
|
|
|
std::cout<<std::setw(4)<<i<<". ";
|
2019-08-14 16:36:02 +08:00
|
|
|
|
|
2023-05-12 00:31:20 +08:00
|
|
|
|
std::cout<<"Format [ID:"<<std::setw(10)<<vf->format<<"]["<<std::setw(16)<<vf->name<<"]";
|
2019-08-14 16:36:02 +08:00
|
|
|
|
|
2023-05-12 00:31:20 +08:00
|
|
|
|
if(vf->depth!=VulkanBaseType::NONE)
|
2024-07-27 20:52:58 +08:00
|
|
|
|
std::cout<<"[ Depth:"<<std::setw(8)<<VulkanBaseTypeName[size_t(vf->depth)]<<"]";
|
2019-08-14 16:36:02 +08:00
|
|
|
|
|
2023-05-12 00:31:20 +08:00
|
|
|
|
if(vf->stencil!=VulkanBaseType::NONE)
|
2024-07-27 20:52:58 +08:00
|
|
|
|
std::cout<<"[Stencil:"<<std::setw(8)<<VulkanBaseTypeName[size_t(vf->stencil)]<<"]";
|
2019-08-14 16:36:02 +08:00
|
|
|
|
|
2023-05-12 00:31:20 +08:00
|
|
|
|
if((vf->depth==VulkanBaseType::NONE)
|
|
|
|
|
&&(vf->stencil==VulkanBaseType::NONE))
|
2024-07-27 20:52:58 +08:00
|
|
|
|
std::cout<<"[ Color:"<<std::setw(8)<<VulkanBaseTypeName[size_t(vf->color)]<<"]";
|
2019-08-15 11:00:15 +08:00
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
const VkFormatProperties fp=physical_device->GetFormatProperties(vf->format);
|
|
|
|
|
|
2023-05-12 00:31:20 +08:00
|
|
|
|
char olb[]="[ ]";
|
|
|
|
|
|
2023-05-13 03:14:38 +08:00
|
|
|
|
if(fp.optimalTilingFeatures&VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT )olb[1]='O';
|
|
|
|
|
if(fp.linearTilingFeatures&VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT )olb[2]='L';
|
|
|
|
|
if(fp.bufferFeatures&VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT )olb[2]='B';
|
2023-05-12 00:31:20 +08:00
|
|
|
|
|
|
|
|
|
std::cout<<olb;
|
2019-08-15 11:00:15 +08:00
|
|
|
|
}
|
2023-05-12 00:31:20 +08:00
|
|
|
|
|
|
|
|
|
if(vf->compress_type!=TextureCompressType::NONE)
|
2024-07-27 20:52:58 +08:00
|
|
|
|
std::cout<<" use "<<TextureCompressTypeName[size_t(vf->compress_type)]<<" compress.";
|
2023-05-12 00:31:20 +08:00
|
|
|
|
else
|
|
|
|
|
std::cout<<std::setw(4)<<vf->bytes<<" bytes/pixel.";
|
2019-08-14 16:36:02 +08:00
|
|
|
|
|
|
|
|
|
std::cout<<std::endl;
|
2019-08-13 17:08:37 +08:00
|
|
|
|
|
2019-08-14 16:36:02 +08:00
|
|
|
|
++vf;
|
2019-08-13 17:08:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-15 11:00:15 +08:00
|
|
|
|
delete inst;
|
2019-11-13 16:01:13 +08:00
|
|
|
|
|
2019-08-13 17:08:37 +08:00
|
|
|
|
return 0;
|
|
|
|
|
}
|