Hash :
616a341b
Author :
Date :
2025-08-26T13:56:40
Vulkan: Set EGL_NATIVE_VISUAL_ID for EGL_KHR_platform_gbm Spec requires EGLConfig on GBM platform to report a GBM color format in EGL_NATIVE_VISUAL_ID. Previously this field was left unset. This change ensures compliance by assigning the appropriate GBM color format. Bug: angleproject:7829 Change-Id: I6c5a23374824c444e0de0b6592ea31eb855722e4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6882716 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@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
//
// 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::Error(EGL_NOT_INITIALIZED);
}
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);
return cfgSet;
}
void DisplayVkGbm::checkConfigSupport(egl::Config *config)
{
ASSERT(mGbmDevice);
uint32_t format = angle::GLInternalFormatToDrmFourCCFormat(config->renderTargetFormat);
uint32_t flags = GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT;
if (!gbm_device_is_format_supported(mGbmDevice, format, flags))
{
config->surfaceType &= ~EGL_WINDOW_BIT;
return;
}
config->nativeVisualID = format;
}
const char *DisplayVkGbm::getWSIExtension() const
{
return nullptr;
}
angle::NativeWindowSystem DisplayVkGbm::getWindowSystem() const
{
return angle::NativeWindowSystem::Gbm;
}
bool IsVulkanGbmDisplayAvailable()
{
return true;
}
DisplayImpl *CreateVulkanGbmDisplay(const egl::DisplayState &state)
{
return new DisplayVkGbm(state);
}
} // namespace rx