Hash :
e1aa9219
Author :
Date :
2018-01-08T17:53:05
Create a new DeviceImpl each time one is requested from a DisplayImpl. This makes sure that the Device to DeviceImpl ratio is always 1:1 and avoids any potential double-deletion or unexpected deletion of DeviceImpl objects. BUG=742034 Change-Id: I778068ccd09b7478d3683123456062b94be242a1 Reviewed-on: https://chromium-review.googlesource.com/854627 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@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 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
//
// 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.
//
// DisplayVk.cpp:
// Implements the class methods for DisplayVk.
//
#include "libANGLE/renderer/vulkan/DisplayVk.h"
#include "common/debug.h"
#include "libANGLE/Context.h"
#include "libANGLE/Display.h"
#include "libANGLE/renderer/vulkan/ContextVk.h"
#include "libANGLE/renderer/vulkan/RendererVk.h"
#include "libANGLE/renderer/vulkan/SurfaceVk.h"
namespace rx
{
DisplayVk::DisplayVk(const egl::DisplayState &state) : DisplayImpl(state), mRenderer(nullptr)
{
}
DisplayVk::~DisplayVk()
{
}
egl::Error DisplayVk::initialize(egl::Display *display)
{
ASSERT(!mRenderer && display != nullptr);
mRenderer.reset(new RendererVk());
return mRenderer->initialize(display->getAttributeMap(), getWSIName())
.toEGL(EGL_NOT_INITIALIZED);
}
void DisplayVk::terminate()
{
mRenderer.reset(nullptr);
}
egl::Error DisplayVk::makeCurrent(egl::Surface * /*drawSurface*/,
egl::Surface * /*readSurface*/,
gl::Context * /*context*/)
{
return egl::NoError();
}
egl::ConfigSet DisplayVk::generateConfigs()
{
// TODO(jmadill): Multiple configs, pbuffers, and proper checking of config attribs.
egl::Config singleton;
singleton.renderTargetFormat = GL_RGBA8;
singleton.depthStencilFormat = GL_NONE;
singleton.bufferSize = 32;
singleton.redSize = 8;
singleton.greenSize = 8;
singleton.blueSize = 8;
singleton.alphaSize = 8;
singleton.alphaMaskSize = 0;
singleton.bindToTextureRGB = EGL_FALSE;
singleton.bindToTextureRGBA = EGL_FALSE;
singleton.colorBufferType = EGL_RGB_BUFFER;
singleton.configCaveat = EGL_NONE;
singleton.conformant = 0;
singleton.depthSize = 0;
singleton.stencilSize = 0;
singleton.level = 0;
singleton.matchNativePixmap = EGL_NONE;
singleton.maxPBufferWidth = 0;
singleton.maxPBufferHeight = 0;
singleton.maxPBufferPixels = 0;
singleton.maxSwapInterval = 1;
singleton.minSwapInterval = 1;
singleton.nativeRenderable = EGL_TRUE;
singleton.nativeVisualID = 0;
singleton.nativeVisualType = EGL_NONE;
singleton.renderableType = EGL_OPENGL_ES2_BIT;
singleton.sampleBuffers = 0;
singleton.samples = 0;
singleton.surfaceType = EGL_WINDOW_BIT;
singleton.optimalOrientation = 0;
singleton.transparentType = EGL_NONE;
singleton.transparentRedValue = 0;
singleton.transparentGreenValue = 0;
singleton.transparentBlueValue = 0;
singleton.colorComponentType = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
egl::ConfigSet configSet;
configSet.add(singleton);
return configSet;
}
bool DisplayVk::testDeviceLost()
{
// TODO(jmadill): Figure out how to do device lost in Vulkan.
return false;
}
egl::Error DisplayVk::restoreLostDevice(const egl::Display *display)
{
UNIMPLEMENTED();
return egl::EglBadAccess();
}
std::string DisplayVk::getVendorString() const
{
std::string vendorString = "Google Inc.";
if (mRenderer)
{
vendorString += " " + mRenderer->getVendorString();
}
return vendorString;
}
DeviceImpl *DisplayVk::createDevice()
{
UNIMPLEMENTED();
return nullptr;
}
egl::Error DisplayVk::waitClient(const gl::Context *context) const
{
UNIMPLEMENTED();
return egl::EglBadAccess();
}
egl::Error DisplayVk::waitNative(const gl::Context *context, EGLint engine) const
{
UNIMPLEMENTED();
return egl::EglBadAccess();
}
SurfaceImpl *DisplayVk::createWindowSurface(const egl::SurfaceState &state,
EGLNativeWindowType window,
const egl::AttributeMap &attribs)
{
EGLint width = attribs.getAsInt(EGL_WIDTH, 0);
EGLint height = attribs.getAsInt(EGL_HEIGHT, 0);
return createWindowSurfaceVk(state, window, width, height);
}
SurfaceImpl *DisplayVk::createPbufferSurface(const egl::SurfaceState &state,
const egl::AttributeMap &attribs)
{
ASSERT(mRenderer);
EGLint width = attribs.getAsInt(EGL_WIDTH, 0);
EGLint height = attribs.getAsInt(EGL_HEIGHT, 0);
return new OffscreenSurfaceVk(state, width, height);
}
SurfaceImpl *DisplayVk::createPbufferFromClientBuffer(const egl::SurfaceState &state,
EGLenum buftype,
EGLClientBuffer clientBuffer,
const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
return static_cast<SurfaceImpl *>(0);
}
SurfaceImpl *DisplayVk::createPixmapSurface(const egl::SurfaceState &state,
NativePixmapType nativePixmap,
const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
return static_cast<SurfaceImpl *>(0);
}
ImageImpl *DisplayVk::createImage(const egl::ImageState &state,
EGLenum target,
const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
return static_cast<ImageImpl *>(0);
}
ContextImpl *DisplayVk::createContext(const gl::ContextState &state)
{
return new ContextVk(state, mRenderer.get());
}
StreamProducerImpl *DisplayVk::createStreamProducerD3DTexture(
egl::Stream::ConsumerType consumerType,
const egl::AttributeMap &attribs)
{
UNIMPLEMENTED();
return static_cast<StreamProducerImpl *>(0);
}
gl::Version DisplayVk::getMaxSupportedESVersion() const
{
UNIMPLEMENTED();
return gl::Version(0, 0);
}
void DisplayVk::generateExtensions(egl::DisplayExtensions *outExtensions) const
{
}
void DisplayVk::generateCaps(egl::Caps *outCaps) const
{
outCaps->textureNPOT = true;
}
} // namespace rx