Hash :
4e22c2c3
Author :
Date :
2021-01-19T12:42:38
EGL: Merge DisplayAndroid/Gmb into DisplayEGL. These classes classes have a lot of duplicated code for no reason. DisplayGmb still needs more work. Bug: angleproject:5563 Change-Id: Ia3d3d7f0bd7c03b4ac1aece4369c49118426b9de Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3140498 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Maksim Sisov <msisov@igalia.com> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Commit-Queue: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
//
// Copyright 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// DisplayGL.h: GL implementation of egl::Display
#include "libANGLE/renderer/gl/DisplayGL.h"
#include "libANGLE/AttributeMap.h"
#include "libANGLE/Context.h"
#include "libANGLE/Display.h"
#include "libANGLE/Surface.h"
#include "libANGLE/renderer/gl/ContextGL.h"
#include "libANGLE/renderer/gl/RendererGL.h"
#include "libANGLE/renderer/gl/StateManagerGL.h"
#include "libANGLE/renderer/gl/SurfaceGL.h"
#include <EGL/eglext.h>
namespace rx
{
// On Linux with the amdgpu driver, the renderer string looks like:
//
// AMD Radeon (TM) <GPU model> Graphics (<GPUgeneration>, DRM <DRMversion>, <kernelversion>,
// LLVM <LLVMversion>) eg. AMD Radeon (TM) RX 460 Graphics (POLARIS11,
// DRM 3.35.0, 5.4.0-65-generic, LLVM 11.0.0)
//
// We also want to handle the case without GPUGeneration:
// AMD Radeon GPU model (DRM DRMversion, kernelversion, LLVM LLVMversion)
//
// Thanks to Jeff Gilbert of Mozilla for this example
// https://phabricator.services.mozilla.com/D105636
std::string SanitizeRendererString(std::string rendererString)
{
size_t pos = rendererString.find(", DRM ");
if (pos != std::string::npos)
{
rendererString.resize(pos);
rendererString.push_back(')');
return rendererString;
}
pos = rendererString.find(" (DRM ");
if (pos != std::string::npos)
{
rendererString.resize(pos);
return rendererString;
}
return rendererString;
}
// OpenGL ES requires a prefix of "OpenGL ES" for the GL_VERSION string.
// We can also add the prefix to desktop OpenGL for consistency.
std::string SanitizeVersionString(std::string versionString, bool isES)
{
if (versionString.find("OpenGL") == std::string::npos)
{
std::string prefix = "OpenGL ";
if (isES)
{
prefix += "ES ";
}
versionString = prefix + versionString;
}
return versionString;
}
DisplayGL::DisplayGL(const egl::DisplayState &state) : DisplayImpl(state) {}
DisplayGL::~DisplayGL() {}
egl::Error DisplayGL::initialize(egl::Display *display)
{
return egl::NoError();
}
void DisplayGL::terminate() {}
ImageImpl *DisplayGL::createImage(const egl::ImageState &state,
const gl::Context *context,
EGLenum target,
const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
return nullptr;
}
SurfaceImpl *DisplayGL::createPbufferFromClientBuffer(const egl::SurfaceState &state,
EGLenum buftype,
EGLClientBuffer clientBuffer,
const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
return nullptr;
}
StreamProducerImpl *DisplayGL::createStreamProducerD3DTexture(
egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
return nullptr;
}
ShareGroupImpl *DisplayGL::createShareGroup()
{
return new ShareGroupGL();
}
egl::Error DisplayGL::makeCurrent(egl::Display *display,
egl::Surface *drawSurface,
egl::Surface *readSurface,
gl::Context *context)
{
// Ensure that the correct global DebugAnnotator is installed when the end2end tests change
// the ANGLE back-end (done frequently).
display->setGlobalDebugAnnotator();
if (!context)
{
return egl::NoError();
}
// Pause transform feedback before making a new surface current, to workaround anglebug.com/1426
ContextGL *glContext = GetImplAs<ContextGL>(context);
glContext->getStateManager()->pauseTransformFeedback();
if (drawSurface == nullptr)
{
ANGLE_TRY(makeCurrentSurfaceless(context));
}
return egl::NoError();
}
gl::Version DisplayGL::getMaxConformantESVersion() const
{
// 3.1 support is in progress.
return std::min(getMaxSupportedESVersion(), gl::Version(3, 0));
}
void DisplayGL::generateExtensions(egl::DisplayExtensions *outExtensions) const
{
// Advertise robust resource initialization on all OpenGL backends for testing even though it is
// not fully implemented.
outExtensions->robustResourceInitializationANGLE = true;
}
egl::Error DisplayGL::makeCurrentSurfaceless(gl::Context *context)
{
UNIMPLEMENTED();
return egl::NoError();
}
std::string DisplayGL::getRendererDescription()
{
std::string rendererString = GetRendererString(getRenderer()->getFunctions());
const angle::FeaturesGL &features = getRenderer()->getFeatures();
if (features.sanitizeAmdGpuRendererString.enabled)
{
return SanitizeRendererString(rendererString);
}
return rendererString;
}
std::string DisplayGL::getVendorString()
{
return GetVendorString(getRenderer()->getFunctions());
}
std::string DisplayGL::getVersionString()
{
std::string versionString = GetVersionString(getRenderer()->getFunctions());
return SanitizeVersionString(versionString,
getRenderer()->getFunctions()->standard == STANDARD_GL_ES);
}
} // namespace rx