• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //* Copyright 2018 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 #include "dawn_native/ValidationUtils_autogen.h"
16 
17 namespace dawn_native {
18 
19     {% for type in by_category["enum"] %}
20         MaybeError Validate{{type.name.CamelCase()}}(wgpu::{{as_cppType(type.name)}} value) {
21             switch (value) {
22                 {% for value in type.values if value.valid %}
23                     case wgpu::{{as_cppType(type.name)}}::{{as_cppEnum(value.name)}}:
24                         return {};
25                 {% endfor %}
26                 default:
27                     return DAWN_VALIDATION_ERROR("Invalid value for {{as_cType(type.name)}}");
28             }
29         }
30 
31     {% endfor %}
32 
33     {% for type in by_category["bitmask"] %}
34         MaybeError Validate{{type.name.CamelCase()}}(wgpu::{{as_cppType(type.name)}} value) {
35             if ((value & static_cast<wgpu::{{as_cppType(type.name)}}>(~{{type.full_mask}})) == 0) {
36                 return {};
37             }
38             return DAWN_VALIDATION_ERROR("Invalid value for {{as_cType(type.name)}}");
39         }
40 
41     {% endfor %}
42 
43 } // namespace dawn_native
44