From f7c0506e6150ff8ea7271261d5f1ff0275f2dd0f Mon Sep 17 00:00:00 2001 From: Kenny van Vulpen Date: Wed, 24 Oct 2018 07:00:31 +0200 Subject: [PATCH] Adress requested changes --- ChocolArm64/Decoder/ADecoderHelper.cs | 4 +- ChocolArm64/Decoder/AOpCodeBfm.cs | 4 +- ChocolArm64/Instruction/AInstEmitBfm.cs | 8 +- ChocolArm64/Instruction/ASoftFallback.cs | 34 +++--- ChocolArm64/Instruction/AVectorHelper.cs | 6 +- .../Instruction32/A32InstInterpretHelper.cs | 8 +- ChocolArm64/Translation/AILEmitterCtx.cs | 8 +- Ryujinx.Graphics/Gal/GalPipelineState.cs | 6 +- .../Gal/OpenGL/OGLCachedResource.cs | 8 +- Ryujinx.Graphics/Gal/OpenGL/OGLExtension.cs | 12 +-- Ryujinx.Graphics/Gal/OpenGL/OGLPipeline.cs | 81 +++++++------- Ryujinx.Graphics/Gal/Shader/GlslDecl.cs | 100 +++++++++--------- Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs | 45 ++++---- Ryujinx.Graphics/Memory/NvGpuPBEntry.cs | 6 +- Ryujinx.Graphics/NvGpuEngine3dReg.cs | 18 ++-- Ryujinx.Graphics/Texture/ImageUtils.cs | 8 +- Ryujinx.Graphics/Texture/IntegerEncoded.cs | 8 +- Ryujinx.HLE/HOS/ErrorModule.cs | 32 +++--- Ryujinx.HLE/HOS/Kernel/KThread.cs | 6 +- 19 files changed, 205 insertions(+), 197 deletions(-) diff --git a/ChocolArm64/Decoder/ADecoderHelper.cs b/ChocolArm64/Decoder/ADecoderHelper.cs index 3d8b32b619..d7f0182133 100644 --- a/ChocolArm64/Decoder/ADecoderHelper.cs +++ b/ChocolArm64/Decoder/ADecoderHelper.cs @@ -7,7 +7,7 @@ namespace ChocolArm64.Decoder public struct BitMask { public long WMask; - public long Mask; + public long TMask; public int Pos; public int Shift; public bool IsUndefined; @@ -54,7 +54,7 @@ namespace ChocolArm64.Decoder return new BitMask() { WMask = ABitUtils.Replicate(wMask, size), - Mask = ABitUtils.Replicate(mask, size), + TMask = ABitUtils.Replicate(mask, size), Pos = immS, Shift = immR diff --git a/ChocolArm64/Decoder/AOpCodeBfm.cs b/ChocolArm64/Decoder/AOpCodeBfm.cs index e14b84e409..188b9a05a0 100644 --- a/ChocolArm64/Decoder/AOpCodeBfm.cs +++ b/ChocolArm64/Decoder/AOpCodeBfm.cs @@ -5,7 +5,7 @@ namespace ChocolArm64.Decoder class AOpCodeBfm : AOpCodeAlu { 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 Shift { get; private set; } @@ -21,7 +21,7 @@ namespace ChocolArm64.Decoder } WMask = bm.WMask; - Mask = bm.Mask; + TMask = bm.TMask; Pos = bm.Pos; Shift = bm.Shift; } diff --git a/ChocolArm64/Instruction/AInstEmitBfm.cs b/ChocolArm64/Instruction/AInstEmitBfm.cs index 6c341e49e7..cbd079fc21 100644 --- a/ChocolArm64/Instruction/AInstEmitBfm.cs +++ b/ChocolArm64/Instruction/AInstEmitBfm.cs @@ -14,13 +14,13 @@ namespace ChocolArm64.Instruction EmitBfmLoadRn(context); 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.Or); context.EmitLdintzr(op.Rd); - context.EmitLdc_I(~op.Mask); + context.EmitLdc_I(~op.TMask); context.Emit(OpCodes.And); context.Emit(OpCodes.Or); @@ -63,7 +63,7 @@ namespace ChocolArm64.Instruction context.EmitLsl(bitsCount - 1 - op.Pos); context.EmitAsr(bitsCount - 1); - context.EmitLdc_I(~op.Mask); + context.EmitLdc_I(~op.TMask); context.Emit(OpCodes.And); context.Emit(OpCodes.Or); @@ -200,7 +200,7 @@ namespace ChocolArm64.Instruction context.EmitRor(op.Shift); - context.EmitLdc_I(op.WMask & op.Mask); + context.EmitLdc_I(op.WMask & op.TMask); context.Emit(OpCodes.And); } diff --git a/ChocolArm64/Instruction/ASoftFallback.cs b/ChocolArm64/Instruction/ASoftFallback.cs index d4f5d611ee..623ae7b329 100644 --- a/ChocolArm64/Instruction/ASoftFallback.cs +++ b/ChocolArm64/Instruction/ASoftFallback.cs @@ -543,17 +543,17 @@ namespace ChocolArm64.Instruction return Sha256Hash(hashAbcd, hashEfgh, wk, false); } - public static Vector128 SchedulePart1(Vector128 w03, Vector128 w47) + public static Vector128 SchedulePart1(Vector128 w0_3, Vector128 w4_7) { Vector128 result = new Vector128(); 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 += (uint)VectorExtractIntZx(w03, (byte)e, 2); + elt += (uint)VectorExtractIntZx(w0_3, (byte)e, 2); result = VectorInsertInt((ulong)elt, result, (byte)e, 2); } @@ -561,11 +561,11 @@ namespace ChocolArm64.Instruction return result; } - public static Vector128 SchedulePart2(Vector128 w03, Vector128 w811, Vector128 w1215) + public static Vector128 SchedulePart2(Vector128 w0_3, Vector128 w8_11, Vector128 w1_215) { Vector128 result = new Vector128(); - ulong t1 = VectorExtractIntZx(w1215, (byte)1, 3); + ulong t1 = VectorExtractIntZx(w1_215, (byte)1, 3); 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 += (uint)VectorExtractIntZx(w03, (byte)e, 2); - elt += (uint)VectorExtractIntZx(w811, (byte)(e + 1), 2); + elt += (uint)VectorExtractIntZx(w0_3, (byte)e, 2); + elt += (uint)VectorExtractIntZx(w8_11, (byte)(e + 1), 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 += (uint)VectorExtractIntZx(w03, (byte)e, 2); - elt += (uint)VectorExtractIntZx(e == 2 ? w811 : w1215, (byte)(e == 2 ? 3 : 0), 2); + elt += (uint)VectorExtractIntZx(w0_3, (byte)e, 2); + elt += (uint)VectorExtractIntZx(e == 2 ? w8_11 : w1_215, (byte)(e == 2 ? 3 : 0), 2); result = VectorInsertInt((ulong)elt, result, (byte)e, 2); } @@ -600,21 +600,21 @@ namespace ChocolArm64.Instruction { 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)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)2, 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); uint t2 = t1 + (uint)VectorExtractIntZx(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); Rol32_256(ref y, ref x); @@ -640,22 +640,22 @@ namespace ChocolArm64.Instruction 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); } - private static uint ShAhashSigma1(uint x) + private static uint ShaHashSigma1(uint x) { 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); } - 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; } diff --git a/ChocolArm64/Instruction/AVectorHelper.cs b/ChocolArm64/Instruction/AVectorHelper.cs index 1bf9bb324f..7173cbed09 100644 --- a/ChocolArm64/Instruction/AVectorHelper.cs +++ b/ChocolArm64/Instruction/AVectorHelper.cs @@ -9,7 +9,7 @@ namespace ChocolArm64.Instruction { static class AVectorHelper { - private static readonly Vector128 Zero32128Mask; + private static readonly Vector128 Zero32_128Mask; static AVectorHelper() { @@ -18,7 +18,7 @@ namespace ChocolArm64.Instruction throw new PlatformNotSupportedException(); } - Zero32128Mask = Sse.StaticCast(Sse2.SetVector128(0, 0, 0, 0xffffffff)); + Zero32_128Mask = Sse.StaticCast(Sse2.SetVector128(0, 0, 0, 0xffffffff)); } public static void EmitCall(AilEmitterCtx context, string name64, string name128) @@ -583,7 +583,7 @@ namespace ChocolArm64.Instruction { if (Sse.IsSupported) { - return Sse.And(vector, Zero32128Mask); + return Sse.And(vector, Zero32_128Mask); } throw new PlatformNotSupportedException(); diff --git a/ChocolArm64/Instruction32/A32InstInterpretHelper.cs b/ChocolArm64/Instruction32/A32InstInterpretHelper.cs index d382e5d92b..b0e7c9ef3f 100644 --- a/ChocolArm64/Instruction32/A32InstInterpretHelper.cs +++ b/ChocolArm64/Instruction32/A32InstInterpretHelper.cs @@ -12,14 +12,14 @@ namespace ChocolArm64.Instruction32 { case ACond.Eq: return state.Zero; case ACond.Ne: return !state.Zero; - case ACond.GeUn: return state.Carry; - case ACond.LtUn: return !state.Carry; + case ACond.GeUn: return state.Carry; + case ACond.LtUn: return !state.Carry; case ACond.Mi: return state.Negative; case ACond.Pl: return !state.Negative; case ACond.Vs: return state.Overflow; case ACond.Vc: return !state.Overflow; - case ACond.GtUn: return state.Carry && !state.Zero; - case ACond.LeUn: return !state.Carry && state.Zero; + case ACond.GtUn: return state.Carry && !state.Zero; + case ACond.LeUn: return !state.Carry && state.Zero; case ACond.Ge: return state.Negative == state.Overflow; case ACond.Lt: return state.Negative != state.Overflow; case ACond.Gt: return state.Negative == state.Overflow && !state.Zero; diff --git a/ChocolArm64/Translation/AILEmitterCtx.cs b/ChocolArm64/Translation/AILEmitterCtx.cs index 9f94f46c90..75144b730b 100644 --- a/ChocolArm64/Translation/AILEmitterCtx.cs +++ b/ChocolArm64/Translation/AILEmitterCtx.cs @@ -178,10 +178,10 @@ namespace ChocolArm64.Translation { { ACond.Eq, OpCodes.Beq }, { ACond.Ne, OpCodes.Bne_Un }, - { ACond.GeUn, OpCodes.Bge_Un }, - { ACond.LtUn, OpCodes.Blt_Un }, - { ACond.GtUn, OpCodes.Bgt_Un }, - { ACond.LeUn, OpCodes.Ble_Un }, + { ACond.GeUn, OpCodes.Bge_Un }, + { ACond.LtUn, OpCodes.Blt_Un }, + { ACond.GtUn, OpCodes.Bgt_Un }, + { ACond.LeUn, OpCodes.Ble_Un }, { ACond.Ge, OpCodes.Bge }, { ACond.Lt, OpCodes.Blt }, { ACond.Gt, OpCodes.Bgt }, diff --git a/Ryujinx.Graphics/Gal/GalPipelineState.cs b/Ryujinx.Graphics/Gal/GalPipelineState.cs index efac04acda..25f39903be 100644 --- a/Ryujinx.Graphics/Gal/GalPipelineState.cs +++ b/Ryujinx.Graphics/Gal/GalPipelineState.cs @@ -2,7 +2,7 @@ { public struct ColorMaskRgba { - public static ColorMaskRgba Default { get; } = new ColorMaskRgba() + public static ColorMaskRgba Default { get; } = new ColorMaskRgba() { Red = true, Green = true, @@ -11,8 +11,8 @@ }; public bool Red; - public bool Green; - public bool Blue; + public bool Green; + public bool Blue; public bool Alpha; } diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLCachedResource.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLCachedResource.cs index 7bd031beab..202c6e7fe5 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLCachedResource.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLCachedResource.cs @@ -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 { - return New - old; + return newValue - oldValue; } } } diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLExtension.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLExtension.cs index 866c9138d4..991ed8dcec 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLExtension.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLExtension.cs @@ -5,13 +5,13 @@ namespace Ryujinx.Graphics.Gal.OpenGL { static class OglExtension { - private static Lazy _sEnhancedLayouts = new Lazy(() => HasExtension("GL_ARB_enhanced_layouts")); - private static Lazy _sTextureMirrorClamp = new Lazy(() => HasExtension("GL_EXT_texture_mirror_clamp")); - private static Lazy _sViewportArray = new Lazy(() => HasExtension("GL_ARB_viewport_array")); + private static Lazy _EnhancedLayouts = new Lazy(() => HasExtension("GL_ARB_enhanced_layouts")); + private static Lazy _TextureMirrorClamp = new Lazy(() => HasExtension("GL_EXT_texture_mirror_clamp")); + private static Lazy _ViewportArray = new Lazy(() => HasExtension("GL_ARB_viewport_array")); - public static bool EnhancedLayouts => _sEnhancedLayouts.Value; - public static bool TextureMirrorClamp => _sTextureMirrorClamp.Value; - public static bool ViewportArray => _sViewportArray.Value; + public static bool EnhancedLayouts => _EnhancedLayouts.Value; + public static bool TextureMirrorClamp => _TextureMirrorClamp.Value; + public static bool ViewportArray => _ViewportArray.Value; private static bool HasExtension(string name) { diff --git a/Ryujinx.Graphics/Gal/OpenGL/OGLPipeline.cs b/Ryujinx.Graphics/Gal/OpenGL/OGLPipeline.cs index 846bf4610e..42259f06bd 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OGLPipeline.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OGLPipeline.cs @@ -90,50 +90,51 @@ namespace Ryujinx.Graphics.Gal.OpenGL _shader = shader; //These values match OpenGL's defaults - _old = new GalPipelineState - { - FrontFace = GalFrontFace.Ccw, + _old = new GalPipelineState + { + FrontFace = GalFrontFace.Ccw, - CullFaceEnabled = false, - CullFace = GalCullFace.Back, - - DepthTestEnabled = false, - DepthWriteEnabled = true, - DepthFunc = GalComparisonOp.Less, + CullFaceEnabled = false, + CullFace = GalCullFace.Back, + DepthTestEnabled = false, + DepthWriteEnabled = true, + DepthFunc = GalComparisonOp.Less, + DepthRangeNear = 0, + DepthRangeFar = 1, StencilTestEnabled = false, - StencilBackFuncFunc = GalComparisonOp.Always, - StencilBackFuncRef = 0, - StencilBackFuncMask = UInt32.MaxValue, - StencilBackOpFail = GalStencilOp.Keep, - StencilBackOpZFail = GalStencilOp.Keep, - StencilBackOpZPass = GalStencilOp.Keep, - StencilBackMask = UInt32.MaxValue, + StencilBackFuncFunc = GalComparisonOp.Always, + StencilBackFuncRef = 0, + StencilBackFuncMask = UInt32.MaxValue, + StencilBackOpFail = GalStencilOp.Keep, + StencilBackOpZFail = GalStencilOp.Keep, + StencilBackOpZPass = GalStencilOp.Keep, + StencilBackMask = UInt32.MaxValue, - StencilFrontFuncFunc = GalComparisonOp.Always, - StencilFrontFuncRef = 0, - StencilFrontFuncMask = UInt32.MaxValue, - StencilFrontOpFail = GalStencilOp.Keep, - StencilFrontOpZFail = GalStencilOp.Keep, - StencilFrontOpZPass = GalStencilOp.Keep, - StencilFrontMask = UInt32.MaxValue, + StencilFrontFuncFunc = GalComparisonOp.Always, + StencilFrontFuncRef = 0, + StencilFrontFuncMask = UInt32.MaxValue, + StencilFrontOpFail = GalStencilOp.Keep, + StencilFrontOpZFail = GalStencilOp.Keep, + StencilFrontOpZPass = GalStencilOp.Keep, + StencilFrontMask = UInt32.MaxValue, - BlendEnabled = false, - BlendSeparateAlpha = false, + BlendEnabled = false, + BlendSeparateAlpha = false, - BlendEquationRgb = 0, - BlendFuncSrcRgb = GalBlendFactor.One, - BlendFuncDstRgb = GalBlendFactor.Zero, - BlendEquationAlpha = 0, - BlendFuncSrcAlpha = GalBlendFactor.One, - BlendFuncDstAlpha = GalBlendFactor.Zero, + BlendEquationRgb = 0, + BlendFuncSrcRgb = GalBlendFactor.One, + BlendFuncDstRgb = GalBlendFactor.Zero, + BlendEquationAlpha = 0, + BlendFuncSrcAlpha = GalBlendFactor.One, + BlendFuncDstAlpha = GalBlendFactor.Zero, - ColorMask = ColorMaskRgba.Default, + ColorMask = ColorMaskRgba.Default, - PrimitiveRestartEnabled = false, - PrimitiveRestartIndex = 0 - }; + PrimitiveRestartEnabled = false, + PrimitiveRestartIndex = 0 + }; for (int index = 0; index < GalPipelineState.RenderTargetsCount; index++) { @@ -195,11 +196,11 @@ namespace Ryujinx.Graphics.Gal.OpenGL } } - if (New.DepthRangeNear != _old.DepthRangeNear || - New.DepthRangeFar != _old.DepthRangeFar) - { - GL.DepthRange(New.DepthRangeNear, New.DepthRangeFar); - } + if (New.DepthRangeNear != _old.DepthRangeNear || + New.DepthRangeFar != _old.DepthRangeFar) + { + GL.DepthRange(New.DepthRangeNear, New.DepthRangeFar); + } if (New.StencilTestEnabled != _old.StencilTestEnabled) { diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs index 525ffb1801..a744c551a6 100644 --- a/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs +++ b/Ryujinx.Graphics/Gal/Shader/GlslDecl.cs @@ -55,29 +55,29 @@ namespace Ryujinx.Graphics.Gal.Shader private string _stagePrefix; - private Dictionary _mCbTextures; + private Dictionary _cbTextures; - private Dictionary _mTextures; - private Dictionary _mUniforms; + private Dictionary _Textures; + private Dictionary _uniforms; - private Dictionary _mAttributes; - private Dictionary _mInAttributes; - private Dictionary _mOutAttributes; + private Dictionary _attributes; + private Dictionary _inAttributes; + private Dictionary _outAttributes; - private Dictionary _mGprs; - private Dictionary _mPreds; + private Dictionary _gprs; + private Dictionary _preds; - public IReadOnlyDictionary CbTextures => _mCbTextures; + public IReadOnlyDictionary CbTextures => _cbTextures; - public IReadOnlyDictionary Textures => _mTextures; - public IReadOnlyDictionary Uniforms => _mUniforms; + public IReadOnlyDictionary Textures => _Textures; + public IReadOnlyDictionary Uniforms => _uniforms; - public IReadOnlyDictionary Attributes => _mAttributes; - public IReadOnlyDictionary InAttributes => _mInAttributes; - public IReadOnlyDictionary OutAttributes => _mOutAttributes; + public IReadOnlyDictionary Attributes => _attributes; + public IReadOnlyDictionary InAttributes => _inAttributes; + public IReadOnlyDictionary OutAttributes => _outAttributes; - public IReadOnlyDictionary Gprs => _mGprs; - public IReadOnlyDictionary Preds => _mPreds; + public IReadOnlyDictionary Gprs => _gprs; + public IReadOnlyDictionary Preds => _preds; public GalShaderType ShaderType { get; private set; } @@ -85,17 +85,17 @@ namespace Ryujinx.Graphics.Gal.Shader { ShaderType = shaderType; - _mCbTextures = new Dictionary(); + _cbTextures = new Dictionary(); - _mTextures = new Dictionary(); - _mUniforms = new Dictionary(); + _Textures = new Dictionary(); + _uniforms = new Dictionary(); - _mAttributes = new Dictionary(); - _mInAttributes = new Dictionary(); - _mOutAttributes = new Dictionary(); + _attributes = new Dictionary(); + _inAttributes = new Dictionary(); + _outAttributes = new Dictionary(); - _mGprs = new Dictionary(); - _mPreds = new Dictionary(); + _gprs = new Dictionary(); + _preds = new Dictionary(); } public GlslDecl(ShaderIrBlock[] blocks, GalShaderType shaderType, ShaderHeader header) @@ -113,7 +113,7 @@ namespace Ryujinx.Graphics.Gal.Shader { if (header.OmapTargets[attachment].ComponentEnabled(component)) { - _mGprs.TryAdd(index, new ShaderDeclInfo(GetGprName(index), index)); + _gprs.TryAdd(index, new ShaderDeclInfo(GetGprName(index), index)); index++; } @@ -124,7 +124,7 @@ namespace Ryujinx.Graphics.Gal.Shader { 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); - Merge(combined._mTextures, vpA._mTextures, vpB._mTextures); - Merge(combined._mUniforms, vpA._mUniforms, vpB._mUniforms); + Merge(combined._Textures, vpA._Textures, vpB._Textures); + Merge(combined._uniforms, vpA._uniforms, vpB._uniforms); - Merge(combined._mAttributes, vpA._mAttributes, vpB._mAttributes); - Merge(combined._mOutAttributes, vpA._mOutAttributes, vpB._mOutAttributes); + Merge(combined._attributes, vpA._attributes, vpB._attributes); + Merge(combined._outAttributes, vpA._outAttributes, vpB._outAttributes); - Merge(combined._mGprs, vpA._mGprs, vpB._mGprs); - Merge(combined._mPreds, vpA._mPreds, vpB._mPreds); + Merge(combined._gprs, vpA._gprs, vpB._gprs); + Merge(combined._preds, vpA._preds, vpB._preds); //Merge input attributes. - foreach (KeyValuePair kv in vpA._mInAttributes) + foreach (KeyValuePair kv in vpA._inAttributes) { - combined._mInAttributes.TryAdd(kv.Key, kv.Value); + combined._inAttributes.TryAdd(kv.Key, kv.Value); } - foreach (KeyValuePair kv in vpB._mInAttributes) + foreach (KeyValuePair kv in vpB._inAttributes) { //If Vertex Program A already writes to this attribute, //then we don't need to add it as an input attribute since //Vertex Program A will already have written to it anyway, //and there's no guarantee that there is an input attribute //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; - _mTextures.TryAdd(handle, new ShaderDeclInfo(name, handle)); + _Textures.TryAdd(handle, new ShaderDeclInfo(name, handle)); } else if (op.Inst == ShaderIrInst.Texb) { @@ -258,7 +258,7 @@ namespace Ryujinx.Graphics.Gal.Shader { 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 { @@ -270,13 +270,13 @@ namespace Ryujinx.Graphics.Gal.Shader case ShaderIrOperCbuf cbuf: { - if (!_mUniforms.ContainsKey(cbuf.Index)) + if (!_uniforms.ContainsKey(cbuf.Index)) { string name = _stagePrefix + UniformName + cbuf.Index; ShaderDeclInfo declInfo = new ShaderDeclInfo(name, cbuf.Pos, true, cbuf.Index); - _mUniforms.Add(cbuf.Index, declInfo); + _uniforms.Add(cbuf.Index, declInfo); } break; } @@ -309,30 +309,30 @@ namespace Ryujinx.Graphics.Gal.Shader 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); - _mOutAttributes.Add(index, declInfo); + _outAttributes.Add(index, declInfo); } } else { - if (!_mInAttributes.TryGetValue(index, out declInfo)) + if (!_inAttributes.TryGetValue(index, out declInfo)) { declInfo = new ShaderDeclInfo(InAttrName + glslIndex, glslIndex); - _mInAttributes.Add(index, declInfo); + _inAttributes.Add(index, declInfo); } } declInfo.Enlarge(elem + 1); - if (!_mAttributes.ContainsKey(index)) + if (!_attributes.ContainsKey(index)) { declInfo = new ShaderDeclInfo(AttrName + glslIndex, glslIndex, false, 0, 4); - _mAttributes.Add(index, declInfo); + _attributes.Add(index, declInfo); } Traverse(nodes, abuf, abuf.Vertex); @@ -346,18 +346,18 @@ namespace Ryujinx.Graphics.Gal.Shader { string name = GetGprName(gpr.Index); - _mGprs.TryAdd(gpr.Index, new ShaderDeclInfo(name, gpr.Index)); + _gprs.TryAdd(gpr.Index, new ShaderDeclInfo(name, gpr.Index)); } break; } case ShaderIrOperPred pred: { - if (!pred.IsConst && !HasName(_mPreds, pred.Index)) + if (!pred.IsConst && !HasName(_preds, 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; } diff --git a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs index bfbd408321..8513b2ec58 100644 --- a/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs +++ b/Ryujinx.Graphics/Gal/Shader/GlslDecompiler.cs @@ -312,13 +312,11 @@ namespace Ryujinx.Graphics.Gal.Shader if (_decl.ShaderType == GalShaderType.Fragment) { int count = 0; - for (int attachment = 0; attachment < 8; attachment++) { if (_header.OmapTargets[attachment].Enabled) { _sb.AppendLine("layout (location = " + attachment + ") out vec4 " + GlslDecl.FragmentOutputName + attachment + ";"); - count++; } } @@ -340,13 +338,11 @@ namespace Ryujinx.Graphics.Gal.Shader private void PrintDeclAttributes(IEnumerable decls, string inOut) { int count = 0; - foreach (ShaderDeclInfo declInfo in decls.OrderBy(DeclKeySelector)) { if (declInfo.Index >= 0) { _sb.AppendLine("layout (location = " + declInfo.Index + ") " + inOut + " vec4 " + declInfo.Name + ";"); - count++; } } @@ -370,7 +366,6 @@ namespace Ryujinx.Graphics.Gal.Shader private void PrintDeclSsy() { _sb.AppendLine("uint " + GlslDecl.SsyCursorName + " = 0;"); - _sb.AppendLine("uint " + GlslDecl.SsyStackName + "[" + GlslDecl.SsyStackSize + "];" + Environment.NewLine); } @@ -574,29 +569,41 @@ namespace Ryujinx.Graphics.Gal.Shader PrintNode(block, node, IdentationStr); } - if (nodes.Length > 0) + if (nodes.Length == 0) { - ShaderIrNode last = nodes[nodes.Length - 1]; + _sb.AppendLine(IdentationStr + "return 0u;"); - bool unconditionalFlowChange = false; + return; + } - if (last is ShaderIrOp op) + + ShaderIrNode last = nodes[nodes.Length - 1]; + + bool unconditionalFlowChange = false; + + if (last is ShaderIrOp op) + { + switch (op.Inst) { - switch (op.Inst) - { - case ShaderIrInst.Bra: - case ShaderIrInst.Exit: - case ShaderIrInst.Kil: - case ShaderIrInst.Sync: - unconditionalFlowChange = true; - break; - } + case ShaderIrInst.Bra: + case ShaderIrInst.Exit: + case ShaderIrInst.Kil: + case ShaderIrInst.Sync: + unconditionalFlowChange = true; + break; } + } - if (!unconditionalFlowChange) + if (!unconditionalFlowChange) + { + if (block.Next != null) { _sb.AppendLine(IdentationStr + "return " + GetBlockPosition(block.Next) + ";"); } + else + { + _sb.AppendLine(IdentationStr + "return 0u;"); + } } } diff --git a/Ryujinx.Graphics/Memory/NvGpuPBEntry.cs b/Ryujinx.Graphics/Memory/NvGpuPBEntry.cs index 2ff899d351..518dba6b2d 100644 --- a/Ryujinx.Graphics/Memory/NvGpuPBEntry.cs +++ b/Ryujinx.Graphics/Memory/NvGpuPBEntry.cs @@ -9,15 +9,15 @@ namespace Ryujinx.Graphics.Memory public int SubChannel { get; private set; } - private int[] _mArguments; + private int[] _arguments; - public ReadOnlyCollection Arguments => Array.AsReadOnly(_mArguments); + public ReadOnlyCollection Arguments => Array.AsReadOnly(_arguments); public NvGpuPbEntry(int method, int subChannel, params int[] arguments) { Method = method; SubChannel = subChannel; - _mArguments = arguments; + _arguments = arguments; } } } \ No newline at end of file diff --git a/Ryujinx.Graphics/NvGpuEngine3dReg.cs b/Ryujinx.Graphics/NvGpuEngine3dReg.cs index 380ea280b9..d143809265 100644 --- a/Ryujinx.Graphics/NvGpuEngine3dReg.cs +++ b/Ryujinx.Graphics/NvGpuEngine3dReg.cs @@ -37,7 +37,7 @@ namespace Ryujinx.Graphics ZetaVert = 0x48b, ZetaArrayMode = 0x48c, DepthTestEnable = 0x4b3, - BlendEnable = 0x4b9, + IBlendEnable = 0x4b9, DepthWriteEnable = 0x4ba, DepthTestFunction = 0x4c3, BlendSeparateAlpha = 0x4cf, @@ -48,7 +48,7 @@ namespace Ryujinx.Graphics BlendFuncSrcAlpha = 0x4d4, BlendFuncDstAlpha = 0x4d6, BlendEnableMaster = 0x4d7, - BlendNEnable = 0x4d8, + BlendNEnable = 0x4d8, StencilEnable = 0x4e0, StencilFrontOpFail = 0x4e1, StencilFrontOpZFail = 0x4e2, @@ -88,13 +88,13 @@ namespace Ryujinx.Graphics VertexArrayNControl = 0x700, VertexArrayNAddress = 0x701, VertexArrayNDivisor = 0x703, - BlendNSeparateAlpha = 0x780, - BlendNEquationRgb = 0x781, - BlendNFuncSrcRgb = 0x782, - BlendNFuncDstRgb = 0x783, - BlendNEquationAlpha = 0x784, - BlendNFuncSrcAlpha = 0x785, - BlendNFuncDstAlpha = 0x786, + BlendNSeparateAlpha = 0x780, + BlendNEquationRgb = 0x781, + BlendNFuncSrcRgb = 0x782, + BlendNFuncDstRgb = 0x783, + BlendNEquationAlpha = 0x784, + BlendNFuncSrcAlpha = 0x785, + BlendNFuncDstAlpha = 0x786, VertexArrayNEndAddr = 0x7c0, ShaderNControl = 0x800, ShaderNOffset = 0x801, diff --git a/Ryujinx.Graphics/Texture/ImageUtils.cs b/Ryujinx.Graphics/Texture/ImageUtils.cs index 019fd5a7bc..2730c869f6 100644 --- a/Ryujinx.Graphics/Texture/ImageUtils.cs +++ b/Ryujinx.Graphics/Texture/ImageUtils.cs @@ -42,7 +42,7 @@ namespace Ryujinx.Graphics.Texture private const GalImageFormat Float = GalImageFormat.Float; private const GalImageFormat Srgb = GalImageFormat.Srgb; - private static readonly Dictionary STextureTable = + private static readonly Dictionary TextureTable = new Dictionary() { { GalTextureFormat.Rgba32, GalImageFormat.Rgba32 | Sint | Uint | Float }, @@ -89,7 +89,7 @@ namespace Ryujinx.Graphics.Texture { GalTextureFormat.Astc2D10X6, GalImageFormat.Astc2D10X6 | Unorm | Srgb } }; - private static readonly Dictionary SImageTable = + private static readonly Dictionary ImageTable = new Dictionary() { { 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!"); } - if (!STextureTable.TryGetValue(format, out GalImageFormat imageFormat)) + if (!TextureTable.TryGetValue(format, out GalImageFormat imageFormat)) { throw new NotImplementedException($"Format 0x{((int)format):x} not implemented!"); } @@ -375,7 +375,7 @@ namespace Ryujinx.Graphics.Texture { GalImageFormat pixelFormat = format & GalImageFormat.FormatMask; - if (SImageTable.TryGetValue(pixelFormat, out ImageDescriptor descriptor)) + if (ImageTable.TryGetValue(pixelFormat, out ImageDescriptor descriptor)) { return descriptor; } diff --git a/Ryujinx.Graphics/Texture/IntegerEncoded.cs b/Ryujinx.Graphics/Texture/IntegerEncoded.cs index 18671bdfea..73272d3745 100644 --- a/Ryujinx.Graphics/Texture/IntegerEncoded.cs +++ b/Ryujinx.Graphics/Texture/IntegerEncoded.cs @@ -21,10 +21,10 @@ namespace Ryujinx.Graphics.Texture public IntegerEncoded(EIntegerEncoding encoding, int numBits) { _encoding = encoding; - NumberBits = numBits; - BitValue = 0; - TritValue = 0; - QuintValue = 0; + NumberBits = numBits; + BitValue = 0; + TritValue = 0; + QuintValue = 0; } public bool MatchesEncoding(IntegerEncoded other) diff --git a/Ryujinx.HLE/HOS/ErrorModule.cs b/Ryujinx.HLE/HOS/ErrorModule.cs index ffadc7f1f3..e13d5e84fb 100644 --- a/Ryujinx.HLE/HOS/ErrorModule.cs +++ b/Ryujinx.HLE/HOS/ErrorModule.cs @@ -8,18 +8,18 @@ namespace Ryujinx.HLE.HOS Htcs = 4, Ncm = 5, Dd = 6, - DebugMonitor = 7, + DebugMonitor = 7, Lr = 8, Loader = 9, - IpcCommandInterface = 10, + IpcCommandInterface = 10, Ipc = 11, Pm = 15, Ns = 16, Socket = 17, Htc = 18, - NcmContent = 20, + NcmContent = 20, Sm = 21, - RoUserland = 22, + RoUserland = 22, SdMmc = 24, Ovln = 25, Spl = 26, @@ -47,7 +47,7 @@ namespace Ryujinx.HLE.HOS Mii = 126, Nfc = 127, Am = 128, - PlayReport = 129, + PlayReport = 129, Ahid = 130, Qlaunch = 132, Pcv = 133, @@ -64,23 +64,23 @@ namespace Ryujinx.HLE.HOS Ec = 144, ETicket = 145, Ngc = 146, - ErrorReport = 147, + ErrorReport = 147, Apm = 148, Profiler = 150, - ErrorUpload = 151, + ErrorUpload = 151, Audio = 153, Npns = 154, - NpnsHttpStream = 155, + NpnsHttpStream = 155, Arp = 157, Swkbd = 158, Boot = 159, - NfcMifare = 161, - UserlandAssert = 162, + NfcMifare = 161, + UserlandAssert = 162, Fatal = 163, - NimShop = 164, + NimShop = 164, Spsm = 165, Bgtc = 167, - UserlandCrash = 168, + UserlandCrash = 168, SRepo = 180, Dauth = 181, Hid = 202, @@ -92,10 +92,10 @@ namespace Ryujinx.HLE.HOS Web = 210, Grc = 212, Migration = 216, - MigrationLdcServer = 217, - GeneralWebApplet = 800, - WifiWebAuthApplet = 809, - WhitelistedApplet = 810, + MigrationLdcServer = 217, + GeneralWebApplet = 800, + WifiWebAuthApplet = 809, + WhitelistedApplet = 810, ShopN = 811 } } diff --git a/Ryujinx.HLE/HOS/Kernel/KThread.cs b/Ryujinx.HLE/HOS/Kernel/KThread.cs index 957dd2a6c9..7c0870876e 100644 --- a/Ryujinx.HLE/HOS/Kernel/KThread.cs +++ b/Ryujinx.HLE/HOS/Kernel/KThread.cs @@ -75,9 +75,9 @@ namespace Ryujinx.HLE.HOS.Kernel { ThreadId = threadId; - Context = thread; - Owner = process; - PreferredCore = processorId; + Context = thread; + Owner = process; + PreferredCore = processorId; _scheduler = system.Scheduler; _schedulingData = system.Scheduler.SchedulingData;