Support bindless texture gather shader instruction

This commit is contained in:
gdkchan 2019-12-07 18:31:17 -03:00 committed by Thog
parent 7ce5584f9e
commit 6b13c5b439
7 changed files with 69 additions and 3 deletions

View file

@ -0,0 +1,23 @@
namespace Ryujinx.Graphics.Shader.Decoders
{
interface IOpCodeTexture : IOpCode
{
Register Rd { get; }
Register Ra { get; }
Register Rb { get; }
bool IsArray { get; }
TextureDimensions Dimensions { get; }
int ComponentMask { get; }
int Immediate { get; }
TextureLodMode LodMode { get; }
bool HasOffset { get; }
bool HasDepthCompare { get; }
bool IsMultisample { get; }
}
}

View file

@ -0,0 +1,11 @@
namespace Ryujinx.Graphics.Shader.Decoders
{
interface IOpCodeTld4 : IOpCodeTexture
{
TextureGatherOffset Offset { get; }
int GatherCompIndex { get; }
bool Bindless { get; }
}
}

View file

@ -184,6 +184,7 @@ namespace Ryujinx.Graphics.Shader.Decoders
Set("11011100xx111x", InstEmit.Tld, typeof(OpCodeTld)); Set("11011100xx111x", InstEmit.Tld, typeof(OpCodeTld));
Set("11011101xx111x", InstEmit.TldB, typeof(OpCodeTld)); Set("11011101xx111x", InstEmit.TldB, typeof(OpCodeTld));
Set("110010xxxx111x", InstEmit.Tld4, typeof(OpCodeTld4)); Set("110010xxxx111x", InstEmit.Tld4, typeof(OpCodeTld4));
Set("1101111011111x", InstEmit.Tld4, typeof(OpCodeTld4B));
Set("110111100x1110", InstEmit.Txd, typeof(OpCodeTxd)); Set("110111100x1110", InstEmit.Txd, typeof(OpCodeTxd));
Set("1101111101001x", InstEmit.Txq, typeof(OpCodeTex)); Set("1101111101001x", InstEmit.Txq, typeof(OpCodeTex));
Set("1101111101010x", InstEmit.TxqB, typeof(OpCodeTex)); Set("1101111101010x", InstEmit.TxqB, typeof(OpCodeTex));

View file

@ -2,7 +2,7 @@ using Ryujinx.Graphics.Shader.Instructions;
namespace Ryujinx.Graphics.Shader.Decoders namespace Ryujinx.Graphics.Shader.Decoders
{ {
class OpCodeTexture : OpCode class OpCodeTexture : OpCode, IOpCodeTexture
{ {
public Register Rd { get; } public Register Rd { get; }
public Register Ra { get; } public Register Ra { get; }

View file

@ -2,12 +2,14 @@ using Ryujinx.Graphics.Shader.Instructions;
namespace Ryujinx.Graphics.Shader.Decoders namespace Ryujinx.Graphics.Shader.Decoders
{ {
class OpCodeTld4 : OpCodeTexture class OpCodeTld4 : OpCodeTexture, IOpCodeTld4
{ {
public TextureGatherOffset Offset { get; } public TextureGatherOffset Offset { get; }
public int GatherCompIndex { get; } public int GatherCompIndex { get; }
public bool Bindless => false;
public OpCodeTld4(InstEmitter emitter, ulong address, long opCode) : base(emitter, address, opCode) public OpCodeTld4(InstEmitter emitter, ulong address, long opCode) : base(emitter, address, opCode)
{ {
HasDepthCompare = opCode.Extract(50); HasDepthCompare = opCode.Extract(50);

View file

@ -0,0 +1,22 @@
using Ryujinx.Graphics.Shader.Instructions;
namespace Ryujinx.Graphics.Shader.Decoders
{
class OpCodeTld4B : OpCodeTexture, IOpCodeTld4
{
public TextureGatherOffset Offset { get; }
public int GatherCompIndex { get; }
public bool Bindless => true;
public OpCodeTld4B(InstEmitter emitter, ulong address, long opCode) : base(emitter, address, opCode)
{
HasDepthCompare = opCode.Extract(50);
Offset = (TextureGatherOffset)opCode.Extract(36, 2);
GatherCompIndex = opCode.Extract(38, 2);
}
}
}

View file

@ -417,7 +417,7 @@ namespace Ryujinx.Graphics.Shader.Instructions
public static void Tld4(EmitterContext context) public static void Tld4(EmitterContext context)
{ {
OpCodeTld4 op = (OpCodeTld4)context.CurrOp; IOpCodeTld4 op = (IOpCodeTld4)context.CurrOp;
if (op.Rd.IsRZ) if (op.Rd.IsRZ)
{ {
@ -455,6 +455,13 @@ namespace Ryujinx.Graphics.Shader.Instructions
TextureFlags flags = TextureFlags.Gather; TextureFlags flags = TextureFlags.Gather;
if (op.Bindless)
{
sourcesList.Add(Rb());
flags |= TextureFlags.Bindless;
}
int coordsCount = type.GetDimensions(); int coordsCount = type.GetDimensions();
for (int index = 0; index < coordsCount; index++) for (int index = 0; index < coordsCount; index++)