Adress requested changes

This commit is contained in:
Kenny van Vulpen 2018-10-24 07:00:31 +02:00
commit f7c0506e61
No known key found for this signature in database
GPG key ID: BBD011B8B9C45F87
19 changed files with 205 additions and 197 deletions

View file

@ -7,7 +7,7 @@ namespace ChocolArm64.Decoder
public struct BitMask public struct BitMask
{ {
public long WMask; public long WMask;
public long Mask; public long TMask;
public int Pos; public int Pos;
public int Shift; public int Shift;
public bool IsUndefined; public bool IsUndefined;
@ -54,7 +54,7 @@ namespace ChocolArm64.Decoder
return new BitMask() return new BitMask()
{ {
WMask = ABitUtils.Replicate(wMask, size), WMask = ABitUtils.Replicate(wMask, size),
Mask = ABitUtils.Replicate(mask, size), TMask = ABitUtils.Replicate(mask, size),
Pos = immS, Pos = immS,
Shift = immR Shift = immR

View file

@ -5,7 +5,7 @@ namespace ChocolArm64.Decoder
class AOpCodeBfm : AOpCodeAlu class AOpCodeBfm : AOpCodeAlu
{ {
public long WMask { get; private set; } public long WMask { get; private set; }
public long Mask { get; private set; } public long TMask { get; private set; }
public int Pos { get; private set; } public int Pos { get; private set; }
public int Shift { get; private set; } public int Shift { get; private set; }
@ -21,7 +21,7 @@ namespace ChocolArm64.Decoder
} }
WMask = bm.WMask; WMask = bm.WMask;
Mask = bm.Mask; TMask = bm.TMask;
Pos = bm.Pos; Pos = bm.Pos;
Shift = bm.Shift; Shift = bm.Shift;
} }

View file

@ -14,13 +14,13 @@ namespace ChocolArm64.Instruction
EmitBfmLoadRn(context); EmitBfmLoadRn(context);
context.EmitLdintzr(op.Rd); context.EmitLdintzr(op.Rd);
context.EmitLdc_I(~op.WMask & op.Mask); context.EmitLdc_I(~op.WMask & op.TMask);
context.Emit(OpCodes.And); context.Emit(OpCodes.And);
context.Emit(OpCodes.Or); context.Emit(OpCodes.Or);
context.EmitLdintzr(op.Rd); context.EmitLdintzr(op.Rd);
context.EmitLdc_I(~op.Mask); context.EmitLdc_I(~op.TMask);
context.Emit(OpCodes.And); context.Emit(OpCodes.And);
context.Emit(OpCodes.Or); context.Emit(OpCodes.Or);
@ -63,7 +63,7 @@ namespace ChocolArm64.Instruction
context.EmitLsl(bitsCount - 1 - op.Pos); context.EmitLsl(bitsCount - 1 - op.Pos);
context.EmitAsr(bitsCount - 1); context.EmitAsr(bitsCount - 1);
context.EmitLdc_I(~op.Mask); context.EmitLdc_I(~op.TMask);
context.Emit(OpCodes.And); context.Emit(OpCodes.And);
context.Emit(OpCodes.Or); context.Emit(OpCodes.Or);
@ -200,7 +200,7 @@ namespace ChocolArm64.Instruction
context.EmitRor(op.Shift); context.EmitRor(op.Shift);
context.EmitLdc_I(op.WMask & op.Mask); context.EmitLdc_I(op.WMask & op.TMask);
context.Emit(OpCodes.And); context.Emit(OpCodes.And);
} }

View file

@ -543,17 +543,17 @@ namespace ChocolArm64.Instruction
return Sha256Hash(hashAbcd, hashEfgh, wk, false); return Sha256Hash(hashAbcd, hashEfgh, wk, false);
} }
public static Vector128<float> SchedulePart1(Vector128<float> w03, Vector128<float> w47) public static Vector128<float> SchedulePart1(Vector128<float> w0_3, Vector128<float> w4_7)
{ {
Vector128<float> result = new Vector128<float>(); Vector128<float> result = new Vector128<float>();
for (int e = 0; e <= 3; e++) for (int e = 0; e <= 3; e++)
{ {
uint elt = (uint)VectorExtractIntZx(e <= 2 ? w03 : w47, (byte)(e <= 2 ? e + 1 : 0), 2); uint elt = (uint)VectorExtractIntZx(e <= 2 ? w0_3 : w4_7, (byte)(e <= 2 ? e + 1 : 0), 2);
elt = elt.Ror(7) ^ elt.Ror(18) ^ elt.Lsr(3); elt = elt.Ror(7) ^ elt.Ror(18) ^ elt.Lsr(3);
elt += (uint)VectorExtractIntZx(w03, (byte)e, 2); elt += (uint)VectorExtractIntZx(w0_3, (byte)e, 2);
result = VectorInsertInt((ulong)elt, result, (byte)e, 2); result = VectorInsertInt((ulong)elt, result, (byte)e, 2);
} }
@ -561,11 +561,11 @@ namespace ChocolArm64.Instruction
return result; return result;
} }
public static Vector128<float> SchedulePart2(Vector128<float> w03, Vector128<float> w811, Vector128<float> w1215) public static Vector128<float> SchedulePart2(Vector128<float> w0_3, Vector128<float> w8_11, Vector128<float> w1_215)
{ {
Vector128<float> result = new Vector128<float>(); Vector128<float> result = new Vector128<float>();
ulong t1 = VectorExtractIntZx(w1215, (byte)1, 3); ulong t1 = VectorExtractIntZx(w1_215, (byte)1, 3);
for (int e = 0; e <= 1; e++) for (int e = 0; e <= 1; e++)
{ {
@ -573,8 +573,8 @@ namespace ChocolArm64.Instruction
elt = elt.Ror(17) ^ elt.Ror(19) ^ elt.Lsr(10); elt = elt.Ror(17) ^ elt.Ror(19) ^ elt.Lsr(10);
elt += (uint)VectorExtractIntZx(w03, (byte)e, 2); elt += (uint)VectorExtractIntZx(w0_3, (byte)e, 2);
elt += (uint)VectorExtractIntZx(w811, (byte)(e + 1), 2); elt += (uint)VectorExtractIntZx(w8_11, (byte)(e + 1), 2);
result = VectorInsertInt((ulong)elt, result, (byte)e, 2); result = VectorInsertInt((ulong)elt, result, (byte)e, 2);
} }
@ -587,8 +587,8 @@ namespace ChocolArm64.Instruction
elt = elt.Ror(17) ^ elt.Ror(19) ^ elt.Lsr(10); elt = elt.Ror(17) ^ elt.Ror(19) ^ elt.Lsr(10);
elt += (uint)VectorExtractIntZx(w03, (byte)e, 2); elt += (uint)VectorExtractIntZx(w0_3, (byte)e, 2);
elt += (uint)VectorExtractIntZx(e == 2 ? w811 : w1215, (byte)(e == 2 ? 3 : 0), 2); elt += (uint)VectorExtractIntZx(e == 2 ? w8_11 : w1_215, (byte)(e == 2 ? 3 : 0), 2);
result = VectorInsertInt((ulong)elt, result, (byte)e, 2); result = VectorInsertInt((ulong)elt, result, (byte)e, 2);
} }
@ -600,21 +600,21 @@ namespace ChocolArm64.Instruction
{ {
for (int e = 0; e <= 3; e++) for (int e = 0; e <= 3; e++)
{ {
uint chs = ShAchoose((uint)VectorExtractIntZx(y, (byte)0, 2), uint chs = ShaChoose((uint)VectorExtractIntZx(y, (byte)0, 2),
(uint)VectorExtractIntZx(y, (byte)1, 2), (uint)VectorExtractIntZx(y, (byte)1, 2),
(uint)VectorExtractIntZx(y, (byte)2, 2)); (uint)VectorExtractIntZx(y, (byte)2, 2));
uint maj = ShAmajority((uint)VectorExtractIntZx(x, (byte)0, 2), uint maj = ShaMajority((uint)VectorExtractIntZx(x, (byte)0, 2),
(uint)VectorExtractIntZx(x, (byte)1, 2), (uint)VectorExtractIntZx(x, (byte)1, 2),
(uint)VectorExtractIntZx(x, (byte)2, 2)); (uint)VectorExtractIntZx(x, (byte)2, 2));
uint t1 = (uint)VectorExtractIntZx(y, (byte)3, 2); uint t1 = (uint)VectorExtractIntZx(y, (byte)3, 2);
t1 += ShAhashSigma1((uint)VectorExtractIntZx(y, (byte)0, 2)) + chs; t1 += ShaHashSigma1((uint)VectorExtractIntZx(y, (byte)0, 2)) + chs;
t1 += (uint)VectorExtractIntZx(w, (byte)e, 2); t1 += (uint)VectorExtractIntZx(w, (byte)e, 2);
uint t2 = t1 + (uint)VectorExtractIntZx(x, (byte)3, 2); uint t2 = t1 + (uint)VectorExtractIntZx(x, (byte)3, 2);
x = VectorInsertInt((ulong)t2, x, (byte)3, 2); x = VectorInsertInt((ulong)t2, x, (byte)3, 2);
t2 = t1 + ShAhashSigma0((uint)VectorExtractIntZx(x, (byte)0, 2)) + maj; t2 = t1 + ShaHashSigma0((uint)VectorExtractIntZx(x, (byte)0, 2)) + maj;
y = VectorInsertInt((ulong)t2, y, (byte)3, 2); y = VectorInsertInt((ulong)t2, y, (byte)3, 2);
Rol32_256(ref y, ref x); Rol32_256(ref y, ref x);
@ -640,22 +640,22 @@ namespace ChocolArm64.Instruction
x = VectorInsertInt((ulong)yE3, x, (byte)0, 2); x = VectorInsertInt((ulong)yE3, x, (byte)0, 2);
} }
private static uint ShAhashSigma0(uint x) private static uint ShaHashSigma0(uint x)
{ {
return x.Ror(2) ^ x.Ror(13) ^ x.Ror(22); return x.Ror(2) ^ x.Ror(13) ^ x.Ror(22);
} }
private static uint ShAhashSigma1(uint x) private static uint ShaHashSigma1(uint x)
{ {
return x.Ror(6) ^ x.Ror(11) ^ x.Ror(25); return x.Ror(6) ^ x.Ror(11) ^ x.Ror(25);
} }
private static uint ShAmajority(uint x, uint y, uint z) private static uint ShaMajority(uint x, uint y, uint z)
{ {
return (x & y) | ((x | y) & z); return (x & y) | ((x | y) & z);
} }
private static uint ShAchoose(uint x, uint y, uint z) private static uint ShaChoose(uint x, uint y, uint z)
{ {
return ((y ^ z) & x) ^ z; return ((y ^ z) & x) ^ z;
} }

View file

@ -9,7 +9,7 @@ namespace ChocolArm64.Instruction
{ {
static class AVectorHelper static class AVectorHelper
{ {
private static readonly Vector128<float> Zero32128Mask; private static readonly Vector128<float> Zero32_128Mask;
static AVectorHelper() static AVectorHelper()
{ {
@ -18,7 +18,7 @@ namespace ChocolArm64.Instruction
throw new PlatformNotSupportedException(); throw new PlatformNotSupportedException();
} }
Zero32128Mask = Sse.StaticCast<uint, float>(Sse2.SetVector128(0, 0, 0, 0xffffffff)); Zero32_128Mask = Sse.StaticCast<uint, float>(Sse2.SetVector128(0, 0, 0, 0xffffffff));
} }
public static void EmitCall(AilEmitterCtx context, string name64, string name128) public static void EmitCall(AilEmitterCtx context, string name64, string name128)
@ -583,7 +583,7 @@ namespace ChocolArm64.Instruction
{ {
if (Sse.IsSupported) if (Sse.IsSupported)
{ {
return Sse.And(vector, Zero32128Mask); return Sse.And(vector, Zero32_128Mask);
} }
throw new PlatformNotSupportedException(); throw new PlatformNotSupportedException();

View file

@ -171,15 +171,15 @@ namespace Ryujinx.Graphics.Gal.OpenGL
} }
} }
private int RingDelta(int old, int New) private int RingDelta(int oldValue, int newValue)
{ {
if ((uint)New < (uint)old) if ((uint)newValue < (uint)oldValue)
{ {
return New + (~old + 1); return newValue + (~oldValue + 1);
} }
else else
{ {
return New - old; return newValue - oldValue;
} }
} }
} }

View file

@ -5,13 +5,13 @@ namespace Ryujinx.Graphics.Gal.OpenGL
{ {
static class OglExtension static class OglExtension
{ {
private static Lazy<bool> _sEnhancedLayouts = new Lazy<bool>(() => HasExtension("GL_ARB_enhanced_layouts")); private static Lazy<bool> _EnhancedLayouts = new Lazy<bool>(() => HasExtension("GL_ARB_enhanced_layouts"));
private static Lazy<bool> _sTextureMirrorClamp = new Lazy<bool>(() => HasExtension("GL_EXT_texture_mirror_clamp")); private static Lazy<bool> _TextureMirrorClamp = new Lazy<bool>(() => HasExtension("GL_EXT_texture_mirror_clamp"));
private static Lazy<bool> _sViewportArray = new Lazy<bool>(() => HasExtension("GL_ARB_viewport_array")); private static Lazy<bool> _ViewportArray = new Lazy<bool>(() => HasExtension("GL_ARB_viewport_array"));
public static bool EnhancedLayouts => _sEnhancedLayouts.Value; public static bool EnhancedLayouts => _EnhancedLayouts.Value;
public static bool TextureMirrorClamp => _sTextureMirrorClamp.Value; public static bool TextureMirrorClamp => _TextureMirrorClamp.Value;
public static bool ViewportArray => _sViewportArray.Value; public static bool ViewportArray => _ViewportArray.Value;
private static bool HasExtension(string name) private static bool HasExtension(string name)
{ {

View file

@ -100,7 +100,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL
DepthTestEnabled = false, DepthTestEnabled = false,
DepthWriteEnabled = true, DepthWriteEnabled = true,
DepthFunc = GalComparisonOp.Less, DepthFunc = GalComparisonOp.Less,
DepthRangeNear = 0,
DepthRangeFar = 1,
StencilTestEnabled = false, StencilTestEnabled = false,
StencilBackFuncFunc = GalComparisonOp.Always, StencilBackFuncFunc = GalComparisonOp.Always,

View file

@ -55,29 +55,29 @@ namespace Ryujinx.Graphics.Gal.Shader
private string _stagePrefix; private string _stagePrefix;
private Dictionary<ShaderIrOp, ShaderDeclInfo> _mCbTextures; private Dictionary<ShaderIrOp, ShaderDeclInfo> _cbTextures;
private Dictionary<int, ShaderDeclInfo> _mTextures; private Dictionary<int, ShaderDeclInfo> _Textures;
private Dictionary<int, ShaderDeclInfo> _mUniforms; private Dictionary<int, ShaderDeclInfo> _uniforms;
private Dictionary<int, ShaderDeclInfo> _mAttributes; private Dictionary<int, ShaderDeclInfo> _attributes;
private Dictionary<int, ShaderDeclInfo> _mInAttributes; private Dictionary<int, ShaderDeclInfo> _inAttributes;
private Dictionary<int, ShaderDeclInfo> _mOutAttributes; private Dictionary<int, ShaderDeclInfo> _outAttributes;
private Dictionary<int, ShaderDeclInfo> _mGprs; private Dictionary<int, ShaderDeclInfo> _gprs;
private Dictionary<int, ShaderDeclInfo> _mPreds; private Dictionary<int, ShaderDeclInfo> _preds;
public IReadOnlyDictionary<ShaderIrOp, ShaderDeclInfo> CbTextures => _mCbTextures; public IReadOnlyDictionary<ShaderIrOp, ShaderDeclInfo> CbTextures => _cbTextures;
public IReadOnlyDictionary<int, ShaderDeclInfo> Textures => _mTextures; public IReadOnlyDictionary<int, ShaderDeclInfo> Textures => _Textures;
public IReadOnlyDictionary<int, ShaderDeclInfo> Uniforms => _mUniforms; public IReadOnlyDictionary<int, ShaderDeclInfo> Uniforms => _uniforms;
public IReadOnlyDictionary<int, ShaderDeclInfo> Attributes => _mAttributes; public IReadOnlyDictionary<int, ShaderDeclInfo> Attributes => _attributes;
public IReadOnlyDictionary<int, ShaderDeclInfo> InAttributes => _mInAttributes; public IReadOnlyDictionary<int, ShaderDeclInfo> InAttributes => _inAttributes;
public IReadOnlyDictionary<int, ShaderDeclInfo> OutAttributes => _mOutAttributes; public IReadOnlyDictionary<int, ShaderDeclInfo> OutAttributes => _outAttributes;
public IReadOnlyDictionary<int, ShaderDeclInfo> Gprs => _mGprs; public IReadOnlyDictionary<int, ShaderDeclInfo> Gprs => _gprs;
public IReadOnlyDictionary<int, ShaderDeclInfo> Preds => _mPreds; public IReadOnlyDictionary<int, ShaderDeclInfo> Preds => _preds;
public GalShaderType ShaderType { get; private set; } public GalShaderType ShaderType { get; private set; }
@ -85,17 +85,17 @@ namespace Ryujinx.Graphics.Gal.Shader
{ {
ShaderType = shaderType; ShaderType = shaderType;
_mCbTextures = new Dictionary<ShaderIrOp, ShaderDeclInfo>(); _cbTextures = new Dictionary<ShaderIrOp, ShaderDeclInfo>();
_mTextures = new Dictionary<int, ShaderDeclInfo>(); _Textures = new Dictionary<int, ShaderDeclInfo>();
_mUniforms = new Dictionary<int, ShaderDeclInfo>(); _uniforms = new Dictionary<int, ShaderDeclInfo>();
_mAttributes = new Dictionary<int, ShaderDeclInfo>(); _attributes = new Dictionary<int, ShaderDeclInfo>();
_mInAttributes = new Dictionary<int, ShaderDeclInfo>(); _inAttributes = new Dictionary<int, ShaderDeclInfo>();
_mOutAttributes = new Dictionary<int, ShaderDeclInfo>(); _outAttributes = new Dictionary<int, ShaderDeclInfo>();
_mGprs = new Dictionary<int, ShaderDeclInfo>(); _gprs = new Dictionary<int, ShaderDeclInfo>();
_mPreds = new Dictionary<int, ShaderDeclInfo>(); _preds = new Dictionary<int, ShaderDeclInfo>();
} }
public GlslDecl(ShaderIrBlock[] blocks, GalShaderType shaderType, ShaderHeader header) public GlslDecl(ShaderIrBlock[] blocks, GalShaderType shaderType, ShaderHeader header)
@ -113,7 +113,7 @@ namespace Ryujinx.Graphics.Gal.Shader
{ {
if (header.OmapTargets[attachment].ComponentEnabled(component)) if (header.OmapTargets[attachment].ComponentEnabled(component))
{ {
_mGprs.TryAdd(index, new ShaderDeclInfo(GetGprName(index), index)); _gprs.TryAdd(index, new ShaderDeclInfo(GetGprName(index), index));
index++; index++;
} }
@ -124,7 +124,7 @@ namespace Ryujinx.Graphics.Gal.Shader
{ {
index = header.DepthRegister; index = header.DepthRegister;
_mGprs.TryAdd(index, new ShaderDeclInfo(GetGprName(index), index)); _gprs.TryAdd(index, new ShaderDeclInfo(GetGprName(index), index));
} }
} }
@ -143,31 +143,31 @@ namespace Ryujinx.Graphics.Gal.Shader
{ {
GlslDecl combined = new GlslDecl(GalShaderType.Vertex); GlslDecl combined = new GlslDecl(GalShaderType.Vertex);
Merge(combined._mTextures, vpA._mTextures, vpB._mTextures); Merge(combined._Textures, vpA._Textures, vpB._Textures);
Merge(combined._mUniforms, vpA._mUniforms, vpB._mUniforms); Merge(combined._uniforms, vpA._uniforms, vpB._uniforms);
Merge(combined._mAttributes, vpA._mAttributes, vpB._mAttributes); Merge(combined._attributes, vpA._attributes, vpB._attributes);
Merge(combined._mOutAttributes, vpA._mOutAttributes, vpB._mOutAttributes); Merge(combined._outAttributes, vpA._outAttributes, vpB._outAttributes);
Merge(combined._mGprs, vpA._mGprs, vpB._mGprs); Merge(combined._gprs, vpA._gprs, vpB._gprs);
Merge(combined._mPreds, vpA._mPreds, vpB._mPreds); Merge(combined._preds, vpA._preds, vpB._preds);
//Merge input attributes. //Merge input attributes.
foreach (KeyValuePair<int, ShaderDeclInfo> kv in vpA._mInAttributes) foreach (KeyValuePair<int, ShaderDeclInfo> kv in vpA._inAttributes)
{ {
combined._mInAttributes.TryAdd(kv.Key, kv.Value); combined._inAttributes.TryAdd(kv.Key, kv.Value);
} }
foreach (KeyValuePair<int, ShaderDeclInfo> kv in vpB._mInAttributes) foreach (KeyValuePair<int, ShaderDeclInfo> kv in vpB._inAttributes)
{ {
//If Vertex Program A already writes to this attribute, //If Vertex Program A already writes to this attribute,
//then we don't need to add it as an input attribute since //then we don't need to add it as an input attribute since
//Vertex Program A will already have written to it anyway, //Vertex Program A will already have written to it anyway,
//and there's no guarantee that there is an input attribute //and there's no guarantee that there is an input attribute
//for this slot. //for this slot.
if (!vpA._mOutAttributes.ContainsKey(kv.Key)) if (!vpA._outAttributes.ContainsKey(kv.Key))
{ {
combined._mInAttributes.TryAdd(kv.Key, kv.Value); combined._inAttributes.TryAdd(kv.Key, kv.Value);
} }
} }
@ -231,7 +231,7 @@ namespace Ryujinx.Graphics.Gal.Shader
string name = _stagePrefix + TextureName + index; string name = _stagePrefix + TextureName + index;
_mTextures.TryAdd(handle, new ShaderDeclInfo(name, handle)); _Textures.TryAdd(handle, new ShaderDeclInfo(name, handle));
} }
else if (op.Inst == ShaderIrInst.Texb) else if (op.Inst == ShaderIrInst.Texb)
{ {
@ -258,7 +258,7 @@ namespace Ryujinx.Graphics.Gal.Shader
{ {
string name = _stagePrefix + TextureName + "_cb" + cbuf.Index + "_" + cbuf.Pos; string name = _stagePrefix + TextureName + "_cb" + cbuf.Index + "_" + cbuf.Pos;
_mCbTextures.Add(op, new ShaderDeclInfo(name, cbuf.Pos, true, cbuf.Index)); _cbTextures.Add(op, new ShaderDeclInfo(name, cbuf.Pos, true, cbuf.Index));
} }
else else
{ {
@ -270,13 +270,13 @@ namespace Ryujinx.Graphics.Gal.Shader
case ShaderIrOperCbuf cbuf: case ShaderIrOperCbuf cbuf:
{ {
if (!_mUniforms.ContainsKey(cbuf.Index)) if (!_uniforms.ContainsKey(cbuf.Index))
{ {
string name = _stagePrefix + UniformName + cbuf.Index; string name = _stagePrefix + UniformName + cbuf.Index;
ShaderDeclInfo declInfo = new ShaderDeclInfo(name, cbuf.Pos, true, cbuf.Index); ShaderDeclInfo declInfo = new ShaderDeclInfo(name, cbuf.Pos, true, cbuf.Index);
_mUniforms.Add(cbuf.Index, declInfo); _uniforms.Add(cbuf.Index, declInfo);
} }
break; break;
} }
@ -309,30 +309,30 @@ namespace Ryujinx.Graphics.Gal.Shader
if (parent is ShaderIrAsg asg && asg.Dst == node) if (parent is ShaderIrAsg asg && asg.Dst == node)
{ {
if (!_mOutAttributes.TryGetValue(index, out declInfo)) if (!_outAttributes.TryGetValue(index, out declInfo))
{ {
declInfo = new ShaderDeclInfo(OutAttrName + glslIndex, glslIndex); declInfo = new ShaderDeclInfo(OutAttrName + glslIndex, glslIndex);
_mOutAttributes.Add(index, declInfo); _outAttributes.Add(index, declInfo);
} }
} }
else else
{ {
if (!_mInAttributes.TryGetValue(index, out declInfo)) if (!_inAttributes.TryGetValue(index, out declInfo))
{ {
declInfo = new ShaderDeclInfo(InAttrName + glslIndex, glslIndex); declInfo = new ShaderDeclInfo(InAttrName + glslIndex, glslIndex);
_mInAttributes.Add(index, declInfo); _inAttributes.Add(index, declInfo);
} }
} }
declInfo.Enlarge(elem + 1); declInfo.Enlarge(elem + 1);
if (!_mAttributes.ContainsKey(index)) if (!_attributes.ContainsKey(index))
{ {
declInfo = new ShaderDeclInfo(AttrName + glslIndex, glslIndex, false, 0, 4); declInfo = new ShaderDeclInfo(AttrName + glslIndex, glslIndex, false, 0, 4);
_mAttributes.Add(index, declInfo); _attributes.Add(index, declInfo);
} }
Traverse(nodes, abuf, abuf.Vertex); Traverse(nodes, abuf, abuf.Vertex);
@ -346,18 +346,18 @@ namespace Ryujinx.Graphics.Gal.Shader
{ {
string name = GetGprName(gpr.Index); string name = GetGprName(gpr.Index);
_mGprs.TryAdd(gpr.Index, new ShaderDeclInfo(name, gpr.Index)); _gprs.TryAdd(gpr.Index, new ShaderDeclInfo(name, gpr.Index));
} }
break; break;
} }
case ShaderIrOperPred pred: case ShaderIrOperPred pred:
{ {
if (!pred.IsConst && !HasName(_mPreds, pred.Index)) if (!pred.IsConst && !HasName(_preds, pred.Index))
{ {
string name = PredName + pred.Index; string name = PredName + pred.Index;
_mPreds.TryAdd(pred.Index, new ShaderDeclInfo(name, pred.Index)); _preds.TryAdd(pred.Index, new ShaderDeclInfo(name, pred.Index));
} }
break; break;
} }

View file

@ -312,13 +312,11 @@ namespace Ryujinx.Graphics.Gal.Shader
if (_decl.ShaderType == GalShaderType.Fragment) if (_decl.ShaderType == GalShaderType.Fragment)
{ {
int count = 0; int count = 0;
for (int attachment = 0; attachment < 8; attachment++) for (int attachment = 0; attachment < 8; attachment++)
{ {
if (_header.OmapTargets[attachment].Enabled) if (_header.OmapTargets[attachment].Enabled)
{ {
_sb.AppendLine("layout (location = " + attachment + ") out vec4 " + GlslDecl.FragmentOutputName + attachment + ";"); _sb.AppendLine("layout (location = " + attachment + ") out vec4 " + GlslDecl.FragmentOutputName + attachment + ";");
count++; count++;
} }
} }
@ -340,13 +338,11 @@ namespace Ryujinx.Graphics.Gal.Shader
private void PrintDeclAttributes(IEnumerable<ShaderDeclInfo> decls, string inOut) private void PrintDeclAttributes(IEnumerable<ShaderDeclInfo> decls, string inOut)
{ {
int count = 0; int count = 0;
foreach (ShaderDeclInfo declInfo in decls.OrderBy(DeclKeySelector)) foreach (ShaderDeclInfo declInfo in decls.OrderBy(DeclKeySelector))
{ {
if (declInfo.Index >= 0) if (declInfo.Index >= 0)
{ {
_sb.AppendLine("layout (location = " + declInfo.Index + ") " + inOut + " vec4 " + declInfo.Name + ";"); _sb.AppendLine("layout (location = " + declInfo.Index + ") " + inOut + " vec4 " + declInfo.Name + ";");
count++; count++;
} }
} }
@ -370,7 +366,6 @@ namespace Ryujinx.Graphics.Gal.Shader
private void PrintDeclSsy() private void PrintDeclSsy()
{ {
_sb.AppendLine("uint " + GlslDecl.SsyCursorName + " = 0;"); _sb.AppendLine("uint " + GlslDecl.SsyCursorName + " = 0;");
_sb.AppendLine("uint " + GlslDecl.SsyStackName + "[" + GlslDecl.SsyStackSize + "];" + Environment.NewLine); _sb.AppendLine("uint " + GlslDecl.SsyStackName + "[" + GlslDecl.SsyStackSize + "];" + Environment.NewLine);
} }
@ -574,8 +569,14 @@ namespace Ryujinx.Graphics.Gal.Shader
PrintNode(block, node, IdentationStr); PrintNode(block, node, IdentationStr);
} }
if (nodes.Length > 0) if (nodes.Length == 0)
{ {
_sb.AppendLine(IdentationStr + "return 0u;");
return;
}
ShaderIrNode last = nodes[nodes.Length - 1]; ShaderIrNode last = nodes[nodes.Length - 1];
bool unconditionalFlowChange = false; bool unconditionalFlowChange = false;
@ -594,9 +595,15 @@ namespace Ryujinx.Graphics.Gal.Shader
} }
if (!unconditionalFlowChange) if (!unconditionalFlowChange)
{
if (block.Next != null)
{ {
_sb.AppendLine(IdentationStr + "return " + GetBlockPosition(block.Next) + ";"); _sb.AppendLine(IdentationStr + "return " + GetBlockPosition(block.Next) + ";");
} }
else
{
_sb.AppendLine(IdentationStr + "return 0u;");
}
} }
} }

View file

@ -9,15 +9,15 @@ namespace Ryujinx.Graphics.Memory
public int SubChannel { get; private set; } public int SubChannel { get; private set; }
private int[] _mArguments; private int[] _arguments;
public ReadOnlyCollection<int> Arguments => Array.AsReadOnly(_mArguments); public ReadOnlyCollection<int> Arguments => Array.AsReadOnly(_arguments);
public NvGpuPbEntry(int method, int subChannel, params int[] arguments) public NvGpuPbEntry(int method, int subChannel, params int[] arguments)
{ {
Method = method; Method = method;
SubChannel = subChannel; SubChannel = subChannel;
_mArguments = arguments; _arguments = arguments;
} }
} }
} }

View file

@ -37,7 +37,7 @@ namespace Ryujinx.Graphics
ZetaVert = 0x48b, ZetaVert = 0x48b,
ZetaArrayMode = 0x48c, ZetaArrayMode = 0x48c,
DepthTestEnable = 0x4b3, DepthTestEnable = 0x4b3,
BlendEnable = 0x4b9, IBlendEnable = 0x4b9,
DepthWriteEnable = 0x4ba, DepthWriteEnable = 0x4ba,
DepthTestFunction = 0x4c3, DepthTestFunction = 0x4c3,
BlendSeparateAlpha = 0x4cf, BlendSeparateAlpha = 0x4cf,

View file

@ -42,7 +42,7 @@ namespace Ryujinx.Graphics.Texture
private const GalImageFormat Float = GalImageFormat.Float; private const GalImageFormat Float = GalImageFormat.Float;
private const GalImageFormat Srgb = GalImageFormat.Srgb; private const GalImageFormat Srgb = GalImageFormat.Srgb;
private static readonly Dictionary<GalTextureFormat, GalImageFormat> STextureTable = private static readonly Dictionary<GalTextureFormat, GalImageFormat> TextureTable =
new Dictionary<GalTextureFormat, GalImageFormat>() new Dictionary<GalTextureFormat, GalImageFormat>()
{ {
{ GalTextureFormat.Rgba32, GalImageFormat.Rgba32 | Sint | Uint | Float }, { GalTextureFormat.Rgba32, GalImageFormat.Rgba32 | Sint | Uint | Float },
@ -89,7 +89,7 @@ namespace Ryujinx.Graphics.Texture
{ GalTextureFormat.Astc2D10X6, GalImageFormat.Astc2D10X6 | Unorm | Srgb } { GalTextureFormat.Astc2D10X6, GalImageFormat.Astc2D10X6 | Unorm | Srgb }
}; };
private static readonly Dictionary<GalImageFormat, ImageDescriptor> SImageTable = private static readonly Dictionary<GalImageFormat, ImageDescriptor> ImageTable =
new Dictionary<GalImageFormat, ImageDescriptor>() new Dictionary<GalImageFormat, ImageDescriptor>()
{ {
{ GalImageFormat.Rgba32, new ImageDescriptor(16, 1, 1, TargetBuffer.Color) }, { GalImageFormat.Rgba32, new ImageDescriptor(16, 1, 1, TargetBuffer.Color) },
@ -149,7 +149,7 @@ namespace Ryujinx.Graphics.Texture
throw new NotImplementedException("Per component types are not implemented!"); throw new NotImplementedException("Per component types are not implemented!");
} }
if (!STextureTable.TryGetValue(format, out GalImageFormat imageFormat)) if (!TextureTable.TryGetValue(format, out GalImageFormat imageFormat))
{ {
throw new NotImplementedException($"Format 0x{((int)format):x} not implemented!"); throw new NotImplementedException($"Format 0x{((int)format):x} not implemented!");
} }
@ -375,7 +375,7 @@ namespace Ryujinx.Graphics.Texture
{ {
GalImageFormat pixelFormat = format & GalImageFormat.FormatMask; GalImageFormat pixelFormat = format & GalImageFormat.FormatMask;
if (SImageTable.TryGetValue(pixelFormat, out ImageDescriptor descriptor)) if (ImageTable.TryGetValue(pixelFormat, out ImageDescriptor descriptor))
{ {
return descriptor; return descriptor;
} }