blob: 9c11792eb39767a8890fb987b98b18f026521fbd [file] [log] [blame]
Austin Engcc2516a2023-10-17 20:57:54 +00001// Copyright 2022 The Dawn & Tint Authors
Ben Clayton7f2b8cd2022-05-18 22:41:48 +00002//
Austin Engcc2516a2023-10-17 20:57:54 +00003// Redistribution and use in source and binary forms, with or without
4// modification, are permitted provided that the following conditions are met:
Ben Clayton7f2b8cd2022-05-18 22:41:48 +00005//
Austin Engcc2516a2023-10-17 20:57:54 +00006// 1. Redistributions of source code must retain the above copyright notice, this
7// list of conditions and the following disclaimer.
Ben Clayton7f2b8cd2022-05-18 22:41:48 +00008//
Austin Engcc2516a2023-10-17 20:57:54 +00009// 2. Redistributions in binary form must reproduce the above copyright notice,
10// this list of conditions and the following disclaimer in the documentation
11// and/or other materials provided with the distribution.
12//
13// 3. Neither the name of the copyright holder nor the names of its
14// contributors may be used to endorse or promote products derived from
15// this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Ben Clayton7f2b8cd2022-05-18 22:41:48 +000027
Ben Claytonf50d56a2022-07-27 18:32:19 +000028////////////////////////////////////////////////////////////////////////////////
Ben Clayton57ded6a2023-08-22 13:22:22 +000029// File generated by 'tools/src/cmd/gen' using the template:
Ben Clayton11653892023-09-19 19:15:59 +000030// src/tint/lang/wgsl/extension.h.tmpl
Ben Claytonf50d56a2022-07-27 18:32:19 +000031//
Ben Clayton57ded6a2023-08-22 13:22:22 +000032// To regenerate run: './tools/run gen'
33//
34// Do not modify this file directly
Ben Claytonf50d56a2022-07-27 18:32:19 +000035////////////////////////////////////////////////////////////////////////////////
36
Ben Clayton11653892023-09-19 19:15:59 +000037#ifndef SRC_TINT_LANG_WGSL_EXTENSION_H_
38#define SRC_TINT_LANG_WGSL_EXTENSION_H_
Ben Clayton7f2b8cd2022-05-18 22:41:48 +000039
dan sinclair22b4dd22023-07-21 00:40:07 +000040#include "src/tint/utils/containers/unique_vector.h"
Ben Clayton68919602023-07-28 22:51:18 +000041#include "src/tint/utils/traits/traits.h"
Ben Clayton7f2b8cd2022-05-18 22:41:48 +000042
Ben Clayton11653892023-09-19 19:15:59 +000043namespace tint::wgsl {
Ben Clayton7f2b8cd2022-05-18 22:41:48 +000044
45/// An enumerator of WGSL extensions
Ben Clayton2dffb3c2023-08-07 12:35:33 +000046/// @see src/tint/lang/wgsl/intrinsics.def for extension descriptions
Ben Clayton0f8b6ef2023-08-10 14:12:42 +000047enum class Extension : uint8_t {
Ben Claytond2e0db32022-10-12 18:49:15 +000048 kUndefined,
Ben Clayton7f2b8cd2022-05-18 22:41:48 +000049 kChromiumDisableUniformityAnalysis,
Ben Clayton3e56a382023-11-09 16:22:33 +000050 kChromiumExperimentalFramebufferFetch,
Ben Clayton74688c92023-09-05 13:35:35 +000051 kChromiumExperimentalPixelLocal,
dan sinclair4abf28e2022-08-02 15:55:35 +000052 kChromiumExperimentalPushConstant,
dan sinclair5e6e6092024-08-19 20:00:01 +000053 kChromiumExperimentalSubgroupMatrix,
James Price3b97fc42023-08-01 08:08:34 +000054 kChromiumExperimentalSubgroups,
Ben Claytone4d210d2024-02-26 17:08:02 +000055 kChromiumInternalGraphite,
Le Hoang Quyenf9a99182024-05-22 21:02:35 +000056 kChromiumInternalInputAttachments,
James Price0b3400c2023-02-27 18:39:20 +000057 kChromiumInternalRelaxedUniformLayout,
Jiawei Shao2918c422024-08-15 00:55:19 +000058 kClipDistances,
Jiawei Shaocc43f152024-05-29 00:44:43 +000059 kDualSourceBlending,
Ben Claytondb368f12022-10-11 18:26:18 +000060 kF16,
James Price32950eb2024-06-26 11:25:37 +000061 kSubgroups,
62 kSubgroupsF16,
Ben Clayton7f2b8cd2022-05-18 22:41:48 +000063};
64
Ben Clayton68919602023-07-28 22:51:18 +000065/// @param value the enum value
66/// @returns the string for the given enum value
67std::string_view ToString(Extension value);
68
dan sinclair6cc183c2023-03-02 21:28:45 +000069/// @param out the stream to write to
Ben Claytonf50d56a2022-07-27 18:32:19 +000070/// @param value the Extension
Ben Clayton68919602023-07-28 22:51:18 +000071/// @returns @p out so calls can be chained
72template <typename STREAM, typename = traits::EnableIfIsOStream<STREAM>>
73auto& operator<<(STREAM& out, Extension value) {
74 return out << ToString(value);
75}
Ben Clayton7f2b8cd2022-05-18 22:41:48 +000076
Ben Claytonf50d56a2022-07-27 18:32:19 +000077/// ParseExtension parses a Extension from a string.
78/// @param str the string to parse
Ben Claytond2e0db32022-10-12 18:49:15 +000079/// @returns the parsed enum, or Extension::kUndefined if the string could not be parsed.
Ben Claytonf50d56a2022-07-27 18:32:19 +000080Extension ParseExtension(std::string_view str);
Ben Clayton7f2b8cd2022-05-18 22:41:48 +000081
Ben Clayton0b255d22023-11-08 18:34:09 +000082constexpr std::string_view kExtensionStrings[] = {
Ben Claytone4d210d2024-02-26 17:08:02 +000083 "chromium_disable_uniformity_analysis",
84 "chromium_experimental_framebuffer_fetch",
85 "chromium_experimental_pixel_local",
86 "chromium_experimental_push_constant",
dan sinclair5e6e6092024-08-19 20:00:01 +000087 "chromium_experimental_subgroup_matrix",
Ben Claytone4d210d2024-02-26 17:08:02 +000088 "chromium_experimental_subgroups",
Ben Claytone4d210d2024-02-26 17:08:02 +000089 "chromium_internal_graphite",
Le Hoang Quyenf9a99182024-05-22 21:02:35 +000090 "chromium_internal_input_attachments",
Ben Claytone4d210d2024-02-26 17:08:02 +000091 "chromium_internal_relaxed_uniform_layout",
Jiawei Shao2918c422024-08-15 00:55:19 +000092 "clip_distances",
Jiawei Shaocc43f152024-05-29 00:44:43 +000093 "dual_source_blending",
Ben Claytone4d210d2024-02-26 17:08:02 +000094 "f16",
James Price32950eb2024-06-26 11:25:37 +000095 "subgroups",
96 "subgroups_f16",
Ben Claytonb7aef032022-10-11 19:29:11 +000097};
98
Ben Clayton1d6f3542023-11-07 20:33:31 +000099/// All extensions
100static constexpr Extension kAllExtensions[] = {
101 Extension::kChromiumDisableUniformityAnalysis,
Ben Clayton3e56a382023-11-09 16:22:33 +0000102 Extension::kChromiumExperimentalFramebufferFetch,
Ben Clayton1d6f3542023-11-07 20:33:31 +0000103 Extension::kChromiumExperimentalPixelLocal,
104 Extension::kChromiumExperimentalPushConstant,
dan sinclair5e6e6092024-08-19 20:00:01 +0000105 Extension::kChromiumExperimentalSubgroupMatrix,
Ben Clayton1d6f3542023-11-07 20:33:31 +0000106 Extension::kChromiumExperimentalSubgroups,
Ben Claytone4d210d2024-02-26 17:08:02 +0000107 Extension::kChromiumInternalGraphite,
Le Hoang Quyenf9a99182024-05-22 21:02:35 +0000108 Extension::kChromiumInternalInputAttachments,
Ben Clayton1d6f3542023-11-07 20:33:31 +0000109 Extension::kChromiumInternalRelaxedUniformLayout,
Jiawei Shao2918c422024-08-15 00:55:19 +0000110 Extension::kClipDistances,
Jiawei Shaocc43f152024-05-29 00:44:43 +0000111 Extension::kDualSourceBlending,
Ben Clayton1d6f3542023-11-07 20:33:31 +0000112 Extension::kF16,
James Price32950eb2024-06-26 11:25:37 +0000113 Extension::kSubgroups,
114 Extension::kSubgroupsF16,
Ben Clayton1d6f3542023-11-07 20:33:31 +0000115};
116
117/// A unique vector of extensions
dan sinclairbae54e72023-07-28 15:01:54 +0000118using Extensions = UniqueVector<Extension, 4>;
Ben Clayton7f2b8cd2022-05-18 22:41:48 +0000119
Ben Clayton11653892023-09-19 19:15:59 +0000120} // namespace tint::wgsl
Ben Clayton7f2b8cd2022-05-18 22:41:48 +0000121
Ben Clayton11653892023-09-19 19:15:59 +0000122#endif // SRC_TINT_LANG_WGSL_EXTENSION_H_