double-buffer main emulation display texture. maybe this will help improve performance on some finnicky video cards.
This commit is contained in:
parent
b7a053f7da
commit
c922dde1ee
|
@ -1,4 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using BizHawk.Common;
|
using BizHawk.Common;
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
using BizHawk.Client.Common;
|
using BizHawk.Client.Common;
|
||||||
|
@ -8,7 +10,7 @@ using BizHawk.Bizware.BizwareGL;
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Recycles a temporary texture to contain a BitmapBuffer's or DisplaySurface's contents, as long as the dimensions match.
|
/// Recycles a pair of temporary textures (in case double-buffering helps any) to contain a BitmapBuffer's or DisplaySurface's contents, as long as the dimensions match.
|
||||||
/// When the dimensions dont match, a new one will be allocated
|
/// When the dimensions dont match, a new one will be allocated
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class TextureFrugalizer : IDisposable
|
class TextureFrugalizer : IDisposable
|
||||||
|
@ -16,19 +18,26 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public TextureFrugalizer(IGL gl)
|
public TextureFrugalizer(IGL gl)
|
||||||
{
|
{
|
||||||
GL = gl;
|
GL = gl;
|
||||||
|
ResetList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (CurrentTexture != null)
|
foreach (var ct in CurrentTextures)
|
||||||
{
|
if(ct != null)
|
||||||
CurrentTexture.Dispose();
|
ct.Dispose();
|
||||||
CurrentTexture = null;
|
ResetList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ResetList()
|
||||||
|
{
|
||||||
|
CurrentTextures = new List<Texture2d>();
|
||||||
|
CurrentTextures.Add(null);
|
||||||
|
CurrentTextures.Add(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
IGL GL;
|
IGL GL;
|
||||||
Texture2d CurrentTexture;
|
List<Texture2d> CurrentTextures;
|
||||||
|
|
||||||
public Texture2d Get(DisplaySurface ds)
|
public Texture2d Get(DisplaySurface ds)
|
||||||
{
|
{
|
||||||
|
@ -39,17 +48,28 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
public Texture2d Get(BitmapBuffer bb)
|
public Texture2d Get(BitmapBuffer bb)
|
||||||
{
|
{
|
||||||
|
//get the current entry
|
||||||
|
Texture2d CurrentTexture = CurrentTextures[0];
|
||||||
|
|
||||||
|
//check if its rotten and needs recreating
|
||||||
if (CurrentTexture == null || CurrentTexture.IntWidth != bb.Width || CurrentTexture.IntHeight != bb.Height)
|
if (CurrentTexture == null || CurrentTexture.IntWidth != bb.Width || CurrentTexture.IntHeight != bb.Height)
|
||||||
{
|
{
|
||||||
|
//needs recreating. be sure to kill the old one...
|
||||||
if (CurrentTexture != null)
|
if (CurrentTexture != null)
|
||||||
CurrentTexture.Dispose();
|
CurrentTexture.Dispose();
|
||||||
|
//and make a new one
|
||||||
CurrentTexture = GL.LoadTexture(bb);
|
CurrentTexture = GL.LoadTexture(bb);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//its good! just load in the data
|
||||||
GL.LoadTextureData(CurrentTexture, bb);
|
GL.LoadTextureData(CurrentTexture, bb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//now shuffle the buffers
|
||||||
|
CurrentTextures.Insert(0,CurrentTextures[1]);
|
||||||
|
CurrentTextures[1] = CurrentTexture;
|
||||||
|
|
||||||
return CurrentTexture;
|
return CurrentTexture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue