dispose all objects in encoder state manager

This commit is contained in:
Samuliak 2024-05-25 08:17:43 +02:00 committed by Isaac Marovitz
parent c26df1f7a3
commit 7654f0b16c

View file

@ -143,6 +143,9 @@ namespace Ryujinx.Graphics.Metal
SetTextureAndSampler(renderCommandEncoder, ShaderStage.Vertex, _currentState.VertexTextures, _currentState.VertexSamplers);
SetTextureAndSampler(renderCommandEncoder, ShaderStage.Fragment, _currentState.FragmentTextures, _currentState.FragmentSamplers);
// Cleanup
renderPassDescriptor.Dispose();
return renderCommandEncoder;
}
@ -217,16 +220,13 @@ namespace Ryujinx.Graphics.Metal
}
}
renderPipelineDescriptor.VertexDescriptor = BuildVertexDescriptor(_currentState.VertexBuffers, _currentState.VertexAttribs);
var vertexDescriptor = BuildVertexDescriptor(_currentState.VertexBuffers, _currentState.VertexAttribs);
renderPipelineDescriptor.VertexDescriptor = vertexDescriptor;
if (_currentState.VertexFunction != null)
{
renderPipelineDescriptor.VertexFunction = _currentState.VertexFunction.Value;
}
else
{
return;
}
if (_currentState.FragmentFunction != null)
{
@ -242,6 +242,10 @@ namespace Ryujinx.Graphics.Metal
_currentState.BlendColor.Green,
_currentState.BlendColor.Blue,
_currentState.BlendColor.Alpha);
// Cleanup
renderPipelineDescriptor.Dispose();
vertexDescriptor.Dispose();
}
public void UpdateIndexBuffer(BufferRange buffer, IndexType type)
@ -320,7 +324,7 @@ namespace Ryujinx.Graphics.Metal
// Inlineable
public void UpdateStencilState(StencilTestDescriptor stencilTest)
{
_currentState.BackFaceStencil = new MTLStencilDescriptor
var backFace = new MTLStencilDescriptor
{
StencilFailureOperation = stencilTest.BackSFail.Convert(),
DepthFailureOperation = stencilTest.BackDpFail.Convert(),
@ -329,8 +333,9 @@ namespace Ryujinx.Graphics.Metal
ReadMask = (uint)stencilTest.BackFuncMask,
WriteMask = (uint)stencilTest.BackMask
};
_currentState.BackFaceStencil = backFace;
_currentState.FrontFaceStencil = new MTLStencilDescriptor
var frontFace = new MTLStencilDescriptor
{
StencilFailureOperation = stencilTest.FrontSFail.Convert(),
DepthFailureOperation = stencilTest.FrontDpFail.Convert(),
@ -339,6 +344,7 @@ namespace Ryujinx.Graphics.Metal
ReadMask = (uint)stencilTest.FrontFuncMask,
WriteMask = (uint)stencilTest.FrontMask
};
_currentState.FrontFaceStencil = frontFace;
_currentState.StencilTestEnabled = stencilTest.TestEnable;
@ -358,6 +364,11 @@ namespace Ryujinx.Graphics.Metal
// Mark dirty
_currentState.Dirty.DepthStencil = true;
// Cleanup
descriptor.Dispose();
frontFace.Dispose();
backFace.Dispose();
}
// Inlineable
@ -382,6 +393,9 @@ namespace Ryujinx.Graphics.Metal
// Mark dirty
_currentState.Dirty.DepthStencil = true;
// Cleanup
descriptor.Dispose();
}
// Inlineable