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