Hash :
81d964a1
Author :
Date :
2021-10-28T10:50:51
vulkan: implement EGLDevice for vulkan backend It allows ANGLE clients to get and use VkDevice and VkQueue used by vulkan backend. Bug: chromium:1264439 Change-Id: I338ac08152cfec50bb34c5025730e5e6368efba9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3250964 Reviewed-by: Peng Huang <penghuang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Peng Huang <penghuang@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
//
// 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.
//
// DeviceVk.cpp:
// Implements the class methods for DeviceVk.
//
#include "libANGLE/renderer/vulkan/DeviceVk.h"
#include <stdint.h>
#include "common/debug.h"
#include "libANGLE/Display.h"
#include "libANGLE/renderer/vulkan/DisplayVk.h"
#include "libANGLE/renderer/vulkan/RendererVk.h"
namespace rx
{
DeviceVk::DeviceVk() = default;
DeviceVk::~DeviceVk() = default;
egl::Error DeviceVk::initialize()
{
return egl::NoError();
}
egl::Error DeviceVk::getAttribute(const egl::Display *display, EGLint attribute, void **outValue)
{
RendererVk *renderer =
static_cast<rx::DisplayVk *>(display->getImplementation())->getRenderer();
switch (attribute)
{
case EGL_VULKAN_DEVICE_ANGLE:
{
*outValue = renderer->getDevice();
return egl::NoError();
}
case EGL_VULKAN_PHYSICAL_DEVICE_ANGLE:
{
*outValue = renderer->getPhysicalDevice();
return egl::NoError();
}
case EGL_VULKAN_QUEUE_ANGLE:
{
// egl::ContextPriority::Medium is the default context priority.
*outValue = renderer->getQueue(egl::ContextPriority::Medium);
return egl::NoError();
}
case EGL_VULKAN_QUEUE_FAMILIY_INDEX_ANGLE:
{
intptr_t index = static_cast<intptr_t>(renderer->getQueueFamilyIndex());
*outValue = reinterpret_cast<void *>(index);
return egl::NoError();
}
case EGL_VULKAN_EXTENSIONS_ANGLE:
{
char **extensions = const_cast<char **>(renderer->getEnabledDeviceExtensions().data());
*outValue = reinterpret_cast<void *>(extensions);
return egl::NoError();
}
default:
return egl::EglBadAccess();
}
}
EGLint DeviceVk::getType()
{
return EGL_VULKAN_DEVICE_ANGLE;
}
void DeviceVk::generateExtensions(egl::DeviceExtensions *outExtensions) const
{
outExtensions->deviceVulkan = true;
}
} // namespace rx