1 //* Copyright 2021 The Dawn Authors 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 WEBGPU_ABSL_FORMAT_H_ 16 #define WEBGPU_ABSL_FORMAT_H_ 17 18 #include "dawn_native/dawn_platform.h" 19 20 #include "absl/strings/str_format.h" 21 22 namespace dawn_native { 23 24 // TODO(dawn:563): 25 // - Split the file between autogenerated parts and manually written parts. 26 // - Forward declare common Dawn enums and have AbslFormatConvert for them. 27 // - Support AbslFormatConvert for Dawn's typed integers. 28 29 // 30 // Structs (Manually written) 31 // 32 33 struct Color; 34 absl::FormatConvertResult<absl::FormatConversionCharSet::kString> 35 AbslFormatConvert(const Color* value, 36 const absl::FormatConversionSpec& spec, 37 absl::FormatSink* s); 38 39 struct Extent3D; 40 absl::FormatConvertResult<absl::FormatConversionCharSet::kString> 41 AbslFormatConvert(const Extent3D* value, 42 const absl::FormatConversionSpec& spec, 43 absl::FormatSink* s); 44 45 struct Origin3D; 46 absl::FormatConvertResult<absl::FormatConversionCharSet::kString> 47 AbslFormatConvert(const Origin3D* value, 48 const absl::FormatConversionSpec& spec, 49 absl::FormatSink* s); 50 51 // 52 // Objects 53 // 54 55 class DeviceBase; 56 absl::FormatConvertResult<absl::FormatConversionCharSet::kString> 57 AbslFormatConvert(const DeviceBase* value, 58 const absl::FormatConversionSpec& spec, 59 absl::FormatSink* s); 60 61 class ApiObjectBase; 62 absl::FormatConvertResult<absl::FormatConversionCharSet::kString> 63 AbslFormatConvert(const ApiObjectBase* value, 64 const absl::FormatConversionSpec& spec, 65 absl::FormatSink* s); 66 67 // Special case for TextureViews, since frequently the texture will be the 68 // thing that's labeled. 69 class TextureViewBase; 70 absl::FormatConvertResult<absl::FormatConversionCharSet::kString> 71 AbslFormatConvert(const TextureViewBase* value, 72 const absl::FormatConversionSpec& spec, 73 absl::FormatSink* s); 74 75 // 76 // Descriptors 77 // 78 79 // Only includes structures that have a 'label' member. 80 {% for type in by_category["structure"] %} 81 {% for member in type.members %} 82 {% if member.name.canonical_case() == "label" %} 83 absl::FormatConvertResult<absl::FormatConversionCharSet::kString> 84 AbslFormatConvert(const {{as_cppType(type.name)}}* value, 85 const absl::FormatConversionSpec& spec, 86 absl::FormatSink* s); 87 {% endif %} 88 {% endfor %} 89 {% endfor %} 90 } 91 92 namespace wgpu { 93 94 // 95 // Enums 96 // 97 98 {% for type in by_category["enum"] %} 99 absl::FormatConvertResult<absl::FormatConversionCharSet::kString> 100 AbslFormatConvert({{as_cppType(type.name)}} value, 101 const absl::FormatConversionSpec& spec, 102 absl::FormatSink* s); 103 {% endfor %} 104 105 // 106 // Bitmasks 107 // 108 109 {% for type in by_category["bitmask"] %} 110 absl::FormatConvertResult<absl::FormatConversionCharSet::kString> 111 AbslFormatConvert({{as_cppType(type.name)}} value, 112 const absl::FormatConversionSpec& spec, 113 absl::FormatSink* s); 114 {% endfor %} 115 116 } // namespace dawn_native 117 118 #endif // WEBGPU_ABSL_FORMAT_H_ 119