1 // Copyright 2020 The SwiftShader Authors. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef SWIFTSHADER_DISPLAYSURFACEKHR_HPP 16 #define SWIFTSHADER_DISPLAYSURFACEKHR_HPP 17 18 #include "VkSurfaceKHR.hpp" 19 #include "Vulkan/VkObject.hpp" 20 21 #include <xf86drmMode.h> 22 23 namespace vk { 24 25 class DisplaySurfaceKHR : public SurfaceKHR, public ObjectBase<DisplaySurfaceKHR, VkSurfaceKHR> 26 { 27 public: 28 static VkResult GetDisplayModeProperties(uint32_t *pPropertyCount, VkDisplayModePropertiesKHR *pProperties); 29 static VkResult GetDisplayPlaneCapabilities(VkDisplayPlaneCapabilitiesKHR *pCapabilities); 30 static VkResult GetDisplayPlaneSupportedDisplays(uint32_t *pDisplayCount, VkDisplayKHR *pDisplays); 31 static VkResult GetPhysicalDeviceDisplayPlaneProperties(uint32_t *pPropertyCount, VkDisplayPlanePropertiesKHR *pProperties); 32 static VkResult GetPhysicalDeviceDisplayProperties(uint32_t *pPropertyCount, VkDisplayPropertiesKHR *pProperties); 33 34 DisplaySurfaceKHR(const VkDisplaySurfaceCreateInfoKHR *pCreateInfo, void *mem); 35 36 void destroySurface(const VkAllocationCallbacks *pAllocator) override; 37 38 static size_t ComputeRequiredAllocationSize(const VkDisplaySurfaceCreateInfoKHR *pCreateInfo); 39 40 VkResult getSurfaceCapabilities(VkSurfaceCapabilitiesKHR *pSurfaceCapabilities) const override; 41 42 virtual void attachImage(PresentImage *image) override; 43 virtual void detachImage(PresentImage *image) override; 44 VkResult present(PresentImage *image) override; 45 46 private: 47 int fd; 48 uint32_t connector_id; 49 uint32_t encoder_id; 50 uint32_t crtc_id; 51 drmModeCrtc *crtc; 52 drmModeModeInfo mode_info; 53 uint32_t handle; 54 uint32_t width; 55 uint32_t height; 56 uint32_t pitch; 57 uint32_t size; 58 uint32_t fb_id; 59 uint8_t *fb_buffer; 60 }; 61 62 } // namespace vk 63 #endif //SWIFTSHADER_DISPLAYSURFACEKHR_HPP 64