mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-13 23:26:24 +00:00
Implement the device error callback.
This adds support for "natively defined" API types like callbacks that will have to be implemented manually for each target language. Also this splits the concept of "native method" into a set of native methods per language. Removes the "Synchronous error" concept that was used to make builders work in the maybe Monad, this will have to be reinroduced with builder callbacks.
This commit is contained in:
committed by
Corentin Wallez
parent
682a8250b3
commit
4b410a33ca
@@ -28,8 +28,6 @@
|
||||
BackendBinding* CreateMetalBinding();
|
||||
|
||||
namespace backend {
|
||||
void RegisterSynchronousErrorCallback(nxtDevice device, void(*)(const char*, void*), void* userData);
|
||||
|
||||
namespace opengl {
|
||||
void Init(void* (*getProc)(const char*), nxtProcTable* procs, nxtDevice* device);
|
||||
void HACKCLEAR();
|
||||
@@ -61,6 +59,10 @@ class OpenGLBinding : public BackendBinding {
|
||||
}
|
||||
};
|
||||
|
||||
void PrintDeviceError(const char* message, nxt::CallbackUserdata) {
|
||||
std::cout << "Device error: " << message << std::endl;
|
||||
}
|
||||
|
||||
enum class BackendType {
|
||||
OpenGL,
|
||||
Metal,
|
||||
@@ -83,15 +85,6 @@ static nxt::wire::CommandHandler* wireClient = nullptr;
|
||||
static nxt::wire::TerribleCommandBuffer* c2sBuf = nullptr;
|
||||
static nxt::wire::TerribleCommandBuffer* s2cBuf = nullptr;
|
||||
|
||||
void HandleSynchronousError(const char* errorMessage, void* userData) {
|
||||
std::cerr << errorMessage << std::endl;
|
||||
|
||||
if (userData != nullptr) {
|
||||
auto wireServer = reinterpret_cast<nxt::wire::CommandHandler*>(userData);
|
||||
wireServer->OnSynchronousError();
|
||||
}
|
||||
}
|
||||
|
||||
void GetProcTableAndDevice(nxtProcTable* procs, nxt::Device* device) {
|
||||
switch (backendType) {
|
||||
case BackendType::OpenGL:
|
||||
@@ -147,8 +140,7 @@ void GetProcTableAndDevice(nxtProcTable* procs, nxt::Device* device) {
|
||||
break;
|
||||
}
|
||||
|
||||
//TODO(cwallez@chromium.org) this will disappear
|
||||
backend::RegisterSynchronousErrorCallback(backendDevice, HandleSynchronousError, wireServer);
|
||||
procs->deviceSetErrorCallback(device->Get(), PrintDeviceError, 0);
|
||||
}
|
||||
|
||||
nxt::ShaderModule CreateShaderModule(const nxt::Device& device, nxt::ShaderStage stage, const char* source) {
|
||||
|
||||
Reference in New Issue
Block a user