mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Impeller] Metal:Reset Encoder viewport and scissor rect in case the command specifies no opinion (flutter/engine#34252)
This commit is contained in:
parent
e021669d32
commit
e794617c3e
@ -429,28 +429,28 @@ bool RenderPassMTL::EncodeCommands(const std::shared_ptr<Allocator>& allocator,
|
||||
: MTLWindingCounterClockwise];
|
||||
[encoder setCullMode:ToMTLCullMode(command.cull_mode)];
|
||||
[encoder setStencilReferenceValue:command.stencil_reference];
|
||||
if (command.viewport.has_value()) {
|
||||
auto v = command.viewport.value();
|
||||
MTLViewport viewport = {
|
||||
.originX = v.rect.origin.x,
|
||||
.originY = v.rect.origin.y,
|
||||
.width = v.rect.size.width,
|
||||
.height = v.rect.size.height,
|
||||
.znear = v.depth_range.z_near,
|
||||
.zfar = v.depth_range.z_far,
|
||||
};
|
||||
[encoder setViewport:viewport];
|
||||
}
|
||||
if (command.scissor.has_value()) {
|
||||
auto s = command.scissor.value();
|
||||
MTLScissorRect scissor = {
|
||||
.x = static_cast<NSUInteger>(s.origin.x),
|
||||
.y = static_cast<NSUInteger>(s.origin.y),
|
||||
.width = static_cast<NSUInteger>(s.size.width),
|
||||
.height = static_cast<NSUInteger>(s.size.height),
|
||||
};
|
||||
[encoder setScissorRect:scissor];
|
||||
}
|
||||
|
||||
auto v = command.viewport.value_or<Viewport>(
|
||||
{.rect = Rect::MakeSize(Size(GetRenderTargetSize()))});
|
||||
MTLViewport viewport = {
|
||||
.originX = v.rect.origin.x,
|
||||
.originY = v.rect.origin.y,
|
||||
.width = v.rect.size.width,
|
||||
.height = v.rect.size.height,
|
||||
.znear = v.depth_range.z_near,
|
||||
.zfar = v.depth_range.z_far,
|
||||
};
|
||||
[encoder setViewport:viewport];
|
||||
|
||||
auto s = command.scissor.value_or(IRect::MakeSize(GetRenderTargetSize()));
|
||||
MTLScissorRect scissor = {
|
||||
.x = static_cast<NSUInteger>(s.origin.x),
|
||||
.y = static_cast<NSUInteger>(s.origin.y),
|
||||
.width = static_cast<NSUInteger>(s.size.width),
|
||||
.height = static_cast<NSUInteger>(s.size.height),
|
||||
};
|
||||
[encoder setScissorRect:scissor];
|
||||
|
||||
if (!bind_stage_resources(command.vertex_bindings, ShaderStage::kVertex)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user