fixed a bug that don't copy color_space data.

This commit is contained in:
hyzboy 2021-09-23 15:19:09 +08:00
parent 1e81a9f4c4
commit 45f5d0d5be
6 changed files with 21 additions and 19 deletions

View File

@ -74,7 +74,8 @@ public:
VkDescriptorPool GetDescriptorPool () {return attr->desc_pool;}
VkPipelineCache GetPipelineCache () {return attr->pipeline_cache;}
const VkFormat GetSurfaceFormat ()const {return attr->format;}
const VkFormat GetSurfaceFormat ()const {return attr->surface_format.format;}
const VkColorSpaceKHR GetColorSpace ()const {return attr->surface_format.colorSpace;}
VkQueue GetGraphicsQueue () {return attr->graphics_queue;}
RenderPass * GetRenderPass () {return device_render_pass;}

View File

@ -25,8 +25,8 @@ struct GPUDeviceAttribute
List<VkQueueFamilyProperties> family_properties;
List<VkBool32> supports_present;
List<VkSurfaceFormatKHR> surface_formts;
VkFormat format;
List<VkSurfaceFormatKHR> surface_formats_list;
VkSurfaceFormatKHR surface_format;
List<VkPresentModeKHR> present_modes;
VkSurfaceTransformFlagBitsKHR preTransform;

View File

@ -109,7 +109,7 @@ SET(VK_MEMORY_SOURCE ${SG_INCLUDE_PATH}/VKMemory.h
Vulkan/VKMemoryAllocator.cpp
Vulkan/VKBuffer.cpp
)
SET(VK_DEVICE_SOURCE ${SG_INCLUDE_PATH}/VKDevice.h
${SG_INCLUDE_PATH}/VKDeviceAttribute.h
Vulkan/VKDeviceAttribute.cpp

View File

@ -71,29 +71,30 @@ void GPUDeviceAttribute::Refresh()
{
uint32_t format_count;
surface_format.format = VK_FORMAT_B8G8R8A8_SRGB;
surface_format.colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
if (vkGetPhysicalDeviceSurfaceFormatsKHR(pdevice, surface, &format_count, nullptr) == VK_SUCCESS)
{
surface_formts.SetCount(format_count);
surface_formats_list.SetCount(format_count);
if (vkGetPhysicalDeviceSurfaceFormatsKHR(pdevice, surface, &format_count, surface_formts.GetData()) != VK_SUCCESS)
if (vkGetPhysicalDeviceSurfaceFormatsKHR(pdevice, surface, &format_count, surface_formats_list.GetData()) != VK_SUCCESS)
{
surface_formts.Clear();
format = VK_FORMAT_B8G8R8A8_UNORM;
surface_formats_list.Clear();
}
else
{
VkSurfaceFormatKHR *sf = surface_formts.GetData();
VkSurfaceFormatKHR *sf = surface_formats_list.GetData();
if (format_count == 1 && sf->format == VK_FORMAT_UNDEFINED)
format = VK_FORMAT_B8G8R8A8_UNORM;
else
if (format_count>1)
{
format=VK_FORMAT_UNDEFINED;
surface_format.format=VK_FORMAT_UNDEFINED;
for(uint32_t i=0;i<format_count;i++)
{
if(sf->format>format)
format=sf->format;
if(sf->format>surface_format.format)
surface_format=*sf;
++sf;
}

View File

@ -8,7 +8,7 @@ void GPUDevice::InitRenderPassManage()
{
render_pass_manage=new DeviceRenderPassManage(attr->device,attr->pipeline_cache);
SwapchainRenderbufferInfo rbi(attr->format,attr->physical_device->GetDepthFormat());
SwapchainRenderbufferInfo rbi(attr->surface_format.format,attr->physical_device->GetDepthFormat());
device_render_pass=render_pass_manage->AcquireRenderPass(&rbi);
}

View File

@ -24,8 +24,8 @@ namespace
swapchain_ci.flags =0;
swapchain_ci.surface =dev_attr->surface;
swapchain_ci.minImageCount =3;//rsa->surface_caps.minImageCount;
swapchain_ci.imageFormat =dev_attr->format;
swapchain_ci.imageColorSpace =VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
swapchain_ci.imageFormat =dev_attr->surface_format.format;
swapchain_ci.imageColorSpace =dev_attr->surface_format.colorSpace;
swapchain_ci.imageExtent =extent;
swapchain_ci.imageArrayLayers =1;
swapchain_ci.imageUsage =VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
@ -79,7 +79,7 @@ bool GPUDevice::CreateSwapchainColorTexture()
return(false);
for(VkImage ip:sc_images)
swapchain->sc_color.Add(CreateTexture2D(new SwapchainColorTextureCreateInfo(attr->format,swapchain->extent,ip)));
swapchain->sc_color.Add(CreateTexture2D(new SwapchainColorTextureCreateInfo(attr->surface_format.format,swapchain->extent,ip)));
return(true);
}