Commit 60641abc by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Make ImageViewHelper a Resource

Bug: angleproject:3573 Change-Id: I12e70418b3b971e802bc911409e170cbf8c61915 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2542223Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent b10a0dfc
...@@ -185,7 +185,7 @@ class Resource : angle::NonCopyable ...@@ -185,7 +185,7 @@ class Resource : angle::NonCopyable
angle::Result waitForIdle(ContextVk *contextVk, const char *debugMessage); angle::Result waitForIdle(ContextVk *contextVk, const char *debugMessage);
// Adds the resource to a resource use list. // Adds the resource to a resource use list.
void retain(ResourceUseList *resourceUseList); void retain(ResourceUseList *resourceUseList) const;
protected: protected:
Resource(); Resource();
...@@ -195,7 +195,7 @@ class Resource : angle::NonCopyable ...@@ -195,7 +195,7 @@ class Resource : angle::NonCopyable
SharedResourceUse mUse; SharedResourceUse mUse;
}; };
ANGLE_INLINE void Resource::retain(ResourceUseList *resourceUseList) ANGLE_INLINE void Resource::retain(ResourceUseList *resourceUseList) const
{ {
// Store reference in resource list. // Store reference in resource list.
resourceUseList->add(mUse); resourceUseList->add(mUse);
......
...@@ -6146,13 +6146,14 @@ FramebufferHelper::FramebufferHelper() = default; ...@@ -6146,13 +6146,14 @@ FramebufferHelper::FramebufferHelper() = default;
FramebufferHelper::~FramebufferHelper() = default; FramebufferHelper::~FramebufferHelper() = default;
FramebufferHelper::FramebufferHelper(FramebufferHelper &&other) FramebufferHelper::FramebufferHelper(FramebufferHelper &&other) : Resource(std::move(other))
{ {
mFramebuffer = std::move(other.mFramebuffer); mFramebuffer = std::move(other.mFramebuffer);
} }
FramebufferHelper &FramebufferHelper::operator=(FramebufferHelper &&other) FramebufferHelper &FramebufferHelper::operator=(FramebufferHelper &&other)
{ {
std::swap(mUse, other.mUse);
std::swap(mFramebuffer, other.mFramebuffer); std::swap(mFramebuffer, other.mFramebuffer);
return *this; return *this;
} }
...@@ -6170,12 +6171,9 @@ void FramebufferHelper::release(ContextVk *contextVk) ...@@ -6170,12 +6171,9 @@ void FramebufferHelper::release(ContextVk *contextVk)
} }
// ImageViewHelper implementation. // ImageViewHelper implementation.
ImageViewHelper::ImageViewHelper() : mCurrentMaxLevel(0), mLinearColorspace(true) ImageViewHelper::ImageViewHelper() : mCurrentMaxLevel(0), mLinearColorspace(true) {}
{
mUse.init();
}
ImageViewHelper::ImageViewHelper(ImageViewHelper &&other) ImageViewHelper::ImageViewHelper(ImageViewHelper &&other) : Resource(std::move(other))
{ {
std::swap(mCurrentMaxLevel, other.mCurrentMaxLevel); std::swap(mCurrentMaxLevel, other.mCurrentMaxLevel);
std::swap(mPerLevelLinearReadImageViews, other.mPerLevelLinearReadImageViews); std::swap(mPerLevelLinearReadImageViews, other.mPerLevelLinearReadImageViews);
...@@ -6192,10 +6190,7 @@ ImageViewHelper::ImageViewHelper(ImageViewHelper &&other) ...@@ -6192,10 +6190,7 @@ ImageViewHelper::ImageViewHelper(ImageViewHelper &&other)
std::swap(mImageViewSerial, other.mImageViewSerial); std::swap(mImageViewSerial, other.mImageViewSerial);
} }
ImageViewHelper::~ImageViewHelper() ImageViewHelper::~ImageViewHelper() {}
{
mUse.release();
}
void ImageViewHelper::init(RendererVk *renderer) void ImageViewHelper::init(RendererVk *renderer)
{ {
......
...@@ -415,7 +415,7 @@ class DynamicQueryPool final : public DynamicallyGrowingPool<QueryPool> ...@@ -415,7 +415,7 @@ class DynamicQueryPool final : public DynamicallyGrowingPool<QueryPool>
// of a fixed size as needed and allocates indices within those pools. // of a fixed size as needed and allocates indices within those pools.
// //
// The QueryHelper class below keeps the pool and index pair together. // The QueryHelper class below keeps the pool and index pair together.
class QueryHelper final : public vk::Resource class QueryHelper final : public Resource
{ {
public: public:
QueryHelper(); QueryHelper();
...@@ -1894,12 +1894,12 @@ enum class SrgbDecodeMode ...@@ -1894,12 +1894,12 @@ enum class SrgbDecodeMode
SrgbDecode SrgbDecode
}; };
class ImageViewHelper : angle::NonCopyable class ImageViewHelper final : public Resource
{ {
public: public:
ImageViewHelper(); ImageViewHelper();
ImageViewHelper(ImageViewHelper &&other); ImageViewHelper(ImageViewHelper &&other);
~ImageViewHelper(); ~ImageViewHelper() override;
void init(RendererVk *renderer); void init(RendererVk *renderer);
void release(RendererVk *renderer); void release(RendererVk *renderer);
...@@ -1986,9 +1986,6 @@ class ImageViewHelper : angle::NonCopyable ...@@ -1986,9 +1986,6 @@ class ImageViewHelper : angle::NonCopyable
} }
} }
// Store reference to usage in graph.
void retain(ResourceUseList *resourceUseList) const { resourceUseList->add(mUse); }
// For applications that frequently switch a texture's max level, and make no other changes to // For applications that frequently switch a texture's max level, and make no other changes to
// the texture, change the currently-used max level, and potentially create new "read views" // the texture, change the currently-used max level, and potentially create new "read views"
// for the new max-level // for the new max-level
...@@ -2094,9 +2091,6 @@ class ImageViewHelper : angle::NonCopyable ...@@ -2094,9 +2091,6 @@ class ImageViewHelper : angle::NonCopyable
uint32_t layerCount, uint32_t layerCount,
VkImageUsageFlags imageUsageFlags); VkImageUsageFlags imageUsageFlags);
// Lifetime.
SharedResourceUse mUse;
// For applications that frequently switch a texture's max level, and make no other changes to // For applications that frequently switch a texture's max level, and make no other changes to
// the texture, keep track of the currently-used max level, and keep one "read view" per // the texture, keep track of the currently-used max level, and keep one "read view" per
// max-level // max-level
......
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