1 // 2 // Copyright 2022 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 // 6 // DisplayVkGbm.cpp: 7 // Implements the class methods for DisplayVkGbm. 8 // 9 10 #include "libANGLE/renderer/vulkan/linux/gbm/DisplayVkGbm.h" 11 12 #include <gbm.h> 13 14 #include "common/linux/dma_buf_utils.h" 15 #include "libANGLE/Display.h" 16 #include "libANGLE/renderer/vulkan/vk_caps_utils.h" 17 18 namespace rx 19 { 20 DisplayVkGbm(const egl::DisplayState & state)21DisplayVkGbm::DisplayVkGbm(const egl::DisplayState &state) 22 : DisplayVkLinux(state), mGbmDevice(nullptr) 23 {} 24 initialize(egl::Display * display)25egl::Error DisplayVkGbm::initialize(egl::Display *display) 26 { 27 mGbmDevice = reinterpret_cast<gbm_device *>(display->getNativeDisplayId()); 28 if (!mGbmDevice) 29 { 30 ERR() << "Failed to retrieve GBM device"; 31 return egl::EglNotInitialized(); 32 } 33 34 return DisplayVk::initialize(display); 35 } 36 terminate()37void DisplayVkGbm::terminate() 38 { 39 mGbmDevice = nullptr; 40 DisplayVk::terminate(); 41 } 42 isValidNativeWindow(EGLNativeWindowType window) const43bool DisplayVkGbm::isValidNativeWindow(EGLNativeWindowType window) const 44 { 45 return (void *)window != nullptr; 46 } 47 createWindowSurfaceVk(const egl::SurfaceState & state,EGLNativeWindowType window)48SurfaceImpl *DisplayVkGbm::createWindowSurfaceVk(const egl::SurfaceState &state, 49 EGLNativeWindowType window) 50 { 51 return nullptr; 52 } 53 generateConfigs()54egl::ConfigSet DisplayVkGbm::generateConfigs() 55 { 56 const std::array<GLenum, 1> kColorFormats = {GL_BGRA8_EXT}; 57 58 std::vector<GLenum> depthStencilFormats( 59 egl_vk::kConfigDepthStencilFormats, 60 egl_vk::kConfigDepthStencilFormats + ArraySize(egl_vk::kConfigDepthStencilFormats)); 61 62 if (getCaps().stencil8) 63 { 64 depthStencilFormats.push_back(GL_STENCIL_INDEX8); 65 } 66 67 egl::ConfigSet cfgSet = 68 egl_vk::GenerateConfigs(kColorFormats.data(), kColorFormats.size(), 69 depthStencilFormats.data(), depthStencilFormats.size(), this); 70 71 return cfgSet; 72 } 73 checkConfigSupport(egl::Config * config)74void DisplayVkGbm::checkConfigSupport(egl::Config *config) {} 75 getWSIExtension() const76const char *DisplayVkGbm::getWSIExtension() const 77 { 78 return nullptr; 79 } 80 getWindowSystem() const81angle::NativeWindowSystem DisplayVkGbm::getWindowSystem() const 82 { 83 return angle::NativeWindowSystem::Gbm; 84 } 85 IsVulkanGbmDisplayAvailable()86bool IsVulkanGbmDisplayAvailable() 87 { 88 return true; 89 } 90 CreateVulkanGbmDisplay(const egl::DisplayState & state)91DisplayImpl *CreateVulkanGbmDisplay(const egl::DisplayState &state) 92 { 93 return new DisplayVkGbm(state); 94 } 95 96 } // namespace rx 97