2018-07-18 09:40:26 +00:00
|
|
|
//* Copyright 2017 The Dawn Authors
|
2017-04-20 18:38:20 +00:00
|
|
|
//*
|
|
|
|
//* 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.
|
|
|
|
|
2018-07-24 14:30:14 +00:00
|
|
|
#ifndef DAWN_DAWN_H_
|
|
|
|
#define DAWN_DAWN_H_
|
2017-04-20 18:38:20 +00:00
|
|
|
|
2018-07-25 10:41:29 +00:00
|
|
|
#include "dawn/dawn_export.h"
|
|
|
|
|
2017-04-20 18:38:20 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2019-07-17 08:54:19 +00:00
|
|
|
const uint64_t DAWN_WHOLE_SIZE = 0xffffffffffffffffULL; // UINT64_MAX
|
|
|
|
|
2019-10-17 08:46:07 +00:00
|
|
|
typedef uint32_t WGPUFlags;
|
|
|
|
|
2017-04-20 18:38:20 +00:00
|
|
|
{% 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"] %}
|
2019-10-08 07:38:01 +00:00
|
|
|
typedef enum {{as_cType(type.name)}} {
|
2017-04-20 18:38:20 +00:00
|
|
|
{% 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)}};
|
2019-10-17 08:46:07 +00:00
|
|
|
{% if type.category == "bitmask" %}
|
|
|
|
typedef WGPUFlags {{as_cType(type.name)}}Flags;
|
|
|
|
{% endif %}
|
2017-04-20 18:38:20 +00:00
|
|
|
|
|
|
|
{% endfor %}
|
|
|
|
|
2018-05-17 20:55:53 +00:00
|
|
|
{% for type in by_category["structure"] %}
|
2018-09-18 12:09:55 +00:00
|
|
|
typedef struct {{as_cType(type.name)}} {
|
2018-05-17 20:55:53 +00:00
|
|
|
{% if type.extensible %}
|
2019-10-08 07:38:01 +00:00
|
|
|
void const * nextInChain;
|
2018-05-17 20:55:53 +00:00
|
|
|
{% endif %}
|
|
|
|
{% for member in type.members %}
|
|
|
|
{{as_annotated_cType(member)}};
|
|
|
|
{% endfor %}
|
|
|
|
} {{as_cType(type.name)}};
|
2018-09-18 12:09:55 +00:00
|
|
|
|
2018-05-17 20:55:53 +00:00
|
|
|
{% endfor %}
|
|
|
|
|
2019-10-08 07:38:01 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-04-20 18:42:36 +00:00
|
|
|
// Custom types depending on the target language
|
2019-06-14 17:35:56 +00:00
|
|
|
typedef void (*DawnBufferCreateMappedCallback)(DawnBufferMapAsyncStatus status,
|
|
|
|
DawnCreateBufferMappedResult result,
|
|
|
|
void* userdata);
|
2019-05-29 13:03:50 +00:00
|
|
|
typedef void (*DawnBufferMapReadCallback)(DawnBufferMapAsyncStatus status,
|
|
|
|
const void* data,
|
|
|
|
uint64_t dataLength,
|
|
|
|
void* userdata);
|
|
|
|
typedef void (*DawnBufferMapWriteCallback)(DawnBufferMapAsyncStatus status,
|
|
|
|
void* data,
|
|
|
|
uint64_t dataLength,
|
|
|
|
void* userdata);
|
|
|
|
typedef void (*DawnFenceOnCompletionCallback)(DawnFenceCompletionStatus status, void* userdata);
|
2019-10-15 12:08:48 +00:00
|
|
|
typedef void (*DawnErrorCallback)(DawnErrorType type, const char* message, void* userdata);
|
|
|
|
|
|
|
|
typedef void (*DawnProc)();
|
2017-04-20 18:42:36 +00:00
|
|
|
|
2019-10-08 07:38:01 +00:00
|
|
|
#if !defined(DAWN_SKIP_PROCS)
|
2017-04-20 18:38:20 +00:00
|
|
|
|
2019-10-15 12:08:48 +00:00
|
|
|
typedef DawnProc (*DawnProcGetProcAddress)(DawnDevice device, const char* procName);
|
|
|
|
|
2017-04-20 18:38:20 +00:00
|
|
|
{% for type in by_category["object"] %}
|
|
|
|
// Procs of {{type.name.CamelCase()}}
|
|
|
|
{% for method in native_methods(type) %}
|
|
|
|
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 %}
|
2019-10-08 07:38:01 +00:00
|
|
|
#endif // !defined(DAWN_SKIP_PROCS)
|
2017-04-20 18:38:20 +00:00
|
|
|
|
2019-10-08 07:38:01 +00:00
|
|
|
#if !defined(DAWN_SKIP_DECLARATIONS)
|
|
|
|
|
2019-10-15 12:08:48 +00:00
|
|
|
DAWN_EXPORT DawnProc DawnGetProcAddress(DawnDevice device, const char* procName);
|
|
|
|
|
2017-04-20 18:38:20 +00:00
|
|
|
{% for type in by_category["object"] %}
|
|
|
|
// Methods of {{type.name.CamelCase()}}
|
|
|
|
{% for method in native_methods(type) %}
|
2018-07-25 10:41:29 +00:00
|
|
|
DAWN_EXPORT {{as_cType(method.return_type.name)}} {{as_cMethod(type.name, method.name)}}(
|
2017-04-20 18:38:20 +00:00
|
|
|
{{-as_cType(type.name)}} {{as_varName(type.name)}}
|
|
|
|
{%- for arg in method.arguments -%}
|
|
|
|
, {{as_annotated_cType(arg)}}
|
|
|
|
{%- endfor -%}
|
|
|
|
);
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
{% endfor %}
|
2019-10-08 07:38:01 +00:00
|
|
|
#endif // !defined(DAWN_SKIP_DECLARATIONS)
|
2017-04-20 18:38:20 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
2018-07-24 14:30:14 +00:00
|
|
|
#endif // DAWN_DAWN_H_
|