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.
|
|
|
|
//*
|
|
|
|
//*
|
|
|
|
//* This template itself is part of the Dawn source and follows Dawn's license
|
|
|
|
//* but the generated file is used for "WebGPU native". 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.
|
|
|
|
//*
|
|
|
|
//*
|
2019-10-21 20:04:10 +00:00
|
|
|
// BSD 3-Clause License
|
|
|
|
//
|
|
|
|
// Copyright (c) 2019, "WebGPU native" developers
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// 1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
// list of conditions and the following disclaimer.
|
|
|
|
//
|
|
|
|
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
//
|
|
|
|
// 3. Neither the name of the copyright holder nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived from
|
|
|
|
// this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
|
|
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
#ifndef WEBGPU_H_
|
|
|
|
#define WEBGPU_H_
|
|
|
|
|
|
|
|
#if defined(WGPU_SHARED_LIBRARY)
|
|
|
|
# if defined(_WIN32)
|
|
|
|
# if defined(WGPU_IMPLEMENTATION)
|
|
|
|
# define WGPU_EXPORT __declspec(dllexport)
|
|
|
|
# else
|
|
|
|
# define WGPU_EXPORT __declspec(dllimport)
|
|
|
|
# endif
|
|
|
|
# else // defined(_WIN32)
|
|
|
|
# if defined(WGPU_IMPLEMENTATION)
|
|
|
|
# define WGPU_EXPORT __attribute__((visibility("default")))
|
|
|
|
# else
|
|
|
|
# define WGPU_EXPORT
|
|
|
|
# endif
|
|
|
|
# endif // defined(_WIN32)
|
|
|
|
#else // defined(WGPU_SHARED_LIBRARY)
|
|
|
|
# define WGPU_EXPORT
|
|
|
|
#endif // defined(WGPU_SHARED_LIBRARY)
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2020-02-10 20:25:36 +00:00
|
|
|
#define WGPU_WHOLE_SIZE (0xffffffffffffffffULL)
|
2021-07-25 18:40:19 +00:00
|
|
|
// TODO(crbug.com/dawn/520): Remove WGPU_STRIDE_UNDEFINED in favor of WGPU_COPY_STRIDE_UNDEFINED.
|
2020-11-06 13:41:50 +00:00
|
|
|
#define WGPU_STRIDE_UNDEFINED (0xffffffffUL)
|
2020-12-16 07:53:30 +00:00
|
|
|
#define WGPU_COPY_STRIDE_UNDEFINED (0xffffffffUL)
|
2021-09-13 18:49:09 +00:00
|
|
|
#define WGPU_LIMIT_U32_UNDEFINED (0xffffffffUL)
|
|
|
|
#define WGPU_LIMIT_U64_UNDEFINED (0xffffffffffffffffULL)
|
2021-09-14 02:41:49 +00:00
|
|
|
#define WGPU_ARRAY_LAYER_COUNT_UNDEFINED (0xffffffffUL)
|
2021-09-15 06:27:25 +00:00
|
|
|
#define WGPU_MIP_LEVEL_COUNT_UNDEFINED (0xffffffffUL)
|
2019-10-21 20:04:10 +00:00
|
|
|
|
|
|
|
typedef uint32_t WGPUFlags;
|
|
|
|
|
|
|
|
{% for type in by_category["object"] %}
|
|
|
|
typedef struct {{as_cType(type.name)}}Impl* {{as_cType(type.name)}};
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
{% 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
|
|
|
|
} {{as_cType(type.name)}};
|
|
|
|
{% if type.category == "bitmask" %}
|
|
|
|
typedef WGPUFlags {{as_cType(type.name)}}Flags;
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% endfor %}
|
|
|
|
|
2020-01-15 09:54:42 +00:00
|
|
|
typedef struct WGPUChainedStruct {
|
2020-01-25 09:30:40 +00:00
|
|
|
struct WGPUChainedStruct const * next;
|
2020-01-15 09:54:42 +00:00
|
|
|
WGPUSType sType;
|
|
|
|
} WGPUChainedStruct;
|
|
|
|
|
2019-10-21 20:04:10 +00:00
|
|
|
{% for type in by_category["structure"] %}
|
|
|
|
typedef struct {{as_cType(type.name)}} {
|
|
|
|
{% if type.extensible %}
|
2020-01-15 09:54:42 +00:00
|
|
|
WGPUChainedStruct const * nextInChain;
|
|
|
|
{% endif %}
|
|
|
|
{% if type.chained %}
|
2020-01-25 09:30:40 +00:00
|
|
|
WGPUChainedStruct chain;
|
2019-10-21 20:04:10 +00:00
|
|
|
{% endif %}
|
|
|
|
{% for member in type.members %}
|
|
|
|
{{as_annotated_cType(member)}};
|
|
|
|
{% endfor %}
|
|
|
|
} {{as_cType(type.name)}};
|
|
|
|
|
|
|
|
{% 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 %}
|
|
|
|
|
2021-07-25 18:40:19 +00:00
|
|
|
// TODO(crbug.com/dawn/1023): Remove after the deprecation period.
|
|
|
|
#define WGPUInputStepMode_Vertex WGPUVertexStepMode_Vertex
|
|
|
|
#define WGPUInputStepMode_Instance WGPUVertexStepMode_Instance
|
|
|
|
#define WGPUInputStepMode_Force32 WGPUVertexStepMode_Force32
|
|
|
|
|
2019-10-21 20:04:10 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-11-22 13:18:22 +00:00
|
|
|
{% for type in by_category["callback"] %}
|
|
|
|
typedef void (*{{as_cType(type.name)}})(
|
|
|
|
{%- for arg in type.arguments -%}
|
|
|
|
{% if not loop.first %}, {% endif %}{{as_annotated_cType(arg)}}
|
|
|
|
{%- endfor -%}
|
|
|
|
);
|
|
|
|
{% endfor %}
|
2019-10-21 20:04:10 +00:00
|
|
|
|
2020-04-07 16:09:27 +00:00
|
|
|
typedef void (*WGPUProc)(void);
|
2019-10-21 20:04:10 +00:00
|
|
|
|
|
|
|
#if !defined(WGPU_SKIP_PROCS)
|
|
|
|
|
2020-01-10 13:06:48 +00:00
|
|
|
typedef WGPUInstance (*WGPUProcCreateInstance)(WGPUInstanceDescriptor const * descriptor);
|
2019-11-26 17:28:11 +00:00
|
|
|
typedef WGPUProc (*WGPUProcGetProcAddress)(WGPUDevice device, char const * procName);
|
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 -%}
|
|
|
|
, {{as_annotated_cType(arg)}}
|
|
|
|
{%- endfor -%}
|
|
|
|
);
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
{% endfor %}
|
|
|
|
#endif // !defined(WGPU_SKIP_PROCS)
|
|
|
|
|
|
|
|
#if !defined(WGPU_SKIP_DECLARATIONS)
|
|
|
|
|
2020-01-10 13:06:48 +00:00
|
|
|
WGPU_EXPORT WGPUInstance wgpuCreateInstance(WGPUInstanceDescriptor const * descriptor);
|
2019-11-26 17:28:11 +00:00
|
|
|
WGPU_EXPORT WGPUProc wgpuGetProcAddress(WGPUDevice device, char const * procName);
|
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) %}
|
2019-10-21 20:04:10 +00:00
|
|
|
WGPU_EXPORT {{as_cType(method.return_type.name)}} {{as_cMethod(type.name, method.name)}}(
|
|
|
|
{{-as_cType(type.name)}} {{as_varName(type.name)}}
|
|
|
|
{%- for arg in method.arguments -%}
|
|
|
|
, {{as_annotated_cType(arg)}}
|
|
|
|
{%- endfor -%}
|
|
|
|
);
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
{% endfor %}
|
|
|
|
#endif // !defined(WGPU_SKIP_DECLARATIONS)
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // WEBGPU_H_
|