[Impeller] Updated TextureSourceVK docs and deleted unused ivars (flutter/engine#45123)
Just some documentation and cleanup while i'm trying to get render pass recycling working. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
@@ -435,7 +435,7 @@ bool SwapchainImplVK::Present(const std::shared_ptr<SwapchainImageVK>& image,
|
||||
barrier.dst_access = {};
|
||||
barrier.dst_stage = vk::PipelineStageFlagBits::eBottomOfPipe;
|
||||
|
||||
if (!image->SetLayout(barrier)) {
|
||||
if (!image->SetLayout(barrier).ok()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@ vk::ImageLayout TextureSourceVK::SetLayoutWithoutEncoding(
|
||||
return old_layout;
|
||||
}
|
||||
|
||||
bool TextureSourceVK::SetLayout(const BarrierVK& barrier) const {
|
||||
fml::Status TextureSourceVK::SetLayout(const BarrierVK& barrier) const {
|
||||
const auto old_layout = SetLayoutWithoutEncoding(barrier.new_layout);
|
||||
if (barrier.new_layout == old_layout) {
|
||||
return true;
|
||||
return {};
|
||||
}
|
||||
|
||||
vk::ImageMemoryBarrier image_barrier;
|
||||
@@ -55,7 +55,7 @@ bool TextureSourceVK::SetLayout(const BarrierVK& barrier) const {
|
||||
image_barrier // image barriers
|
||||
);
|
||||
|
||||
return true;
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/fml/status.h"
|
||||
#include "impeller/base/thread.h"
|
||||
#include "impeller/core/texture_descriptor.h"
|
||||
#include "impeller/renderer/backend/vulkan/barrier_vk.h"
|
||||
@@ -13,6 +14,10 @@
|
||||
|
||||
namespace impeller {
|
||||
|
||||
/// Abstract base class that represents a vkImage and an vkImageView.
|
||||
///
|
||||
/// This is intended to be used with an impeller::TextureVK. Example
|
||||
/// implementations represent swapchain images or uploaded textures.
|
||||
class TextureSourceVK {
|
||||
public:
|
||||
virtual ~TextureSourceVK();
|
||||
@@ -23,10 +28,26 @@ class TextureSourceVK {
|
||||
|
||||
virtual vk::ImageView GetImageView() const = 0;
|
||||
|
||||
bool SetLayout(const BarrierVK& barrier) const;
|
||||
/// Encodes the layout transition `barrier` to `barrier.cmd_buffer` for the
|
||||
/// image.
|
||||
///
|
||||
/// The transition is from the layout stored via `SetLayoutWithoutEncoding` to
|
||||
/// `barrier.new_layout`.
|
||||
fml::Status SetLayout(const BarrierVK& barrier) const;
|
||||
|
||||
/// Store the layout of the image.
|
||||
///
|
||||
/// This just is bookkeeping on the CPU, to actually set the layout use
|
||||
/// `SetLayout`.
|
||||
///
|
||||
/// @param layout The new layout.
|
||||
/// @return The old layout.
|
||||
vk::ImageLayout SetLayoutWithoutEncoding(vk::ImageLayout layout) const;
|
||||
|
||||
/// Get the last layout assigned to the TextureSourceVK.
|
||||
///
|
||||
/// This value is synchronized with the GPU via SetLayout so it may not
|
||||
/// reflect the actual layout.
|
||||
vk::ImageLayout GetLayout() const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -137,7 +137,7 @@ std::shared_ptr<const TextureSourceVK> TextureVK::GetTextureSource() const {
|
||||
}
|
||||
|
||||
bool TextureVK::SetLayout(const BarrierVK& barrier) const {
|
||||
return source_ ? source_->SetLayout(barrier) : false;
|
||||
return source_ ? source_->SetLayout(barrier).ok() : false;
|
||||
}
|
||||
|
||||
vk::ImageLayout TextureVK::SetLayoutWithoutEncoding(
|
||||
|
||||
@@ -40,9 +40,6 @@ class TextureVK final : public Texture, public BackendCast<TextureVK, Texture> {
|
||||
private:
|
||||
std::weak_ptr<Context> context_;
|
||||
std::shared_ptr<TextureSourceVK> source_;
|
||||
mutable RWMutex layout_mutex_;
|
||||
mutable vk::ImageLayout layout_ IPLR_GUARDED_BY(layout_mutex_) =
|
||||
vk::ImageLayout::eUndefined;
|
||||
|
||||
// |Texture|
|
||||
void SetLabel(std::string_view label) override;
|
||||
|
||||
Reference in New Issue
Block a user