aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2021-10-18 20:24:15 -0300
committerGitHub <noreply@github.com>2021-10-18 20:24:15 -0300
commit63f1663fa959d8809d1762d99e9364565ba9b3d8 (patch)
tree4317d6067048cbd912eed16b563b76d6b9ab6cfe /Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs
parent052deebf26beb5e62e677e8d31c2eb024beaa82f (diff)
Fix shader 8-bit and 16-bit STS/STG (#2741)
* Fix 8 and 16-bit STG * Fix 8 and 16-bit STS * Shader cache version bump
Diffstat (limited to 'Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs')
-rw-r--r--Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs52
1 files changed, 33 insertions, 19 deletions
diff --git a/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs b/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs
index 78f41e8e..ceb76de1 100644
--- a/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs
+++ b/Ryujinx.Graphics.Shader/Instructions/InstEmitMemory.cs
@@ -366,23 +366,33 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand value = Register(isRz ? rd : rd + index, RegisterType.Gpr);
Operand elemOffset = context.IAdd(wordOffset, Const(index));
- if (isSmallInt)
+ if (isSmallInt && region == MemoryRegion.Local)
{
- Operand word = null;
-
- switch (region)
- {
- case MemoryRegion.Local: word = context.LoadLocal(elemOffset); break;
- case MemoryRegion.Shared: word = context.LoadShared(elemOffset); break;
- }
+ Operand word = context.LoadLocal(elemOffset);
value = InsertSmallInt(context, (LsSize)size, bitOffset, word, value);
}
- switch (region)
+ if (region == MemoryRegion.Local)
{
- case MemoryRegion.Local: context.StoreLocal(elemOffset, value); break;
- case MemoryRegion.Shared: context.StoreShared(elemOffset, value); break;
+ context.StoreLocal(elemOffset, value);
+ }
+ else if (region == MemoryRegion.Shared)
+ {
+ switch (size)
+ {
+ case LsSize2.U8:
+ case LsSize2.S8:
+ context.StoreShared8(baseOffset, value);
+ break;
+ case LsSize2.U16:
+ case LsSize2.S16:
+ context.StoreShared16(baseOffset, value);
+ break;
+ default:
+ context.StoreShared(elemOffset, value);
+ break;
+ }
}
}
}
@@ -401,8 +411,6 @@ namespace Ryujinx.Graphics.Shader.Instructions
return;
}
- bool isSmallInt = size < LsSize2.B32;
-
int count = GetVectorCount((LsSize)size);
(Operand addrLow, Operand addrHigh) = Get40BitsAddress(context, new Register(ra, RegisterType.Gpr), extended, offset);
@@ -415,14 +423,20 @@ namespace Ryujinx.Graphics.Shader.Instructions
Operand value = Register(isRz ? rd : rd + index, RegisterType.Gpr);
- if (isSmallInt)
- {
- Operand word = context.LoadGlobal(addrLow, addrHigh);
+ Operand addrLowOffset = context.IAdd(addrLow, Const(index * 4));
- value = InsertSmallInt(context, (LsSize)size, bitOffset, word, value);
+ if (size == LsSize2.U8 || size == LsSize2.S8)
+ {
+ context.StoreGlobal8(addrLowOffset, addrHigh, value);
+ }
+ else if (size == LsSize2.U16 || size == LsSize2.S16)
+ {
+ context.StoreGlobal16(addrLowOffset, addrHigh, value);
+ }
+ else
+ {
+ context.StoreGlobal(addrLowOffset, addrHigh, value);
}
-
- context.StoreGlobal(context.IAdd(addrLow, Const(index * 4)), addrHigh, value);
}
}