diff --git a/generator/dawn_json_generator.py b/generator/dawn_json_generator.py index 086f9cb1c2..1d810cad5a 100644 --- a/generator/dawn_json_generator.py +++ b/generator/dawn_json_generator.py @@ -870,7 +870,7 @@ class MultiGeneratorFromDawnJSON(Generator): frontend_params)) renders.append( FileRender('dawn_native/dawn_platform.h', - 'src/dawn_native/dawn_platform_autogen.h', + 'src/' + native_dir + '/' + prefix + '_platform_autogen.h', frontend_params)) renders.append( FileRender('dawn_native/wgpu_structs.h', diff --git a/generator/templates/dawn_native/dawn_platform.h b/generator/templates/dawn_native/dawn_platform.h index 0690064fa1..cffa2ae25b 100644 --- a/generator/templates/dawn_native/dawn_platform.h +++ b/generator/templates/dawn_native/dawn_platform.h @@ -12,17 +12,25 @@ //* See the License for the specific language governing permissions and //* limitations under the License. -#ifndef DAWNNATIVE_DAWN_PLATFORM_AUTOGEN_H_ -#define DAWNNATIVE_DAWN_PLATFORM_AUTOGEN_H_ +{% set namespace_name = Name(metadata.native_namespace) %} +{% set NATIVE_DIR = namespace_name.concatcase().upper() %} +{% set PREFIX = metadata.proc_table_prefix.upper() %} +#ifndef {{NATIVE_DIR}}_{{PREFIX}}_PLATFORM_AUTOGEN_H_ +#define {{NATIVE_DIR}}_{{PREFIX}}_PLATFORM_AUTOGEN_H_ -#include "dawn/webgpu_cpp.h" -#include "dawn_native/Forward.h" +{% set api = metadata.api.lower() %} +#include "dawn/{{api}}_cpp.h" +{% set impl_dir = metadata.impl_dir + "/" if metadata.impl_dir else "" %} +{% set native_namespace = namespace_name.snake_case() %} +{% set native_dir = impl_dir + native_namespace %} +#include "{{native_dir}}/Forward.h" -// Use our autogenerated version of the wgpu structures that point to dawn_native object types +{% set namespace = metadata.namespace %} +// Use our autogenerated version of the {{namespace}} structures that point to {{native_namespace}} object types // (wgpu::Buffer is dawn_native::BufferBase*) -#include +#include <{{native_dir}}/{{namespace}}_structs_autogen.h> -namespace dawn_native { +namespace {{native_namespace}} { {% for type in by_category["structure"] %} inline const {{as_cType(type.name)}}* ToAPI(const {{as_cppType(type.name)}}* rhs) { @@ -65,10 +73,10 @@ namespace dawn_native { {% for e in by_category["enum"] if e.contiguousFromZero %} template<> - struct EnumCount { + struct EnumCount<{{namespace}}::{{as_cppType(e.name)}}> { static constexpr uint32_t value = {{len(e.values)}}; }; {% endfor %} } -#endif // DAWNNATIVE_DAWN_PLATFORM_AUTOGEN_H_ \ No newline at end of file +#endif // {{NATIVE_DIR}}_{{PREFIX}}_PLATFORM_AUTOGEN_H_ \ No newline at end of file