Commit 0e16a89b authored by Miguel Casas's avatar Miguel Casas Committed by Commit Bot

ui: s/XR30/AR30/ and support it for SCANOUT

This CL replaces the DRM specific XR30 with AR30 where
appropriate, and adds the necessary entries to support
AR30 with SCANOUT usage.

This format started being supported with the recent Mesa
uprev.

Test: forcing BGRA_1010102 as DisplaySnapshot::PrimaryFormat,
and allowing for only an opaque FB (ToT wants both opaque and
normal) the primary plane of the device is indeed XR30 as per
/sys/kernel/debug/dri/0/state).
and
 gl_unittests  --gtest_also_run_disabled_tests
and
 ozone_gl_unittests  --gtest_also_run_disabled_tests
AR30 test cases passing.

Bug: 949260
Change-Id: I852433d30a5243f682b7bb9b9e8bbb0184b1d4d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2068825
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Reviewed-by: default avatarMichael Spang <spang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747122}
parent b2fbd398
...@@ -80,7 +80,8 @@ GPU_EXPORT bool NativeBufferNeedsPlatformSpecificTextureTarget( ...@@ -80,7 +80,8 @@ GPU_EXPORT bool NativeBufferNeedsPlatformSpecificTextureTarget(
format == gfx::BufferFormat::BGRA_8888 || format == gfx::BufferFormat::BGRA_8888 ||
format == gfx::BufferFormat::RGBX_8888 || format == gfx::BufferFormat::RGBX_8888 ||
format == gfx::BufferFormat::BGRX_8888 || format == gfx::BufferFormat::BGRX_8888 ||
format == gfx::BufferFormat::RGBA_1010102) { format == gfx::BufferFormat::RGBA_1010102 ||
format == gfx::BufferFormat::BGRA_1010102) {
return false; return false;
} }
#elif defined(OS_ANDROID) #elif defined(OS_ANDROID)
......
...@@ -37,9 +37,10 @@ class GPU_GLES2_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> { ...@@ -37,9 +37,10 @@ class GPU_GLES2_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> {
FeatureFlags(); FeatureFlags();
GpuMemoryBufferFormatSet gpu_memory_buffer_formats = { GpuMemoryBufferFormatSet gpu_memory_buffer_formats = {
gfx::BufferFormat::BGR_565, gfx::BufferFormat::RGBA_4444, gfx::BufferFormat::BGR_565, gfx::BufferFormat::RGBA_4444,
gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::RGBX_8888, gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::RGBX_8888,
gfx::BufferFormat::YVU_420, gfx::BufferFormat::RGBA_1010102, gfx::BufferFormat::YVU_420, gfx::BufferFormat::RGBA_1010102,
gfx::BufferFormat::BGRA_1010102,
}; };
// Use glBlitFramebuffer() and glRenderbufferStorageMultisample() with // Use glBlitFramebuffer() and glRenderbufferStorageMultisample() with
// GL_EXT_framebuffer_multisample-style semantics (as opposed to // GL_EXT_framebuffer_multisample-style semantics (as opposed to
......
...@@ -44,6 +44,7 @@ size_t AlphaBitsForBufferFormat(BufferFormat format) { ...@@ -44,6 +44,7 @@ size_t AlphaBitsForBufferFormat(BufferFormat format) {
return 4; return 4;
case BufferFormat::RGBA_8888: case BufferFormat::RGBA_8888:
return 8; return 8;
case BufferFormat::BGRA_1010102:
case BufferFormat::RGBA_1010102: case BufferFormat::RGBA_1010102:
return 2; return 2;
case BufferFormat::BGRA_8888: case BufferFormat::BGRA_8888:
...@@ -56,7 +57,6 @@ size_t AlphaBitsForBufferFormat(BufferFormat format) { ...@@ -56,7 +57,6 @@ size_t AlphaBitsForBufferFormat(BufferFormat format) {
case BufferFormat::BGR_565: case BufferFormat::BGR_565:
case BufferFormat::RGBX_8888: case BufferFormat::RGBX_8888:
case BufferFormat::BGRX_8888: case BufferFormat::BGRX_8888:
case BufferFormat::BGRA_1010102:
case BufferFormat::YVU_420: case BufferFormat::YVU_420:
case BufferFormat::YUV_420_BIPLANAR: case BufferFormat::YUV_420_BIPLANAR:
case BufferFormat::P010: case BufferFormat::P010:
......
...@@ -40,7 +40,7 @@ int GetFourCCFormatFromBufferFormat(gfx::BufferFormat format) { ...@@ -40,7 +40,7 @@ int GetFourCCFormatFromBufferFormat(gfx::BufferFormat format) {
case gfx::BufferFormat::BGRX_8888: case gfx::BufferFormat::BGRX_8888:
return DRM_FORMAT_XRGB8888; return DRM_FORMAT_XRGB8888;
case gfx::BufferFormat::BGRA_1010102: case gfx::BufferFormat::BGRA_1010102:
return DRM_FORMAT_XRGB2101010; return DRM_FORMAT_ARGB2101010;
case gfx::BufferFormat::RGBA_1010102: case gfx::BufferFormat::RGBA_1010102:
return DRM_FORMAT_ABGR2101010; return DRM_FORMAT_ABGR2101010;
case gfx::BufferFormat::RGBA_F16: case gfx::BufferFormat::RGBA_F16:
...@@ -69,7 +69,7 @@ gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) { ...@@ -69,7 +69,7 @@ gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) {
return gfx::BufferFormat::BGRA_8888; return gfx::BufferFormat::BGRA_8888;
case DRM_FORMAT_XRGB8888: case DRM_FORMAT_XRGB8888:
return gfx::BufferFormat::BGRX_8888; return gfx::BufferFormat::BGRX_8888;
case DRM_FORMAT_XRGB2101010: case DRM_FORMAT_ARGB2101010:
return gfx::BufferFormat::BGRA_1010102; return gfx::BufferFormat::BGRA_1010102;
case DRM_FORMAT_ABGR2101010: case DRM_FORMAT_ABGR2101010:
return gfx::BufferFormat::RGBA_1010102; return gfx::BufferFormat::RGBA_1010102;
...@@ -95,7 +95,7 @@ bool IsValidBufferFormat(uint32_t current_format) { ...@@ -95,7 +95,7 @@ bool IsValidBufferFormat(uint32_t current_format) {
case DRM_FORMAT_XBGR8888: case DRM_FORMAT_XBGR8888:
case DRM_FORMAT_ARGB8888: case DRM_FORMAT_ARGB8888:
case DRM_FORMAT_XRGB8888: case DRM_FORMAT_XRGB8888:
case DRM_FORMAT_XRGB2101010: case DRM_FORMAT_ARGB2101010:
case DRM_FORMAT_ABGR2101010: case DRM_FORMAT_ABGR2101010:
case DRM_FORMAT_RGB565: case DRM_FORMAT_RGB565:
case DRM_FORMAT_NV12: case DRM_FORMAT_NV12:
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#define DRM_FORMAT_XRGB8888 FOURCC('X', 'R', '2', '4') #define DRM_FORMAT_XRGB8888 FOURCC('X', 'R', '2', '4')
#define DRM_FORMAT_XBGR8888 FOURCC('X', 'B', '2', '4') #define DRM_FORMAT_XBGR8888 FOURCC('X', 'B', '2', '4')
#define DRM_FORMAT_ABGR2101010 FOURCC('A', 'B', '3', '0') #define DRM_FORMAT_ABGR2101010 FOURCC('A', 'B', '3', '0')
#define DRM_FORMAT_XRGB2101010 FOURCC('X', 'R', '3', '0') #define DRM_FORMAT_ARGB2101010 FOURCC('A', 'R', '3', '0')
#define DRM_FORMAT_YVU420 FOURCC('Y', 'V', '1', '2') #define DRM_FORMAT_YVU420 FOURCC('Y', 'V', '1', '2')
#define DRM_FORMAT_NV12 FOURCC('N', 'V', '1', '2') #define DRM_FORMAT_NV12 FOURCC('N', 'V', '1', '2')
#define DRM_FORMAT_P010 FOURCC('P', '0', '1', '0') #define DRM_FORMAT_P010 FOURCC('P', '0', '1', '0')
...@@ -72,7 +72,7 @@ EGLint FourCC(gfx::BufferFormat format) { ...@@ -72,7 +72,7 @@ EGLint FourCC(gfx::BufferFormat format) {
case gfx::BufferFormat::RGBA_1010102: case gfx::BufferFormat::RGBA_1010102:
return DRM_FORMAT_ABGR2101010; return DRM_FORMAT_ABGR2101010;
case gfx::BufferFormat::BGRA_1010102: case gfx::BufferFormat::BGRA_1010102:
return DRM_FORMAT_XRGB2101010; return DRM_FORMAT_ARGB2101010;
case gfx::BufferFormat::YVU_420: case gfx::BufferFormat::YVU_420:
return DRM_FORMAT_YVU420; return DRM_FORMAT_YVU420;
case gfx::BufferFormat::YUV_420_BIPLANAR: case gfx::BufferFormat::YUV_420_BIPLANAR:
...@@ -104,6 +104,8 @@ gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) { ...@@ -104,6 +104,8 @@ gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) {
return gfx::BufferFormat::BGRX_8888; return gfx::BufferFormat::BGRX_8888;
case DRM_FORMAT_ABGR2101010: case DRM_FORMAT_ABGR2101010:
return gfx::BufferFormat::RGBA_1010102; return gfx::BufferFormat::RGBA_1010102;
case DRM_FORMAT_ARGB2101010:
return gfx::BufferFormat::BGRA_1010102;
case DRM_FORMAT_RGB565: case DRM_FORMAT_RGB565:
return gfx::BufferFormat::BGR_565; return gfx::BufferFormat::BGR_565;
case DRM_FORMAT_NV12: case DRM_FORMAT_NV12:
......
...@@ -138,19 +138,22 @@ void GLImageTestSupport::SetBufferDataToColor(int width, ...@@ -138,19 +138,22 @@ void GLImageTestSupport::SetBufferDataToColor(int width,
} }
} }
return; return;
case gfx::BufferFormat::BGRA_1010102: case gfx::BufferFormat::BGRA_1010102: {
DCHECK_EQ(0, plane); DCHECK_EQ(0, plane);
DCHECK_EQ(63, color[3] % 64) << "Alpha channel doesn't have enough "
"precision for the supplied value";
const uint8_t scaled_alpha = color[3] >> 6;
for (int y = 0; y < height; ++y) { for (int y = 0; y < height; ++y) {
for (int x = 0; x < width; ++x) { for (int x = 0; x < width; ++x) {
*reinterpret_cast<uint32_t*>(&data[y * stride + x * 4]) = *reinterpret_cast<uint32_t*>(&data[y * stride + x * 4]) =
0x3 << 30 | // Alpha channel is unused (scaled_alpha << 30) | // A
((color[0] << 2) | (color[0] >> 6)) << 20 | // R ((color[0] << 2) | (color[0] >> 6)) << 20 | // B
((color[1] << 2) | (color[1] >> 6)) << 10 | // G ((color[1] << 2) | (color[1] >> 6)) << 10 | // G
((color[2] << 2) | (color[2] >> 6)); // B ((color[2] << 2) | (color[2] >> 6)); // R
} }
} }
return; return;
}
case gfx::BufferFormat::RGBA_1010102: { case gfx::BufferFormat::RGBA_1010102: {
DCHECK_EQ(0, plane); DCHECK_EQ(0, plane);
DCHECK_EQ(63, color[3] % 64) << "Alpha channel doesn't have enough " DCHECK_EQ(63, color[3] % 64) << "Alpha channel doesn't have enough "
...@@ -167,7 +170,6 @@ void GLImageTestSupport::SetBufferDataToColor(int width, ...@@ -167,7 +170,6 @@ void GLImageTestSupport::SetBufferDataToColor(int width,
} }
return; return;
} }
case gfx::BufferFormat::BGRA_8888: case gfx::BufferFormat::BGRA_8888:
DCHECK_EQ(0, plane); DCHECK_EQ(0, plane);
for (int y = 0; y < height; ++y) { for (int y = 0; y < height; ++y) {
......
...@@ -91,7 +91,9 @@ INSTANTIATE_TYPED_TEST_SUITE_P(GLImageNativePixmapScanoutBGRA, ...@@ -91,7 +91,9 @@ INSTANTIATE_TYPED_TEST_SUITE_P(GLImageNativePixmapScanoutBGRA,
using GLImageScanoutTypeDisabled = testing::Types< using GLImageScanoutTypeDisabled = testing::Types<
GLImageNativePixmapTestDelegate<gfx::BufferUsage::SCANOUT, GLImageNativePixmapTestDelegate<gfx::BufferUsage::SCANOUT,
gfx::BufferFormat::RGBA_1010102>>; gfx::BufferFormat::RGBA_1010102>,
GLImageNativePixmapTestDelegate<gfx::BufferUsage::SCANOUT,
gfx::BufferFormat::BGRA_1010102>>;
// This test is disabled since we need mesa support for AB30 that is not // This test is disabled since we need mesa support for AB30 that is not
// available on many boards yet. // available on many boards yet.
......
...@@ -909,8 +909,7 @@ TEST_P(HardwareDisplayPlaneManagerTest, ForceOpaqueFormatsForAddFramebuffer) { ...@@ -909,8 +909,7 @@ TEST_P(HardwareDisplayPlaneManagerTest, ForceOpaqueFormatsForAddFramebuffer) {
uint32_t used_fourcc; // FourCC expected to be used in AddFramebuffer. uint32_t used_fourcc; // FourCC expected to be used in AddFramebuffer.
} kFourCCFormats[] = { } kFourCCFormats[] = {
{DRM_FORMAT_ABGR2101010, DRM_FORMAT_XBGR2101010}, {DRM_FORMAT_ABGR2101010, DRM_FORMAT_XBGR2101010},
// TODO(mcasas): use AR30 when the CLs in crrev.com/c/2068722 have landed. {DRM_FORMAT_ARGB2101010, DRM_FORMAT_XRGB2101010},
{DRM_FORMAT_XRGB2101010, DRM_FORMAT_XRGB2101010},
}; };
for (const auto& format_pair : kFourCCFormats) { for (const auto& format_pair : kFourCCFormats) {
......
...@@ -121,7 +121,7 @@ std::unique_ptr<GbmBuffer> MockGbmDevice::CreateBufferWithModifiers( ...@@ -121,7 +121,7 @@ std::unique_ptr<GbmBuffer> MockGbmDevice::CreateBufferWithModifiers(
switch (format) { switch (format) {
case DRM_FORMAT_XRGB8888: case DRM_FORMAT_XRGB8888:
case DRM_FORMAT_ARGB8888: case DRM_FORMAT_ARGB8888:
case DRM_FORMAT_XRGB2101010: case DRM_FORMAT_ARGB2101010:
case DRM_FORMAT_ABGR2101010: case DRM_FORMAT_ABGR2101010:
bytes_per_pixel = 4; bytes_per_pixel = 4;
break; break;
......
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