1 // 2 // Copyright (c) 2022 The Khronos Group Inc. 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 // 16 17 #ifndef _vulkan_utility_hpp_ 18 #define _vulkan_utility_hpp_ 19 20 #include "vulkan_wrapper_types.hpp" 21 #include <vector> 22 #include <ostream> 23 #include <string.h> 24 #include <map> 25 #include "../../../test_common/harness/testHarness.h" 26 27 #define STRING_(str) #str 28 #define STRING(str) STRING_(str) 29 30 #define ROUND_UP(n, multiple) \ 31 (((n) + (multiple)-1) - ((((n) + (multiple)-1)) % (multiple))) 32 33 const VulkanInstance& getVulkanInstance(); 34 const VulkanPhysicalDevice& getVulkanPhysicalDevice(); 35 const VulkanQueueFamily& 36 getVulkanQueueFamily(uint32_t queueFlags = VULKAN_QUEUE_FLAG_MASK_ALL); 37 const VulkanMemoryType& 38 getVulkanMemoryType(const VulkanDevice& device, 39 VulkanMemoryTypeProperty memoryTypeProperty); 40 bool checkVkSupport(); 41 const VulkanQueueFamilyList& getEmptyVulkanQueueFamilyList(); 42 const VulkanDescriptorSetLayoutList& getEmptyVulkanDescriptorSetLayoutList(); 43 const VulkanQueueFamilyToQueueCountMap& 44 getDefaultVulkanQueueFamilyToQueueCountMap(); 45 const std::vector<VulkanExternalMemoryHandleType> 46 getSupportedVulkanExternalMemoryHandleTypeList(); 47 const std::vector<VulkanExternalSemaphoreHandleType> 48 getSupportedVulkanExternalSemaphoreHandleTypeList(); 49 const std::vector<VulkanFormat> getSupportedVulkanFormatList(); 50 51 uint32_t getVulkanFormatElementSize(VulkanFormat format); 52 const char* getVulkanFormatGLSLFormat(VulkanFormat format); 53 const char* getVulkanFormatGLSLTypePrefix(VulkanFormat format); 54 55 std::string prepareVulkanShader( 56 std::string shaderCode, 57 const std::map<std::string, std::string>& patternToSubstituteMap); 58 59 std::ostream& operator<<(std::ostream& os, 60 VulkanMemoryTypeProperty memoryTypeProperty); 61 std::ostream& 62 operator<<(std::ostream& os, 63 VulkanExternalMemoryHandleType externalMemoryHandleType); 64 std::ostream& 65 operator<<(std::ostream& os, 66 VulkanExternalSemaphoreHandleType externalSemaphoreHandleType); 67 std::ostream& operator<<(std::ostream& os, VulkanFormat format); 68 69 std::vector<char> readFile(const std::string& filename); 70 #endif // _vulkan_utility_hpp_ 71