Commit dc7eb76b authored by Geoff Lang's avatar Geoff Lang Committed by Commit Bot

Continue using the RGB emulation path for IOSurfaces with Swiftshader.

Swiftshader with the validating command decoder do not fully emulate RGB on
BGRA IOSurfaces so use the old emulation paths in the validating command
decoder for this case.

BUG=995142

Change-Id: I6cb5053b0bd03d54866a50ec3a392be4b39057c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1763238
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689553}
parent a98f2787
...@@ -170,7 +170,9 @@ GLImageIOSurface* GLImageIOSurface::Create(const gfx::Size& size, ...@@ -170,7 +170,9 @@ GLImageIOSurface* GLImageIOSurface::Create(const gfx::Size& size,
case kGLImplementationEGLGLES2: case kGLImplementationEGLGLES2:
case kGLImplementationEGLANGLE: case kGLImplementationEGLANGLE:
case kGLImplementationSwiftShaderGL: case kGLImplementationSwiftShaderGL:
return new GLImageIOSurfaceEGL(size, internalformat); return new GLImageIOSurfaceEGL(
size, internalformat,
GetGLImplementation() == kGLImplementationSwiftShaderGL);
default: default:
break; break;
} }
......
...@@ -15,7 +15,9 @@ namespace gl { ...@@ -15,7 +15,9 @@ namespace gl {
// EGL_ANGLE_iosurface_client_buffer extension to bind the IOSurface to textures // EGL_ANGLE_iosurface_client_buffer extension to bind the IOSurface to textures
class GL_EXPORT GLImageIOSurfaceEGL : public GLImageIOSurface { class GL_EXPORT GLImageIOSurfaceEGL : public GLImageIOSurface {
public: public:
GLImageIOSurfaceEGL(const gfx::Size& size, unsigned internalformat); GLImageIOSurfaceEGL(const gfx::Size& size,
unsigned internalformat,
bool emulate_rgb);
void ReleaseTexImage(unsigned target) override; void ReleaseTexImage(unsigned target) override;
...@@ -25,6 +27,12 @@ class GL_EXPORT GLImageIOSurfaceEGL : public GLImageIOSurface { ...@@ -25,6 +27,12 @@ class GL_EXPORT GLImageIOSurfaceEGL : public GLImageIOSurface {
bool CopyTexImage(unsigned target) override; bool CopyTexImage(unsigned target) override;
private: private:
// If Swiftshader is being used, use the RGB emulation paths in the validating
// command decoder instead of creating the IOSurface with an RGB format. ANGLE
// handles the emulation internally. This can be removed once Swiftshader is
// used as an ANGLE backend.
bool emulate_rgb_;
EGLDisplay display_; EGLDisplay display_;
EGLSurface pbuffer_; EGLSurface pbuffer_;
EGLConfig dummy_config_; EGLConfig dummy_config_;
......
...@@ -31,7 +31,8 @@ struct InternalFormatType { ...@@ -31,7 +31,8 @@ struct InternalFormatType {
// Convert a gfx::BufferFormat to a (internal format, type) combination from the // Convert a gfx::BufferFormat to a (internal format, type) combination from the
// EGL_ANGLE_iosurface_client_buffer extension spec. // EGL_ANGLE_iosurface_client_buffer extension spec.
InternalFormatType BufferFormatToInternalFormatType(gfx::BufferFormat format) { InternalFormatType BufferFormatToInternalFormatType(gfx::BufferFormat format,
bool emulate_rgb) {
switch (format) { switch (format) {
case gfx::BufferFormat::R_8: case gfx::BufferFormat::R_8:
return {GL_RED, GL_UNSIGNED_BYTE}; return {GL_RED, GL_UNSIGNED_BYTE};
...@@ -40,7 +41,11 @@ InternalFormatType BufferFormatToInternalFormatType(gfx::BufferFormat format) { ...@@ -40,7 +41,11 @@ InternalFormatType BufferFormatToInternalFormatType(gfx::BufferFormat format) {
case gfx::BufferFormat::RG_88: case gfx::BufferFormat::RG_88:
return {GL_RG, GL_UNSIGNED_BYTE}; return {GL_RG, GL_UNSIGNED_BYTE};
case gfx::BufferFormat::BGRX_8888: case gfx::BufferFormat::BGRX_8888:
return {GL_RGB, GL_UNSIGNED_BYTE}; if (emulate_rgb) {
return {GL_BGRA_EXT, GL_UNSIGNED_BYTE};
} else {
return {GL_RGB, GL_UNSIGNED_BYTE};
}
case gfx::BufferFormat::BGRA_8888: case gfx::BufferFormat::BGRA_8888:
case gfx::BufferFormat::RGBA_8888: case gfx::BufferFormat::RGBA_8888:
return {GL_BGRA_EXT, GL_UNSIGNED_BYTE}; return {GL_BGRA_EXT, GL_UNSIGNED_BYTE};
...@@ -67,8 +72,10 @@ InternalFormatType BufferFormatToInternalFormatType(gfx::BufferFormat format) { ...@@ -67,8 +72,10 @@ InternalFormatType BufferFormatToInternalFormatType(gfx::BufferFormat format) {
} // anonymous namespace } // anonymous namespace
GLImageIOSurfaceEGL::GLImageIOSurfaceEGL(const gfx::Size& size, GLImageIOSurfaceEGL::GLImageIOSurfaceEGL(const gfx::Size& size,
unsigned internalformat) unsigned internalformat,
bool emulate_rgb)
: GLImageIOSurface(size, internalformat), : GLImageIOSurface(size, internalformat),
emulate_rgb_(emulate_rgb),
display_(GLSurfaceEGL::GetHardwareDisplay()), display_(GLSurfaceEGL::GetHardwareDisplay()),
pbuffer_(EGL_NO_SURFACE), pbuffer_(EGL_NO_SURFACE),
dummy_config_(nullptr), dummy_config_(nullptr),
...@@ -116,7 +123,8 @@ bool GLImageIOSurfaceEGL::BindTexImageImpl(unsigned internalformat) { ...@@ -116,7 +123,8 @@ bool GLImageIOSurfaceEGL::BindTexImageImpl(unsigned internalformat) {
// in the constructor if we're going to be used to bind plane 0 to a texture, // in the constructor if we're going to be used to bind plane 0 to a texture,
// or to transform YUV to RGB. // or to transform YUV to RGB.
if (pbuffer_ == EGL_NO_SURFACE) { if (pbuffer_ == EGL_NO_SURFACE) {
InternalFormatType formatType = BufferFormatToInternalFormatType(format_); InternalFormatType formatType =
BufferFormatToInternalFormatType(format_, emulate_rgb_);
// clang-format off // clang-format off
const EGLint attribs[] = { const EGLint attribs[] = {
......
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