Commit 42232ab5 by Alexis Hetu Committed by Alexis Hétu

Fix VkFence destruction crashing on Windows

vk::destroy was crashing for vk::Fence after: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31988 Reverted that change and fixed it in VkObject.cpp to make sure the result of the cast is always equal to the allocated memory. Bug: b/117835459 Change-Id: I831625418fc83503329e833d48d9765b75d83b80 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31990Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Presubmit-Ready: Alexis Hétu <sugoi@google.com> Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent a71a1dbb
......@@ -82,7 +82,7 @@ private:
static inline Fence* Cast(VkFence object)
{
return static_cast<Fence*>(reinterpret_cast<Object<Fence, VkFence>*>(object.get()));
return reinterpret_cast<Fence*>(object.get());
}
} // namespace vk
......
......@@ -61,6 +61,9 @@ static VkResult Create(const VkAllocationCallbacks* pAllocator, const CreateInfo
*outObject = *object;
// Assert that potential v-table offsets from multiple inheritance aren't causing an offset on the handle
ASSERT(*outObject == objectMemory);
return VK_SUCCESS;
}
......@@ -87,7 +90,9 @@ class Object : public ObjectBase<T, VkT>
public:
operator VkT()
{
return reinterpret_cast<typename VkT::HandleType>(this);
// The static_cast<T*> is used to make sure the returned pointer points to the
// beginning of the object, even if the derived class uses multiple inheritance
return reinterpret_cast<typename VkT::HandleType>(static_cast<T*>(this));
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment