Chromium Code Reviews| Index: gpu/vulkan/vulkan_surface.cc |
| diff --git a/gpu/vulkan/vulkan_surface.cc b/gpu/vulkan/vulkan_surface.cc |
| index 63e01c36c32c42dfbb2c86453760d6214846d9b5..4a678afaf39ece9b41a8b06f87309c0d1d0a1c46 100644 |
| --- a/gpu/vulkan/vulkan_surface.cc |
| +++ b/gpu/vulkan/vulkan_surface.cc |
| @@ -22,9 +22,11 @@ namespace gpu { |
| namespace { |
| const VkFormat kNativeVkFormat[] = { |
| VK_FORMAT_B8G8R8A8_UNORM, // FORMAT_BGRA8888, |
| + VK_FORMAT_R8G8B8A8_UNORM, // FORMAT_RGBA8888, |
| VK_FORMAT_R5G6B5_UNORM_PACK16, // FORMAT_RGB565, |
| }; |
| -static_assert(arraysize(kNativeVkFormat) == VulkanSurface::NUM_SURFACE_FORMATS, |
| +static_assert(arraysize(kNativeVkFormat) == |
| + VulkanSurface::NUM_SURFACE_FORMATS + 1, |
| "Array size for kNativeVkFormat must match surface formats."); |
| } // namespace |
| @@ -95,17 +97,28 @@ class VulkanWSISurface : public VulkanSurface { |
| } |
| const VkFormat preferred_format = kNativeVkFormat[format]; |
|
piman
2016/05/10 19:52:44
nit: this is not used anymore, please remove.
sohanjg
2016/05/11 09:25:50
Acknowledged.
|
| + |
| + std::vector<VkFormat> preferred_formats(VulkanSurface::NUM_SURFACE_FORMATS); |
| + if (format == VulkanSurface::Format::FORMAT_RGBA_32) { |
| + preferred_formats[0] = kNativeVkFormat[format]; |
| + preferred_formats[1] = kNativeVkFormat[format + 1]; |
| + } else if (format == VulkanSurface::Format::FORMAT_RGB_16) { |
| + preferred_formats[0] = kNativeVkFormat[format + 1]; |
| + } |
|
piman
2016/05/10 19:52:44
I think we could instead have 2 arrays, kPreferred
sohanjg
2016/05/11 09:25:50
Done.
|
| + |
| if (formats.size() == 1 && VK_FORMAT_UNDEFINED == formats[0].format) { |
| - surface_format_.format = preferred_format; |
| + surface_format_.format = preferred_formats[0]; |
| surface_format_.colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; |
| } else { |
| bool format_set = false; |
| for (VkSurfaceFormatKHR supported_format : formats) { |
| - if (supported_format.format == preferred_format) { |
| - surface_format_ = supported_format; |
| - surface_format_.colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; |
| - format_set = true; |
| - break; |
| + for (VkFormat fmt : preferred_formats) { |
| + if (supported_format.format == fmt) { |
| + surface_format_ = supported_format; |
| + surface_format_.colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; |
| + format_set = true; |
| + break; |
| + } |
| } |
| } |
| if (!format_set) { |