Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Unified Diff: gpu/vulkan/vulkan_surface.cc

Issue 1963983002: Support vulkan surface formats for Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/vulkan/vulkan_surface.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/vulkan/vulkan_surface.cc
diff --git a/gpu/vulkan/vulkan_surface.cc b/gpu/vulkan/vulkan_surface.cc
index 63e01c36c32c42dfbb2c86453760d6214846d9b5..4344362ed9f981ecee23bf55aebe25d91ce65ed4 100644
--- a/gpu/vulkan/vulkan_surface.cc
+++ b/gpu/vulkan/vulkan_surface.cc
@@ -20,12 +20,14 @@
namespace gpu {
namespace {
-const VkFormat kNativeVkFormat[] = {
- VK_FORMAT_B8G8R8A8_UNORM, // FORMAT_BGRA8888,
+const VkFormat kPreferredVkFormats32[] = {
+ VK_FORMAT_B8G8R8A8_UNORM, // FORMAT_BGRA8888,
+ VK_FORMAT_R8G8B8A8_UNORM, // FORMAT_RGBA8888,
+};
+
+const VkFormat kPreferredVkFormats16[] = {
VK_FORMAT_R5G6B5_UNORM_PACK16, // FORMAT_RGB565,
};
-static_assert(arraysize(kNativeVkFormat) == VulkanSurface::NUM_SURFACE_FORMATS,
- "Array size for kNativeVkFormat must match surface formats.");
} // namespace
@@ -94,19 +96,30 @@ class VulkanWSISurface : public VulkanSurface {
return false;
}
- const VkFormat preferred_format = kNativeVkFormat[format];
+ const VkFormat* preferred_formats = (format == FORMAT_RGBA_32)
+ ? kPreferredVkFormats32
+ : kPreferredVkFormats16;
+ unsigned int size = (format == FORMAT_RGBA_32)
+ ? arraysize(kPreferredVkFormats32)
+ : arraysize(kPreferredVkFormats16);
+
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;
+ unsigned int counter = 0;
+ while (counter < size && format_set == false) {
+ if (supported_format.format == preferred_formats[counter]) {
+ surface_format_ = supported_format;
+ surface_format_.colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
+ format_set = true;
+ }
+ counter++;
}
+ if (format_set)
+ break;
}
if (!format_set) {
DLOG(ERROR) << "Format not supported.";
« no previous file with comments | « gpu/vulkan/vulkan_surface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698