Commit f237d4c8 authored by Miguel Casas-Sanchez's avatar Miguel Casas-Sanchez Committed by Commit Bot

Mac gl_unittests: enable GLImageBindTest BGRX_1010102 (2nd go)

This CL relands crrev.com/c/886543, enabling the GLImageBindTest for
GLImageIOSUrface with the BufferFormat BGRX_1010102.

The CL also adds a provision to swizzle the color channels when running
on nVidia on High Sierra to workaround some bug that can be repro'ed on
the bots and stand alone laptops.

Bug: 803473
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I5472606a82b393fe1d2375b3c644e836ea7f12cf
Reviewed-on: https://chromium-review.googlesource.com/890007Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533313}
parent 6bf91042
......@@ -5,6 +5,9 @@
#include <stddef.h>
#include <stdint.h>
#include "base/mac/mac_util.h"
#include "base/strings/string_util.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/buffer_format_util.h"
#include "ui/gfx/mac/io_surface.h"
......@@ -37,6 +40,11 @@ class GLImageIOSurfaceTestDelegate : public GLImageTestDelegateBase {
IOReturn status = IOSurfaceLock(surface_ref, 0, nullptr);
EXPECT_NE(status, kIOReturnCannotLock);
static const bool is_nvidia_and_mac_os_x_at_least_10_13 =
base::mac::IsAtLeastOS10_13() &&
base::StartsWith(reinterpret_cast<const char*>(glGetString(GL_VENDOR)),
"nvidia", base::CompareCase::INSENSITIVE_ASCII);
uint8_t corrected_color[4];
if (format == gfx::BufferFormat::RGBA_8888) {
// GL_RGBA is not supported by CGLTexImageIOSurface2D(), so we pretend it
......@@ -46,6 +54,16 @@ class GLImageIOSurfaceTestDelegate : public GLImageTestDelegateBase {
corrected_color[1] = color[1];
corrected_color[2] = color[0];
corrected_color[3] = color[3];
} else if (format == gfx::BufferFormat::BGRX_1010102 &&
is_nvidia_and_mac_os_x_at_least_10_13) {
// Framebuffers are wrongly interpreted as BGRA when using GL_RGB10_A2
// textures and/or IOSurfaces on High Sierra using nVidia GPUs; swizzle
// the channels here in advance https://crbug.com/803473,
// http://www.openradar.me/36824694, rdar://36824694.
corrected_color[0] = color[2];
corrected_color[1] = color[1];
corrected_color[2] = color[0];
corrected_color[3] = color[3];
} else {
memcpy(corrected_color, color, arraysize(corrected_color));
}
......@@ -109,11 +127,11 @@ INSTANTIATE_TYPED_TEST_CASE_P(GLImageIOSurface,
GLImageRGBTestTypes);
using GLImageBindTestTypes = testing::Types<
// TODO(mcasas): enable BGRX_1010102, https://crbug.com/803473.
GLImageIOSurfaceTestDelegate<gfx::BufferFormat::BGRA_8888>,
GLImageIOSurfaceTestDelegate<gfx::BufferFormat::RGBA_8888>,
GLImageIOSurfaceTestDelegate<gfx::BufferFormat::BGRX_8888>,
GLImageIOSurfaceTestDelegate<gfx::BufferFormat::RGBA_F16>>;
GLImageIOSurfaceTestDelegate<gfx::BufferFormat::RGBA_F16>,
GLImageIOSurfaceTestDelegate<gfx::BufferFormat::BGRX_1010102>>;
INSTANTIATE_TYPED_TEST_CASE_P(GLImageIOSurface,
GLImageBindTest,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment