Commit a3cf06ac by Mohan Maiya Committed by Commit Bot

EGL: populate EGL_NATIVE_VISUAL_ID values for Android

When generating the default EGL configs, populate EGL_NATIVE_VISUAL_ID with AHARDWAREBUFFER formats. Bug: angleproject:4469 Change-Id: Ifde9df0497cbd4e01219ab6067acd8d97f8460e4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2101577Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
parent 57fa7c6c
......@@ -266,6 +266,46 @@ GLenum NativePixelFormatToGLInternalFormat(int pixelFormat)
}
}
int GLInternalFormatToNativePixelFormat(GLenum internalFormat)
{
switch (internalFormat)
{
case GL_RGBA8:
return AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
case GL_RGB8:
return AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM;
case GL_RGB565:
return AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM;
case GL_BGRA8_EXT:
return AHARDWAREBUFFER_FORMAT_B8G8R8A8_UNORM;
case GL_RGB5_A1:
return AHARDWAREBUFFER_FORMAT_B5G5R5A1_UNORM;
case GL_RGBA4:
return AHARDWAREBUFFER_FORMAT_B4G4R4A4_UNORM;
case GL_RGBA16F:
return AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT;
case GL_RGB10_A2:
return AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM;
case GL_NONE:
return AHARDWAREBUFFER_FORMAT_BLOB;
case GL_DEPTH_COMPONENT16:
return AHARDWAREBUFFER_FORMAT_D16_UNORM;
case GL_DEPTH_COMPONENT24:
return AHARDWAREBUFFER_FORMAT_D24_UNORM;
case GL_DEPTH24_STENCIL8:
return AHARDWAREBUFFER_FORMAT_D24_UNORM_S8_UINT;
case GL_DEPTH_COMPONENT32F:
return AHARDWAREBUFFER_FORMAT_D32_FLOAT;
case GL_DEPTH32F_STENCIL8:
return AHARDWAREBUFFER_FORMAT_D32_FLOAT_S8_UINT;
case GL_STENCIL_INDEX8:
return AHARDWAREBUFFER_FORMAT_S8_UINT;
default:
WARN() << "Unknown internalFormat: " << internalFormat << ". Treating as 0";
return 0;
}
}
AHardwareBuffer *ANativeWindowBufferToAHardwareBuffer(ANativeWindowBuffer *windowBuffer)
{
return offsetPointer<AHardwareBuffer>(windowBuffer,
......
......@@ -30,6 +30,7 @@ void GetANativeWindowBufferProperties(const ANativeWindowBuffer *buffer,
int *depth,
int *pixelFormat);
GLenum NativePixelFormatToGLInternalFormat(int pixelFormat);
int GLInternalFormatToNativePixelFormat(GLenum internalFormat);
AHardwareBuffer *ANativeWindowBufferToAHardwareBuffer(ANativeWindowBuffer *windowBuffer);
......
......@@ -14,6 +14,7 @@
#include <ostream>
#include "angle_gl.h"
#include "common/android_util.h"
#include "libANGLE/Caps.h"
#include "libANGLE/Error.h"
#include "libANGLE/Version.h"
......@@ -271,6 +272,16 @@ typedef std::unordered_map<GLenum, std::unordered_map<GLenum, InternalFormat>>
InternalFormatInfoMap;
const InternalFormatInfoMap &GetInternalFormatMap();
ANGLE_INLINE int GetNativeVisualID(const InternalFormat &internalFormat)
{
int nativeVisualId = 0;
#if defined(ANGLE_PLATFORM_ANDROID)
nativeVisualId =
angle::android::GLInternalFormatToNativePixelFormat(internalFormat.internalFormat);
#endif
return nativeVisualId;
}
// From the ESSL 3.00.4 spec:
// Vertex shader inputs can only be float, floating-point vectors, matrices, signed and unsigned
// integers and integer vectors. Vertex shader inputs cannot be arrays or structures.
......
......@@ -612,7 +612,7 @@ egl::Config GenerateDefaultConfig(const RendererVk *renderer,
config.maxSwapInterval = 1;
config.minSwapInterval = 0;
config.nativeRenderable = EGL_TRUE;
config.nativeVisualID = 0;
config.nativeVisualID = static_cast<EGLint>(GetNativeVisualID(colorFormat));
config.nativeVisualType = EGL_NONE;
config.renderableType = es2Support | es3Support;
config.sampleBuffers = (sampleCount > 0) ? 1 : 0;
......
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