diff options
author | Kaiyi Li <kaiyili@google.com> | 2022-03-23 10:23:48 -0700 |
---|---|---|
committer | Kaiyi Li <kaiyili@google.com> | 2022-03-23 16:44:30 -0700 |
commit | e31de80111686b616d02fe4b91d1bdece8a617d0 (patch) | |
tree | d718ae137b9ff7aef0c9b401e4f6797c864b4909 /stream-servers/SwapChainStateVk.h | |
parent | 6d5497f81548362a84debe8d5071a3a6e87fd4ed (diff) | |
download | vulkan-cereal-e31de80111686b616d02fe4b91d1bdece8a617d0.tar.gz |
Make SwapChainStateVk::createSwapChainCi returns a value object
... which stores all the data on the stack, so that in a crash dump,
VkSwapchainCreateInfoKHR will be guaranteed to be captured.
Bug: b/222118078
Test: run the emulator
Change-Id: Ib63f1abda5c57894bc3edc238f0d3f870b1eb47b
Diffstat (limited to 'stream-servers/SwapChainStateVk.h')
-rw-r--r-- | stream-servers/SwapChainStateVk.h | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/stream-servers/SwapChainStateVk.h b/stream-servers/SwapChainStateVk.h index ee50c07c..71066d75 100644 --- a/stream-servers/SwapChainStateVk.h +++ b/stream-servers/SwapChainStateVk.h @@ -4,22 +4,41 @@ #include <functional> #include <memory> #include <optional> +#include <type_traits> #include <unordered_set> #include <vector> #include "vulkan/cereal/common/goldfish_vk_dispatch.h" +struct SwapchainCreateInfoWrapper { + VkSwapchainCreateInfoKHR mCreateInfo; + std::vector<uint32_t> mQueueFamilyIndices; + + SwapchainCreateInfoWrapper(const SwapchainCreateInfoWrapper&); + SwapchainCreateInfoWrapper(SwapchainCreateInfoWrapper&&) = delete; + SwapchainCreateInfoWrapper& operator=(const SwapchainCreateInfoWrapper&); + SwapchainCreateInfoWrapper& operator=(SwapchainCreateInfoWrapper&&) = delete; + + SwapchainCreateInfoWrapper(const VkSwapchainCreateInfoKHR&); + + void setQueueFamilyIndices(const std::vector<uint32_t>& queueFamilyIndices); +}; + +// Assert SwapchainCreateInfoWrapper is a copy only class. +static_assert(std::is_copy_assignable_v<SwapchainCreateInfoWrapper> && + std::is_copy_constructible_v<SwapchainCreateInfoWrapper> && + !std::is_move_constructible_v<SwapchainCreateInfoWrapper> && + !std::is_move_assignable_v<SwapchainCreateInfoWrapper>); + class SwapChainStateVk { public: static std::vector<const char *> getRequiredInstanceExtensions(); static std::vector<const char *> getRequiredDeviceExtensions(); static bool validateQueueFamilyProperties(const goldfish_vk::VulkanDispatch &, VkPhysicalDevice, VkSurfaceKHR, uint32_t queueFamilyIndex); - using VkSwapchainCreateInfoKHRPtr = - std::unique_ptr<VkSwapchainCreateInfoKHR, std::function<void(VkSwapchainCreateInfoKHR *)>>; - static VkSwapchainCreateInfoKHRPtr createSwapChainCi( - const goldfish_vk::VulkanDispatch &, VkSurfaceKHR, VkPhysicalDevice, uint32_t width, - uint32_t height, const std::unordered_set<uint32_t> &queueFamilyIndices); + static std::optional<SwapchainCreateInfoWrapper> createSwapChainCi( + const goldfish_vk::VulkanDispatch&, VkSurfaceKHR, VkPhysicalDevice, uint32_t width, + uint32_t height, const std::unordered_set<uint32_t>& queueFamilyIndices); explicit SwapChainStateVk(const goldfish_vk::VulkanDispatch &, VkDevice, const VkSwapchainCreateInfoKHR &); |