2021-12-14 01:06:15 +00:00
|
|
|
//* This template itself is part of the Dawn source and follows Dawn's license,
|
|
|
|
//* which is Apache 2.0.
|
|
|
|
//*
|
2021-12-16 00:52:26 +00:00
|
|
|
//* The WebGPU native API is a joint project used by Google, Mozilla, and Apple.
|
|
|
|
//* It was agreed to use a BSD 3-Clause license so that it is GPLv2-compatible.
|
2021-12-14 01:06:15 +00:00
|
|
|
//*
|
|
|
|
//* As a result, the template comments using //* at the top of the file are
|
|
|
|
//* removed during generation such that the resulting file starts with the
|
|
|
|
//* BSD 3-Clause comment, which is inside BSD_LICENSE as included below.
|
|
|
|
//*
|
2020-01-15 15:39:12 +00:00
|
|
|
//* Copyright 2020 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-14 01:06:15 +00:00
|
|
|
{% include 'BSD_LICENSE' %}
|
2022-02-09 19:42:51 +00:00
|
|
|
{% if 'dawn' in enabled_tags %}
|
|
|
|
#ifdef __EMSCRIPTEN__
|
|
|
|
#error "Do not include this header. Emscripten already provides headers needed for {{metadata.api}}."
|
|
|
|
#endif
|
|
|
|
{% endif %}
|
2021-11-23 08:47:35 +00:00
|
|
|
#ifndef {{metadata.api.upper()}}_H_
|
|
|
|
#define {{metadata.api.upper()}}_H_
|
2019-10-21 20:04:10 +00:00
|
|
|
|
2023-05-23 08:16:55 +00:00
|
|
|
{% set API = metadata.c_prefix %}
|
|
|
|
#if defined({{API}}_SHARED_LIBRARY)
|
2019-10-21 20:04:10 +00:00
|
|
|
# if defined(_WIN32)
|
2023-05-23 08:16:55 +00:00
|
|
|
# if defined({{API}}_IMPLEMENTATION)
|
|
|
|
# define {{API}}_EXPORT __declspec(dllexport)
|
2019-10-21 20:04:10 +00:00
|
|
|
# else
|
2023-05-23 08:16:55 +00:00
|
|
|
# define {{API}}_EXPORT __declspec(dllimport)
|
2019-10-21 20:04:10 +00:00
|
|
|
# endif
|
|
|
|
# else // defined(_WIN32)
|
2023-05-23 08:16:55 +00:00
|
|
|
# if defined({{API}}_IMPLEMENTATION)
|
|
|
|
# define {{API}}_EXPORT __attribute__((visibility("default")))
|
2019-10-21 20:04:10 +00:00
|
|
|
# else
|
2023-05-23 08:16:55 +00:00
|
|
|
# define {{API}}_EXPORT
|
2019-10-21 20:04:10 +00:00
|
|
|
# endif
|
|
|
|
# endif // defined(_WIN32)
|
2023-05-23 08:16:55 +00:00
|
|
|
#else // defined({{API}}_SHARED_LIBRARY)
|
|
|
|
# define {{API}}_EXPORT
|
|
|
|
#endif // defined({{API}}_SHARED_LIBRARY)
|
|
|
|
|
|
|
|
#if !defined({{API}}_OBJECT_ATTRIBUTE)
|
|
|
|
#define {{API}}_OBJECT_ATTRIBUTE
|
|
|
|
#endif
|
|
|
|
#if !defined({{API}}_ENUM_ATTRIBUTE)
|
|
|
|
#define {{API}}_ENUM_ATTRIBUTE
|
|
|
|
#endif
|
|
|
|
#if !defined({{API}}_STRUCTURE_ATTRIBUTE)
|
|
|
|
#define {{API}}_STRUCTURE_ATTRIBUTE
|
|
|
|
#endif
|
|
|
|
#if !defined({{API}}_FUNCTION_ATTRIBUTE)
|
|
|
|
#define {{API}}_FUNCTION_ATTRIBUTE
|
|
|
|
#endif
|
|
|
|
#if !defined({{API}}_NULLABLE)
|
|
|
|
#define {{API}}_NULLABLE
|
|
|
|
#endif
|
2019-10-21 20:04:10 +00:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2021-11-25 08:44:01 +00:00
|
|
|
{% for constant in by_category["constant"] %}
|
2023-05-23 08:16:55 +00:00
|
|
|
#define {{API}}_{{constant.name.SNAKE_CASE()}} {{constant.value}}
|
2021-11-25 08:44:01 +00:00
|
|
|
{% endfor %}
|
2019-10-21 20:04:10 +00:00
|
|
|
|
2023-05-23 08:16:55 +00:00
|
|
|
typedef uint32_t {{API}}Flags;
|
2019-10-21 20:04:10 +00:00
|
|
|
|
|
|
|
{% for type in by_category["object"] %}
|
2023-05-23 08:16:55 +00:00
|
|
|
typedef struct {{as_cType(type.name)}}Impl* {{as_cType(type.name)}} {{API}}_OBJECT_ATTRIBUTE;
|
2019-10-21 20:04:10 +00:00
|
|
|
{% endfor %}
|
|
|
|
|
2023-05-17 01:52:30 +00:00
|
|
|
// Structure forward declarations
|
|
|
|
{% for type in by_category["structure"] %}
|
|
|
|
struct {{as_cType(type.name)}};
|
|
|
|
{% endfor %}
|
|
|
|
|
2019-10-21 20:04:10 +00:00
|
|
|
{% for type in by_category["enum"] + by_category["bitmask"] %}
|
|
|
|
typedef enum {{as_cType(type.name)}} {
|
|
|
|
{% for value in type.values %}
|
|
|
|
{{as_cEnum(type.name, value.name)}} = 0x{{format(value.value, "08X")}},
|
|
|
|
{% endfor %}
|
|
|
|
{{as_cEnum(type.name, Name("force32"))}} = 0x7FFFFFFF
|
2023-05-23 08:16:55 +00:00
|
|
|
} {{as_cType(type.name)}} {{API}}_ENUM_ATTRIBUTE;
|
2019-10-21 20:04:10 +00:00
|
|
|
{% if type.category == "bitmask" %}
|
2023-05-23 08:16:55 +00:00
|
|
|
typedef {{API}}Flags {{as_cType(type.name)}}Flags {{API}}_ENUM_ATTRIBUTE;
|
2019-10-21 20:04:10 +00:00
|
|
|
{% endif %}
|
|
|
|
|
2021-09-17 19:44:43 +00:00
|
|
|
{% endfor -%}
|
2023-05-17 01:52:30 +00:00
|
|
|
{% for type in by_category["function pointer"] %}
|
|
|
|
typedef {{as_cType(type.return_type.name)}} (*{{as_cType(type.name)}})(
|
|
|
|
{%- if type.arguments == [] -%}
|
|
|
|
void
|
|
|
|
{%- else -%}
|
|
|
|
{%- for arg in type.arguments -%}
|
2023-05-23 08:16:55 +00:00
|
|
|
{% if not loop.first %}, {% endif %}
|
|
|
|
{% if arg.type.category == "structure" %}struct {% endif %}{{as_annotated_cType(arg)}}
|
2023-05-17 01:52:30 +00:00
|
|
|
{%- endfor -%}
|
|
|
|
{%- endif -%}
|
2023-05-23 08:16:55 +00:00
|
|
|
) {{API}}_FUNCTION_ATTRIBUTE;
|
2023-05-17 01:52:30 +00:00
|
|
|
{% endfor %}
|
|
|
|
|
2023-05-23 08:16:55 +00:00
|
|
|
typedef struct {{API}}ChainedStruct {
|
|
|
|
struct {{API}}ChainedStruct const * next;
|
|
|
|
{{API}}SType sType;
|
|
|
|
} {{API}}ChainedStruct {{API}}_STRUCTURE_ATTRIBUTE;
|
2020-01-15 09:54:42 +00:00
|
|
|
|
2023-05-23 08:16:55 +00:00
|
|
|
typedef struct {{API}}ChainedStructOut {
|
|
|
|
struct {{API}}ChainedStructOut * next;
|
|
|
|
{{API}}SType sType;
|
|
|
|
} {{API}}ChainedStructOut {{API}}_STRUCTURE_ATTRIBUTE;
|
2021-09-17 15:36:00 +00:00
|
|
|
|
2019-10-21 20:04:10 +00:00
|
|
|
{% for type in by_category["structure"] %}
|
2022-07-14 12:58:25 +00:00
|
|
|
{% for root in type.chain_roots %}
|
|
|
|
// Can be chained in {{as_cType(root.name)}}
|
|
|
|
{% endfor %}
|
2019-10-21 20:04:10 +00:00
|
|
|
typedef struct {{as_cType(type.name)}} {
|
2021-09-17 15:36:00 +00:00
|
|
|
{% set Out = "Out" if type.output else "" %}
|
2021-09-21 17:36:27 +00:00
|
|
|
{% set const = "const " if not type.output else "" %}
|
2019-10-21 20:04:10 +00:00
|
|
|
{% if type.extensible %}
|
2023-05-23 08:16:55 +00:00
|
|
|
{{API}}ChainedStruct{{Out}} {{const}}* nextInChain;
|
2020-01-15 09:54:42 +00:00
|
|
|
{% endif %}
|
|
|
|
{% if type.chained %}
|
2023-05-23 08:16:55 +00:00
|
|
|
{{API}}ChainedStruct{{Out}} chain;
|
2019-10-21 20:04:10 +00:00
|
|
|
{% endif %}
|
|
|
|
{% for member in type.members %}
|
2023-05-23 08:16:55 +00:00
|
|
|
{% if member.optional %}
|
|
|
|
{{API}}_NULLABLE {{as_annotated_cType(member)}};
|
|
|
|
{% else %}
|
|
|
|
{{as_annotated_cType(member)}};
|
|
|
|
{% endif-%}
|
2019-10-21 20:04:10 +00:00
|
|
|
{% endfor %}
|
2023-05-23 08:16:55 +00:00
|
|
|
} {{as_cType(type.name)}} {{API}}_STRUCTURE_ATTRIBUTE;
|
2019-10-21 20:04:10 +00:00
|
|
|
|
|
|
|
{% endfor %}
|
2021-02-08 19:48:06 +00:00
|
|
|
{% for typeDef in by_category["typedef"] %}
|
|
|
|
// {{as_cType(typeDef.name)}} is deprecated.
|
|
|
|
// Use {{as_cType(typeDef.type.name)}} instead.
|
|
|
|
typedef {{as_cType(typeDef.type.name)}} {{as_cType(typeDef.name)}};
|
|
|
|
|
|
|
|
{% endfor %}
|
2019-10-21 20:04:10 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2023-05-23 08:16:55 +00:00
|
|
|
#if !defined({{API}}_SKIP_PROCS)
|
2019-10-21 20:04:10 +00:00
|
|
|
|
2021-12-02 07:41:21 +00:00
|
|
|
{% for function in by_category["function"] %}
|
|
|
|
typedef {{as_cType(function.return_type.name)}} (*{{as_cProc(None, function.name)}})(
|
|
|
|
{%- for arg in function.arguments -%}
|
|
|
|
{% if not loop.first %}, {% endif %}{{as_annotated_cType(arg)}}
|
|
|
|
{%- endfor -%}
|
2023-05-23 08:16:55 +00:00
|
|
|
) {{API}}_FUNCTION_ATTRIBUTE;
|
2021-12-02 07:41:21 +00:00
|
|
|
{% endfor %}
|
2019-10-21 20:04:10 +00:00
|
|
|
|
2019-11-22 14:02:52 +00:00
|
|
|
{% for type in by_category["object"] if len(c_methods(type)) > 0 %}
|
2019-10-21 20:04:10 +00:00
|
|
|
// Procs of {{type.name.CamelCase()}}
|
2019-11-22 14:02:52 +00:00
|
|
|
{% for method in c_methods(type) %}
|
2019-10-21 20:04:10 +00:00
|
|
|
typedef {{as_cType(method.return_type.name)}} (*{{as_cProc(type.name, method.name)}})(
|
|
|
|
{{-as_cType(type.name)}} {{as_varName(type.name)}}
|
|
|
|
{%- for arg in method.arguments -%}
|
2023-05-23 08:16:55 +00:00
|
|
|
,{{" "}}
|
|
|
|
{%- if arg.optional %}{{API}}_NULLABLE {% endif -%}
|
|
|
|
{{as_annotated_cType(arg)}}
|
2019-10-21 20:04:10 +00:00
|
|
|
{%- endfor -%}
|
2023-05-23 08:16:55 +00:00
|
|
|
) {{API}}_FUNCTION_ATTRIBUTE;
|
2019-10-21 20:04:10 +00:00
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
{% endfor %}
|
2023-05-23 08:16:55 +00:00
|
|
|
#endif // !defined({{API}}_SKIP_PROCS)
|
2019-10-21 20:04:10 +00:00
|
|
|
|
2023-05-23 08:16:55 +00:00
|
|
|
#if !defined({{API}}_SKIP_DECLARATIONS)
|
2019-10-21 20:04:10 +00:00
|
|
|
|
2021-12-02 07:41:21 +00:00
|
|
|
{% for function in by_category["function"] %}
|
2023-05-23 08:16:55 +00:00
|
|
|
{{API}}_EXPORT {{as_cType(function.return_type.name)}} {{as_cMethod(None, function.name)}}(
|
2021-12-02 07:41:21 +00:00
|
|
|
{%- for arg in function.arguments -%}
|
|
|
|
{% if not loop.first %}, {% endif %}{{as_annotated_cType(arg)}}
|
|
|
|
{%- endfor -%}
|
2023-05-23 08:16:55 +00:00
|
|
|
) {{API}}_FUNCTION_ATTRIBUTE;
|
2021-12-02 07:41:21 +00:00
|
|
|
{% endfor %}
|
2019-10-21 20:04:10 +00:00
|
|
|
|
2019-11-22 14:02:52 +00:00
|
|
|
{% for type in by_category["object"] if len(c_methods(type)) > 0 %}
|
2019-10-21 20:04:10 +00:00
|
|
|
// Methods of {{type.name.CamelCase()}}
|
2019-11-22 14:02:52 +00:00
|
|
|
{% for method in c_methods(type) %}
|
2023-05-23 08:16:55 +00:00
|
|
|
{{API}}_EXPORT {{as_cType(method.return_type.name)}} {{as_cMethod(type.name, method.name)}}(
|
2019-10-21 20:04:10 +00:00
|
|
|
{{-as_cType(type.name)}} {{as_varName(type.name)}}
|
|
|
|
{%- for arg in method.arguments -%}
|
2023-05-23 08:16:55 +00:00
|
|
|
,{{" "}}
|
|
|
|
{%- if arg.optional %}{{API}}_NULLABLE {% endif -%}
|
|
|
|
{{as_annotated_cType(arg)}}
|
2019-10-21 20:04:10 +00:00
|
|
|
{%- endfor -%}
|
2023-05-23 08:16:55 +00:00
|
|
|
) {{API}}_FUNCTION_ATTRIBUTE;
|
2019-10-21 20:04:10 +00:00
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
{% endfor %}
|
2023-05-23 08:16:55 +00:00
|
|
|
#endif // !defined({{API}}_SKIP_DECLARATIONS)
|
2019-10-21 20:04:10 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
2021-11-23 08:47:35 +00:00
|
|
|
#endif // {{metadata.api.upper()}}_H_
|