新的颜色格式属性记录
This commit is contained in:
parent
65805cd6cc
commit
9b961ffe08
@ -16,12 +16,7 @@ class PhysicalDevice
|
||||
List<VkLayerProperties> layer_properties;
|
||||
List<VkExtensionProperties> extension_properties;
|
||||
|
||||
Set<VkFormat> optimal_color_format;
|
||||
Set<VkFormat> optimal_depth_format;
|
||||
Set<VkFormat> linear_color_format;
|
||||
Set<VkFormat> linear_depth_format;
|
||||
Set<VkFormat> buffer_color_format;
|
||||
Set<VkFormat> buffer_depth_format;
|
||||
VkFormatProperties format_properties[VK_FORMAT_RANGE_SIZE];
|
||||
|
||||
void InitFormatSupport();
|
||||
|
||||
@ -80,13 +75,17 @@ public:
|
||||
|
||||
return fp;
|
||||
}
|
||||
|
||||
bool IsOptimalTilingFeatures(const VkFormat format,const VkFormatFeatureFlags flag)const
|
||||
{
|
||||
if(format<VK_FORMAT_BEGIN_RANGE||format>VK_FORMAT_END_RANGE)
|
||||
return(false);
|
||||
|
||||
return(format_properties[format].optimalTilingFeatures&flag);
|
||||
}
|
||||
|
||||
bool IsOptimalColorFormat(const VkFormat format)const{return optimal_color_format.IsMember(format);}
|
||||
bool IsOptimalDepthFormat(const VkFormat format)const{return optimal_depth_format.IsMember(format);}
|
||||
bool IsLinearColorFormat(const VkFormat format)const{return linear_color_format.IsMember(format);}
|
||||
bool IsLinearDepthFormat(const VkFormat format)const{return linear_depth_format.IsMember(format);}
|
||||
bool IsBufferColorFormat(const VkFormat format)const{return buffer_color_format.IsMember(format);}
|
||||
bool IsBufferDepthFormat(const VkFormat format)const{return buffer_depth_format.IsMember(format);}
|
||||
bool IsColorAttachmentOptimal(const VkFormat format)const{return IsOptimalTilingFeatures(format,VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT);}
|
||||
bool IsDepthAttachmentOptimal(const VkFormat format)const{return IsOptimalTilingFeatures(format,VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT);}
|
||||
|
||||
VkFormat GetDepthFormat(bool lower_to_high=true)const;
|
||||
VkFormat GetDepthStencilFormat(bool lower_to_high=true)const;
|
||||
|
@ -109,7 +109,7 @@ bool Device::CreateColorAttachment( List<VkAttachmentReference> &ref_list,List<V
|
||||
|
||||
for(uint i=0;i<color_format.GetCount();i++)
|
||||
{
|
||||
if(!attr->physical_device->IsOptimalColorFormat(*cf))
|
||||
if(!attr->physical_device->IsColorAttachmentOptimal(*cf))
|
||||
return(false);
|
||||
|
||||
++cf;
|
||||
@ -143,7 +143,7 @@ bool Device::CreateColorAttachment( List<VkAttachmentReference> &ref_list,List<V
|
||||
|
||||
bool Device::CreateDepthAttachment( List<VkAttachmentReference> &ref_list,List<VkAttachmentDescription> &desc_list,const VkFormat &depth_format,const VkImageLayout depth_final_layout)
|
||||
{
|
||||
if(!attr->physical_device->IsOptimalDepthFormat(depth_format))
|
||||
if(!attr->physical_device->IsDepthAttachmentOptimal(depth_format))
|
||||
return(false);
|
||||
|
||||
{
|
||||
@ -184,14 +184,14 @@ RenderPass *Device::CreateRenderPass( const List<VkAttachmentDescription> &des
|
||||
|
||||
for(uint i=0;i<color_format.GetCount();i++)
|
||||
{
|
||||
if(!attr->physical_device->IsOptimalColorFormat(*cf))
|
||||
if(!attr->physical_device->IsColorAttachmentOptimal(*cf))
|
||||
return(false);
|
||||
|
||||
++cf;
|
||||
}
|
||||
}
|
||||
|
||||
if(!attr->physical_device->IsOptimalDepthFormat(depth_format))
|
||||
if(!attr->physical_device->IsDepthAttachmentOptimal(depth_format))
|
||||
return(false);
|
||||
|
||||
VkRenderPassCreateInfo rp_info;
|
||||
@ -214,10 +214,10 @@ RenderPass *Device::CreateRenderPass( const List<VkAttachmentDescription> &des
|
||||
|
||||
RenderPass *Device::CreateRenderPass(VkFormat color_format,VkFormat depth_format,VkImageLayout color_final_layout,VkImageLayout depth_final_layout)
|
||||
{
|
||||
if(!attr->physical_device->IsOptimalColorFormat(color_format))
|
||||
if(!attr->physical_device->IsColorAttachmentOptimal(color_format))
|
||||
return(false);
|
||||
|
||||
if(!attr->physical_device->IsOptimalDepthFormat(depth_format))
|
||||
if(!attr->physical_device->IsDepthAttachmentOptimal(depth_format))
|
||||
return(false);
|
||||
|
||||
List<VkAttachmentReference> ref_list;
|
||||
|
@ -96,21 +96,13 @@ const bool PhysicalDevice::CheckMemoryType(uint32_t typeBits,VkMemoryPropertyFla
|
||||
|
||||
void PhysicalDevice::InitFormatSupport()
|
||||
{
|
||||
VkFormatProperties formatProps;
|
||||
VkFormatProperties *fp=format_properties;
|
||||
|
||||
for(uint32 i=VK_FORMAT_BEGIN_RANGE;i<=VK_FORMAT_END_RANGE;i++)
|
||||
{
|
||||
hgl_zero(formatProps);
|
||||
|
||||
vkGetPhysicalDeviceFormatProperties(physical_device,(VkFormat)i,&formatProps);
|
||||
|
||||
if(formatProps.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT )optimal_color_format.Add((VkFormat)i);
|
||||
if(formatProps.linearTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT )linear_color_format.Add((VkFormat)i);
|
||||
if(formatProps.bufferFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT )buffer_color_format.Add((VkFormat)i);
|
||||
|
||||
if(formatProps.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)optimal_depth_format.Add((VkFormat)i);
|
||||
if(formatProps.linearTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)linear_depth_format.Add((VkFormat)i);
|
||||
if(formatProps.bufferFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)buffer_depth_format.Add((VkFormat)i);
|
||||
vkGetPhysicalDeviceFormatProperties(physical_device,(VkFormat)i,fp);
|
||||
|
||||
++fp;
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,7 +120,7 @@ VkFormat PhysicalDevice::GetDepthFormat(bool lower_to_high)const
|
||||
|
||||
for (auto& format : depthFormats)
|
||||
{
|
||||
if(IsOptimalDepthFormat(format))
|
||||
if(IsDepthAttachmentOptimal(format))
|
||||
{
|
||||
if(lower_to_high)
|
||||
return format;
|
||||
@ -153,7 +145,7 @@ VkFormat PhysicalDevice::GetDepthStencilFormat(bool lower_to_high)const
|
||||
|
||||
for (auto& format : depthStencilFormats)
|
||||
{
|
||||
if(IsOptimalDepthFormat(format))
|
||||
if(IsDepthAttachmentOptimal(format))
|
||||
{
|
||||
if(lower_to_high)
|
||||
return format;
|
||||
|
Loading…
x
Reference in New Issue
Block a user