From 596e7f0e1125e026d71489dfa6be3673de0411f5 Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Sat, 12 Mar 2022 05:48:02 +0000 Subject: [PATCH] Added a couple of helpers to WrappedMTLObject Dealloc() GetObjCWrappedMTLDevice() --- renderdoc/driver/metal/CMakeLists.txt | 1 + renderdoc/driver/metal/metal_resources.cpp | 36 ++++++++++++++++++++++ renderdoc/driver/metal/metal_resources.h | 4 +++ 3 files changed, 41 insertions(+) create mode 100644 renderdoc/driver/metal/metal_resources.cpp diff --git a/renderdoc/driver/metal/CMakeLists.txt b/renderdoc/driver/metal/CMakeLists.txt index e6e280801..fb7e1e38e 100644 --- a/renderdoc/driver/metal/CMakeLists.txt +++ b/renderdoc/driver/metal/CMakeLists.txt @@ -7,6 +7,7 @@ set(sources metal_device.cpp metal_device.h metal_device_bridge.mm + metal_resources.cpp metal_resources.h metal_types_bridge.mm metal_types_bridge.h diff --git a/renderdoc/driver/metal/metal_resources.cpp b/renderdoc/driver/metal/metal_resources.cpp new file mode 100644 index 000000000..2833677d0 --- /dev/null +++ b/renderdoc/driver/metal/metal_resources.cpp @@ -0,0 +1,36 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2022 Baldur Karlsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +#include "metal_resources.h" +#include "metal_device.h" + +void WrappedMTLObject::Dealloc() +{ + // TODO: call the wrapped object destructor +} + +MTL::Device *WrappedMTLObject::GetObjCWrappedMTLDevice() +{ + return UnwrapObjC(m_WrappedMTLDevice); +} diff --git a/renderdoc/driver/metal/metal_resources.h b/renderdoc/driver/metal/metal_resources.h index 61a8339f9..c251f77b9 100644 --- a/renderdoc/driver/metal/metal_resources.h +++ b/renderdoc/driver/metal/metal_resources.h @@ -57,6 +57,10 @@ struct WrappedMTLObject } ~WrappedMTLObject() = default; + void Dealloc(); + + MTL::Device *GetObjCWrappedMTLDevice(); + void *wrappedObjC; void *real; ResourceId id;