Fix 3 graphics related issues (#180)

* Fix 3 graphics related bugs

* OGLShader shouldn't be public (yet)
This commit is contained in:
gdkchan 2018-06-23 02:00:44 -03:00 committed by GitHub
parent 5182361f4b
commit c26ddd6259
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 40 additions and 14 deletions

View file

@ -80,6 +80,7 @@ namespace Ryujinx.Graphics.Gal.Shader
{ ShaderIrInst.Frcp, GetFrcpExpr }, { ShaderIrInst.Frcp, GetFrcpExpr },
{ ShaderIrInst.Frsq, GetFrsqExpr }, { ShaderIrInst.Frsq, GetFrsqExpr },
{ ShaderIrInst.Fsin, GetFsinExpr }, { ShaderIrInst.Fsin, GetFsinExpr },
{ ShaderIrInst.Fsqrt, GetFsqrtExpr },
{ ShaderIrInst.Ftos, GetFtosExpr }, { ShaderIrInst.Ftos, GetFtosExpr },
{ ShaderIrInst.Ftou, GetFtouExpr }, { ShaderIrInst.Ftou, GetFtouExpr },
{ ShaderIrInst.Ipa, GetIpaExpr }, { ShaderIrInst.Ipa, GetIpaExpr },
@ -716,6 +717,8 @@ namespace Ryujinx.Graphics.Gal.Shader
private string GetFsinExpr(ShaderIrOp Op) => GetUnaryCall(Op, "sin"); private string GetFsinExpr(ShaderIrOp Op) => GetUnaryCall(Op, "sin");
private string GetFsqrtExpr(ShaderIrOp Op) => GetUnaryCall(Op, "sqrt");
private string GetFtosExpr(ShaderIrOp Op) private string GetFtosExpr(ShaderIrOp Op)
{ {
return "int(" + GetOperExpr(Op, Op.OperandA) + ")"; return "int(" + GetOperExpr(Op, Op.OperandA) + ")";

View file

@ -217,7 +217,7 @@ namespace Ryujinx.Graphics.Gal.Shader
public static void Mufu(ShaderIrBlock Block, long OpCode) public static void Mufu(ShaderIrBlock Block, long OpCode)
{ {
int SubOp = (int)(OpCode >> 20) & 7; int SubOp = (int)(OpCode >> 20) & 0xf;
bool AbsA = ((OpCode >> 46) & 1) != 0; bool AbsA = ((OpCode >> 46) & 1) != 0;
bool NegA = ((OpCode >> 48) & 1) != 0; bool NegA = ((OpCode >> 48) & 1) != 0;
@ -232,6 +232,7 @@ namespace Ryujinx.Graphics.Gal.Shader
case 3: Inst = ShaderIrInst.Flg2; break; case 3: Inst = ShaderIrInst.Flg2; break;
case 4: Inst = ShaderIrInst.Frcp; break; case 4: Inst = ShaderIrInst.Frcp; break;
case 5: Inst = ShaderIrInst.Frsq; break; case 5: Inst = ShaderIrInst.Frsq; break;
case 8: Inst = ShaderIrInst.Fsqrt; break;
default: throw new NotImplementedException(SubOp.ToString()); default: throw new NotImplementedException(SubOp.ToString());
} }

View file

@ -43,6 +43,7 @@ namespace Ryujinx.Graphics.Gal.Shader
Frcp, Frcp,
Frsq, Frsq,
Fsin, Fsin,
Fsqrt,
Ftos, Ftos,
Ftou, Ftou,
Ipa, Ipa,

View file

@ -248,6 +248,15 @@ namespace Ryujinx.HLE.Gpu
int TextureHandle = Vmm.ReadInt32(Position); int TextureHandle = Vmm.ReadInt32(Position);
if (TextureHandle == 0)
{
//TODO: Is this correct?
//Some games like puyo puyo will have 0 handles.
//It may be just normal behaviour or a bug caused by sync issues.
//The game does initialize the value properly after through.
return;
}
int TicIndex = (TextureHandle >> 0) & 0xfffff; int TicIndex = (TextureHandle >> 0) & 0xfffff;
int TscIndex = (TextureHandle >> 20) & 0xfff; int TscIndex = (TextureHandle >> 20) & 0xfff;
@ -314,7 +323,7 @@ namespace Ryujinx.HLE.Gpu
continue; continue;
} }
for (int Cbuf = 0; Cbuf < ConstBuffers.Length; Cbuf++) for (int Cbuf = 0; Cbuf < ConstBuffers[Index].Length; Cbuf++)
{ {
ConstBuffer Cb = ConstBuffers[Index][Cbuf]; ConstBuffer Cb = ConstBuffers[Index][Cbuf];

View file

@ -41,6 +41,17 @@ namespace Ryujinx.HLE.Gpu
TextureSwizzle Swizzle = (TextureSwizzle)((Tic[2] >> 21) & 7); TextureSwizzle Swizzle = (TextureSwizzle)((Tic[2] >> 21) & 7);
if (Swizzle == TextureSwizzle.BlockLinear ||
Swizzle == TextureSwizzle.BlockLinearColorKey)
{
TextureAddress &= ~0x1ffL;
}
else if (Swizzle == TextureSwizzle.Pitch ||
Swizzle == TextureSwizzle.PitchColorKey)
{
TextureAddress &= ~0x1fL;
}
int Pitch = (Tic[3] & 0xffff) << 5; int Pitch = (Tic[3] & 0xffff) << 5;
int BlockHeightLog2 = (Tic[3] >> 3) & 7; int BlockHeightLog2 = (Tic[3] >> 3) & 7;

View file

@ -10,6 +10,7 @@ namespace Ryujinx.HLE.Gpu
{ {
switch (Texture.Swizzle) switch (Texture.Swizzle)
{ {
case TextureSwizzle._1dBuffer:
case TextureSwizzle.Pitch: case TextureSwizzle.Pitch:
case TextureSwizzle.PitchColorKey: case TextureSwizzle.PitchColorKey:
return new LinearSwizzle(Texture.Pitch, Bpp); return new LinearSwizzle(Texture.Pitch, Bpp);

View file

@ -24,14 +24,14 @@ namespace Ryujinx.HLE.OsHle.Services.Nv.NvMap
this.Size = Size; this.Size = Size;
} }
public long IncrementRefCount() public void IncrementRefCount()
{ {
return Interlocked.Increment(ref Dupes); Interlocked.Increment(ref Dupes);
} }
public long DecrementRefCount() public long DecrementRefCount()
{ {
return Interlocked.Decrement(ref Dupes); return Interlocked.Decrement(ref Dupes) + 1;
} }
} }
} }

View file

@ -163,9 +163,9 @@ namespace Ryujinx.HLE.OsHle.Services.Nv.NvMap
return NvResult.InvalidInput; return NvResult.InvalidInput;
} }
long RefCount = Map.DecrementRefCount(); long OldRefCount = Map.DecrementRefCount();
if (RefCount <= 0) if (OldRefCount <= 1)
{ {
DeleteNvMap(Context, Args.Handle); DeleteNvMap(Context, Args.Handle);
@ -178,7 +178,7 @@ namespace Ryujinx.HLE.OsHle.Services.Nv.NvMap
Args.Flags = FlagNotFreedYet; Args.Flags = FlagNotFreedYet;
} }
Args.RefCount = RefCount; Args.RefCount = OldRefCount;
Args.Size = Map.Size; Args.Size = Map.Size;
AMemoryHelper.Write(Context.Memory, OutputPosition, Args); AMemoryHelper.Write(Context.Memory, OutputPosition, Args);