Commit 25301b60 by Jamie Madill Committed by Commit Bot

Remove WrappedObject::retain.

With resources being mostly deleted by the Renderer along with a serial number, the retain move semantics weren't very useful. Refactoring change only. BUG=angleproject:2200 Change-Id: I7b72b1decfa7604cdd767e7d9b5213b9383eb240 Reviewed-on: https://chromium-review.googlesource.com/742369Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 4751aabb
......@@ -58,10 +58,7 @@ gl::Error BufferVk::setData(const gl::Context *context,
createInfo.queueFamilyIndexCount = 0;
createInfo.pQueueFamilyIndices = nullptr;
vk::Buffer newBuffer;
ANGLE_TRY(newBuffer.init(device, createInfo));
mBuffer.retain(device, std::move(newBuffer));
ANGLE_TRY(mBuffer.init(device, createInfo));
ANGLE_TRY(vk::AllocateBufferMemory(contextVk, size, &mBuffer, &mBufferMemory,
&mCurrentRequiredSize));
}
......
......@@ -288,11 +288,7 @@ gl::Error ContextVk::initPipeline(const gl::Context *context)
mCurrentPipelineInfo.layout = pipelineLayout.getHandle();
mCurrentPipelineInfo.renderPass = renderPass->getHandle();
vk::Pipeline newPipeline;
ANGLE_TRY(newPipeline.initGraphics(device, mCurrentPipelineInfo));
// TODO(jmadill): Don't dispose the current pipeline immediately, it could be in use.
mCurrentPipeline.retain(device, std::move(newPipeline));
ANGLE_TRY(mCurrentPipeline.initGraphics(device, mCurrentPipelineInfo));
return gl::NoError();
}
......
......@@ -479,10 +479,7 @@ gl::ErrorOrResult<vk::RenderPass *> FramebufferVk::getRenderPass(const gl::Conte
renderPassInfo.dependencyCount = 0;
renderPassInfo.pDependencies = nullptr;
vk::RenderPass renderPass;
ANGLE_TRY(renderPass.init(device, renderPassInfo));
mRenderPass.retain(device, std::move(renderPass));
ANGLE_TRY(mRenderPass.init(device, renderPassInfo));
return &mRenderPass;
}
......@@ -549,10 +546,7 @@ gl::ErrorOrResult<vk::Framebuffer *> FramebufferVk::getFramebuffer(const gl::Con
framebufferInfo.height = static_cast<uint32_t>(attachmentsSize.height);
framebufferInfo.layers = 1;
vk::Framebuffer framebuffer;
ANGLE_TRY(framebuffer.init(device, framebufferInfo));
mFramebuffer.retain(device, std::move(framebuffer));
ANGLE_TRY(mFramebuffer.init(device, framebufferInfo));
return &mFramebuffer;
}
......
......@@ -390,19 +390,16 @@ vk::Error WindowSurfaceVk::initializeImpl(RendererVk *renderer)
imageViewInfo.subresourceRange.baseArrayLayer = 0;
imageViewInfo.subresourceRange.layerCount = 1;
vk::Image image(swapchainImage);
vk::ImageView imageView;
ANGLE_TRY(imageView.init(device, imageViewInfo));
auto &member = mSwapchainImages[imageIndex];
// Set transfer dest layout, and clear the image to black.
image.changeLayoutTop(VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
commandBuffer);
commandBuffer->clearSingleColorImage(image, transparentBlack);
member.image.setHandle(swapchainImage);
ANGLE_TRY(member.imageView.init(device, imageViewInfo));
auto &member = mSwapchainImages[imageIndex];
// Set transfer dest layout, and clear the image to black.
member.image.changeLayoutTop(VK_IMAGE_ASPECT_COLOR_BIT,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, commandBuffer);
commandBuffer->clearSingleColorImage(member.image, transparentBlack);
member.image.retain(device, std::move(image));
member.imageView.retain(device, std::move(imageView));
ANGLE_TRY(member.imageAcquiredSemaphore.init(device));
ANGLE_TRY(member.commandsCompleteSemaphore.init(device));
}
......@@ -578,11 +575,7 @@ gl::ErrorOrResult<vk::Framebuffer *> WindowSurfaceVk::getCurrentFramebuffer(
for (auto &swapchainImage : mSwapchainImages)
{
framebufferInfo.pAttachments = swapchainImage.imageView.ptr();
vk::Framebuffer framebuffer;
ANGLE_TRY(framebuffer.init(device, framebufferInfo));
swapchainImage.framebuffer.retain(device, std::move(framebuffer));
ANGLE_TRY(swapchainImage.framebuffer.init(device, framebufferInfo));
}
ASSERT(currentFramebuffer.valid());
......
......@@ -488,14 +488,9 @@ Image::Image() : mCurrentLayout(VK_IMAGE_LAYOUT_UNDEFINED)
{
}
Image::Image(VkImage image) : WrappedObject(image), mCurrentLayout(VK_IMAGE_LAYOUT_UNDEFINED)
void Image::setHandle(VkImage handle)
{
}
void Image::retain(VkDevice device, Image &&other)
{
WrappedObject::retain(device, std::move(other));
std::swap(mCurrentLayout, other.mCurrentLayout);
mHandle = handle;
}
void Image::reset()
......@@ -746,13 +741,6 @@ void StagingImage::destroy(VkDevice device)
mDeviceMemory.destroy(device);
}
void StagingImage::retain(VkDevice device, StagingImage &&other)
{
mImage.retain(device, std::move(other.mImage));
mDeviceMemory.retain(device, std::move(other.mDeviceMemory));
std::swap(mSize, other.mSize);
}
Error StagingImage::init(VkDevice device,
uint32_t queueFamilyIndex,
const vk::MemoryProperties &memoryProperties,
......
......@@ -225,7 +225,6 @@ class WrappedObject : angle::NonCopyable
protected:
WrappedObject() : mHandle(VK_NULL_HANDLE) {}
WrappedObject(HandleT handle) : mHandle(handle) {}
~WrappedObject() { ASSERT(!valid()); }
WrappedObject(WrappedObject &&other) : mHandle(other.mHandle)
......@@ -241,15 +240,6 @@ class WrappedObject : angle::NonCopyable
return *this;
}
void retain(VkDevice device, DerivedT &&other)
{
if (valid())
{
static_cast<DerivedT *>(this)->destroy(device);
}
std::swap(mHandle, other.mHandle);
}
HandleT mHandle;
};
......@@ -335,9 +325,10 @@ class CommandBuffer final : public WrappedObject<CommandBuffer, VkCommandBuffer>
class Image final : public WrappedObject<Image, VkImage>
{
public:
// Use this constructor if the lifetime of the image is not controlled by ANGLE. (SwapChain)
Image();
explicit Image(VkImage image);
// Use this method if the lifetime of the image is not controlled by ANGLE. (SwapChain)
void setHandle(VkImage handle);
// Called on shutdown when the helper class *doesn't* own the handle to the image resource.
void reset();
......@@ -345,8 +336,6 @@ class Image final : public WrappedObject<Image, VkImage>
// Called on shutdown when the helper class *does* own the handle to the image resource.
void destroy(VkDevice device);
void retain(VkDevice device, Image &&other);
Error init(VkDevice device, const VkImageCreateInfo &createInfo);
void changeLayoutTop(VkImageAspectFlags aspectMask,
......@@ -374,7 +363,6 @@ class ImageView final : public WrappedObject<ImageView, VkImageView>
public:
ImageView();
void destroy(VkDevice device);
using WrappedObject::retain;
Error init(VkDevice device, const VkImageViewCreateInfo &createInfo);
};
......@@ -384,7 +372,6 @@ class Semaphore final : public WrappedObject<Semaphore, VkSemaphore>
public:
Semaphore();
void destroy(VkDevice device);
using WrappedObject::retain;
Error init(VkDevice device);
};
......@@ -394,7 +381,6 @@ class Framebuffer final : public WrappedObject<Framebuffer, VkFramebuffer>
public:
Framebuffer();
void destroy(VkDevice device);
using WrappedObject::retain;
Error init(VkDevice device, const VkFramebufferCreateInfo &createInfo);
};
......@@ -404,7 +390,6 @@ class DeviceMemory final : public WrappedObject<DeviceMemory, VkDeviceMemory>
public:
DeviceMemory();
void destroy(VkDevice device);
using WrappedObject::retain;
Error allocate(VkDevice device, const VkMemoryAllocateInfo &allocInfo);
Error map(VkDevice device,
......@@ -420,7 +405,6 @@ class RenderPass final : public WrappedObject<RenderPass, VkRenderPass>
public:
RenderPass();
void destroy(VkDevice device);
using WrappedObject::retain;
Error init(VkDevice device, const VkRenderPassCreateInfo &createInfo);
};
......@@ -438,7 +422,6 @@ class StagingImage final : angle::NonCopyable
StagingImage();
StagingImage(StagingImage &&other);
void destroy(VkDevice device);
void retain(VkDevice device, StagingImage &&other);
vk::Error init(VkDevice device,
uint32_t queueFamilyIndex,
......@@ -467,7 +450,6 @@ class Buffer final : public WrappedObject<Buffer, VkBuffer>
public:
Buffer();
void destroy(VkDevice device);
using WrappedObject::retain;
Error init(VkDevice device, const VkBufferCreateInfo &createInfo);
Error bindMemory(VkDevice device, const DeviceMemory &deviceMemory);
......@@ -478,7 +460,6 @@ class ShaderModule final : public WrappedObject<ShaderModule, VkShaderModule>
public:
ShaderModule();
void destroy(VkDevice device);
using WrappedObject::retain;
Error init(VkDevice device, const VkShaderModuleCreateInfo &createInfo);
};
......@@ -488,7 +469,6 @@ class Pipeline final : public WrappedObject<Pipeline, VkPipeline>
public:
Pipeline();
void destroy(VkDevice device);
using WrappedObject::retain;
Error initGraphics(VkDevice device, const VkGraphicsPipelineCreateInfo &createInfo);
};
......@@ -498,7 +478,6 @@ class PipelineLayout final : public WrappedObject<PipelineLayout, VkPipelineLayo
public:
PipelineLayout();
void destroy(VkDevice device);
using WrappedObject::retain;
Error init(VkDevice device, const VkPipelineLayoutCreateInfo &createInfo);
};
......@@ -508,7 +487,6 @@ class DescriptorSetLayout final : public WrappedObject<DescriptorSetLayout, VkDe
public:
DescriptorSetLayout();
void destroy(VkDevice device);
using WrappedObject::retain;
Error init(VkDevice device, const VkDescriptorSetLayoutCreateInfo &createInfo);
};
......@@ -518,7 +496,6 @@ class DescriptorPool final : public WrappedObject<DescriptorPool, VkDescriptorPo
public:
DescriptorPool();
void destroy(VkDevice device);
using WrappedObject::retain;
Error init(VkDevice device, const VkDescriptorPoolCreateInfo &createInfo);
......@@ -540,7 +517,6 @@ class Fence final : public WrappedObject<Fence, VkFence>
public:
Fence();
void destroy(VkDevice fence);
using WrappedObject::retain;
using WrappedObject::operator=;
Error init(VkDevice device, const VkFenceCreateInfo &createInfo);
......
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