diff options
Diffstat (limited to 'src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs')
-rw-r--r-- | src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs | 83 |
1 files changed, 64 insertions, 19 deletions
diff --git a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs index bbac8038..5a231079 100644 --- a/src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs +++ b/src/Ryujinx.Graphics.Shader/Instructions/InstEmitTexture.cs @@ -1094,7 +1094,14 @@ namespace Ryujinx.Graphics.Shader.Instructions if (isBindless) { - type = (componentMask & 4) != 0 ? SamplerType.Texture3D : SamplerType.Texture2D; + if (query == TexQuery.TexHeaderTextureType) + { + type = SamplerType.Texture2D | SamplerType.Multisample; + } + else + { + type = (componentMask & 4) != 0 ? SamplerType.Texture3D : SamplerType.Texture2D; + } } else { @@ -1102,31 +1109,69 @@ namespace Ryujinx.Graphics.Shader.Instructions } TextureFlags flags = isBindless ? TextureFlags.Bindless : TextureFlags.None; + int binding; - int binding = isBindless ? 0 : context.ResourceManager.GetTextureOrImageBinding( - Instruction.TextureSize, - type, - TextureFormat.Unknown, - flags, - TextureOperation.DefaultCbufSlot, - imm); - - for (int compMask = componentMask, compIndex = 0; compMask != 0; compMask >>= 1, compIndex++) + switch (query) { - if ((compMask & 1) != 0) - { - Operand d = GetDest(); + case TexQuery.TexHeaderDimension: + binding = isBindless ? 0 : context.ResourceManager.GetTextureOrImageBinding( + Instruction.TextureQuerySize, + type, + TextureFormat.Unknown, + flags, + TextureOperation.DefaultCbufSlot, + imm); - if (d == null) + for (int compMask = componentMask, compIndex = 0; compMask != 0; compMask >>= 1, compIndex++) { - break; + if ((compMask & 1) != 0) + { + Operand d = GetDest(); + + if (d == null) + { + break; + } + + context.Copy(d, context.TextureQuerySize(type, flags, binding, compIndex, sources)); + } } + break; - // TODO: Validate and use query parameter. - Operand res = context.TextureSize(type, flags, binding, compIndex, sources); + case TexQuery.TexHeaderTextureType: + binding = isBindless ? 0 : context.ResourceManager.GetTextureOrImageBinding( + Instruction.TextureQuerySamples, + type, + TextureFormat.Unknown, + flags, + TextureOperation.DefaultCbufSlot, + imm); - context.Copy(d, res); - } + if ((componentMask & 4) != 0) + { + // Skip first 2 components if necessary. + if ((componentMask & 1) != 0) + { + GetDest(); + } + + if ((componentMask & 2) != 0) + { + GetDest(); + } + + Operand d = GetDest(); + + if (d != null) + { + context.Copy(d, context.TextureQuerySamples(type, flags, binding, sources)); + } + } + break; + + default: + context.TranslatorContext.GpuAccessor.Log($"Invalid or unsupported query type \"{query}\"."); + break; } } |