void PopulateViewports(MgPipelineViewportStateCreateInfo viewportState) { if (viewportState != null) { Viewports = new GLCmdViewportParameter(0, viewportState.Viewports); Scissors = new GLCmdScissorParameter(0, viewportState.Scissors); } else { // Should be 0,0 (width, height) Viewports = new GLCmdViewportParameter(0, new MgViewport [] { //new MgViewport{ X = 0, Y = 0, Width = 0, Height = 0 } } ); // Scissors = new GLCmdScissorParameter(0, new MgRect2D [] { // new MgRect2D // { // Offset = new MgOffset2D{ X = 0, Y = 0}, // Extent = new MgExtent2D{Width = 0, Height = 0 }, // } } ); } }
void InitializeViewportAndScissor(MgPipelineViewportStateCreateInfo viewportState) { // if dynamic state has not been supplied, then default viewport is mandatory bool isViewportUserSupplied = (DynamicStates & AmtGraphicsPipelineDynamicStateFlagBits.VIEWPORT) == AmtGraphicsPipelineDynamicStateFlagBits.VIEWPORT; if (viewportState == null || viewportState.Viewports == null) { if (!isViewportUserSupplied) { throw new InvalidOperationException(nameof(viewportState.Viewports) + " must be supplied."); } } else { var vp = viewportState.Viewports[0]; Viewport = new MTLViewport { Height = vp.Height, Width = vp.Width, OriginX = vp.X, OriginY = vp.Y, // HOPE THIS IS RIGHT ZNear = vp.MinDepth, ZFar = vp.MaxDepth, }; } bool isScissorUserSupplied = (DynamicStates & AmtGraphicsPipelineDynamicStateFlagBits.SCISSOR) == AmtGraphicsPipelineDynamicStateFlagBits.SCISSOR; // if dynamic state has not been supplied, then default viewport is mandatory if (viewportState == null || viewportState.Scissors == null) { if (!isScissorUserSupplied) { throw new InvalidOperationException(nameof(viewportState.Scissors) + " must be supplied."); } } else { var scissor = viewportState.Scissors[0]; ScissorRect = new MTLScissorRect { X = (nuint)scissor.Offset.X, Y = (nuint)scissor.Offset.Y, Width = (nuint)scissor.Extent.Width, Height = (nuint)scissor.Extent.Height }; } }