From be5ca38351fa810fb25273b9619e2d9c9c21d9a7 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Wed, 18 Jul 2018 15:15:07 +0200 Subject: [PATCH] Rename nxtProcTable and nxtSetProcs to dawn --- README.md | 4 ++-- examples/SampleUtils.cpp | 8 ++++---- generator/templates/api.c | 6 +++--- generator/templates/api.h | 10 +++++----- generator/templates/backend/ProcTable.cpp | 8 ++++---- generator/templates/mock_api.cpp | 2 +- generator/templates/mock_api.h | 2 +- generator/templates/wire/WireClient.cpp | 6 +++--- generator/templates/wire/WireServer.cpp | 6 +++--- src/backend/d3d12/DeviceD3D12.cpp | 6 +++--- src/backend/metal/DeviceMTL.mm | 6 +++--- src/backend/null/NullBackend.cpp | 6 +++--- src/backend/opengl/DeviceGL.cpp | 6 +++--- src/backend/vulkan/DeviceVk.cpp | 6 +++--- src/tests/NXTTest.cpp | 10 +++++----- src/tests/unittests/WireTests.cpp | 8 ++++---- src/tests/unittests/validation/ValidationTest.cpp | 8 ++++---- src/utils/BackendBinding.h | 4 ++-- src/utils/D3D12Binding.cpp | 4 ++-- src/utils/MetalBinding.mm | 4 ++-- src/utils/NullBinding.cpp | 4 ++-- src/utils/OpenGLBinding.cpp | 4 ++-- src/utils/VulkanBinding.cpp | 4 ++-- src/wire/Wire.h | 4 ++-- 24 files changed, 68 insertions(+), 68 deletions(-) diff --git a/README.md b/README.md index 6e3e9356a4..93e911c497 100644 --- a/README.md +++ b/README.md @@ -84,8 +84,8 @@ For example, NXT can only return objects which prevents mapping buffers or even Other generators include: -- A C-header with the definition of nxtProcTable that is the “real” underlying NXT API exposed by the backends. -- Glue code generating nxtProcTable for a backend with simple validation included (enum value checks etc.) +- A C-header with the definition of dawnProcTable that is the “real” underlying NXT API exposed by the backends. +- Glue code generating dawnProcTable for a backend with simple validation included (enum value checks etc.) - A mock API for testing ## Structure of the code diff --git a/examples/SampleUtils.cpp b/examples/SampleUtils.cpp index 81e840fd5e..3509c56043 100644 --- a/examples/SampleUtils.cpp +++ b/examples/SampleUtils.cpp @@ -85,11 +85,11 @@ dawn::Device CreateCppDawnDevice() { binding->SetWindow(window); dawnDevice backendDevice; - nxtProcTable backendProcs; + dawnProcTable backendProcs; binding->GetProcAndDevice(&backendProcs, &backendDevice); dawnDevice cDevice = nullptr; - nxtProcTable procs; + dawnProcTable procs; switch (cmdBufType) { case CmdBufType::None: procs = backendProcs; @@ -105,7 +105,7 @@ dawn::Device CreateCppDawnDevice() { c2sBuf->SetHandler(wireServer); dawnDevice clientDevice; - nxtProcTable clientProcs; + dawnProcTable clientProcs; wireClient = dawn::wire::NewClientDevice(&clientProcs, &clientDevice, c2sBuf); s2cBuf->SetHandler(wireClient); @@ -115,7 +115,7 @@ dawn::Device CreateCppDawnDevice() { break; } - nxtSetProcs(&procs); + dawnSetProcs(&procs); procs.deviceSetErrorCallback(cDevice, PrintDeviceError, 0); return dawn::Device::Acquire(cDevice); } diff --git a/generator/templates/api.c b/generator/templates/api.c index 5ee25ccf4d..b1c09f99aa 100644 --- a/generator/templates/api.c +++ b/generator/templates/api.c @@ -14,11 +14,11 @@ #include "dawn/dawn.h" -static nxtProcTable procs; +static dawnProcTable procs; -static nxtProcTable nullProcs; +static dawnProcTable nullProcs; -void nxtSetProcs(const nxtProcTable* procs_) { +void dawnSetProcs(const dawnProcTable* procs_) { if (procs_) { procs = *procs_; } else { diff --git a/generator/templates/api.h b/generator/templates/api.h index 2a6628b70a..c497a29f5f 100644 --- a/generator/templates/api.h +++ b/generator/templates/api.h @@ -68,7 +68,7 @@ extern "C" { {% endfor %} -struct nxtProcTable_s { +struct dawnProcTable_s { {% for type in by_category["object"] %} {% for method in native_methods(type) %} {{as_cProc(type.name, method.name)}} {{as_varName(type.name, method.name)}}; @@ -76,12 +76,12 @@ struct nxtProcTable_s { {% endfor %} }; -typedef struct nxtProcTable_s nxtProcTable; +typedef struct dawnProcTable_s dawnProcTable; -// Stuff below is for convenience and will forward calls to a static nxtProcTable. +// Stuff below is for convenience and will forward calls to a static dawnProcTable. -// Set which nxtProcTable will be used -void nxtSetProcs(const nxtProcTable* procs); +// Set which dawnProcTable will be used +void dawnSetProcs(const dawnProcTable* procs); {% for type in by_category["object"] %} // Methods of {{type.name.CamelCase()}} diff --git a/generator/templates/backend/ProcTable.cpp b/generator/templates/backend/ProcTable.cpp index 65e17912dc..a1722ad799 100644 --- a/generator/templates/backend/ProcTable.cpp +++ b/generator/templates/backend/ProcTable.cpp @@ -183,8 +183,8 @@ namespace {{namespace}} { {% endfor %} } - nxtProcTable GetNonValidatingProcs() { - nxtProcTable table; + dawnProcTable GetNonValidatingProcs() { + dawnProcTable table; {% for type in by_category["object"] %} {% for method in native_methods(type) %} table.{{as_varName(type.name, method.name)}} = reinterpret_cast<{{as_cProc(type.name, method.name)}}>(NonValidating{{as_MethodSuffix(type.name, method.name)}}); @@ -193,8 +193,8 @@ namespace {{namespace}} { return table; } - nxtProcTable GetValidatingProcs() { - nxtProcTable table; + dawnProcTable GetValidatingProcs() { + dawnProcTable table; {% for type in by_category["object"] %} {% for method in native_methods(type) %} table.{{as_varName(type.name, method.name)}} = reinterpret_cast<{{as_cProc(type.name, method.name)}}>(Validating{{as_MethodSuffix(type.name, method.name)}}); diff --git a/generator/templates/mock_api.cpp b/generator/templates/mock_api.cpp index 9c6ac1dda1..1ea25c3fbd 100644 --- a/generator/templates/mock_api.cpp +++ b/generator/templates/mock_api.cpp @@ -38,7 +38,7 @@ namespace { ProcTableAsClass::~ProcTableAsClass() { } -void ProcTableAsClass::GetProcTableAndDevice(nxtProcTable* table, dawnDevice* device) { +void ProcTableAsClass::GetProcTableAndDevice(dawnProcTable* table, dawnDevice* device) { *device = GetNewDevice(); {% for type in by_category["object"] %} diff --git a/generator/templates/mock_api.h b/generator/templates/mock_api.h index 63e5ec43ff..ba884fa0d2 100644 --- a/generator/templates/mock_api.h +++ b/generator/templates/mock_api.h @@ -27,7 +27,7 @@ class ProcTableAsClass { public: virtual ~ProcTableAsClass(); - void GetProcTableAndDevice(nxtProcTable* table, dawnDevice* device); + void GetProcTableAndDevice(dawnProcTable* table, dawnDevice* device); // Creates an object that can be returned by a mocked call as in WillOnce(Return(foo)). // It returns an object of the write type that isn't equal to any previously returned object. diff --git a/generator/templates/wire/WireClient.cpp b/generator/templates/wire/WireClient.cpp index 655eff1254..5e22509086 100644 --- a/generator/templates/wire/WireClient.cpp +++ b/generator/templates/wire/WireClient.cpp @@ -416,8 +416,8 @@ namespace dawn { namespace wire { // the autogenerated one, and that will have to call Client{{suffix}} {% set proxied_commands = ["BufferUnmap"] %} - nxtProcTable GetProcs() { - nxtProcTable table; + dawnProcTable GetProcs() { + dawnProcTable table; {% for type in by_category["object"] %} {% for method in native_methods(type) %} {% set suffix = as_MethodSuffix(type.name, method.name) %} @@ -664,7 +664,7 @@ namespace dawn { namespace wire { } - CommandHandler* NewClientDevice(nxtProcTable* procs, dawnDevice* device, CommandSerializer* serializer) { + CommandHandler* NewClientDevice(dawnProcTable* procs, dawnDevice* device, CommandSerializer* serializer) { auto clientDevice = new client::Device(serializer); *device = reinterpret_cast(clientDevice); diff --git a/generator/templates/wire/WireServer.cpp b/generator/templates/wire/WireServer.cpp index 55c9fd777a..25980d8fcd 100644 --- a/generator/templates/wire/WireServer.cpp +++ b/generator/templates/wire/WireServer.cpp @@ -205,7 +205,7 @@ namespace dawn { namespace wire { class Server : public CommandHandler, public ObjectIdResolver { public: - Server(dawnDevice device, const nxtProcTable& procs, CommandSerializer* serializer) + Server(dawnDevice device, const dawnProcTable& procs, CommandSerializer* serializer) : mProcs(procs), mSerializer(serializer) { //* The client-server knowledge is bootstrapped with device 1. auto* deviceData = mKnownDevice.Allocate(1); @@ -346,7 +346,7 @@ namespace dawn { namespace wire { } private: - nxtProcTable mProcs; + dawnProcTable mProcs; CommandSerializer* mSerializer = nullptr; ServerAllocator mAllocator; @@ -622,7 +622,7 @@ namespace dawn { namespace wire { } } - CommandHandler* NewServerCommandHandler(dawnDevice device, const nxtProcTable& procs, CommandSerializer* serializer) { + CommandHandler* NewServerCommandHandler(dawnDevice device, const dawnProcTable& procs, CommandSerializer* serializer) { return new server::Server(device, procs, serializer); } diff --git a/src/backend/d3d12/DeviceD3D12.cpp b/src/backend/d3d12/DeviceD3D12.cpp index a504a5f115..7d427c138d 100644 --- a/src/backend/d3d12/DeviceD3D12.cpp +++ b/src/backend/d3d12/DeviceD3D12.cpp @@ -40,10 +40,10 @@ namespace backend { namespace d3d12 { - nxtProcTable GetNonValidatingProcs(); - nxtProcTable GetValidatingProcs(); + dawnProcTable GetNonValidatingProcs(); + dawnProcTable GetValidatingProcs(); - void Init(nxtProcTable* procs, dawnDevice* device) { + void Init(dawnProcTable* procs, dawnDevice* device) { *device = nullptr; *procs = GetValidatingProcs(); *device = reinterpret_cast(new Device()); diff --git a/src/backend/metal/DeviceMTL.mm b/src/backend/metal/DeviceMTL.mm index 1dc51dbfdd..2ba726c3c4 100644 --- a/src/backend/metal/DeviceMTL.mm +++ b/src/backend/metal/DeviceMTL.mm @@ -35,10 +35,10 @@ #include namespace backend { namespace metal { - nxtProcTable GetNonValidatingProcs(); - nxtProcTable GetValidatingProcs(); + dawnProcTable GetNonValidatingProcs(); + dawnProcTable GetValidatingProcs(); - void Init(id metalDevice, nxtProcTable* procs, dawnDevice* device) { + void Init(id metalDevice, dawnProcTable* procs, dawnDevice* device) { *device = nullptr; *procs = GetValidatingProcs(); diff --git a/src/backend/null/NullBackend.cpp b/src/backend/null/NullBackend.cpp index d2e69da291..5aa8ce21b2 100644 --- a/src/backend/null/NullBackend.cpp +++ b/src/backend/null/NullBackend.cpp @@ -20,10 +20,10 @@ namespace backend { namespace null { - nxtProcTable GetNonValidatingProcs(); - nxtProcTable GetValidatingProcs(); + dawnProcTable GetNonValidatingProcs(); + dawnProcTable GetValidatingProcs(); - void Init(nxtProcTable* procs, dawnDevice* device) { + void Init(dawnProcTable* procs, dawnDevice* device) { *procs = GetValidatingProcs(); *device = reinterpret_cast(new Device); } diff --git a/src/backend/opengl/DeviceGL.cpp b/src/backend/opengl/DeviceGL.cpp index a5798a8057..121e9085bf 100644 --- a/src/backend/opengl/DeviceGL.cpp +++ b/src/backend/opengl/DeviceGL.cpp @@ -32,10 +32,10 @@ #include "backend/opengl/TextureGL.h" namespace backend { namespace opengl { - nxtProcTable GetNonValidatingProcs(); - nxtProcTable GetValidatingProcs(); + dawnProcTable GetNonValidatingProcs(); + dawnProcTable GetValidatingProcs(); - void Init(void* (*getProc)(const char*), nxtProcTable* procs, dawnDevice* device) { + void Init(void* (*getProc)(const char*), dawnProcTable* procs, dawnDevice* device) { *device = nullptr; gladLoadGLLoader(reinterpret_cast(getProc)); diff --git a/src/backend/vulkan/DeviceVk.cpp b/src/backend/vulkan/DeviceVk.cpp index feda37926b..9cfb7c6be0 100644 --- a/src/backend/vulkan/DeviceVk.cpp +++ b/src/backend/vulkan/DeviceVk.cpp @@ -52,10 +52,10 @@ const char kVulkanLibName[] = "vulkan-1.dll"; namespace backend { namespace vulkan { - nxtProcTable GetNonValidatingProcs(); - nxtProcTable GetValidatingProcs(); + dawnProcTable GetNonValidatingProcs(); + dawnProcTable GetValidatingProcs(); - void Init(nxtProcTable* procs, + void Init(dawnProcTable* procs, dawnDevice* device, const std::vector& requiredInstanceExtensions) { *procs = GetValidatingProcs(); diff --git a/src/tests/NXTTest.cpp b/src/tests/NXTTest.cpp index bc7b875d05..ea7bf7defa 100644 --- a/src/tests/NXTTest.cpp +++ b/src/tests/NXTTest.cpp @@ -106,7 +106,7 @@ NXTTest::~NXTTest() { delete mBinding; mBinding = nullptr; - nxtSetProcs(nullptr); + dawnSetProcs(nullptr); } bool NXTTest::IsD3D12() const { @@ -137,12 +137,12 @@ void NXTTest::SetUp() { mBinding->SetWindow(testWindow); dawnDevice backendDevice; - nxtProcTable backendProcs; + dawnProcTable backendProcs; mBinding->GetProcAndDevice(&backendProcs, &backendDevice); // Choose whether to use the backend procs and devices directly, or set up the wire. dawnDevice cDevice = nullptr; - nxtProcTable procs; + dawnProcTable procs; if (gTestUsesWire) { mC2sBuf = new dawn::wire::TerribleCommandBuffer(); @@ -152,7 +152,7 @@ void NXTTest::SetUp() { mC2sBuf->SetHandler(mWireServer); dawnDevice clientDevice; - nxtProcTable clientProcs; + dawnProcTable clientProcs; mWireClient = dawn::wire::NewClientDevice(&clientProcs, &clientDevice, mC2sBuf); mS2cBuf->SetHandler(mWireClient); @@ -165,7 +165,7 @@ void NXTTest::SetUp() { // Set up the device and queue because all tests need them, and NXTTest needs them too for the // deferred expectations. - nxtSetProcs(&procs); + dawnSetProcs(&procs); device = dawn::Device::Acquire(cDevice); queue = device.CreateQueue(); diff --git a/src/tests/unittests/WireTests.cpp b/src/tests/unittests/WireTests.cpp index b7a5aecfb8..382345158e 100644 --- a/src/tests/unittests/WireTests.cpp +++ b/src/tests/unittests/WireTests.cpp @@ -127,7 +127,7 @@ class WireTestsBase : public Test { mockBufferMapReadCallback = new MockBufferMapReadCallback; mockBufferMapWriteCallback = new MockBufferMapWriteCallback; - nxtProcTable mockProcs; + dawnProcTable mockProcs; dawnDevice mockDevice; api.GetProcTableAndDevice(&mockProcs, &mockDevice); @@ -144,16 +144,16 @@ class WireTestsBase : public Test { mWireServer = NewServerCommandHandler(mockDevice, mockProcs, mS2cBuf); mC2sBuf->SetHandler(mWireServer); - nxtProcTable clientProcs; + dawnProcTable clientProcs; mWireClient = NewClientDevice(&clientProcs, &device, mC2sBuf); - nxtSetProcs(&clientProcs); + dawnSetProcs(&clientProcs); mS2cBuf->SetHandler(mWireClient); apiDevice = mockDevice; } void TearDown() override { - nxtSetProcs(nullptr); + dawnSetProcs(nullptr); delete mWireServer; delete mWireClient; delete mC2sBuf; diff --git a/src/tests/unittests/validation/ValidationTest.cpp b/src/tests/unittests/validation/ValidationTest.cpp index 3fa11eac7d..344dd2b88c 100644 --- a/src/tests/unittests/validation/ValidationTest.cpp +++ b/src/tests/unittests/validation/ValidationTest.cpp @@ -18,16 +18,16 @@ namespace backend { namespace null { - void Init(nxtProcTable* procs, dawnDevice* device); + void Init(dawnProcTable* procs, dawnDevice* device); } } ValidationTest::ValidationTest() { - nxtProcTable procs; + dawnProcTable procs; dawnDevice cDevice; backend::null::Init(&procs, &cDevice); - nxtSetProcs(&procs); + dawnSetProcs(&procs); device = dawn::Device::Acquire(cDevice); device.SetErrorCallback(ValidationTest::OnDeviceError, static_cast(reinterpret_cast(this))); @@ -37,7 +37,7 @@ ValidationTest::~ValidationTest() { // We need to destroy NXT objects before setting the procs to null otherwise the nxt*Release // will call a nullptr device = dawn::Device(); - nxtSetProcs(nullptr); + dawnSetProcs(nullptr); } void ValidationTest::TearDown() { diff --git a/src/utils/BackendBinding.h b/src/utils/BackendBinding.h index 99d6c80a6d..c4f8fbffeb 100644 --- a/src/utils/BackendBinding.h +++ b/src/utils/BackendBinding.h @@ -18,7 +18,7 @@ #include struct GLFWwindow; -typedef struct nxtProcTable_s nxtProcTable; +typedef struct dawnProcTable_s dawnProcTable; typedef struct dawnDeviceImpl* dawnDevice; namespace utils { @@ -36,7 +36,7 @@ namespace utils { virtual ~BackendBinding() = default; virtual void SetupGLFWWindowHints() = 0; - virtual void GetProcAndDevice(nxtProcTable* procs, dawnDevice* device) = 0; + virtual void GetProcAndDevice(dawnProcTable* procs, dawnDevice* device) = 0; virtual uint64_t GetSwapChainImplementation() = 0; virtual dawnTextureFormat GetPreferredSwapChainTextureFormat() = 0; diff --git a/src/utils/D3D12Binding.cpp b/src/utils/D3D12Binding.cpp index 950a965cb4..60466212e1 100644 --- a/src/utils/D3D12Binding.cpp +++ b/src/utils/D3D12Binding.cpp @@ -22,7 +22,7 @@ #include "GLFW/glfw3native.h" namespace backend { namespace d3d12 { - void Init(nxtProcTable* procs, dawnDevice* device); + void Init(dawnProcTable* procs, dawnDevice* device); dawnSwapChainImplementation CreateNativeSwapChainImpl(dawnDevice device, HWND window); dawnTextureFormat GetNativeSwapChainPreferredFormat( @@ -37,7 +37,7 @@ namespace utils { glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); } - void GetProcAndDevice(nxtProcTable* procs, dawnDevice* device) override { + void GetProcAndDevice(dawnProcTable* procs, dawnDevice* device) override { backend::d3d12::Init(procs, device); mBackendDevice = *device; } diff --git a/src/utils/MetalBinding.mm b/src/utils/MetalBinding.mm index 2fe0e99a9d..da1f07f91d 100644 --- a/src/utils/MetalBinding.mm +++ b/src/utils/MetalBinding.mm @@ -26,7 +26,7 @@ #import namespace backend { namespace metal { - void Init(id metalDevice, nxtProcTable* procs, dawnDevice* device); + void Init(id metalDevice, dawnProcTable* procs, dawnDevice* device); void SetNextDrawable(dawnDevice device, id drawable); void Present(dawnDevice device); }} @@ -114,7 +114,7 @@ namespace utils { void SetupGLFWWindowHints() override { glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); } - void GetProcAndDevice(nxtProcTable* procs, dawnDevice* device) override { + void GetProcAndDevice(dawnProcTable* procs, dawnDevice* device) override { mMetalDevice = MTLCreateSystemDefaultDevice(); backend::metal::Init(mMetalDevice, procs, device); diff --git a/src/utils/NullBinding.cpp b/src/utils/NullBinding.cpp index 0e86828479..c6681bc64f 100644 --- a/src/utils/NullBinding.cpp +++ b/src/utils/NullBinding.cpp @@ -15,7 +15,7 @@ #include "utils/BackendBinding.h" namespace backend { namespace null { - void Init(nxtProcTable* procs, dawnDevice* device); + void Init(dawnProcTable* procs, dawnDevice* device); }} // namespace backend::null namespace utils { @@ -24,7 +24,7 @@ namespace utils { public: void SetupGLFWWindowHints() override { } - void GetProcAndDevice(nxtProcTable* procs, dawnDevice* device) override { + void GetProcAndDevice(dawnProcTable* procs, dawnDevice* device) override { backend::null::Init(procs, device); } uint64_t GetSwapChainImplementation() override { diff --git a/src/utils/OpenGLBinding.cpp b/src/utils/OpenGLBinding.cpp index cc5dc2a823..0f58f7f54b 100644 --- a/src/utils/OpenGLBinding.cpp +++ b/src/utils/OpenGLBinding.cpp @@ -26,7 +26,7 @@ #include "GLFW/glfw3.h" namespace backend { namespace opengl { - void Init(void* (*getProc)(const char*), nxtProcTable* procs, dawnDevice* device); + void Init(void* (*getProc)(const char*), dawnProcTable* procs, dawnDevice* device); }} // namespace backend::opengl namespace utils { @@ -111,7 +111,7 @@ namespace utils { glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); #endif } - void GetProcAndDevice(nxtProcTable* procs, dawnDevice* device) override { + void GetProcAndDevice(dawnProcTable* procs, dawnDevice* device) override { glfwMakeContextCurrent(mWindow); backend::opengl::Init(reinterpret_cast(glfwGetProcAddress), procs, device); diff --git a/src/utils/VulkanBinding.cpp b/src/utils/VulkanBinding.cpp index e700e20d29..f714fbcbda 100644 --- a/src/utils/VulkanBinding.cpp +++ b/src/utils/VulkanBinding.cpp @@ -23,7 +23,7 @@ #include namespace backend { namespace vulkan { - void Init(nxtProcTable* procs, + void Init(dawnProcTable* procs, dawnDevice* device, const std::vector& requiredInstanceExtensions); @@ -67,7 +67,7 @@ namespace utils { void SetupGLFWWindowHints() override { glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); } - void GetProcAndDevice(nxtProcTable* procs, dawnDevice* device) override { + void GetProcAndDevice(dawnProcTable* procs, dawnDevice* device) override { uint32_t extensionCount = 0; const char** glfwInstanceExtensions = glfwGetRequiredInstanceExtensions(&extensionCount); diff --git a/src/wire/Wire.h b/src/wire/Wire.h index 88d37ade02..b0aca95c0e 100644 --- a/src/wire/Wire.h +++ b/src/wire/Wire.h @@ -34,11 +34,11 @@ namespace dawn { namespace wire { virtual const char* HandleCommands(const char* commands, size_t size) = 0; }; - CommandHandler* NewClientDevice(nxtProcTable* procs, + CommandHandler* NewClientDevice(dawnProcTable* procs, dawnDevice* device, CommandSerializer* serializer); CommandHandler* NewServerCommandHandler(dawnDevice device, - const nxtProcTable& procs, + const dawnProcTable& procs, CommandSerializer* serializer); }} // namespace dawn::wire