Commit 14f472f2 by Geoff Lang Committed by Commit Bot

GL: Treat unknown AHardwareBuffer formats as RGBA8.

When Android's AImageReader encounters YUV formats, it converts the hardware buffer's internal format to vendor-specific formats. Since these sample as RGB using samplerExternal, simply validate them as if they are RGB8. BUG=angleproject:3929 Change-Id: I991512c8a584b08a978aacf67ab153ada7e4fd76 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1816300Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 59d982c0
......@@ -7,6 +7,7 @@
// android_util.cpp: Utilities for the using the Android platform
#include "common/android_util.h"
#include "common/debug.h"
#include <cstdint>
......@@ -159,6 +160,14 @@ enum {
* OpenGL ES: GL_STENCIL_INDEX8
*/
AHARDWAREBUFFER_FORMAT_S8_UINT = 0x35,
/**
* YUV 420 888 format.
* Must have an even width and height. Can be accessed in OpenGL
* shaders through an external sampler. Does not support mip-maps
* cube-maps or multi-layered textures.
*/
AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420 = 0x23,
};
// clang-format on
......@@ -247,8 +256,13 @@ GLenum NativePixelFormatToGLInternalFormat(int pixelFormat)
return GL_DEPTH32F_STENCIL8;
case AHARDWAREBUFFER_FORMAT_S8_UINT:
return GL_STENCIL_INDEX8;
case AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420:
return GL_RGB8;
default:
return GL_NONE;
// Treat unknown formats as RGB. They are vendor-specific YUV formats that would sample
// as RGB.
WARN() << "Unknown pixelFormat: " << pixelFormat << ". Treating as RGB8";
return GL_RGB8;
}
}
......
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