1 // Copyright 2019 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 #include "VkStringify.hpp" 16 17 #include "System/Debug.hpp" 18 19 #include <vulkan/vk_google_filtering_precision.h> 20 #define VULKAN_HPP_NO_EXCEPTIONS 21 #define VULKAN_HPP_NAMESPACE vkhpp 22 #include <vulkan/vulkan.hpp> 23 24 namespace vk { 25 Stringify(VkStructureType value)26std::string Stringify(VkStructureType value) 27 { 28 #ifndef NDEBUG 29 switch(static_cast<int>(value)) 30 { 31 default: 32 return vkhpp::to_string(static_cast<vkhpp::StructureType>(value)); 33 34 // TODO(b/174746309): This structure's extension has not been upstreamed yet. 35 case VK_STRUCTURE_TYPE_SAMPLER_FILTERING_PRECISION_GOOGLE: 36 return "SamplerFilteringPrecisionGOOGLE"; 37 } 38 #else 39 // In Release builds we avoid a dependency on vkhpp::to_string() to reduce binary size. 40 return std::to_string(static_cast<int>(value)); 41 #endif 42 } 43 Stringify(VkFormat value)44std::string Stringify(VkFormat value) 45 { 46 #ifndef NDEBUG 47 return vkhpp::to_string(static_cast<vkhpp::Format>(value)); 48 #else 49 // In Release builds we avoid a dependency on vkhpp::to_string() to reduce binary size. 50 return std::to_string(static_cast<int>(value)); 51 #endif 52 } 53 54 } // namespace vk 55