Hash :
2fb58a95
Author :
Date :
2022-02-15T15:40:23
Re-land: "Vulkan: GBM platform" Add support for GBM platform by implementing a Display with no WSI extension. Re-land fixes build script, including GBM Vulkan backend whenever ozone platform GBM is enabled. Bug: angleproject:7217 Change-Id: Icbf2d034b700e22ab4c351e479f472d65d832ebe Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3637562 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@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
//
// Copyright 2022 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.
//
// DisplayVkGbm.cpp:
// Implements the class methods for DisplayVkGbm.
//
#include "libANGLE/renderer/vulkan/linux/gbm/DisplayVkGbm.h"
#include <gbm.h>
#include "common/linux/dma_buf_utils.h"
#include "libANGLE/Display.h"
#include "libANGLE/renderer/vulkan/vk_caps_utils.h"
namespace rx
{
DisplayVkGbm::DisplayVkGbm(const egl::DisplayState &state)
: DisplayVkLinux(state), mGbmDevice(nullptr)
{}
egl::Error DisplayVkGbm::initialize(egl::Display *display)
{
mGbmDevice = reinterpret_cast<gbm_device *>(display->getNativeDisplayId());
if (!mGbmDevice)
{
ERR() << "Failed to retrieve GBM device";
return egl::EglNotInitialized();
}
return DisplayVk::initialize(display);
}
void DisplayVkGbm::terminate()
{
mGbmDevice = nullptr;
DisplayVk::terminate();
}
bool DisplayVkGbm::isValidNativeWindow(EGLNativeWindowType window) const
{
return (void *)window != nullptr;
}
SurfaceImpl *DisplayVkGbm::createWindowSurfaceVk(const egl::SurfaceState &state,
EGLNativeWindowType window)
{
return nullptr;
}
egl::ConfigSet DisplayVkGbm::generateConfigs()
{
const std::array<GLenum, 1> kColorFormats = {GL_BGRA8_EXT};
std::vector<GLenum> depthStencilFormats(
egl_vk::kConfigDepthStencilFormats,
egl_vk::kConfigDepthStencilFormats + ArraySize(egl_vk::kConfigDepthStencilFormats));
if (getCaps().stencil8)
{
depthStencilFormats.push_back(GL_STENCIL_INDEX8);
}
egl::ConfigSet cfgSet =
egl_vk::GenerateConfigs(kColorFormats.data(), kColorFormats.size(),
depthStencilFormats.data(), depthStencilFormats.size(), this);
cfgSet.begin()->second.nativeVisualID = DRM_FORMAT_XRGB8888;
return cfgSet;
}
void DisplayVkGbm::checkConfigSupport(egl::Config *config) {}
const char *DisplayVkGbm::getWSIExtension() const
{
return nullptr;
}
bool DisplayVkGbm::isUsingSwapchain() const
{
return true;
}
bool IsVulkanGbmDisplayAvailable()
{
return true;
}
DisplayImpl *CreateVulkanGbmDisplay(const egl::DisplayState &state)
{
return new DisplayVkGbm(state);
}
} // namespace rx