Shorten names of the render target attachment descriptors.
This commit is contained in:
@@ -140,14 +140,14 @@ bool Playground::OpenPlaygroundHere(Renderer::RenderCallback render_callback) {
|
||||
static_cast<ISize::Type>(current_drawable.texture.width),
|
||||
static_cast<ISize::Type>(current_drawable.texture.height)};
|
||||
|
||||
RenderPassColorAttachment color0;
|
||||
ColorAttachment color0;
|
||||
color0.texture =
|
||||
std::make_shared<TextureMTL>(color0_desc, current_drawable.texture);
|
||||
color0.clear_color = Color::SkyBlue();
|
||||
color0.load_action = LoadAction::kClear;
|
||||
color0.store_action = StoreAction::kStore;
|
||||
|
||||
RenderPassDescriptor desc;
|
||||
RenderTarget desc;
|
||||
desc.SetColorAttachment(color0, 0u);
|
||||
|
||||
Surface surface(desc);
|
||||
|
||||
@@ -34,7 +34,7 @@ class CommandBufferMTL final : public CommandBuffer {
|
||||
|
||||
// |CommandBuffer|
|
||||
std::shared_ptr<RenderPass> CreateRenderPass(
|
||||
const RenderPassDescriptor& desc) const override;
|
||||
const RenderTarget& desc) const override;
|
||||
|
||||
FML_DISALLOW_COPY_AND_ASSIGN(CommandBufferMTL);
|
||||
};
|
||||
|
||||
@@ -53,7 +53,7 @@ void CommandBufferMTL::SubmitCommands(CompletionCallback callback) {
|
||||
}
|
||||
|
||||
std::shared_ptr<RenderPass> CommandBufferMTL::CreateRenderPass(
|
||||
const RenderPassDescriptor& desc) const {
|
||||
const RenderTarget& desc) const {
|
||||
if (!buffer_) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class RenderPassDescriptor;
|
||||
class RenderTarget;
|
||||
|
||||
constexpr MTLPixelFormat ToMTLPixelFormat(PixelFormat format) {
|
||||
switch (format) {
|
||||
|
||||
@@ -27,7 +27,7 @@ class RenderPassMTL final : public RenderPass {
|
||||
std::string label_;
|
||||
bool is_valid_ = false;
|
||||
|
||||
RenderPassMTL(id<MTLCommandBuffer> buffer, const RenderPassDescriptor& desc);
|
||||
RenderPassMTL(id<MTLCommandBuffer> buffer, const RenderTarget& desc);
|
||||
|
||||
// |RenderPass|
|
||||
bool IsValid() const override;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
namespace impeller {
|
||||
|
||||
static bool ConfigureAttachment(const RenderPassAttachment& desc,
|
||||
static bool ConfigureAttachment(const Attachment& desc,
|
||||
MTLRenderPassAttachmentDescriptor* attachment) {
|
||||
if (!desc.texture) {
|
||||
return false;
|
||||
@@ -30,7 +30,7 @@ static bool ConfigureAttachment(const RenderPassAttachment& desc,
|
||||
}
|
||||
|
||||
static bool ConfigureColorAttachment(
|
||||
const RenderPassColorAttachment& desc,
|
||||
const ColorAttachment& desc,
|
||||
MTLRenderPassColorAttachmentDescriptor* attachment) {
|
||||
if (!ConfigureAttachment(desc, attachment)) {
|
||||
return false;
|
||||
@@ -40,7 +40,7 @@ static bool ConfigureColorAttachment(
|
||||
}
|
||||
|
||||
static bool ConfigureDepthAttachment(
|
||||
const RenderPassDepthAttachment& desc,
|
||||
const DepthAttachment& desc,
|
||||
MTLRenderPassDepthAttachmentDescriptor* attachment) {
|
||||
if (!ConfigureAttachment(desc, attachment)) {
|
||||
return false;
|
||||
@@ -50,7 +50,7 @@ static bool ConfigureDepthAttachment(
|
||||
}
|
||||
|
||||
static bool ConfigureStencilAttachment(
|
||||
const RenderPassStencilAttachment& desc,
|
||||
const StencilAttachment& desc,
|
||||
MTLRenderPassStencilAttachmentDescriptor* attachment) {
|
||||
if (!ConfigureAttachment(desc, attachment)) {
|
||||
return false;
|
||||
@@ -61,7 +61,7 @@ static bool ConfigureStencilAttachment(
|
||||
|
||||
// TODO(csg): Move this to formats_mtl.h
|
||||
static MTLRenderPassDescriptor* ToMTLRenderPassDescriptor(
|
||||
const RenderPassDescriptor& desc) {
|
||||
const RenderTarget& desc) {
|
||||
auto result = [MTLRenderPassDescriptor renderPassDescriptor];
|
||||
|
||||
const auto& colors = desc.GetColorAttachments();
|
||||
@@ -93,7 +93,7 @@ static MTLRenderPassDescriptor* ToMTLRenderPassDescriptor(
|
||||
}
|
||||
|
||||
RenderPassMTL::RenderPassMTL(id<MTLCommandBuffer> buffer,
|
||||
const RenderPassDescriptor& desc)
|
||||
const RenderTarget& desc)
|
||||
: buffer_(buffer),
|
||||
desc_(ToMTLRenderPassDescriptor(desc)),
|
||||
transients_buffer_(HostBuffer::Create()) {
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace impeller {
|
||||
|
||||
class Context;
|
||||
class RenderPass;
|
||||
class RenderPassDescriptor;
|
||||
class RenderTarget;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// @brief A collection of encoded commands to be submitted to the GPU for
|
||||
@@ -59,7 +59,7 @@ class CommandBuffer {
|
||||
/// @return A valid render pass or null.
|
||||
///
|
||||
virtual std::shared_ptr<RenderPass> CreateRenderPass(
|
||||
const RenderPassDescriptor& desc) const = 0;
|
||||
const RenderTarget& desc) const = 0;
|
||||
|
||||
protected:
|
||||
CommandBuffer();
|
||||
|
||||
@@ -319,7 +319,7 @@ struct PipelineStencilAttachment {
|
||||
}
|
||||
};
|
||||
|
||||
struct RenderPassAttachment {
|
||||
struct Attachment {
|
||||
std::shared_ptr<Texture> texture = nullptr;
|
||||
LoadAction load_action = LoadAction::kDontCare;
|
||||
StoreAction store_action = StoreAction::kStore;
|
||||
@@ -327,15 +327,15 @@ struct RenderPassAttachment {
|
||||
constexpr operator bool() const { return static_cast<bool>(texture); }
|
||||
};
|
||||
|
||||
struct RenderPassColorAttachment : public RenderPassAttachment {
|
||||
struct ColorAttachment : public Attachment {
|
||||
Color clear_color = Color::BlackTransparent();
|
||||
};
|
||||
|
||||
struct RenderPassDepthAttachment : public RenderPassAttachment {
|
||||
struct DepthAttachment : public Attachment {
|
||||
double clear_depth = 0.0;
|
||||
};
|
||||
|
||||
struct RenderPassStencilAttachment : public RenderPassAttachment {
|
||||
struct StencilAttachment : public Attachment {
|
||||
uint32_t clear_stencil = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -13,6 +13,13 @@ namespace impeller {
|
||||
class HostBuffer;
|
||||
class Allocator;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// @brief Render passes encode render commands directed as one specific
|
||||
/// render target into an underlying command buffer.
|
||||
///
|
||||
/// Render passes can be obtained from the command buffer in which
|
||||
/// the pass is meant to encode commands into.
|
||||
///
|
||||
class RenderPass {
|
||||
public:
|
||||
virtual ~RenderPass();
|
||||
|
||||
@@ -8,19 +8,18 @@
|
||||
|
||||
namespace impeller {
|
||||
|
||||
RenderPassDescriptor::RenderPassDescriptor() = default;
|
||||
RenderTarget::RenderTarget() = default;
|
||||
|
||||
RenderPassDescriptor::~RenderPassDescriptor() = default;
|
||||
RenderTarget::~RenderTarget() = default;
|
||||
|
||||
bool RenderPassDescriptor::HasColorAttachment(size_t index) const {
|
||||
bool RenderTarget::HasColorAttachment(size_t index) const {
|
||||
if (auto found = colors_.find(index); found != colors_.end()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::optional<ISize> RenderPassDescriptor::GetColorAttachmentSize(
|
||||
size_t index) const {
|
||||
std::optional<ISize> RenderTarget::GetColorAttachmentSize(size_t index) const {
|
||||
auto found = colors_.find(index);
|
||||
|
||||
if (found == colors_.end()) {
|
||||
@@ -30,43 +29,39 @@ std::optional<ISize> RenderPassDescriptor::GetColorAttachmentSize(
|
||||
return found->second.texture->GetSize();
|
||||
}
|
||||
|
||||
RenderPassDescriptor& RenderPassDescriptor::SetColorAttachment(
|
||||
RenderPassColorAttachment attachment,
|
||||
size_t index) {
|
||||
RenderTarget& RenderTarget::SetColorAttachment(ColorAttachment attachment,
|
||||
size_t index) {
|
||||
if (attachment) {
|
||||
colors_[index] = attachment;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
RenderPassDescriptor& RenderPassDescriptor::SetDepthAttachment(
|
||||
RenderPassDepthAttachment attachment) {
|
||||
RenderTarget& RenderTarget::SetDepthAttachment(DepthAttachment attachment) {
|
||||
if (attachment) {
|
||||
depth_ = std::move(attachment);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
RenderPassDescriptor& RenderPassDescriptor::SetStencilAttachment(
|
||||
RenderPassStencilAttachment attachment) {
|
||||
RenderTarget& RenderTarget::SetStencilAttachment(StencilAttachment attachment) {
|
||||
if (attachment) {
|
||||
stencil_ = std::move(attachment);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
const std::map<size_t, RenderPassColorAttachment>&
|
||||
RenderPassDescriptor::GetColorAttachments() const {
|
||||
const std::map<size_t, ColorAttachment>& RenderTarget::GetColorAttachments()
|
||||
const {
|
||||
return colors_;
|
||||
}
|
||||
|
||||
const std::optional<RenderPassDepthAttachment>&
|
||||
RenderPassDescriptor::GetDepthAttachment() const {
|
||||
const std::optional<DepthAttachment>& RenderTarget::GetDepthAttachment() const {
|
||||
return depth_;
|
||||
}
|
||||
|
||||
const std::optional<RenderPassStencilAttachment>&
|
||||
RenderPassDescriptor::GetStencilAttachment() const {
|
||||
const std::optional<StencilAttachment>& RenderTarget::GetStencilAttachment()
|
||||
const {
|
||||
return stencil_;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,37 +13,32 @@
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class RenderPassDescriptor {
|
||||
class RenderTarget {
|
||||
public:
|
||||
RenderPassDescriptor();
|
||||
RenderTarget();
|
||||
|
||||
~RenderPassDescriptor();
|
||||
~RenderTarget();
|
||||
|
||||
bool HasColorAttachment(size_t index) const;
|
||||
|
||||
std::optional<ISize> GetColorAttachmentSize(size_t index) const;
|
||||
|
||||
RenderPassDescriptor& SetColorAttachment(RenderPassColorAttachment attachment,
|
||||
size_t index);
|
||||
RenderTarget& SetColorAttachment(ColorAttachment attachment, size_t index);
|
||||
|
||||
RenderPassDescriptor& SetDepthAttachment(
|
||||
RenderPassDepthAttachment attachment);
|
||||
RenderTarget& SetDepthAttachment(DepthAttachment attachment);
|
||||
|
||||
RenderPassDescriptor& SetStencilAttachment(
|
||||
RenderPassStencilAttachment attachment);
|
||||
RenderTarget& SetStencilAttachment(StencilAttachment attachment);
|
||||
|
||||
const std::map<size_t, RenderPassColorAttachment>& GetColorAttachments()
|
||||
const;
|
||||
const std::map<size_t, ColorAttachment>& GetColorAttachments() const;
|
||||
|
||||
const std::optional<RenderPassDepthAttachment>& GetDepthAttachment() const;
|
||||
const std::optional<DepthAttachment>& GetDepthAttachment() const;
|
||||
|
||||
const std::optional<RenderPassStencilAttachment>& GetStencilAttachment()
|
||||
const;
|
||||
const std::optional<StencilAttachment>& GetStencilAttachment() const;
|
||||
|
||||
private:
|
||||
std::map<size_t, RenderPassColorAttachment> colors_;
|
||||
std::optional<RenderPassDepthAttachment> depth_;
|
||||
std::optional<RenderPassStencilAttachment> stencil_;
|
||||
std::map<size_t, ColorAttachment> colors_;
|
||||
std::optional<DepthAttachment> depth_;
|
||||
std::optional<StencilAttachment> stencil_;
|
||||
};
|
||||
|
||||
} // namespace impeller
|
||||
|
||||
@@ -198,7 +198,7 @@ TEST_F(RendererTest, CanRenderToTexture) {
|
||||
std::shared_ptr<RenderPass> r2t_pass;
|
||||
|
||||
{
|
||||
RenderPassColorAttachment color0;
|
||||
ColorAttachment color0;
|
||||
color0.load_action = LoadAction::kClear;
|
||||
color0.store_action = StoreAction::kStore;
|
||||
|
||||
@@ -218,7 +218,7 @@ TEST_F(RendererTest, CanRenderToTexture) {
|
||||
|
||||
color0.texture->SetLabel("r2t_target");
|
||||
|
||||
RenderPassDescriptor r2t_desc;
|
||||
RenderTarget r2t_desc;
|
||||
r2t_desc.SetColorAttachment(color0, 0u);
|
||||
auto cmd_buffer = context->CreateRenderCommandBuffer();
|
||||
r2t_pass = cmd_buffer->CreateRenderPass(r2t_desc);
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
|
||||
namespace impeller {
|
||||
|
||||
Surface::Surface(RenderPassDescriptor target_desc)
|
||||
: desc_(std::move(target_desc)) {
|
||||
Surface::Surface(RenderTarget target_desc) : desc_(std::move(target_desc)) {
|
||||
if (auto size = desc_.GetColorAttachmentSize(0u); size.has_value()) {
|
||||
size_ = size.value();
|
||||
} else {
|
||||
@@ -29,7 +28,7 @@ bool Surface::IsValid() const {
|
||||
return is_valid_;
|
||||
}
|
||||
|
||||
const RenderPassDescriptor& Surface::GetTargetRenderPassDescriptor() const {
|
||||
const RenderTarget& Surface::GetTargetRenderPassDescriptor() const {
|
||||
return desc_;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace impeller {
|
||||
|
||||
class Surface {
|
||||
public:
|
||||
Surface(RenderPassDescriptor target_desc);
|
||||
Surface(RenderTarget target_desc);
|
||||
|
||||
~Surface();
|
||||
|
||||
@@ -24,10 +24,10 @@ class Surface {
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
const RenderPassDescriptor& GetTargetRenderPassDescriptor() const;
|
||||
const RenderTarget& GetTargetRenderPassDescriptor() const;
|
||||
|
||||
private:
|
||||
RenderPassDescriptor desc_;
|
||||
RenderTarget desc_;
|
||||
ISize size_;
|
||||
|
||||
bool is_valid_ = false;
|
||||
|
||||
Reference in New Issue
Block a user