Rename nxtProcTable and nxtSetProcs to dawn
This commit is contained in:
parent
b1669e3fa4
commit
be5ca38351
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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()}}
|
||||
|
|
|
@ -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)}});
|
||||
|
|
|
@ -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"] %}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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<dawnDeviceImpl*>(clientDevice);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<dawnDevice>(new Device());
|
||||
|
|
|
@ -35,10 +35,10 @@
|
|||
#include <unistd.h>
|
||||
|
||||
namespace backend { namespace metal {
|
||||
nxtProcTable GetNonValidatingProcs();
|
||||
nxtProcTable GetValidatingProcs();
|
||||
dawnProcTable GetNonValidatingProcs();
|
||||
dawnProcTable GetValidatingProcs();
|
||||
|
||||
void Init(id<MTLDevice> metalDevice, nxtProcTable* procs, dawnDevice* device) {
|
||||
void Init(id<MTLDevice> metalDevice, dawnProcTable* procs, dawnDevice* device) {
|
||||
*device = nullptr;
|
||||
|
||||
*procs = GetValidatingProcs();
|
||||
|
|
|
@ -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<dawnDevice>(new Device);
|
||||
}
|
||||
|
|
|
@ -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<GLADloadproc>(getProc));
|
||||
|
|
|
@ -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<const char*>& requiredInstanceExtensions) {
|
||||
*procs = GetValidatingProcs();
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<dawnCallbackUserdata>(reinterpret_cast<uintptr_t>(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() {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include <dawn/dawn_wsi.h>
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#import <QuartzCore/CAMetalLayer.h>
|
||||
|
||||
namespace backend { namespace metal {
|
||||
void Init(id<MTLDevice> metalDevice, nxtProcTable* procs, dawnDevice* device);
|
||||
void Init(id<MTLDevice> metalDevice, dawnProcTable* procs, dawnDevice* device);
|
||||
void SetNextDrawable(dawnDevice device, id<CAMetalDrawable> 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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<void* (*)(const char*)>(glfwGetProcAddress),
|
||||
procs, device);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <vector>
|
||||
|
||||
namespace backend { namespace vulkan {
|
||||
void Init(nxtProcTable* procs,
|
||||
void Init(dawnProcTable* procs,
|
||||
dawnDevice* device,
|
||||
const std::vector<const char*>& 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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue