@@ -429,28 +429,28 @@ static bool Bind(PassBindingsCache& pass,
429
429
: MTLWindingCounterClockwise ];
430
430
[encoder setCullMode: ToMTLCullMode (command.cull_mode)];
431
431
[encoder setStencilReferenceValue: command.stencil_reference];
432
- if (command. viewport . has_value ()) {
433
- auto v = command.viewport .value ();
434
- MTLViewport viewport = {
435
- . originX = v. rect . origin . x ,
436
- . originY = v.rect .origin .y ,
437
- . width = v.rect .size . width ,
438
- . height = v.rect .size .height ,
439
- . znear = v.depth_range . z_near ,
440
- . zfar = v.depth_range .z_far ,
441
- };
442
- [encoder setViewport: viewport] ;
443
- }
444
- if (command. scissor . has_value ()) {
445
- auto s = command.scissor .value ( );
446
- MTLScissorRect scissor = {
447
- .x = static_cast <NSUInteger >(s.origin .x ),
448
- .y = static_cast <NSUInteger >(s.origin .y ),
449
- .width = static_cast <NSUInteger >(s.size .width ),
450
- .height = static_cast <NSUInteger >(s.size .height ),
451
- };
452
- [encoder setScissorRect: scissor];
453
- }
432
+
433
+ auto v = command.viewport .value_or <Viewport>(
434
+ {. rect = Rect::MakeSize ( Size ( GetRenderTargetSize ()))});
435
+ MTLViewport viewport = {
436
+ . originX = v.rect .origin .x ,
437
+ . originY = v.rect .origin . y ,
438
+ . width = v.rect .size .width ,
439
+ . height = v.rect . size . height ,
440
+ . znear = v.depth_range .z_near ,
441
+ . zfar = v. depth_range . z_far ,
442
+ } ;
443
+ [encoder setViewport: viewport];
444
+
445
+ auto s = command.scissor .value_or ( IRect::MakeSize ( GetRenderTargetSize ()) );
446
+ MTLScissorRect scissor = {
447
+ .x = static_cast <NSUInteger >(s.origin .x ),
448
+ .y = static_cast <NSUInteger >(s.origin .y ),
449
+ .width = static_cast <NSUInteger >(s.size .width ),
450
+ .height = static_cast <NSUInteger >(s.size .height ),
451
+ };
452
+ [encoder setScissorRect: scissor];
453
+
454
454
if (!bind_stage_resources (command.vertex_bindings , ShaderStage::kVertex )) {
455
455
return false ;
456
456
}
0 commit comments