Example #1
0
        public override void SetInputFormat(string channel, SurfaceState state)
        {
            //calculate integer scaling factors
            XIS = OutputSize.Width / state.SurfaceFormat.Size.Width;
            YIS = OutputSize.Height / state.SurfaceFormat.Size.Height;

            OutputSize = state.SurfaceFormat.Size;

            if (XIS <= 1 && YIS <= 1)
            {
                IsNOP = true;
            }
            else
            {
                OutputSize.Width *= XIS;
                OutputSize.Height *= YIS;
            }

            var outState = new SurfaceState();
            outState.SurfaceFormat = new SurfaceFormat(OutputSize);
            outState.SurfaceDisposition = SurfaceDisposition.RenderTarget;
            DeclareOutput(outState);
        }
Example #2
0
		public override void SetInputFormat(string channel, SurfaceState state)
		{
			if (RenderCallback == null) return;
			DeclareOutput(state);
		}
Example #3
0
		public override void SetInputFormat(string channel, SurfaceState state)
		{
			DeclareOutput(state);
		}
Example #4
0
		public override void SetInputFormat(string channel, SurfaceState state)
		{
			var OutputSize = state.SurfaceFormat.Size;
			OutputSize.Width *= Scale;
			OutputSize.Height *= Scale;
			var ss = new SurfaceState(new SurfaceFormat(OutputSize), SurfaceDisposition.RenderTarget);
			DeclareOutput(ss, channel);
		}
Example #5
0
		public override void SetInputFormat(string channel, SurfaceState state)
		{
			bool need = false;
			if (state.SurfaceFormat.Size != OutputSize)
				need = true;
			if (FilterOption != eFilterOption.None)
				need = true;
			if (Flip)
				need = true;

			if (!need)
			{
				nop = true;
				ContentSize = state.SurfaceFormat.Size;
				return;
			}

			FindInput().SurfaceDisposition = SurfaceDisposition.Texture;
			DeclareOutput(new SurfaceState(new SurfaceFormat(OutputSize), SurfaceDisposition.RenderTarget));
			InputSize = state.SurfaceFormat.Size;
			if (Config_PadOnly)
			{
				//TODO - redundant fix
				LL = new LetterboxingLogic();
				LL.vx += Padding.Left;
				LL.vy += Padding.Top;
				LL.vw = InputSize.Width;
				LL.vh = InputSize.Height;
				LL.WidthScale = 1;
				LL.HeightScale = 1;
			}
			else
			{
				int ow = OutputSize.Width;
				int oh = OutputSize.Height;
				ow -= Padding.Horizontal;
				oh -= Padding.Vertical;
				LL = new LetterboxingLogic(Config_FixAspectRatio, Config_FixScaleInteger, ow, oh, InputSize.Width, InputSize.Height, TextureSize, VirtualTextureSize);
				LL.vx += Padding.Left;
				LL.vy += Padding.Top;
			}
			ContentSize = new Size(LL.vw,LL.vh);
		}
Example #6
0
        public void Compile(string channel, Size insize, Size outsize, bool finalTarget)
        {
RETRY:

            Program.Clear();

            //prep filters for initialization
            foreach (var f in Filters)
            {
                f.BeginInitialization(this);
                f.Initialize();
            }

            //propagate input size forwards through filter chain to allow a 'flex' filter to determine what its input will be
            Size presize = insize;

            for (int i = 0; i < Filters.Count; i++)
            {
                var filter = Filters[i];
                presize = filter.PresizeInput(channel, presize);
            }

            //propagate output size backwards through filter chain to allow a 'flex' filter to determine its output based on the desired output needs
            presize = outsize;
            for (int i = Filters.Count - 1; i >= 0; i--)
            {
                var filter = Filters[i];
                presize = filter.PresizeOutput(channel, presize);
            }

            SurfaceState currState = null;

            for (int i = 0; i < Filters.Count; i++)
            {
                BaseFilter f = Filters[i];

                //check whether this filter needs input. if so, notify it of the current pipeline state
                var iosi = f.FindInput(channel);
                if (iosi != null)
                {
                    iosi.SurfaceFormat = currState.SurfaceFormat;
                    f.SetInputFormat(channel, currState);

                    if (f.IsNop)
                    {
                        continue;
                    }

                    //check if the desired disposition needs to change from texture to render target
                    //(if so, insert a render filter)
                    if (iosi.SurfaceDisposition == SurfaceDisposition.RenderTarget && currState.SurfaceDisposition == SurfaceDisposition.Texture)
                    {
                        var renderer = new Render();
                        Filters.Insert(i, renderer);
                        goto RETRY;
                    }
                    //check if the desired disposition needs to change from a render target to a texture
                    //(if so, the current render target gets resolved, and made no longer current
                    else if (iosi.SurfaceDisposition == SurfaceDisposition.Texture && currState.SurfaceDisposition == SurfaceDisposition.RenderTarget)
                    {
                        var resolver = new Resolve();
                        Filters.Insert(i, resolver);
                        goto RETRY;
                    }
                }

                //now, the filter will have set its output state depending on its input state. check if it outputs:
                iosi = f.FindOutput(channel);
                if (iosi != null)
                {
                    if (currState == null)
                    {
                        currState = new SurfaceState
                        {
                            SurfaceFormat      = iosi.SurfaceFormat,
                            SurfaceDisposition = iosi.SurfaceDisposition
                        };
                    }
                    else
                    {
                        //if output disposition is unspecified, change it to whatever we've got right now
                        if (iosi.SurfaceDisposition == SurfaceDisposition.Unspecified)
                        {
                            iosi.SurfaceDisposition = currState.SurfaceDisposition;
                        }

                        bool newTarget = false;
                        if (iosi.SurfaceFormat.Size != currState.SurfaceFormat.Size)
                        {
                            newTarget = true;
                        }
                        else if (currState.SurfaceDisposition == SurfaceDisposition.Texture && iosi.SurfaceDisposition == SurfaceDisposition.RenderTarget)
                        {
                            newTarget = true;
                        }

                        if (newTarget)
                        {
                            currState               = new SurfaceState();
                            iosi.SurfaceFormat      = currState.SurfaceFormat = iosi.SurfaceFormat;
                            iosi.SurfaceDisposition = currState.SurfaceDisposition = iosi.SurfaceDisposition;
                            Program.Add(new ProgramStep(ProgramStepType.NewTarget, currState.SurfaceFormat.Size));
                        }
                        else
                        {
                            currState.SurfaceDisposition = iosi.SurfaceDisposition;
                        }
                    }
                }

                Program.Add(new ProgramStep(ProgramStepType.Run, i, f.GetType().Name));
            }             //filter loop

            //if the current output disposition is a texture, we need to render it
            if (currState.SurfaceDisposition == SurfaceDisposition.Texture)
            {
                var renderer = new Render();
                Filters.Insert(Filters.Count, renderer);
                goto RETRY;
            }

            //patch the program so that the final rendertarget set operation is the framebuffer instead
            if (finalTarget)
            {
                for (int i = Program.Count - 1; i >= 0; i--)
                {
                    var ps = Program[i];
                    if (ps.Type == ProgramStepType.NewTarget)
                    {
                        var size = (Size)ps.Args;
                        Debug.Assert(size == outsize);
                        ps.Type = ProgramStepType.FinalTarget;
                        ps.Args = size;
                        break;
                    }
                }
            }
        }
Example #7
0
		public void Compile(string channel, Size insize, Size outsize, bool finalTarget)
		{
		RETRY:
			
			Program.Clear();

			//prep filters for initialization
			foreach (var f in Filters)
			{
				f.BeginInitialization(this);
				f.Initialize();
			}

			//propagate input size forwards through filter chain to allow a 'flex' filter to determine what its input will be
			Size presize = insize;
			for (int i = 0; i < Filters.Count; i++)
			{
				var filter = Filters[i];
				presize = filter.PresizeInput(channel, presize);
			}

			//propagate output size backwards through filter chain to allow a 'flex' filter to determine its output based on the desired output needs
			presize = outsize;
			for (int i = Filters.Count - 1; i >= 0; i--)
			{
				var filter = Filters[i];
				presize = filter.PresizeOutput(channel, presize);
			}

			SurfaceState currState = null;

			for (int i = 0; i < Filters.Count; i++)
			{
				BaseFilter f = Filters[i];

				//check whether this filter needs input. if so, notify it of the current pipeline state
				var iosi = f.FindInput(channel);
				if (iosi != null)
				{
					iosi.SurfaceFormat = currState.SurfaceFormat;
					f.SetInputFormat(channel, currState);

					//check if the desired disposition needs to change from texture to render target
					//(if so, insert a render filter)
					if (iosi.SurfaceDisposition == SurfaceDisposition.RenderTarget && currState.SurfaceDisposition == SurfaceDisposition.Texture)
					{
						var renderer = new Render();
						Filters.Insert(i, renderer);
						goto RETRY;
					}
					//check if the desired disposition needs to change from a render target to a texture
					//(if so, the current render target gets resolved, and made no longer current
					else if (iosi.SurfaceDisposition == SurfaceDisposition.Texture && currState.SurfaceDisposition == SurfaceDisposition.RenderTarget)
					{
						var resolver = new Resolve();
						Filters.Insert(i, resolver);
						goto RETRY;
					}
				}

				//now, the filter will have set its output state depending on its input state. check if it outputs:
				iosi = f.FindOutput(channel);
				if (iosi != null)
				{
					if (currState == null)
					{
						currState = new SurfaceState();
						currState.SurfaceFormat = iosi.SurfaceFormat;
						currState.SurfaceDisposition = iosi.SurfaceDisposition;
					}
					else
					{
						//if output disposition is unspecified, change it to whatever we've got right now
						if (iosi.SurfaceDisposition == SurfaceDisposition.Unspecified)
						{
							iosi.SurfaceDisposition = currState.SurfaceDisposition;
						}

						bool newTarget = false;
						if (iosi.SurfaceFormat.Size != currState.SurfaceFormat.Size)
							newTarget = true;
						else if (currState.SurfaceDisposition == SurfaceDisposition.Texture && iosi.SurfaceDisposition == SurfaceDisposition.RenderTarget)
							newTarget = true;

						if (newTarget)
						{
							currState = new SurfaceState();
							iosi.SurfaceFormat = currState.SurfaceFormat = iosi.SurfaceFormat;
							iosi.SurfaceDisposition = currState.SurfaceDisposition = iosi.SurfaceDisposition;
							Program.Add(new ProgramStep(ProgramStepType.NewTarget, currState.SurfaceFormat.Size));
						}
						else
						{
							currState.SurfaceDisposition = iosi.SurfaceDisposition;
						}
					}


				}

				Program.Add(new ProgramStep(ProgramStepType.Run, i, f.GetType().Name));

			} //filter loop

			//if the current output disposition is a texture, we need to render it
			if (currState.SurfaceDisposition == SurfaceDisposition.Texture)
			{
				var renderer = new Render();
				Filters.Insert(Filters.Count, renderer);
				goto RETRY;
			}

			//patch the program so that the final rendertarget set operation is the framebuffer instead
			if (finalTarget)
			{
				for (int i = Program.Count - 1; i >= 0; i--)
				{
					var ps = Program[i];
					if (ps.Type == ProgramStepType.NewTarget)
					{
						var size = (Size)ps.Args;
						Debug.Assert(size == outsize);
						ps.Type = ProgramStepType.FinalTarget;
						ps.Args = size;
						break;
					}
				}
			}
		}
Example #8
0
		public override void SetInputFormat(string channel, SurfaceState state)
		{
			DeclareOutput(new SurfaceState(state.SurfaceFormat, SurfaceDisposition.Texture));
		}
Example #9
0
		public override void SetInputFormat(string channel, SurfaceState format)
		{
			DeclareOutput(SurfaceDisposition.Texture);
		}
Example #10
0
		public override void SetInputFormat(string channel, SurfaceState state)
		{
			Size insize = state.SurfaceFormat.Size;
			if (SP.ScaleTypeX == RetroShaderPreset.ScaleType.Absolute) OutputSize.Width = (int)SP.Scale.X;
			if (SP.ScaleTypeY == RetroShaderPreset.ScaleType.Absolute) OutputSize.Width = (int)SP.Scale.Y;
			if (SP.ScaleTypeX == RetroShaderPreset.ScaleType.Source) OutputSize.Width = (int)(insize.Width * SP.Scale.X);
			if (SP.ScaleTypeY == RetroShaderPreset.ScaleType.Source) OutputSize.Height = (int)(insize.Height * SP.Scale.Y);

			var outState = new SurfaceState();
			outState.SurfaceFormat = new SurfaceFormat(OutputSize);
			outState.SurfaceDisposition = SurfaceDisposition.RenderTarget;
			DeclareOutput(outState);
		}
Example #11
0
		//TODO - why a different param order than DeclareOutput?

		protected IOSurfaceInfo DeclareOutput(SurfaceState state, string channel = "default")
		{
			var iosi = DeclareIO(SurfaceDirection.Output, channel, state.SurfaceDisposition);
			iosi.SurfaceFormat = state.SurfaceFormat;
			return iosi;
		}
Example #12
0
		public virtual void SetInputFormat(string channel, SurfaceState state) { } //TODO - why a different param order than DeclareOutput?
Example #13
0
		public override void SetInputFormat(string channel, SurfaceState state)
		{
			bool need = false;
			if (state.SurfaceFormat.Size != OutputSize)
				need = true;
			if (FilterOption != eFilterOption.None)
				need = true;

			if (!need)
			{
				nop = true;
				ContentSize = state.SurfaceFormat.Size;
				return;
			}

			FindInput().SurfaceDisposition = SurfaceDisposition.Texture;
			DeclareOutput(new SurfaceState(new SurfaceFormat(OutputSize), SurfaceDisposition.RenderTarget));
			InputSize = state.SurfaceFormat.Size;
			LL = new LetterboxingLogic(Global.Config.DispFixAspectRatio, Global.Config.DispFixScaleInteger, OutputSize.Width, OutputSize.Height, InputSize.Width, InputSize.Height, TextureSize, VirtualTextureSize);
			ContentSize = new Size(LL.vw,LL.vh);
		}
Example #14
0
 public virtual void SetInputFormat(string channel, SurfaceState state)
 {
 }