added VulkanDeviceCreater::ChooseSurfaceFormat
This commit is contained in:
@@ -11,27 +11,6 @@
|
||||
#include<hgl/graph/VKDeviceRenderPassManage.h>
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
void LogSurfaceFormat(const List<VkSurfaceFormatKHR> &surface_format_list)
|
||||
{
|
||||
const uint32_t format_count=surface_format_list.GetCount();
|
||||
const VkSurfaceFormatKHR *sf=surface_format_list.GetData();
|
||||
|
||||
LOG_INFO(OS_TEXT("Current physics device support ")+OSString::numberOf(format_count)+OS_TEXT(" surface format"));
|
||||
|
||||
const VulkanFormat *vf;
|
||||
const VulkanColorSpace *cs;
|
||||
|
||||
for(uint32_t i=0;i<format_count;i++)
|
||||
{
|
||||
vf=GetVulkanFormat(sf->format);
|
||||
cs=GetVulkanColorSpace(sf->colorSpace);
|
||||
|
||||
LOG_INFO(" "+AnsiString::numberOf(i)+": "+AnsiString(vf->name)+", "+AnsiString(cs->name));
|
||||
|
||||
++sf;
|
||||
}
|
||||
}
|
||||
|
||||
GPUDevice::GPUDevice(GPUDeviceAttribute *da)
|
||||
{
|
||||
attr=da;
|
||||
@@ -46,8 +25,6 @@ GPUDevice::GPUDevice(GPUDeviceAttribute *da)
|
||||
|
||||
texture_cmd_buf=CreateTextureCommandBuffer();
|
||||
texture_queue=CreateQueue();
|
||||
|
||||
LogSurfaceFormat(attr->surface_formats_list);
|
||||
}
|
||||
|
||||
GPUDevice::~GPUDevice()
|
||||
|
@@ -14,7 +14,6 @@ GPUDeviceAttribute::GPUDeviceAttribute(VulkanInstance *inst,const GPUPhysicalDev
|
||||
surface=s;
|
||||
|
||||
RefreshSurfaceCaps();
|
||||
GetSurfaceFormatList();
|
||||
GetSurfacePresentMode();
|
||||
GetQueueFamily();
|
||||
}
|
||||
@@ -83,49 +82,6 @@ void GPUDeviceAttribute::RefreshSurfaceCaps()
|
||||
}
|
||||
}
|
||||
|
||||
void GPUDeviceAttribute::GetSurfaceFormatList()
|
||||
{
|
||||
VkPhysicalDevice pdevice = *physical_device;
|
||||
|
||||
{
|
||||
uint32_t format_count;
|
||||
|
||||
surface_format.format = PF_A2BGR10UN;
|
||||
surface_format.colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
|
||||
|
||||
if (vkGetPhysicalDeviceSurfaceFormatsKHR(pdevice, surface, &format_count, nullptr) == VK_SUCCESS)
|
||||
{
|
||||
surface_formats_list.SetCount(format_count);
|
||||
|
||||
if (vkGetPhysicalDeviceSurfaceFormatsKHR(pdevice, surface, &format_count, surface_formats_list.GetData()) != VK_SUCCESS)
|
||||
{
|
||||
surface_formats_list.Clear();
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// VkSurfaceFormatKHR *sf = surface_formats_list.GetData();
|
||||
|
||||
// if (format_count == 1 && sf->format == VK_FORMAT_UNDEFINED)
|
||||
// {
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// surface_format.format=VK_FORMAT_UNDEFINED;
|
||||
|
||||
// for(uint32_t i=0;i<format_count;i++)
|
||||
// {
|
||||
// if(sf->format>surface_format.format
|
||||
// &&sf->colorSpace==VK_COLOR_SPACE_SRGB_NONLINEAR_KHR)
|
||||
// surface_format=*sf;
|
||||
|
||||
// ++sf;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GPUDeviceAttribute::GetSurfacePresentMode()
|
||||
{
|
||||
uint32_t mode_count;
|
||||
|
@@ -16,6 +16,29 @@ VkPipelineCache CreatePipelineCache(VkDevice device,const VkPhysicalDeviceProper
|
||||
#ifdef _DEBUG
|
||||
DebugMaker *CreateDebugMaker(VkDevice);
|
||||
DebugUtils *CreateDebugUtils(VkDevice);
|
||||
|
||||
void LogSurfaceFormat(const VkSurfaceFormatKHR *surface_format_list,const uint32_t format_count,const uint32_t select)
|
||||
{
|
||||
const VkSurfaceFormatKHR *sf=surface_format_list;
|
||||
|
||||
std::cout<<"Current physics device support "<<format_count<<" surface format"<<std::endl;
|
||||
|
||||
const VulkanFormat *vf;
|
||||
const VulkanColorSpace *cs;
|
||||
|
||||
for(uint32_t i=0;i<format_count;i++)
|
||||
{
|
||||
vf=GetVulkanFormat(sf->format);
|
||||
cs=GetVulkanColorSpace(sf->colorSpace);
|
||||
|
||||
if(select==i)
|
||||
std::cout<<" * "<<i<<": "<<vf->name<<", "<<cs->name<<std::endl;
|
||||
else
|
||||
std::cout<<" "<<i<<": "<<vf->name<<", "<<cs->name<<std::endl;
|
||||
|
||||
++sf;
|
||||
}
|
||||
}
|
||||
#endif//_DEBUG
|
||||
|
||||
namespace
|
||||
@@ -197,6 +220,46 @@ VkDevice VulkanDeviceCreater::CreateDevice(const uint32_t graphics_family)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void VulkanDeviceCreater::ChooseSurfaceFormat()
|
||||
{
|
||||
uint32_t format_count;
|
||||
|
||||
if (vkGetPhysicalDeviceSurfaceFormatsKHR(*physical_device, surface, &format_count, nullptr) != VK_SUCCESS)
|
||||
return;
|
||||
|
||||
AutoDeleteArray<VkSurfaceFormatKHR> surface_formats_list(format_count);
|
||||
|
||||
if (vkGetPhysicalDeviceSurfaceFormatsKHR(*physical_device, surface, &format_count, surface_formats_list) == VK_SUCCESS)
|
||||
{
|
||||
int index=-1;
|
||||
int result;
|
||||
uint32_t sel=0;
|
||||
|
||||
for(uint32_t i=0;i<format_count;i++)
|
||||
{
|
||||
result=perfer_color_formats->Find(surface_formats_list[i].format);
|
||||
|
||||
if(result>index)
|
||||
{
|
||||
surface_format=surface_formats_list[i];
|
||||
|
||||
index=result;
|
||||
sel=i;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
LogSurfaceFormat(surface_formats_list,format_count,sel);
|
||||
#endif//_DEBUG
|
||||
|
||||
if(index!=-1)
|
||||
return;
|
||||
}
|
||||
|
||||
surface_format.format=PF_RGBA8s;
|
||||
surface_format.colorSpace=VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
|
||||
}
|
||||
|
||||
GPUDevice *VulkanDeviceCreater::CreateRenderDevice()
|
||||
{
|
||||
GPUDeviceAttribute *device_attr=new GPUDeviceAttribute(instance,physical_device,surface);
|
||||
@@ -209,6 +272,10 @@ GPUDevice *VulkanDeviceCreater::CreateRenderDevice()
|
||||
SetDeviceExtension(&ext_list,physical_device,require);
|
||||
SetDeviceFeatures(&features,physical_device->GetFeatures10(),require);
|
||||
|
||||
ChooseSurfaceFormat();
|
||||
|
||||
device_attr->surface_format=surface_format;
|
||||
|
||||
device_attr->device=CreateDevice(device_attr->graphics_family);
|
||||
|
||||
if(!device_attr->device)
|
||||
@@ -322,7 +389,6 @@ GPUDevice *VulkanDeviceCreater::Create()
|
||||
OutputPhysicalDeviceCaps(physical_device);
|
||||
#endif//_DEBUG
|
||||
|
||||
|
||||
if(!RequirementCheck())
|
||||
return(false);
|
||||
|
||||
|
@@ -136,12 +136,12 @@ Material *GPUDevice::CreateMaterial(const UTF8String &mtl_name,ShaderModuleMap *
|
||||
|
||||
// 但只要我们限制一个MI数据不超过64/256字节,一次渲染不超过256种材质实例,就无需解决此问题。
|
||||
|
||||
if(desc_manager->hasSet(DescriptorSetType::PerMaterial))
|
||||
{
|
||||
data->mi_size
|
||||
data->mi_data=new uint8[data->mi_size*256];
|
||||
}
|
||||
else
|
||||
//if(desc_manager->hasSet(DescriptorSetType::PerMaterial))
|
||||
//{
|
||||
// data->mi_size
|
||||
// data->mi_data=new uint8[data->mi_size*256];
|
||||
//}
|
||||
//else
|
||||
{
|
||||
data->mi_size=0;
|
||||
data->mi_data=nullptr;
|
||||
|
Reference in New Issue
Block a user