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

@@ -16,7 +16,7 @@
#include "dawn/EnumClassBitmasks.h"
namespace dawn {
namespace wgpu {
enum class Color : uint32_t {
R = 1,
@@ -80,14 +80,14 @@ namespace dawn {
TEST(BitmaskTests, ZeroOrOneBits) {
Color zero = static_cast<Color>(0);
ASSERT_TRUE(HasZeroOrOneBits(zero));
ASSERT_TRUE(HasZeroOrOneBits(Color::R));
ASSERT_TRUE(HasZeroOrOneBits(Color::G));
ASSERT_TRUE(HasZeroOrOneBits(Color::B));
ASSERT_TRUE(HasZeroOrOneBits(Color::A));
ASSERT_FALSE(HasZeroOrOneBits(static_cast<Color>(Color::R | Color::G)));
ASSERT_FALSE(HasZeroOrOneBits(static_cast<Color>(Color::G | Color::B)));
ASSERT_FALSE(HasZeroOrOneBits(static_cast<Color>(Color::B | Color::A)));
ASSERT_TRUE(dawn::HasZeroOrOneBits(zero));
ASSERT_TRUE(dawn::HasZeroOrOneBits(Color::R));
ASSERT_TRUE(dawn::HasZeroOrOneBits(Color::G));
ASSERT_TRUE(dawn::HasZeroOrOneBits(Color::B));
ASSERT_TRUE(dawn::HasZeroOrOneBits(Color::A));
ASSERT_FALSE(dawn::HasZeroOrOneBits(static_cast<Color>(Color::R | Color::G)));
ASSERT_FALSE(dawn::HasZeroOrOneBits(static_cast<Color>(Color::G | Color::B)));
ASSERT_FALSE(dawn::HasZeroOrOneBits(static_cast<Color>(Color::B | Color::A)));
}
} // namespace dawn
} // namespace wgpu

View File

@@ -102,13 +102,13 @@ namespace {
// Test GetProcAddress with and without devices on some valid examples
TEST_P(GetProcAddressTests, ValidExamples) {
ASSERT_EQ(mProcs.getProcAddress(nullptr, "dawnDeviceCreateBuffer"),
ASSERT_EQ(mProcs.getProcAddress(nullptr, "wgpuDeviceCreateBuffer"),
reinterpret_cast<DawnProc>(mProcs.deviceCreateBuffer));
ASSERT_EQ(mProcs.getProcAddress(mDevice.Get(), "dawnDeviceCreateBuffer"),
ASSERT_EQ(mProcs.getProcAddress(mDevice.Get(), "wgpuDeviceCreateBuffer"),
reinterpret_cast<DawnProc>(mProcs.deviceCreateBuffer));
ASSERT_EQ(mProcs.getProcAddress(nullptr, "dawnQueueSubmit"),
ASSERT_EQ(mProcs.getProcAddress(nullptr, "wgpuQueueSubmit"),
reinterpret_cast<DawnProc>(mProcs.queueSubmit));
ASSERT_EQ(mProcs.getProcAddress(mDevice.Get(), "dawnQueueSubmit"),
ASSERT_EQ(mProcs.getProcAddress(mDevice.Get(), "wgpuQueueSubmit"),
reinterpret_cast<DawnProc>(mProcs.queueSubmit));
}
@@ -120,8 +120,8 @@ namespace {
// Test GetProcAddress with and without devices on some invalid
TEST_P(GetProcAddressTests, InvalidExamples) {
ASSERT_EQ(mProcs.getProcAddress(nullptr, "dawnDeviceDoSomething"), nullptr);
ASSERT_EQ(mProcs.getProcAddress(mDevice.Get(), "dawnDeviceDoSomething"), nullptr);
ASSERT_EQ(mProcs.getProcAddress(nullptr, "wgpuDeviceDoSomething"), nullptr);
ASSERT_EQ(mProcs.getProcAddress(mDevice.Get(), "wgpuDeviceDoSomething"), nullptr);
// Trigger the condition where lower_bound will return the end of the procMap.
ASSERT_EQ(mProcs.getProcAddress(nullptr, "zzzzzzz"), nullptr);
@@ -139,9 +139,9 @@ namespace {
// Test that GetProcAddress supports itself: it is handled specially because it is a
// freestanding function and not a method on an object.
TEST_P(GetProcAddressTests, GetProcAddressItself) {
ASSERT_EQ(mProcs.getProcAddress(nullptr, "dawnGetProcAddress"),
ASSERT_EQ(mProcs.getProcAddress(nullptr, "wgpuGetProcAddress"),
reinterpret_cast<DawnProc>(mProcs.getProcAddress));
ASSERT_EQ(mProcs.getProcAddress(mDevice.Get(), "dawnGetProcAddress"),
ASSERT_EQ(mProcs.getProcAddress(mDevice.Get(), "wgpuGetProcAddress"),
reinterpret_cast<DawnProc>(mProcs.getProcAddress));
}

View File

@@ -16,19 +16,19 @@
#include "dawn/dawncpp.h"
class Object : public dawn::ObjectBase<Object, int*> {
public:
using ObjectBase::ObjectBase;
using ObjectBase::operator=;
class Object : public wgpu::ObjectBase<Object, int*> {
public:
using ObjectBase::ObjectBase;
using ObjectBase::operator=;
static void DawnReference(int* handle) {
ASSERT_LE(0, *handle);
*handle += 1;
}
static void DawnRelease(int* handle) {
ASSERT_LT(0, *handle);
*handle -= 1;
}
static void WGPUReference(int* handle) {
ASSERT_LE(0, *handle);
*handle += 1;
}
static void WGPURelease(int* handle) {
ASSERT_LT(0, *handle);
*handle -= 1;
}
};
// Test that creating an C++ object from a C object takes a ref.

View File

@@ -25,12 +25,12 @@ TEST_F(WireDawnDevicePropertiesTests, SerializeDawnDeviceProperties) {
sentDawnDeviceProperties.textureCompressionBC = true;
size_t sentDawnDevicePropertiesSize =
dawn_wire::SerializedDawnDevicePropertiesSize(&sentDawnDeviceProperties);
dawn_wire::SerializedWGPUDevicePropertiesSize(&sentDawnDeviceProperties);
std::vector<char> buffer;
buffer.resize(sentDawnDevicePropertiesSize);
dawn_wire::SerializeDawnDeviceProperties(&sentDawnDeviceProperties, buffer.data());
dawn_wire::SerializeWGPUDeviceProperties(&sentDawnDeviceProperties, buffer.data());
DawnDeviceProperties receivedDawnDeviceProperties;
dawn_wire::DeserializeDawnDeviceProperties(&receivedDawnDeviceProperties, buffer.data());
dawn_wire::DeserializeWGPUDeviceProperties(&receivedDawnDeviceProperties, buffer.data());
ASSERT_TRUE(receivedDawnDeviceProperties.textureCompressionBC);
}