Fixed memory leak when deleting Effect

This commit is contained in:
Simon Lübeß
2024-08-24 20:09:22 +02:00
parent b98de9835d
commit ad73abd4ea
10 changed files with 139 additions and 176 deletions
@@ -8,18 +8,17 @@ namespace GlitchyEngine.Renderer
{
extension BufferCollection
{
public static override int MaxBufferSlotCount => DirectX.D3D11.D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT;
internal ID3D11Buffer*[DirectX.D3D11.D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT] nativeBuffers;
internal void PlatformFetchNativeBuffers()
{
Debug.Profiler.ProfileRendererFunction!();
// Clear
nativeBuffers = .();
for(let buffer in _buffers)
{
nativeBuffers[buffer.Index] = buffer.Buffer.nativeBuffer;
nativeBuffers[@buffer] = buffer.Buffer?.nativeBuffer;
}
}
}
@@ -334,10 +334,7 @@ namespace GlitchyEngine.Renderer
_ps_FirstTexture = _firstTexture;
_ps_BoundTextures = _textureCount;
for (var buffer in shader?.Buffers)
{
_psBuffers[buffer.Index] = buffer.Buffer.nativeBuffer;
}
_psBuffers = shader.Buffers.nativeBuffers;
//NativeContext.PixelShader.SetConstantBuffers(0, shader.Buffers.nativeBuffers.Count, &shader.Buffers.nativeBuffers);
@@ -351,11 +348,8 @@ namespace GlitchyEngine.Renderer
NativeContext.VertexShader.SetShaderResources(_firstTexture, _textureCount, &_textures[_firstTexture]);
NativeContext.VertexShader.SetSamplers(_firstTexture, _textureCount, &_samplers[_firstTexture]);
}
for (var buffer in shader?.Buffers)
{
_vsBuffers[buffer.Index] = buffer.Buffer.nativeBuffer;
}
_vsBuffers = shader.Buffers.nativeBuffers;
//NativeContext.VertexShader.SetConstantBuffers(0, shader.Buffers.nativeBuffers.Count, &shader.Buffers.nativeBuffers);