From 81b1ae4bcf7875a838ccce727168f7189e3a2d04 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Mon, 9 Oct 2023 11:16:33 -0400 Subject: [PATCH] Partial TextureQuerySamples --- .../CodeGen/Msl/Instructions/InstGen.cs | 2 +- .../CodeGen/Msl/Instructions/InstGenMemory.cs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGen.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGen.cs index 030f3402e..f4eb33516 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGen.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGen.cs @@ -138,7 +138,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions case Instruction.TextureSample: return TextureSample(context, operation); case Instruction.TextureQuerySamples: - return "|| TEXTURE QUERY SIZE ||"; + return TextureQuerySamples(context, operation); case Instruction.TextureQuerySize: return TextureQuerySize(context, operation); case Instruction.VectorExtract: diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenMemory.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenMemory.cs index 613387843..73936383c 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenMemory.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Msl/Instructions/InstGenMemory.cs @@ -269,6 +269,25 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions return swizzle; } + public static string TextureQuerySamples(CodeGenContext context, AstOperation operation) + { + AstTextureOperation texOp = (AstTextureOperation)operation; + + bool isBindless = (texOp.Flags & TextureFlags.Bindless) != 0; + + // TODO: Bindless texture support. For now we just return 0. + if (isBindless) + { + return NumberFormatter.FormatInt(0); + } + + string textureName = "texture"; + string texCall = textureName + "."; + texCall += $"get_num_samples()"; + + return texCall; + } + public static string TextureQuerySize(CodeGenContext context, AstOperation operation) { AstTextureOperation texOp = (AstTextureOperation)operation;