tint->dawn: Move src/include -> include
Also simplify the target names.
Bug: dawn:1275
Change-Id: I2929b70897f64903b91b693b48c2e8dd7c11d07b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79102
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index adaedc3..310a0a5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,7 +38,7 @@
set(DAWN_BUILD_GEN_DIR "${Dawn_BINARY_DIR}/gen")
set(DAWN_GENERATOR_DIR "${Dawn_SOURCE_DIR}/generator")
set(DAWN_SRC_DIR "${Dawn_SOURCE_DIR}/src")
-set(DAWN_INCLUDE_DIR "${DAWN_SRC_DIR}/include")
+set(DAWN_INCLUDE_DIR "${Dawn_SOURCE_DIR}/include")
set(DAWN_TEMPLATE_DIR "${DAWN_GENERATOR_DIR}/templates")
set(DAWN_DUMMY_FILE "${DAWN_SRC_DIR}/Dummy.cpp")
@@ -160,8 +160,8 @@
# The public config contains only the include paths for the Dawn headers.
add_library(dawn_public_config INTERFACE)
target_include_directories(dawn_public_config INTERFACE
- "${DAWN_SRC_DIR}/include"
- "${DAWN_BUILD_GEN_DIR}/src/include"
+ "${DAWN_INCLUDE_DIR}"
+ "${DAWN_BUILD_GEN_DIR}/include"
)
# The internal config conatins additional path but includes the dawn_public_config include paths
diff --git a/generator/dawn_generator.gni b/generator/dawn_generator.gni
index c1eb5b9..fb7e639 100644
--- a/generator/dawn_generator.gni
+++ b/generator/dawn_generator.gni
@@ -23,9 +23,9 @@
# 1. The generated output file directory structure has to match the structure
# of the source tree, starting at dawn_gen_root (gen/ or
# gen/third_party/dawn depending on where we are).
-# 2. src/include and dawn_gen_root/src/include has to match the structure of
+# 2. include and dawn_gen_root/include has to match the structure of
# the source tree too.
-# 3. Dawn files must use include relative to src/ or src/include such as
+# 3. Dawn files must use include relative to src/ or include such as
# "dawn/dawn.h" or "dawn/native/backend/BackendStuff.h".
#
# The allowed list below ensure 1). Include directory rules for Dawn ensure 3)
@@ -44,7 +44,7 @@
"src/dawn/wire/client/",
"src/dawn/wire/server/",
"src/dawn/wire/",
- "src/include/dawn/",
+ "include/dawn/",
"emscripten-bits/",
"webgpu-headers/",
]
diff --git a/generator/dawn_json_generator.py b/generator/dawn_json_generator.py
index 982725e..36e6ec6 100644
--- a/generator/dawn_json_generator.py
+++ b/generator/dawn_json_generator.py
@@ -804,21 +804,21 @@
prefix = metadata.proc_table_prefix.lower()
if 'headers' in targets:
renders.append(
- FileRender('api.h', 'src/include/dawn/' + api + '.h',
+ FileRender('api.h', 'include/dawn/' + api + '.h',
[RENDER_PARAMS_BASE, params_dawn]))
renders.append(
FileRender('dawn_proc_table.h',
- 'src/include/dawn/' + prefix + '_proc_table.h',
+ 'include/dawn/' + prefix + '_proc_table.h',
[RENDER_PARAMS_BASE, params_dawn]))
if 'cpp_headers' in targets:
renders.append(
- FileRender('api_cpp.h', 'src/include/dawn/' + api + '_cpp.h',
+ FileRender('api_cpp.h', 'include/dawn/' + api + '_cpp.h',
[RENDER_PARAMS_BASE, params_dawn]))
renders.append(
FileRender('api_cpp_print.h',
- 'src/include/dawn/' + api + '_cpp_print.h',
+ 'include/dawn/' + api + '_cpp_print.h',
[RENDER_PARAMS_BASE, params_dawn]))
if 'proc' in targets:
diff --git a/include/dawn/BUILD.gn b/include/dawn/BUILD.gn
new file mode 100644
index 0000000..d493820
--- /dev/null
+++ b/include/dawn/BUILD.gn
@@ -0,0 +1,84 @@
+# Copyright 2019 The Dawn Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("../../scripts/dawn_overrides_with_defaults.gni")
+
+import("${dawn_root}/generator/dawn_generator.gni")
+import("${dawn_root}/scripts/dawn_component.gni")
+
+###############################################################################
+# Dawn headers
+###############################################################################
+
+dawn_json_generator("headers_gen") {
+ target = "headers"
+ outputs = [
+ "include/dawn/dawn_proc_table.h",
+ "include/dawn/webgpu.h",
+ ]
+}
+
+source_set("headers") {
+ all_dependent_configs = [ ":public" ]
+ public_deps = [ ":headers_gen" ]
+
+ sources = get_target_outputs(":headers_gen")
+ sources += [ "${dawn_root}/include/dawn/dawn_wsi.h" ]
+}
+
+###############################################################################
+# Dawn C++ headers
+###############################################################################
+
+dawn_json_generator("cpp_headers_gen") {
+ target = "cpp_headers"
+ outputs = [
+ "include/dawn/webgpu_cpp.h",
+ "include/dawn/webgpu_cpp_print.h",
+ ]
+}
+
+source_set("cpp_headers") {
+ public_deps = [
+ ":cpp_headers_gen",
+ ":headers",
+ ]
+
+ sources = get_target_outputs(":cpp_headers_gen")
+ sources += [ "${dawn_root}/include/dawn/EnumClassBitmasks.h" ]
+}
+
+###############################################################################
+# Dawn public include directories
+###############################################################################
+
+config("public") {
+ include_dirs = [
+ "${target_gen_dir}/../../include",
+ "${dawn_root}/include",
+
+ "${dawn_root}/src/include", # TODO(crbug.com/dawn/1275) - remove
+ ]
+}
+
+################################################################################
+# Build target aliases
+# TODO(crbug.com/dawn/1275) - remove these
+################################################################################
+group("dawncpp_headers") {
+ public_deps = [ ":cpp_headers" ]
+}
+group("dawn_headers") {
+ public_deps = [ ":headers" ]
+}
diff --git a/include/dawn/EnumClassBitmasks.h b/include/dawn/EnumClassBitmasks.h
new file mode 100644
index 0000000..3947f00
--- /dev/null
+++ b/include/dawn/EnumClassBitmasks.h
@@ -0,0 +1,156 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWN_ENUM_CLASS_BITMASKS_H_
+#define DAWN_ENUM_CLASS_BITMASKS_H_
+
+#include <type_traits>
+
+// The operators in dawn:: namespace need be introduced into other namespaces with
+// using-declarations for C++ Argument Dependent Lookup to work.
+#define DAWN_IMPORT_BITMASK_OPERATORS \
+ using dawn::operator|; \
+ using dawn::operator&; \
+ using dawn::operator^; \
+ using dawn::operator~; \
+ using dawn::operator&=; \
+ using dawn::operator|=; \
+ using dawn::operator^=; \
+ using dawn::HasZeroOrOneBits;
+
+namespace dawn {
+
+ template <typename T>
+ struct IsDawnBitmask {
+ static constexpr bool enable = false;
+ };
+
+ template <typename T, typename Enable = void>
+ struct LowerBitmask {
+ static constexpr bool enable = false;
+ };
+
+ template <typename T>
+ struct LowerBitmask<T, typename std::enable_if<IsDawnBitmask<T>::enable>::type> {
+ static constexpr bool enable = true;
+ using type = T;
+ constexpr static T Lower(T t) {
+ return t;
+ }
+ };
+
+ template <typename T>
+ struct BoolConvertible {
+ using Integral = typename std::underlying_type<T>::type;
+
+ constexpr BoolConvertible(Integral value) : value(value) {
+ }
+ constexpr operator bool() const {
+ return value != 0;
+ }
+ constexpr operator T() const {
+ return static_cast<T>(value);
+ }
+
+ Integral value;
+ };
+
+ template <typename T>
+ struct LowerBitmask<BoolConvertible<T>> {
+ static constexpr bool enable = true;
+ using type = T;
+ static constexpr type Lower(BoolConvertible<T> t) {
+ return t;
+ }
+ };
+
+ template <typename T1,
+ typename T2,
+ typename = typename std::enable_if<LowerBitmask<T1>::enable &&
+ LowerBitmask<T2>::enable>::type>
+ constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator|(T1 left, T2 right) {
+ using T = typename LowerBitmask<T1>::type;
+ using Integral = typename std::underlying_type<T>::type;
+ return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) |
+ static_cast<Integral>(LowerBitmask<T2>::Lower(right));
+ }
+
+ template <typename T1,
+ typename T2,
+ typename = typename std::enable_if<LowerBitmask<T1>::enable &&
+ LowerBitmask<T2>::enable>::type>
+ constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator&(T1 left, T2 right) {
+ using T = typename LowerBitmask<T1>::type;
+ using Integral = typename std::underlying_type<T>::type;
+ return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) &
+ static_cast<Integral>(LowerBitmask<T2>::Lower(right));
+ }
+
+ template <typename T1,
+ typename T2,
+ typename = typename std::enable_if<LowerBitmask<T1>::enable &&
+ LowerBitmask<T2>::enable>::type>
+ constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator^(T1 left, T2 right) {
+ using T = typename LowerBitmask<T1>::type;
+ using Integral = typename std::underlying_type<T>::type;
+ return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) ^
+ static_cast<Integral>(LowerBitmask<T2>::Lower(right));
+ }
+
+ template <typename T1>
+ constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator~(T1 t) {
+ using T = typename LowerBitmask<T1>::type;
+ using Integral = typename std::underlying_type<T>::type;
+ return ~static_cast<Integral>(LowerBitmask<T1>::Lower(t));
+ }
+
+ template <typename T,
+ typename T2,
+ typename = typename std::enable_if<IsDawnBitmask<T>::enable &&
+ LowerBitmask<T2>::enable>::type>
+ constexpr T& operator&=(T& l, T2 right) {
+ T r = LowerBitmask<T2>::Lower(right);
+ l = l & r;
+ return l;
+ }
+
+ template <typename T,
+ typename T2,
+ typename = typename std::enable_if<IsDawnBitmask<T>::enable &&
+ LowerBitmask<T2>::enable>::type>
+ constexpr T& operator|=(T& l, T2 right) {
+ T r = LowerBitmask<T2>::Lower(right);
+ l = l | r;
+ return l;
+ }
+
+ template <typename T,
+ typename T2,
+ typename = typename std::enable_if<IsDawnBitmask<T>::enable &&
+ LowerBitmask<T2>::enable>::type>
+ constexpr T& operator^=(T& l, T2 right) {
+ T r = LowerBitmask<T2>::Lower(right);
+ l = l ^ r;
+ return l;
+ }
+
+ template <typename T>
+ constexpr bool HasZeroOrOneBits(T value) {
+ using Integral = typename std::underlying_type<T>::type;
+ return (static_cast<Integral>(value) & (static_cast<Integral>(value) - 1)) == 0;
+ }
+
+} // namespace dawn
+
+#endif // DAWN_ENUM_CLASS_BITMASKS_H_
diff --git a/include/dawn/dawn_proc.h b/include/dawn/dawn_proc.h
new file mode 100644
index 0000000..adeec46
--- /dev/null
+++ b/include/dawn/dawn_proc.h
@@ -0,0 +1,36 @@
+// Copyright 2019 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWN_DAWN_PROC_H_
+#define DAWN_DAWN_PROC_H_
+
+#include "dawn/dawn_proc_table.h"
+#include "dawn/webgpu.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Sets the static proctable used by libdawn_proc to implement the Dawn entrypoints. Passing NULL
+// for `procs` sets up the null proctable that contains only null function pointers. It is the
+// default value of the proctable. Setting the proctable back to null is good practice when you
+// are done using libdawn_proc since further usage will cause a segfault instead of calling an
+// unexpected function.
+WGPU_EXPORT void dawnProcSetProcs(const DawnProcTable* procs);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // DAWN_DAWN_PROC_H_
diff --git a/include/dawn/dawn_thread_dispatch_proc.h b/include/dawn/dawn_thread_dispatch_proc.h
new file mode 100644
index 0000000..4d08ba8
--- /dev/null
+++ b/include/dawn/dawn_thread_dispatch_proc.h
@@ -0,0 +1,33 @@
+// Copyright 2020 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWN_DAWN_THREAD_DISPATCH_PROC_H_
+#define DAWN_DAWN_THREAD_DISPATCH_PROC_H_
+
+#include "dawn/dawn_proc.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Call dawnProcSetProcs(&dawnThreadDispatchProcTable) and then use dawnProcSetPerThreadProcs
+// to set per-thread procs.
+WGPU_EXPORT extern DawnProcTable dawnThreadDispatchProcTable;
+WGPU_EXPORT void dawnProcSetPerThreadProcs(const DawnProcTable* procs);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // DAWN_DAWN_THREAD_DISPATCH_PROC_H_
diff --git a/include/dawn/dawn_wsi.h b/include/dawn/dawn_wsi.h
new file mode 100644
index 0000000..f1a6047
--- /dev/null
+++ b/include/dawn/dawn_wsi.h
@@ -0,0 +1,86 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWN_DAWN_WSI_H_
+#define DAWN_DAWN_WSI_H_
+
+#include <dawn/webgpu.h>
+
+// Error message (or nullptr if there was no error)
+typedef const char* DawnSwapChainError;
+constexpr DawnSwapChainError DAWN_SWAP_CHAIN_NO_ERROR = nullptr;
+
+typedef struct {
+ /// Backend-specific texture id/name/pointer
+ union {
+ void* ptr;
+ uint64_t u64;
+ uint32_t u32;
+ } texture;
+} DawnSwapChainNextTexture;
+
+typedef struct {
+ /// Initialize the swap chain implementation.
+ /// (*wsiContext) is one of DawnWSIContext{D3D12,Metal,GL}
+ void (*Init)(void* userData, void* wsiContext);
+
+ /// Destroy the swap chain implementation.
+ void (*Destroy)(void* userData);
+
+ /// Configure/reconfigure the swap chain.
+ DawnSwapChainError (*Configure)(void* userData,
+ WGPUTextureFormat format,
+ WGPUTextureUsage allowedUsage,
+ uint32_t width,
+ uint32_t height);
+
+ /// Acquire the next texture from the swap chain.
+ DawnSwapChainError (*GetNextTexture)(void* userData, DawnSwapChainNextTexture* nextTexture);
+
+ /// Present the last acquired texture to the screen.
+ DawnSwapChainError (*Present)(void* userData);
+
+ /// Each function is called with userData as its first argument.
+ void* userData;
+
+ /// For use by the D3D12 and Vulkan backends: how the swapchain will use the texture.
+ WGPUTextureUsage textureUsage;
+} DawnSwapChainImplementation;
+
+#if defined(DAWN_ENABLE_BACKEND_D3D12) && defined(__cplusplus)
+struct DawnWSIContextD3D12 {
+ WGPUDevice device = nullptr;
+};
+#endif
+
+#if defined(DAWN_ENABLE_BACKEND_METAL) && defined(__OBJC__)
+# import <Metal/Metal.h>
+
+struct DawnWSIContextMetal {
+ id<MTLDevice> device = nil;
+ id<MTLCommandQueue> queue = nil;
+};
+#endif
+
+#ifdef DAWN_ENABLE_BACKEND_OPENGL
+typedef struct {
+} DawnWSIContextGL;
+#endif
+
+#ifdef DAWN_ENABLE_BACKEND_VULKAN
+typedef struct {
+} DawnWSIContextVulkan;
+#endif
+
+#endif // DAWN_DAWN_WSI_H
diff --git a/src/include/dawn/native/D3D12Backend.h b/include/dawn/native/D3D12Backend.h
similarity index 100%
rename from src/include/dawn/native/D3D12Backend.h
rename to include/dawn/native/D3D12Backend.h
diff --git a/src/include/dawn/native/DawnNative.h b/include/dawn/native/DawnNative.h
similarity index 100%
rename from src/include/dawn/native/DawnNative.h
rename to include/dawn/native/DawnNative.h
diff --git a/src/include/dawn/native/MetalBackend.h b/include/dawn/native/MetalBackend.h
similarity index 100%
rename from src/include/dawn/native/MetalBackend.h
rename to include/dawn/native/MetalBackend.h
diff --git a/src/include/dawn/native/NullBackend.h b/include/dawn/native/NullBackend.h
similarity index 100%
rename from src/include/dawn/native/NullBackend.h
rename to include/dawn/native/NullBackend.h
diff --git a/src/include/dawn/native/OpenGLBackend.h b/include/dawn/native/OpenGLBackend.h
similarity index 100%
rename from src/include/dawn/native/OpenGLBackend.h
rename to include/dawn/native/OpenGLBackend.h
diff --git a/src/include/dawn/native/VulkanBackend.h b/include/dawn/native/VulkanBackend.h
similarity index 100%
rename from src/include/dawn/native/VulkanBackend.h
rename to include/dawn/native/VulkanBackend.h
diff --git a/src/include/dawn/native/dawn_native_export.h b/include/dawn/native/dawn_native_export.h
similarity index 100%
rename from src/include/dawn/native/dawn_native_export.h
rename to include/dawn/native/dawn_native_export.h
diff --git a/src/include/dawn/platform/DawnPlatform.h b/include/dawn/platform/DawnPlatform.h
similarity index 100%
rename from src/include/dawn/platform/DawnPlatform.h
rename to include/dawn/platform/DawnPlatform.h
diff --git a/src/include/dawn/platform/dawn_platform_export.h b/include/dawn/platform/dawn_platform_export.h
similarity index 100%
rename from src/include/dawn/platform/dawn_platform_export.h
rename to include/dawn/platform/dawn_platform_export.h
diff --git a/src/include/dawn/wire/Wire.h b/include/dawn/wire/Wire.h
similarity index 100%
rename from src/include/dawn/wire/Wire.h
rename to include/dawn/wire/Wire.h
diff --git a/src/include/dawn/wire/WireClient.h b/include/dawn/wire/WireClient.h
similarity index 100%
rename from src/include/dawn/wire/WireClient.h
rename to include/dawn/wire/WireClient.h
diff --git a/src/include/dawn/wire/WireServer.h b/include/dawn/wire/WireServer.h
similarity index 100%
rename from src/include/dawn/wire/WireServer.h
rename to include/dawn/wire/WireServer.h
diff --git a/src/include/dawn/wire/dawn_wire_export.h b/include/dawn/wire/dawn_wire_export.h
similarity index 100%
rename from src/include/dawn/wire/dawn_wire_export.h
rename to include/dawn/wire/dawn_wire_export.h
diff --git a/include/webgpu/webgpu.h b/include/webgpu/webgpu.h
new file mode 100644
index 0000000..4a29d37
--- /dev/null
+++ b/include/webgpu/webgpu.h
@@ -0,0 +1 @@
+#include "dawn/webgpu.h"
diff --git a/include/webgpu/webgpu_cpp.h b/include/webgpu/webgpu_cpp.h
new file mode 100644
index 0000000..5bbd869
--- /dev/null
+++ b/include/webgpu/webgpu_cpp.h
@@ -0,0 +1 @@
+#include <dawn/webgpu_cpp.h>
diff --git a/src/dawn/BUILD.gn b/src/dawn/BUILD.gn
index 5fd957d..67991ad 100644
--- a/src/dawn/BUILD.gn
+++ b/src/dawn/BUILD.gn
@@ -18,48 +18,6 @@
import("${dawn_root}/scripts/dawn_component.gni")
###############################################################################
-# Dawn headers
-###############################################################################
-
-dawn_json_generator("headers_gen") {
- target = "headers"
- outputs = [
- "src/include/dawn/dawn_proc_table.h",
- "src/include/dawn/webgpu.h",
- ]
-}
-
-source_set("headers") {
- all_dependent_configs = [ "${dawn_root}/src/dawn/common:public_include_dirs" ]
- public_deps = [ ":headers_gen" ]
-
- sources = get_target_outputs(":headers_gen")
- sources += [ "${dawn_root}/src/include/dawn/dawn_wsi.h" ]
-}
-
-###############################################################################
-# Dawn C++ headers
-###############################################################################
-
-dawn_json_generator("cpp_headers_gen") {
- target = "cpp_headers"
- outputs = [
- "src/include/dawn/webgpu_cpp.h",
- "src/include/dawn/webgpu_cpp_print.h",
- ]
-}
-
-source_set("cpp_headers") {
- public_deps = [
- ":cpp_headers_gen",
- ":headers",
- ]
-
- sources = get_target_outputs(":cpp_headers_gen")
- sources += [ "${dawn_root}/src/include/dawn/EnumClassBitmasks.h" ]
-}
-
-###############################################################################
# Dawn C++ wrapper
###############################################################################
@@ -71,7 +29,7 @@
source_set("cpp") {
deps = [
":cpp_gen",
- ":cpp_headers",
+ "${dawn_root}/include/dawn:cpp_headers",
]
sources = get_target_outputs(":cpp_gen")
}
@@ -91,12 +49,12 @@
dawn_component("proc") {
DEFINE_PREFIX = "WGPU"
- public_deps = [ ":headers" ]
+ public_deps = [ "${dawn_root}/include/dawn:headers" ]
deps = [ ":proc_gen" ]
sources = get_target_outputs(":proc_gen")
sources += [
- "${dawn_root}/src/include/dawn/dawn_proc.h",
- "${dawn_root}/src/include/dawn/dawn_thread_dispatch_proc.h",
+ "${dawn_root}/include/dawn/dawn_proc.h",
+ "${dawn_root}/include/dawn/dawn_thread_dispatch_proc.h",
]
}
@@ -128,13 +86,13 @@
public_deps = [ ":cpp" ]
}
group("dawncpp_headers") {
- public_deps = [ ":cpp_headers" ]
+ public_deps = [ "${dawn_root}/include/dawn:cpp_headers" ]
}
group("dawn_proc") {
public_deps = [ ":proc" ]
}
group("dawn_headers") {
- public_deps = [ ":headers" ]
+ public_deps = [ "${dawn_root}/include/dawn:headers" ]
}
group("dawn_cpp") {
public_deps = [ ":cpp" ]
diff --git a/src/dawn/common/BUILD.gn b/src/dawn/common/BUILD.gn
index 7090fc3..4fb7c9e 100644
--- a/src/dawn/common/BUILD.gn
+++ b/src/dawn/common/BUILD.gn
@@ -35,13 +35,6 @@
# Common dawn configs
###############################################################################
-config("public_include_dirs") {
- include_dirs = [
- "${target_gen_dir}/../../../src/include",
- "${dawn_root}/src/include",
- ]
-}
-
config("internal_config") {
include_dirs = [
"${target_gen_dir}/../../../src",
@@ -237,8 +230,8 @@
public_configs = [ ":internal_config" ]
deps = [
- "${dawn_root}/src/dawn:cpp_headers",
- "${dawn_root}/src/dawn:headers",
+ "${dawn_root}/include/dawn:cpp_headers",
+ "${dawn_root}/include/dawn:headers",
]
if (is_win) {
diff --git a/src/dawn/native/BUILD.gn b/src/dawn/native/BUILD.gn
index b2ea25f..d76a813 100644
--- a/src/dawn/native/BUILD.gn
+++ b/src/dawn/native/BUILD.gn
@@ -137,19 +137,19 @@
# Public dawn native headers so they can be publicly visible for
# dependencies of dawn native
source_set("headers") {
- public_deps = [ "${dawn_root}/src/dawn:cpp_headers" ]
- all_dependent_configs = [ "${dawn_root}/src/dawn/common:public_include_dirs" ]
+ public_deps = [ "${dawn_root}/include/dawn:cpp_headers" ]
+ all_dependent_configs = [ "${dawn_root}/include/dawn:public" ]
sources = [
- "${dawn_root}/src/include/dawn/native/DawnNative.h",
- "${dawn_root}/src/include/dawn/native/dawn_native_export.h",
+ "${dawn_root}/include/dawn/native/DawnNative.h",
+ "${dawn_root}/include/dawn/native/dawn_native_export.h",
# Include all backend's public headers so that dependencies can include
# them even when the backends are disabled.
- "${dawn_root}/src/include/dawn/native/D3D12Backend.h",
- "${dawn_root}/src/include/dawn/native/MetalBackend.h",
- "${dawn_root}/src/include/dawn/native/NullBackend.h",
- "${dawn_root}/src/include/dawn/native/OpenGLBackend.h",
- "${dawn_root}/src/include/dawn/native/VulkanBackend.h",
+ "${dawn_root}/include/dawn/native/D3D12Backend.h",
+ "${dawn_root}/include/dawn/native/MetalBackend.h",
+ "${dawn_root}/include/dawn/native/NullBackend.h",
+ "${dawn_root}/include/dawn/native/OpenGLBackend.h",
+ "${dawn_root}/include/dawn/native/VulkanBackend.h",
]
}
diff --git a/src/dawn/platform/BUILD.gn b/src/dawn/platform/BUILD.gn
index 86a2414..2d1cb00 100644
--- a/src/dawn/platform/BUILD.gn
+++ b/src/dawn/platform/BUILD.gn
@@ -22,8 +22,8 @@
configs = [ "${dawn_root}/src/dawn/common:internal_config" ]
sources = [
- "${dawn_root}/src/include/dawn/platform/DawnPlatform.h",
- "${dawn_root}/src/include/dawn/platform/dawn_platform_export.h",
+ "${dawn_root}/include/dawn/platform/DawnPlatform.h",
+ "${dawn_root}/include/dawn/platform/dawn_platform_export.h",
"DawnPlatform.cpp",
"WorkerThread.cpp",
"WorkerThread.h",
@@ -36,6 +36,6 @@
public_deps = [
# DawnPlatform.h has #include <dawn/webgpu.h>
- "${dawn_root}/src/dawn:headers",
+ "${dawn_root}/include/dawn:headers",
]
}
diff --git a/src/dawn/utils/BUILD.gn b/src/dawn/utils/BUILD.gn
index 0714490..e281b41 100644
--- a/src/dawn/utils/BUILD.gn
+++ b/src/dawn/utils/BUILD.gn
@@ -134,7 +134,7 @@
}
}
- public_deps = [ "${dawn_root}/src/dawn:cpp_headers" ]
+ public_deps = [ "${dawn_root}/include/dawn:cpp_headers" ]
}
###############################################################################
@@ -151,7 +151,7 @@
"BackendBinding.h",
]
- public_deps = [ "${dawn_root}/src/dawn:headers" ]
+ public_deps = [ "${dawn_root}/include/dawn:headers" ]
deps = [
":glfw",
diff --git a/src/dawn/wire/BUILD.gn b/src/dawn/wire/BUILD.gn
index 9102149..bff2136 100644
--- a/src/dawn/wire/BUILD.gn
+++ b/src/dawn/wire/BUILD.gn
@@ -20,13 +20,13 @@
# Public dawn wire headers so they can be publically visible for dependencies of
# dawn/wire
source_set("headers") {
- public_deps = [ "${dawn_root}/src/dawn:headers" ]
- all_dependent_configs = [ "${dawn_root}/src/dawn/common:public_include_dirs" ]
+ public_deps = [ "${dawn_root}/include/dawn:headers" ]
+ all_dependent_configs = [ "${dawn_root}/include/dawn:public" ]
sources = [
- "${dawn_root}/src/include/dawn/wire/Wire.h",
- "${dawn_root}/src/include/dawn/wire/WireClient.h",
- "${dawn_root}/src/include/dawn/wire/WireServer.h",
- "${dawn_root}/src/include/dawn/wire/dawn_wire_export.h",
+ "${dawn_root}/include/dawn/wire/Wire.h",
+ "${dawn_root}/include/dawn/wire/WireClient.h",
+ "${dawn_root}/include/dawn/wire/WireServer.h",
+ "${dawn_root}/include/dawn/wire/dawn_wire_export.h",
]
}
diff --git a/src/include/README.md b/src/include/README.md
new file mode 100644
index 0000000..8111f62
--- /dev/null
+++ b/src/include/README.md
@@ -0,0 +1,4 @@
+# TODO(crbug.com/dawn/1275) - remove this directory
+
+This directory exists as a temporary include directory while migrating Chromium source to the new Dawn include layout.
+All headers in the subdirectories simply #include to the new location for the header.
diff --git a/src/include/dawn/EnumClassBitmasks.h b/src/include/dawn/EnumClassBitmasks.h
index 3947f00..143e980 100644
--- a/src/include/dawn/EnumClassBitmasks.h
+++ b/src/include/dawn/EnumClassBitmasks.h
@@ -1,156 +1 @@
-// Copyright 2017 The Dawn Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef DAWN_ENUM_CLASS_BITMASKS_H_
-#define DAWN_ENUM_CLASS_BITMASKS_H_
-
-#include <type_traits>
-
-// The operators in dawn:: namespace need be introduced into other namespaces with
-// using-declarations for C++ Argument Dependent Lookup to work.
-#define DAWN_IMPORT_BITMASK_OPERATORS \
- using dawn::operator|; \
- using dawn::operator&; \
- using dawn::operator^; \
- using dawn::operator~; \
- using dawn::operator&=; \
- using dawn::operator|=; \
- using dawn::operator^=; \
- using dawn::HasZeroOrOneBits;
-
-namespace dawn {
-
- template <typename T>
- struct IsDawnBitmask {
- static constexpr bool enable = false;
- };
-
- template <typename T, typename Enable = void>
- struct LowerBitmask {
- static constexpr bool enable = false;
- };
-
- template <typename T>
- struct LowerBitmask<T, typename std::enable_if<IsDawnBitmask<T>::enable>::type> {
- static constexpr bool enable = true;
- using type = T;
- constexpr static T Lower(T t) {
- return t;
- }
- };
-
- template <typename T>
- struct BoolConvertible {
- using Integral = typename std::underlying_type<T>::type;
-
- constexpr BoolConvertible(Integral value) : value(value) {
- }
- constexpr operator bool() const {
- return value != 0;
- }
- constexpr operator T() const {
- return static_cast<T>(value);
- }
-
- Integral value;
- };
-
- template <typename T>
- struct LowerBitmask<BoolConvertible<T>> {
- static constexpr bool enable = true;
- using type = T;
- static constexpr type Lower(BoolConvertible<T> t) {
- return t;
- }
- };
-
- template <typename T1,
- typename T2,
- typename = typename std::enable_if<LowerBitmask<T1>::enable &&
- LowerBitmask<T2>::enable>::type>
- constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator|(T1 left, T2 right) {
- using T = typename LowerBitmask<T1>::type;
- using Integral = typename std::underlying_type<T>::type;
- return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) |
- static_cast<Integral>(LowerBitmask<T2>::Lower(right));
- }
-
- template <typename T1,
- typename T2,
- typename = typename std::enable_if<LowerBitmask<T1>::enable &&
- LowerBitmask<T2>::enable>::type>
- constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator&(T1 left, T2 right) {
- using T = typename LowerBitmask<T1>::type;
- using Integral = typename std::underlying_type<T>::type;
- return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) &
- static_cast<Integral>(LowerBitmask<T2>::Lower(right));
- }
-
- template <typename T1,
- typename T2,
- typename = typename std::enable_if<LowerBitmask<T1>::enable &&
- LowerBitmask<T2>::enable>::type>
- constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator^(T1 left, T2 right) {
- using T = typename LowerBitmask<T1>::type;
- using Integral = typename std::underlying_type<T>::type;
- return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) ^
- static_cast<Integral>(LowerBitmask<T2>::Lower(right));
- }
-
- template <typename T1>
- constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator~(T1 t) {
- using T = typename LowerBitmask<T1>::type;
- using Integral = typename std::underlying_type<T>::type;
- return ~static_cast<Integral>(LowerBitmask<T1>::Lower(t));
- }
-
- template <typename T,
- typename T2,
- typename = typename std::enable_if<IsDawnBitmask<T>::enable &&
- LowerBitmask<T2>::enable>::type>
- constexpr T& operator&=(T& l, T2 right) {
- T r = LowerBitmask<T2>::Lower(right);
- l = l & r;
- return l;
- }
-
- template <typename T,
- typename T2,
- typename = typename std::enable_if<IsDawnBitmask<T>::enable &&
- LowerBitmask<T2>::enable>::type>
- constexpr T& operator|=(T& l, T2 right) {
- T r = LowerBitmask<T2>::Lower(right);
- l = l | r;
- return l;
- }
-
- template <typename T,
- typename T2,
- typename = typename std::enable_if<IsDawnBitmask<T>::enable &&
- LowerBitmask<T2>::enable>::type>
- constexpr T& operator^=(T& l, T2 right) {
- T r = LowerBitmask<T2>::Lower(right);
- l = l ^ r;
- return l;
- }
-
- template <typename T>
- constexpr bool HasZeroOrOneBits(T value) {
- using Integral = typename std::underlying_type<T>::type;
- return (static_cast<Integral>(value) & (static_cast<Integral>(value) - 1)) == 0;
- }
-
-} // namespace dawn
-
-#endif // DAWN_ENUM_CLASS_BITMASKS_H_
+#include <dawn/EnumClassBitmasks.h>
diff --git a/src/include/dawn/dawn_proc.h b/src/include/dawn/dawn_proc.h
index adeec46..f706d9f 100644
--- a/src/include/dawn/dawn_proc.h
+++ b/src/include/dawn/dawn_proc.h
@@ -1,36 +1 @@
-// Copyright 2019 The Dawn Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef DAWN_DAWN_PROC_H_
-#define DAWN_DAWN_PROC_H_
-
-#include "dawn/dawn_proc_table.h"
-#include "dawn/webgpu.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Sets the static proctable used by libdawn_proc to implement the Dawn entrypoints. Passing NULL
-// for `procs` sets up the null proctable that contains only null function pointers. It is the
-// default value of the proctable. Setting the proctable back to null is good practice when you
-// are done using libdawn_proc since further usage will cause a segfault instead of calling an
-// unexpected function.
-WGPU_EXPORT void dawnProcSetProcs(const DawnProcTable* procs);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // DAWN_DAWN_PROC_H_
+#include <dawn/dawn_proc.h>
diff --git a/src/include/dawn/dawn_thread_dispatch_proc.h b/src/include/dawn/dawn_thread_dispatch_proc.h
index 4d08ba8..318acb13 100644
--- a/src/include/dawn/dawn_thread_dispatch_proc.h
+++ b/src/include/dawn/dawn_thread_dispatch_proc.h
@@ -1,33 +1 @@
-// Copyright 2020 The Dawn Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef DAWN_DAWN_THREAD_DISPATCH_PROC_H_
-#define DAWN_DAWN_THREAD_DISPATCH_PROC_H_
-
-#include "dawn/dawn_proc.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// Call dawnProcSetProcs(&dawnThreadDispatchProcTable) and then use dawnProcSetPerThreadProcs
-// to set per-thread procs.
-WGPU_EXPORT extern DawnProcTable dawnThreadDispatchProcTable;
-WGPU_EXPORT void dawnProcSetPerThreadProcs(const DawnProcTable* procs);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // DAWN_DAWN_THREAD_DISPATCH_PROC_H_
+#include <dawn/dawn_thread_dispatch_proc.h>
diff --git a/src/include/dawn/dawn_wsi.h b/src/include/dawn/dawn_wsi.h
index f1a6047..0ee9aab 100644
--- a/src/include/dawn/dawn_wsi.h
+++ b/src/include/dawn/dawn_wsi.h
@@ -1,86 +1 @@
-// Copyright 2017 The Dawn Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef DAWN_DAWN_WSI_H_
-#define DAWN_DAWN_WSI_H_
-
-#include <dawn/webgpu.h>
-
-// Error message (or nullptr if there was no error)
-typedef const char* DawnSwapChainError;
-constexpr DawnSwapChainError DAWN_SWAP_CHAIN_NO_ERROR = nullptr;
-
-typedef struct {
- /// Backend-specific texture id/name/pointer
- union {
- void* ptr;
- uint64_t u64;
- uint32_t u32;
- } texture;
-} DawnSwapChainNextTexture;
-
-typedef struct {
- /// Initialize the swap chain implementation.
- /// (*wsiContext) is one of DawnWSIContext{D3D12,Metal,GL}
- void (*Init)(void* userData, void* wsiContext);
-
- /// Destroy the swap chain implementation.
- void (*Destroy)(void* userData);
-
- /// Configure/reconfigure the swap chain.
- DawnSwapChainError (*Configure)(void* userData,
- WGPUTextureFormat format,
- WGPUTextureUsage allowedUsage,
- uint32_t width,
- uint32_t height);
-
- /// Acquire the next texture from the swap chain.
- DawnSwapChainError (*GetNextTexture)(void* userData, DawnSwapChainNextTexture* nextTexture);
-
- /// Present the last acquired texture to the screen.
- DawnSwapChainError (*Present)(void* userData);
-
- /// Each function is called with userData as its first argument.
- void* userData;
-
- /// For use by the D3D12 and Vulkan backends: how the swapchain will use the texture.
- WGPUTextureUsage textureUsage;
-} DawnSwapChainImplementation;
-
-#if defined(DAWN_ENABLE_BACKEND_D3D12) && defined(__cplusplus)
-struct DawnWSIContextD3D12 {
- WGPUDevice device = nullptr;
-};
-#endif
-
-#if defined(DAWN_ENABLE_BACKEND_METAL) && defined(__OBJC__)
-# import <Metal/Metal.h>
-
-struct DawnWSIContextMetal {
- id<MTLDevice> device = nil;
- id<MTLCommandQueue> queue = nil;
-};
-#endif
-
-#ifdef DAWN_ENABLE_BACKEND_OPENGL
-typedef struct {
-} DawnWSIContextGL;
-#endif
-
-#ifdef DAWN_ENABLE_BACKEND_VULKAN
-typedef struct {
-} DawnWSIContextVulkan;
-#endif
-
-#endif // DAWN_DAWN_WSI_H
+#include <dawn/dawn_wsi.h>
diff --git a/src/include/dawn/webgpu.h b/src/include/dawn/webgpu.h
new file mode 100644
index 0000000..a410df1
--- /dev/null
+++ b/src/include/dawn/webgpu.h
@@ -0,0 +1 @@
+#include <dawn/webgpu.h>
diff --git a/src/include/dawn/webgpu_cpp.h b/src/include/dawn/webgpu_cpp.h
new file mode 100644
index 0000000..8904453
--- /dev/null
+++ b/src/include/dawn/webgpu_cpp.h
@@ -0,0 +1 @@
+#include "dawn/webgpu_cpp.h"