Hash :
29bb612e
Author :
Date :
2020-05-28T10:32:26
Add egl::ShareGroup class to abstract the share context group Vulkan backend has a barrier tracker that tracks memory barrier needs of all shared resources. Because the buffer/texture objects are shared resources within a shared group, the tracker can not live in a context. Putting it in a device/renderer requires locks. It fits perfectly in a shareGroup object. The work is already done at API level to handle the mutex lock for shared context access so that no extra lock needs to be taken in the backend. This CL adds egl::ShareGroup class that represents the object that are shared among all share context group. At the front end this usually will include all the shared resource managers (not done in this CL). The ShareGroup object is accessible from gl::State object. This CL also adds ability for backend driver to allocate implementation specific ShareGroupImpl object. Vulkan backend will then use it to keeps the barrier tracker and other things that naturally fits the share group concept. Bug: angleproject:4664 Change-Id: Ifcd975cbdf5130022e21c41397894afc28f572e7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2217252 Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Charlie Lao <cclao@google.com>
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 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
//
// Copyright 2016 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.
//
// DisplayNULL.cpp:
// Implements the class methods for DisplayNULL.
//
#include "libANGLE/renderer/null/DisplayNULL.h"
#include "common/debug.h"
#include "libANGLE/renderer/null/ContextNULL.h"
#include "libANGLE/renderer/null/DeviceNULL.h"
#include "libANGLE/renderer/null/ImageNULL.h"
#include "libANGLE/renderer/null/SurfaceNULL.h"
namespace rx
{
DisplayNULL::DisplayNULL(const egl::DisplayState &state) : DisplayImpl(state) {}
DisplayNULL::~DisplayNULL() {}
egl::Error DisplayNULL::initialize(egl::Display *display)
{
constexpr size_t kMaxTotalAllocationSize = 1 << 28; // 256MB
mAllocationTracker.reset(new AllocationTrackerNULL(kMaxTotalAllocationSize));
return egl::NoError();
}
void DisplayNULL::terminate()
{
mAllocationTracker.reset();
}
egl::Error DisplayNULL::makeCurrent(egl::Surface *drawSurface,
egl::Surface *readSurface,
gl::Context *context)
{
return egl::NoError();
}
egl::ConfigSet DisplayNULL::generateConfigs()
{
egl::Config config;
config.renderTargetFormat = GL_RGBA8;
config.depthStencilFormat = GL_DEPTH24_STENCIL8;
config.bufferSize = 32;
config.redSize = 8;
config.greenSize = 8;
config.blueSize = 8;
config.alphaSize = 8;
config.alphaMaskSize = 0;
config.bindToTextureRGB = EGL_TRUE;
config.bindToTextureRGBA = EGL_TRUE;
config.colorBufferType = EGL_RGB_BUFFER;
config.configCaveat = EGL_NONE;
config.conformant = EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT;
config.depthSize = 24;
config.level = 0;
config.matchNativePixmap = EGL_NONE;
config.maxPBufferWidth = 0;
config.maxPBufferHeight = 0;
config.maxPBufferPixels = 0;
config.maxSwapInterval = 1;
config.minSwapInterval = 1;
config.nativeRenderable = EGL_TRUE;
config.nativeVisualID = 0;
config.nativeVisualType = EGL_NONE;
config.renderableType = EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT;
config.sampleBuffers = 0;
config.samples = 0;
config.stencilSize = 8;
config.surfaceType = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
config.optimalOrientation = 0;
config.transparentType = EGL_NONE;
config.transparentRedValue = 0;
config.transparentGreenValue = 0;
config.transparentBlueValue = 0;
egl::ConfigSet configSet;
configSet.add(config);
return configSet;
}
bool DisplayNULL::testDeviceLost()
{
return false;
}
egl::Error DisplayNULL::restoreLostDevice(const egl::Display *display)
{
return egl::NoError();
}
bool DisplayNULL::isValidNativeWindow(EGLNativeWindowType window) const
{
return true;
}
std::string DisplayNULL::getVendorString() const
{
return "NULL";
}
DeviceImpl *DisplayNULL::createDevice()
{
return new DeviceNULL();
}
egl::Error DisplayNULL::waitClient(const gl::Context *context)
{
return egl::NoError();
}
egl::Error DisplayNULL::waitNative(const gl::Context *context, EGLint engine)
{
return egl::NoError();
}
gl::Version DisplayNULL::getMaxSupportedESVersion() const
{
return gl::Version(3, 2);
}
gl::Version DisplayNULL::getMaxConformantESVersion() const
{
return getMaxSupportedESVersion();
}
SurfaceImpl *DisplayNULL::createWindowSurface(const egl::SurfaceState &state,
EGLNativeWindowType window,
const egl::AttributeMap &attribs)
{
return new SurfaceNULL(state);
}
SurfaceImpl *DisplayNULL::createPbufferSurface(const egl::SurfaceState &state,
const egl::AttributeMap &attribs)
{
return new SurfaceNULL(state);
}
SurfaceImpl *DisplayNULL::createPbufferFromClientBuffer(const egl::SurfaceState &state,
EGLenum buftype,
EGLClientBuffer buffer,
const egl::AttributeMap &attribs)
{
return new SurfaceNULL(state);
}
SurfaceImpl *DisplayNULL::createPixmapSurface(const egl::SurfaceState &state,
NativePixmapType nativePixmap,
const egl::AttributeMap &attribs)
{
return new SurfaceNULL(state);
}
ImageImpl *DisplayNULL::createImage(const egl::ImageState &state,
const gl::Context *context,
EGLenum target,
const egl::AttributeMap &attribs)
{
return new ImageNULL(state);
}
rx::ContextImpl *DisplayNULL::createContext(const gl::State &state,
gl::ErrorSet *errorSet,
const egl::Config *configuration,
const gl::Context *shareContext,
const egl::AttributeMap &attribs)
{
return new ContextNULL(state, errorSet, mAllocationTracker.get());
}
StreamProducerImpl *DisplayNULL::createStreamProducerD3DTexture(
egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
return nullptr;
}
ShareGroupImpl *DisplayNULL::createShareGroup()
{
return new ShareGroupNULL();
}
void DisplayNULL::generateExtensions(egl::DisplayExtensions *outExtensions) const
{
outExtensions->createContextRobustness = true;
outExtensions->postSubBuffer = true;
outExtensions->createContext = true;
outExtensions->deviceQuery = true;
outExtensions->image = true;
outExtensions->imageBase = true;
outExtensions->glTexture2DImage = true;
outExtensions->glTextureCubemapImage = true;
outExtensions->glTexture3DImage = true;
outExtensions->glRenderbufferImage = true;
outExtensions->getAllProcAddresses = true;
outExtensions->flexibleSurfaceCompatibility = true;
outExtensions->directComposition = true;
outExtensions->createContextNoError = true;
outExtensions->createContextWebGLCompatibility = true;
outExtensions->createContextBindGeneratesResource = true;
outExtensions->swapBuffersWithDamage = true;
outExtensions->pixelFormatFloat = true;
outExtensions->surfacelessContext = true;
outExtensions->displayTextureShareGroup = true;
outExtensions->createContextClientArrays = true;
outExtensions->programCacheControl = true;
outExtensions->robustResourceInitialization = true;
}
void DisplayNULL::generateCaps(egl::Caps *outCaps) const
{
outCaps->textureNPOT = true;
}
} // namespace rx