mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-20 10:25:28 +00:00
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:
@@ -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 %}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user