Start Load/Store implementation
This commit is contained in:
parent
058dcda18d
commit
9fdbd1150f
2 changed files with 56 additions and 2 deletions
|
@ -5,6 +5,7 @@ using System;
|
||||||
|
|
||||||
using static Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions.InstGenCall;
|
using static Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions.InstGenCall;
|
||||||
using static Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions.InstGenHelper;
|
using static Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions.InstGenHelper;
|
||||||
|
using static Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions.InstGenMemory;
|
||||||
using static Ryujinx.Graphics.Shader.StructuredIr.InstructionInfo;
|
using static Ryujinx.Graphics.Shader.StructuredIr.InstructionInfo;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||||
|
@ -126,13 +127,13 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||||
case Instruction.ImageAtomic:
|
case Instruction.ImageAtomic:
|
||||||
return "|| IMAGE ATOMIC ||";
|
return "|| IMAGE ATOMIC ||";
|
||||||
case Instruction.Load:
|
case Instruction.Load:
|
||||||
return "|| LOAD ||";
|
return Load(context, operation);
|
||||||
case Instruction.Lod:
|
case Instruction.Lod:
|
||||||
return "|| LOD ||";
|
return "|| LOD ||";
|
||||||
case Instruction.MemoryBarrier:
|
case Instruction.MemoryBarrier:
|
||||||
return "|| MEMORY BARRIER ||";
|
return "|| MEMORY BARRIER ||";
|
||||||
case Instruction.Store:
|
case Instruction.Store:
|
||||||
return "|| STORE ||";
|
return Store(context, operation);
|
||||||
case Instruction.TextureSample:
|
case Instruction.TextureSample:
|
||||||
return "|| TEXTURE SAMPLE ||";
|
return "|| TEXTURE SAMPLE ||";
|
||||||
case Instruction.TextureSize:
|
case Instruction.TextureSize:
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
using Ryujinx.Graphics.Shader.IntermediateRepresentation;
|
||||||
|
using Ryujinx.Graphics.Shader.StructuredIr;
|
||||||
|
using Ryujinx.Graphics.Shader.Translation;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Ryujinx.Graphics.Shader.CodeGen.Msl.Instructions
|
||||||
|
{
|
||||||
|
static class InstGenMemory
|
||||||
|
{
|
||||||
|
public static string GenerateLoadOrStore(CodeGenContext context, AstOperation operation, bool isStore)
|
||||||
|
{
|
||||||
|
StorageKind storageKind = operation.StorageKind;
|
||||||
|
|
||||||
|
string varName;
|
||||||
|
AggregateType varType;
|
||||||
|
int srcIndex = 0;
|
||||||
|
bool isStoreOrAtomic = operation.Inst == Instruction.Store || operation.Inst.IsAtomic();
|
||||||
|
int inputsCount = isStoreOrAtomic ? operation.SourcesCount - 1 : operation.SourcesCount;
|
||||||
|
|
||||||
|
if (operation.Inst == Instruction.AtomicCompareAndSwap)
|
||||||
|
{
|
||||||
|
inputsCount--;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (storageKind)
|
||||||
|
{
|
||||||
|
case StorageKind.ConstantBuffer:
|
||||||
|
case StorageKind.StorageBuffer:
|
||||||
|
return "Constant or Storage buffer load or store";
|
||||||
|
case StorageKind.LocalMemory:
|
||||||
|
case StorageKind.SharedMemory:
|
||||||
|
return "Local or Shader memory load or store";
|
||||||
|
case StorageKind.Input:
|
||||||
|
case StorageKind.InputPerPatch:
|
||||||
|
case StorageKind.Output:
|
||||||
|
case StorageKind.OutputPerPatch:
|
||||||
|
return "I/O load or store";
|
||||||
|
default:
|
||||||
|
throw new InvalidOperationException($"Invalid storage kind {storageKind}.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Load(CodeGenContext context, AstOperation operation)
|
||||||
|
{
|
||||||
|
return GenerateLoadOrStore(context, operation, isStore: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Store(CodeGenContext context, AstOperation operation)
|
||||||
|
{
|
||||||
|
return GenerateLoadOrStore(context, operation, isStore: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue