예제 #1
0
        /// <summary>
        /// Updates host scissor test state based on current GPU state.
        /// </summary>
        private void UpdateScissorState()
        {
            for (int index = 0; index < Constants.TotalViewports; index++)
            {
                ScissorState scissor = _state.State.ScissorState[index];

                bool enable = scissor.Enable && (scissor.X1 != 0 || scissor.Y1 != 0 || scissor.X2 != 0xffff || scissor.Y2 != 0xffff);

                if (enable)
                {
                    int x      = scissor.X1;
                    int y      = scissor.Y1;
                    int width  = scissor.X2 - x;
                    int height = scissor.Y2 - y;

                    float scale = _channel.TextureManager.RenderTargetScale;
                    if (scale != 1f)
                    {
                        x      = (int)(x * scale);
                        y      = (int)(y * scale);
                        width  = (int)Math.Ceiling(width * scale);
                        height = (int)Math.Ceiling(height * scale);
                    }

                    _context.Renderer.Pipeline.SetScissor(index, true, x, y, width, height);
                }
                else
                {
                    _context.Renderer.Pipeline.SetScissor(index, false, 0, 0, 0, 0);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Updates host scissor test state based on current GPU state.
        /// </summary>
        private void UpdateScissorState()
        {
            const int MinX = 0;
            const int MinY = 0;
            const int MaxW = 0xffff;
            const int MaxH = 0xffff;

            Span <Rectangle <int> > regions = stackalloc Rectangle <int> [Constants.TotalViewports];

            for (int index = 0; index < Constants.TotalViewports; index++)
            {
                ScissorState scissor = _state.State.ScissorState[index];

                bool enable = scissor.Enable && (scissor.X1 != MinX ||
                                                 scissor.Y1 != MinY ||
                                                 scissor.X2 != MaxW ||
                                                 scissor.Y2 != MaxH);

                if (enable)
                {
                    int x      = scissor.X1;
                    int y      = scissor.Y1;
                    int width  = scissor.X2 - x;
                    int height = scissor.Y2 - y;

                    float scale = _channel.TextureManager.RenderTargetScale;
                    if (scale != 1f)
                    {
                        x      = (int)(x * scale);
                        y      = (int)(y * scale);
                        width  = (int)Math.Ceiling(width * scale);
                        height = (int)Math.Ceiling(height * scale);
                    }

                    regions[index] = new Rectangle <int>(x, y, width, height);
                }
                else
                {
                    regions[index] = new Rectangle <int>(MinX, MinY, MaxW, MaxH);
                }
            }

            _context.Renderer.Pipeline.SetScissors(regions);
        }
예제 #3
0
        /// <summary>
        /// Updates host scissor test state based on current GPU state.
        /// </summary>
        public void UpdateScissorState()
        {
            for (int index = 0; index < Constants.TotalViewports; index++)
            {
                ScissorState scissor = _state.State.ScissorState[index];

                bool enable = scissor.Enable && (scissor.X1 != 0 || scissor.Y1 != 0 || scissor.X2 != 0xffff || scissor.Y2 != 0xffff);

                if (enable)
                {
                    int x      = scissor.X1;
                    int y      = scissor.Y1;
                    int width  = scissor.X2 - x;
                    int height = scissor.Y2 - y;

                    if (_state.State.YControl.HasFlag(YControl.NegateY))
                    {
                        ref var screenScissor = ref _state.State.ScreenScissorState;
                        y = screenScissor.Height - height - y;

                        if (y < 0)
                        {
                            height += y;
                            y       = 0;
                        }
                    }

                    float scale = _channel.TextureManager.RenderTargetScale;
                    if (scale != 1f)
                    {
                        x      = (int)(x * scale);
                        y      = (int)(y * scale);
                        width  = (int)Math.Ceiling(width * scale);
                        height = (int)Math.Ceiling(height * scale);
                    }

                    _context.Renderer.Pipeline.SetScissor(index, true, x, y, width, height);
                }