Make dawn_platform.h template flexible
Replace hardcode content with metadata defined in api.json BUG=dawn:1201 Change-Id: Ib6d6a9c7afc8fb89d3ff2d0129dbfba04adb542a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/73160 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Junwei Fu <junwei.fu@intel.com>
This commit is contained in:
parent
b6dc96055e
commit
fc38f7d879
|
@ -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',
|
||||
|
|
|
@ -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 <dawn_native/wgpu_structs_autogen.h>
|
||||
#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<wgpu::{{as_cppType(e.name)}}> {
|
||||
struct EnumCount<{{namespace}}::{{as_cppType(e.name)}}> {
|
||||
static constexpr uint32_t value = {{len(e.values)}};
|
||||
};
|
||||
{% endfor %}
|
||||
}
|
||||
|
||||
#endif // DAWNNATIVE_DAWN_PLATFORM_AUTOGEN_H_
|
||||
#endif // {{NATIVE_DIR}}_{{PREFIX}}_PLATFORM_AUTOGEN_H_
|
Loading…
Reference in New Issue