Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[Impeller] Updated TextureSourceVK docs and deleted unused ivars #45123

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion impeller/renderer/backend/vulkan/swapchain_impl_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions impeller/renderer/backend/vulkan/texture_source_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -55,7 +55,7 @@ bool TextureSourceVK::SetLayout(const BarrierVK& barrier) const {
image_barrier // image barriers
);

return true;
return {};
}

} // namespace impeller
23 changes: 22 additions & 1 deletion impeller/renderer/backend/vulkan/texture_source_vk.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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();
Expand All @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had forgotten about fml::Status!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, this one was tricky since does "true" mean a transition happened or does "true" mean no error happened. I figured it's cleaner to just use the proper type. I wish we used it more often.


/// 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:
Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/backend/vulkan/texture_vk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 0 additions & 3 deletions impeller/renderer/backend/vulkan/texture_vk.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Comment on lines -43 to -45
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are unused.


// |Texture|
void SetLabel(std::string_view label) override;
Expand Down