Hash :
914fe61b
Author :
Date :
2024-03-15T13:20:49
Vulkan: Rename RendererVk.* to vk_renderer.* Done in a separate CL from the move to namespace vk to avoid possible rebase-time confusion with the file name change. Bug: angleproject:8564 Change-Id: Ibab79029834b88514d4466a7a4c076b1352bc450 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5370107 Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com> Commit-Queue: Amirali Abdolrashidi <abdolrashidi@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
//
// 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.
//
// DeviceVkLinux.cpp:
// Implements the class methods for DeviceVkLinux.
//
#include "libANGLE/renderer/vulkan/linux/DeviceVkLinux.h"
#include <unistd.h>
#include "common/debug.h"
#include "common/vulkan/vulkan_icd.h"
#include "libANGLE/Display.h"
#include "libANGLE/renderer/vulkan/DisplayVk.h"
#include "libANGLE/renderer/vulkan/vk_renderer.h"
namespace rx
{
DeviceVkLinux::DeviceVkLinux(DisplayVk *display) : mDisplay(display) {}
egl::Error DeviceVkLinux::initialize()
{
vk::Renderer *renderer = mDisplay->getRenderer();
VkPhysicalDeviceDrmPropertiesEXT drmProperties = renderer->getPhysicalDeviceDrmProperties();
// Unfortunately `VkPhysicalDeviceDrmPropertiesEXT` doesn't give us the information about the
// filesystem layout needed by the EGL version. As ChromeOS/Exo is currently the only user,
// implement the extension only for Linux where we can reasonably assume `/dev/dri/...` file
// paths.
if (drmProperties.hasPrimary)
{
char deviceName[50];
const long long primaryMinor = drmProperties.primaryMinor;
snprintf(deviceName, sizeof(deviceName), "/dev/dri/card%lld", primaryMinor);
if (access(deviceName, F_OK) != -1)
{
mDrmDevice = deviceName;
}
}
if (drmProperties.hasRender)
{
char deviceName[50];
const long long renderMinor = drmProperties.renderMinor;
snprintf(deviceName, sizeof(deviceName), "/dev/dri/renderD%lld", renderMinor);
if (access(deviceName, F_OK) != -1)
{
mDrmRenderNode = deviceName;
}
}
if (mDrmDevice.empty() && !mDrmRenderNode.empty())
{
mDrmDevice = mDrmRenderNode;
}
return egl::NoError();
}
void DeviceVkLinux::generateExtensions(egl::DeviceExtensions *outExtensions) const
{
DeviceVk::generateExtensions(outExtensions);
if (!mDrmDevice.empty())
{
outExtensions->deviceDrmEXT = true;
}
if (!mDrmRenderNode.empty())
{
outExtensions->deviceDrmRenderNodeEXT = true;
}
}
const std::string DeviceVkLinux::getDeviceString(EGLint name)
{
switch (name)
{
case EGL_DRM_DEVICE_FILE_EXT:
return mDrmDevice;
case EGL_DRM_RENDER_NODE_FILE_EXT:
return mDrmRenderNode;
default:
UNIMPLEMENTED();
return std::string();
}
}
} // namespace rx