Skip to content

Commit

Permalink
emuhawk - add experimental prescale option to display manager
Browse files Browse the repository at this point in the history
  • Loading branch information
zeromus committed Jul 6, 2015
1 parent 60c3734 commit db1191d
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 97 deletions.
2 changes: 2 additions & 0 deletions BizHawk.Client.Common/config/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ public enum ClientProfile
public bool DispFixScaleInteger = true;
public bool DispFullscreenHacks = true;

public int DispPrescale = 1;

//warning: we dont even want to deal with changing this at runtime. but we want it changed here for config purposes. so dont check this variable. check in GlobalWin or something like that.
public EDispMethod DispMethod = EDispMethod.OpenGL;

Expand Down
6 changes: 6 additions & 0 deletions BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,12 @@ FilterProgram BuildDefaultChain(Size chain_insize, Size chain_outsize, bool incl
//add lua layer 'emu'
AppendLuaLayer(chain, "emu");

if (Global.Config.DispPrescale != 1)
{
Filters.PrescaleFilter fPrescale = new Filters.PrescaleFilter() { Scale = Global.Config.DispPrescale };
chain.AddFilter(fPrescale, "prescale");
}

//add user-selected retro shader
if (selectedChain != null)
AppendRetroShaderChain(chain, "retroShader", selectedChain, selectedChainProperties);
Expand Down
3 changes: 2 additions & 1 deletion BizHawk.Client.EmuHawk/DisplayManager/Filters/BaseFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class BaseFilter
public virtual void Initialize() { }
public virtual Size PresizeInput(string channel, Size size) { return size; }
public virtual Size PresizeOutput(string channel, Size size) { return size; }
public virtual void SetInputFormat(string channel, SurfaceState state) { }
public virtual void SetInputFormat(string channel, SurfaceState state) { } //TODO - why a different param order than DeclareOutput?
public Dictionary<string, object> Parameters = new Dictionary<string, object>();

//runtime signals
Expand Down Expand Up @@ -85,6 +85,7 @@ protected void YieldOutput(Texture2d tex)
//setup utilities
protected IOSurfaceInfo DeclareInput(SurfaceDisposition disposition = SurfaceDisposition.Unspecified, string channel = "default") { return DeclareIO(SurfaceDirection.Input, channel, disposition); }
protected IOSurfaceInfo DeclareOutput(SurfaceDisposition disposition = SurfaceDisposition.Unspecified, string channel = "default") { return DeclareIO(SurfaceDirection.Output, channel, disposition); }
//TODO - why a different param order than DeclareOutput?

protected IOSurfaceInfo DeclareOutput(SurfaceState state, string channel = "default")
{
Expand Down
30 changes: 30 additions & 0 deletions BizHawk.Client.EmuHawk/DisplayManager/Filters/Gui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,36 @@ public override void Run()
}
}

//TODO - turn this into a NOP at 1x, just in case something accidentally activates it with 1x
public class PrescaleFilter : BaseFilter
{
public int Scale;

public override void Initialize()
{
DeclareInput(SurfaceDisposition.Texture);
}

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);
}

public override void Run()
{
var outSize = FindOutput().SurfaceFormat.Size;
FilterProgram.GuiRenderer.Begin(outSize);
FilterProgram.GuiRenderer.SetBlendState(FilterProgram.GL.BlendNoneCopy);
FilterProgram.GuiRenderer.Modelview.Scale(Scale);
FilterProgram.GuiRenderer.Draw(InputTexture);
FilterProgram.GuiRenderer.End();
}
}

public class LuaLayer : BaseFilter
{
public override void Initialize()
Expand Down
238 changes: 142 additions & 96 deletions BizHawk.Client.EmuHawk/config/DisplayConfigLite.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit db1191d

Please sign in to comment.