Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 1 | // Copyright 2021 The Dawn & Tint Authors |
Ben Clayton | 7f2b8cd | 2022-05-18 22:41:48 +0000 | [diff] [blame] | 2 | // |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 3 | // Redistribution and use in source and binary forms, with or without |
| 4 | // modification, are permitted provided that the following conditions are met: |
Ben Clayton | 7f2b8cd | 2022-05-18 22:41:48 +0000 | [diff] [blame] | 5 | // |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 6 | // 1. Redistributions of source code must retain the above copyright notice, this |
| 7 | // list of conditions and the following disclaimer. |
Ben Clayton | 7f2b8cd | 2022-05-18 22:41:48 +0000 | [diff] [blame] | 8 | // |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 9 | // 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 Clayton | 7f2b8cd | 2022-05-18 22:41:48 +0000 | [diff] [blame] | 27 | |
Ben Clayton | f50d56a | 2022-07-27 18:32:19 +0000 | [diff] [blame] | 28 | //////////////////////////////////////////////////////////////////////////////// |
Ben Clayton | 57ded6a | 2023-08-22 13:22:22 +0000 | [diff] [blame] | 29 | // File generated by 'tools/src/cmd/gen' using the template: |
Ben Clayton | 1165389 | 2023-09-19 19:15:59 +0000 | [diff] [blame] | 30 | // src/tint/lang/wgsl/extension_test.cc.tmpl |
Ben Clayton | f50d56a | 2022-07-27 18:32:19 +0000 | [diff] [blame] | 31 | // |
Ben Clayton | 57ded6a | 2023-08-22 13:22:22 +0000 | [diff] [blame] | 32 | // To regenerate run: './tools/run gen' |
| 33 | // |
| 34 | // Do not modify this file directly |
Ben Clayton | f50d56a | 2022-07-27 18:32:19 +0000 | [diff] [blame] | 35 | //////////////////////////////////////////////////////////////////////////////// |
| 36 | |
Ben Clayton | 1165389 | 2023-09-19 19:15:59 +0000 | [diff] [blame] | 37 | #include "src/tint/lang/wgsl/extension.h" |
dan sinclair | e4039c7 | 2023-02-17 21:58:59 +0000 | [diff] [blame] | 38 | |
| 39 | #include <gtest/gtest.h> |
Ben Clayton | 7f2b8cd | 2022-05-18 22:41:48 +0000 | [diff] [blame] | 40 | |
Ben Clayton | f50d56a | 2022-07-27 18:32:19 +0000 | [diff] [blame] | 41 | #include <string> |
| 42 | |
dan sinclair | 22b4dd2 | 2023-07-21 00:40:07 +0000 | [diff] [blame] | 43 | #include "src/tint/utils/text/string.h" |
Ben Clayton | 7f2b8cd | 2022-05-18 22:41:48 +0000 | [diff] [blame] | 44 | |
Ben Clayton | 1165389 | 2023-09-19 19:15:59 +0000 | [diff] [blame] | 45 | namespace tint::wgsl { |
Ben Clayton | 7f2b8cd | 2022-05-18 22:41:48 +0000 | [diff] [blame] | 46 | namespace { |
| 47 | |
Ben Clayton | f50d56a | 2022-07-27 18:32:19 +0000 | [diff] [blame] | 48 | namespace parse_print_tests { |
| 49 | |
| 50 | struct Case { |
| 51 | const char* string; |
| 52 | Extension value; |
| 53 | }; |
| 54 | |
| 55 | inline std::ostream& operator<<(std::ostream& out, Case c) { |
| 56 | return out << "'" << std::string(c.string) << "'"; |
Ben Clayton | 7f2b8cd | 2022-05-18 22:41:48 +0000 | [diff] [blame] | 57 | } |
| 58 | |
Ben Clayton | f50d56a | 2022-07-27 18:32:19 +0000 | [diff] [blame] | 59 | static constexpr Case kValidCases[] = { |
Ben Clayton | f50d56a | 2022-07-27 18:32:19 +0000 | [diff] [blame] | 60 | {"chromium_disable_uniformity_analysis", Extension::kChromiumDisableUniformityAnalysis}, |
Ben Clayton | 3e56a38 | 2023-11-09 16:22:33 +0000 | [diff] [blame] | 61 | {"chromium_experimental_framebuffer_fetch", Extension::kChromiumExperimentalFramebufferFetch}, |
Ben Clayton | 74688c9 | 2023-09-05 13:35:35 +0000 | [diff] [blame] | 62 | {"chromium_experimental_pixel_local", Extension::kChromiumExperimentalPixelLocal}, |
dan sinclair | 4abf28e | 2022-08-02 15:55:35 +0000 | [diff] [blame] | 63 | {"chromium_experimental_push_constant", Extension::kChromiumExperimentalPushConstant}, |
dan sinclair | 5e6e609 | 2024-08-19 20:00:01 +0000 | [diff] [blame] | 64 | {"chromium_experimental_subgroup_matrix", Extension::kChromiumExperimentalSubgroupMatrix}, |
James Price | 3b97fc4 | 2023-08-01 08:08:34 +0000 | [diff] [blame] | 65 | {"chromium_experimental_subgroups", Extension::kChromiumExperimentalSubgroups}, |
Ben Clayton | e4d210d | 2024-02-26 17:08:02 +0000 | [diff] [blame] | 66 | {"chromium_internal_graphite", Extension::kChromiumInternalGraphite}, |
Le Hoang Quyen | f9a9918 | 2024-05-22 21:02:35 +0000 | [diff] [blame] | 67 | {"chromium_internal_input_attachments", Extension::kChromiumInternalInputAttachments}, |
James Price | 0b3400c | 2023-02-27 18:39:20 +0000 | [diff] [blame] | 68 | {"chromium_internal_relaxed_uniform_layout", Extension::kChromiumInternalRelaxedUniformLayout}, |
Jiawei Shao | 2918c42 | 2024-08-15 00:55:19 +0000 | [diff] [blame] | 69 | {"clip_distances", Extension::kClipDistances}, |
Jiawei Shao | cc43f15 | 2024-05-29 00:44:43 +0000 | [diff] [blame] | 70 | {"dual_source_blending", Extension::kDualSourceBlending}, |
Ben Clayton | db368f1 | 2022-10-11 18:26:18 +0000 | [diff] [blame] | 71 | {"f16", Extension::kF16}, |
James Price | 32950eb | 2024-06-26 11:25:37 +0000 | [diff] [blame] | 72 | {"subgroups", Extension::kSubgroups}, |
| 73 | {"subgroups_f16", Extension::kSubgroupsF16}, |
Ben Clayton | f50d56a | 2022-07-27 18:32:19 +0000 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | static constexpr Case kInvalidCases[] = { |
Ben Clayton | d2e0db3 | 2022-10-12 18:49:15 +0000 | [diff] [blame] | 77 | {"chromium_disableuniformiccy_analysis", Extension::kUndefined}, |
| 78 | {"chromil3_disable_unifority_analss", Extension::kUndefined}, |
| 79 | {"chromium_disable_Vniformity_analysis", Extension::kUndefined}, |
Jiawei Shao | 53c0fa9 | 2023-12-08 01:24:00 +0000 | [diff] [blame] | 80 | {"chromium_experimental_framebuf1er_fetch", Extension::kUndefined}, |
| 81 | {"chromium_experiqqntal_framebuffer_fetch", Extension::kUndefined}, |
| 82 | {"chromium_experimental_framebuffll77_fetch", Extension::kUndefined}, |
Ben Clayton | f468667 | 2024-01-17 11:06:59 +0000 | [diff] [blame] | 83 | {"chroqqppum_expermental_pixel_HHocal", Extension::kUndefined}, |
| 84 | {"chromium_experimenta_piel_occl", Extension::kUndefined}, |
| 85 | {"chromium_exeGimental_pixel_local", Extension::kUndefined}, |
| 86 | {"chvomium_experimental_push_constiint", Extension::kUndefined}, |
| 87 | {"chromiu8WWexperimental_push_constant", Extension::kUndefined}, |
| 88 | {"chromium_experiMental_push_costanxx", Extension::kUndefined}, |
dan sinclair | 5e6e609 | 2024-08-19 20:00:01 +0000 | [diff] [blame] | 89 | {"cXromium_experimeggtal_subgrup_matrix", Extension::kUndefined}, |
| 90 | {"chrXmiuu_expeimVtal_subgroup_matrix", Extension::kUndefined}, |
| 91 | {"chromium_e3perimental_subgroup_matrix", Extension::kUndefined}, |
| 92 | {"cEromium_experimental_subgroups", Extension::kUndefined}, |
| 93 | {"TThromium_experiPPental_sugroups", Extension::kUndefined}, |
| 94 | {"chddomium_experimental_subgroxxs", Extension::kUndefined}, |
| 95 | {"chromi44m_internal_graphite", Extension::kUndefined}, |
| 96 | {"chromSSuVV_internal_graphite", Extension::kUndefined}, |
| 97 | {"cRromium_nternR22_graphite", Extension::kUndefined}, |
| 98 | {"chromium_int9rnaF_inpu_attachments", Extension::kUndefined}, |
| 99 | {"chrmium_internal_input_attachments", Extension::kUndefined}, |
| 100 | {"cOOromium_internVlHinput_ttachRRents", Extension::kUndefined}, |
| 101 | {"chromium_internl_relaxyd_uniform_layout", Extension::kUndefined}, |
| 102 | {"chromnnum_internrr77_Gelaxell_uniform_layout", Extension::kUndefined}, |
| 103 | {"chromium_intern4l_relaxe00_uniform_layout", Extension::kUndefined}, |
| 104 | {"cli_iootanes", Extension::kUndefined}, |
| 105 | {"czip_dstances", Extension::kUndefined}, |
| 106 | {"lipp_distan11es", Extension::kUndefined}, |
| 107 | {"XXual_source_blending", Extension::kUndefined}, |
| 108 | {"dual_sou5IIcennblend99ng", Extension::kUndefined}, |
| 109 | {"aSSual_soYrce_blerrdinHH", Extension::kUndefined}, |
| 110 | {"U", Extension::kUndefined}, |
| 111 | {"jV3", Extension::kUndefined}, |
| 112 | {"", Extension::kUndefined}, |
| 113 | {"uGGSrops", Extension::kUndefined}, |
| 114 | {"subgous", Extension::kUndefined}, |
| 115 | {"bgrups", Extension::kUndefined}, |
| 116 | {"subgrokp_jj6", Extension::kUndefined}, |
| 117 | {"ubgroupsffr6", Extension::kUndefined}, |
| 118 | {"subgroujs_f16", Extension::kUndefined}, |
Ben Clayton | f50d56a | 2022-07-27 18:32:19 +0000 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | using ExtensionParseTest = testing::TestWithParam<Case>; |
| 122 | |
| 123 | TEST_P(ExtensionParseTest, Parse) { |
| 124 | const char* string = GetParam().string; |
| 125 | Extension expect = GetParam().value; |
| 126 | EXPECT_EQ(expect, ParseExtension(string)); |
Ben Clayton | 7f2b8cd | 2022-05-18 22:41:48 +0000 | [diff] [blame] | 127 | } |
| 128 | |
Ben Clayton | f50d56a | 2022-07-27 18:32:19 +0000 | [diff] [blame] | 129 | INSTANTIATE_TEST_SUITE_P(ValidCases, ExtensionParseTest, testing::ValuesIn(kValidCases)); |
| 130 | INSTANTIATE_TEST_SUITE_P(InvalidCases, ExtensionParseTest, testing::ValuesIn(kInvalidCases)); |
| 131 | |
| 132 | using ExtensionPrintTest = testing::TestWithParam<Case>; |
| 133 | |
| 134 | TEST_P(ExtensionPrintTest, Print) { |
| 135 | Extension value = GetParam().value; |
| 136 | const char* expect = GetParam().string; |
Ben Clayton | 3c54ba5 | 2023-11-28 21:36:08 +0000 | [diff] [blame] | 137 | EXPECT_EQ(expect, ToString(value)); |
Ben Clayton | f50d56a | 2022-07-27 18:32:19 +0000 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | INSTANTIATE_TEST_SUITE_P(ValidCases, ExtensionPrintTest, testing::ValuesIn(kValidCases)); |
| 141 | |
| 142 | } // namespace parse_print_tests |
| 143 | |
Ben Clayton | 7f2b8cd | 2022-05-18 22:41:48 +0000 | [diff] [blame] | 144 | } // namespace |
Ben Clayton | 1165389 | 2023-09-19 19:15:59 +0000 | [diff] [blame] | 145 | } // namespace tint::wgsl |