Pass sampler to Blit shader

This commit is contained in:
Isaac Marovitz 2023-08-03 08:58:14 -04:00 committed by Isaac Marovitz
parent a03471a8ab
commit d0d5c76f06
2 changed files with 23 additions and 4 deletions

View file

@ -33,8 +33,7 @@ vertex CopyVertexOut vertexBlit(unsigned short vid [[vertex_id]]) {
} }
fragment float4 fragmentBlit(CopyVertexOut in [[stage_in]], fragment float4 fragmentBlit(CopyVertexOut in [[stage_in]],
texture2d<float> tex) { texture2d<float, access::sample> texture [[texture(0)]],
constexpr sampler sam(min_filter::nearest, mag_filter::nearest, mip_filter::none); sampler sampler [[sampler(0)]]) {
return texture.sample(sampler, in.uv);
return tex.sample(sam, in.uv).xyzw;
} }

View file

@ -101,7 +101,15 @@ namespace Ryujinx.Graphics.Metal
Logger.Warning?.Print(LogClass.Gpu, "Began present"); Logger.Warning?.Print(LogClass.Gpu, "Began present");
_renderEncoderState.SetEncoderState(renderCommandEncoder); _renderEncoderState.SetEncoderState(renderCommandEncoder);
var sampler = _device.NewSamplerState(new MTLSamplerDescriptor
{
MinFilter = MTLSamplerMinMagFilter.Nearest,
MagFilter = MTLSamplerMinMagFilter.Nearest,
MipFilter = MTLSamplerMipFilter.NotMipmapped
});
renderCommandEncoder.SetFragmentTexture(texture.MTLTexture, 0); renderCommandEncoder.SetFragmentTexture(texture.MTLTexture, 0);
renderCommandEncoder.SetFragmentSamplerState(sampler, 0);
renderCommandEncoder.DrawPrimitives(MTLPrimitiveType.Triangle, 0, 6); renderCommandEncoder.DrawPrimitives(MTLPrimitiveType.Triangle, 0, 6);
renderCommandEncoder.EndEncoding(); renderCommandEncoder.EndEncoding();
@ -199,6 +207,8 @@ 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)
{ {
Logger.Warning?.Print(LogClass.Gpu, "Draw");
MTLRenderCommandEncoder renderCommandEncoder; MTLRenderCommandEncoder renderCommandEncoder;
if (_currentEncoder is MTLRenderCommandEncoder encoder) if (_currentEncoder is MTLRenderCommandEncoder encoder)
@ -218,6 +228,8 @@ 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)
{ {
Logger.Warning?.Print(LogClass.Gpu, "Draw");
MTLRenderCommandEncoder renderCommandEncoder; MTLRenderCommandEncoder renderCommandEncoder;
if (_currentEncoder is MTLRenderCommandEncoder encoder) if (_currentEncoder is MTLRenderCommandEncoder encoder)
@ -292,6 +304,8 @@ namespace Ryujinx.Graphics.Metal
public void SetDepthTest(DepthTestDescriptor depthTest) public void SetDepthTest(DepthTestDescriptor depthTest)
{ {
Logger.Warning?.Print(LogClass.Gpu, "Set depth test");
var depthStencilState = _renderEncoderState.UpdateDepthState( var depthStencilState = _renderEncoderState.UpdateDepthState(
depthTest.TestEnable ? MTLCompareFunction.Always : depthTest.Func.Convert(), depthTest.TestEnable ? MTLCompareFunction.Always : depthTest.Func.Convert(),
depthTest.WriteEnable); depthTest.WriteEnable);
@ -304,6 +318,8 @@ namespace Ryujinx.Graphics.Metal
public void SetFaceCulling(bool enable, Face face) public void SetFaceCulling(bool enable, Face face)
{ {
Logger.Warning?.Print(LogClass.Gpu, "Set face culling");
var cullMode = enable ? face.Convert() : MTLCullMode.None; var cullMode = enable ? face.Convert() : MTLCullMode.None;
if (_currentEncoder is MTLRenderCommandEncoder renderCommandEncoder) if (_currentEncoder is MTLRenderCommandEncoder renderCommandEncoder)
@ -316,6 +332,8 @@ namespace Ryujinx.Graphics.Metal
public void SetFrontFace(FrontFace frontFace) public void SetFrontFace(FrontFace frontFace)
{ {
Logger.Warning?.Print(LogClass.Gpu, "Set front face");
var winding = frontFace.Convert(); var winding = frontFace.Convert();
if (_currentEncoder is MTLRenderCommandEncoder renderCommandEncoder) if (_currentEncoder is MTLRenderCommandEncoder renderCommandEncoder)
@ -328,6 +346,8 @@ namespace Ryujinx.Graphics.Metal
public void SetIndexBuffer(BufferRange buffer, IndexType type) public void SetIndexBuffer(BufferRange buffer, IndexType type)
{ {
Logger.Warning?.Print(LogClass.Gpu, "Set index buffer");
if (buffer.Handle != BufferHandle.Null) if (buffer.Handle != BufferHandle.Null)
{ {
_indexType = type.Convert(); _indexType = type.Convert();