Skip to content

Commit

Permalink
ui: s/XR30/AR30/ and support it for SCANOUT
Browse files Browse the repository at this point in the history
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: Daniel Nicoara <dnicoara@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Michael Spang <spang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747122}
  • Loading branch information
yellowdoge authored and Commit Bot committed Mar 5, 2020
1 parent b2fbd39 commit 0e16a89
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 20 deletions.
3 changes: 2 additions & 1 deletion gpu/command_buffer/common/gpu_memory_buffer_support.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ GPU_EXPORT bool NativeBufferNeedsPlatformSpecificTextureTarget(
format == gfx::BufferFormat::BGRA_8888 ||
format == gfx::BufferFormat::RGBX_8888 ||
format == gfx::BufferFormat::BGRX_8888 ||
format == gfx::BufferFormat::RGBA_1010102) {
format == gfx::BufferFormat::RGBA_1010102 ||
format == gfx::BufferFormat::BGRA_1010102) {
return false;
}
#elif defined(OS_ANDROID)
Expand Down
7 changes: 4 additions & 3 deletions gpu/command_buffer/service/feature_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ class GPU_GLES2_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> {
FeatureFlags();

GpuMemoryBufferFormatSet gpu_memory_buffer_formats = {
gfx::BufferFormat::BGR_565, gfx::BufferFormat::RGBA_4444,
gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::RGBX_8888,
gfx::BufferFormat::YVU_420, gfx::BufferFormat::RGBA_1010102,
gfx::BufferFormat::BGR_565, gfx::BufferFormat::RGBA_4444,
gfx::BufferFormat::RGBA_8888, gfx::BufferFormat::RGBX_8888,
gfx::BufferFormat::YVU_420, gfx::BufferFormat::RGBA_1010102,
gfx::BufferFormat::BGRA_1010102,
};
// Use glBlitFramebuffer() and glRenderbufferStorageMultisample() with
// GL_EXT_framebuffer_multisample-style semantics (as opposed to
Expand Down
2 changes: 1 addition & 1 deletion ui/gfx/buffer_format_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ size_t AlphaBitsForBufferFormat(BufferFormat format) {
return 4;
case BufferFormat::RGBA_8888:
return 8;
case BufferFormat::BGRA_1010102:
case BufferFormat::RGBA_1010102:
return 2;
case BufferFormat::BGRA_8888:
Expand All @@ -56,7 +57,6 @@ size_t AlphaBitsForBufferFormat(BufferFormat format) {
case BufferFormat::BGR_565:
case BufferFormat::RGBX_8888:
case BufferFormat::BGRX_8888:
case BufferFormat::BGRA_1010102:
case BufferFormat::YVU_420:
case BufferFormat::YUV_420_BIPLANAR:
case BufferFormat::P010:
Expand Down
6 changes: 3 additions & 3 deletions ui/gfx/linux/drm_util_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int GetFourCCFormatFromBufferFormat(gfx::BufferFormat format) {
case gfx::BufferFormat::BGRX_8888:
return DRM_FORMAT_XRGB8888;
case gfx::BufferFormat::BGRA_1010102:
return DRM_FORMAT_XRGB2101010;
return DRM_FORMAT_ARGB2101010;
case gfx::BufferFormat::RGBA_1010102:
return DRM_FORMAT_ABGR2101010;
case gfx::BufferFormat::RGBA_F16:
Expand Down Expand Up @@ -69,7 +69,7 @@ gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) {
return gfx::BufferFormat::BGRA_8888;
case DRM_FORMAT_XRGB8888:
return gfx::BufferFormat::BGRX_8888;
case DRM_FORMAT_XRGB2101010:
case DRM_FORMAT_ARGB2101010:
return gfx::BufferFormat::BGRA_1010102;
case DRM_FORMAT_ABGR2101010:
return gfx::BufferFormat::RGBA_1010102;
Expand All @@ -95,7 +95,7 @@ bool IsValidBufferFormat(uint32_t current_format) {
case DRM_FORMAT_XBGR8888:
case DRM_FORMAT_ARGB8888:
case DRM_FORMAT_XRGB8888:
case DRM_FORMAT_XRGB2101010:
case DRM_FORMAT_ARGB2101010:
case DRM_FORMAT_ABGR2101010:
case DRM_FORMAT_RGB565:
case DRM_FORMAT_NV12:
Expand Down
6 changes: 4 additions & 2 deletions ui/gl/gl_image_native_pixmap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#define DRM_FORMAT_XRGB8888 FOURCC('X', 'R', '2', '4')
#define DRM_FORMAT_XBGR8888 FOURCC('X', 'B', '2', '4')
#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_NV12 FOURCC('N', 'V', '1', '2')
#define DRM_FORMAT_P010 FOURCC('P', '0', '1', '0')
Expand Down Expand Up @@ -72,7 +72,7 @@ EGLint FourCC(gfx::BufferFormat format) {
case gfx::BufferFormat::RGBA_1010102:
return DRM_FORMAT_ABGR2101010;
case gfx::BufferFormat::BGRA_1010102:
return DRM_FORMAT_XRGB2101010;
return DRM_FORMAT_ARGB2101010;
case gfx::BufferFormat::YVU_420:
return DRM_FORMAT_YVU420;
case gfx::BufferFormat::YUV_420_BIPLANAR:
Expand Down Expand Up @@ -104,6 +104,8 @@ gfx::BufferFormat GetBufferFormatFromFourCCFormat(int format) {
return gfx::BufferFormat::BGRX_8888;
case DRM_FORMAT_ABGR2101010:
return gfx::BufferFormat::RGBA_1010102;
case DRM_FORMAT_ARGB2101010:
return gfx::BufferFormat::BGRA_1010102;
case DRM_FORMAT_RGB565:
return gfx::BufferFormat::BGR_565;
case DRM_FORMAT_NV12:
Expand Down
14 changes: 8 additions & 6 deletions ui/gl/test/gl_image_test_support.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,22 @@ void GLImageTestSupport::SetBufferDataToColor(int width,
}
}
return;
case gfx::BufferFormat::BGRA_1010102:
case gfx::BufferFormat::BGRA_1010102: {
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 x = 0; x < width; ++x) {
*reinterpret_cast<uint32_t*>(&data[y * stride + x * 4]) =
0x3 << 30 | // Alpha channel is unused
((color[0] << 2) | (color[0] >> 6)) << 20 | // R
(scaled_alpha << 30) | // A
((color[0] << 2) | (color[0] >> 6)) << 20 | // B
((color[1] << 2) | (color[1] >> 6)) << 10 | // G
((color[2] << 2) | (color[2] >> 6)); // B
((color[2] << 2) | (color[2] >> 6)); // R
}
}
return;

}
case gfx::BufferFormat::RGBA_1010102: {
DCHECK_EQ(0, plane);
DCHECK_EQ(63, color[3] % 64) << "Alpha channel doesn't have enough "
Expand All @@ -167,7 +170,6 @@ void GLImageTestSupport::SetBufferDataToColor(int width,
}
return;
}

case gfx::BufferFormat::BGRA_8888:
DCHECK_EQ(0, plane);
for (int y = 0; y < height; ++y) {
Expand Down
4 changes: 3 additions & 1 deletion ui/ozone/gl/gl_image_ozone_native_pixmap_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ INSTANTIATE_TYPED_TEST_SUITE_P(GLImageNativePixmapScanoutBGRA,

using GLImageScanoutTypeDisabled = testing::Types<
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
// available on many boards yet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -909,8 +909,7 @@ TEST_P(HardwareDisplayPlaneManagerTest, ForceOpaqueFormatsForAddFramebuffer) {
uint32_t used_fourcc; // FourCC expected to be used in AddFramebuffer.
} kFourCCFormats[] = {
{DRM_FORMAT_ABGR2101010, DRM_FORMAT_XBGR2101010},
// TODO(mcasas): use AR30 when the CLs in crrev.com/c/2068722 have landed.
{DRM_FORMAT_XRGB2101010, DRM_FORMAT_XRGB2101010},
{DRM_FORMAT_ARGB2101010, DRM_FORMAT_XRGB2101010},
};

for (const auto& format_pair : kFourCCFormats) {
Expand Down
2 changes: 1 addition & 1 deletion ui/ozone/platform/drm/gpu/mock_gbm_device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ std::unique_ptr<GbmBuffer> MockGbmDevice::CreateBufferWithModifiers(
switch (format) {
case DRM_FORMAT_XRGB8888:
case DRM_FORMAT_ARGB8888:
case DRM_FORMAT_XRGB2101010:
case DRM_FORMAT_ARGB2101010:
case DRM_FORMAT_ABGR2101010:
bytes_per_pixel = 4;
break;
Expand Down

0 comments on commit 0e16a89

Please sign in to comment.