commit
f20a77790d
|
@ -258,6 +258,10 @@
|
|||
<Project>{5160CFB1-5389-47C1-B7F6-8A0DC97641EE}</Project>
|
||||
<Name>BizHawk.Bizware.BizwareGL.OpenTK</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Bizware\BizHawk.Bizware.BizwareGL.SlimDX\BizHawk.Bizware.BizwareGL.SlimDX.csproj">
|
||||
<Project>{E6B436B1-A3CD-4C9A-8F76-5D7154726884}</Project>
|
||||
<Name>BizHawk.Bizware.BizwareGL.SlimDX</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Bizware\BizHawk.Bizware.BizwareGL\BizHawk.Bizware.BizwareGL.csproj">
|
||||
<Project>{9F84A0B2-861E-4EF4-B89B-5E2A3F38A465}</Project>
|
||||
<Name>BizHawk.Bizware.BizwareGL</Name>
|
||||
|
|
|
@ -35,7 +35,8 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
return new ContextRef
|
||||
{
|
||||
gc = gc
|
||||
gc = gc,
|
||||
gl = gc.IGL
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -59,13 +60,24 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void Activate(ContextRef cr)
|
||||
{
|
||||
bool begun = false;
|
||||
|
||||
//this needs a begin signal to set the swap chain to the next backbuffer
|
||||
if (cr.gl is BizHawk.Bizware.BizwareGL.Drivers.SlimDX.IGL_SlimDX9)
|
||||
{
|
||||
cr.gc.Begin();
|
||||
begun = true;
|
||||
}
|
||||
|
||||
if (cr == ActiveContext)
|
||||
return;
|
||||
|
||||
ActiveContext = cr;
|
||||
if (cr.gc != null)
|
||||
{
|
||||
//TODO - this is checking the current context inside to avoid an extra NOP context change. make this optional or remove it, since we're tracking it here
|
||||
cr.gc.Begin();
|
||||
if(!begun)
|
||||
cr.gc.Begin();
|
||||
}
|
||||
if (cr.gl != null)
|
||||
{
|
||||
|
|
|
@ -29,6 +29,8 @@ namespace BizHawk.Client.Common
|
|||
/// </summary>
|
||||
public static string MakeProgramRelativePath(string path) { return MakeAbsolutePath("%exe%/" + path, null); }
|
||||
|
||||
public static string GetDllDirectory() { return Path.Combine(GetExeDirectoryAbsolute(), "dll"); }
|
||||
|
||||
/// <summary>
|
||||
/// The location of the default INI file
|
||||
/// </summary>
|
||||
|
|
|
@ -225,41 +225,41 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public int DispFPSx = DefaultMessageOptions.DispFPSx;
|
||||
public int DispFPSy = DefaultMessageOptions.DispFPSy;
|
||||
public int DispFrameCx = DefaultMessageOptions.DispFrameCx;
|
||||
public int DispFrameCy = DefaultMessageOptions.DispFrameCy;
|
||||
public int DispLagx = DefaultMessageOptions.DispLagx;
|
||||
public int DispLagy = DefaultMessageOptions.DispLagy;
|
||||
public int DispInpx = DefaultMessageOptions.DispInpx;
|
||||
public int DispInpy = DefaultMessageOptions.DispInpy;
|
||||
public int DispRecx = DefaultMessageOptions.DispRecx;
|
||||
public int DispRecy = DefaultMessageOptions.DispRecy;
|
||||
public int DispMultix = DefaultMessageOptions.DispMultix;
|
||||
public int DispMultiy = DefaultMessageOptions.DispMultiy;
|
||||
public int DispFrameCx = DefaultMessageOptions.DispFrameCx;
|
||||
public int DispFrameCy = DefaultMessageOptions.DispFrameCy;
|
||||
public int DispLagx = DefaultMessageOptions.DispLagx;
|
||||
public int DispLagy = DefaultMessageOptions.DispLagy;
|
||||
public int DispInpx = DefaultMessageOptions.DispInpx;
|
||||
public int DispInpy = DefaultMessageOptions.DispInpy;
|
||||
public int DispRecx = DefaultMessageOptions.DispRecx;
|
||||
public int DispRecy = DefaultMessageOptions.DispRecy;
|
||||
public int DispMultix = DefaultMessageOptions.DispMultix;
|
||||
public int DispMultiy = DefaultMessageOptions.DispMultiy;
|
||||
public int DispRamWatchx = DefaultMessageOptions.DispRamWatchx;
|
||||
public int DispRamWatchy = DefaultMessageOptions.DispRamWatchy;
|
||||
public int DispMessagex = DefaultMessageOptions.DispMessagex;
|
||||
public int DispMessagey = DefaultMessageOptions.DispMessagey;
|
||||
public int DispMessagex = DefaultMessageOptions.DispMessagex;
|
||||
public int DispMessagey = DefaultMessageOptions.DispMessagey;
|
||||
public int DispAutoholdx = DefaultMessageOptions.DispAutoholdx;
|
||||
public int DispAutoholdy = DefaultMessageOptions.DispAutoholdy;
|
||||
public int DispAutoholdy = DefaultMessageOptions.DispAutoholdy;
|
||||
|
||||
public int DispFPSanchor = DefaultMessageOptions.DispFPSanchor; // 0 = UL, 1 = UR, 2 = DL, 3 = DR
|
||||
public int DispFrameanchor = DefaultMessageOptions.DispFrameanchor;
|
||||
public int DispLaganchor = DefaultMessageOptions.DispLaganchor;
|
||||
public int DispInpanchor = DefaultMessageOptions.DispInpanchor;
|
||||
public int DispRecanchor = DefaultMessageOptions.DispRecanchor;
|
||||
public int DispMultianchor = DefaultMessageOptions.DispMultianchor;
|
||||
public int DispMessageanchor = DefaultMessageOptions.DispMessageanchor;
|
||||
public int DispAutoholdanchor = DefaultMessageOptions.DispAutoholdanchor;
|
||||
public int DispFPSanchor = DefaultMessageOptions.DispFPSanchor; // 0 = UL, 1 = UR, 2 = DL, 3 = DR
|
||||
public int DispFrameanchor = DefaultMessageOptions.DispFrameanchor;
|
||||
public int DispLaganchor = DefaultMessageOptions.DispLaganchor;
|
||||
public int DispInpanchor = DefaultMessageOptions.DispInpanchor;
|
||||
public int DispRecanchor = DefaultMessageOptions.DispRecanchor;
|
||||
public int DispMultianchor = DefaultMessageOptions.DispMultianchor;
|
||||
public int DispMessageanchor = DefaultMessageOptions.DispMessageanchor;
|
||||
public int DispAutoholdanchor = DefaultMessageOptions.DispAutoholdanchor;
|
||||
|
||||
public int MessagesColor = DefaultMessageOptions.MessagesColor;
|
||||
public int AlertMessageColor = DefaultMessageOptions.AlertMessageColor;
|
||||
public int LastInputColor = DefaultMessageOptions.LastInputColor;
|
||||
public int MovieInput = DefaultMessageOptions.MovieInput;
|
||||
public int MessagesColor = DefaultMessageOptions.MessagesColor;
|
||||
public int AlertMessageColor = DefaultMessageOptions.AlertMessageColor;
|
||||
public int LastInputColor = DefaultMessageOptions.LastInputColor;
|
||||
public int MovieInput = DefaultMessageOptions.MovieInput;
|
||||
|
||||
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;
|
||||
public EDispMethod DispMethod = EDispMethod.SlimDX9;
|
||||
|
||||
public int DispChrome_FrameWindowed = 2;
|
||||
public bool DispChrome_StatusBarWindowed = true;
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
ffmpeg = new Process();
|
||||
#if WINDOWS
|
||||
ffmpeg.StartInfo.FileName = System.IO.Path.Combine(PathManager.GetBasePathAbsolute(), "dll", "ffmpeg.exe");
|
||||
ffmpeg.StartInfo.FileName = System.IO.Path.Combine(PathManager.GetDllDirectory(), "dll", "ffmpeg.exe");
|
||||
#else
|
||||
ffmpeg.StartInfo.FileName = "ffmpeg"; // expecting native version to be in path
|
||||
#endif
|
||||
|
|
|
@ -63,19 +63,22 @@ namespace BizHawk.Client.EmuHawk
|
|||
using (var tex = typeof(Program).Assembly.GetManifestResourceStream("BizHawk.Client.EmuHawk.Resources.courier16px_0.png"))
|
||||
TheOneFont = new StringRenderer(GL, xml, tex);
|
||||
|
||||
if (GL is BizHawk.Bizware.BizwareGL.Drivers.OpenTK.IGL_TK)
|
||||
if (GL is BizHawk.Bizware.BizwareGL.Drivers.OpenTK.IGL_TK || GL is BizHawk.Bizware.BizwareGL.Drivers.SlimDX.IGL_SlimDX9)
|
||||
{
|
||||
var fiHq2x = new FileInfo(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk/hq2x.cgp"));
|
||||
if (fiHq2x.Exists)
|
||||
using (var stream = fiHq2x.OpenRead())
|
||||
ShaderChain_hq2x = new Filters.RetroShaderChain(GL, new Filters.RetroShaderPreset(stream), Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk"));
|
||||
var fiScanlines = new FileInfo(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk/BizScanlines.cgp"));
|
||||
if (fiScanlines.Exists)
|
||||
using (var stream = fiScanlines.OpenRead())
|
||||
ShaderChain_scanlines = new Filters.RetroShaderChain(GL, new Filters.RetroShaderPreset(stream), Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk"));
|
||||
var fiBicubic = new FileInfo(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk/bicubic-fast.cgp"));
|
||||
//var fiHq2x = new FileInfo(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk/hq2x.cgp"));
|
||||
//if (fiHq2x.Exists)
|
||||
// using (var stream = fiHq2x.OpenRead())
|
||||
// ShaderChain_hq2x = new Filters.RetroShaderChain(GL, new Filters.RetroShaderPreset(stream), Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk"));
|
||||
//var fiScanlines = new FileInfo(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk/BizScanlines.cgp"));
|
||||
//if (fiScanlines.Exists)
|
||||
// using (var stream = fiScanlines.OpenRead())
|
||||
// ShaderChain_scanlines = new Filters.RetroShaderChain(GL, new Filters.RetroShaderPreset(stream), Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk"));
|
||||
string bicubic_path = "Shaders/BizHawk/bicubic-fast.cgp";
|
||||
if(GL is BizHawk.Bizware.BizwareGL.Drivers.SlimDX.IGL_SlimDX9)
|
||||
bicubic_path = "Shaders/BizHawk/bicubic-normal.cgp";
|
||||
var fiBicubic = new FileInfo(Path.Combine(PathManager.GetExeDirectoryAbsolute(), bicubic_path));
|
||||
if (fiBicubic.Exists)
|
||||
using (var stream = fiBicubic.OpenRead())
|
||||
using (var stream = fiBicubic.Open(FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
ShaderChain_bicubic = new Filters.RetroShaderChain(GL, new Filters.RetroShaderPreset(stream), Path.Combine(PathManager.GetExeDirectoryAbsolute(), "Shaders/BizHawk"));
|
||||
}
|
||||
|
||||
|
@ -241,10 +244,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
Filters.FinalPresentation.eFilterOption finalFilter = Filters.FinalPresentation.eFilterOption.None;
|
||||
if (Global.Config.DispFinalFilter == 1) finalFilter = Filters.FinalPresentation.eFilterOption.Bilinear;
|
||||
if (Global.Config.DispFinalFilter == 2) finalFilter = Filters.FinalPresentation.eFilterOption.Bicubic;
|
||||
//if bicubic is selected and unavailable, dont use it
|
||||
if (ShaderChain_bicubic != null && !ShaderChain_bicubic.Available && fPresent.FilterOption == Filters.FinalPresentation.eFilterOption.Bicubic)
|
||||
//if bicubic is selected and unavailable, dont use it. use bilinear instead I guess
|
||||
if (finalFilter == Filters.FinalPresentation.eFilterOption.Bicubic)
|
||||
{
|
||||
finalFilter = Filters.FinalPresentation.eFilterOption.None;
|
||||
if (ShaderChain_bicubic == null || !ShaderChain_bicubic.Available)
|
||||
finalFilter = Filters.FinalPresentation.eFilterOption.Bilinear;
|
||||
}
|
||||
fPresent.FilterOption = finalFilter;
|
||||
|
||||
|
@ -259,7 +263,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
AppendLuaLayer(chain, "native");
|
||||
|
||||
//and OSD goes on top of that
|
||||
//TODO - things break if this isnt present (the final presentation filter gets messed up)
|
||||
//TODO - things break if this isnt present (the final presentation filter gets messed up when used with prescaling)
|
||||
//so, always include it (we'll handle this flag in the callback to do no rendering)
|
||||
//if (includeOSD)
|
||||
chain.AddFilter(fOSD, "osd");
|
||||
|
@ -519,7 +523,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
FilterProgram UpdateSourceInternal(JobInfo job)
|
||||
{
|
||||
GlobalWin.GLManager.Activate(CR_GraphicsControl);
|
||||
//no drawing actually happens. it's important not to begin drawing on a control
|
||||
if (!job.simulate)
|
||||
{
|
||||
GlobalWin.GLManager.Activate(CR_GraphicsControl);
|
||||
}
|
||||
|
||||
IVideoProvider videoProvider = job.videoProvider;
|
||||
bool simulate = job.simulate;
|
||||
|
@ -550,19 +558,21 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
int[] videoBuffer = videoProvider.GetVideoBuffer();
|
||||
|
||||
TESTEROO:
|
||||
int bufferWidth = videoProvider.BufferWidth;
|
||||
int bufferHeight = videoProvider.BufferHeight;
|
||||
bool isGlTextureId = videoBuffer.Length == 1;
|
||||
|
||||
//TODO - need to do some work here for GDI+ to repair gl texture ID importing
|
||||
BitmapBuffer bb = null;
|
||||
Texture2d videoTexture = null;
|
||||
if (!simulate)
|
||||
{
|
||||
//special codepath for GDI+
|
||||
//TODO - make for gdi+ only. maybe other codepath for d3d
|
||||
if (!(GL is BizHawk.Bizware.BizwareGL.Drivers.OpenTK.IGL_TK))
|
||||
if (isGlTextureId)
|
||||
{
|
||||
//FYI: this is a million years from happening on n64, since it's all geriatric non-FBO code
|
||||
//is it workable for saturn?
|
||||
videoTexture = GL.WrapGLTexture2d(new IntPtr(videoBuffer[0]), bufferWidth, bufferHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
//wrap the videoprovider data in a BitmapBuffer (no point to refactoring that many IVideoProviders)
|
||||
bb = new BitmapBuffer(bufferWidth, bufferHeight, videoBuffer);
|
||||
|
@ -570,30 +580,9 @@ TESTEROO:
|
|||
|
||||
//now, acquire the data sent from the videoProvider into a texture
|
||||
videoTexture = VideoTextureFrugalizer.Get(bb);
|
||||
GL.SetTextureWrapMode(videoTexture, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isGlTextureId)
|
||||
{
|
||||
videoTexture = GL.WrapGLTexture2d(new IntPtr(videoBuffer[0]), bufferWidth, bufferHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
//wrap the videoprovider data in a BitmapBuffer (no point to refactoring that many IVideoProviders)
|
||||
bb = new BitmapBuffer(bufferWidth, bufferHeight, videoBuffer);
|
||||
|
||||
//now, acquire the data sent from the videoProvider into a texture
|
||||
videoTexture = VideoTextureFrugalizer.Get(bb);
|
||||
GL.SetTextureWrapMode(videoTexture, true);
|
||||
}
|
||||
|
||||
//TEST (to be removed once we have an actual example of bring in a texture ID from opengl emu core):
|
||||
if (!isGlTextureId)
|
||||
{
|
||||
videoBuffer = new int[1] { videoTexture.Id.ToInt32() };
|
||||
goto TESTEROO;
|
||||
}
|
||||
|
||||
//lets not use this. lets define BizwareGL to make clamp by default (TBD: check opengl)
|
||||
//GL.SetTextureWrapMode(videoTexture, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -647,6 +636,8 @@ TESTEROO:
|
|||
//do i need to check this on an intel video card to see if running excessively is a problem? (it used to be in the FinalTarget command below, shouldnt be a problem)
|
||||
//GraphicsControl.Begin();
|
||||
|
||||
GlobalWin.GL.BeginScene();
|
||||
|
||||
//run filter chain
|
||||
Texture2d texCurr = null;
|
||||
RenderTarget rtCurr = null;
|
||||
|
@ -693,6 +684,8 @@ TESTEROO:
|
|||
}
|
||||
}
|
||||
|
||||
GL.EndScene();
|
||||
|
||||
if (job.offscreen)
|
||||
{
|
||||
job.offscreenBB = rtCurr.Texture2d.Resolve();
|
||||
|
@ -730,6 +723,7 @@ TESTEROO:
|
|||
|
||||
NeedsToPaint = false; //??
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool? LastVsyncSetting;
|
||||
|
|
|
@ -7,9 +7,19 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public static MainForm MainForm;
|
||||
public static ToolManager Tools;
|
||||
|
||||
/// <summary>
|
||||
/// the IGL to be used for rendering
|
||||
/// </summary>
|
||||
public static IGL GL;
|
||||
public static Bizware.BizwareGL.Drivers.OpenTK.IGL_TK IGL_GL;
|
||||
|
||||
public static GLManager.ContextRef CR_GL;
|
||||
|
||||
/// <summary>
|
||||
/// The IGL_TK to be used for specifically opengl operations (accessing textures from opengl-based cores)
|
||||
/// </summary>
|
||||
public static Bizware.BizwareGL.Drivers.OpenTK.IGL_TK IGL_GL;
|
||||
|
||||
public static Sound Sound;
|
||||
public static OSDManager OSD = new OSDManager();
|
||||
public static DisplayManager DisplayManager;
|
||||
|
|
|
@ -211,6 +211,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Database.LoadDatabase(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "gamedb.txt"));
|
||||
|
||||
//TODO GL - a lot of disorganized wiring-up here
|
||||
CGC.CGCBinPath = Path.Combine(PathManager.GetDllDirectory(), "cgc.exe");
|
||||
PresentationPanel = new PresentationPanel();
|
||||
GlobalWin.DisplayManager = new DisplayManager(PresentationPanel);
|
||||
Controls.Add(PresentationPanel);
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
this.lblUserFilterName = new System.Windows.Forms.Label();
|
||||
this.btnSelectUserFilter = new System.Windows.Forms.Button();
|
||||
this.rbUser = new System.Windows.Forms.RadioButton();
|
||||
this.tbScanlineIntensity = new BizHawk.Client.EmuHawk.TransparentTrackBar();
|
||||
this.rbNone = new System.Windows.Forms.RadioButton();
|
||||
this.rbScanlines = new System.Windows.Forms.RadioButton();
|
||||
this.rbHq2x = new System.Windows.Forms.RadioButton();
|
||||
|
@ -86,10 +87,10 @@
|
|||
this.cbStatusBarWindowed = new System.Windows.Forms.CheckBox();
|
||||
this.label9 = new System.Windows.Forms.Label();
|
||||
this.cbMenuWindowed = new System.Windows.Forms.CheckBox();
|
||||
this.cbCaptionWindowed = new System.Windows.Forms.CheckBox();
|
||||
this.tbScanlineIntensity = new BizHawk.Client.EmuHawk.TransparentTrackBar();
|
||||
this.trackbarFrameSizeWindowed = new BizHawk.Client.EmuHawk.TransparentTrackBar();
|
||||
this.cbCaptionWindowed = new System.Windows.Forms.CheckBox();
|
||||
this.groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.tbScanlineIntensity)).BeginInit();
|
||||
this.grpFinalFilter.SuspendLayout();
|
||||
this.grpARSelection.SuspendLayout();
|
||||
this.tabControl1.SuspendLayout();
|
||||
|
@ -102,7 +103,6 @@
|
|||
this.tabPage1.SuspendLayout();
|
||||
this.groupBox4.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.tbScanlineIntensity)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackbarFrameSizeWindowed)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
|
@ -184,6 +184,19 @@
|
|||
this.rbUser.Text = "User";
|
||||
this.rbUser.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tbScanlineIntensity
|
||||
//
|
||||
this.tbScanlineIntensity.LargeChange = 32;
|
||||
this.tbScanlineIntensity.Location = new System.Drawing.Point(83, 55);
|
||||
this.tbScanlineIntensity.Maximum = 256;
|
||||
this.tbScanlineIntensity.Name = "tbScanlineIntensity";
|
||||
this.tbScanlineIntensity.Size = new System.Drawing.Size(70, 42);
|
||||
this.tbScanlineIntensity.TabIndex = 3;
|
||||
this.tbScanlineIntensity.TickFrequency = 32;
|
||||
this.tbScanlineIntensity.TickStyle = System.Windows.Forms.TickStyle.TopLeft;
|
||||
this.tbScanlineIntensity.Scroll += new System.EventHandler(this.tbScanlineIntensity_Scroll);
|
||||
this.tbScanlineIntensity.ValueChanged += new System.EventHandler(this.tbScanlineIntensity_Scroll);
|
||||
//
|
||||
// rbNone
|
||||
//
|
||||
this.rbNone.AutoSize = true;
|
||||
|
@ -373,8 +386,8 @@
|
|||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(398, 27);
|
||||
this.label2.TabIndex = 17;
|
||||
this.label2.Text = "Some people think the whitenoise is a great idea, and some people don\'t. Enabling" +
|
||||
" this displays black instead.";
|
||||
this.label2.Text = "Some people think the white noise is a great idea, and some people don\'t. Disabli" +
|
||||
"ng this displays black instead.";
|
||||
//
|
||||
// checkSnowyNullEmulator
|
||||
//
|
||||
|
@ -515,17 +528,17 @@
|
|||
//
|
||||
// label8
|
||||
//
|
||||
this.label8.Location = new System.Drawing.Point(24, 30);
|
||||
this.label8.Location = new System.Drawing.Point(21, 30);
|
||||
this.label8.Name = "label8";
|
||||
this.label8.Size = new System.Drawing.Size(359, 47);
|
||||
this.label8.TabIndex = 20;
|
||||
this.label8.Text = " • Not working yet\r\n • Best compatibility\r\n • No support for custom shaders\r\n";
|
||||
this.label8.Text = " • Best compatibility\r\n • May have trouble with OpenGL-based cores (Saturn,N64)\r\n" +
|
||||
"";
|
||||
//
|
||||
// rbD3D9
|
||||
//
|
||||
this.rbD3D9.AutoSize = true;
|
||||
this.rbD3D9.Checked = true;
|
||||
this.rbD3D9.Enabled = false;
|
||||
this.rbD3D9.Location = new System.Drawing.Point(6, 10);
|
||||
this.rbD3D9.Name = "rbD3D9";
|
||||
this.rbD3D9.Size = new System.Drawing.Size(73, 17);
|
||||
|
@ -540,8 +553,8 @@
|
|||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(359, 47);
|
||||
this.label7.TabIndex = 18;
|
||||
this.label7.Text = " • Mainly for compatibility purposes\r\n • Missing some features\r\n • Works better o" +
|
||||
"ver Remote Desktop, etc.\r\n";
|
||||
this.label7.Text = " • Slow; Mainly for compatibility purposes\r\n • Missing many features\r\n • Works be" +
|
||||
"tter over Remote Desktop, etc.\r\n";
|
||||
//
|
||||
// rbGDIPlus
|
||||
//
|
||||
|
@ -644,9 +657,9 @@
|
|||
this.cbFSAutohideMouse.AutoSize = true;
|
||||
this.cbFSAutohideMouse.Location = new System.Drawing.Point(87, 19);
|
||||
this.cbFSAutohideMouse.Name = "cbFSAutohideMouse";
|
||||
this.cbFSAutohideMouse.Size = new System.Drawing.Size(139, 17);
|
||||
this.cbFSAutohideMouse.Size = new System.Drawing.Size(141, 17);
|
||||
this.cbFSAutohideMouse.TabIndex = 28;
|
||||
this.cbFSAutohideMouse.Text = "Auto-hide Mouse Cursor";
|
||||
this.cbFSAutohideMouse.Text = "Auto-Hide Mouse Cursor";
|
||||
this.cbFSAutohideMouse.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label1
|
||||
|
@ -740,29 +753,6 @@
|
|||
this.cbMenuWindowed.Text = "Menu";
|
||||
this.cbMenuWindowed.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cbCaptionWindowed
|
||||
//
|
||||
this.cbCaptionWindowed.AutoSize = true;
|
||||
this.cbCaptionWindowed.Location = new System.Drawing.Point(9, 104);
|
||||
this.cbCaptionWindowed.Name = "cbCaptionWindowed";
|
||||
this.cbCaptionWindowed.Size = new System.Drawing.Size(62, 17);
|
||||
this.cbCaptionWindowed.TabIndex = 24;
|
||||
this.cbCaptionWindowed.Text = "Caption";
|
||||
this.cbCaptionWindowed.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tbScanlineIntensity
|
||||
//
|
||||
this.tbScanlineIntensity.LargeChange = 32;
|
||||
this.tbScanlineIntensity.Location = new System.Drawing.Point(83, 55);
|
||||
this.tbScanlineIntensity.Maximum = 256;
|
||||
this.tbScanlineIntensity.Name = "tbScanlineIntensity";
|
||||
this.tbScanlineIntensity.Size = new System.Drawing.Size(70, 42);
|
||||
this.tbScanlineIntensity.TabIndex = 3;
|
||||
this.tbScanlineIntensity.TickFrequency = 32;
|
||||
this.tbScanlineIntensity.TickStyle = System.Windows.Forms.TickStyle.TopLeft;
|
||||
this.tbScanlineIntensity.Scroll += new System.EventHandler(this.tbScanlineIntensity_Scroll);
|
||||
this.tbScanlineIntensity.ValueChanged += new System.EventHandler(this.tbScanlineIntensity_Scroll);
|
||||
//
|
||||
// trackbarFrameSizeWindowed
|
||||
//
|
||||
this.trackbarFrameSizeWindowed.LargeChange = 1;
|
||||
|
@ -774,6 +764,16 @@
|
|||
this.trackbarFrameSizeWindowed.Value = 1;
|
||||
this.trackbarFrameSizeWindowed.ValueChanged += new System.EventHandler(this.trackbarFrameSizeWindowed_ValueChanged);
|
||||
//
|
||||
// cbCaptionWindowed
|
||||
//
|
||||
this.cbCaptionWindowed.AutoSize = true;
|
||||
this.cbCaptionWindowed.Location = new System.Drawing.Point(9, 104);
|
||||
this.cbCaptionWindowed.Name = "cbCaptionWindowed";
|
||||
this.cbCaptionWindowed.Size = new System.Drawing.Size(62, 17);
|
||||
this.cbCaptionWindowed.TabIndex = 24;
|
||||
this.cbCaptionWindowed.Text = "Caption";
|
||||
this.cbCaptionWindowed.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// DisplayConfigLite
|
||||
//
|
||||
this.AcceptButton = this.btnOk;
|
||||
|
@ -790,6 +790,7 @@
|
|||
this.Text = "Display Configuration";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.tbScanlineIntensity)).EndInit();
|
||||
this.grpFinalFilter.ResumeLayout(false);
|
||||
this.grpFinalFilter.PerformLayout();
|
||||
this.grpARSelection.ResumeLayout(false);
|
||||
|
@ -810,7 +811,6 @@
|
|||
this.groupBox4.PerformLayout();
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.tbScanlineIntensity)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackbarFrameSizeWindowed)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
|
|
|
@ -399,11 +399,11 @@ TESTEROO:
|
|||
}
|
||||
|
||||
//TEST (to be removed once we have an actual example of bring in a texture ID from opengl emu core):
|
||||
if (!isGlTextureId)
|
||||
{
|
||||
videoBuffer = new int[1] { videoTexture.Id.ToInt32() };
|
||||
goto TESTEROO;
|
||||
}
|
||||
//if (!isGlTextureId)
|
||||
//{
|
||||
// videoBuffer = new int[1] { videoTexture.Id.ToInt32() };
|
||||
// goto TESTEROO;
|
||||
//}
|
||||
}
|
||||
|
||||
//record the size of what we received, since lua and stuff is gonna want to draw onto it
|
||||
|
|
|
@ -73,6 +73,9 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus
|
|||
|
||||
public class IGL_GdiPlus : IGL
|
||||
{
|
||||
//rendering state
|
||||
RenderTarget _CurrRenderTarget;
|
||||
|
||||
public IGL_GdiPlus()
|
||||
{
|
||||
MyBufferedGraphicsContext = new BufferedGraphicsContext();
|
||||
|
@ -113,17 +116,17 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus
|
|||
public IntPtr GenTexture() { return ResourceIDs.Alloc(ResourceIdManager.EResourceType.Texture); }
|
||||
public void FreeTexture(Texture2d tex)
|
||||
{
|
||||
ResourceIDs.Free(tex.Id);
|
||||
ResourceIDs.Free((IntPtr)tex.Opaque);
|
||||
}
|
||||
public IntPtr GetEmptyHandle() { return new IntPtr(0); }
|
||||
public IntPtr GetEmptyUniformHandle() { return new IntPtr(-1); }
|
||||
|
||||
|
||||
public Shader CreateFragmentShader(string source, bool required)
|
||||
public Shader CreateFragmentShader(bool cg, string source, string entry, bool required)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public Shader CreateVertexShader(string source, bool required)
|
||||
public Shader CreateVertexShader(bool cg, string source, string entry, bool required)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -142,27 +145,21 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus
|
|||
public IBlendState BlendNoneOpaque { get { return _rsBlendNoneOpaque; } }
|
||||
public IBlendState BlendNormal { get { return _rsBlendNormal; } }
|
||||
|
||||
public Pipeline CreatePipeline(VertexLayout vertexLayout, Shader vertexShader, Shader fragmentShader, bool required)
|
||||
public Pipeline CreatePipeline(VertexLayout vertexLayout, Shader vertexShader, Shader fragmentShader, bool required, string memo)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public VertexLayout CreateVertexLayout() { return new VertexLayout(this, new IntPtr(0)); }
|
||||
public void FreePipeline(Pipeline pipeline) {}
|
||||
|
||||
public void BindTexture2d(Texture2d tex)
|
||||
{
|
||||
CurrentBoundTexture = tex;
|
||||
}
|
||||
public VertexLayout CreateVertexLayout() { return new VertexLayout(this, new IntPtr(0)); }
|
||||
|
||||
public void SetTextureWrapMode(Texture2d tex, bool clamp)
|
||||
{
|
||||
if (CurrentBoundTexture == null)
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
public void DrawArrays(PrimitiveType mode, int first, int count)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void BindPipeline(Pipeline pipeline)
|
||||
|
@ -170,6 +167,10 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus
|
|||
|
||||
}
|
||||
|
||||
public void Internal_FreeShader(Shader shader)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetPipelineUniform(PipelineUniform uniform, bool value)
|
||||
{
|
||||
|
||||
|
@ -199,17 +200,14 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus
|
|||
{
|
||||
}
|
||||
|
||||
public void SetPipelineUniformSampler(PipelineUniform uniform, IntPtr texHandle)
|
||||
public void SetPipelineUniformSampler(PipelineUniform uniform, Texture2d tex)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void TexParameter2d(TextureParameterName pname, int param)
|
||||
public void TexParameter2d(Texture2d tex, TextureParameterName pname, int param)
|
||||
{
|
||||
if (CurrentBoundTexture == null)
|
||||
return;
|
||||
|
||||
TextureWrapper tw = TextureWrapperForTexture(CurrentBoundTexture);
|
||||
TextureWrapper tw = TextureWrapperForTexture(tex);
|
||||
if (pname == TextureParameterName.TextureMinFilter)
|
||||
tw.MinFilter = (TextureMinFilter)param;
|
||||
if (pname == TextureParameterName.TextureMagFilter)
|
||||
|
@ -223,7 +221,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus
|
|||
tw.SDBitmap = sdbmp;
|
||||
IntPtr id = GenTexture();
|
||||
ResourceIDs.Lookup[id.ToInt32()] = tw;
|
||||
return new Texture2d(this, id, null, bitmap.Width, bitmap.Height);
|
||||
return new Texture2d(this, id, bitmap.Width, bitmap.Height);
|
||||
}
|
||||
|
||||
public Texture2d LoadTexture(Stream stream)
|
||||
|
@ -257,7 +255,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus
|
|||
var tw = new TextureWrapper();
|
||||
tw.SDBitmap = sdbmp;
|
||||
ResourceIDs.Lookup[id.ToInt32()] = tw;
|
||||
return new Texture2d(this, id, null, bmp.Width, bmp.Height);
|
||||
return new Texture2d(this, id, bmp.Width, bmp.Height);
|
||||
}
|
||||
|
||||
public unsafe BitmapBuffer ResolveTexture2d(Texture2d tex)
|
||||
|
@ -279,9 +277,9 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus
|
|||
return CreateGuiProjectionMatrix(new sd.Size(w, h));
|
||||
}
|
||||
|
||||
public Matrix4 CreateGuiViewMatrix(int w, int h)
|
||||
public Matrix4 CreateGuiViewMatrix(int w, int h, bool autoflip)
|
||||
{
|
||||
return CreateGuiViewMatrix(new sd.Size(w, h));
|
||||
return CreateGuiViewMatrix(new sd.Size(w, h), autoflip);
|
||||
}
|
||||
|
||||
public Matrix4 CreateGuiProjectionMatrix(sd.Size dims)
|
||||
|
@ -299,15 +297,25 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus
|
|||
ret.M22 = 1;
|
||||
else ret.M22 = 2.0f / (float)dims.Height;
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Matrix4 CreateGuiViewMatrix(sd.Size dims)
|
||||
public Matrix4 CreateGuiViewMatrix(sd.Size dims, bool autoflip)
|
||||
{
|
||||
Matrix4 ret = Matrix4.Identity;
|
||||
ret.M22 = -1.0f;
|
||||
ret.M41 = -(float)dims.Width * 0.5f;
|
||||
ret.M42 = (float)dims.Height * 0.5f;
|
||||
if (autoflip)
|
||||
{
|
||||
if (_CurrRenderTarget == null) { }
|
||||
else
|
||||
{
|
||||
//flip as long as we're not a final render target
|
||||
ret.M22 = 1.0f;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -393,6 +401,14 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus
|
|||
}
|
||||
}
|
||||
|
||||
public void BeginScene()
|
||||
{
|
||||
}
|
||||
|
||||
public void EndScene()
|
||||
{
|
||||
}
|
||||
|
||||
public IGraphicsControl Internal_CreateGraphicsControl()
|
||||
{
|
||||
var ret = new GLControlWrapper_GdiPlus(this);
|
||||
|
@ -407,9 +423,9 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus
|
|||
|
||||
public void FreeRenderTarget(RenderTarget rt)
|
||||
{
|
||||
int id = rt.Id.ToInt32();
|
||||
int id = (int)rt.Opaque;
|
||||
var rtw = ResourceIDs.Lookup[id] as RenderTargetWrapper;
|
||||
ResourceIDs.Free(rt.Id);
|
||||
ResourceIDs.Free(new IntPtr(id));
|
||||
}
|
||||
|
||||
public unsafe RenderTarget CreateRenderTarget(int w, int h)
|
||||
|
@ -418,10 +434,10 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus
|
|||
tw.SDBitmap = new Bitmap(w,h, sdi.PixelFormat.Format32bppArgb);
|
||||
IntPtr texid = GenTexture();
|
||||
ResourceIDs.Lookup[texid.ToInt32()] = tw;
|
||||
var tex = new Texture2d(this, texid, null, w, h);
|
||||
var tex = new Texture2d(this, texid, w, h);
|
||||
|
||||
var rt = new RenderTarget(this, ResourceIDs.Alloc(ResourceIdManager.EResourceType.RenderTarget), tex);
|
||||
int id = rt.Id.ToInt32();
|
||||
int id = (int)rt.Opaque;
|
||||
RenderTargetWrapper rtw = new RenderTargetWrapper(this);
|
||||
rtw.Target = rt;
|
||||
ResourceIDs.Lookup[id] = rtw;
|
||||
|
@ -430,6 +446,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus
|
|||
|
||||
public void BindRenderTarget(RenderTarget rt)
|
||||
{
|
||||
_CurrRenderTarget = rt;
|
||||
if (CurrentRenderTargetWrapper != null)
|
||||
{
|
||||
if (CurrentRenderTargetWrapper == CurrentControl.RenderTargetWrapper)
|
||||
|
@ -460,12 +477,12 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus
|
|||
|
||||
public TextureWrapper TextureWrapperForTexture(Texture2d tex)
|
||||
{
|
||||
return ResourceIDs.Lookup[tex.Id.ToInt32()] as TextureWrapper;
|
||||
return ResourceIDs.Lookup[((IntPtr)tex.Opaque).ToInt32()] as TextureWrapper;
|
||||
}
|
||||
|
||||
public RenderTargetWrapper RenderTargetWrapperForRt(RenderTarget rt)
|
||||
{
|
||||
return ResourceIDs.Lookup[rt.Id.ToInt32()] as RenderTargetWrapper;
|
||||
return ResourceIDs.Lookup[(int)rt.Opaque] as RenderTargetWrapper;
|
||||
}
|
||||
|
||||
public Graphics GetCurrentGraphics()
|
||||
|
@ -476,7 +493,6 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.GdiPlus
|
|||
|
||||
public GLControlWrapper_GdiPlus CurrentControl;
|
||||
public RenderTargetWrapper CurrentRenderTargetWrapper;
|
||||
Texture2d CurrentBoundTexture;
|
||||
|
||||
//todo - not thread safe
|
||||
public static ResourceIdManager ResourceIDs = new ResourceIdManager();
|
||||
|
|
|
@ -68,7 +68,6 @@
|
|||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="IGL_TK.cs" />
|
||||
<Compile Include="RetroShader.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
@ -33,6 +33,10 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
/// </summary>
|
||||
public class IGL_TK : IGL
|
||||
{
|
||||
//rendering state
|
||||
Pipeline _CurrPipeline;
|
||||
RenderTarget _CurrRenderTarget;
|
||||
|
||||
static IGL_TK()
|
||||
{
|
||||
//make sure OpenTK initializes without getting wrecked on the SDL check and throwing an exception to annoy our MDA's
|
||||
|
@ -79,6 +83,16 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
PurgeStateCache();
|
||||
}
|
||||
|
||||
public void BeginScene()
|
||||
{
|
||||
//seems not to be needed...
|
||||
}
|
||||
|
||||
public void EndScene()
|
||||
{
|
||||
//seems not to be needed...
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
//TODO - a lot of analysis here
|
||||
|
@ -107,57 +121,31 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
return glc;
|
||||
}
|
||||
|
||||
public IntPtr GenTexture() { return new IntPtr(GL.GenTexture()); }
|
||||
public int GenTexture() { return GL.GenTexture(); }
|
||||
public void FreeTexture(Texture2d tex)
|
||||
{
|
||||
GL.DeleteTexture(tex.Id.ToInt32());
|
||||
}
|
||||
public IntPtr GetEmptyHandle() { return new IntPtr(0); }
|
||||
public IntPtr GetEmptyUniformHandle() { return new IntPtr(-1); }
|
||||
|
||||
|
||||
public Shader CreateFragmentShader(string source, bool required)
|
||||
{
|
||||
return CreateShader(ShaderType.FragmentShader, source, required);
|
||||
}
|
||||
public Shader CreateVertexShader(string source, bool required)
|
||||
{
|
||||
return CreateShader(ShaderType.VertexShader, source, required);
|
||||
GL.DeleteTexture((int)tex.Opaque);
|
||||
}
|
||||
|
||||
public void FreeShader(IntPtr shader) { GL.DeleteShader(shader.ToInt32()); }
|
||||
|
||||
class MyBlendState : IBlendState
|
||||
public Shader CreateFragmentShader(bool cg, string source, string entry, bool required)
|
||||
{
|
||||
public bool enabled;
|
||||
public global::OpenTK.Graphics.OpenGL.BlendingFactorSrc colorSource;
|
||||
public global::OpenTK.Graphics.OpenGL.BlendEquationMode colorEquation;
|
||||
public global::OpenTK.Graphics.OpenGL.BlendingFactorDest colorDest;
|
||||
public global::OpenTK.Graphics.OpenGL.BlendingFactorSrc alphaSource;
|
||||
public global::OpenTK.Graphics.OpenGL.BlendEquationMode alphaEquation;
|
||||
public global::OpenTK.Graphics.OpenGL.BlendingFactorDest alphaDest;
|
||||
public MyBlendState(bool enabled, BlendingFactorSrc colorSource, BlendEquationMode colorEquation, BlendingFactorDest colorDest,
|
||||
BlendingFactorSrc alphaSource, BlendEquationMode alphaEquation, BlendingFactorDest alphaDest)
|
||||
{
|
||||
this.enabled = enabled;
|
||||
this.colorSource = (global::OpenTK.Graphics.OpenGL.BlendingFactorSrc)colorSource;
|
||||
this.colorEquation = (global::OpenTK.Graphics.OpenGL.BlendEquationMode)colorEquation;
|
||||
this.colorDest = (global::OpenTK.Graphics.OpenGL.BlendingFactorDest)colorDest;
|
||||
this.alphaSource = (global::OpenTK.Graphics.OpenGL.BlendingFactorSrc)alphaSource;
|
||||
this.alphaEquation = (global::OpenTK.Graphics.OpenGL.BlendEquationMode)alphaEquation;
|
||||
this.alphaDest = (global::OpenTK.Graphics.OpenGL.BlendingFactorDest)alphaDest;
|
||||
}
|
||||
return CreateShader(cg, ShaderType.FragmentShader, source, entry, required);
|
||||
}
|
||||
public Shader CreateVertexShader(bool cg, string source, string entry, bool required)
|
||||
{
|
||||
return CreateShader(cg, ShaderType.VertexShader, source, entry, required);
|
||||
}
|
||||
|
||||
public IBlendState CreateBlendState(BlendingFactorSrc colorSource, BlendEquationMode colorEquation, BlendingFactorDest colorDest,
|
||||
BlendingFactorSrc alphaSource, BlendEquationMode alphaEquation, BlendingFactorDest alphaDest)
|
||||
{
|
||||
return new MyBlendState(true, colorSource, colorEquation, colorDest, alphaSource, alphaEquation, alphaDest);
|
||||
return new CacheBlendState(true, colorSource, colorEquation, colorDest, alphaSource, alphaEquation, alphaDest);
|
||||
}
|
||||
|
||||
public void SetBlendState(IBlendState rsBlend)
|
||||
{
|
||||
var mybs = rsBlend as MyBlendState;
|
||||
if (mybs.enabled)
|
||||
var mybs = rsBlend as CacheBlendState;
|
||||
if (mybs.Enabled)
|
||||
{
|
||||
GL.Enable(EnableCap.Blend);
|
||||
GL.BlendEquationSeparate(mybs.colorEquation, mybs.alphaEquation);
|
||||
|
@ -175,20 +163,73 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
public IBlendState BlendNoneOpaque { get { return _rsBlendNoneOpaque; } }
|
||||
public IBlendState BlendNormal { get { return _rsBlendNormal; } }
|
||||
|
||||
public Pipeline CreatePipeline(VertexLayout vertexLayout, Shader vertexShader, Shader fragmentShader, bool required)
|
||||
class ShaderWrapper
|
||||
{
|
||||
public int sid;
|
||||
public Dictionary<string, string> MapCodeToNative;
|
||||
public Dictionary<string, string> MapNativeToCode;
|
||||
}
|
||||
|
||||
class PipelineWrapper
|
||||
{
|
||||
public int pid;
|
||||
public Shader FragmentShader, VertexShader;
|
||||
public List<int> SamplerLocs;
|
||||
}
|
||||
|
||||
static int poop = 0;
|
||||
|
||||
public Pipeline CreatePipeline(VertexLayout vertexLayout, Shader vertexShader, Shader fragmentShader, bool required, string memo)
|
||||
{
|
||||
required = true;
|
||||
poop++;
|
||||
bool success = true;
|
||||
|
||||
var vsw = vertexShader.Opaque as ShaderWrapper;
|
||||
var fsw = fragmentShader.Opaque as ShaderWrapper;
|
||||
var sws = new[] { vsw,fsw };
|
||||
|
||||
bool mapVariables = vsw.MapCodeToNative != null || fsw.MapCodeToNative != null;
|
||||
|
||||
ErrorCode errcode;
|
||||
int pid = GL.CreateProgram();
|
||||
GL.AttachShader(pid, vertexShader.Id.ToInt32());
|
||||
GL.AttachShader(pid, vsw.sid);
|
||||
errcode = GL.GetError();
|
||||
GL.AttachShader(pid, fragmentShader.Id.ToInt32());
|
||||
GL.AttachShader(pid, fsw.sid);
|
||||
errcode = GL.GetError();
|
||||
|
||||
//bind the attribute locations from the vertex layout
|
||||
foreach (var kvp in vertexLayout.Items)
|
||||
GL.BindAttribLocation(pid, kvp.Key, kvp.Value.Name);
|
||||
//NOT BEING USED NOW: USING SEMANTICS INSTEAD
|
||||
////bind the attribute locations from the vertex layout
|
||||
////as we go, look for attribute mappings (CGC will happily reorder and rename our attribute mappings)
|
||||
////what's more it will _RESIZE_ them but this seems benign..somehow..
|
||||
////WELLLLLLL we wish we could do that by names
|
||||
////but the shaders dont seem to be adequate quality (oddly named attributes.. texCoord vs texCoord1). need to use semantics instead.
|
||||
//foreach (var kvp in vertexLayout.Items)
|
||||
//{
|
||||
// string name = kvp.Value.Name;
|
||||
// //if (mapVariables)
|
||||
// //{
|
||||
// // foreach (var sw in sws)
|
||||
// // {
|
||||
// // if (sw.MapNativeToCode.ContainsKey(name))
|
||||
// // {
|
||||
// // name = sw.MapNativeToCode[name];
|
||||
// // break;
|
||||
// // }
|
||||
// // }
|
||||
// //}
|
||||
|
||||
// if(mapVariables) {
|
||||
// ////proxy for came-from-cgc
|
||||
// //switch (kvp.Value.Usage)
|
||||
// //{
|
||||
// // case AttributeUsage.Position:
|
||||
// //}
|
||||
// }
|
||||
|
||||
// //GL.BindAttribLocation(pid, kvp.Key, name);
|
||||
//}
|
||||
|
||||
|
||||
GL.LinkProgram(pid);
|
||||
errcode = GL.GetError();
|
||||
|
@ -231,45 +272,51 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
//set the program to active, in case we need to set sampler uniforms on it
|
||||
GL.UseProgram(pid);
|
||||
|
||||
////get all the attributes (not needed)
|
||||
//List<AttributeInfo> attributes = new List<AttributeInfo>();
|
||||
//int nAttributes;
|
||||
//GL.GetProgram(pid, GetProgramParameterName.ActiveAttributes, out nAttributes);
|
||||
//for (int i = 0; i < nAttributes; i++)
|
||||
//{
|
||||
// int size, length;
|
||||
// var sbName = new System.Text.StringBuilder();
|
||||
// ActiveAttribType type;
|
||||
// GL.GetActiveAttrib(pid, i, 1024, out length, out size, out type, sbName);
|
||||
// attributes.Add(new AttributeInfo() { Handle = new IntPtr(i), Name = sbName.ToString() });
|
||||
//}
|
||||
//get all the attributes (not needed)
|
||||
List<AttributeInfo> attributes = new List<AttributeInfo>();
|
||||
int nAttributes;
|
||||
GL.GetProgram(pid, GetProgramParameterName.ActiveAttributes, out nAttributes);
|
||||
for (int i = 0; i < nAttributes; i++)
|
||||
{
|
||||
int size, length;
|
||||
var sbName = new System.Text.StringBuilder(1024);
|
||||
ActiveAttribType type;
|
||||
GL.GetActiveAttrib(pid, i, 1024, out length, out size, out type, sbName);
|
||||
attributes.Add(new AttributeInfo() { Handle = new IntPtr(i), Name = sbName.ToString() });
|
||||
}
|
||||
|
||||
//get all the uniforms
|
||||
List<UniformInfo> uniforms = new List<UniformInfo>();
|
||||
int nUniforms;
|
||||
int nSamplers = 0;
|
||||
GL.GetProgram(pid,GetProgramParameterName.ActiveUniforms,out nUniforms);
|
||||
List<int> samplers = new List<int>();
|
||||
|
||||
for (int i = 0; i < nUniforms; i++)
|
||||
{
|
||||
int size, length;
|
||||
ActiveUniformType type;
|
||||
var sbName = new System.Text.StringBuilder();
|
||||
var sbName = new System.Text.StringBuilder(1024);
|
||||
GL.GetActiveUniform(pid, i, 1024, out length, out size, out type, sbName);
|
||||
errcode = GL.GetError();
|
||||
string name = sbName.ToString();
|
||||
int loc = GL.GetUniformLocation(pid, name);
|
||||
|
||||
//translate name if appropriate
|
||||
//not sure how effective this approach will be, due to confusion of vertex and fragment uniforms
|
||||
if (mapVariables)
|
||||
{
|
||||
if (vsw.MapCodeToNative.ContainsKey(name)) name = vsw.MapCodeToNative[name];
|
||||
if (fsw.MapCodeToNative.ContainsKey(name)) name = fsw.MapCodeToNative[name];
|
||||
}
|
||||
|
||||
var ui = new UniformInfo();
|
||||
ui.Name = name;
|
||||
ui.Handle = new IntPtr(loc);
|
||||
ui.Opaque = loc;
|
||||
|
||||
//automatically assign sampler uniforms to texture units (and bind them)
|
||||
bool isSampler = (type == ActiveUniformType.Sampler2D);
|
||||
if (isSampler)
|
||||
if (type == ActiveUniformType.Sampler2D)
|
||||
{
|
||||
ui.SamplerIndex = nSamplers;
|
||||
GL.Uniform1(loc, nSamplers);
|
||||
nSamplers++;
|
||||
ui.Opaque = loc | (samplers.Count << 24);
|
||||
samplers.Add(loc);
|
||||
}
|
||||
|
||||
uniforms.Add(ui);
|
||||
|
@ -281,14 +328,55 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
if (!vertexShader.Available) success = false;
|
||||
if (!fragmentShader.Available) success = false;
|
||||
|
||||
return new Pipeline(this, new IntPtr(pid), success, vertexLayout, uniforms);
|
||||
var pw = new PipelineWrapper() { pid = pid, VertexShader = vertexShader, FragmentShader = fragmentShader, SamplerLocs = samplers };
|
||||
|
||||
return new Pipeline(this, pw, success, vertexLayout, uniforms, memo);
|
||||
}
|
||||
|
||||
public VertexLayout CreateVertexLayout() { return new VertexLayout(this, new IntPtr(0)); }
|
||||
|
||||
public void BindTexture2d(Texture2d tex)
|
||||
public void FreePipeline(Pipeline pipeline)
|
||||
{
|
||||
GL.BindTexture(TextureTarget.Texture2D, tex.Id.ToInt32());
|
||||
var pw = pipeline.Opaque as PipelineWrapper;
|
||||
GL.DeleteProgram(pw.pid);
|
||||
|
||||
pw.FragmentShader.Release();
|
||||
pw.VertexShader.Release();
|
||||
}
|
||||
|
||||
public void Internal_FreeShader(Shader shader)
|
||||
{
|
||||
GL.DeleteShader((int)shader.Opaque);
|
||||
}
|
||||
|
||||
public void BindPipeline(Pipeline pipeline)
|
||||
{
|
||||
_CurrPipeline = pipeline;
|
||||
|
||||
if (pipeline == null)
|
||||
{
|
||||
sStatePendingVertexLayout = null;
|
||||
GL.UseProgram(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pipeline.Available) throw new InvalidOperationException("Attempt to bind unavailable pipeline");
|
||||
sStatePendingVertexLayout = pipeline.VertexLayout;
|
||||
|
||||
var pw = pipeline.Opaque as PipelineWrapper;
|
||||
GL.UseProgram(pw.pid);
|
||||
|
||||
//this is dumb and confusing, but we have to bind physical sampler numbers to sampler variables.
|
||||
for (int i = 0; i < pw.SamplerLocs.Count; i++)
|
||||
{
|
||||
GL.Uniform1(pw.SamplerLocs[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public VertexLayout CreateVertexLayout() { return new VertexLayout(this, null); }
|
||||
|
||||
private void BindTexture2d(Texture2d tex)
|
||||
{
|
||||
GL.BindTexture(TextureTarget.Texture2D, (int)tex.Opaque);
|
||||
}
|
||||
|
||||
public void SetTextureWrapMode(Texture2d tex, bool clamp)
|
||||
|
@ -315,71 +403,67 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
GL.DrawArrays((global::OpenTK.Graphics.OpenGL.PrimitiveType)mode, first, count);
|
||||
}
|
||||
|
||||
public void BindPipeline(Pipeline pipeline)
|
||||
{
|
||||
if (pipeline == null)
|
||||
{
|
||||
sStatePendingVertexLayout = null;
|
||||
GL.UseProgram(0);
|
||||
return;
|
||||
}
|
||||
if (!pipeline.Available) throw new InvalidOperationException("Attempt to bind unavailable pipeline");
|
||||
sStatePendingVertexLayout = pipeline.VertexLayout;
|
||||
GL.UseProgram(pipeline.Id.ToInt32());
|
||||
}
|
||||
|
||||
public void SetPipelineUniform(PipelineUniform uniform, bool value)
|
||||
{
|
||||
GL.Uniform1(uniform.Id.ToInt32(), value ? 1 : 0);
|
||||
GL.Uniform1((int)uniform.Sole.Opaque, value ? 1 : 0);
|
||||
}
|
||||
|
||||
public unsafe void SetPipelineUniformMatrix(PipelineUniform uniform, Matrix4 mat, bool transpose)
|
||||
{
|
||||
GL.UniformMatrix4(uniform.Id.ToInt32(), 1, transpose, (float*)&mat);
|
||||
//GL.UniformMatrix4((int)uniform.Opaque, 1, transpose, (float*)&mat);
|
||||
GL.Uniform4((int)uniform.Sole.Opaque + 0, 1, (float*)&mat.Row0);
|
||||
GL.Uniform4((int)uniform.Sole.Opaque + 1, 1, (float*)&mat.Row1);
|
||||
GL.Uniform4((int)uniform.Sole.Opaque + 2, 1, (float*)&mat.Row2);
|
||||
GL.Uniform4((int)uniform.Sole.Opaque + 3, 1, (float*)&mat.Row3);
|
||||
}
|
||||
|
||||
public unsafe void SetPipelineUniformMatrix(PipelineUniform uniform, ref Matrix4 mat, bool transpose)
|
||||
{
|
||||
fixed(Matrix4* pMat = &mat)
|
||||
GL.UniformMatrix4(uniform.Id.ToInt32(), 1, transpose, (float*)pMat);
|
||||
GL.UniformMatrix4((int)uniform.Sole.Opaque, 1, transpose, (float*)pMat);
|
||||
}
|
||||
|
||||
public void SetPipelineUniform(PipelineUniform uniform, Vector4 value)
|
||||
{
|
||||
GL.Uniform4(uniform.Id.ToInt32(), value.X, value.Y, value.Z, value.W);
|
||||
GL.Uniform4((int)uniform.Sole.Opaque, value.X, value.Y, value.Z, value.W);
|
||||
}
|
||||
|
||||
public void SetPipelineUniform(PipelineUniform uniform, Vector2 value)
|
||||
{
|
||||
GL.Uniform2(uniform.Id.ToInt32(), value.X, value.Y);
|
||||
GL.Uniform2((int)uniform.Sole.Opaque, value.X, value.Y);
|
||||
}
|
||||
|
||||
public void SetPipelineUniform(PipelineUniform uniform, float value)
|
||||
{
|
||||
GL.Uniform1(uniform.Id.ToInt32(), value);
|
||||
if (uniform.Owner == null) return; //uniform was optimized out
|
||||
GL.Uniform1((int)uniform.Sole.Opaque, value);
|
||||
}
|
||||
|
||||
public unsafe void SetPipelineUniform(PipelineUniform uniform, Vector4[] values)
|
||||
{
|
||||
fixed (Vector4* pValues = &values[0])
|
||||
GL.Uniform4(uniform.Id.ToInt32(), values.Length, (float*)pValues);
|
||||
GL.Uniform4((int)uniform.Sole.Opaque, values.Length, (float*)pValues);
|
||||
}
|
||||
|
||||
public void SetPipelineUniformSampler(PipelineUniform uniform, IntPtr texHandle)
|
||||
public void SetPipelineUniformSampler(PipelineUniform uniform, Texture2d tex)
|
||||
{
|
||||
int n = ((int)uniform.Sole.Opaque)>>24;
|
||||
|
||||
//set the sampler index into the uniform first
|
||||
//now bind the texture
|
||||
if(sActiveTexture != uniform.SamplerIndex)
|
||||
if (sActiveTexture != n)
|
||||
{
|
||||
sActiveTexture = uniform.SamplerIndex;
|
||||
var selectedUnit = (TextureUnit)((int)TextureUnit.Texture0 + uniform.SamplerIndex);
|
||||
sActiveTexture = n;
|
||||
var selectedUnit = (TextureUnit)((int)TextureUnit.Texture0 + n);
|
||||
GL.ActiveTexture(selectedUnit);
|
||||
}
|
||||
GL.BindTexture(TextureTarget.Texture2D, texHandle.ToInt32());
|
||||
|
||||
//now bind the texture
|
||||
GL.BindTexture(TextureTarget.Texture2D, (int)tex.Opaque);
|
||||
}
|
||||
|
||||
public void TexParameter2d(TextureParameterName pname, int param)
|
||||
public void TexParameter2d(Texture2d tex, TextureParameterName pname, int param)
|
||||
{
|
||||
BindTexture2d(tex);
|
||||
GL.TexParameter(TextureTarget.Texture2D, (global::OpenTK.Graphics.OpenGL.TextureParameterName)pname, param);
|
||||
}
|
||||
|
||||
|
@ -397,13 +481,13 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
|
||||
public Texture2d CreateTexture(int width, int height)
|
||||
{
|
||||
IntPtr id = GenTexture();
|
||||
return new Texture2d(this, id, null, width, height);
|
||||
int id = GenTexture();
|
||||
return new Texture2d(this, id, width, height);
|
||||
}
|
||||
|
||||
public Texture2d WrapGLTexture2d(IntPtr glTexId, int width, int height)
|
||||
{
|
||||
return new Texture2d(this as IGL, glTexId, null, width, height);
|
||||
return new Texture2d(this as IGL, glTexId, width, height);
|
||||
}
|
||||
|
||||
public void LoadTextureData(Texture2d tex, BitmapBuffer bmp)
|
||||
|
@ -411,7 +495,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
sdi.BitmapData bmp_data = bmp.LockBits();
|
||||
try
|
||||
{
|
||||
GL.BindTexture(TextureTarget.Texture2D, tex.Id.ToInt32());
|
||||
GL.BindTexture(TextureTarget.Texture2D, (int)tex.Opaque);
|
||||
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, bmp.Width, bmp.Height, PixelFormat.Bgra, PixelType.UnsignedByte, bmp_data.Scan0);
|
||||
}
|
||||
finally
|
||||
|
@ -423,15 +507,15 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
public void FreeRenderTarget(RenderTarget rt)
|
||||
{
|
||||
rt.Texture2d.Dispose();
|
||||
GL.Ext.DeleteFramebuffer(rt.Id.ToInt32());
|
||||
GL.Ext.DeleteFramebuffer((int)rt.Opaque);
|
||||
}
|
||||
|
||||
public unsafe RenderTarget CreateRenderTarget(int w, int h)
|
||||
{
|
||||
//create a texture for it
|
||||
IntPtr texid = GenTexture();
|
||||
Texture2d tex = new Texture2d(this, texid, null, w, h);
|
||||
GL.BindTexture(TextureTarget.Texture2D,texid.ToInt32());
|
||||
int texid = GenTexture();
|
||||
Texture2d tex = new Texture2d(this, texid, w, h);
|
||||
GL.BindTexture(TextureTarget.Texture2D,texid);
|
||||
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, w, h, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
|
||||
tex.SetMagFilter(TextureMagFilter.Nearest);
|
||||
tex.SetMinFilter(TextureMinFilter.Nearest);
|
||||
|
@ -441,7 +525,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
GL.Ext.BindFramebuffer(FramebufferTarget.Framebuffer, fbid);
|
||||
|
||||
//bind the tex to the FBO
|
||||
GL.Ext.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, texid.ToInt32(), 0);
|
||||
GL.Ext.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, texid, 0);
|
||||
|
||||
//do something, I guess say which colorbuffers are used by the framebuffer
|
||||
DrawBuffersEnum* buffers = stackalloc DrawBuffersEnum[1];
|
||||
|
@ -454,32 +538,33 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
//since we're done configuring unbind this framebuffer, to return to the default
|
||||
GL.Ext.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
|
||||
|
||||
return new RenderTarget(this, new IntPtr(fbid), tex);
|
||||
return new RenderTarget(this, fbid, tex);
|
||||
}
|
||||
|
||||
public void BindRenderTarget(RenderTarget rt)
|
||||
{
|
||||
_CurrRenderTarget = rt;
|
||||
if(rt == null)
|
||||
GL.Ext.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
|
||||
else
|
||||
GL.Ext.BindFramebuffer(FramebufferTarget.Framebuffer, rt.Id.ToInt32());
|
||||
GL.Ext.BindFramebuffer(FramebufferTarget.Framebuffer, (int)rt.Opaque);
|
||||
}
|
||||
|
||||
public Texture2d LoadTexture(BitmapBuffer bmp)
|
||||
{
|
||||
Texture2d ret = null;
|
||||
IntPtr id = GenTexture();
|
||||
int id = GenTexture();
|
||||
try
|
||||
{
|
||||
ret = new Texture2d(this, id, null, bmp.Width, bmp.Height);
|
||||
GL.BindTexture(TextureTarget.Texture2D, id.ToInt32());
|
||||
ret = new Texture2d(this, id, bmp.Width, bmp.Height);
|
||||
GL.BindTexture(TextureTarget.Texture2D, id);
|
||||
//picking a color order that matches doesnt seem to help, any. maybe my driver is accelerating it, or maybe it isnt a big deal. but its something to study on another day
|
||||
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmp.Width, bmp.Height, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
|
||||
(this as IGL).LoadTextureData(ret, bmp);
|
||||
}
|
||||
catch
|
||||
{
|
||||
GL.DeleteTexture(id.ToInt32());
|
||||
GL.DeleteTexture(id);
|
||||
throw;
|
||||
}
|
||||
|
||||
|
@ -511,9 +596,9 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
return CreateGuiProjectionMatrix(new sd.Size(w, h));
|
||||
}
|
||||
|
||||
public Matrix4 CreateGuiViewMatrix(int w, int h)
|
||||
public Matrix4 CreateGuiViewMatrix(int w, int h, bool autoflip)
|
||||
{
|
||||
return CreateGuiViewMatrix(new sd.Size(w, h));
|
||||
return CreateGuiViewMatrix(new sd.Size(w, h), autoflip);
|
||||
}
|
||||
|
||||
public Matrix4 CreateGuiProjectionMatrix(sd.Size dims)
|
||||
|
@ -524,12 +609,22 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
return ret;
|
||||
}
|
||||
|
||||
public Matrix4 CreateGuiViewMatrix(sd.Size dims)
|
||||
public Matrix4 CreateGuiViewMatrix(sd.Size dims, bool autoflip)
|
||||
{
|
||||
Matrix4 ret = Matrix4.Identity;
|
||||
ret.M22 = -1.0f;
|
||||
ret.M41 = -(float)dims.Width * 0.5f; // -0.5f;
|
||||
ret.M42 = (float)dims.Height * 0.5f; // +0.5f;
|
||||
ret.M41 = -(float)dims.Width * 0.5f;
|
||||
ret.M42 = (float)dims.Height * 0.5f;
|
||||
if (autoflip)
|
||||
{
|
||||
if (_CurrRenderTarget == null) { }
|
||||
else
|
||||
{
|
||||
//flip as long as we're not a final render target
|
||||
ret.M22 = 1.0f;
|
||||
ret.M42 *= -1;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -537,6 +632,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
{
|
||||
GL.Viewport(x, y, width, height);
|
||||
GL.Scissor(x, y, width, height); //hack for mupen[rice]+intel: at least the rice plugin leaves the scissor rectangle scrambled, and we're trying to run it in the main graphics context for intel
|
||||
//BUT ALSO: new specifications.. viewport+scissor make sense together
|
||||
}
|
||||
|
||||
public void SetViewport(int width, int height)
|
||||
|
@ -571,17 +667,33 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
return glc;
|
||||
}
|
||||
|
||||
Shader CreateShader(ShaderType type, string source, bool required)
|
||||
Shader CreateShader(bool cg, ShaderType type, string source, string entry, bool required)
|
||||
{
|
||||
var sw = new ShaderWrapper();
|
||||
if (cg)
|
||||
{
|
||||
var cgc = new CGC();
|
||||
var results = cgc.Run(source, entry, type == ShaderType.FragmentShader ? "glslf" : "glslv");
|
||||
|
||||
if (!results.Succeeded)
|
||||
return new Shader(this, null, false);
|
||||
|
||||
source = results.Code;
|
||||
sw.MapCodeToNative = results.MapCodeToNative;
|
||||
sw.MapNativeToCode = results.MapNativeToCode;
|
||||
}
|
||||
|
||||
int sid = GL.CreateShader(type);
|
||||
bool ok = CompileShaderSimple(sid,source, required);
|
||||
bool ok = CompileShaderSimple(sid, source, required);
|
||||
if(!ok)
|
||||
{
|
||||
GL.DeleteShader(sid);
|
||||
sid = 0;
|
||||
}
|
||||
|
||||
return new Shader(this, new IntPtr(sid), ok);
|
||||
sw.sid = sid;
|
||||
|
||||
return new Shader(this, sw, ok);
|
||||
}
|
||||
|
||||
bool CompileShaderSimple(int sid, string source, bool required)
|
||||
|
@ -645,11 +757,53 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
|
||||
if (layout == null) return;
|
||||
|
||||
//disable all the client states.. a lot of overhead right now, to be sure
|
||||
GL.DisableClientState(ArrayCap.VertexArray);
|
||||
GL.DisableClientState(ArrayCap.ColorArray);
|
||||
for(int i=0;i<8;i++)
|
||||
GL.DisableVertexAttribArray(i);
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
GL.ClientActiveTexture(TextureUnit.Texture0 + i);
|
||||
GL.DisableClientState(ArrayCap.TextureCoordArray);
|
||||
}
|
||||
GL.ClientActiveTexture(TextureUnit.Texture0);
|
||||
|
||||
foreach (var kvp in layout.Items)
|
||||
{
|
||||
GL.VertexAttribPointer(kvp.Key, kvp.Value.Components, (VertexAttribPointerType)kvp.Value.AttribType, kvp.Value.Normalized, kvp.Value.Stride, new IntPtr(pData) + kvp.Value.Offset);
|
||||
GL.EnableVertexAttribArray(kvp.Key);
|
||||
currBindings.Add(kvp.Key);
|
||||
if(_CurrPipeline.Memo == "gui")
|
||||
{
|
||||
GL.VertexAttribPointer(kvp.Key, kvp.Value.Components, (VertexAttribPointerType)kvp.Value.AttribType, kvp.Value.Normalized, kvp.Value.Stride, new IntPtr(pData) + kvp.Value.Offset);
|
||||
GL.EnableVertexAttribArray(kvp.Key);
|
||||
currBindings.Add(kvp.Key);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var pw = _CurrPipeline.Opaque as PipelineWrapper;
|
||||
|
||||
//comment SNACKPANTS
|
||||
switch (kvp.Value.Usage)
|
||||
{
|
||||
case AttributeUsage.Position:
|
||||
GL.EnableClientState(ArrayCap.VertexArray);
|
||||
GL.VertexPointer(kvp.Value.Components,VertexPointerType.Float,kvp.Value.Stride,new IntPtr(pData) + kvp.Value.Offset);
|
||||
break;
|
||||
case AttributeUsage.Texcoord0:
|
||||
GL.ClientActiveTexture(TextureUnit.Texture0);
|
||||
GL.EnableClientState(ArrayCap.TextureCoordArray);
|
||||
GL.TexCoordPointer(kvp.Value.Components, TexCoordPointerType.Float, kvp.Value.Stride, new IntPtr(pData) + kvp.Value.Offset);
|
||||
break;
|
||||
case AttributeUsage.Texcoord1:
|
||||
GL.ClientActiveTexture(TextureUnit.Texture1);
|
||||
GL.EnableClientState(ArrayCap.TextureCoordArray);
|
||||
GL.TexCoordPointer(kvp.Value.Components, TexCoordPointerType.Float, kvp.Value.Stride, new IntPtr(pData) + kvp.Value.Offset);
|
||||
GL.ClientActiveTexture(TextureUnit.Texture0);
|
||||
break;
|
||||
case AttributeUsage.Color0:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -666,23 +820,23 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
|
||||
void CreateRenderStates()
|
||||
{
|
||||
_rsBlendNoneVerbatim = new MyBlendState(
|
||||
_rsBlendNoneVerbatim = new CacheBlendState(
|
||||
false,
|
||||
BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero,
|
||||
BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero);
|
||||
|
||||
_rsBlendNoneOpaque = new MyBlendState(
|
||||
|
||||
_rsBlendNoneOpaque = new CacheBlendState(
|
||||
false,
|
||||
BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero,
|
||||
BlendingFactorSrc.ConstantAlpha, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero);
|
||||
|
||||
_rsBlendNormal = new MyBlendState(
|
||||
|
||||
_rsBlendNormal = new CacheBlendState(
|
||||
true,
|
||||
BlendingFactorSrc.SrcAlpha, BlendEquationMode.FuncAdd, BlendingFactorDest.OneMinusSrcAlpha,
|
||||
BlendingFactorSrc.One, BlendEquationMode.FuncAdd, BlendingFactorDest.Zero);
|
||||
}
|
||||
|
||||
MyBlendState _rsBlendNoneVerbatim, _rsBlendNoneOpaque, _rsBlendNormal;
|
||||
CacheBlendState _rsBlendNoneVerbatim, _rsBlendNoneOpaque, _rsBlendNormal;
|
||||
|
||||
//state caches
|
||||
int sActiveTexture;
|
||||
|
|
|
@ -32,8 +32,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK
|
|||
|
||||
public void Dispose()
|
||||
{
|
||||
VertexLayout.Dispose();
|
||||
VertexLayout = null;
|
||||
Pipeline.Dispose();
|
||||
}
|
||||
|
||||
public void Bind()
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Extensions.cs" />
|
||||
<Compile Include="GLControlWrapper_SlimDX9.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
public static global::SlimDX.Matrix ToSlimDXMatrix(this OpenTK.Matrix4 m, bool transpose)
|
||||
{
|
||||
global::SlimDX.Matrix ret = new global::SlimDX.Matrix();
|
||||
ret.M11 = m.M11;
|
||||
ret.M12 = m.M12;
|
||||
ret.M13 = m.M13;
|
||||
ret.M14 = m.M14;
|
||||
ret.M21 = m.M21;
|
||||
ret.M22 = m.M22;
|
||||
ret.M23 = m.M23;
|
||||
ret.M24 = m.M24;
|
||||
ret.M31 = m.M31;
|
||||
ret.M32 = m.M32;
|
||||
ret.M33 = m.M33;
|
||||
ret.M34 = m.M34;
|
||||
ret.M41 = m.M41;
|
||||
ret.M42 = m.M42;
|
||||
ret.M43 = m.M43;
|
||||
ret.M44 = m.M44;
|
||||
|
||||
//could be optimized later into the above copies
|
||||
if (transpose)
|
||||
ret = global::SlimDX.Matrix.Transpose(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static global::SlimDX.Vector4 ToSlimDXVector4(this OpenTK.Vector4 v)
|
||||
{
|
||||
return new global::SlimDX.Vector4(v.X, v.Y, v.Z, v.W);
|
||||
}
|
||||
|
||||
public static global::SlimDX.Vector2 ToSlimDXVector2(this OpenTK.Vector2 v)
|
||||
{
|
||||
return new global::SlimDX.Vector2(v.X, v.Y);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -55,17 +55,17 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
|
|||
|
||||
public void Begin()
|
||||
{
|
||||
|
||||
sdx.BeginControl(this);
|
||||
}
|
||||
|
||||
public void End()
|
||||
{
|
||||
|
||||
sdx.EndControl(this);
|
||||
}
|
||||
|
||||
public void SwapBuffers()
|
||||
{
|
||||
|
||||
sdx.SwapControl(this);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
|
@ -18,15 +19,23 @@ using OpenTK;
|
|||
using OpenTK.Graphics;
|
||||
using gl=OpenTK.Graphics.OpenGL;
|
||||
|
||||
//todo - do a better job selecting shader model? base on caps somehow? try several and catch compilation exceptions (yuck, exceptions)
|
||||
|
||||
namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
|
||||
{
|
||||
|
||||
public class IGL_SlimDX9 : IGL
|
||||
{
|
||||
static Direct3D d3d;
|
||||
private Device dev;
|
||||
internal Device dev;
|
||||
INativeWindow OffscreenNativeWindow;
|
||||
|
||||
//rendering state
|
||||
IntPtr _pVertexData;
|
||||
RenderTarget _CurrRenderTarget;
|
||||
Pipeline _CurrPipeline;
|
||||
GLControlWrapper_SlimDX9 _CurrentControl;
|
||||
|
||||
public string API { get { return "D3D9"; } }
|
||||
|
||||
public IGL_SlimDX9()
|
||||
|
@ -41,6 +50,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
|
|||
OffscreenNativeWindow.ClientSize = new sd.Size(8, 8);
|
||||
|
||||
CreateDevice();
|
||||
CreateRenderStates();
|
||||
}
|
||||
|
||||
private void DestroyDevice()
|
||||
|
@ -79,89 +89,231 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
|
|||
|
||||
public void Clear(OpenTK.Graphics.OpenGL.ClearBufferMask mask)
|
||||
{
|
||||
ClearFlags flags = ClearFlags.None;
|
||||
if ((mask & gl.ClearBufferMask.ColorBufferBit) != 0) flags |= ClearFlags.Target;
|
||||
if ((mask & gl.ClearBufferMask.DepthBufferBit) != 0) flags |= ClearFlags.ZBuffer;
|
||||
if ((mask & gl.ClearBufferMask.StencilBufferBit) != 0) flags |= ClearFlags.Stencil;
|
||||
dev.Clear(flags, _clearColor, 0.0f, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int _clearColor;
|
||||
public void SetClearColor(sd.Color color)
|
||||
{
|
||||
_clearColor = color.ToArgb();
|
||||
}
|
||||
|
||||
public IBlendState CreateBlendState(gl.BlendingFactorSrc colorSource, gl.BlendEquationMode colorEquation, gl.BlendingFactorDest colorDest,
|
||||
gl.BlendingFactorSrc alphaSource, gl.BlendEquationMode alphaEquation, gl.BlendingFactorDest alphaDest)
|
||||
{
|
||||
return null;
|
||||
return new CacheBlendState(true, colorSource, colorEquation, colorDest, alphaSource, alphaEquation, alphaDest);
|
||||
}
|
||||
|
||||
public void SetClearColor(sd.Color color)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public unsafe void BindArrayData(void* pData)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void FreeTexture(Texture2d tex) {
|
||||
var dtex = tex.Opaque as d3d9.Texture;
|
||||
dtex.Dispose();
|
||||
var tw = tex.Opaque as TextureWrapper;
|
||||
tw.Texture.Dispose();
|
||||
}
|
||||
public IntPtr GetEmptyHandle() { return new IntPtr(0); }
|
||||
public IntPtr GetEmptyUniformHandle() { return new IntPtr(-1); }
|
||||
|
||||
class ShaderWrapper
|
||||
class ShaderWrapper : IDisposable
|
||||
{
|
||||
public d3d9.ConstantTable ct;
|
||||
public d3d9.ShaderBytecode bytecode;
|
||||
public d3d9.VertexShader vs;
|
||||
public d3d9.PixelShader ps;
|
||||
public Shader IGLShader;
|
||||
public Dictionary<string, string> MapCodeToNative;
|
||||
public Dictionary<string, string> MapNativeToCode;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
vs.Dispose();
|
||||
vs = null;
|
||||
ps.Dispose();
|
||||
bytecode.Dispose();
|
||||
bytecode = null;
|
||||
}
|
||||
}
|
||||
|
||||
public Shader CreateFragmentShader(string source, bool required)
|
||||
public Shader CreateFragmentShader(bool cg, string source, string entry, bool required)
|
||||
{
|
||||
ShaderWrapper sw = new ShaderWrapper();
|
||||
string errors;
|
||||
using (var bytecode = d3d9.ShaderBytecode.Compile(source, null, null, "psmain", "ps_2_0", ShaderFlags.None, out errors))
|
||||
if (cg)
|
||||
{
|
||||
sw.ct = bytecode.ConstantTable;
|
||||
sw.ps = new PixelShader(dev, bytecode);
|
||||
var cgc = new CGC();
|
||||
var results = cgc.Run(source, entry, "hlslf");
|
||||
source = results.Code;
|
||||
entry = "main";
|
||||
if (!results.Succeeded)
|
||||
{
|
||||
if (required) throw new InvalidOperationException(results.Errors);
|
||||
else return new Shader(this, null, false);
|
||||
}
|
||||
|
||||
sw.MapCodeToNative = results.MapCodeToNative;
|
||||
sw.MapNativeToCode = results.MapNativeToCode;
|
||||
}
|
||||
|
||||
Shader s = new Shader(this, IntPtr.Zero, true);
|
||||
s.Opaque = sw;
|
||||
string errors = null;
|
||||
d3d9.ShaderBytecode bytecode = null;
|
||||
|
||||
try
|
||||
{
|
||||
//cgc can create shaders that will need backwards compatibility...
|
||||
bytecode = d3d9.ShaderBytecode.Compile(source, null, null, entry, "ps_3_0", ShaderFlags.EnableBackwardsCompatibility, out errors);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
throw new InvalidOperationException("Error compiling shader: " + errors, ex);
|
||||
}
|
||||
|
||||
sw.ps = new PixelShader(dev, bytecode);
|
||||
sw.bytecode = bytecode;
|
||||
|
||||
Shader s = new Shader(this, sw, true);
|
||||
sw.IGLShader = s;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
public Shader CreateVertexShader(string source, bool required)
|
||||
public Shader CreateVertexShader(bool cg, string source, string entry, bool required)
|
||||
{
|
||||
ShaderWrapper sw = new ShaderWrapper();
|
||||
string errors;
|
||||
using (var bytecode = d3d9.ShaderBytecode.Compile(source, null, null, "vsmain", "vs_2_0", ShaderFlags.None, out errors))
|
||||
if (cg)
|
||||
{
|
||||
sw.ct = bytecode.ConstantTable;
|
||||
sw.vs = new VertexShader(dev, bytecode);
|
||||
var cgc = new CGC();
|
||||
var results = cgc.Run(source, entry, "hlslv");
|
||||
source = results.Code;
|
||||
entry = "main";
|
||||
if (!results.Succeeded)
|
||||
{
|
||||
if (required) throw new InvalidOperationException(results.Errors);
|
||||
else return new Shader(this, null, false);
|
||||
}
|
||||
|
||||
sw.MapCodeToNative = results.MapCodeToNative;
|
||||
sw.MapNativeToCode = results.MapNativeToCode;
|
||||
}
|
||||
|
||||
Shader s = new Shader(this, IntPtr.Zero, true);
|
||||
s.Opaque = sw;
|
||||
string errors = null;
|
||||
d3d9.ShaderBytecode bytecode = null;
|
||||
|
||||
try
|
||||
{
|
||||
//cgc can create shaders that will need backwards compatibility...
|
||||
bytecode = d3d9.ShaderBytecode.Compile(source, null, null, entry, "vs_3_0", ShaderFlags.EnableBackwardsCompatibility, out errors);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new InvalidOperationException("Error compiling shader: " + errors, ex);
|
||||
}
|
||||
|
||||
sw.vs = new VertexShader(dev, bytecode);
|
||||
sw.bytecode = bytecode;
|
||||
|
||||
Shader s = new Shader(this, sw, true);
|
||||
sw.IGLShader = s;
|
||||
return s;
|
||||
}
|
||||
|
||||
public void FreeShader(IntPtr shader) { }
|
||||
BlendOperation ConvertBlendOp(gl.BlendEquationMode glmode)
|
||||
{
|
||||
if (glmode == gl.BlendEquationMode.FuncAdd) return BlendOperation.Add;
|
||||
if (glmode == gl.BlendEquationMode.FuncSubtract) return BlendOperation.Subtract;
|
||||
if (glmode == gl.BlendEquationMode.Max) return BlendOperation.Maximum;
|
||||
if (glmode == gl.BlendEquationMode.Min) return BlendOperation.Minimum;
|
||||
if (glmode == gl.BlendEquationMode.FuncReverseSubtract) return BlendOperation.ReverseSubtract;
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
Blend ConvertBlendArg(gl.BlendingFactorDest glmode) { return ConvertBlendArg((gl.BlendingFactorSrc)glmode); }
|
||||
|
||||
Blend ConvertBlendArg(gl.BlendingFactorSrc glmode)
|
||||
{
|
||||
if(glmode == gl.BlendingFactorSrc.Zero) return Blend.Zero;
|
||||
if(glmode == gl.BlendingFactorSrc.One) return Blend.One;
|
||||
if(glmode == gl.BlendingFactorSrc.SrcColor) return Blend.SourceColor;
|
||||
if(glmode == gl.BlendingFactorSrc.OneMinusSrcColor) return Blend.InverseSourceColor;
|
||||
if(glmode == gl.BlendingFactorSrc.SrcAlpha) return Blend.SourceAlpha;
|
||||
if(glmode == gl.BlendingFactorSrc.OneMinusSrcAlpha) return Blend.InverseSourceAlpha;
|
||||
if(glmode == gl.BlendingFactorSrc.DstAlpha) return Blend.DestinationAlpha;
|
||||
if(glmode == gl.BlendingFactorSrc.OneMinusDstAlpha) return Blend.InverseDestinationAlpha;
|
||||
if(glmode == gl.BlendingFactorSrc.DstColor) return Blend.DestinationColor;
|
||||
if(glmode == gl.BlendingFactorSrc.OneMinusDstColor) return Blend.InverseDestinationColor;
|
||||
if(glmode == gl.BlendingFactorSrc.SrcAlphaSaturate) return Blend.SourceAlphaSaturated;
|
||||
if(glmode == gl.BlendingFactorSrc.ConstantColorExt) throw new NotSupportedException();
|
||||
if(glmode == gl.BlendingFactorSrc.ConstantColor) return Blend.BlendFactor;
|
||||
if(glmode == gl.BlendingFactorSrc.OneMinusConstantColor) return Blend.InverseBlendFactor;
|
||||
if(glmode == gl.BlendingFactorSrc.OneMinusConstantColorExt) throw new NotSupportedException();
|
||||
if(glmode == gl.BlendingFactorSrc.ConstantAlpha) throw new NotSupportedException();
|
||||
if(glmode == gl.BlendingFactorSrc.ConstantAlphaExt) throw new NotSupportedException();
|
||||
if(glmode == gl.BlendingFactorSrc.OneMinusConstantAlphaExt) throw new NotSupportedException();
|
||||
if(glmode == gl.BlendingFactorSrc.OneMinusConstantAlpha) throw new NotSupportedException();
|
||||
if(glmode == gl.BlendingFactorSrc.Src1Alpha) throw new NotSupportedException();
|
||||
if(glmode == gl.BlendingFactorSrc.Src1Color) throw new NotSupportedException();
|
||||
if(glmode == gl.BlendingFactorSrc.OneMinusSrc1Color) throw new NotSupportedException();
|
||||
if (glmode == gl.BlendingFactorSrc.OneMinusSrc1Alpha) throw new NotSupportedException();
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
public void SetBlendState(IBlendState rsBlend)
|
||||
{
|
||||
//TODO for real
|
||||
|
||||
var mybs = rsBlend as CacheBlendState;
|
||||
if (mybs.Enabled)
|
||||
{
|
||||
dev.SetRenderState(RenderState.AlphaBlendEnable, true);
|
||||
dev.SetRenderState(RenderState.SeparateAlphaBlendEnable, true);
|
||||
|
||||
dev.SetRenderState(RenderState.BlendOperation, ConvertBlendOp(mybs.colorEquation));
|
||||
dev.SetRenderState(RenderState.SourceBlend, ConvertBlendArg(mybs.colorSource));
|
||||
dev.SetRenderState(RenderState.DestinationBlend, ConvertBlendArg(mybs.colorDest));
|
||||
|
||||
dev.SetRenderState(RenderState.BlendOperationAlpha, ConvertBlendOp(mybs.alphaEquation));
|
||||
dev.SetRenderState(RenderState.SourceBlendAlpha, ConvertBlendArg(mybs.alphaSource));
|
||||
dev.SetRenderState(RenderState.DestinationBlendAlpha, ConvertBlendArg(mybs.alphaDest));
|
||||
}
|
||||
else dev.SetRenderState(RenderState.AlphaBlendEnable, false);
|
||||
if (rsBlend == _rsBlendNoneOpaque)
|
||||
{
|
||||
//make sure constant color is set correctly
|
||||
dev.SetRenderState(RenderState.BlendFactor, -1); //white
|
||||
}
|
||||
}
|
||||
|
||||
class MyBlendState : IBlendState { }
|
||||
static MyBlendState _rsBlendNoneOpaque = new MyBlendState(), _rsBlendNoneVerbatim = new MyBlendState(), _rsBlendNormal = new MyBlendState();
|
||||
void CreateRenderStates()
|
||||
{
|
||||
_rsBlendNoneVerbatim = new CacheBlendState(
|
||||
false,
|
||||
gl.BlendingFactorSrc.One, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.Zero,
|
||||
gl.BlendingFactorSrc.One, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.Zero);
|
||||
|
||||
_rsBlendNoneOpaque = new CacheBlendState(
|
||||
false,
|
||||
gl.BlendingFactorSrc.One, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.Zero,
|
||||
gl.BlendingFactorSrc.ConstantAlpha, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.Zero);
|
||||
|
||||
_rsBlendNormal = new CacheBlendState(
|
||||
true,
|
||||
gl.BlendingFactorSrc.SrcAlpha, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.OneMinusSrcAlpha,
|
||||
gl.BlendingFactorSrc.One, gl.BlendEquationMode.FuncAdd, gl.BlendingFactorDest.Zero);
|
||||
}
|
||||
|
||||
CacheBlendState _rsBlendNoneVerbatim, _rsBlendNoneOpaque, _rsBlendNormal;
|
||||
|
||||
public IBlendState BlendNoneCopy { get { return _rsBlendNoneVerbatim; } }
|
||||
public IBlendState BlendNoneOpaque { get { return _rsBlendNoneOpaque; } }
|
||||
public IBlendState BlendNormal { get { return _rsBlendNormal; } }
|
||||
|
||||
public Pipeline CreatePipeline(VertexLayout vertexLayout, Shader vertexShader, Shader fragmentShader, bool required)
|
||||
public Pipeline CreatePipeline(VertexLayout vertexLayout, Shader vertexShader, Shader fragmentShader, bool required, string memo)
|
||||
{
|
||||
if (!vertexShader.Available || !fragmentShader.Available)
|
||||
{
|
||||
if (required)
|
||||
throw new InvalidOperationException("Couldn't build required GL pipeline");
|
||||
else return new Pipeline(this, null, false, null, null,null);
|
||||
}
|
||||
|
||||
VertexElement[] ves = new VertexElement[vertexLayout.Items.Count];
|
||||
int stride = 0;
|
||||
foreach (var kvp in vertexLayout.Items)
|
||||
{
|
||||
var item = kvp.Value;
|
||||
|
@ -174,6 +326,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
|
|||
else if (item.Components == 3) decltype = DeclarationType.Float3;
|
||||
else if (item.Components == 4) decltype = DeclarationType.Float4;
|
||||
else throw new NotSupportedException();
|
||||
stride += 4 * item.Components;
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException();
|
||||
|
@ -203,86 +356,256 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
|
|||
ves[kvp.Key] = new VertexElement(0, (short)item.Offset, decltype, DeclarationMethod.Default, usage, usageIndex);
|
||||
}
|
||||
|
||||
var pw = new PipelineWrapper();
|
||||
pw.VertexDeclaration = new VertexDeclaration(dev, ves);
|
||||
|
||||
Pipeline pipeline = new Pipeline(this,IntPtr.Zero,true, vertexLayout, new List<UniformInfo>());
|
||||
pipeline.Opaque = pw;
|
||||
|
||||
return pipeline;
|
||||
var pw = new PipelineWrapper()
|
||||
{
|
||||
VertexDeclaration = new VertexDeclaration(dev, ves),
|
||||
VertexShader = vertexShader.Opaque as ShaderWrapper,
|
||||
FragmentShader = fragmentShader.Opaque as ShaderWrapper,
|
||||
VertexStride = stride,
|
||||
};
|
||||
|
||||
//scan uniforms from constant tables
|
||||
//handles must be disposed later (with the pipeline probably)
|
||||
var uniforms = new List<UniformInfo>();
|
||||
var fs = pw.FragmentShader;
|
||||
var vs = pw.VertexShader;
|
||||
var fsct = fs.bytecode.ConstantTable;
|
||||
var vsct = vs.bytecode.ConstantTable;
|
||||
foreach(var ct in new[]{fsct,vsct})
|
||||
{
|
||||
Queue<Tuple<string,EffectHandle>> todo = new Queue<Tuple<string,EffectHandle>>();
|
||||
int n = ct.Description.Constants;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
var handle = ct.GetConstant(null, i);
|
||||
todo.Enqueue(Tuple.Create("", handle));
|
||||
}
|
||||
|
||||
while(todo.Count != 0)
|
||||
{
|
||||
var tuple = todo.Dequeue();
|
||||
var prefix = tuple.Item1;
|
||||
var handle = tuple.Item2;
|
||||
var descr = ct.GetConstantDescription(handle);
|
||||
|
||||
//Console.WriteLine("D3D UNIFORM: " + descr.Name);
|
||||
|
||||
if (descr.StructMembers != 0)
|
||||
{
|
||||
string newprefix = prefix + descr.Name + ".";
|
||||
for (int j = 0; j < descr.StructMembers; j++)
|
||||
{
|
||||
var subhandle = ct.GetConstant(handle, j);
|
||||
todo.Enqueue(Tuple.Create(newprefix, subhandle));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
UniformInfo ui = new UniformInfo();
|
||||
UniformWrapper uw = new UniformWrapper();
|
||||
|
||||
ui.Opaque = uw;
|
||||
string name = prefix + descr.Name;
|
||||
|
||||
//mehhh not happy about this stuff
|
||||
if (fs.MapCodeToNative != null || vs.MapCodeToNative != null)
|
||||
{
|
||||
string key = name.TrimStart('$');
|
||||
if (descr.Rows != 1)
|
||||
key = key + "[0]";
|
||||
if (fs.MapCodeToNative != null && ct == fsct) if (fs.MapCodeToNative.ContainsKey(key)) name = fs.MapCodeToNative[key];
|
||||
if (vs.MapCodeToNative != null && ct == vsct) if (vs.MapCodeToNative.ContainsKey(key)) name = vs.MapCodeToNative[key];
|
||||
}
|
||||
|
||||
ui.Name = name;
|
||||
uw.Description = descr;
|
||||
uw.EffectHandle = handle;
|
||||
uw.FS = (ct == fsct);
|
||||
uw.CT = ct;
|
||||
if (descr.Type == ParameterType.Sampler2D)
|
||||
uw.SamplerIndex = descr.RegisterIndex;
|
||||
uniforms.Add(ui);
|
||||
}
|
||||
}
|
||||
|
||||
pw.fsct = fsct;
|
||||
pw.vsct = vsct;
|
||||
|
||||
return new Pipeline(this, pw, true, vertexLayout, uniforms,memo);
|
||||
}
|
||||
|
||||
public void FreePipeline(Pipeline pipeline)
|
||||
{
|
||||
var pw = pipeline.Opaque as PipelineWrapper;
|
||||
|
||||
pw.FragmentShader.IGLShader.Release();
|
||||
pw.VertexShader.IGLShader.Release();
|
||||
}
|
||||
|
||||
public void Internal_FreeShader(Shader shader)
|
||||
{
|
||||
var sw = shader.Opaque as ShaderWrapper;
|
||||
sw.bytecode.Dispose();
|
||||
if (sw.ps != null) sw.ps.Dispose();
|
||||
if (sw.vs != null) sw.vs.Dispose();
|
||||
}
|
||||
|
||||
class UniformWrapper
|
||||
{
|
||||
public d3d9.EffectHandle EffectHandle;
|
||||
public d3d9.ConstantDescription Description;
|
||||
public bool FS;
|
||||
public d3d9.ConstantTable CT;
|
||||
public int SamplerIndex;
|
||||
}
|
||||
|
||||
class PipelineWrapper
|
||||
{
|
||||
public d3d9.VertexDeclaration VertexDeclaration;
|
||||
public ShaderWrapper VertexShader, FragmentShader;
|
||||
public int VertexStride;
|
||||
public d3d9.ConstantTable fsct, vsct;
|
||||
}
|
||||
|
||||
class TextureWrapper
|
||||
{
|
||||
public d3d9.Texture Texture;
|
||||
public TextureAddress WrapClamp = TextureAddress.Clamp;
|
||||
public TextureFilter MinFilter = TextureFilter.Point, MagFilter = TextureFilter.Point;
|
||||
}
|
||||
|
||||
public VertexLayout CreateVertexLayout() { return new VertexLayout(this, new IntPtr(0)); }
|
||||
|
||||
public void BindTexture2d(Texture2d tex)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void SetTextureWrapMode(Texture2d tex, bool clamp)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void DrawArrays(PrimitiveType mode, int first, int count)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void BindPipeline(Pipeline pipeline)
|
||||
{
|
||||
_CurrPipeline = pipeline;
|
||||
|
||||
if (pipeline == null)
|
||||
{
|
||||
//unbind? i dont know
|
||||
return;
|
||||
}
|
||||
|
||||
var pw = pipeline.Opaque as PipelineWrapper;
|
||||
dev.PixelShader = pw.FragmentShader.ps;
|
||||
dev.VertexShader = pw.VertexShader.vs;
|
||||
dev.VertexDeclaration = pw.VertexDeclaration;
|
||||
|
||||
//not helpful...
|
||||
//pw.vsct.SetDefaults(dev);
|
||||
//pw.fsct.SetDefaults(dev);
|
||||
}
|
||||
|
||||
public void SetPipelineUniform(PipelineUniform uniform, bool value)
|
||||
{
|
||||
if (uniform.Owner == null) return; //uniform was optimized out
|
||||
|
||||
foreach (var ui in uniform.UniformInfos)
|
||||
{
|
||||
var uw = ui.Opaque as UniformWrapper;
|
||||
uw.CT.SetValue(dev, uw.EffectHandle, value);
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe void SetPipelineUniformMatrix(PipelineUniform uniform, Matrix4 mat, bool transpose)
|
||||
{
|
||||
if (uniform.Owner == null) return; //uniform was optimized out
|
||||
|
||||
foreach (var ui in uniform.UniformInfos)
|
||||
{
|
||||
var uw = ui.Opaque as UniformWrapper;
|
||||
uw.CT.SetValue(dev, uw.EffectHandle, mat.ToSlimDXMatrix(!transpose));
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe void SetPipelineUniformMatrix(PipelineUniform uniform, ref Matrix4 mat, bool transpose)
|
||||
{
|
||||
if (uniform.Owner == null) return; //uniform was optimized out
|
||||
|
||||
foreach (var ui in uniform.UniformInfos)
|
||||
{
|
||||
var uw = ui.Opaque as UniformWrapper;
|
||||
uw.CT.SetValue(dev, uw.EffectHandle, mat.ToSlimDXMatrix(!transpose));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPipelineUniform(PipelineUniform uniform, Vector4 value)
|
||||
{
|
||||
if (uniform.Owner == null) return; //uniform was optimized out
|
||||
|
||||
foreach (var ui in uniform.UniformInfos)
|
||||
{
|
||||
var uw = ui.Opaque as UniformWrapper;
|
||||
uw.CT.SetValue(dev, uw.EffectHandle, value.ToSlimDXVector4());
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPipelineUniform(PipelineUniform uniform, Vector2 value)
|
||||
{
|
||||
if (uniform.Owner == null) return; //uniform was optimized out
|
||||
|
||||
foreach (var ui in uniform.UniformInfos)
|
||||
{
|
||||
var uw = ui.Opaque as UniformWrapper;
|
||||
uw.CT.SetValue(dev, uw.EffectHandle, value.ToSlimDXVector2());
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPipelineUniform(PipelineUniform uniform, float value)
|
||||
{
|
||||
if (uniform.Owner == null) return; //uniform was optimized out
|
||||
foreach (var ui in uniform.UniformInfos)
|
||||
{
|
||||
var uw = ui.Opaque as UniformWrapper;
|
||||
uw.CT.SetValue(dev, uw.EffectHandle, value);
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe void SetPipelineUniform(PipelineUniform uniform, Vector4[] values)
|
||||
{
|
||||
if (uniform.Owner == null) return; //uniform was optimized out
|
||||
var v = new global::SlimDX.Vector4[values.Length];
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
v[i] = values[i].ToSlimDXVector4();
|
||||
foreach (var ui in uniform.UniformInfos)
|
||||
{
|
||||
var uw = ui.Opaque as UniformWrapper;
|
||||
uw.CT.SetValue(dev, uw.EffectHandle, v);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPipelineUniformSampler(PipelineUniform uniform, IntPtr texHandle)
|
||||
public void SetPipelineUniformSampler(PipelineUniform uniform, Texture2d tex)
|
||||
{
|
||||
if (uniform.Owner == null) return; //uniform was optimized out
|
||||
var tw = tex.Opaque as TextureWrapper;
|
||||
|
||||
foreach (var ui in uniform.UniformInfos)
|
||||
{
|
||||
var uw = ui.Opaque as UniformWrapper;
|
||||
dev.SetTexture(uw.SamplerIndex, tw.Texture);
|
||||
|
||||
dev.SetSamplerState(uw.SamplerIndex, SamplerState.AddressU, tw.WrapClamp);
|
||||
dev.SetSamplerState(uw.SamplerIndex, SamplerState.AddressV, tw.WrapClamp);
|
||||
dev.SetSamplerState(uw.SamplerIndex, SamplerState.MinFilter, tw.MinFilter);
|
||||
dev.SetSamplerState(uw.SamplerIndex, SamplerState.MagFilter, tw.MagFilter);
|
||||
}
|
||||
}
|
||||
|
||||
public void TexParameter2d(gl.TextureParameterName pname, int param)
|
||||
public void SetTextureWrapMode(Texture2d tex, bool clamp)
|
||||
{
|
||||
//if (CurrentBoundTexture == null)
|
||||
// return;
|
||||
var tw = tex.Opaque as TextureWrapper;
|
||||
tw.WrapClamp = clamp ? TextureAddress.Clamp : TextureAddress.Wrap;
|
||||
}
|
||||
|
||||
//TextureWrapper tw = TextureWrapperForTexture(CurrentBoundTexture);
|
||||
//if (pname == TextureParameterName.TextureMinFilter)
|
||||
// tw.MinFilter = (TextureMinFilter)param;
|
||||
//if (pname == TextureParameterName.TextureMagFilter)
|
||||
// tw.MagFilter = (TextureMagFilter)param;
|
||||
public void TexParameter2d(Texture2d tex, gl.TextureParameterName pname, int param)
|
||||
{
|
||||
var tw = tex.Opaque as TextureWrapper;
|
||||
|
||||
if(pname == gl.TextureParameterName.TextureMinFilter)
|
||||
tw.MinFilter = (param == (int)gl.TextureMinFilter.Linear) ? TextureFilter.Linear : TextureFilter.Point;
|
||||
if (pname == gl.TextureParameterName.TextureMagFilter)
|
||||
tw.MagFilter = (param == (int)gl.TextureMagFilter.Linear) ? TextureFilter.Linear : TextureFilter.Point;
|
||||
}
|
||||
|
||||
public Texture2d LoadTexture(sd.Bitmap bitmap)
|
||||
|
@ -304,19 +627,25 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
|
|||
|
||||
public Texture2d WrapGLTexture2d(IntPtr glTexId, int width, int height)
|
||||
{
|
||||
//not needed 1st pass (except for GL cores)
|
||||
//TODO - need to rip the texturedata. we had code for that somewhere...
|
||||
return null;
|
||||
}
|
||||
|
||||
public void LoadTextureData(Texture2d tex, BitmapBuffer bmp)
|
||||
public unsafe void LoadTextureData(Texture2d tex, BitmapBuffer bmp)
|
||||
{
|
||||
sdi.BitmapData bmp_data = bmp.LockBits();
|
||||
d3d9.Texture dtex = tex.Opaque as d3d9.Texture;
|
||||
var dr = dtex.LockRectangle(0, LockFlags.None);
|
||||
|
||||
var tw = tex.Opaque as TextureWrapper;
|
||||
var dr = tw.Texture.LockRectangle(0, LockFlags.None);
|
||||
|
||||
//TODO - do we need to handle odd sizes, weird pitches here?
|
||||
dr.Data.WriteRange(bmp_data.Scan0, bmp.Width * bmp.Height);
|
||||
dtex.UnlockRectangle(0);
|
||||
if (bmp.Width * 4 != bmp_data.Stride)
|
||||
throw new InvalidOperationException();
|
||||
|
||||
dr.Data.WriteRange(bmp_data.Scan0, bmp.Width * bmp.Height * 4);
|
||||
dr.Data.Close();
|
||||
|
||||
tw.Texture.UnlockRectangle(0);
|
||||
bmp.UnlockBits(bmp_data);
|
||||
}
|
||||
|
||||
|
@ -324,19 +653,34 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
|
|||
public Texture2d LoadTexture(BitmapBuffer bmp)
|
||||
{
|
||||
var tex = new d3d9.Texture(dev, bmp.Width, bmp.Height, 1, d3d9.Usage.None, d3d9.Format.A8R8G8B8, d3d9.Pool.Managed);
|
||||
var ret = new Texture2d(this, IntPtr.Zero, tex, bmp.Width, bmp.Height);
|
||||
var tw = new TextureWrapper() { Texture = tex };
|
||||
var ret = new Texture2d(this, tw, bmp.Width, bmp.Height);
|
||||
LoadTextureData(ret, bmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public unsafe BitmapBuffer ResolveTexture2d(Texture2d tex)
|
||||
{
|
||||
//todo
|
||||
return null;
|
||||
//TODO - lazy create and cache resolving target in RT
|
||||
var target = new d3d9.Texture(dev, tex.IntWidth, tex.IntHeight, 1, d3d9.Usage.None, d3d9.Format.A8R8G8B8, d3d9.Pool.SystemMemory);
|
||||
var tw = tex.Opaque as TextureWrapper;
|
||||
dev.GetRenderTargetData(tw.Texture.GetSurfaceLevel(0), target.GetSurfaceLevel(0));
|
||||
var dr = target.LockRectangle(0, LockFlags.ReadOnly);
|
||||
if (dr.Pitch != tex.IntWidth * 4) throw new InvalidOperationException();
|
||||
int[] pixels = new int[tex.IntWidth * tex.IntHeight];
|
||||
dr.Data.ReadRange(pixels, 0, tex.IntWidth * tex.IntHeight);
|
||||
var bb = new BitmapBuffer(tex.IntWidth, tex.IntHeight, pixels);
|
||||
target.UnlockRectangle(0);
|
||||
target.Dispose(); //buffer churn warning
|
||||
|
||||
//TEMPORARY until flipping is sorted out
|
||||
bb.YFlip();
|
||||
return bb;
|
||||
}
|
||||
|
||||
public Texture2d LoadTexture(string path)
|
||||
{
|
||||
//not needed 1st pass ??
|
||||
//todo
|
||||
//using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
// return (this as IGL).LoadTexture(fs);
|
||||
|
@ -348,9 +692,9 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
|
|||
return CreateGuiProjectionMatrix(new sd.Size(w, h));
|
||||
}
|
||||
|
||||
public Matrix4 CreateGuiViewMatrix(int w, int h)
|
||||
public Matrix4 CreateGuiViewMatrix(int w, int h, bool autoflip)
|
||||
{
|
||||
return CreateGuiViewMatrix(new sd.Size(w, h));
|
||||
return CreateGuiViewMatrix(new sd.Size(w, h), autoflip);
|
||||
}
|
||||
|
||||
public Matrix4 CreateGuiProjectionMatrix(sd.Size dims)
|
||||
|
@ -361,21 +705,25 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
|
|||
return ret;
|
||||
}
|
||||
|
||||
public Matrix4 CreateGuiViewMatrix(sd.Size dims)
|
||||
public Matrix4 CreateGuiViewMatrix(sd.Size dims, bool autoflip)
|
||||
{
|
||||
Matrix4 ret = Matrix4.Identity;
|
||||
ret.M22 = -1.0f;
|
||||
ret.M41 = -(float)dims.Width * 0.5f; // -0.5f;
|
||||
ret.M42 = (float)dims.Height * 0.5f; // +0.5f;
|
||||
ret.M41 = -(float)dims.Width * 0.5f - 0.5f;
|
||||
ret.M42 = (float)dims.Height * 0.5f + 0.5f;
|
||||
//autoflipping isnt needed on d3d
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void SetViewport(int x, int y, int width, int height)
|
||||
{
|
||||
dev.Viewport = new Viewport(x, y, width, height);
|
||||
dev.ScissorRect = new Rectangle(x, y, width, height);
|
||||
}
|
||||
|
||||
public void SetViewport(int width, int height)
|
||||
{
|
||||
SetViewport(0, 0, width, height);
|
||||
}
|
||||
|
||||
public void SetViewport(sd.Size size)
|
||||
|
@ -385,55 +733,62 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
|
|||
|
||||
public void SetViewport(swf.Control control)
|
||||
{
|
||||
|
||||
var r = control.ClientRectangle;
|
||||
SetViewport(r.Left, r.Top, r.Width, r.Height);
|
||||
}
|
||||
|
||||
|
||||
public void BeginControl(GLControlWrapper_SlimDX9 control)
|
||||
{
|
||||
|
||||
_CurrentControl = control;
|
||||
dev.SetRenderTarget(0, control.SwapChain.GetBackBuffer(0));
|
||||
}
|
||||
|
||||
public void EndControl(GLControlWrapper_SlimDX9 control)
|
||||
{
|
||||
|
||||
if (control != _CurrentControl)
|
||||
throw new InvalidOperationException();
|
||||
|
||||
_CurrentControl = null;
|
||||
}
|
||||
|
||||
public void SwapControl(GLControlWrapper_SlimDX9 control)
|
||||
{
|
||||
control.SwapChain.Present(Present.None);
|
||||
}
|
||||
|
||||
public void FreeRenderTarget(RenderTarget rt)
|
||||
{
|
||||
//not needed 1st pass ??
|
||||
//int id = rt.Id.ToInt32();
|
||||
//var rtw = ResourceIDs.Lookup[id] as RenderTargetWrapper;
|
||||
//rtw.Target.Dispose();
|
||||
//ResourceIDs.Free(rt.Id);
|
||||
}
|
||||
|
||||
public unsafe RenderTarget CreateRenderTarget(int w, int h)
|
||||
public RenderTarget CreateRenderTarget(int w, int h)
|
||||
{
|
||||
//Texture2d tex = null;
|
||||
//var rt = new RenderTarget(this, ResourceIDs.Alloc(ResourceIdManager.EResourceType.RenderTarget), tex);
|
||||
//int id = rt.Id.ToInt32();
|
||||
//RenderTargetWrapper rtw = new RenderTargetWrapper(this);
|
||||
//rtw.Target = rt;
|
||||
//ResourceIDs.Lookup[id] = rtw;
|
||||
//return rt;
|
||||
return null;
|
||||
var d3dtex = new d3d9.Texture(dev, w, h, 1, d3d9.Usage.RenderTarget, d3d9.Format.A8R8G8B8, d3d9.Pool.Default);
|
||||
var tw = new TextureWrapper() { Texture = d3dtex };
|
||||
var tex = new Texture2d(this, tw, w, h);
|
||||
RenderTarget rt = new RenderTarget(this, tw, tex);
|
||||
return rt;
|
||||
}
|
||||
|
||||
public void BindRenderTarget(RenderTarget rt)
|
||||
{
|
||||
//if (rt == null)
|
||||
//{
|
||||
// //null means to use the default RT for the current control
|
||||
// CurrentRenderTargetWrapper = CurrentControl.RenderTargetWrapper;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// CurrentRenderTargetWrapper = RenderTargetWrapperForRt(rt);
|
||||
//}
|
||||
_CurrRenderTarget = rt;
|
||||
|
||||
if (rt == null)
|
||||
{
|
||||
dev.SetRenderTarget(0, _CurrentControl.SwapChain.GetBackBuffer(0));
|
||||
dev.DepthStencilSurface = null;
|
||||
return;
|
||||
}
|
||||
|
||||
var tw = rt.Opaque as TextureWrapper;
|
||||
//TODO - cache surface level in an RT wrapper
|
||||
dev.SetRenderTarget(0, tw.Texture.GetSurfaceLevel(0));
|
||||
dev.DepthStencilSurface = null;
|
||||
}
|
||||
|
||||
public void RefreshControlSwapChain(GLControlWrapper_SlimDX9 control)
|
||||
|
@ -465,10 +820,44 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX
|
|||
return ret;
|
||||
}
|
||||
|
||||
public void DrawArrays(gl.PrimitiveType mode, int first, int count)
|
||||
public unsafe void DrawArrays(gl.PrimitiveType mode, int first, int count)
|
||||
{
|
||||
PrimitiveType pt = PrimitiveType.TriangleStrip;
|
||||
|
||||
if(mode != gl.PrimitiveType.TriangleStrip)
|
||||
throw new NotSupportedException();
|
||||
|
||||
//for tristrip
|
||||
int primCount = (count - 2);
|
||||
|
||||
var pw = _CurrPipeline.Opaque as PipelineWrapper;
|
||||
int stride = pw.VertexStride;
|
||||
byte* ptr = (byte*)_pVertexData.ToPointer() + first * stride;
|
||||
|
||||
dev.DrawUserPrimitives(pt, primCount, (void*)ptr, (uint)stride);
|
||||
}
|
||||
|
||||
|
||||
public unsafe void BindArrayData(void* pData)
|
||||
{
|
||||
_pVertexData = new IntPtr(pData);
|
||||
}
|
||||
|
||||
public void BeginScene()
|
||||
{
|
||||
dev.BeginScene();
|
||||
dev.SetRenderState(RenderState.CullMode, Cull.None);
|
||||
dev.SetRenderState(RenderState.ZEnable, false);
|
||||
dev.SetRenderState(RenderState.ZWriteEnable, false);
|
||||
dev.SetRenderState(RenderState.Lighting, false);
|
||||
}
|
||||
|
||||
public void EndScene()
|
||||
{
|
||||
dev.EndScene();
|
||||
}
|
||||
|
||||
|
||||
|
||||
} //class IGL_SlimDX
|
||||
|
||||
|
|
|
@ -81,6 +81,30 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
UnlockBits(CurrLock);
|
||||
}
|
||||
|
||||
public unsafe void YFlip()
|
||||
{
|
||||
//TODO - could be faster
|
||||
var bmpdata = LockBits();
|
||||
int[] newPixels = new int[Width * Height];
|
||||
int todo = Width * Height;
|
||||
int* s = (int*)bmpdata.Scan0.ToPointer();
|
||||
fixed (int* d = newPixels)
|
||||
{
|
||||
for (int y = 0, si = 0, di = (Height - 1) * Width; y < Height; y++)
|
||||
{
|
||||
for (int x = 0; x < Width; x++, si++, di++)
|
||||
{
|
||||
d[di] = s[si];
|
||||
}
|
||||
di -= Width * 2;
|
||||
}
|
||||
}
|
||||
|
||||
UnlockBits(bmpdata);
|
||||
|
||||
Pixels = newPixels;
|
||||
}
|
||||
|
||||
public unsafe void Normalize(bool yflip)
|
||||
{
|
||||
var bmpdata = LockBits();
|
||||
|
@ -214,7 +238,7 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// loads an image from the specified stream
|
||||
/// loads an image (png,bmp,etc) from the specified stream
|
||||
/// </summary>
|
||||
public BitmapBuffer(Stream stream, BitmapLoadOptions options)
|
||||
{
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
<Compile Include="Borrowed\BitmapFontParser\Kerning.cs" />
|
||||
<Compile Include="Borrowed\BitmapFontParser\Padding.cs" />
|
||||
<Compile Include="Borrowed\BitmapFontParser\Page.cs" />
|
||||
<Compile Include="CGC.cs" />
|
||||
<Compile Include="Extensions.cs" />
|
||||
<Compile Include="GraphicsControl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
|
@ -79,6 +80,7 @@
|
|||
<Compile Include="RetainedGraphicsControl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="RetroShader.cs" />
|
||||
<Compile Include="Shader.cs" />
|
||||
<Compile Include="StringRenderer.cs" />
|
||||
<Compile Include="TexAtlas.cs" />
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
//todo - be able to run out of PATH too
|
||||
|
||||
namespace BizHawk.Bizware.BizwareGL
|
||||
{
|
||||
public class CGC
|
||||
{
|
||||
public CGC()
|
||||
{
|
||||
}
|
||||
|
||||
public static string CGCBinPath;
|
||||
|
||||
private static string[] Escape(IEnumerable<string> args)
|
||||
{
|
||||
return args.Select(s => s.Contains(" ") ? string.Format("\"{0}\"", s) : s).ToArray();
|
||||
}
|
||||
|
||||
public class Results
|
||||
{
|
||||
public bool Succeeded;
|
||||
public string Code, Errors;
|
||||
public Dictionary<string, string> MapCodeToNative = new Dictionary<string, string>();
|
||||
public Dictionary<string, string> MapNativeToCode = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
public Results Run(string code, string entry, string profile)
|
||||
{
|
||||
//version=110; GLSL generates old fashioned semantic attributes and not generic attributes
|
||||
string[] args = new[]{"-profile", profile, "-entry", entry, "-po", "version=110"};
|
||||
|
||||
args = Escape(args);
|
||||
StringBuilder sbCmdline = new StringBuilder();
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
{
|
||||
sbCmdline.Append(args[i]);
|
||||
if (i != args.Length - 1) sbCmdline.Append(' ');
|
||||
}
|
||||
|
||||
//http://stackoverflow.com/questions/139593/processstartinfo-hanging-on-waitforexit-why
|
||||
using (Process proc = new Process())
|
||||
{
|
||||
proc.StartInfo.UseShellExecute = false;
|
||||
proc.StartInfo.CreateNoWindow = true;
|
||||
proc.StartInfo.RedirectStandardInput = true;
|
||||
proc.StartInfo.RedirectStandardOutput = true;
|
||||
proc.StartInfo.RedirectStandardError = true;
|
||||
proc.StartInfo.Arguments = sbCmdline.ToString();
|
||||
proc.StartInfo.FileName = CGCBinPath;
|
||||
|
||||
StringBuilder output = new StringBuilder(), error = new StringBuilder();
|
||||
|
||||
using (AutoResetEvent outputWaitHandle = new AutoResetEvent(false))
|
||||
using (AutoResetEvent errorWaitHandle = new AutoResetEvent(false))
|
||||
{
|
||||
proc.OutputDataReceived += (sender, e) =>
|
||||
{
|
||||
if (e.Data == null) outputWaitHandle.Set();
|
||||
else output.AppendLine(e.Data);
|
||||
};
|
||||
proc.ErrorDataReceived += (sender, e) =>
|
||||
{
|
||||
if (e.Data == null) errorWaitHandle.Set();
|
||||
else error.AppendLine(e.Data);
|
||||
};
|
||||
|
||||
|
||||
proc.Start();
|
||||
new Thread(() =>
|
||||
{
|
||||
proc.StandardInput.AutoFlush = true;
|
||||
proc.StandardInput.Write(code);
|
||||
proc.StandardInput.Flush();
|
||||
proc.StandardInput.Close();
|
||||
}).Start();
|
||||
|
||||
proc.BeginOutputReadLine();
|
||||
proc.BeginErrorReadLine();
|
||||
proc.WaitForExit();
|
||||
outputWaitHandle.WaitOne();
|
||||
errorWaitHandle.WaitOne();
|
||||
}
|
||||
|
||||
bool ok = (proc.ExitCode == 0);
|
||||
|
||||
var ret = new Results()
|
||||
{
|
||||
Succeeded = ok,
|
||||
Code = output.ToString(),
|
||||
Errors = error.ToString()
|
||||
};
|
||||
|
||||
if (!ok)
|
||||
Console.WriteLine(ret.Errors);
|
||||
|
||||
//make variable name map
|
||||
//loop until the first line that doesnt start with a comment
|
||||
var reader = new StringReader(ret.Code);
|
||||
for(;;)
|
||||
{
|
||||
var line = reader.ReadLine();
|
||||
if (line == null) break;
|
||||
if (!line.StartsWith("//")) break;
|
||||
if (!line.StartsWith("//var")) continue;
|
||||
var parts = line.Split(':');
|
||||
var native_name = parts[0].Split(' ')[2];
|
||||
var code_name = parts[1].Trim();
|
||||
if (code_name.StartsWith("TEXUNIT")) code_name = ""; //need parsing differently
|
||||
if (code_name == "")
|
||||
code_name = parts[2].Trim();
|
||||
//remove some array indicators. example: `modelViewProj1[0], 4`
|
||||
code_name = code_name.Split(',')[0];
|
||||
code_name = code_name.Split(' ')[0];
|
||||
if (code_name != "")
|
||||
{
|
||||
ret.MapCodeToNative[code_name] = native_name;
|
||||
ret.MapNativeToCode[native_name] = code_name;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BizHawk.Bizware.BizwareGL
|
||||
{
|
||||
|
||||
}
|
|
@ -12,6 +12,8 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
{
|
||||
public GraphicsControl(IGL owner)
|
||||
{
|
||||
IGL = owner;
|
||||
|
||||
SetStyle(ControlStyles.Opaque, true);
|
||||
SetStyle(ControlStyles.UserPaint, true);
|
||||
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
|
@ -44,6 +46,8 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
OnPaint(e);
|
||||
}
|
||||
|
||||
public readonly IGL IGL;
|
||||
|
||||
IGraphicsControl IGC;
|
||||
Control Managed;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ using System;
|
|||
using System.Diagnostics;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using sd=System.Drawing;
|
||||
using sd = System.Drawing;
|
||||
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
@ -47,9 +47,9 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
psProgram = DefaultPixelShader_gl;
|
||||
}
|
||||
|
||||
var vs = Owner.CreateVertexShader(vsProgram, true);
|
||||
var ps = Owner.CreateFragmentShader(psProgram, true);
|
||||
CurrPipeline = DefaultPipeline = Owner.CreatePipeline(VertexLayout, vs, ps, true);
|
||||
var vs = Owner.CreateVertexShader(false, vsProgram, "vsmain", true);
|
||||
var ps = Owner.CreateFragmentShader(false, psProgram, "psmain", true);
|
||||
CurrPipeline = DefaultPipeline = Owner.CreatePipeline(VertexLayout, vs, ps, true, "xgui");
|
||||
}
|
||||
|
||||
OpenTK.Graphics.Color4[] CornerColors = new OpenTK.Graphics.Color4[4] {
|
||||
|
@ -63,7 +63,7 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
CornerColors[which] = color;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void SetCornerColors(OpenTK.Graphics.Color4[] colors)
|
||||
{
|
||||
Flush(); //dont really need to flush with current implementation. we might as well roll modulate color into it too.
|
||||
|
@ -74,13 +74,9 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
|
||||
public void Dispose()
|
||||
{
|
||||
VertexLayout.Dispose();
|
||||
VertexLayout = null;
|
||||
DefaultPipeline.Dispose();
|
||||
DefaultPipeline = null;
|
||||
}
|
||||
|
||||
|
||||
public void SetPipeline(Pipeline pipeline)
|
||||
{
|
||||
if (IsActive)
|
||||
|
@ -112,9 +108,9 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
|
||||
public void SetBlendState(IBlendState rsBlend)
|
||||
{
|
||||
#if DEBUG
|
||||
#if DEBUG
|
||||
BlendStateSet = true;
|
||||
#endif
|
||||
#endif
|
||||
Flush();
|
||||
Owner.SetBlendState(rsBlend);
|
||||
}
|
||||
|
@ -148,12 +144,12 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
Projection = Owner.CreateGuiProjectionMatrix(width, height);
|
||||
Modelview = Owner.CreateGuiViewMatrix(width, height);
|
||||
|
||||
if (yflipped)
|
||||
{
|
||||
//not sure this is the best way to do it. could be done in the view matrix creation
|
||||
Modelview.Scale(1, -1);
|
||||
Modelview.Translate(0, -height);
|
||||
}
|
||||
//if (yflipped)
|
||||
//{
|
||||
// //not sure this is the best way to do it. could be done in the view matrix creation
|
||||
// Modelview.Scale(1, -1);
|
||||
// Modelview.Translate(0, -height);
|
||||
//}
|
||||
Owner.SetViewport(width, height);
|
||||
}
|
||||
|
||||
|
@ -162,9 +158,9 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
{
|
||||
//uhhmmm I want to throw an exception if its already active, but its annoying.
|
||||
|
||||
if(CurrPipeline == null)
|
||||
if (CurrPipeline == null)
|
||||
throw new InvalidOperationException("Pipeline hasn't been set!");
|
||||
|
||||
|
||||
IsActive = true;
|
||||
Owner.BindPipeline(CurrPipeline);
|
||||
|
||||
|
@ -175,9 +171,9 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
Projection.Clear();
|
||||
SetModulateColorWhite();
|
||||
|
||||
#if DEBUG
|
||||
BlendStateSet = false;
|
||||
#endif
|
||||
#if DEBUG
|
||||
BlendStateSet = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -240,15 +236,18 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
art.u0 = art.v0 = 0;
|
||||
art.u1 = art.v1 = 1;
|
||||
art.BaseTexture = tex;
|
||||
DrawInternal(art,x,y,w,h,false,tex.IsUpsideDown);
|
||||
DrawInternal(art, x, y, w, h, false, tex.IsUpsideDown);
|
||||
}
|
||||
|
||||
unsafe void DrawInternal(Art art, float x, float y, float w, float h, bool fx, bool fy)
|
||||
{
|
||||
float u0,v0,u1,v1;
|
||||
if(fx) { u0 = art.u1; u1 = art.u0; }
|
||||
//TEST: d3d shouldnt ever use this, it was a gl hack. maybe we can handle it some other way in gl (fix the projection? take a render-to-texture arg to the gui view transforms?)
|
||||
fy = false;
|
||||
|
||||
float u0, v0, u1, v1;
|
||||
if (fx) { u0 = art.u1; u1 = art.u0; }
|
||||
else { u0 = art.u0; u1 = art.u1; }
|
||||
if(fy) { v0 = art.v1; v1 = art.v0; }
|
||||
if (fy) { v0 = art.v1; v1 = art.v0; }
|
||||
else { v0 = art.v0; v1 = art.v1; }
|
||||
|
||||
float[] data = new float[32] {
|
||||
|
@ -259,7 +258,7 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
};
|
||||
|
||||
Texture2d tex = art.BaseTexture;
|
||||
|
||||
|
||||
PrepDrawSubrectInternal(tex);
|
||||
|
||||
fixed (float* pData = &data[0])
|
||||
|
@ -287,12 +286,12 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
|
||||
if (_Projection.IsDirty)
|
||||
{
|
||||
CurrPipeline["um44Projection"].Set(ref _Projection.Top);
|
||||
CurrPipeline["um44Projection"].Set(ref _Projection.Top, false);
|
||||
_Projection.IsDirty = false;
|
||||
}
|
||||
if (_Modelview.IsDirty)
|
||||
{
|
||||
CurrPipeline["um44Modelview"].Set(ref _Modelview.Top);
|
||||
CurrPipeline["um44Modelview"].Set(ref _Modelview.Top, false);
|
||||
_Modelview.IsDirty = false;
|
||||
}
|
||||
}
|
||||
|
@ -336,9 +335,9 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
Owner.BindArrayData(pData);
|
||||
Owner.DrawArrays(PrimitiveType.TriangleStrip, 0, 4);
|
||||
|
||||
#if DEBUG
|
||||
#if DEBUG
|
||||
Debug.Assert(BlendStateSet);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
unsafe void DrawSubrectInternal(Texture2d tex, float x, float y, float w, float h, float u0, float v0, float u1, float v1)
|
||||
|
@ -346,7 +345,7 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
PrepDrawSubrectInternal(tex);
|
||||
EmitRectangleInternal(x, y, w, h, u0, v0, u1, v1);
|
||||
}
|
||||
|
||||
|
||||
public bool IsActive { get; private set; }
|
||||
public IGL Owner { get; private set; }
|
||||
|
||||
|
@ -355,17 +354,20 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
|
||||
//state cache
|
||||
Texture2d sTexture;
|
||||
#if DEBUG
|
||||
bool BlendStateSet;
|
||||
#endif
|
||||
#if DEBUG
|
||||
bool BlendStateSet;
|
||||
#endif
|
||||
|
||||
//shaders are hand-coded for each platform to make sure they stay as fast as possible
|
||||
|
||||
public readonly string DefaultShader_d3d9 = @"
|
||||
public readonly string DefaultShader_d3d9 = @"
|
||||
//vertex shader uniforms
|
||||
float4x4 um44Modelview, um44Projection;
|
||||
float4 uModulateColor;
|
||||
|
||||
//pixel shader uniforms
|
||||
bool uSamplerEnable;
|
||||
texture2D texture0;
|
||||
texture2D texture0, texture1;
|
||||
sampler uSampler0 = sampler_state { Texture = (texture0); };
|
||||
|
||||
struct VS_INPUT
|
||||
|
@ -392,7 +394,7 @@ VS_OUTPUT vsmain(VS_INPUT src)
|
|||
{
|
||||
VS_OUTPUT dst;
|
||||
float4 temp = float4(src.aPosition,0,1);
|
||||
dst.vPosition = mul(mul(temp,um44Modelview),um44Projection);
|
||||
dst.vPosition = mul(um44Projection,mul(um44Modelview,temp));
|
||||
dst.vTexcoord0 = src.aTexcoord;
|
||||
dst.vCornerColor = src.aColor * uModulateColor;
|
||||
return dst;
|
||||
|
@ -411,9 +413,12 @@ float4 psmain(PS_INPUT src) : COLOR
|
|||
uniform mat4 um44Modelview, um44Projection;
|
||||
uniform vec4 uModulateColor;
|
||||
|
||||
attribute vec2 aPosition;
|
||||
attribute vec2 aTexcoord;
|
||||
attribute vec4 aColor;
|
||||
//attribute vec2 aPosition : gl_Vertex;
|
||||
//attribute vec2 aTexcoord : gl_MultiTexCoord0;
|
||||
//attribute vec4 aColor : gl_Color;
|
||||
#define aPosition vec2(gl_Vertex.xy)
|
||||
#define aTexcoord vec2(gl_MultiTexCoord0.xy)
|
||||
#define aColor gl_Color
|
||||
|
||||
varying vec2 vTexcoord0;
|
||||
varying vec4 vCornerColor;
|
||||
|
|
|
@ -22,7 +22,6 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
/// <summary>
|
||||
/// Clears the specified buffer parts
|
||||
/// </summary>
|
||||
/// <param name="mask"></param>
|
||||
void Clear(ClearBufferMask mask);
|
||||
|
||||
/// <summary>
|
||||
|
@ -30,30 +29,20 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
/// </summary>
|
||||
void SetClearColor(Color color);
|
||||
|
||||
/// <summary>
|
||||
/// returns an empty handle
|
||||
/// </summary>
|
||||
IntPtr GetEmptyHandle();
|
||||
|
||||
/// <summary>
|
||||
/// returns an empty uniform handle
|
||||
/// </summary>
|
||||
IntPtr GetEmptyUniformHandle();
|
||||
|
||||
/// <summary>
|
||||
/// compile a fragment shader. This is the simplified method. A more complex method may be added later which will accept multiple sources and preprocessor definitions independently
|
||||
/// </summary>
|
||||
Shader CreateFragmentShader(string source, bool required);
|
||||
Shader CreateFragmentShader(bool cg, string source, string entry, bool required);
|
||||
|
||||
/// <summary>
|
||||
/// compile a vertex shader. This is the simplified method. A more complex method may be added later which will accept multiple sources and preprocessor definitions independently
|
||||
/// </summary>
|
||||
Shader CreateVertexShader(string source, bool required);
|
||||
Shader CreateVertexShader(bool cg, string source, string entry, bool required);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a complete pipeline from the provided vertex and fragment shader handles
|
||||
/// </summary>
|
||||
Pipeline CreatePipeline(VertexLayout vertexLayout, Shader vertexShader, Shader fragmentShader, bool required);
|
||||
Pipeline CreatePipeline(VertexLayout vertexLayout, Shader vertexShader, Shader fragmentShader, bool required, string memo);
|
||||
|
||||
/// <summary>
|
||||
/// Binds this pipeline as the current used for rendering
|
||||
|
@ -61,9 +50,9 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
void BindPipeline(Pipeline pipeline);
|
||||
|
||||
/// <summary>
|
||||
/// Sets a uniform sampler to use use the provided texture handle
|
||||
/// Sets a uniform sampler to use use the provided texture
|
||||
/// </summary>
|
||||
void SetPipelineUniformSampler(PipelineUniform uniform, IntPtr texHandle);
|
||||
void SetPipelineUniformSampler(PipelineUniform uniform, Texture2d tex);
|
||||
|
||||
/// <summary>
|
||||
/// Sets a uniform value
|
||||
|
@ -101,44 +90,35 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
void SetPipelineUniform(PipelineUniform uniform, bool value);
|
||||
|
||||
/// <summary>
|
||||
/// Binds array data for use with the currently-bound VertexLayout
|
||||
/// Binds array data for use with the currently-bound pipeline's VertexLayout
|
||||
/// </summary>
|
||||
unsafe void BindArrayData(void* pData);
|
||||
|
||||
/// <summary>
|
||||
/// Draws based on the currently set VertexLayout and ArrayData
|
||||
/// Begins a rendering scene; use before doing any draw calls, as per normal
|
||||
/// </summary>
|
||||
void BeginScene();
|
||||
|
||||
/// <summary>
|
||||
/// Indicates end of scene rendering; use after alldraw calls as per normal
|
||||
/// </summary>
|
||||
void EndScene();
|
||||
|
||||
/// <summary>
|
||||
/// Draws based on the currently set pipeline, VertexLayout and ArrayData.
|
||||
/// Count is the VERT COUNT not the primitive count
|
||||
/// </summary>
|
||||
void DrawArrays(PrimitiveType mode, int first, int count);
|
||||
|
||||
/// <summary>
|
||||
/// Frees the provided shader handle
|
||||
/// </summary>
|
||||
void FreeShader(IntPtr shader);
|
||||
|
||||
/// <summary>
|
||||
/// frees the provided texture
|
||||
/// </summary>
|
||||
void FreeTexture(Texture2d tex);
|
||||
|
||||
/// <summary>
|
||||
/// resolves the texture into a new BitmapBuffer
|
||||
/// </summary>
|
||||
BitmapBuffer ResolveTexture2d(Texture2d texture);
|
||||
|
||||
/// <summary>
|
||||
/// frees the provided render target
|
||||
/// </summary>
|
||||
void FreeRenderTarget(RenderTarget rt);
|
||||
|
||||
/// <summary>
|
||||
/// Binds this texture as the current texture2d target for parameter-specification
|
||||
/// </summary>
|
||||
void BindTexture2d(Texture2d texture);
|
||||
|
||||
/// <summary>
|
||||
/// Sets a 2d texture parameter
|
||||
/// </summary>
|
||||
void TexParameter2d(TextureParameterName pname, int param);
|
||||
void TexParameter2d(Texture2d texture, TextureParameterName pname, int param);
|
||||
|
||||
/// <summary>
|
||||
/// creates a vertex layout resource
|
||||
|
@ -187,7 +167,8 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
Texture2d WrapGLTexture2d(IntPtr glTexId, int width, int height);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the clamp mode (for both uv) for the Texture2d
|
||||
/// Sets the clamp mode (for both uv) for the Texture2d.
|
||||
/// The default is clamped=true.
|
||||
/// </summary>
|
||||
void SetTextureWrapMode(Texture2d tex, bool clamp);
|
||||
|
||||
|
@ -217,22 +198,22 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
Texture2d LoadTexture(Bitmap bitmap);
|
||||
|
||||
/// <summary>
|
||||
/// sets the viewport according to the provided specifications
|
||||
/// sets the viewport (and scissor) according to the provided specifications
|
||||
/// </summary>
|
||||
void SetViewport(int x, int y, int width, int height);
|
||||
|
||||
/// <summary>
|
||||
/// sets the viewport according to the provided specifications
|
||||
/// sets the viewport (and scissor) according to the provided specifications
|
||||
/// </summary>
|
||||
void SetViewport(int width, int height);
|
||||
|
||||
/// <summary>
|
||||
/// sets the viewport according to the client area of the provided control
|
||||
/// sets the viewport (and scissor) according to the client area of the provided control
|
||||
/// </summary>
|
||||
void SetViewport(swf.Control control);
|
||||
|
||||
/// <summary>
|
||||
/// sets the viewport according to the provided specifications
|
||||
/// sets the viewport (and scissor) according to the provided specifications
|
||||
/// </summary>
|
||||
void SetViewport(Size size);
|
||||
|
||||
|
@ -250,16 +231,16 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
/// generates a proper view transform for a standard 2d ortho projection, including half-pixel jitter if necessary and
|
||||
/// re-establishing of a normal 2d graphics top-left origin. suitable for use in a GUI
|
||||
/// </summary>
|
||||
Matrix4 CreateGuiViewMatrix(int w, int h);
|
||||
Matrix4 CreateGuiViewMatrix(int w, int h, bool autoflip = true);
|
||||
|
||||
/// <summary>
|
||||
/// generates a proper view transform for a standard 2d ortho projection, including half-pixel jitter if necessary and
|
||||
/// re-establishing of a normal 2d graphics top-left origin. suitable for use in a GUI
|
||||
/// </summary>
|
||||
Matrix4 CreateGuiViewMatrix(Size dims);
|
||||
Matrix4 CreateGuiViewMatrix(Size dims, bool autoflip = true);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a render target. Includes a color buffer. Pixel format control TBD
|
||||
/// Creates a render target. Only includes a color buffer. Pixel format control TBD
|
||||
/// </summary>
|
||||
RenderTarget CreateRenderTarget(int w, int h);
|
||||
|
||||
|
@ -268,11 +249,31 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
/// </summary>
|
||||
void BindRenderTarget(RenderTarget rt);
|
||||
|
||||
IGraphicsControl Internal_CreateGraphicsControl();
|
||||
|
||||
/// <summary>
|
||||
/// returns a string representing the API employed by this context
|
||||
/// </summary>
|
||||
string API { get; }
|
||||
|
||||
/// <summary>
|
||||
/// frees the provided render target. Same as disposing the resource.
|
||||
/// </summary>
|
||||
void FreeRenderTarget(RenderTarget rt);
|
||||
|
||||
/// <summary>
|
||||
/// frees the provided texture. Same as disposing the resource.
|
||||
/// </summary>
|
||||
void FreeTexture(Texture2d tex);
|
||||
|
||||
/// <summary>
|
||||
/// Frees the provided pipeline. Same as disposing the resource.
|
||||
/// </summary>
|
||||
void FreePipeline(Pipeline pipeline);
|
||||
|
||||
/// <summary>
|
||||
/// Frees the provided texture. For internal use only.
|
||||
/// </summary>
|
||||
void Internal_FreeShader(Shader shader);
|
||||
|
||||
IGraphicsControl Internal_CreateGraphicsControl();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BizHawk.Bizware.BizwareGL
|
||||
|
@ -8,24 +9,32 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
/// </summary>
|
||||
public class Pipeline : IDisposable
|
||||
{
|
||||
public Pipeline(IGL owner, IntPtr id, bool available, VertexLayout vertexLayout, IEnumerable<UniformInfo> uniforms)
|
||||
public string Memo;
|
||||
|
||||
public Pipeline(IGL owner, object opaque, bool available, VertexLayout vertexLayout, IEnumerable<UniformInfo> uniforms, string memo)
|
||||
{
|
||||
Memo = memo;
|
||||
Owner = owner;
|
||||
Id = id;
|
||||
Opaque = opaque;
|
||||
VertexLayout = vertexLayout;
|
||||
Available = available;
|
||||
|
||||
//create the uniforms from the info list we got
|
||||
if(!Available)
|
||||
return;
|
||||
|
||||
UniformsDictionary = new SpecialWorkingDictionary(this);
|
||||
foreach(var ui in uniforms)
|
||||
UniformsDictionary[ui.Name] = new PipelineUniform(this);
|
||||
foreach (var ui in uniforms)
|
||||
{
|
||||
UniformsDictionary[ui.Name] = new PipelineUniform(this, ui);
|
||||
UniformsDictionary[ui.Name].AddUniformInfo(ui);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Allows us to create PipelineUniforms on the fly, in case a non-existing one has been requested.
|
||||
/// GLSL will optimize out unused uniforms, and we wont have a record of it in the uniforms population loop
|
||||
/// Shader compilers will optimize out unused uniforms, and we wont have a record of it in the uniforms population loop
|
||||
/// </summary>
|
||||
class SpecialWorkingDictionary : Dictionary<string, PipelineUniform>
|
||||
{
|
||||
|
@ -43,8 +52,8 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
if (!TryGetValue(key, out temp))
|
||||
{
|
||||
var ui = new UniformInfo();
|
||||
ui.Handle = Owner.Owner.GetEmptyUniformHandle();
|
||||
temp = this[key] = new PipelineUniform(Owner,ui);
|
||||
ui.Opaque = null;
|
||||
temp = this[key] = new PipelineUniform(null);
|
||||
}
|
||||
|
||||
return temp;
|
||||
|
@ -66,16 +75,13 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
}
|
||||
|
||||
public IGL Owner { get; private set; }
|
||||
public IntPtr Id { get; private set; }
|
||||
public object Opaque { get; private set; }
|
||||
public VertexLayout VertexLayout { get; private set; }
|
||||
public bool Available { get; private set; }
|
||||
public object Opaque;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
//todo
|
||||
Owner.FreePipeline(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -5,61 +5,87 @@ using OpenTK;
|
|||
|
||||
namespace BizHawk.Bizware.BizwareGL
|
||||
{
|
||||
/// <summary>
|
||||
/// represents a pipeline uniform...
|
||||
/// and one of those can represent multiple shader uniforms!!
|
||||
/// </summary>
|
||||
public class PipelineUniform
|
||||
{
|
||||
internal PipelineUniform(Pipeline owner, UniformInfo info)
|
||||
internal PipelineUniform(Pipeline owner)
|
||||
{
|
||||
Owner = owner;
|
||||
Id = info.Handle;
|
||||
SamplerIndex = info.SamplerIndex;
|
||||
//Opaque = info.Opaque;
|
||||
//SamplerIndex = info.SamplerIndex;
|
||||
}
|
||||
|
||||
internal void AddUniformInfo(UniformInfo ui)
|
||||
{
|
||||
_UniformInfos.Add(ui);
|
||||
}
|
||||
|
||||
public IEnumerable<UniformInfo> UniformInfos { get { return _UniformInfos; } }
|
||||
List<UniformInfo> _UniformInfos = new List<UniformInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the sole UniformInfo or throws an exception if there's more than one
|
||||
/// </summary>
|
||||
public UniformInfo Sole
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_UniformInfos.Count != 1) throw new InvalidOperationException();
|
||||
return _UniformInfos[0];
|
||||
}
|
||||
}
|
||||
|
||||
public Pipeline Owner { get; private set; }
|
||||
public IntPtr Id { get; private set; }
|
||||
public int SamplerIndex { get; private set; }
|
||||
|
||||
|
||||
public void Set(Matrix4 mat, bool transpose = false)
|
||||
{
|
||||
if (Owner == null) return; //uniform was optimized out
|
||||
Owner.Owner.SetPipelineUniformMatrix(this, mat, transpose);
|
||||
}
|
||||
|
||||
public void Set(Vector4 vec)
|
||||
{
|
||||
if (Owner == null) return; //uniform was optimized out
|
||||
Owner.Owner.SetPipelineUniform(this, vec);
|
||||
}
|
||||
|
||||
public void Set(Vector2 vec)
|
||||
{
|
||||
if (Owner == null) return; //uniform was optimized out
|
||||
Owner.Owner.SetPipelineUniform(this, vec);
|
||||
}
|
||||
|
||||
public void Set(float f)
|
||||
{
|
||||
if (Owner == null) return; //uniform was optimized out
|
||||
Owner.Owner.SetPipelineUniform(this, f);
|
||||
}
|
||||
|
||||
public void Set(Vector4[] vecs)
|
||||
{
|
||||
if (Owner == null) return; //uniform was optimized out
|
||||
Owner.Owner.SetPipelineUniform(this, vecs);
|
||||
}
|
||||
|
||||
public void Set(ref Matrix4 mat, bool transpose = false)
|
||||
{
|
||||
if (Owner == null) return; //uniform was optimized out
|
||||
Owner.Owner.SetPipelineUniformMatrix(this, ref mat, transpose);
|
||||
}
|
||||
|
||||
public void Set(bool value)
|
||||
{
|
||||
if (Owner == null) return; //uniform was optimized out
|
||||
Owner.Owner.SetPipelineUniform(this, value);
|
||||
}
|
||||
|
||||
public void Set(Texture2d tex)
|
||||
{
|
||||
IntPtr handle;
|
||||
if (tex == null)
|
||||
handle = Owner.Owner.GetEmptyHandle();
|
||||
else handle = tex.Id;
|
||||
Owner.Owner.SetPipelineUniformSampler(this, handle);
|
||||
if (Owner == null) return; //uniform was optimized out
|
||||
Owner.Owner.SetPipelineUniformSampler(this, tex);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,4 +4,35 @@ using System.Collections.Generic;
|
|||
namespace BizHawk.Bizware.BizwareGL
|
||||
{
|
||||
public interface IBlendState { }
|
||||
|
||||
/// <summary>
|
||||
/// An IBlendState token that just caches all the args needed to create a blend state
|
||||
/// </summary>
|
||||
public class CacheBlendState : IBlendState
|
||||
{
|
||||
public bool Enabled;
|
||||
public global::OpenTK.Graphics.OpenGL.BlendingFactorSrc colorSource;
|
||||
public global::OpenTK.Graphics.OpenGL.BlendEquationMode colorEquation;
|
||||
public global::OpenTK.Graphics.OpenGL.BlendingFactorDest colorDest;
|
||||
public global::OpenTK.Graphics.OpenGL.BlendingFactorSrc alphaSource;
|
||||
public global::OpenTK.Graphics.OpenGL.BlendEquationMode alphaEquation;
|
||||
public global::OpenTK.Graphics.OpenGL.BlendingFactorDest alphaDest;
|
||||
|
||||
public CacheBlendState(bool enabled,
|
||||
global::OpenTK.Graphics.OpenGL.BlendingFactorSrc colorSource,
|
||||
global::OpenTK.Graphics.OpenGL.BlendEquationMode colorEquation,
|
||||
global::OpenTK.Graphics.OpenGL.BlendingFactorDest colorDest,
|
||||
global::OpenTK.Graphics.OpenGL.BlendingFactorSrc alphaSource,
|
||||
global::OpenTK.Graphics.OpenGL.BlendEquationMode alphaEquation,
|
||||
global::OpenTK.Graphics.OpenGL.BlendingFactorDest alphaDest)
|
||||
{
|
||||
this.Enabled = enabled;
|
||||
this.colorSource = (global::OpenTK.Graphics.OpenGL.BlendingFactorSrc)colorSource;
|
||||
this.colorEquation = (global::OpenTK.Graphics.OpenGL.BlendEquationMode)colorEquation;
|
||||
this.colorDest = (global::OpenTK.Graphics.OpenGL.BlendingFactorDest)colorDest;
|
||||
this.alphaSource = (global::OpenTK.Graphics.OpenGL.BlendingFactorSrc)alphaSource;
|
||||
this.alphaEquation = (global::OpenTK.Graphics.OpenGL.BlendEquationMode)alphaEquation;
|
||||
this.alphaDest = (global::OpenTK.Graphics.OpenGL.BlendingFactorDest)alphaDest;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,10 +5,10 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
{
|
||||
public class RenderTarget : IDisposable
|
||||
{
|
||||
public RenderTarget(IGL owner, IntPtr handle, Texture2d tex)
|
||||
public RenderTarget(IGL owner, object opaque, Texture2d tex)
|
||||
{
|
||||
Owner = owner;
|
||||
Id = handle;
|
||||
Opaque = opaque;
|
||||
Texture2d = tex;
|
||||
tex.IsUpsideDown = true;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
return string.Format("GL RT: {0}x{1}", Texture2d.Width, Texture2d.Height);
|
||||
}
|
||||
|
||||
public IntPtr Id { get; private set; }
|
||||
public object Opaque { get; private set; }
|
||||
public IGL Owner { get; private set; }
|
||||
public Texture2d Texture2d { get; private set; }
|
||||
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace BizHawk.Bizware.BizwareGL
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles RetroArch's GLSL shader pass format
|
||||
/// </summary>
|
||||
public class RetroShader : IDisposable
|
||||
{
|
||||
//NOTE: we may need to overhaul uniform-setting infrastructure later.
|
||||
//maybe samplers will need to be set by index and not by name (I think the specs dont dictate what the sampler must be named)
|
||||
|
||||
public RetroShader(IGL owner, string source, bool debug = false)
|
||||
{
|
||||
Owner = owner;
|
||||
|
||||
VertexLayout = owner.CreateVertexLayout();
|
||||
VertexLayout.DefineVertexAttribute("position", 0, 4, VertexAttribPointerType.Float, AttributeUsage.Position, false, 24, 0);
|
||||
VertexLayout.DefineVertexAttribute("texCoord1", 1, 2, VertexAttribPointerType.Float, AttributeUsage.Texcoord0, false, 24, 16);
|
||||
VertexLayout.Close();
|
||||
|
||||
string defines = "#define TEXCOORD TEXCOORD0\r\n"; //maybe not safe..
|
||||
string vsSource = "#define VERTEX\r\n" + defines + source;
|
||||
string psSource = "#define FRAGMENT\r\n" + defines + source;
|
||||
var vs = owner.CreateVertexShader(true, vsSource, "main_vertex", debug);
|
||||
var ps = owner.CreateFragmentShader(true, psSource, "main_fragment", debug);
|
||||
Pipeline = Owner.CreatePipeline(VertexLayout, vs, ps, debug, "retro");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Pipeline.Dispose();
|
||||
}
|
||||
|
||||
public void Bind()
|
||||
{
|
||||
//lame...
|
||||
Owner.BindPipeline(Pipeline);
|
||||
}
|
||||
|
||||
public unsafe void Run(Texture2d tex, Size InputSize, Size OutputSize, bool flip)
|
||||
{
|
||||
flip = false;
|
||||
//test
|
||||
|
||||
//ack! make sure to set the pipeline before setting uniforms
|
||||
Bind();
|
||||
|
||||
Pipeline["IN.video_size"].Set(new Vector2(InputSize.Width, InputSize.Height));
|
||||
Pipeline["IN.texture_size"].Set(new Vector2(tex.Width, tex.Height));
|
||||
Pipeline["IN.output_size"].Set(new Vector2(OutputSize.Width, OutputSize.Height));
|
||||
Pipeline["IN.frame_count"].Set(1); //todo
|
||||
Pipeline["IN.frame_direction"].Set(1); //todo
|
||||
|
||||
|
||||
var Projection = Owner.CreateGuiProjectionMatrix(OutputSize);
|
||||
var Modelview = Owner.CreateGuiViewMatrix(OutputSize);
|
||||
var mat = Modelview * Projection;
|
||||
mat.Transpose();
|
||||
Pipeline["modelViewProj"].Set(mat, true);
|
||||
|
||||
Owner.SetTextureWrapMode(tex, true);
|
||||
|
||||
Pipeline["s_p"].Set(tex);
|
||||
Owner.SetViewport(OutputSize);
|
||||
|
||||
int w = OutputSize.Width;
|
||||
int h = OutputSize.Height;
|
||||
float v0,v1;
|
||||
if (flip) { v0 = 1; v1 = 0; }
|
||||
else { v0 = 0; v1 = 1; }
|
||||
float* pData = stackalloc float[8*4];
|
||||
int i=0;
|
||||
pData[i++] = 0; pData[i++] = 0; pData[i++] = 0; pData[i++] = 1; //topleft vert
|
||||
pData[i++] = 0; pData[i++] = v0;
|
||||
pData[i++] = w; pData[i++] = 0; pData[i++] = 0; pData[i++] = 1; //topright vert
|
||||
pData[i++] = 1; pData[i++] = v0;
|
||||
pData[i++] = 0; pData[i++] = h; pData[i++] = 0; pData[i++] = 1; //bottomleft vert
|
||||
pData[i++] = 0; pData[i++] = v1;
|
||||
pData[i++] = w; pData[i++] = h; pData[i++] = 0; pData[i++] = 1; //bottomright vert
|
||||
pData[i++] = 1; pData[i++] = v1;
|
||||
|
||||
Owner.SetBlendState(Owner.BlendNoneCopy);
|
||||
Owner.BindArrayData(pData);
|
||||
Owner.DrawArrays(PrimitiveType.TriangleStrip, 0, 4);
|
||||
}
|
||||
|
||||
|
||||
public IGL Owner { get; private set; }
|
||||
|
||||
VertexLayout VertexLayout;
|
||||
public Pipeline Pipeline;
|
||||
}
|
||||
}
|
|
@ -4,29 +4,39 @@ using System.Collections.Generic;
|
|||
namespace BizHawk.Bizware.BizwareGL
|
||||
{
|
||||
/// <summary>
|
||||
/// Just a lifecycle-managed wrapper around shader handles
|
||||
/// Represents an individual (fragment,vertex) shader.
|
||||
/// It isnt IDisposable because itll be lifecycle-managed by the IGL (disposed when all dependent pipelines are disposed)
|
||||
/// But if you want to be sure to save it for later, use AddRef
|
||||
/// </summary>
|
||||
public class Shader : IDisposable
|
||||
public class Shader
|
||||
{
|
||||
public Shader(IGL owner, IntPtr id, bool available)
|
||||
public Shader(IGL owner, object opaque, bool available)
|
||||
{
|
||||
Owner = owner;
|
||||
Id = id;
|
||||
Opaque = opaque;
|
||||
Available = available;
|
||||
}
|
||||
|
||||
public IGL Owner { get; private set; }
|
||||
public IntPtr Id { get; private set; }
|
||||
public bool Disposed { get; private set; }
|
||||
public object Opaque { get; private set; }
|
||||
public bool Available { get; private set; }
|
||||
public object Opaque;
|
||||
|
||||
public void Dispose()
|
||||
int RefCount;
|
||||
|
||||
public void Release()
|
||||
{
|
||||
if (Disposed) return;
|
||||
Disposed = true;
|
||||
Owner.FreeShader(Id);
|
||||
Id = Owner.GetEmptyHandle();
|
||||
RefCount--;
|
||||
if (RefCount <= 0)
|
||||
{
|
||||
Owner.Internal_FreeShader(this);
|
||||
Available = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddRef()
|
||||
{
|
||||
RefCount++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -24,19 +24,18 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
public void Dispose()
|
||||
{
|
||||
Owner.FreeTexture(this);
|
||||
Id = Owner.GetEmptyHandle();
|
||||
Opaque = null;
|
||||
}
|
||||
|
||||
public Texture2d(IGL owner, IntPtr id, object opaque, int width, int height)
|
||||
public Texture2d(IGL owner, object opaque, int width, int height)
|
||||
{
|
||||
Owner = owner;
|
||||
Id = id;
|
||||
Opaque = opaque;
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("GL Tex: {0}x{1}", Width, Height);
|
||||
}
|
||||
|
@ -47,14 +46,12 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
|
||||
public void SetMinFilter(TextureMinFilter minFilter)
|
||||
{
|
||||
Owner.BindTexture2d(this);
|
||||
Owner.TexParameter2d(TextureParameterName.TextureMinFilter, (int)minFilter);
|
||||
Owner.TexParameter2d(this,TextureParameterName.TextureMinFilter, (int)minFilter);
|
||||
}
|
||||
|
||||
public void SetMagFilter(TextureMagFilter magFilter)
|
||||
{
|
||||
Owner.BindTexture2d(this);
|
||||
Owner.TexParameter2d(TextureParameterName.TextureMagFilter, (int)magFilter);
|
||||
Owner.TexParameter2d(this, TextureParameterName.TextureMagFilter, (int)magFilter);
|
||||
}
|
||||
|
||||
public void SetFilterLinear()
|
||||
|
@ -70,7 +67,6 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
}
|
||||
|
||||
public IGL Owner { get; private set; }
|
||||
public IntPtr Id { get; private set; }
|
||||
public object Opaque { get; private set; }
|
||||
|
||||
//note.. this was a lame idea. convenient, but weird. lets just change this back to ints.
|
||||
|
@ -84,6 +80,7 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
|
||||
/// <summary>
|
||||
/// opengl sucks, man. seriously, screw this (textures from render targets are upside down)
|
||||
/// (couldnt we fix it up in the matrices somewhere?)
|
||||
/// </summary>
|
||||
public bool IsUpsideDown;
|
||||
}
|
||||
|
|
|
@ -5,8 +5,7 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
{
|
||||
public class UniformInfo
|
||||
{
|
||||
public IntPtr Handle;
|
||||
public object Opaque;
|
||||
public string Name;
|
||||
public int SamplerIndex;
|
||||
}
|
||||
}
|
|
@ -7,20 +7,40 @@ using OpenTK.Graphics.OpenGL;
|
|||
|
||||
namespace BizHawk.Bizware.BizwareGL
|
||||
{
|
||||
public class VertexLayout : IDisposable
|
||||
/// <summary>
|
||||
/// Represents a vertex layout, really a kind of a peer of the vertex and fragment shaders.
|
||||
/// It isnt IDisposable because itll be lifecycle-managed by the IGL (disposed when all dependent pipelines are disposed)
|
||||
/// But if you want to be sure to save it for later, use AddRef
|
||||
/// </summary>
|
||||
public class VertexLayout
|
||||
{
|
||||
//TODO - could refactor to use vertex array objects? check opengl profile requirements (answer: 3.0. dont want to do this.)
|
||||
|
||||
public VertexLayout(IGL owner, IntPtr id)
|
||||
public VertexLayout(IGL owner, object opaque)
|
||||
{
|
||||
Owner = owner;
|
||||
Id = id;
|
||||
Opaque = opaque;
|
||||
Items = new MyDictionary();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
public object Opaque { get; private set; }
|
||||
public IGL Owner { get; private set; }
|
||||
|
||||
int RefCount;
|
||||
|
||||
public void Release()
|
||||
{
|
||||
//nothing to do yet..
|
||||
RefCount--;
|
||||
if (RefCount <= 0)
|
||||
{
|
||||
//nothing like this yet
|
||||
//Available = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddRef()
|
||||
{
|
||||
RefCount++;
|
||||
}
|
||||
|
||||
public void DefineVertexAttribute(string name, int index, int components, VertexAttribPointerType attribType, AttributeUsage usage, bool normalized, int stride, int offset = 0)
|
||||
|
@ -68,7 +88,5 @@ namespace BizHawk.Bizware.BizwareGL
|
|||
public MyDictionary Items { get; private set; }
|
||||
bool Closed = false;
|
||||
|
||||
public IGL Owner { get; private set; }
|
||||
public IntPtr Id { get; private set; }
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -1,76 +0,0 @@
|
|||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
|
||||
COMPAT_VARYING vec2 vTexCoord0;
|
||||
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVPMatrix * VertexCoord;
|
||||
vTexCoord0 = TexCoord.xy;
|
||||
}
|
||||
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
|
||||
COMPAT_VARYING vec2 vTexCoord0;
|
||||
uniform sampler2D Texture;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
uniform float uIntensity;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 temp = texture2D(Texture,vTexCoord0);
|
||||
if(floor(gl_FragCoord.y/2) != floor(gl_FragCoord.y)/2) temp.rgb *= uIntensity;
|
||||
FragColor = temp;
|
||||
}
|
||||
#endif
|
|
@ -6,7 +6,25 @@
|
|||
/*
|
||||
bicubic-fast Shader
|
||||
|
||||
Programmed by Hyllian - 2012
|
||||
Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
|
@ -35,15 +53,15 @@ struct input
|
|||
|
||||
|
||||
struct out_vertex {
|
||||
float2 texCoord;
|
||||
float4 t1;
|
||||
float4 t2;
|
||||
float4 t3;
|
||||
float4 t4;
|
||||
float4 t5;
|
||||
float4 t6;
|
||||
float4 t7;
|
||||
float2 t8;
|
||||
float2 texCoord : TEXCOORD0;
|
||||
float4 t1 : TEXCOORD1;
|
||||
float4 t2 : TEXCOORD2;
|
||||
float4 t3 : TEXCOORD3;
|
||||
float4 t4 : TEXCOORD4;
|
||||
float4 t5 : TEXCOORD5;
|
||||
float4 t6 : TEXCOORD6;
|
||||
float4 t7 : TEXCOORD7;
|
||||
float2 t8 : COLOR0;
|
||||
};
|
||||
|
||||
/* VERTEX_SHADER */
|
||||
|
@ -51,7 +69,7 @@ out_vertex main_vertex
|
|||
(
|
||||
float4 position : POSITION,
|
||||
out float4 oPosition : POSITION,
|
||||
float2 tex : TEXCOORD0,
|
||||
float2 texCoord1 : TEXCOORD0,
|
||||
|
||||
uniform float4x4 modelViewProj,
|
||||
uniform input IN
|
||||
|
@ -63,6 +81,9 @@ out_vertex main_vertex
|
|||
|
||||
oPosition = mul(modelViewProj, position);
|
||||
|
||||
// This line fix a bug in ATI cards.
|
||||
float2 tex = texCoord1 + float2(0.0000001, 0.0000001);
|
||||
|
||||
out_vertex OUT = {
|
||||
tex,
|
||||
float4(tex,tex) + float4( -dx, -dy, 0.0, -dy),
|
||||
|
@ -84,7 +105,6 @@ float4 main_fragment(in out_vertex VAR, uniform sampler2D s_p : TEXUNIT0, unifor
|
|||
{
|
||||
|
||||
float2 fp = frac(VAR.texCoord*IN.texture_size);
|
||||
|
||||
float3 c00 = tex2D(s_p, VAR.t1.xy).xyz;
|
||||
float3 c01 = tex2D(s_p, VAR.t1.zw).xyz;
|
||||
float3 c02 = tex2D(s_p, VAR.t2.xy).xyz;
|
|
@ -1,4 +1,4 @@
|
|||
shaders = 1
|
||||
|
||||
shader0 = bicubic-fast.glsl
|
||||
shader0 = bicubic-fast.cg
|
||||
scale_type0 = viewport
|
|
@ -1,338 +0,0 @@
|
|||
// GLSL shader autogenerated by cg2glsl.py.
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
COMPAT_VARYING vec2 VARt8;
|
||||
COMPAT_VARYING vec4 VARt7;
|
||||
COMPAT_VARYING vec4 VARt6;
|
||||
COMPAT_VARYING vec4 VARt5;
|
||||
COMPAT_VARYING vec4 VARt4;
|
||||
COMPAT_VARYING vec4 VARt3;
|
||||
COMPAT_VARYING vec4 VARt2;
|
||||
COMPAT_VARYING vec4 VARt1;
|
||||
COMPAT_VARYING vec2 VARtexCoord;
|
||||
COMPAT_VARYING float _frame_rotation;
|
||||
|
||||
|
||||
struct input_dummy {
|
||||
vec2 _video_size;
|
||||
vec2 _texture_size;
|
||||
vec2 _output_dummy_size;
|
||||
float _frame_count;
|
||||
float _frame_direction;
|
||||
float _frame_rotation;
|
||||
};
|
||||
|
||||
struct out_vertex {
|
||||
vec2 VARtexCoord;
|
||||
vec4 VARt1;
|
||||
vec4 VARt2;
|
||||
vec4 VARt3;
|
||||
vec4 VARt4;
|
||||
vec4 VARt5;
|
||||
vec4 VARt6;
|
||||
vec4 VARt7;
|
||||
vec2 VARt8;
|
||||
};
|
||||
|
||||
vec4 _oPosition1;
|
||||
out_vertex _ret_0;
|
||||
|
||||
input_dummy _IN1;
|
||||
vec4 _r0023;
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
|
||||
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
void main()
|
||||
{
|
||||
|
||||
vec2 _ps;
|
||||
out_vertex _TMP17;
|
||||
|
||||
_ps = vec2(1.00000000E+000/TextureSize.x, 1.00000000E+000/TextureSize.y);
|
||||
_r0023 = VertexCoord.x*MVPMatrix[0];
|
||||
_r0023 = _r0023 + VertexCoord.y*MVPMatrix[1];
|
||||
_r0023 = _r0023 + VertexCoord.z*MVPMatrix[2];
|
||||
_r0023 = _r0023 + VertexCoord.w*MVPMatrix[3];
|
||||
_oPosition1 = _r0023;
|
||||
_TMP17.VARt1 = vec4(TexCoord.x, TexCoord.y, TexCoord.x, TexCoord.y) + vec4(-_ps.x, -_ps.y, 0.00000000E+000, -_ps.y);
|
||||
_TMP17.VARt2 = vec4(TexCoord.x, TexCoord.y, TexCoord.x, TexCoord.y) + vec4(_ps.x, -_ps.y, 2.00000000E+000*_ps.x, -_ps.y);
|
||||
_TMP17.VARt3 = vec4(TexCoord.x, TexCoord.y, TexCoord.x, TexCoord.y) + vec4(-_ps.x, 0.00000000E+000, _ps.x, 0.00000000E+000);
|
||||
_TMP17.VARt4 = vec4(TexCoord.x, TexCoord.y, TexCoord.x, TexCoord.y) + vec4(2.00000000E+000*_ps.x, 0.00000000E+000, -_ps.x, _ps.y);
|
||||
_TMP17.VARt5 = vec4(TexCoord.x, TexCoord.y, TexCoord.x, TexCoord.y) + vec4(0.00000000E+000, _ps.y, _ps.x, _ps.y);
|
||||
_TMP17.VARt6 = vec4(TexCoord.x, TexCoord.y, TexCoord.x, TexCoord.y) + vec4(2.00000000E+000*_ps.x, _ps.y, -_ps.x, 2.00000000E+000*_ps.y);
|
||||
_TMP17.VARt7 = vec4(TexCoord.x, TexCoord.y, TexCoord.x, TexCoord.y) + vec4(0.00000000E+000, 2.00000000E+000*_ps.y, _ps.x, 2.00000000E+000*_ps.y);
|
||||
_TMP17.VARt8 = TexCoord.xy + vec2(2.00000000E+000*_ps.x, 2.00000000E+000*_ps.y);
|
||||
VARtexCoord = TexCoord.xy;
|
||||
VARt1 = _TMP17.VARt1;
|
||||
VARt2 = _TMP17.VARt2;
|
||||
VARt3 = _TMP17.VARt3;
|
||||
VARt4 = _TMP17.VARt4;
|
||||
VARt5 = _TMP17.VARt5;
|
||||
VARt6 = _TMP17.VARt6;
|
||||
VARt7 = _TMP17.VARt7;
|
||||
VARt8 = _TMP17.VARt8;
|
||||
gl_Position = _r0023;
|
||||
return;
|
||||
}
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
COMPAT_VARYING vec2 VARt8;
|
||||
COMPAT_VARYING vec4 VARt7;
|
||||
COMPAT_VARYING vec4 VARt6;
|
||||
COMPAT_VARYING vec4 VARt5;
|
||||
COMPAT_VARYING vec4 VARt4;
|
||||
COMPAT_VARYING vec4 VARt3;
|
||||
COMPAT_VARYING vec4 VARt2;
|
||||
COMPAT_VARYING vec4 VARt1;
|
||||
COMPAT_VARYING vec2 VARtexCoord;
|
||||
COMPAT_VARYING float _frame_rotation;
|
||||
|
||||
|
||||
struct input_dummy {
|
||||
vec2 _video_size;
|
||||
vec2 _texture_size;
|
||||
vec2 _output_dummy_size;
|
||||
float _frame_count;
|
||||
float _frame_direction;
|
||||
float _frame_rotation;
|
||||
};
|
||||
|
||||
struct out_vertex {
|
||||
vec2 VARtexCoord;
|
||||
vec4 VARt1;
|
||||
vec4 VARt2;
|
||||
vec4 VARt3;
|
||||
vec4 VARt4;
|
||||
vec4 VARt5;
|
||||
vec4 VARt6;
|
||||
vec4 VARt7;
|
||||
vec2 VARt8;
|
||||
};
|
||||
|
||||
vec4 _ret_0;
|
||||
vec4 _TMP15;
|
||||
vec4 _TMP14;
|
||||
vec4 _TMP13;
|
||||
vec4 _TMP12;
|
||||
vec4 _TMP11;
|
||||
vec4 _TMP10;
|
||||
vec4 _TMP9;
|
||||
vec4 _TMP8;
|
||||
vec4 _TMP7;
|
||||
vec4 _TMP6;
|
||||
vec4 _TMP5;
|
||||
vec4 _TMP4;
|
||||
vec4 _TMP3;
|
||||
vec4 _TMP2;
|
||||
vec4 _TMP1;
|
||||
vec4 _TMP0;
|
||||
out_vertex _VAR1;
|
||||
uniform sampler2D Texture;
|
||||
input_dummy _IN1;
|
||||
vec2 _x0035;
|
||||
vec4 _C0069;
|
||||
vec4 _C0079[1];
|
||||
vec4 _C0081;
|
||||
float _C0091;
|
||||
vec4 _C0093;
|
||||
float _C0103;
|
||||
vec4 _C0105;
|
||||
float _C0115;
|
||||
vec4 _TMP116;
|
||||
vec4 _TMP117;
|
||||
vec4 _TMP118;
|
||||
vec4 _TMP119;
|
||||
vec4 _TMP120;
|
||||
vec4 _TMP121;
|
||||
vec4 _TMP122;
|
||||
vec4 _TMP123;
|
||||
vec4 _TMP124;
|
||||
vec4 _TMP125;
|
||||
vec4 _TMP126;
|
||||
vec4 _TMP127;
|
||||
vec4 _TMP128;
|
||||
vec4 _TMP129;
|
||||
vec4 _TMP130;
|
||||
vec4 _TMP131;
|
||||
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
void main()
|
||||
{
|
||||
|
||||
vec2 _fp;
|
||||
vec4 _TMP26[1];
|
||||
vec4 _TMP27;
|
||||
vec4 _TMP29[4];
|
||||
vec4 _TMP30[4];
|
||||
vec4 _TMP31[4];
|
||||
|
||||
_x0035 = VARtexCoord*TextureSize;
|
||||
_fp = fract(_x0035);
|
||||
_TMP0 = COMPAT_TEXTURE(Texture, VARt1.xy);
|
||||
_TMP1 = COMPAT_TEXTURE(Texture, VARt1.zw);
|
||||
_TMP2 = COMPAT_TEXTURE(Texture, VARt2.xy);
|
||||
_TMP3 = COMPAT_TEXTURE(Texture, VARt2.zw);
|
||||
_TMP4 = COMPAT_TEXTURE(Texture, VARt3.xy);
|
||||
_TMP5 = COMPAT_TEXTURE(Texture, VARtexCoord);
|
||||
_TMP6 = COMPAT_TEXTURE(Texture, VARt3.zw);
|
||||
_TMP7 = COMPAT_TEXTURE(Texture, VARt4.xy);
|
||||
_TMP8 = COMPAT_TEXTURE(Texture, VARt4.zw);
|
||||
_TMP9 = COMPAT_TEXTURE(Texture, VARt5.xy);
|
||||
_TMP10 = COMPAT_TEXTURE(Texture, VARt5.zw);
|
||||
_TMP11 = COMPAT_TEXTURE(Texture, VARt6.xy);
|
||||
_TMP12 = COMPAT_TEXTURE(Texture, VARt6.zw);
|
||||
_TMP13 = COMPAT_TEXTURE(Texture, VARt7.xy);
|
||||
_TMP14 = COMPAT_TEXTURE(Texture, VARt7.zw);
|
||||
_TMP15 = COMPAT_TEXTURE(Texture, VARt8.xy);
|
||||
_TMP31[0] = vec4(_TMP0.x, _TMP1.x, _TMP2.x, _TMP3.x);
|
||||
_TMP31[1] = vec4(_TMP4.x, _TMP5.x, _TMP6.x, _TMP7.x);
|
||||
_TMP31[2] = vec4(_TMP8.x, _TMP9.x, _TMP10.x, _TMP11.x);
|
||||
_TMP31[3] = vec4(_TMP12.x, _TMP13.x, _TMP14.x, _TMP15.x);
|
||||
_TMP30[0] = vec4(_TMP0.y, _TMP1.y, _TMP2.y, _TMP3.y);
|
||||
_TMP30[1] = vec4(_TMP4.y, _TMP5.y, _TMP6.y, _TMP7.y);
|
||||
_TMP30[2] = vec4(_TMP8.y, _TMP9.y, _TMP10.y, _TMP11.y);
|
||||
_TMP30[3] = vec4(_TMP12.y, _TMP13.y, _TMP14.y, _TMP15.y);
|
||||
_TMP29[0] = vec4(_TMP0.z, _TMP1.z, _TMP2.z, _TMP3.z);
|
||||
_TMP29[1] = vec4(_TMP4.z, _TMP5.z, _TMP6.z, _TMP7.z);
|
||||
_TMP29[2] = vec4(_TMP8.z, _TMP9.z, _TMP10.z, _TMP11.z);
|
||||
_TMP29[3] = vec4(_TMP12.z, _TMP13.z, _TMP14.z, _TMP15.z);
|
||||
_TMP27[0] = _fp.x*_fp.x*_fp.x;
|
||||
_TMP27[1] = _fp.x*_fp.x;
|
||||
_TMP27[2] = _fp.x;
|
||||
_TMP116.x = _TMP27[0];
|
||||
_TMP116.y = _TMP27[1];
|
||||
_TMP116.z = _TMP27[2];
|
||||
_TMP116.w = 1.00000000E+000;
|
||||
_C0069[0] = dot(vec4( -1.66666672E-001, 5.00000000E-001, -3.33333343E-001, 0.00000000E+000), _TMP116);
|
||||
_TMP117.x = _TMP27[0];
|
||||
_TMP117.y = _TMP27[1];
|
||||
_TMP117.z = _TMP27[2];
|
||||
_TMP117.w = 1.00000000E+000;
|
||||
_C0069[1] = dot(vec4( 5.00000000E-001, -1.00000000E+000, -5.00000000E-001, 1.00000000E+000), _TMP117);
|
||||
_TMP118.x = _TMP27[0];
|
||||
_TMP118.y = _TMP27[1];
|
||||
_TMP118.z = _TMP27[2];
|
||||
_TMP118.w = 1.00000000E+000;
|
||||
_C0069[2] = dot(vec4( -5.00000000E-001, 5.00000000E-001, 1.00000000E+000, 0.00000000E+000), _TMP118);
|
||||
_TMP119.x = _TMP27[0];
|
||||
_TMP119.y = _TMP27[1];
|
||||
_TMP119.z = _TMP27[2];
|
||||
_TMP119.w = 1.00000000E+000;
|
||||
_C0069[3] = dot(vec4( 1.66666672E-001, 0.00000000E+000, -1.66666672E-001, 0.00000000E+000), _TMP119);
|
||||
_TMP26[0] = vec4(_fp.y*_fp.y*_fp.y, _fp.y*_fp.y, _fp.y, 1.00000000E+000);
|
||||
_C0079[0] = _TMP26[0].x*vec4( -1.66666672E-001, 5.00000000E-001, -5.00000000E-001, 1.66666672E-001) + _TMP26[0].y*vec4( 5.00000000E-001, -1.00000000E+000, 5.00000000E-001, 0.00000000E+000) + _TMP26[0].z*vec4( -3.33333343E-001, -5.00000000E-001, 1.00000000E+000, -1.66666672E-001) + _TMP26[0].w*vec4( 0.00000000E+000, 1.00000000E+000, 0.00000000E+000, 0.00000000E+000);
|
||||
_TMP120.x = _C0069[0];
|
||||
_TMP120.y = _C0069[1];
|
||||
_TMP120.z = _C0069[2];
|
||||
_TMP120.w = _C0069[3];
|
||||
_C0081[0] = dot(_TMP31[0], _TMP120);
|
||||
_TMP121.x = _C0069[0];
|
||||
_TMP121.y = _C0069[1];
|
||||
_TMP121.z = _C0069[2];
|
||||
_TMP121.w = _C0069[3];
|
||||
_C0081[1] = dot(_TMP31[1], _TMP121);
|
||||
_TMP122.x = _C0069[0];
|
||||
_TMP122.y = _C0069[1];
|
||||
_TMP122.z = _C0069[2];
|
||||
_TMP122.w = _C0069[3];
|
||||
_C0081[2] = dot(_TMP31[2], _TMP122);
|
||||
_TMP123.x = _C0069[0];
|
||||
_TMP123.y = _C0069[1];
|
||||
_TMP123.z = _C0069[2];
|
||||
_TMP123.w = _C0069[3];
|
||||
_C0081[3] = dot(_TMP31[3], _TMP123);
|
||||
_C0091 = _C0079[0].x*_C0081[0] + _C0079[0].y*_C0081[1] + _C0079[0].z*_C0081[2] + _C0079[0].w*_C0081[3];
|
||||
_TMP124.x = _C0069[0];
|
||||
_TMP124.y = _C0069[1];
|
||||
_TMP124.z = _C0069[2];
|
||||
_TMP124.w = _C0069[3];
|
||||
_C0093[0] = dot(_TMP30[0], _TMP124);
|
||||
_TMP125.x = _C0069[0];
|
||||
_TMP125.y = _C0069[1];
|
||||
_TMP125.z = _C0069[2];
|
||||
_TMP125.w = _C0069[3];
|
||||
_C0093[1] = dot(_TMP30[1], _TMP125);
|
||||
_TMP126.x = _C0069[0];
|
||||
_TMP126.y = _C0069[1];
|
||||
_TMP126.z = _C0069[2];
|
||||
_TMP126.w = _C0069[3];
|
||||
_C0093[2] = dot(_TMP30[2], _TMP126);
|
||||
_TMP127.x = _C0069[0];
|
||||
_TMP127.y = _C0069[1];
|
||||
_TMP127.z = _C0069[2];
|
||||
_TMP127.w = _C0069[3];
|
||||
_C0093[3] = dot(_TMP30[3], _TMP127);
|
||||
_C0103 = _C0079[0].x*_C0093[0] + _C0079[0].y*_C0093[1] + _C0079[0].z*_C0093[2] + _C0079[0].w*_C0093[3];
|
||||
_TMP128.x = _C0069[0];
|
||||
_TMP128.y = _C0069[1];
|
||||
_TMP128.z = _C0069[2];
|
||||
_TMP128.w = _C0069[3];
|
||||
_C0105[0] = dot(_TMP29[0], _TMP128);
|
||||
_TMP129.x = _C0069[0];
|
||||
_TMP129.y = _C0069[1];
|
||||
_TMP129.z = _C0069[2];
|
||||
_TMP129.w = _C0069[3];
|
||||
_C0105[1] = dot(_TMP29[1], _TMP129);
|
||||
_TMP130.x = _C0069[0];
|
||||
_TMP130.y = _C0069[1];
|
||||
_TMP130.z = _C0069[2];
|
||||
_TMP130.w = _C0069[3];
|
||||
_C0105[2] = dot(_TMP29[2], _TMP130);
|
||||
_TMP131.x = _C0069[0];
|
||||
_TMP131.y = _C0069[1];
|
||||
_TMP131.z = _C0069[2];
|
||||
_TMP131.w = _C0069[3];
|
||||
_C0105[3] = dot(_TMP29[3], _TMP131);
|
||||
_C0115 = _C0079[0].x*_C0105[0] + _C0079[0].y*_C0105[1] + _C0079[0].z*_C0105[2] + _C0079[0].w*_C0105[3];
|
||||
_ret_0 = vec4(_C0091, _C0103, _C0115, 1.00000000E+000);
|
||||
FragColor = _ret_0;
|
||||
return;
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,151 @@
|
|||
/* COMPATIBILITY
|
||||
- HLSL compilers
|
||||
- Cg compilers
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (C) 2010 Team XBMC
|
||||
http://www.xbmc.org
|
||||
Copyright (C) 2011 Stefanos A.
|
||||
http://www.opentk.com
|
||||
|
||||
This Program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This Program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with XBMC; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
http://www.gnu.org/copyleft/gpl.html
|
||||
|
||||
From this forum post:
|
||||
http://board.byuu.org/viewtopic.php?p=33488#p33488
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/* Default Vertex shader */
|
||||
void main_vertex
|
||||
(
|
||||
float4 position : POSITION,
|
||||
//float4 color : COLOR,
|
||||
float2 texCoord1 : TEXCOORD0,
|
||||
|
||||
uniform float4x4 modelViewProj,
|
||||
|
||||
out float4 oPosition : POSITION,
|
||||
//out float4 oColor : COLOR,
|
||||
out float2 otexCoord : TEXCOORD
|
||||
)
|
||||
{
|
||||
oPosition = mul(modelViewProj, position);
|
||||
//oColor = color;
|
||||
otexCoord = texCoord1;
|
||||
}
|
||||
|
||||
struct output
|
||||
{
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct input
|
||||
{
|
||||
float2 video_size;
|
||||
float2 texture_size;
|
||||
float2 output_size;
|
||||
float frame_count;
|
||||
float frame_direction;
|
||||
float frame_rotation;
|
||||
};
|
||||
|
||||
float weight(float x)
|
||||
{
|
||||
float ax = abs(x);
|
||||
// Mitchel-Netravali coefficients.
|
||||
// Best psychovisual result.
|
||||
const float B = 1.0 / 3.0;
|
||||
const float C = 1.0 / 3.0;
|
||||
|
||||
// Sharper version.
|
||||
// May look better in some cases.
|
||||
//const float B = 0.0;
|
||||
//const float C = 0.75;
|
||||
|
||||
if (ax < 1.0)
|
||||
{
|
||||
return
|
||||
(
|
||||
pow(x, 2.0) * ((12.0 - 9.0 * B - 6.0 * C) * ax + (-18.0 + 12.0 * B + 6.0 * C)) +
|
||||
(6.0 - 2.0 * B)
|
||||
) / 6.0;
|
||||
}
|
||||
else if ((ax >= 1.0) && (ax < 2.0))
|
||||
{
|
||||
return
|
||||
(
|
||||
pow(x, 2.0) * ((-B - 6.0 * C) * ax + (6.0 * B + 30.0 * C)) +
|
||||
(-12.0 * B - 48.0 * C) * ax + (8.0 * B + 24.0 * C)
|
||||
) / 6.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
float4 weight4(float x)
|
||||
{
|
||||
return float4(
|
||||
weight(x - 2.0),
|
||||
weight(x - 1.0),
|
||||
weight(x),
|
||||
weight(x + 1.0));
|
||||
}
|
||||
|
||||
float3 pixel(float xpos, float ypos, uniform sampler2D s_p)
|
||||
{
|
||||
return tex2D(s_p, float2(xpos, ypos)).rgb;
|
||||
}
|
||||
|
||||
float3 line_run(float ypos, float4 xpos, float4 linetaps, uniform sampler2D s_p)
|
||||
{
|
||||
return
|
||||
pixel(xpos.r, ypos, s_p) * linetaps.r +
|
||||
pixel(xpos.g, ypos, s_p) * linetaps.g +
|
||||
pixel(xpos.b, ypos, s_p) * linetaps.b +
|
||||
pixel(xpos.a, ypos, s_p) * linetaps.a;
|
||||
}
|
||||
|
||||
|
||||
output main_fragment (float2 tex : TEXCOORD0, uniform input IN, uniform sampler2D s_p : TEXUNIT0)
|
||||
{
|
||||
float2 stepxy = float2(1.0/IN.texture_size.x, 1.0/IN.texture_size.y);
|
||||
float2 pos = tex.xy + stepxy * 0.5;
|
||||
float2 f = frac(pos / stepxy);
|
||||
|
||||
float4 linetaps = weight4(1.0 - f.x);
|
||||
float4 columntaps = weight4(1.0 - f.y);
|
||||
|
||||
//make sure all taps added together is exactly 1.0, otherwise some (very small) distortion can occur
|
||||
linetaps /= linetaps.r + linetaps.g + linetaps.b + linetaps.a;
|
||||
columntaps /= columntaps.r + columntaps.g + columntaps.b + columntaps.a;
|
||||
|
||||
float2 xystart = (-1.5 - f) * stepxy + pos;
|
||||
float4 xpos = float4(xystart.x, xystart.x + stepxy.x, xystart.x + stepxy.x * 2.0, xystart.x + stepxy.x * 3.0);
|
||||
|
||||
|
||||
// final sum and weight normalization
|
||||
output OUT;
|
||||
OUT.color = float4(line_run(xystart.y , xpos, linetaps, s_p) * columntaps.r +
|
||||
line_run(xystart.y + stepxy.y , xpos, linetaps, s_p) * columntaps.g +
|
||||
line_run(xystart.y + stepxy.y * 2.0, xpos, linetaps, s_p) * columntaps.b +
|
||||
line_run(xystart.y + stepxy.y * 3.0, xpos, linetaps, s_p) * columntaps.a,1);
|
||||
return OUT;
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
shaders = 1
|
||||
|
||||
shader0 = bicubic-normal.cg
|
||||
scale_type0 = viewport
|
|
@ -1,299 +0,0 @@
|
|||
// GLSL shader autogenerated by cg2glsl.py.
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
COMPAT_VARYING vec2 VARc22;
|
||||
COMPAT_VARYING vec2 VARc21;
|
||||
COMPAT_VARYING vec2 VARc20;
|
||||
COMPAT_VARYING vec2 VARc12;
|
||||
COMPAT_VARYING vec2 VARc11;
|
||||
COMPAT_VARYING vec2 VARc10;
|
||||
COMPAT_VARYING vec2 VARc02;
|
||||
COMPAT_VARYING vec2 VARc01;
|
||||
COMPAT_VARYING vec2 VARc00;
|
||||
|
||||
|
||||
struct tex_coords {
|
||||
vec2 VARc00;
|
||||
vec2 VARc01;
|
||||
vec2 VARc02;
|
||||
vec2 VARc10;
|
||||
vec2 VARc11;
|
||||
vec2 VARc12;
|
||||
vec2 VARc20;
|
||||
vec2 VARc21;
|
||||
vec2 VARc22;
|
||||
};
|
||||
|
||||
struct input_dummy {
|
||||
vec2 _video_size;
|
||||
vec2 _texture_size;
|
||||
vec2 _output_dummy_size;
|
||||
};
|
||||
|
||||
vec4 _oPosition1;
|
||||
tex_coords _coords1;
|
||||
|
||||
input_dummy _IN1;
|
||||
vec4 _r0012;
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 COLOR;
|
||||
COMPAT_VARYING vec4 COL0;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
|
||||
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
void main()
|
||||
{
|
||||
|
||||
vec4 _oColor;
|
||||
vec2 _delta;
|
||||
tex_coords _TMP8;
|
||||
|
||||
_r0012 = VertexCoord.x*MVPMatrix[0];
|
||||
_r0012 = _r0012 + VertexCoord.y*MVPMatrix[1];
|
||||
_r0012 = _r0012 + VertexCoord.z*MVPMatrix[2];
|
||||
_r0012 = _r0012 + VertexCoord.w*MVPMatrix[3];
|
||||
_oPosition1 = _r0012;
|
||||
_oColor = COLOR;
|
||||
_delta = 5.00000000E-001/TextureSize;
|
||||
_TMP8.VARc00 = TexCoord.xy + vec2(-_delta.x, -_delta.y);
|
||||
_TMP8.VARc01 = TexCoord.xy + vec2(-_delta.x, 0.00000000E+000);
|
||||
_TMP8.VARc02 = TexCoord.xy + vec2(-_delta.x, _delta.y);
|
||||
_TMP8.VARc10 = TexCoord.xy + vec2(0.00000000E+000, -_delta.y);
|
||||
_TMP8.VARc12 = TexCoord.xy + vec2(0.00000000E+000, _delta.y);
|
||||
_TMP8.VARc20 = TexCoord.xy + vec2(_delta.x, -_delta.y);
|
||||
_TMP8.VARc21 = TexCoord.xy + vec2(_delta.x, 0.00000000E+000);
|
||||
_TMP8.VARc22 = TexCoord.xy + vec2(_delta.x, _delta.y);
|
||||
VARc00 = _TMP8.VARc00;
|
||||
VARc01 = _TMP8.VARc01;
|
||||
VARc02 = _TMP8.VARc02;
|
||||
VARc10 = _TMP8.VARc10;
|
||||
VARc11 = TexCoord.xy;
|
||||
VARc12 = _TMP8.VARc12;
|
||||
VARc20 = _TMP8.VARc20;
|
||||
VARc21 = _TMP8.VARc21;
|
||||
VARc22 = _TMP8.VARc22;
|
||||
gl_Position = _r0012;
|
||||
COL0 = COLOR;
|
||||
}
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
COMPAT_VARYING vec2 VARc22;
|
||||
COMPAT_VARYING vec2 VARc21;
|
||||
COMPAT_VARYING vec2 VARc20;
|
||||
COMPAT_VARYING vec2 VARc12;
|
||||
COMPAT_VARYING vec2 VARc11;
|
||||
COMPAT_VARYING vec2 VARc10;
|
||||
COMPAT_VARYING vec2 VARc02;
|
||||
COMPAT_VARYING vec2 VARc01;
|
||||
COMPAT_VARYING vec2 VARc00;
|
||||
|
||||
|
||||
struct tex_coords {
|
||||
vec2 VARc00;
|
||||
vec2 VARc01;
|
||||
vec2 VARc02;
|
||||
vec2 VARc10;
|
||||
vec2 VARc11;
|
||||
vec2 VARc12;
|
||||
vec2 VARc20;
|
||||
vec2 VARc21;
|
||||
vec2 VARc22;
|
||||
};
|
||||
|
||||
struct input_dummy {
|
||||
vec2 _video_size;
|
||||
vec2 _texture_size;
|
||||
vec2 _output_dummy_size;
|
||||
};
|
||||
|
||||
vec4 _ret_0;
|
||||
float _TMP29;
|
||||
float _TMP30;
|
||||
vec3 _TMP28;
|
||||
float _TMP27;
|
||||
vec3 _TMP26;
|
||||
float _TMP25;
|
||||
vec3 _TMP24;
|
||||
float _TMP23;
|
||||
vec3 _TMP22;
|
||||
float _TMP21;
|
||||
float _TMP20;
|
||||
float _TMP19;
|
||||
float _TMP18;
|
||||
vec3 _TMP17;
|
||||
float _TMP16;
|
||||
vec3 _TMP15;
|
||||
float _TMP14;
|
||||
vec3 _TMP13;
|
||||
float _TMP12;
|
||||
vec3 _TMP11;
|
||||
vec3 _TMP10;
|
||||
vec3 _TMP9;
|
||||
vec4 _TMP8;
|
||||
vec4 _TMP7;
|
||||
vec4 _TMP6;
|
||||
vec4 _TMP5;
|
||||
vec4 _TMP4;
|
||||
vec4 _TMP3;
|
||||
vec4 _TMP2;
|
||||
vec4 _TMP1;
|
||||
vec4 _TMP0;
|
||||
tex_coords _co1;
|
||||
uniform sampler2D Texture;
|
||||
vec3 _a0058;
|
||||
vec3 _a0062;
|
||||
vec3 _a0066;
|
||||
vec3 _a0070;
|
||||
vec3 _a0074;
|
||||
vec3 _a0078;
|
||||
vec3 _a0084;
|
||||
vec3 _a0086;
|
||||
vec3 _a0088;
|
||||
float _TMP91;
|
||||
float _x0092;
|
||||
vec3 _a0098;
|
||||
float _TMP101;
|
||||
float _x0102;
|
||||
vec3 _a0108;
|
||||
float _TMP111;
|
||||
float _x0112;
|
||||
vec3 _a0118;
|
||||
float _TMP121;
|
||||
float _x0122;
|
||||
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
void main()
|
||||
{
|
||||
|
||||
vec3 _c11;
|
||||
float _md1;
|
||||
float _md2;
|
||||
float _w1;
|
||||
float _w2;
|
||||
float _w3;
|
||||
float _w4;
|
||||
float _t1;
|
||||
float _t2;
|
||||
float _ww;
|
||||
float _lc1;
|
||||
float _lc2;
|
||||
vec3 _TMP38;
|
||||
|
||||
_TMP0 = COMPAT_TEXTURE(Texture, VARc00);
|
||||
_TMP1 = COMPAT_TEXTURE(Texture, VARc01);
|
||||
_TMP2 = COMPAT_TEXTURE(Texture, VARc02);
|
||||
_TMP3 = COMPAT_TEXTURE(Texture, VARc10);
|
||||
_TMP4 = COMPAT_TEXTURE(Texture, VARc11);
|
||||
_TMP5 = COMPAT_TEXTURE(Texture, VARc12);
|
||||
_TMP6 = COMPAT_TEXTURE(Texture, VARc20);
|
||||
_TMP7 = COMPAT_TEXTURE(Texture, VARc21);
|
||||
_TMP8 = COMPAT_TEXTURE(Texture, VARc22);
|
||||
_a0058 = _TMP0.xyz - _TMP8.xyz;
|
||||
_TMP9 = abs(_a0058);
|
||||
_md1 = dot(_TMP9, vec3( 1.00000000E+000, 1.00000000E+000, 1.00000000E+000));
|
||||
_a0062 = _TMP2.xyz - _TMP6.xyz;
|
||||
_TMP10 = abs(_a0062);
|
||||
_md2 = dot(_TMP10, vec3( 1.00000000E+000, 1.00000000E+000, 1.00000000E+000));
|
||||
_a0066 = _TMP8.xyz - _TMP4.xyz;
|
||||
_TMP11 = abs(_a0066);
|
||||
_TMP12 = dot(_TMP11, vec3( 1.00000000E+000, 1.00000000E+000, 1.00000000E+000));
|
||||
_w1 = _TMP12*_md2;
|
||||
_a0070 = _TMP2.xyz - _TMP4.xyz;
|
||||
_TMP13 = abs(_a0070);
|
||||
_TMP14 = dot(_TMP13, vec3( 1.00000000E+000, 1.00000000E+000, 1.00000000E+000));
|
||||
_w2 = _TMP14*_md1;
|
||||
_a0074 = _TMP0.xyz - _TMP4.xyz;
|
||||
_TMP15 = abs(_a0074);
|
||||
_TMP16 = dot(_TMP15, vec3( 1.00000000E+000, 1.00000000E+000, 1.00000000E+000));
|
||||
_w3 = _TMP16*_md2;
|
||||
_a0078 = _TMP6.xyz - _TMP4.xyz;
|
||||
_TMP17 = abs(_a0078);
|
||||
_TMP18 = dot(_TMP17, vec3( 1.00000000E+000, 1.00000000E+000, 1.00000000E+000));
|
||||
_w4 = _TMP18*_md1;
|
||||
_t1 = _w1 + _w3;
|
||||
_t2 = _w2 + _w4;
|
||||
_TMP19 = max(_t1, _t2);
|
||||
_ww = _TMP19 + 9.99999975E-005;
|
||||
_c11 = (_w1*_TMP0.xyz + _w2*_TMP6.xyz + _w3*_TMP8.xyz + _w4*_TMP2.xyz + _ww*_TMP4.xyz)/(_t1 + _t2 + _ww);
|
||||
_a0084 = _TMP3.xyz + _TMP5.xyz + _c11;
|
||||
_TMP20 = dot(_a0084, vec3( 1.00000000E+000, 1.00000000E+000, 1.00000000E+000));
|
||||
_lc1 = -2.50000000E-001/(1.19999997E-001*_TMP20 + 2.50000000E-001);
|
||||
_a0086 = _TMP1.xyz + _TMP7.xyz + _c11;
|
||||
_TMP21 = dot(_a0086, vec3( 1.00000000E+000, 1.00000000E+000, 1.00000000E+000));
|
||||
_lc2 = -2.50000000E-001/(1.19999997E-001*_TMP21 + 2.50000000E-001);
|
||||
_a0088 = _c11 - _TMP3.xyz;
|
||||
_TMP22 = abs(_a0088);
|
||||
_TMP23 = dot(_TMP22, vec3( 1.00000000E+000, 1.00000000E+000, 1.00000000E+000));
|
||||
_x0092 = _lc1*_TMP23 + 3.24999988E-001;
|
||||
_TMP30 = min(2.50000000E-001, _x0092);
|
||||
_TMP91 = max(-5.00000007E-002, _TMP30);
|
||||
_a0098 = _c11 - _TMP7.xyz;
|
||||
_TMP24 = abs(_a0098);
|
||||
_TMP25 = dot(_TMP24, vec3( 1.00000000E+000, 1.00000000E+000, 1.00000000E+000));
|
||||
_x0102 = _lc2*_TMP25 + 3.24999988E-001;
|
||||
_TMP30 = min(2.50000000E-001, _x0102);
|
||||
_TMP101 = max(-5.00000007E-002, _TMP30);
|
||||
_a0108 = _c11 - _TMP5.xyz;
|
||||
_TMP26 = abs(_a0108);
|
||||
_TMP27 = dot(_TMP26, vec3( 1.00000000E+000, 1.00000000E+000, 1.00000000E+000));
|
||||
_x0112 = _lc1*_TMP27 + 3.24999988E-001;
|
||||
_TMP30 = min(2.50000000E-001, _x0112);
|
||||
_TMP111 = max(-5.00000007E-002, _TMP30);
|
||||
_a0118 = _c11 - _TMP1.xyz;
|
||||
_TMP28 = abs(_a0118);
|
||||
_TMP29 = dot(_TMP28, vec3( 1.00000000E+000, 1.00000000E+000, 1.00000000E+000));
|
||||
_x0122 = _lc2*_TMP29 + 3.24999988E-001;
|
||||
_TMP30 = min(2.50000000E-001, _x0122);
|
||||
_TMP121 = max(-5.00000007E-002, _TMP30);
|
||||
_TMP38 = _TMP91*_TMP3.xyz + _TMP101*_TMP7.xyz + _TMP111*_TMP5.xyz + _TMP121*_TMP1.xyz + ((((1.00000000E+000 - _TMP91) - _TMP101) - _TMP111) - _TMP121)*_c11;
|
||||
_ret_0 = vec4(_TMP38.x, _TMP38.y, _TMP38.z, 1.00000000E+000);
|
||||
FragColor = _ret_0;
|
||||
return;
|
||||
}
|
||||
#endif
|
|
@ -1,338 +0,0 @@
|
|||
// GLSL shader autogenerated by cg2glsl.py.
|
||||
#if defined(VERTEX)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING out
|
||||
#define COMPAT_ATTRIBUTE in
|
||||
#define COMPAT_TEXTURE texture
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define COMPAT_ATTRIBUTE attribute
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
COMPAT_VARYING vec2 VARt8;
|
||||
COMPAT_VARYING vec4 VARt7;
|
||||
COMPAT_VARYING vec4 VARt6;
|
||||
COMPAT_VARYING vec4 VARt5;
|
||||
COMPAT_VARYING vec4 VARt4;
|
||||
COMPAT_VARYING vec4 VARt3;
|
||||
COMPAT_VARYING vec4 VARt2;
|
||||
COMPAT_VARYING vec4 VARt1;
|
||||
COMPAT_VARYING vec2 VARtexCoord;
|
||||
COMPAT_VARYING float _frame_rotation;
|
||||
|
||||
|
||||
struct input_dummy {
|
||||
vec2 _video_size;
|
||||
vec2 _texture_size;
|
||||
vec2 _output_dummy_size;
|
||||
float _frame_count;
|
||||
float _frame_direction;
|
||||
float _frame_rotation;
|
||||
};
|
||||
|
||||
struct out_vertex {
|
||||
vec2 VARtexCoord;
|
||||
vec4 VARt1;
|
||||
vec4 VARt2;
|
||||
vec4 VARt3;
|
||||
vec4 VARt4;
|
||||
vec4 VARt5;
|
||||
vec4 VARt6;
|
||||
vec4 VARt7;
|
||||
vec2 VARt8;
|
||||
};
|
||||
|
||||
vec4 _oPosition1;
|
||||
out_vertex _ret_0;
|
||||
|
||||
input_dummy _IN1;
|
||||
vec4 _r0023;
|
||||
COMPAT_ATTRIBUTE vec4 VertexCoord;
|
||||
COMPAT_ATTRIBUTE vec4 TexCoord;
|
||||
|
||||
|
||||
uniform mat4 MVPMatrix;
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
void main()
|
||||
{
|
||||
|
||||
vec2 _ps;
|
||||
out_vertex _TMP17;
|
||||
|
||||
_ps = vec2(1.00000000E+000/TextureSize.x, 1.00000000E+000/TextureSize.y);
|
||||
_r0023 = VertexCoord.x*MVPMatrix[0];
|
||||
_r0023 = _r0023 + VertexCoord.y*MVPMatrix[1];
|
||||
_r0023 = _r0023 + VertexCoord.z*MVPMatrix[2];
|
||||
_r0023 = _r0023 + VertexCoord.w*MVPMatrix[3];
|
||||
_oPosition1 = _r0023;
|
||||
_TMP17.VARt1 = vec4(TexCoord.x, TexCoord.y, TexCoord.x, TexCoord.y) + vec4(-_ps.x, -_ps.y, 0.00000000E+000, -_ps.y);
|
||||
_TMP17.VARt2 = vec4(TexCoord.x, TexCoord.y, TexCoord.x, TexCoord.y) + vec4(_ps.x, -_ps.y, 2.00000000E+000*_ps.x, -_ps.y);
|
||||
_TMP17.VARt3 = vec4(TexCoord.x, TexCoord.y, TexCoord.x, TexCoord.y) + vec4(-_ps.x, 0.00000000E+000, _ps.x, 0.00000000E+000);
|
||||
_TMP17.VARt4 = vec4(TexCoord.x, TexCoord.y, TexCoord.x, TexCoord.y) + vec4(2.00000000E+000*_ps.x, 0.00000000E+000, -_ps.x, _ps.y);
|
||||
_TMP17.VARt5 = vec4(TexCoord.x, TexCoord.y, TexCoord.x, TexCoord.y) + vec4(0.00000000E+000, _ps.y, _ps.x, _ps.y);
|
||||
_TMP17.VARt6 = vec4(TexCoord.x, TexCoord.y, TexCoord.x, TexCoord.y) + vec4(2.00000000E+000*_ps.x, _ps.y, -_ps.x, 2.00000000E+000*_ps.y);
|
||||
_TMP17.VARt7 = vec4(TexCoord.x, TexCoord.y, TexCoord.x, TexCoord.y) + vec4(0.00000000E+000, 2.00000000E+000*_ps.y, _ps.x, 2.00000000E+000*_ps.y);
|
||||
_TMP17.VARt8 = TexCoord.xy + vec2(2.00000000E+000*_ps.x, 2.00000000E+000*_ps.y);
|
||||
VARtexCoord = TexCoord.xy;
|
||||
VARt1 = _TMP17.VARt1;
|
||||
VARt2 = _TMP17.VARt2;
|
||||
VARt3 = _TMP17.VARt3;
|
||||
VARt4 = _TMP17.VARt4;
|
||||
VARt5 = _TMP17.VARt5;
|
||||
VARt6 = _TMP17.VARt6;
|
||||
VARt7 = _TMP17.VARt7;
|
||||
VARt8 = _TMP17.VARt8;
|
||||
gl_Position = _r0023;
|
||||
return;
|
||||
}
|
||||
#elif defined(FRAGMENT)
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
#define COMPAT_VARYING in
|
||||
#define COMPAT_TEXTURE texture
|
||||
out vec4 FragColor;
|
||||
#else
|
||||
#define COMPAT_VARYING varying
|
||||
#define FragColor gl_FragColor
|
||||
#define COMPAT_TEXTURE texture2D
|
||||
#endif
|
||||
|
||||
#ifdef GL_ES
|
||||
#ifdef GL_FRAGMENT_PRECISION_HIGH
|
||||
precision highp float;
|
||||
#else
|
||||
precision mediump float;
|
||||
#endif
|
||||
#define COMPAT_PRECISION mediump
|
||||
#else
|
||||
#define COMPAT_PRECISION
|
||||
#endif
|
||||
COMPAT_VARYING vec2 VARt8;
|
||||
COMPAT_VARYING vec4 VARt7;
|
||||
COMPAT_VARYING vec4 VARt6;
|
||||
COMPAT_VARYING vec4 VARt5;
|
||||
COMPAT_VARYING vec4 VARt4;
|
||||
COMPAT_VARYING vec4 VARt3;
|
||||
COMPAT_VARYING vec4 VARt2;
|
||||
COMPAT_VARYING vec4 VARt1;
|
||||
COMPAT_VARYING vec2 VARtexCoord;
|
||||
COMPAT_VARYING float _frame_rotation;
|
||||
|
||||
|
||||
struct input_dummy {
|
||||
vec2 _video_size;
|
||||
vec2 _texture_size;
|
||||
vec2 _output_dummy_size;
|
||||
float _frame_count;
|
||||
float _frame_direction;
|
||||
float _frame_rotation;
|
||||
};
|
||||
|
||||
struct out_vertex {
|
||||
vec2 VARtexCoord;
|
||||
vec4 VARt1;
|
||||
vec4 VARt2;
|
||||
vec4 VARt3;
|
||||
vec4 VARt4;
|
||||
vec4 VARt5;
|
||||
vec4 VARt6;
|
||||
vec4 VARt7;
|
||||
vec2 VARt8;
|
||||
};
|
||||
|
||||
vec4 _ret_0;
|
||||
vec4 _TMP15;
|
||||
vec4 _TMP14;
|
||||
vec4 _TMP13;
|
||||
vec4 _TMP12;
|
||||
vec4 _TMP11;
|
||||
vec4 _TMP10;
|
||||
vec4 _TMP9;
|
||||
vec4 _TMP8;
|
||||
vec4 _TMP7;
|
||||
vec4 _TMP6;
|
||||
vec4 _TMP5;
|
||||
vec4 _TMP4;
|
||||
vec4 _TMP3;
|
||||
vec4 _TMP2;
|
||||
vec4 _TMP1;
|
||||
vec4 _TMP0;
|
||||
out_vertex _VAR1;
|
||||
uniform sampler2D Texture;
|
||||
input_dummy _IN1;
|
||||
vec2 _x0035;
|
||||
vec4 _C0069;
|
||||
vec4 _C0079[1];
|
||||
vec4 _C0081;
|
||||
float _C0091;
|
||||
vec4 _C0093;
|
||||
float _C0103;
|
||||
vec4 _C0105;
|
||||
float _C0115;
|
||||
vec4 _TMP116;
|
||||
vec4 _TMP117;
|
||||
vec4 _TMP118;
|
||||
vec4 _TMP119;
|
||||
vec4 _TMP120;
|
||||
vec4 _TMP121;
|
||||
vec4 _TMP122;
|
||||
vec4 _TMP123;
|
||||
vec4 _TMP124;
|
||||
vec4 _TMP125;
|
||||
vec4 _TMP126;
|
||||
vec4 _TMP127;
|
||||
vec4 _TMP128;
|
||||
vec4 _TMP129;
|
||||
vec4 _TMP130;
|
||||
vec4 _TMP131;
|
||||
|
||||
|
||||
uniform int FrameDirection;
|
||||
uniform int FrameCount;
|
||||
uniform COMPAT_PRECISION vec2 OutputSize;
|
||||
uniform COMPAT_PRECISION vec2 TextureSize;
|
||||
uniform COMPAT_PRECISION vec2 InputSize;
|
||||
void main()
|
||||
{
|
||||
|
||||
vec2 _fp;
|
||||
vec4 _TMP26[1];
|
||||
vec4 _TMP27;
|
||||
vec4 _TMP29[4];
|
||||
vec4 _TMP30[4];
|
||||
vec4 _TMP31[4];
|
||||
|
||||
_x0035 = VARtexCoord*TextureSize;
|
||||
_fp = fract(_x0035);
|
||||
_TMP0 = COMPAT_TEXTURE(Texture, VARt1.xy);
|
||||
_TMP1 = COMPAT_TEXTURE(Texture, VARt1.zw);
|
||||
_TMP2 = COMPAT_TEXTURE(Texture, VARt2.xy);
|
||||
_TMP3 = COMPAT_TEXTURE(Texture, VARt2.zw);
|
||||
_TMP4 = COMPAT_TEXTURE(Texture, VARt3.xy);
|
||||
_TMP5 = COMPAT_TEXTURE(Texture, VARtexCoord);
|
||||
_TMP6 = COMPAT_TEXTURE(Texture, VARt3.zw);
|
||||
_TMP7 = COMPAT_TEXTURE(Texture, VARt4.xy);
|
||||
_TMP8 = COMPAT_TEXTURE(Texture, VARt4.zw);
|
||||
_TMP9 = COMPAT_TEXTURE(Texture, VARt5.xy);
|
||||
_TMP10 = COMPAT_TEXTURE(Texture, VARt5.zw);
|
||||
_TMP11 = COMPAT_TEXTURE(Texture, VARt6.xy);
|
||||
_TMP12 = COMPAT_TEXTURE(Texture, VARt6.zw);
|
||||
_TMP13 = COMPAT_TEXTURE(Texture, VARt7.xy);
|
||||
_TMP14 = COMPAT_TEXTURE(Texture, VARt7.zw);
|
||||
_TMP15 = COMPAT_TEXTURE(Texture, VARt8.xy);
|
||||
_TMP31[0] = vec4(_TMP0.x, _TMP1.x, _TMP2.x, _TMP3.x);
|
||||
_TMP31[1] = vec4(_TMP4.x, _TMP5.x, _TMP6.x, _TMP7.x);
|
||||
_TMP31[2] = vec4(_TMP8.x, _TMP9.x, _TMP10.x, _TMP11.x);
|
||||
_TMP31[3] = vec4(_TMP12.x, _TMP13.x, _TMP14.x, _TMP15.x);
|
||||
_TMP30[0] = vec4(_TMP0.y, _TMP1.y, _TMP2.y, _TMP3.y);
|
||||
_TMP30[1] = vec4(_TMP4.y, _TMP5.y, _TMP6.y, _TMP7.y);
|
||||
_TMP30[2] = vec4(_TMP8.y, _TMP9.y, _TMP10.y, _TMP11.y);
|
||||
_TMP30[3] = vec4(_TMP12.y, _TMP13.y, _TMP14.y, _TMP15.y);
|
||||
_TMP29[0] = vec4(_TMP0.z, _TMP1.z, _TMP2.z, _TMP3.z);
|
||||
_TMP29[1] = vec4(_TMP4.z, _TMP5.z, _TMP6.z, _TMP7.z);
|
||||
_TMP29[2] = vec4(_TMP8.z, _TMP9.z, _TMP10.z, _TMP11.z);
|
||||
_TMP29[3] = vec4(_TMP12.z, _TMP13.z, _TMP14.z, _TMP15.z);
|
||||
_TMP27[0] = _fp.x*_fp.x*_fp.x;
|
||||
_TMP27[1] = _fp.x*_fp.x;
|
||||
_TMP27[2] = _fp.x;
|
||||
_TMP116.x = _TMP27[0];
|
||||
_TMP116.y = _TMP27[1];
|
||||
_TMP116.z = _TMP27[2];
|
||||
_TMP116.w = 1.00000000E+000;
|
||||
_C0069[0] = dot(vec4( -1.66666672E-001, 5.00000000E-001, -3.33333343E-001, 0.00000000E+000), _TMP116);
|
||||
_TMP117.x = _TMP27[0];
|
||||
_TMP117.y = _TMP27[1];
|
||||
_TMP117.z = _TMP27[2];
|
||||
_TMP117.w = 1.00000000E+000;
|
||||
_C0069[1] = dot(vec4( 5.00000000E-001, -1.00000000E+000, -5.00000000E-001, 1.00000000E+000), _TMP117);
|
||||
_TMP118.x = _TMP27[0];
|
||||
_TMP118.y = _TMP27[1];
|
||||
_TMP118.z = _TMP27[2];
|
||||
_TMP118.w = 1.00000000E+000;
|
||||
_C0069[2] = dot(vec4( -5.00000000E-001, 5.00000000E-001, 1.00000000E+000, 0.00000000E+000), _TMP118);
|
||||
_TMP119.x = _TMP27[0];
|
||||
_TMP119.y = _TMP27[1];
|
||||
_TMP119.z = _TMP27[2];
|
||||
_TMP119.w = 1.00000000E+000;
|
||||
_C0069[3] = dot(vec4( 1.66666672E-001, 0.00000000E+000, -1.66666672E-001, 0.00000000E+000), _TMP119);
|
||||
_TMP26[0] = vec4(_fp.y*_fp.y*_fp.y, _fp.y*_fp.y, _fp.y, 1.00000000E+000);
|
||||
_C0079[0] = _TMP26[0].x*vec4( -1.66666672E-001, 5.00000000E-001, -5.00000000E-001, 1.66666672E-001) + _TMP26[0].y*vec4( 5.00000000E-001, -1.00000000E+000, 5.00000000E-001, 0.00000000E+000) + _TMP26[0].z*vec4( -3.33333343E-001, -5.00000000E-001, 1.00000000E+000, -1.66666672E-001) + _TMP26[0].w*vec4( 0.00000000E+000, 1.00000000E+000, 0.00000000E+000, 0.00000000E+000);
|
||||
_TMP120.x = _C0069[0];
|
||||
_TMP120.y = _C0069[1];
|
||||
_TMP120.z = _C0069[2];
|
||||
_TMP120.w = _C0069[3];
|
||||
_C0081[0] = dot(_TMP31[0], _TMP120);
|
||||
_TMP121.x = _C0069[0];
|
||||
_TMP121.y = _C0069[1];
|
||||
_TMP121.z = _C0069[2];
|
||||
_TMP121.w = _C0069[3];
|
||||
_C0081[1] = dot(_TMP31[1], _TMP121);
|
||||
_TMP122.x = _C0069[0];
|
||||
_TMP122.y = _C0069[1];
|
||||
_TMP122.z = _C0069[2];
|
||||
_TMP122.w = _C0069[3];
|
||||
_C0081[2] = dot(_TMP31[2], _TMP122);
|
||||
_TMP123.x = _C0069[0];
|
||||
_TMP123.y = _C0069[1];
|
||||
_TMP123.z = _C0069[2];
|
||||
_TMP123.w = _C0069[3];
|
||||
_C0081[3] = dot(_TMP31[3], _TMP123);
|
||||
_C0091 = _C0079[0].x*_C0081[0] + _C0079[0].y*_C0081[1] + _C0079[0].z*_C0081[2] + _C0079[0].w*_C0081[3];
|
||||
_TMP124.x = _C0069[0];
|
||||
_TMP124.y = _C0069[1];
|
||||
_TMP124.z = _C0069[2];
|
||||
_TMP124.w = _C0069[3];
|
||||
_C0093[0] = dot(_TMP30[0], _TMP124);
|
||||
_TMP125.x = _C0069[0];
|
||||
_TMP125.y = _C0069[1];
|
||||
_TMP125.z = _C0069[2];
|
||||
_TMP125.w = _C0069[3];
|
||||
_C0093[1] = dot(_TMP30[1], _TMP125);
|
||||
_TMP126.x = _C0069[0];
|
||||
_TMP126.y = _C0069[1];
|
||||
_TMP126.z = _C0069[2];
|
||||
_TMP126.w = _C0069[3];
|
||||
_C0093[2] = dot(_TMP30[2], _TMP126);
|
||||
_TMP127.x = _C0069[0];
|
||||
_TMP127.y = _C0069[1];
|
||||
_TMP127.z = _C0069[2];
|
||||
_TMP127.w = _C0069[3];
|
||||
_C0093[3] = dot(_TMP30[3], _TMP127);
|
||||
_C0103 = _C0079[0].x*_C0093[0] + _C0079[0].y*_C0093[1] + _C0079[0].z*_C0093[2] + _C0079[0].w*_C0093[3];
|
||||
_TMP128.x = _C0069[0];
|
||||
_TMP128.y = _C0069[1];
|
||||
_TMP128.z = _C0069[2];
|
||||
_TMP128.w = _C0069[3];
|
||||
_C0105[0] = dot(_TMP29[0], _TMP128);
|
||||
_TMP129.x = _C0069[0];
|
||||
_TMP129.y = _C0069[1];
|
||||
_TMP129.z = _C0069[2];
|
||||
_TMP129.w = _C0069[3];
|
||||
_C0105[1] = dot(_TMP29[1], _TMP129);
|
||||
_TMP130.x = _C0069[0];
|
||||
_TMP130.y = _C0069[1];
|
||||
_TMP130.z = _C0069[2];
|
||||
_TMP130.w = _C0069[3];
|
||||
_C0105[2] = dot(_TMP29[2], _TMP130);
|
||||
_TMP131.x = _C0069[0];
|
||||
_TMP131.y = _C0069[1];
|
||||
_TMP131.z = _C0069[2];
|
||||
_TMP131.w = _C0069[3];
|
||||
_C0105[3] = dot(_TMP29[3], _TMP131);
|
||||
_C0115 = _C0079[0].x*_C0105[0] + _C0079[0].y*_C0105[1] + _C0079[0].z*_C0105[2] + _C0079[0].w*_C0105[3];
|
||||
_ret_0 = vec4(_C0091, _C0103, _C0115, 1.00000000E+000);
|
||||
FragColor = _ret_0;
|
||||
return;
|
||||
}
|
||||
#endif
|
Binary file not shown.
Loading…
Reference in New Issue