C++用参数返回结果与用返回值返回结果的思考
/*** *xvkBuffer作为参数比写为返回值的好处是: *1,xvkBuffer可以是堆变量或栈变量,若写为返回值则只能是堆上申请,因为必须保证它的永久性 *2,xvkBuffer或作为栈变量返回显然是不行的,因为它不持久 */ void XVulkan::CreateBuffer(VkBufferUsageFlagBits usage, UINT size, OUT XVkBuffer& xvkBuffer) { VkBufferCreateInfo info = {}; info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; info.usage = usage; info.size = size; info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; auto ret = vkCreateBuffer(vkDevice, &info, NULL, &xvkBuffer.info.buffer); CheckResult(ret); }