Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from 1 commit
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
17 changes: 17 additions & 0 deletions impeller/renderer/backend/metal/render_pass_mtl.mm
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,16 @@ static bool Bind(PassBindingsCache& pass,
.zfar = v.depth_range.z_far,
};
[encoder setViewport:viewport];
} else {
MTLViewport viewport = {
Copy link
Member

Choose a reason for hiding this comment

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

Minor nit: You can dry this up a bit. Instead of checking if the viewport has value, then getting its value and then converting to MTLViewport in two places, you could use value_or when getting the viewport. Then you won't need branch here and the code will be more concise.

Something like:

auto v = command.viewport.value_or({GetRenderTargetSize...});
// The old code remains as is

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

.originX = 0.0,
.originY = 0.0,
.width = static_cast<double>(GetRenderTargetSize().width),
.height = static_cast<double>(GetRenderTargetSize().height),
.znear = 0.0,
.zfar = 1.0,
};
[encoder setViewport:viewport];
}
if (command.scissor.has_value()) {
auto s = command.scissor.value();
Expand All @@ -450,6 +460,13 @@ static bool Bind(PassBindingsCache& pass,
.height = static_cast<NSUInteger>(s.size.height),
};
[encoder setScissorRect:scissor];
} else {
MTLScissorRect scissor = {
.x = 0,
.y = 0,
.width = static_cast<NSUInteger>(GetRenderTargetSize().width),
.height = static_cast<NSUInteger>(GetRenderTargetSize().height)};
[encoder setScissorRect:scissor];
}
if (!bind_stage_resources(command.vertex_bindings, ShaderStage::kVertex)) {
return false;
Expand Down