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
This commit is contained in:
gdkchan 2021-10-18 20:24:15 -03:00 committed by GitHub
parent 052deebf26
commit 63f1663fa9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 266 additions and 38 deletions

View file

@ -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 addrLowOffset = context.IAdd(addrLow, Const(index * 4));
if (size == LsSize2.U8 || size == LsSize2.S8)
{
Operand word = context.LoadGlobal(addrLow, addrHigh);
value = InsertSmallInt(context, (LsSize)size, bitOffset, word, value);
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);
}
}