1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-21 01:22:02 +00:00

fix: don't dispose stencil state before using

This commit is contained in:
Samuliak 2024-05-25 13:15:30 +02:00 committed by Isaac Marovitz
parent acce02bdf5
commit 704a78c11f

View file

@ -36,6 +36,10 @@ namespace Ryujinx.Graphics.Metal
public void Dispose() public void Dispose()
{ {
// State
_currentState.FrontFaceStencil.Dispose();
_currentState.BackFaceStencil.Dispose();
_renderPipelineCache.Dispose(); _renderPipelineCache.Dispose();
_depthStencilCache.Dispose(); _depthStencilCache.Dispose();
} }
@ -327,18 +331,11 @@ namespace Ryujinx.Graphics.Metal
// Inlineable // Inlineable
public void UpdateStencilState(StencilTestDescriptor stencilTest) public void UpdateStencilState(StencilTestDescriptor stencilTest)
{ {
var backFace = new MTLStencilDescriptor // Cleanup old state
{ _currentState.FrontFaceStencil.Dispose();
StencilFailureOperation = stencilTest.BackSFail.Convert(), _currentState.BackFaceStencil.Dispose();
DepthFailureOperation = stencilTest.BackDpFail.Convert(),
DepthStencilPassOperation = stencilTest.BackDpPass.Convert(),
StencilCompareFunction = stencilTest.BackFunc.Convert(),
ReadMask = (uint)stencilTest.BackFuncMask,
WriteMask = (uint)stencilTest.BackMask
};
_currentState.BackFaceStencil = backFace;
var frontFace = new MTLStencilDescriptor _currentState.FrontFaceStencil = new MTLStencilDescriptor
{ {
StencilFailureOperation = stencilTest.FrontSFail.Convert(), StencilFailureOperation = stencilTest.FrontSFail.Convert(),
DepthFailureOperation = stencilTest.FrontDpFail.Convert(), DepthFailureOperation = stencilTest.FrontDpFail.Convert(),
@ -347,7 +344,16 @@ namespace Ryujinx.Graphics.Metal
ReadMask = (uint)stencilTest.FrontFuncMask, ReadMask = (uint)stencilTest.FrontFuncMask,
WriteMask = (uint)stencilTest.FrontMask WriteMask = (uint)stencilTest.FrontMask
}; };
_currentState.FrontFaceStencil = frontFace;
_currentState.BackFaceStencil = new MTLStencilDescriptor
{
StencilFailureOperation = stencilTest.BackSFail.Convert(),
DepthFailureOperation = stencilTest.BackDpFail.Convert(),
DepthStencilPassOperation = stencilTest.BackDpPass.Convert(),
StencilCompareFunction = stencilTest.BackFunc.Convert(),
ReadMask = (uint)stencilTest.BackFuncMask,
WriteMask = (uint)stencilTest.BackMask
};
_currentState.StencilTestEnabled = stencilTest.TestEnable; _currentState.StencilTestEnabled = stencilTest.TestEnable;
@ -370,8 +376,6 @@ namespace Ryujinx.Graphics.Metal
// Cleanup // Cleanup
descriptor.Dispose(); descriptor.Dispose();
frontFace.Dispose();
backFace.Dispose();
} }
// Inlineable // Inlineable