2021-12-05 05:29:44 +00:00
|
|
|
{% set Prefix = metadata.proc_table_prefix %}
|
|
|
|
{% set prefix = Prefix.lower() %}
|
|
|
|
#include "dawn/{{prefix}}_thread_dispatch_proc.h"
|
2020-10-06 16:13:42 +00:00
|
|
|
|
|
|
|
#include <thread>
|
|
|
|
|
2021-12-05 05:29:44 +00:00
|
|
|
static {{Prefix}}ProcTable nullProcs;
|
|
|
|
thread_local {{Prefix}}ProcTable perThreadProcs;
|
2020-10-06 16:13:42 +00:00
|
|
|
|
2021-12-05 05:29:44 +00:00
|
|
|
void {{prefix}}ProcSetPerThreadProcs(const {{Prefix}}ProcTable* procs) {
|
2020-10-06 16:13:42 +00:00
|
|
|
if (procs) {
|
|
|
|
perThreadProcs = *procs;
|
|
|
|
} else {
|
|
|
|
perThreadProcs = nullProcs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-10 01:35:19 +00:00
|
|
|
{% for function in by_category["function"] %}
|
|
|
|
static {{as_cType(function.return_type.name)}} ThreadDispatch{{as_cppType(function.name)}}(
|
|
|
|
{%- for arg in function.arguments -%}
|
|
|
|
{% if not loop.first %}, {% endif %}{{as_annotated_cType(arg)}}
|
|
|
|
{%- endfor -%}
|
|
|
|
) {
|
|
|
|
{% if function.return_type.name.canonical_case() != "void" %}return {% endif %}
|
|
|
|
perThreadProcs.{{as_varName(function.name)}}(
|
|
|
|
{%- for arg in function.arguments -%}
|
|
|
|
{% if not loop.first %}, {% endif %}{{as_varName(arg.name)}}
|
|
|
|
{%- endfor -%}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
{% endfor %}
|
2020-10-06 16:13:42 +00:00
|
|
|
|
|
|
|
{% for type in by_category["object"] %}
|
|
|
|
{% for method in c_methods(type) %}
|
|
|
|
static {{as_cType(method.return_type.name)}} ThreadDispatch{{as_MethodSuffix(type.name, method.name)}}(
|
|
|
|
{{-as_cType(type.name)}} {{as_varName(type.name)}}
|
|
|
|
{%- for arg in method.arguments -%}
|
|
|
|
, {{as_annotated_cType(arg)}}
|
|
|
|
{%- endfor -%}
|
|
|
|
) {
|
|
|
|
{% if method.return_type.name.canonical_case() != "void" %}return {% endif %}
|
|
|
|
perThreadProcs.{{as_varName(type.name, method.name)}}({{as_varName(type.name)}}
|
|
|
|
{%- for arg in method.arguments -%}
|
|
|
|
, {{as_varName(arg.name)}}
|
|
|
|
{%- endfor -%}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
extern "C" {
|
2021-12-05 05:29:44 +00:00
|
|
|
{{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 %}
|
2020-10-06 16:13:42 +00:00
|
|
|
};
|
|
|
|
}
|