mirror of
https://git.743378673.xyz/MeloNX/MeloNX.git
synced 2025-07-23 15:07:11 +02:00
Replace constant buffer access on shader with new Load instruction (#4646)
This commit is contained in:
parent
fb27042e01
commit
402f05b8ef
42 changed files with 788 additions and 625 deletions
|
@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
{
|
||||
static class ConstantFolding
|
||||
{
|
||||
public static void RunPass(Operation operation)
|
||||
public static void RunPass(ShaderConfig config, Operation operation)
|
||||
{
|
||||
if (!AreAllSourcesConstant(operation))
|
||||
{
|
||||
|
@ -153,8 +153,21 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations
|
|||
EvaluateFPUnary(operation, (x) => float.IsNaN(x));
|
||||
break;
|
||||
|
||||
case Instruction.LoadConstant:
|
||||
operation.TurnIntoCopy(Cbuf(operation.GetSource(0).Value, operation.GetSource(1).Value));
|
||||
case Instruction.Load:
|
||||
if (operation.StorageKind == StorageKind.ConstantBuffer && operation.SourcesCount == 4)
|
||||
{
|
||||
int binding = operation.GetSource(0).Value;
|
||||
int fieldIndex = operation.GetSource(1).Value;
|
||||
|
||||
if (config.ResourceManager.TryGetConstantBufferSlot(binding, out int cbufSlot) && fieldIndex == 0)
|
||||
{
|
||||
int vecIndex = operation.GetSource(2).Value;
|
||||
int elemIndex = operation.GetSource(3).Value;
|
||||
int cbufOffset = vecIndex * 4 + elemIndex;
|
||||
|
||||
operation.TurnIntoCopy(Cbuf(cbufSlot, cbufOffset));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Instruction.Maximum:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue