Make the prefix of proc table configurable in api.json

Add a metadata to configure the prefix of proc table and Make proc table
flexiable with the prefix and declared functions.

BUG=dawn:1201
Change-Id: Id28e5521506fa5dc8efca90a7883fbd3dd548e8d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/71526
Commit-Queue: Junwei Fu <junwei.fu@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
fujunwei
2021-12-05 05:29:44 +00:00
committed by Dawn LUCI CQ
parent 1c7d3efcd0
commit 3a464767a5
7 changed files with 45 additions and 31 deletions

View File

@@ -1,11 +1,13 @@
#include "dawn/dawn_thread_dispatch_proc.h"
{% set Prefix = metadata.proc_table_prefix %}
{% set prefix = Prefix.lower() %}
#include "dawn/{{prefix}}_thread_dispatch_proc.h"
#include <thread>
static DawnProcTable nullProcs;
thread_local DawnProcTable perThreadProcs;
static {{Prefix}}ProcTable nullProcs;
thread_local {{Prefix}}ProcTable perThreadProcs;
void dawnProcSetPerThreadProcs(const DawnProcTable* procs) {
void {{prefix}}ProcSetPerThreadProcs(const {{Prefix}}ProcTable* procs) {
if (procs) {
perThreadProcs = *procs;
} else {
@@ -40,13 +42,14 @@ static WGPUInstance ThreadDispatchCreateInstance(WGPUInstanceDescriptor const *
{% endfor %}
extern "C" {
DawnProcTable dawnThreadDispatchProcTable = {
ThreadDispatchGetProcAddress,
ThreadDispatchCreateInstance,
{% for type in by_category["object"] %}
{% for method in c_methods(type) %}
ThreadDispatch{{as_MethodSuffix(type.name, method.name)}},
{% endfor %}
{% endfor %}
{{Prefix}}ProcTable {{prefix}}ThreadDispatchProcTable = {
{% for function in by_category["function"] %}
ThreadDispatch{{as_cppType(function.name)}},
{% endfor %}
{% for type in by_category["object"] %}
{% for method in c_methods(type) %}
ThreadDispatch{{as_MethodSuffix(type.name, method.name)}},
{% endfor %}
{% endfor %}
};
}