Remove PBO
It was not used correctly and is actually not really required so save the time fixing it...
This commit is contained in:
1 parent
1ce085b49f
commit
4d197bda9a
3 files changed
+11
-72
No files matched your search
@@ -45,6 +45,7 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
class CD3DTexture : CTextureBase, IDisposable
|
class CD3DTexture : CTextureBase, IDisposable
|
||||||
{
|
{
|
||||||
public readonly Texture D3DTexture;
|
public readonly Texture D3DTexture;
|
||||||
|
|
||||||
public CD3DTexture(Device device, Size dataSize, int texWidth = 0, int texHeight = 0) : base(dataSize, texWidth, texHeight)
|
public CD3DTexture(Device device, Size dataSize, int texWidth = 0, int texHeight = 0) : base(dataSize, texWidth, texHeight)
|
||||||
{
|
{
|
||||||
D3DTexture = new Texture(device, W2, H2, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed);
|
D3DTexture = new Texture(device, W2, H2, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed);
|
||||||
@@ -482,7 +483,7 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public CTextureRef CopyScreen()
|
public CTextureRef CopyScreen()
|
||||||
{
|
{
|
||||||
var tex = _CreateTexture(new Size(_W, _H));
|
CD3DTexture tex = _CreateTexture(new Size(_W, _H));
|
||||||
Surface backbufferSurface = _Device.GetBackBuffer(0, 0);
|
Surface backbufferSurface = _Device.GetBackBuffer(0, 0);
|
||||||
Surface textureSurface = tex.D3DTexture.GetSurfaceLevel(0);
|
Surface textureSurface = tex.D3DTexture.GetSurfaceLevel(0);
|
||||||
Surface.FromSurface(textureSurface, backbufferSurface, Filter.Default, 0, new Rectangle(0, 0, _W, _H), new Rectangle(0, 0, _W, _H));
|
Surface.FromSurface(textureSurface, backbufferSurface, Filter.Default, 0, new Rectangle(0, 0, _W, _H), new Rectangle(0, 0, _W, _H));
|
||||||
|
|||||||
@@ -396,33 +396,17 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Checks if a texture exists
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="texture">The texture to check</param>
|
|
||||||
/// <returns>True if the texture exists</returns>
|
|
||||||
protected bool _TextureExists(CTextureRef texture)
|
|
||||||
{
|
|
||||||
TTextureType t;
|
|
||||||
return _GetTexture(texture, out t);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected TTextureType _GetTexture(CTextureRef textureRef)
|
|
||||||
{
|
|
||||||
if (textureRef == null)
|
|
||||||
return null;
|
|
||||||
TTextureType texture;
|
|
||||||
lock (_Textures)
|
|
||||||
{
|
|
||||||
_Textures.TryGetValue(textureRef.ID, out texture);
|
|
||||||
}
|
|
||||||
return texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected bool _GetTexture(CTextureRef textureRef, out TTextureType texture)
|
protected bool _GetTexture(CTextureRef textureRef, out TTextureType texture)
|
||||||
{
|
{
|
||||||
texture = _GetTexture(textureRef);
|
if (textureRef == null)
|
||||||
return texture != null;
|
{
|
||||||
|
texture = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
lock (_Textures)
|
||||||
|
{
|
||||||
|
return _Textures.TryGetValue(textureRef.ID, out texture) && texture!=null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ using OpenTK.Graphics;
|
|||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Vocaluxe.Base;
|
using Vocaluxe.Base;
|
||||||
using VocaluxeLib;
|
using VocaluxeLib;
|
||||||
@@ -29,9 +28,6 @@ using VocaluxeLib.Draw;
|
|||||||
using BeginMode = OpenTK.Graphics.OpenGL.BeginMode;
|
using BeginMode = OpenTK.Graphics.OpenGL.BeginMode;
|
||||||
using BlendingFactorDest = OpenTK.Graphics.OpenGL.BlendingFactorDest;
|
using BlendingFactorDest = OpenTK.Graphics.OpenGL.BlendingFactorDest;
|
||||||
using BlendingFactorSrc = OpenTK.Graphics.OpenGL.BlendingFactorSrc;
|
using BlendingFactorSrc = OpenTK.Graphics.OpenGL.BlendingFactorSrc;
|
||||||
using BufferAccess = OpenTK.Graphics.OpenGL.BufferAccess;
|
|
||||||
using BufferTarget = OpenTK.Graphics.OpenGL.BufferTarget;
|
|
||||||
using BufferUsageHint = OpenTK.Graphics.OpenGL.BufferUsageHint;
|
|
||||||
using ClearBufferMask = OpenTK.Graphics.OpenGL.ClearBufferMask;
|
using ClearBufferMask = OpenTK.Graphics.OpenGL.ClearBufferMask;
|
||||||
using DepthFunction = OpenTK.Graphics.OpenGL.DepthFunction;
|
using DepthFunction = OpenTK.Graphics.OpenGL.DepthFunction;
|
||||||
using EnableCap = OpenTK.Graphics.OpenGL.EnableCap;
|
using EnableCap = OpenTK.Graphics.OpenGL.EnableCap;
|
||||||
@@ -62,7 +58,6 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
|
|
||||||
class COGLTexture : CTextureBase, IDisposable
|
class COGLTexture : CTextureBase, IDisposable
|
||||||
{
|
{
|
||||||
public int PBO;
|
|
||||||
//The texture "name" according to the specs
|
//The texture "name" according to the specs
|
||||||
public readonly int Name;
|
public readonly int Name;
|
||||||
|
|
||||||
@@ -79,8 +74,6 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
throw new ObjectDisposedException(GetType().Name);
|
throw new ObjectDisposedException(GetType().Name);
|
||||||
_IsDisposed = true;
|
_IsDisposed = true;
|
||||||
GL.DeleteTexture(Name);
|
GL.DeleteTexture(Name);
|
||||||
if (PBO > 0)
|
|
||||||
GL.DeleteBuffers(1, ref PBO);
|
|
||||||
RefCount = 0;
|
RefCount = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,7 +82,6 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
{
|
{
|
||||||
#region private vars
|
#region private vars
|
||||||
private readonly GLControl _Control;
|
private readonly GLControl _Control;
|
||||||
private bool _UsePBO;
|
|
||||||
#endregion private vars
|
#endregion private vars
|
||||||
|
|
||||||
public COpenGL()
|
public COpenGL()
|
||||||
@@ -426,7 +418,6 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
|
|
||||||
GL.BindTexture(TextureTarget.Texture2D, texture.Name);
|
GL.BindTexture(TextureTarget.Texture2D, texture.Name);
|
||||||
|
|
||||||
GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1);
|
|
||||||
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, texture.W2, texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
|
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, texture.W2, texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
|
||||||
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, texture.DataSize.Width, texture.DataSize.Height, PixelFormat.Bgra, PixelType.UnsignedByte, data);
|
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, texture.DataSize.Width, texture.DataSize.Height, PixelFormat.Bgra, PixelType.UnsignedByte, data);
|
||||||
|
|
||||||
@@ -444,22 +435,6 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
{
|
{
|
||||||
COGLTexture texture = _CreateTexture(dataSize);
|
COGLTexture texture = _CreateTexture(dataSize);
|
||||||
|
|
||||||
if (_UsePBO)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
GL.GenBuffers(1, out texture.PBO);
|
|
||||||
GL.BindBuffer(BufferTarget.PixelUnpackBuffer, texture.PBO);
|
|
||||||
GL.BufferData(BufferTarget.PixelUnpackBuffer, (IntPtr)data.Length, IntPtr.Zero, BufferUsageHint.StreamDraw);
|
|
||||||
GL.BindBuffer(BufferTarget.PixelUnpackBuffer, 0);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
CLog.LogError("PBO creation failed. Using fallback solution.", false, false, e);
|
|
||||||
_UsePBO = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GL.BindTexture(TextureTarget.Texture2D, texture.Name);
|
GL.BindTexture(TextureTarget.Texture2D, texture.Name);
|
||||||
|
|
||||||
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, texture.W2, texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
|
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, texture.W2, texture.H2, 0, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
|
||||||
@@ -491,27 +466,6 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
texture.DataSize = new Size(w, h);
|
texture.DataSize = new Size(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_UsePBO)
|
|
||||||
{
|
|
||||||
GL.BindBuffer(BufferTarget.PixelUnpackBuffer, texture.PBO);
|
|
||||||
|
|
||||||
IntPtr buffer = GL.MapBuffer(BufferTarget.PixelUnpackBuffer, BufferAccess.WriteOnly);
|
|
||||||
Marshal.Copy(data, 0, buffer, data.Length);
|
|
||||||
|
|
||||||
GL.UnmapBuffer(BufferTarget.PixelUnpackBuffer);
|
|
||||||
|
|
||||||
GL.BindTexture(TextureTarget.Texture2D, texture.Name);
|
|
||||||
|
|
||||||
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, w, h, PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);
|
|
||||||
|
|
||||||
GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D);
|
|
||||||
|
|
||||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
|
||||||
GL.BindBuffer(BufferTarget.PixelUnpackBuffer, 0);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
GL.BindTexture(TextureTarget.Texture2D, texture.Name);
|
GL.BindTexture(TextureTarget.Texture2D, texture.Name);
|
||||||
|
|
||||||
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, w, h, PixelFormat.Bgra, PixelType.UnsignedByte, data);
|
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, w, h, PixelFormat.Bgra, PixelType.UnsignedByte, data);
|
||||||
|
|||||||
Reference in new issue
Block a user