2021-10-27 19:07:37 +00:00
|
|
|
//* Copyright 2021 The Dawn Authors
|
|
|
|
//*
|
|
|
|
//* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
//* you may not use this file except in compliance with the License.
|
|
|
|
//* You may obtain a copy of the License at
|
|
|
|
//*
|
|
|
|
//* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//*
|
|
|
|
//* Unless required by applicable law or agreed to in writing, software
|
|
|
|
//* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//* See the License for the specific language governing permissions and
|
|
|
|
//* limitations under the License.
|
|
|
|
|
2021-12-17 00:46:08 +00:00
|
|
|
{% set namespace_name = Name(metadata.native_namespace) %}
|
|
|
|
{% set NATIVE_DIR = namespace_name.concatcase().upper() %}
|
|
|
|
{% set PREFIX = metadata.proc_table_prefix.upper() %}
|
|
|
|
#ifndef {{NATIVE_DIR}}_{{PREFIX}}_PLATFORM_AUTOGEN_H_
|
|
|
|
#define {{NATIVE_DIR}}_{{PREFIX}}_PLATFORM_AUTOGEN_H_
|
2021-10-27 19:07:37 +00:00
|
|
|
|
2021-12-17 00:46:08 +00:00
|
|
|
{% set api = metadata.api.lower() %}
|
|
|
|
#include "dawn/{{api}}_cpp.h"
|
|
|
|
{% set impl_dir = metadata.impl_dir + "/" if metadata.impl_dir else "" %}
|
2022-01-12 09:17:35 +00:00
|
|
|
{% set native_namespace = namespace_name.namespace_case() %}
|
2022-02-04 17:07:46 +00:00
|
|
|
{% set native_dir = impl_dir + namespace_name.Dirs() %}
|
2021-12-17 00:46:08 +00:00
|
|
|
#include "{{native_dir}}/Forward.h"
|
2021-10-27 19:07:37 +00:00
|
|
|
|
2021-12-17 00:46:08 +00:00
|
|
|
{% set namespace = metadata.namespace %}
|
|
|
|
// Use our autogenerated version of the {{namespace}} structures that point to {{native_namespace}} object types
|
2022-01-12 09:17:35 +00:00
|
|
|
// (wgpu::Buffer is dawn::native::BufferBase*)
|
2021-12-17 00:46:08 +00:00
|
|
|
#include <{{native_dir}}/{{namespace}}_structs_autogen.h>
|
2021-10-27 19:07:37 +00:00
|
|
|
|
2021-12-17 00:46:08 +00:00
|
|
|
namespace {{native_namespace}} {
|
2021-10-27 19:07:37 +00:00
|
|
|
|
|
|
|
{% for type in by_category["structure"] %}
|
|
|
|
inline const {{as_cType(type.name)}}* ToAPI(const {{as_cppType(type.name)}}* rhs) {
|
|
|
|
return reinterpret_cast<const {{as_cType(type.name)}}*>(rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline {{as_cType(type.name)}}* ToAPI({{as_cppType(type.name)}}* rhs) {
|
|
|
|
return reinterpret_cast<{{as_cType(type.name)}}*>(rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const {{as_cppType(type.name)}}* FromAPI(const {{as_cType(type.name)}}* rhs) {
|
|
|
|
return reinterpret_cast<const {{as_cppType(type.name)}}*>(rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline {{as_cppType(type.name)}}* FromAPI({{as_cType(type.name)}}* rhs) {
|
|
|
|
return reinterpret_cast<{{as_cppType(type.name)}}*>(rhs);
|
|
|
|
}
|
2023-02-17 22:40:13 +00:00
|
|
|
|
|
|
|
inline const {{metadata.namespace}}::{{as_cppType(type.name)}}* ToCppAPI(const {{as_cppType(type.name)}}* rhs) {
|
|
|
|
return reinterpret_cast<const {{metadata.namespace}}::{{as_cppType(type.name)}}*>(rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline {{metadata.namespace}}::{{as_cppType(type.name)}}* ToCppAPI({{as_cppType(type.name)}}* rhs) {
|
|
|
|
return reinterpret_cast<{{metadata.namespace}}::{{as_cppType(type.name)}}*>(rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const {{as_cppType(type.name)}}* FromCppAPI(const {{metadata.namespace}}::{{as_cppType(type.name)}}* rhs) {
|
|
|
|
return reinterpret_cast<const {{as_cppType(type.name)}}*>(rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline {{as_cppType(type.name)}}* FromCppAPI({{metadata.namespace}}::{{as_cppType(type.name)}}* rhs) {
|
|
|
|
return reinterpret_cast<{{as_cppType(type.name)}}*>(rhs);
|
|
|
|
}
|
|
|
|
|
2021-10-27 19:07:37 +00:00
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
{% for type in by_category["object"] %}
|
|
|
|
inline const {{as_cType(type.name)}}Impl* ToAPI(const {{as_cppType(type.name)}}Base* rhs) {
|
|
|
|
return reinterpret_cast<const {{as_cType(type.name)}}Impl*>(rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline {{as_cType(type.name)}}Impl* ToAPI({{as_cppType(type.name)}}Base* rhs) {
|
|
|
|
return reinterpret_cast<{{as_cType(type.name)}}Impl*>(rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const {{as_cppType(type.name)}}Base* FromAPI(const {{as_cType(type.name)}}Impl* rhs) {
|
|
|
|
return reinterpret_cast<const {{as_cppType(type.name)}}Base*>(rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline {{as_cppType(type.name)}}Base* FromAPI({{as_cType(type.name)}}Impl* rhs) {
|
|
|
|
return reinterpret_cast<{{as_cppType(type.name)}}Base*>(rhs);
|
|
|
|
}
|
|
|
|
{% endfor %}
|
2021-12-02 18:12:57 +00:00
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct EnumCount;
|
|
|
|
|
|
|
|
{% for e in by_category["enum"] if e.contiguousFromZero %}
|
|
|
|
template<>
|
2021-12-17 00:46:08 +00:00
|
|
|
struct EnumCount<{{namespace}}::{{as_cppType(e.name)}}> {
|
2021-12-02 18:12:57 +00:00
|
|
|
static constexpr uint32_t value = {{len(e.values)}};
|
|
|
|
};
|
|
|
|
{% endfor %}
|
2022-06-08 14:46:41 +00:00
|
|
|
|
|
|
|
{% for type in by_category["enum"] + by_category["bitmask"] %}
|
|
|
|
inline {{as_cType(type.name)}} ToAPI({{namespace}}::{{as_cppType(type.name)}} rhs) {
|
|
|
|
return static_cast<{{as_cType(type.name)}}>(rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline {{namespace}}::{{as_cppType(type.name)}} FromAPI({{as_cType(type.name)}} rhs) {
|
|
|
|
return static_cast<{{namespace}}::{{as_cppType(type.name)}}>(rhs);
|
|
|
|
}
|
|
|
|
{% endfor %}
|
2023-02-17 22:40:13 +00:00
|
|
|
} // namespace {{native_namespace}}
|
2021-10-27 19:07:37 +00:00
|
|
|
|
2022-01-12 09:17:35 +00:00
|
|
|
#endif // {{NATIVE_DIR}}_{{PREFIX}}_PLATFORM_AUTOGEN_H_
|