mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-28 03:23:05 +00:00
don't recreate render pipeline unless we're about to draw, pass view depth properly (#22)
This commit is contained in:
parent
58b3e2e82b
commit
02de48a6f2
3 changed files with 16 additions and 18 deletions
|
@ -122,7 +122,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
fixed (float* ptr = region)
|
fixed (float* ptr = region)
|
||||||
{
|
{
|
||||||
_pipeline.GetOrCreateRenderEncoder().SetVertexBytes((IntPtr)ptr, RegionBufferSize, 0);
|
_pipeline.GetOrCreateRenderEncoder(true).SetVertexBytes((IntPtr)ptr, RegionBufferSize, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
_pipeline.Draw(4, 1, 0, 0);
|
_pipeline.Draw(4, 1, 0, 0);
|
||||||
|
@ -191,7 +191,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
fixed (float* ptr = region)
|
fixed (float* ptr = region)
|
||||||
{
|
{
|
||||||
_pipeline.GetOrCreateRenderEncoder().SetVertexBytes((IntPtr)ptr, RegionBufferSize, 0);
|
_pipeline.GetOrCreateRenderEncoder(true).SetVertexBytes((IntPtr)ptr, RegionBufferSize, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
_pipeline.Draw(4, 1, 0, 0);
|
_pipeline.Draw(4, 1, 0, 0);
|
||||||
|
@ -234,7 +234,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
fixed (float* ptr = clearColor)
|
fixed (float* ptr = clearColor)
|
||||||
{
|
{
|
||||||
_pipeline.GetOrCreateRenderEncoder().SetFragmentBytes((IntPtr)ptr, ClearColorBufferSize, 0);
|
_pipeline.GetOrCreateRenderEncoder(true).SetFragmentBytes((IntPtr)ptr, ClearColorBufferSize, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
_pipeline.Draw(4, 1, 0, 0);
|
_pipeline.Draw(4, 1, 0, 0);
|
||||||
|
@ -276,7 +276,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
_pipeline.SetViewports(viewports);
|
_pipeline.SetViewports(viewports);
|
||||||
_pipeline.SetDepthTest(new DepthTestDescriptor(true, depthMask, CompareOp.Always));
|
_pipeline.SetDepthTest(new DepthTestDescriptor(true, depthMask, CompareOp.Always));
|
||||||
// _pipeline.SetStencilTest(CreateStencilTestDescriptor(stencilMask != 0, stencilValue, 0xFF, stencilMask));
|
// _pipeline.SetStencilTest(CreateStencilTestDescriptor(stencilMask != 0, stencilValue, 0xFF, stencilMask));
|
||||||
_pipeline.GetOrCreateRenderEncoder().SetFragmentBytes(ptr, ClearDepthBufferSize, 0);
|
_pipeline.GetOrCreateRenderEncoder(true).SetFragmentBytes(ptr, ClearDepthBufferSize, 0);
|
||||||
_pipeline.Draw(4, 1, 0, 0);
|
_pipeline.Draw(4, 1, 0, 0);
|
||||||
|
|
||||||
// Restore previous state
|
// Restore previous state
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
_encoderStateManager.SetClearLoadAction(clear);
|
_encoderStateManager.SetClearLoadAction(clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MTLRenderCommandEncoder GetOrCreateRenderEncoder()
|
public MTLRenderCommandEncoder GetOrCreateRenderEncoder(bool forDraw = false)
|
||||||
{
|
{
|
||||||
MTLRenderCommandEncoder renderCommandEncoder;
|
MTLRenderCommandEncoder renderCommandEncoder;
|
||||||
if (_currentEncoder == null || _currentEncoderType != EncoderType.Render)
|
if (_currentEncoder == null || _currentEncoderType != EncoderType.Render)
|
||||||
|
@ -88,7 +88,10 @@ namespace Ryujinx.Graphics.Metal
|
||||||
renderCommandEncoder = new MTLRenderCommandEncoder(_currentEncoder.Value);
|
renderCommandEncoder = new MTLRenderCommandEncoder(_currentEncoder.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (forDraw)
|
||||||
|
{
|
||||||
_encoderStateManager.RebindRenderState(renderCommandEncoder);
|
_encoderStateManager.RebindRenderState(renderCommandEncoder);
|
||||||
|
}
|
||||||
|
|
||||||
return renderCommandEncoder;
|
return renderCommandEncoder;
|
||||||
}
|
}
|
||||||
|
@ -325,7 +328,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
public void Draw(int vertexCount, int instanceCount, int firstVertex, int firstInstance)
|
public void Draw(int vertexCount, int instanceCount, int firstVertex, int firstInstance)
|
||||||
{
|
{
|
||||||
var renderCommandEncoder = GetOrCreateRenderEncoder();
|
var renderCommandEncoder = GetOrCreateRenderEncoder(true);
|
||||||
|
|
||||||
// TODO: Support topology re-indexing to provide support for TriangleFans
|
// TODO: Support topology re-indexing to provide support for TriangleFans
|
||||||
var primitiveType = _encoderStateManager.Topology.Convert();
|
var primitiveType = _encoderStateManager.Topology.Convert();
|
||||||
|
@ -340,7 +343,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
public void DrawIndexed(int indexCount, int instanceCount, int firstIndex, int firstVertex, int firstInstance)
|
public void DrawIndexed(int indexCount, int instanceCount, int firstIndex, int firstVertex, int firstInstance)
|
||||||
{
|
{
|
||||||
var renderCommandEncoder = GetOrCreateRenderEncoder();
|
var renderCommandEncoder = GetOrCreateRenderEncoder(true);
|
||||||
|
|
||||||
// TODO: Support topology re-indexing to provide support for TriangleFans
|
// TODO: Support topology re-indexing to provide support for TriangleFans
|
||||||
var primitiveType = _encoderStateManager.Topology.Convert();
|
var primitiveType = _encoderStateManager.Topology.Convert();
|
||||||
|
@ -360,28 +363,28 @@ namespace Ryujinx.Graphics.Metal
|
||||||
|
|
||||||
public void DrawIndexedIndirect(BufferRange indirectBuffer)
|
public void DrawIndexedIndirect(BufferRange indirectBuffer)
|
||||||
{
|
{
|
||||||
// var renderCommandEncoder = GetOrCreateRenderEncoder();
|
// var renderCommandEncoder = GetOrCreateRenderEncoder(true);
|
||||||
|
|
||||||
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawIndexedIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
|
public void DrawIndexedIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
|
||||||
{
|
{
|
||||||
// var renderCommandEncoder = GetOrCreateRenderEncoder();
|
// var renderCommandEncoder = GetOrCreateRenderEncoder(true);
|
||||||
|
|
||||||
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawIndirect(BufferRange indirectBuffer)
|
public void DrawIndirect(BufferRange indirectBuffer)
|
||||||
{
|
{
|
||||||
// var renderCommandEncoder = GetOrCreateRenderEncoder();
|
// var renderCommandEncoder = GetOrCreateRenderEncoder(true);
|
||||||
|
|
||||||
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
|
public void DrawIndirectCount(BufferRange indirectBuffer, BufferRange parameterBuffer, int maxDrawCount, int stride)
|
||||||
{
|
{
|
||||||
// var renderCommandEncoder = GetOrCreateRenderEncoder();
|
// var renderCommandEncoder = GetOrCreateRenderEncoder(true);
|
||||||
|
|
||||||
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
Logger.Warning?.Print(LogClass.Gpu, "Not Implemented!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,12 +46,7 @@ namespace Ryujinx.Graphics.Metal
|
||||||
levels.length = (ulong)Info.Levels;
|
levels.length = (ulong)Info.Levels;
|
||||||
NSRange slices;
|
NSRange slices;
|
||||||
slices.location = (ulong)firstLayer;
|
slices.location = (ulong)firstLayer;
|
||||||
slices.length = 1;
|
|
||||||
|
|
||||||
if (info.Target != Target.Texture3D && info.Target != Target.Cubemap)
|
|
||||||
{
|
|
||||||
slices.length = (ulong)Info.Depth;
|
slices.length = (ulong)Info.Depth;
|
||||||
}
|
|
||||||
|
|
||||||
var swizzle = GetSwizzle(info, pixelFormat);
|
var swizzle = GetSwizzle(info, pixelFormat);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue