mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Kind of fixed a memory leak
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using DirectX.Common;
|
using DirectX.Common;
|
||||||
using GlitchyEngine.Core;
|
using GlitchyEngine.Core;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace GlitchyEngine
|
namespace GlitchyEngine
|
||||||
{
|
{
|
||||||
@@ -15,6 +16,15 @@ namespace GlitchyEngine
|
|||||||
oldDest?.ReleaseRef();
|
oldDest?.ReleaseRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Releases the reference to destination, writes newValue into it and adds a reference to newValue.
|
||||||
|
public static mixin SetReferenceVar<T>(T destination, T newValue) where T: var
|
||||||
|
{
|
||||||
|
var oldDest = destination;
|
||||||
|
destination = newValue;
|
||||||
|
destination?.AddRef();
|
||||||
|
oldDest?.Release();
|
||||||
|
}
|
||||||
|
|
||||||
/// Releases the reference to value and nullifies it.
|
/// Releases the reference to value and nullifies it.
|
||||||
public static mixin ReleaseRefAndNullify<T>(T value) where T: RefCounter
|
public static mixin ReleaseRefAndNullify<T>(T value) where T: RefCounter
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ public class Effect : Asset
|
|||||||
{
|
{
|
||||||
Debug.Profiler.ProfileRendererFunction!();
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|
||||||
[Inline]InternalSetTexture(name, textureViewBinding..AddRef());
|
[Inline]InternalSetTexture(name, textureViewBinding);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InternalSetTexture(String name, TextureViewBinding textureViewBinding)
|
private void InternalSetTexture(String name, TextureViewBinding textureViewBinding)
|
||||||
@@ -256,29 +256,17 @@ public class Effect : Asset
|
|||||||
|
|
||||||
ref TextureEntry entry = ref _textures[name];
|
ref TextureEntry entry = ref _textures[name];
|
||||||
|
|
||||||
|
// TODO: Thats weird, we increment this reference somewhere... but WHERE?!
|
||||||
entry.BoundTexture.Release();
|
entry.BoundTexture.Release();
|
||||||
entry.BoundTexture = textureViewBinding;
|
entry.BoundTexture = textureViewBinding;
|
||||||
|
|
||||||
entry.VsSlot?.BoundTexture..Release() = entry.BoundTexture..AddRef();
|
if (entry.VsSlot != null)
|
||||||
entry.PsSlot?.BoundTexture..Release() = entry.BoundTexture..AddRef();
|
SetReferenceVar!(entry.VsSlot.BoundTexture, entry.BoundTexture);
|
||||||
|
|
||||||
|
if (entry.PsSlot != null)
|
||||||
|
SetReferenceVar!(entry.PsSlot.BoundTexture, entry.BoundTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*private void ApplyTextures()
|
|
||||||
{
|
|
||||||
Debug.Profiler.ProfileRendererFunction!();
|
|
||||||
|
|
||||||
for(let (name, entry) in _textures)
|
|
||||||
{
|
|
||||||
entry.VsSlot?.BoundTexture.Release();
|
|
||||||
entry.VsSlot?.BoundTexture = entry.BoundTexture;
|
|
||||||
entry.VsSlot?.BoundTexture.AddRef();
|
|
||||||
|
|
||||||
entry.PsSlot?.BoundTexture.Release();
|
|
||||||
entry.PsSlot?.BoundTexture = entry.BoundTexture;
|
|
||||||
entry.PsSlot?.BoundTexture.AddRef();
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public void ApplyChanges()
|
public void ApplyChanges()
|
||||||
{
|
{
|
||||||
Debug.Profiler.ProfileRendererFunction!();
|
Debug.Profiler.ProfileRendererFunction!();
|
||||||
|
|||||||
Reference in New Issue
Block a user