1 {% set Prefix = metadata.proc_table_prefix %} 2 {% set prefix = Prefix.lower() %} 3 #include "dawn/{{prefix}}_thread_dispatch_proc.h" 4 5 #include <thread> 6 7 static {{Prefix}}ProcTable nullProcs; 8 thread_local {{Prefix}}ProcTable perThreadProcs; 9 ProcSetPerThreadProcs(const{{Prefix}}ProcTable * procs)10void {{prefix}}ProcSetPerThreadProcs(const {{Prefix}}ProcTable* procs) { 11 if (procs) { 12 perThreadProcs = *procs; 13 } else { 14 perThreadProcs = nullProcs; 15 } 16 } 17 18 {% for function in by_category["function"] %} 19 static {{as_cType(function.return_type.name)}} ThreadDispatch{{as_cppType(function.name)}}( 20 {%- for arg in function.arguments -%} 21 {% if not loop.first %}, {% endif %}{{as_annotated_cType(arg)}} 22 {%- endfor -%} 23 ) { 24 {% if function.return_type.name.canonical_case() != "void" %}return {% endif %} 25 perThreadProcs.{{as_varName(function.name)}}( 26 {%- for arg in function.arguments -%} 27 {% if not loop.first %}, {% endif %}{{as_varName(arg.name)}} 28 {%- endfor -%} 29 ); 30 } 31 {% endfor %} 32 33 {% for type in by_category["object"] %} 34 {% for method in c_methods(type) %} 35 static {{as_cType(method.return_type.name)}} ThreadDispatch{{as_MethodSuffix(type.name, method.name)}}( 36 {{-as_cType(type.name)}} {{as_varName(type.name)}} 37 {%- for arg in method.arguments -%} 38 , {{as_annotated_cType(arg)}} 39 {%- endfor -%} 40 ) { 41 {% if method.return_type.name.canonical_case() != "void" %}return {% endif %} 42 perThreadProcs.{{as_varName(type.name, method.name)}}({{as_varName(type.name)}} 43 {%- for arg in method.arguments -%} 44 , {{as_varName(arg.name)}} 45 {%- endfor -%} 46 ); 47 } 48 {% endfor %} 49 {% endfor %} 50 51 extern "C" { 52 {{Prefix}}ProcTable {{prefix}}ThreadDispatchProcTable = { 53 {% for function in by_category["function"] %} 54 ThreadDispatch{{as_cppType(function.name)}}, 55 {% endfor %} 56 {% for type in by_category["object"] %} 57 {% for method in c_methods(type) %} 58 ThreadDispatch{{as_MethodSuffix(type.name, method.name)}}, 59 {% endfor %} 60 {% endfor %} 61 }; 62 } 63