Introduce the webgpu[_cpp].h headers.

webgpu.h is the "official" header for WebGPU in native and is being
developed in https://github.com/webgpu-native/webgpu-headers

dawn.h and dawncpp.h are changed to become webgpu.h and webgpu_cpp.h
respectively and use the new naming convention. New dawn.h and dawncpp.h
headers are created that just proxy the types, constants and functions
to their WebGPU counterpart.

Almost no naming change is done in Dawn in this commit, which help check
that the proxying headers work correctly. A couple changes were
necessary, in particular for tests of the internal of dawncpp.h, and a
workaround for a standard library bug for std::underlying_type was
removed because it is no longer needed and got in the way.

Finally since some templates were renamed to match the name of the file
they create instead of using the generic "api" name.

BUG=dawn:22

Change-Id: I12ee22d0b02ccb5b8a52ceccabb3e63ce74da007
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12480
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez
2019-10-21 20:04:10 +00:00
committed by Commit Bot service account
parent 16f1068025
commit 2c8b5c6370
23 changed files with 395 additions and 273 deletions

View File

@@ -19,24 +19,15 @@
namespace dawn {
// std::underlying_type doesn't work in old GLIBC still used in Chrome
#define CR_GLIBCXX_4_7_0 20120322
#define CR_GLIBCXX_4_5_4 20120702
#define CR_GLIBCXX_4_6_4 20121127
#if defined(__GLIBCXX__) && (__GLIBCXX__ < CR_GLIBCXX_4_7_0 || __GLIBCXX__ == CR_GLIBCXX_4_5_4 || \
__GLIBCXX__ == CR_GLIBCXX_4_6_4)
# define CR_USE_FALLBACKS_FOR_OLD_GLIBCXX
#endif
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;
}
#if defined(CR_USE_FALLBACKS_FOR_OLD_GLIBCXX)
template <typename T>
struct UnderlyingType {
using type = __underlying_type(T);
};
#else
template <typename T>
using UnderlyingType = std::underlying_type<T>;
#endif
} // namespace dawn
namespace wgpu {
template <typename T>
struct IsDawnBitmask {
@@ -59,7 +50,7 @@ namespace dawn {
template <typename T>
struct BoolConvertible {
using Integral = typename UnderlyingType<T>::type;
using Integral = typename std::underlying_type<T>::type;
constexpr BoolConvertible(Integral value) : value(value) {
}
@@ -82,19 +73,13 @@ namespace dawn {
}
};
template <typename T>
constexpr bool HasZeroOrOneBits(T value) {
using Integral = typename UnderlyingType<T>::type;
return (static_cast<Integral>(value) & (static_cast<Integral>(value) - 1)) == 0;
}
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 UnderlyingType<T>::type;
using Integral = typename std::underlying_type<T>::type;
return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) |
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
}
@@ -105,7 +90,7 @@ namespace dawn {
LowerBitmask<T2>::enable>::type>
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator&(T1 left, T2 right) {
using T = typename LowerBitmask<T1>::type;
using Integral = typename UnderlyingType<T>::type;
using Integral = typename std::underlying_type<T>::type;
return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) &
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
}
@@ -116,7 +101,7 @@ namespace dawn {
LowerBitmask<T2>::enable>::type>
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator^(T1 left, T2 right) {
using T = typename LowerBitmask<T1>::type;
using Integral = typename UnderlyingType<T>::type;
using Integral = typename std::underlying_type<T>::type;
return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) ^
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
}
@@ -124,7 +109,7 @@ namespace dawn {
template <typename T1>
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator~(T1 t) {
using T = typename LowerBitmask<T1>::type;
using Integral = typename UnderlyingType<T>::type;
using Integral = typename std::underlying_type<T>::type;
return ~static_cast<Integral>(LowerBitmask<T1>::Lower(t));
}
@@ -157,6 +142,6 @@ namespace dawn {
l = l ^ r;
return l;
}
} // namespace dawn
} // namespace wgpu
#endif // DAWN_ENUM_CLASS_BITMASKS_H_

View File

@@ -1,36 +0,0 @@
// Copyright 2018 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_EXPORT_H_
#define DAWN_EXPORT_H_
#if defined(DAWN_SHARED_LIBRARY)
# if defined(_WIN32)
# if defined(DAWN_IMPLEMENTATION)
# define DAWN_EXPORT __declspec(dllexport)
# else
# define DAWN_EXPORT __declspec(dllimport)
# endif
# else // defined(_WIN32)
# if defined(DAWN_IMPLEMENTATION)
# define DAWN_EXPORT __attribute__((visibility("default")))
# else
# define DAWN_EXPORT
# endif
# endif // defined(_WIN32)
#else // defined(DAWN_SHARED_LIBRARY)
# define DAWN_EXPORT
#endif // defined(DAWN_SHARED_LIBRARY)
#endif // DAWN_EXPORT_H_

View File

@@ -15,8 +15,8 @@
#ifndef DAWN_DAWN_PROC_H_
#define DAWN_DAWN_PROC_H_
#include "dawn/dawn.h"
#include "dawn/dawn_proc_table.h"
#include "dawn/webgpu.h"
#ifdef __cplusplus
extern "C" {
@@ -27,7 +27,7 @@ extern "C" {
// 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.
DAWN_EXPORT void dawnProcSetProcs(const DawnProcTable* procs);
WGPU_EXPORT void dawnProcSetProcs(const DawnProcTable* procs);
#ifdef __cplusplus
} // extern "C"

View File

@@ -36,12 +36,13 @@ namespace dawn_wire {
};
DAWN_WIRE_EXPORT size_t
SerializedDawnDevicePropertiesSize(const DawnDeviceProperties* deviceProperties);
SerializedWGPUDevicePropertiesSize(const DawnDeviceProperties* deviceProperties);
DAWN_WIRE_EXPORT void SerializeDawnDeviceProperties(
DAWN_WIRE_EXPORT void SerializeWGPUDeviceProperties(
const DawnDeviceProperties* deviceProperties,
char* serializeBuffer);
DAWN_WIRE_EXPORT bool DeserializeDawnDeviceProperties(DawnDeviceProperties* deviceProperties,
DAWN_WIRE_EXPORT bool DeserializeWGPUDeviceProperties(DawnDeviceProperties* deviceProperties,
const volatile char* deserializeBuffer);
} // namespace dawn_wire