[Ryujinx.Graphics.Gpu] Address dotnet-format issues (#5367)

* dotnet format style --severity info

Some changes were manually reverted.

* dotnet format analyzers --serverity info

Some changes have been minimally adapted.

* Restore a few unused methods and variables

* Silence dotnet format IDE0060 warnings

* Silence dotnet format IDE0052 warnings

* Address dotnet format CA1816 warnings

* Address or silence dotnet format CA1069 warnings

* Address or silence dotnet format CA2211 warnings

* Address remaining dotnet format analyzer warnings

* Address review comments

* Address most dotnet format whitespace warnings

* Apply dotnet format whitespace formatting

A few of them have been manually reverted and the corresponding warning was silenced

* Format if-blocks correctly

* Run dotnet format whitespace after rebase

* Run dotnet format style after rebase

* Another rebase, another dotnet format run

* Run dotnet format style after rebase

* Run dotnet format after rebase and remove unused usings

- analyzers
- style
- whitespace

* Disable 'prefer switch expression' rule

* Add comments to disabled warnings

* Remove a few unused parameters

* Replace MmeShadowScratch with Array256<uint>

* Simplify properties and array initialization, Use const when possible, Remove trailing commas

* Start working on disabled warnings

* Fix and silence a few dotnet-format warnings again

* Run dotnet format after rebase

* Address IDE0251 warnings

* Silence IDE0060 in .editorconfig

* Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas"

This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e.

* dotnet format whitespace after rebase

* First pass of dotnet format

* Add unsafe dotnet format changes

* Fix typos

* Add trailing commas

* Disable formatting for FormatTable

* Address review feedback
This commit is contained in:
TSRBerry 2023-07-02 02:47:54 +02:00 committed by GitHub
parent 2457cfc911
commit 3b46bb73f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
145 changed files with 1445 additions and 1427 deletions

View file

@ -10,6 +10,6 @@ namespace Ryujinx.Graphics.Gpu
Compute = 0xb1c0, Compute = 0xb1c0,
InlineToMemory = 0xa140, InlineToMemory = 0xa140,
Dma = 0xb0b5, Dma = 0xb0b5,
GPFifo = 0xb06f GPFifo = 0xb06f,
} }
} }

View file

@ -1,9 +1,7 @@
using Ryujinx.Graphics.Device; using Ryujinx.Graphics.Device;
using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Gpu.Engine.InlineToMemory; using Ryujinx.Graphics.Gpu.Engine.InlineToMemory;
using Ryujinx.Graphics.Gpu.Engine.Threed; using Ryujinx.Graphics.Gpu.Engine.Threed;
using Ryujinx.Graphics.Gpu.Engine.Types; using Ryujinx.Graphics.Gpu.Engine.Types;
using Ryujinx.Graphics.Gpu.Image;
using Ryujinx.Graphics.Gpu.Shader; using Ryujinx.Graphics.Gpu.Shader;
using Ryujinx.Graphics.Shader; using Ryujinx.Graphics.Shader;
using System; using System;
@ -39,7 +37,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
{ {
{ nameof(ComputeClassState.LaunchDma), new RwCallback(LaunchDma, null) }, { nameof(ComputeClassState.LaunchDma), new RwCallback(LaunchDma, null) },
{ nameof(ComputeClassState.LoadInlineData), new RwCallback(LoadInlineData, null) }, { nameof(ComputeClassState.LoadInlineData), new RwCallback(LoadInlineData, null) },
{ nameof(ComputeClassState.SendSignalingPcasB), new RwCallback(SendSignalingPcasB, null) } { nameof(ComputeClassState.SendSignalingPcasB), new RwCallback(SendSignalingPcasB, null) },
}); });
_i2mClass = new InlineToMemoryClass(context, channel, initializeState: false); _i2mClass = new InlineToMemoryClass(context, channel, initializeState: false);
@ -128,12 +126,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
ulong samplerPoolGpuVa = ((ulong)_state.State.SetTexSamplerPoolAOffsetUpper << 32) | _state.State.SetTexSamplerPoolB; ulong samplerPoolGpuVa = ((ulong)_state.State.SetTexSamplerPoolAOffsetUpper << 32) | _state.State.SetTexSamplerPoolB;
ulong texturePoolGpuVa = ((ulong)_state.State.SetTexHeaderPoolAOffsetUpper << 32) | _state.State.SetTexHeaderPoolB; ulong texturePoolGpuVa = ((ulong)_state.State.SetTexHeaderPoolAOffsetUpper << 32) | _state.State.SetTexHeaderPoolB;
GpuChannelPoolState poolState = new GpuChannelPoolState( GpuChannelPoolState poolState = new(
texturePoolGpuVa, texturePoolGpuVa,
_state.State.SetTexHeaderPoolCMaximumIndex, _state.State.SetTexHeaderPoolCMaximumIndex,
_state.State.SetBindlessTextureConstantBufferSlotSelect); _state.State.SetBindlessTextureConstantBufferSlotSelect);
GpuChannelComputeState computeState = new GpuChannelComputeState( GpuChannelComputeState computeState = new(
qmd.CtaThreadDimension0, qmd.CtaThreadDimension0,
qmd.CtaThreadDimension1, qmd.CtaThreadDimension1,
qmd.CtaThreadDimension2, qmd.CtaThreadDimension2,
@ -189,8 +187,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
cs = memoryManager.Physical.ShaderCache.GetComputeShader(_channel, poolState, computeState, shaderGpuVa); cs = memoryManager.Physical.ShaderCache.GetComputeShader(_channel, poolState, computeState, shaderGpuVa);
_context.Renderer.Pipeline.SetProgram(cs.HostProgram); _context.Renderer.Pipeline.SetProgram(cs.HostProgram);
info = cs.Shaders[0].Info;
} }
_channel.BufferManager.SetComputeBufferBindings(cs.Bindings); _channel.BufferManager.SetComputeBufferBindings(cs.Bindings);

View file

@ -98,24 +98,24 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
/// </summary> /// </summary>
unsafe struct ComputeClassState unsafe struct ComputeClassState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint SetObject; public uint SetObject;
public int SetObjectClassId => (int)(SetObject & 0xFFFF); public readonly int SetObjectClassId => (int)(SetObject & 0xFFFF);
public int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F); public readonly int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
public fixed uint Reserved04[63]; public fixed uint Reserved04[63];
public uint NoOperation; public uint NoOperation;
public uint SetNotifyA; public uint SetNotifyA;
public int SetNotifyAAddressUpper => (int)(SetNotifyA & 0xFF); public readonly int SetNotifyAAddressUpper => (int)(SetNotifyA & 0xFF);
public uint SetNotifyB; public uint SetNotifyB;
public uint Notify; public uint Notify;
public NotifyType NotifyType => (NotifyType)(Notify); public readonly NotifyType NotifyType => (NotifyType)(Notify);
public uint WaitForIdle; public uint WaitForIdle;
public fixed uint Reserved114[7]; public fixed uint Reserved114[7];
public uint SetGlobalRenderEnableA; public uint SetGlobalRenderEnableA;
public int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF); public readonly int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
public uint SetGlobalRenderEnableB; public uint SetGlobalRenderEnableB;
public uint SetGlobalRenderEnableC; public uint SetGlobalRenderEnableC;
public int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7); public readonly int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
public uint SendGoIdle; public uint SendGoIdle;
public uint PmTrigger; public uint PmTrigger;
public uint PmTriggerWfi; public uint PmTriggerWfi;
@ -126,34 +126,34 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint LineLengthIn; public uint LineLengthIn;
public uint LineCount; public uint LineCount;
public uint OffsetOutUpper; public uint OffsetOutUpper;
public int OffsetOutUpperValue => (int)(OffsetOutUpper & 0xFF); public readonly int OffsetOutUpperValue => (int)(OffsetOutUpper & 0xFF);
public uint OffsetOut; public uint OffsetOut;
public uint PitchOut; public uint PitchOut;
public uint SetDstBlockSize; public uint SetDstBlockSize;
public SetDstBlockSizeWidth SetDstBlockSizeWidth => (SetDstBlockSizeWidth)(SetDstBlockSize & 0xF); public readonly SetDstBlockSizeWidth SetDstBlockSizeWidth => (SetDstBlockSizeWidth)(SetDstBlockSize & 0xF);
public SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF); public readonly SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
public SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF); public readonly SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
public uint SetDstWidth; public uint SetDstWidth;
public uint SetDstHeight; public uint SetDstHeight;
public uint SetDstDepth; public uint SetDstDepth;
public uint SetDstLayer; public uint SetDstLayer;
public uint SetDstOriginBytesX; public uint SetDstOriginBytesX;
public int SetDstOriginBytesXV => (int)(SetDstOriginBytesX & 0xFFFFF); public readonly int SetDstOriginBytesXV => (int)(SetDstOriginBytesX & 0xFFFFF);
public uint SetDstOriginSamplesY; public uint SetDstOriginSamplesY;
public int SetDstOriginSamplesYV => (int)(SetDstOriginSamplesY & 0xFFFF); public readonly int SetDstOriginSamplesYV => (int)(SetDstOriginSamplesY & 0xFFFF);
public uint LaunchDma; public uint LaunchDma;
public LaunchDmaDstMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaDstMemoryLayout)(LaunchDma & 0x1); public readonly LaunchDmaDstMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaDstMemoryLayout)(LaunchDma & 0x1);
public LaunchDmaCompletionType LaunchDmaCompletionType => (LaunchDmaCompletionType)((LaunchDma >> 4) & 0x3); public readonly LaunchDmaCompletionType LaunchDmaCompletionType => (LaunchDmaCompletionType)((LaunchDma >> 4) & 0x3);
public LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 8) & 0x3); public readonly LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 8) & 0x3);
public LaunchDmaSemaphoreStructSize LaunchDmaSemaphoreStructSize => (LaunchDmaSemaphoreStructSize)((LaunchDma >> 12) & 0x1); public readonly LaunchDmaSemaphoreStructSize LaunchDmaSemaphoreStructSize => (LaunchDmaSemaphoreStructSize)((LaunchDma >> 12) & 0x1);
public bool LaunchDmaReductionEnable => (LaunchDma & 0x2) != 0; public readonly bool LaunchDmaReductionEnable => (LaunchDma & 0x2) != 0;
public LaunchDmaReductionOp LaunchDmaReductionOp => (LaunchDmaReductionOp)((LaunchDma >> 13) & 0x7); public readonly LaunchDmaReductionOp LaunchDmaReductionOp => (LaunchDmaReductionOp)((LaunchDma >> 13) & 0x7);
public LaunchDmaReductionFormat LaunchDmaReductionFormat => (LaunchDmaReductionFormat)((LaunchDma >> 2) & 0x3); public readonly LaunchDmaReductionFormat LaunchDmaReductionFormat => (LaunchDmaReductionFormat)((LaunchDma >> 2) & 0x3);
public bool LaunchDmaSysmembarDisable => (LaunchDma & 0x40) != 0; public readonly bool LaunchDmaSysmembarDisable => (LaunchDma & 0x40) != 0;
public uint LoadInlineData; public uint LoadInlineData;
public fixed uint Reserved1B8[9]; public fixed uint Reserved1B8[9];
public uint SetI2mSemaphoreA; public uint SetI2mSemaphoreA;
public int SetI2mSemaphoreAOffsetUpper => (int)(SetI2mSemaphoreA & 0xFF); public readonly int SetI2mSemaphoreAOffsetUpper => (int)(SetI2mSemaphoreA & 0xFF);
public uint SetI2mSemaphoreB; public uint SetI2mSemaphoreB;
public uint SetI2mSemaphoreC; public uint SetI2mSemaphoreC;
public fixed uint Reserved1E8[2]; public fixed uint Reserved1E8[2];
@ -162,20 +162,20 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint SetI2mSpareNoop02; public uint SetI2mSpareNoop02;
public uint SetI2mSpareNoop03; public uint SetI2mSpareNoop03;
public uint SetValidSpanOverflowAreaA; public uint SetValidSpanOverflowAreaA;
public int SetValidSpanOverflowAreaAAddressUpper => (int)(SetValidSpanOverflowAreaA & 0xFF); public readonly int SetValidSpanOverflowAreaAAddressUpper => (int)(SetValidSpanOverflowAreaA & 0xFF);
public uint SetValidSpanOverflowAreaB; public uint SetValidSpanOverflowAreaB;
public uint SetValidSpanOverflowAreaC; public uint SetValidSpanOverflowAreaC;
public uint SetCoalesceWaitingPeriodUnit; public uint SetCoalesceWaitingPeriodUnit;
public uint PerfmonTransfer; public uint PerfmonTransfer;
public uint SetShaderSharedMemoryWindow; public uint SetShaderSharedMemoryWindow;
public uint SetSelectMaxwellTextureHeaders; public uint SetSelectMaxwellTextureHeaders;
public bool SetSelectMaxwellTextureHeadersV => (SetSelectMaxwellTextureHeaders & 0x1) != 0; public readonly bool SetSelectMaxwellTextureHeadersV => (SetSelectMaxwellTextureHeaders & 0x1) != 0;
public uint InvalidateShaderCaches; public uint InvalidateShaderCaches;
public bool InvalidateShaderCachesInstruction => (InvalidateShaderCaches & 0x1) != 0; public readonly bool InvalidateShaderCachesInstruction => (InvalidateShaderCaches & 0x1) != 0;
public bool InvalidateShaderCachesData => (InvalidateShaderCaches & 0x10) != 0; public readonly bool InvalidateShaderCachesData => (InvalidateShaderCaches & 0x10) != 0;
public bool InvalidateShaderCachesConstant => (InvalidateShaderCaches & 0x1000) != 0; public readonly bool InvalidateShaderCachesConstant => (InvalidateShaderCaches & 0x1000) != 0;
public bool InvalidateShaderCachesLocks => (InvalidateShaderCaches & 0x2) != 0; public readonly bool InvalidateShaderCachesLocks => (InvalidateShaderCaches & 0x2) != 0;
public bool InvalidateShaderCachesFlushData => (InvalidateShaderCaches & 0x4) != 0; public readonly bool InvalidateShaderCachesFlushData => (InvalidateShaderCaches & 0x4) != 0;
public uint SetReservedSwMethod00; public uint SetReservedSwMethod00;
public uint SetReservedSwMethod01; public uint SetReservedSwMethod01;
public uint SetReservedSwMethod02; public uint SetReservedSwMethod02;
@ -185,13 +185,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint SetReservedSwMethod06; public uint SetReservedSwMethod06;
public uint SetReservedSwMethod07; public uint SetReservedSwMethod07;
public uint SetCwdControl; public uint SetCwdControl;
public SetCwdControlSmSelection SetCwdControlSmSelection => (SetCwdControlSmSelection)(SetCwdControl & 0x1); public readonly SetCwdControlSmSelection SetCwdControlSmSelection => (SetCwdControlSmSelection)(SetCwdControl & 0x1);
public uint InvalidateTextureHeaderCacheNoWfi; public uint InvalidateTextureHeaderCacheNoWfi;
public InvalidateCacheLines InvalidateTextureHeaderCacheNoWfiLines => (InvalidateCacheLines)(InvalidateTextureHeaderCacheNoWfi & 0x1); public readonly InvalidateCacheLines InvalidateTextureHeaderCacheNoWfiLines => (InvalidateCacheLines)(InvalidateTextureHeaderCacheNoWfi & 0x1);
public int InvalidateTextureHeaderCacheNoWfiTag => (int)((InvalidateTextureHeaderCacheNoWfi >> 4) & 0x3FFFFF); public readonly int InvalidateTextureHeaderCacheNoWfiTag => (int)((InvalidateTextureHeaderCacheNoWfi >> 4) & 0x3FFFFF);
public uint SetCwdRefCounter; public uint SetCwdRefCounter;
public int SetCwdRefCounterSelect => (int)(SetCwdRefCounter & 0x3F); public readonly int SetCwdRefCounterSelect => (int)(SetCwdRefCounter & 0x3F);
public int SetCwdRefCounterValue => (int)((SetCwdRefCounter >> 8) & 0xFFFF); public readonly int SetCwdRefCounterValue => (int)((SetCwdRefCounter >> 8) & 0xFFFF);
public uint SetReservedSwMethod08; public uint SetReservedSwMethod08;
public uint SetReservedSwMethod09; public uint SetReservedSwMethod09;
public uint SetReservedSwMethod10; public uint SetReservedSwMethod10;
@ -201,59 +201,59 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint SetReservedSwMethod14; public uint SetReservedSwMethod14;
public uint SetReservedSwMethod15; public uint SetReservedSwMethod15;
public uint SetGwcScgType; public uint SetGwcScgType;
public SetGwcScgTypeScgType SetGwcScgTypeScgType => (SetGwcScgTypeScgType)(SetGwcScgType & 0x1); public readonly SetGwcScgTypeScgType SetGwcScgTypeScgType => (SetGwcScgTypeScgType)(SetGwcScgType & 0x1);
public uint SetScgControl; public uint SetScgControl;
public int SetScgControlCompute1MaxSmCount => (int)(SetScgControl & 0x1FF); public readonly int SetScgControlCompute1MaxSmCount => (int)(SetScgControl & 0x1FF);
public uint InvalidateConstantBufferCacheA; public uint InvalidateConstantBufferCacheA;
public int InvalidateConstantBufferCacheAAddressUpper => (int)(InvalidateConstantBufferCacheA & 0xFF); public readonly int InvalidateConstantBufferCacheAAddressUpper => (int)(InvalidateConstantBufferCacheA & 0xFF);
public uint InvalidateConstantBufferCacheB; public uint InvalidateConstantBufferCacheB;
public uint InvalidateConstantBufferCacheC; public uint InvalidateConstantBufferCacheC;
public int InvalidateConstantBufferCacheCByteCount => (int)(InvalidateConstantBufferCacheC & 0x1FFFF); public readonly int InvalidateConstantBufferCacheCByteCount => (int)(InvalidateConstantBufferCacheC & 0x1FFFF);
public bool InvalidateConstantBufferCacheCThruL2 => (InvalidateConstantBufferCacheC & 0x80000000) != 0; public readonly bool InvalidateConstantBufferCacheCThruL2 => (InvalidateConstantBufferCacheC & 0x80000000) != 0;
public uint SetComputeClassVersion; public uint SetComputeClassVersion;
public int SetComputeClassVersionCurrent => (int)(SetComputeClassVersion & 0xFFFF); public readonly int SetComputeClassVersionCurrent => (int)(SetComputeClassVersion & 0xFFFF);
public int SetComputeClassVersionOldestSupported => (int)((SetComputeClassVersion >> 16) & 0xFFFF); public readonly int SetComputeClassVersionOldestSupported => (int)((SetComputeClassVersion >> 16) & 0xFFFF);
public uint CheckComputeClassVersion; public uint CheckComputeClassVersion;
public int CheckComputeClassVersionCurrent => (int)(CheckComputeClassVersion & 0xFFFF); public readonly int CheckComputeClassVersionCurrent => (int)(CheckComputeClassVersion & 0xFFFF);
public int CheckComputeClassVersionOldestSupported => (int)((CheckComputeClassVersion >> 16) & 0xFFFF); public readonly int CheckComputeClassVersionOldestSupported => (int)((CheckComputeClassVersion >> 16) & 0xFFFF);
public uint SetQmdVersion; public uint SetQmdVersion;
public int SetQmdVersionCurrent => (int)(SetQmdVersion & 0xFFFF); public readonly int SetQmdVersionCurrent => (int)(SetQmdVersion & 0xFFFF);
public int SetQmdVersionOldestSupported => (int)((SetQmdVersion >> 16) & 0xFFFF); public readonly int SetQmdVersionOldestSupported => (int)((SetQmdVersion >> 16) & 0xFFFF);
public uint SetWfiConfig; public uint SetWfiConfig;
public bool SetWfiConfigEnableScgTypeWfi => (SetWfiConfig & 0x1) != 0; public readonly bool SetWfiConfigEnableScgTypeWfi => (SetWfiConfig & 0x1) != 0;
public uint CheckQmdVersion; public uint CheckQmdVersion;
public int CheckQmdVersionCurrent => (int)(CheckQmdVersion & 0xFFFF); public readonly int CheckQmdVersionCurrent => (int)(CheckQmdVersion & 0xFFFF);
public int CheckQmdVersionOldestSupported => (int)((CheckQmdVersion >> 16) & 0xFFFF); public readonly int CheckQmdVersionOldestSupported => (int)((CheckQmdVersion >> 16) & 0xFFFF);
public uint WaitForIdleScgType; public uint WaitForIdleScgType;
public uint InvalidateSkedCaches; public uint InvalidateSkedCaches;
public bool InvalidateSkedCachesV => (InvalidateSkedCaches & 0x1) != 0; public readonly bool InvalidateSkedCachesV => (InvalidateSkedCaches & 0x1) != 0;
public uint SetScgRenderEnableControl; public uint SetScgRenderEnableControl;
public bool SetScgRenderEnableControlCompute1UsesRenderEnable => (SetScgRenderEnableControl & 0x1) != 0; public readonly bool SetScgRenderEnableControlCompute1UsesRenderEnable => (SetScgRenderEnableControl & 0x1) != 0;
public fixed uint Reserved2A0[4]; public fixed uint Reserved2A0[4];
public uint SetCwdSlotCount; public uint SetCwdSlotCount;
public int SetCwdSlotCountV => (int)(SetCwdSlotCount & 0xFF); public readonly int SetCwdSlotCountV => (int)(SetCwdSlotCount & 0xFF);
public uint SendPcasA; public uint SendPcasA;
public uint SendPcasB; public uint SendPcasB;
public int SendPcasBFrom => (int)(SendPcasB & 0xFFFFFF); public readonly int SendPcasBFrom => (int)(SendPcasB & 0xFFFFFF);
public int SendPcasBDelta => (int)((SendPcasB >> 24) & 0xFF); public readonly int SendPcasBDelta => (int)((SendPcasB >> 24) & 0xFF);
public uint SendSignalingPcasB; public uint SendSignalingPcasB;
public bool SendSignalingPcasBInvalidate => (SendSignalingPcasB & 0x1) != 0; public readonly bool SendSignalingPcasBInvalidate => (SendSignalingPcasB & 0x1) != 0;
public bool SendSignalingPcasBSchedule => (SendSignalingPcasB & 0x2) != 0; public readonly bool SendSignalingPcasBSchedule => (SendSignalingPcasB & 0x2) != 0;
public fixed uint Reserved2C0[9]; public fixed uint Reserved2C0[9];
public uint SetShaderLocalMemoryNonThrottledA; public uint SetShaderLocalMemoryNonThrottledA;
public int SetShaderLocalMemoryNonThrottledASizeUpper => (int)(SetShaderLocalMemoryNonThrottledA & 0xFF); public readonly int SetShaderLocalMemoryNonThrottledASizeUpper => (int)(SetShaderLocalMemoryNonThrottledA & 0xFF);
public uint SetShaderLocalMemoryNonThrottledB; public uint SetShaderLocalMemoryNonThrottledB;
public uint SetShaderLocalMemoryNonThrottledC; public uint SetShaderLocalMemoryNonThrottledC;
public int SetShaderLocalMemoryNonThrottledCMaxSmCount => (int)(SetShaderLocalMemoryNonThrottledC & 0x1FF); public readonly int SetShaderLocalMemoryNonThrottledCMaxSmCount => (int)(SetShaderLocalMemoryNonThrottledC & 0x1FF);
public uint SetShaderLocalMemoryThrottledA; public uint SetShaderLocalMemoryThrottledA;
public int SetShaderLocalMemoryThrottledASizeUpper => (int)(SetShaderLocalMemoryThrottledA & 0xFF); public readonly int SetShaderLocalMemoryThrottledASizeUpper => (int)(SetShaderLocalMemoryThrottledA & 0xFF);
public uint SetShaderLocalMemoryThrottledB; public uint SetShaderLocalMemoryThrottledB;
public uint SetShaderLocalMemoryThrottledC; public uint SetShaderLocalMemoryThrottledC;
public int SetShaderLocalMemoryThrottledCMaxSmCount => (int)(SetShaderLocalMemoryThrottledC & 0x1FF); public readonly int SetShaderLocalMemoryThrottledCMaxSmCount => (int)(SetShaderLocalMemoryThrottledC & 0x1FF);
public fixed uint Reserved2FC[5]; public fixed uint Reserved2FC[5];
public uint SetSpaVersion; public uint SetSpaVersion;
public int SetSpaVersionMinor => (int)(SetSpaVersion & 0xFF); public readonly int SetSpaVersionMinor => (int)(SetSpaVersion & 0xFF);
public int SetSpaVersionMajor => (int)((SetSpaVersion >> 8) & 0xFF); public readonly int SetSpaVersionMajor => (int)((SetSpaVersion >> 8) & 0xFF);
public fixed uint Reserved314[123]; public fixed uint Reserved314[123];
public uint SetFalcon00; public uint SetFalcon00;
public uint SetFalcon01; public uint SetFalcon01;
@ -291,14 +291,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint SetShaderLocalMemoryWindow; public uint SetShaderLocalMemoryWindow;
public fixed uint Reserved780[4]; public fixed uint Reserved780[4];
public uint SetShaderLocalMemoryA; public uint SetShaderLocalMemoryA;
public int SetShaderLocalMemoryAAddressUpper => (int)(SetShaderLocalMemoryA & 0xFF); public readonly int SetShaderLocalMemoryAAddressUpper => (int)(SetShaderLocalMemoryA & 0xFF);
public uint SetShaderLocalMemoryB; public uint SetShaderLocalMemoryB;
public fixed uint Reserved798[383]; public fixed uint Reserved798[383];
public uint SetShaderCacheControl; public uint SetShaderCacheControl;
public bool SetShaderCacheControlIcachePrefetchEnable => (SetShaderCacheControl & 0x1) != 0; public readonly bool SetShaderCacheControlIcachePrefetchEnable => (SetShaderCacheControl & 0x1) != 0;
public fixed uint ReservedD98[19]; public fixed uint ReservedD98[19];
public uint SetSmTimeoutInterval; public uint SetSmTimeoutInterval;
public int SetSmTimeoutIntervalCounterBit => (int)(SetSmTimeoutInterval & 0x3F); public readonly int SetSmTimeoutIntervalCounterBit => (int)(SetSmTimeoutInterval & 0x3F);
public fixed uint ReservedDE8[87]; public fixed uint ReservedDE8[87];
public uint SetSpareNoop12; public uint SetSpareNoop12;
public uint SetSpareNoop13; public uint SetSpareNoop13;
@ -319,62 +319,62 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint SetSpareNoop11; public uint SetSpareNoop11;
public fixed uint Reserved1070[103]; public fixed uint Reserved1070[103];
public uint InvalidateSamplerCacheAll; public uint InvalidateSamplerCacheAll;
public bool InvalidateSamplerCacheAllV => (InvalidateSamplerCacheAll & 0x1) != 0; public readonly bool InvalidateSamplerCacheAllV => (InvalidateSamplerCacheAll & 0x1) != 0;
public uint InvalidateTextureHeaderCacheAll; public uint InvalidateTextureHeaderCacheAll;
public bool InvalidateTextureHeaderCacheAllV => (InvalidateTextureHeaderCacheAll & 0x1) != 0; public readonly bool InvalidateTextureHeaderCacheAllV => (InvalidateTextureHeaderCacheAll & 0x1) != 0;
public fixed uint Reserved1214[29]; public fixed uint Reserved1214[29];
public uint InvalidateTextureDataCacheNoWfi; public uint InvalidateTextureDataCacheNoWfi;
public InvalidateCacheLines InvalidateTextureDataCacheNoWfiLines => (InvalidateCacheLines)(InvalidateTextureDataCacheNoWfi & 0x1); public readonly InvalidateCacheLines InvalidateTextureDataCacheNoWfiLines => (InvalidateCacheLines)(InvalidateTextureDataCacheNoWfi & 0x1);
public int InvalidateTextureDataCacheNoWfiTag => (int)((InvalidateTextureDataCacheNoWfi >> 4) & 0x3FFFFF); public readonly int InvalidateTextureDataCacheNoWfiTag => (int)((InvalidateTextureDataCacheNoWfi >> 4) & 0x3FFFFF);
public fixed uint Reserved128C[7]; public fixed uint Reserved128C[7];
public uint ActivatePerfSettingsForComputeContext; public uint ActivatePerfSettingsForComputeContext;
public bool ActivatePerfSettingsForComputeContextAll => (ActivatePerfSettingsForComputeContext & 0x1) != 0; public readonly bool ActivatePerfSettingsForComputeContextAll => (ActivatePerfSettingsForComputeContext & 0x1) != 0;
public fixed uint Reserved12AC[33]; public fixed uint Reserved12AC[33];
public uint InvalidateSamplerCache; public uint InvalidateSamplerCache;
public InvalidateCacheLines InvalidateSamplerCacheLines => (InvalidateCacheLines)(InvalidateSamplerCache & 0x1); public readonly InvalidateCacheLines InvalidateSamplerCacheLines => (InvalidateCacheLines)(InvalidateSamplerCache & 0x1);
public int InvalidateSamplerCacheTag => (int)((InvalidateSamplerCache >> 4) & 0x3FFFFF); public readonly int InvalidateSamplerCacheTag => (int)((InvalidateSamplerCache >> 4) & 0x3FFFFF);
public uint InvalidateTextureHeaderCache; public uint InvalidateTextureHeaderCache;
public InvalidateCacheLines InvalidateTextureHeaderCacheLines => (InvalidateCacheLines)(InvalidateTextureHeaderCache & 0x1); public readonly InvalidateCacheLines InvalidateTextureHeaderCacheLines => (InvalidateCacheLines)(InvalidateTextureHeaderCache & 0x1);
public int InvalidateTextureHeaderCacheTag => (int)((InvalidateTextureHeaderCache >> 4) & 0x3FFFFF); public readonly int InvalidateTextureHeaderCacheTag => (int)((InvalidateTextureHeaderCache >> 4) & 0x3FFFFF);
public uint InvalidateTextureDataCache; public uint InvalidateTextureDataCache;
public InvalidateCacheLines InvalidateTextureDataCacheLines => (InvalidateCacheLines)(InvalidateTextureDataCache & 0x1); public readonly InvalidateCacheLines InvalidateTextureDataCacheLines => (InvalidateCacheLines)(InvalidateTextureDataCache & 0x1);
public int InvalidateTextureDataCacheTag => (int)((InvalidateTextureDataCache >> 4) & 0x3FFFFF); public readonly int InvalidateTextureDataCacheTag => (int)((InvalidateTextureDataCache >> 4) & 0x3FFFFF);
public fixed uint Reserved133C[58]; public fixed uint Reserved133C[58];
public uint InvalidateSamplerCacheNoWfi; public uint InvalidateSamplerCacheNoWfi;
public InvalidateCacheLines InvalidateSamplerCacheNoWfiLines => (InvalidateCacheLines)(InvalidateSamplerCacheNoWfi & 0x1); public readonly InvalidateCacheLines InvalidateSamplerCacheNoWfiLines => (InvalidateCacheLines)(InvalidateSamplerCacheNoWfi & 0x1);
public int InvalidateSamplerCacheNoWfiTag => (int)((InvalidateSamplerCacheNoWfi >> 4) & 0x3FFFFF); public readonly int InvalidateSamplerCacheNoWfiTag => (int)((InvalidateSamplerCacheNoWfi >> 4) & 0x3FFFFF);
public fixed uint Reserved1428[64]; public fixed uint Reserved1428[64];
public uint SetShaderExceptions; public uint SetShaderExceptions;
public bool SetShaderExceptionsEnable => (SetShaderExceptions & 0x1) != 0; public readonly bool SetShaderExceptionsEnable => (SetShaderExceptions & 0x1) != 0;
public fixed uint Reserved152C[9]; public fixed uint Reserved152C[9];
public uint SetRenderEnableA; public uint SetRenderEnableA;
public int SetRenderEnableAOffsetUpper => (int)(SetRenderEnableA & 0xFF); public readonly int SetRenderEnableAOffsetUpper => (int)(SetRenderEnableA & 0xFF);
public uint SetRenderEnableB; public uint SetRenderEnableB;
public uint SetRenderEnableC; public uint SetRenderEnableC;
public int SetRenderEnableCMode => (int)(SetRenderEnableC & 0x7); public readonly int SetRenderEnableCMode => (int)(SetRenderEnableC & 0x7);
public uint SetTexSamplerPoolA; public uint SetTexSamplerPoolA;
public int SetTexSamplerPoolAOffsetUpper => (int)(SetTexSamplerPoolA & 0xFF); public readonly int SetTexSamplerPoolAOffsetUpper => (int)(SetTexSamplerPoolA & 0xFF);
public uint SetTexSamplerPoolB; public uint SetTexSamplerPoolB;
public uint SetTexSamplerPoolC; public uint SetTexSamplerPoolC;
public int SetTexSamplerPoolCMaximumIndex => (int)(SetTexSamplerPoolC & 0xFFFFF); public readonly int SetTexSamplerPoolCMaximumIndex => (int)(SetTexSamplerPoolC & 0xFFFFF);
public fixed uint Reserved1568[3]; public fixed uint Reserved1568[3];
public uint SetTexHeaderPoolA; public uint SetTexHeaderPoolA;
public int SetTexHeaderPoolAOffsetUpper => (int)(SetTexHeaderPoolA & 0xFF); public readonly int SetTexHeaderPoolAOffsetUpper => (int)(SetTexHeaderPoolA & 0xFF);
public uint SetTexHeaderPoolB; public uint SetTexHeaderPoolB;
public uint SetTexHeaderPoolC; public uint SetTexHeaderPoolC;
public int SetTexHeaderPoolCMaximumIndex => (int)(SetTexHeaderPoolC & 0x3FFFFF); public readonly int SetTexHeaderPoolCMaximumIndex => (int)(SetTexHeaderPoolC & 0x3FFFFF);
public fixed uint Reserved1580[34]; public fixed uint Reserved1580[34];
public uint SetProgramRegionA; public uint SetProgramRegionA;
public int SetProgramRegionAAddressUpper => (int)(SetProgramRegionA & 0xFF); public readonly int SetProgramRegionAAddressUpper => (int)(SetProgramRegionA & 0xFF);
public uint SetProgramRegionB; public uint SetProgramRegionB;
public fixed uint Reserved1610[34]; public fixed uint Reserved1610[34];
public uint InvalidateShaderCachesNoWfi; public uint InvalidateShaderCachesNoWfi;
public bool InvalidateShaderCachesNoWfiInstruction => (InvalidateShaderCachesNoWfi & 0x1) != 0; public readonly bool InvalidateShaderCachesNoWfiInstruction => (InvalidateShaderCachesNoWfi & 0x1) != 0;
public bool InvalidateShaderCachesNoWfiGlobalData => (InvalidateShaderCachesNoWfi & 0x10) != 0; public readonly bool InvalidateShaderCachesNoWfiGlobalData => (InvalidateShaderCachesNoWfi & 0x10) != 0;
public bool InvalidateShaderCachesNoWfiConstant => (InvalidateShaderCachesNoWfi & 0x1000) != 0; public readonly bool InvalidateShaderCachesNoWfiConstant => (InvalidateShaderCachesNoWfi & 0x1000) != 0;
public fixed uint Reserved169C[170]; public fixed uint Reserved169C[170];
public uint SetRenderEnableOverride; public uint SetRenderEnableOverride;
public SetRenderEnableOverrideMode SetRenderEnableOverrideMode => (SetRenderEnableOverrideMode)(SetRenderEnableOverride & 0x3); public readonly SetRenderEnableOverrideMode SetRenderEnableOverrideMode => (SetRenderEnableOverrideMode)(SetRenderEnableOverride & 0x3);
public fixed uint Reserved1948[57]; public fixed uint Reserved1948[57];
public uint PipeNop; public uint PipeNop;
public uint SetSpare00; public uint SetSpare00;
@ -383,20 +383,20 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public uint SetSpare03; public uint SetSpare03;
public fixed uint Reserved1A40[48]; public fixed uint Reserved1A40[48];
public uint SetReportSemaphoreA; public uint SetReportSemaphoreA;
public int SetReportSemaphoreAOffsetUpper => (int)(SetReportSemaphoreA & 0xFF); public readonly int SetReportSemaphoreAOffsetUpper => (int)(SetReportSemaphoreA & 0xFF);
public uint SetReportSemaphoreB; public uint SetReportSemaphoreB;
public uint SetReportSemaphoreC; public uint SetReportSemaphoreC;
public uint SetReportSemaphoreD; public uint SetReportSemaphoreD;
public SetReportSemaphoreDOperation SetReportSemaphoreDOperation => (SetReportSemaphoreDOperation)(SetReportSemaphoreD & 0x3); public readonly SetReportSemaphoreDOperation SetReportSemaphoreDOperation => (SetReportSemaphoreDOperation)(SetReportSemaphoreD & 0x3);
public bool SetReportSemaphoreDAwakenEnable => (SetReportSemaphoreD & 0x100000) != 0; public readonly bool SetReportSemaphoreDAwakenEnable => (SetReportSemaphoreD & 0x100000) != 0;
public SetReportSemaphoreDStructureSize SetReportSemaphoreDStructureSize => (SetReportSemaphoreDStructureSize)((SetReportSemaphoreD >> 28) & 0x1); public readonly SetReportSemaphoreDStructureSize SetReportSemaphoreDStructureSize => (SetReportSemaphoreDStructureSize)((SetReportSemaphoreD >> 28) & 0x1);
public bool SetReportSemaphoreDFlushDisable => (SetReportSemaphoreD & 0x4) != 0; public readonly bool SetReportSemaphoreDFlushDisable => (SetReportSemaphoreD & 0x4) != 0;
public bool SetReportSemaphoreDReductionEnable => (SetReportSemaphoreD & 0x8) != 0; public readonly bool SetReportSemaphoreDReductionEnable => (SetReportSemaphoreD & 0x8) != 0;
public SetReportSemaphoreDReductionOp SetReportSemaphoreDReductionOp => (SetReportSemaphoreDReductionOp)((SetReportSemaphoreD >> 9) & 0x7); public readonly SetReportSemaphoreDReductionOp SetReportSemaphoreDReductionOp => (SetReportSemaphoreDReductionOp)((SetReportSemaphoreD >> 9) & 0x7);
public SetReportSemaphoreDReductionFormat SetReportSemaphoreDReductionFormat => (SetReportSemaphoreDReductionFormat)((SetReportSemaphoreD >> 17) & 0x3); public readonly SetReportSemaphoreDReductionFormat SetReportSemaphoreDReductionFormat => (SetReportSemaphoreDReductionFormat)((SetReportSemaphoreD >> 17) & 0x3);
public fixed uint Reserved1B10[702]; public fixed uint Reserved1B10[702];
public uint SetBindlessTexture; public uint SetBindlessTexture;
public int SetBindlessTextureConstantBufferSlotSelect => (int)(SetBindlessTexture & 0x7); public readonly int SetBindlessTextureConstantBufferSlotSelect => (int)(SetBindlessTexture & 0x7);
public uint SetTrapHandler; public uint SetTrapHandler;
public fixed uint Reserved2610[843]; public fixed uint Reserved2610[843];
public Array8<uint> SetShaderPerformanceCounterValueUpper; public Array8<uint> SetShaderPerformanceCounterValueUpper;
@ -423,13 +423,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
public bool SetShaderPerformanceCounterControlBWindowed(int i) => (SetShaderPerformanceCounterControlB[i] & 0x8) != 0; public bool SetShaderPerformanceCounterControlBWindowed(int i) => (SetShaderPerformanceCounterControlB[i] & 0x8) != 0;
public int SetShaderPerformanceCounterControlBFunc(int i) => (int)((SetShaderPerformanceCounterControlB[i] >> 4) & 0xFFFF); public int SetShaderPerformanceCounterControlBFunc(int i) => (int)((SetShaderPerformanceCounterControlB[i] >> 4) & 0xFFFF);
public uint SetShaderPerformanceCounterTrapControl; public uint SetShaderPerformanceCounterTrapControl;
public int SetShaderPerformanceCounterTrapControlMask => (int)(SetShaderPerformanceCounterTrapControl & 0xFF); public readonly int SetShaderPerformanceCounterTrapControlMask => (int)(SetShaderPerformanceCounterTrapControl & 0xFF);
public uint StartShaderPerformanceCounter; public uint StartShaderPerformanceCounter;
public int StartShaderPerformanceCounterCounterMask => (int)(StartShaderPerformanceCounter & 0xFF); public readonly int StartShaderPerformanceCounterCounterMask => (int)(StartShaderPerformanceCounter & 0xFF);
public uint StopShaderPerformanceCounter; public uint StopShaderPerformanceCounter;
public int StopShaderPerformanceCounterCounterMask => (int)(StopShaderPerformanceCounter & 0xFF); public readonly int StopShaderPerformanceCounterCounterMask => (int)(StopShaderPerformanceCounter & 0xFF);
public fixed uint Reserved33E8[6]; public fixed uint Reserved33E8[6];
public MmeShadowScratch SetMmeShadowScratch; public Array256<uint> SetMmeShadowScratch;
#pragma warning restore CS0649 #pragma warning restore CS0649
} }
} }

View file

@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum DependentQmdType enum DependentQmdType
{ {
Queue, Queue,
Grid Grid,
} }
/// <summary> /// <summary>
@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum ReleaseMembarType enum ReleaseMembarType
{ {
FeNone, FeNone,
FeSysmembar FeSysmembar,
} }
/// <summary> /// <summary>
@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
{ {
L1None, L1None,
L1Sysmembar, L1Sysmembar,
L1Membar L1Membar,
} }
/// <summary> /// <summary>
@ -38,7 +38,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum Fp32NanBehavior enum Fp32NanBehavior
{ {
Legacy, Legacy,
Fp64Compatible Fp64Compatible,
} }
/// <summary> /// <summary>
@ -47,7 +47,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum Fp32F2iNanBehavior enum Fp32F2iNanBehavior
{ {
PassZero, PassZero,
PassIndefinite PassIndefinite,
} }
/// <summary> /// <summary>
@ -56,7 +56,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum ApiVisibleCallLimit enum ApiVisibleCallLimit
{ {
_32, _32,
NoCheck NoCheck,
} }
/// <summary> /// <summary>
@ -65,7 +65,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum SharedMemoryBankMapping enum SharedMemoryBankMapping
{ {
FourBytesPerBank, FourBytesPerBank,
EightBytesPerBank EightBytesPerBank,
} }
/// <summary> /// <summary>
@ -74,7 +74,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum Fp32NarrowInstruction enum Fp32NarrowInstruction
{ {
KeepDenorms, KeepDenorms,
FlushDenorms FlushDenorms,
} }
/// <summary> /// <summary>
@ -84,7 +84,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
{ {
DirectlyAddressableMemorySize16kb, DirectlyAddressableMemorySize16kb,
DirectlyAddressableMemorySize32kb, DirectlyAddressableMemorySize32kb,
DirectlyAddressableMemorySize48kb DirectlyAddressableMemorySize48kb,
} }
/// <summary> /// <summary>
@ -99,7 +99,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
RedDec, RedDec,
RedAnd, RedAnd,
RedOr, RedOr,
RedXor RedXor,
} }
/// <summary> /// <summary>
@ -108,7 +108,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum ReductionFormat enum ReductionFormat
{ {
Unsigned32, Unsigned32,
Signed32 Signed32,
} }
/// <summary> /// <summary>
@ -117,7 +117,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
enum StructureSize enum StructureSize
{ {
FourWords, FourWords,
OneWord OneWord,
} }
/// <summary> /// <summary>
@ -127,129 +127,129 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
{ {
private fixed int _words[64]; private fixed int _words[64];
public int OuterPut => BitRange(30, 0); public readonly int OuterPut => BitRange(30, 0);
public bool OuterOverflow => Bit(31); public readonly bool OuterOverflow => Bit(31);
public int OuterGet => BitRange(62, 32); public readonly int OuterGet => BitRange(62, 32);
public bool OuterStickyOverflow => Bit(63); public readonly bool OuterStickyOverflow => Bit(63);
public int InnerGet => BitRange(94, 64); public readonly int InnerGet => BitRange(94, 64);
public bool InnerOverflow => Bit(95); public readonly bool InnerOverflow => Bit(95);
public int InnerPut => BitRange(126, 96); public readonly int InnerPut => BitRange(126, 96);
public bool InnerStickyOverflow => Bit(127); public readonly bool InnerStickyOverflow => Bit(127);
public int QmdReservedAA => BitRange(159, 128); public readonly int QmdReservedAA => BitRange(159, 128);
public int DependentQmdPointer => BitRange(191, 160); public readonly int DependentQmdPointer => BitRange(191, 160);
public int QmdGroupId => BitRange(197, 192); public readonly int QmdGroupId => BitRange(197, 192);
public bool SmGlobalCachingEnable => Bit(198); public readonly bool SmGlobalCachingEnable => Bit(198);
public bool RunCtaInOneSmPartition => Bit(199); public readonly bool RunCtaInOneSmPartition => Bit(199);
public bool IsQueue => Bit(200); public readonly bool IsQueue => Bit(200);
public bool AddToHeadOfQmdGroupLinkedList => Bit(201); public readonly bool AddToHeadOfQmdGroupLinkedList => Bit(201);
public bool SemaphoreReleaseEnable0 => Bit(202); public readonly bool SemaphoreReleaseEnable0 => Bit(202);
public bool SemaphoreReleaseEnable1 => Bit(203); public readonly bool SemaphoreReleaseEnable1 => Bit(203);
public bool RequireSchedulingPcas => Bit(204); public readonly bool RequireSchedulingPcas => Bit(204);
public bool DependentQmdScheduleEnable => Bit(205); public readonly bool DependentQmdScheduleEnable => Bit(205);
public DependentQmdType DependentQmdType => (DependentQmdType)BitRange(206, 206); public readonly DependentQmdType DependentQmdType => (DependentQmdType)BitRange(206, 206);
public bool DependentQmdFieldCopy => Bit(207); public readonly bool DependentQmdFieldCopy => Bit(207);
public int QmdReservedB => BitRange(223, 208); public readonly int QmdReservedB => BitRange(223, 208);
public int CircularQueueSize => BitRange(248, 224); public readonly int CircularQueueSize => BitRange(248, 224);
public bool QmdReservedC => Bit(249); public readonly bool QmdReservedC => Bit(249);
public bool InvalidateTextureHeaderCache => Bit(250); public readonly bool InvalidateTextureHeaderCache => Bit(250);
public bool InvalidateTextureSamplerCache => Bit(251); public readonly bool InvalidateTextureSamplerCache => Bit(251);
public bool InvalidateTextureDataCache => Bit(252); public readonly bool InvalidateTextureDataCache => Bit(252);
public bool InvalidateShaderDataCache => Bit(253); public readonly bool InvalidateShaderDataCache => Bit(253);
public bool InvalidateInstructionCache => Bit(254); public readonly bool InvalidateInstructionCache => Bit(254);
public bool InvalidateShaderConstantCache => Bit(255); public readonly bool InvalidateShaderConstantCache => Bit(255);
public int ProgramOffset => BitRange(287, 256); public readonly int ProgramOffset => BitRange(287, 256);
public int CircularQueueAddrLower => BitRange(319, 288); public readonly int CircularQueueAddrLower => BitRange(319, 288);
public int CircularQueueAddrUpper => BitRange(327, 320); public readonly int CircularQueueAddrUpper => BitRange(327, 320);
public int QmdReservedD => BitRange(335, 328); public readonly int QmdReservedD => BitRange(335, 328);
public int CircularQueueEntrySize => BitRange(351, 336); public readonly int CircularQueueEntrySize => BitRange(351, 336);
public int CwdReferenceCountId => BitRange(357, 352); public readonly int CwdReferenceCountId => BitRange(357, 352);
public int CwdReferenceCountDeltaMinusOne => BitRange(365, 358); public readonly int CwdReferenceCountDeltaMinusOne => BitRange(365, 358);
public ReleaseMembarType ReleaseMembarType => (ReleaseMembarType)BitRange(366, 366); public readonly ReleaseMembarType ReleaseMembarType => (ReleaseMembarType)BitRange(366, 366);
public bool CwdReferenceCountIncrEnable => Bit(367); public readonly bool CwdReferenceCountIncrEnable => Bit(367);
public CwdMembarType CwdMembarType => (CwdMembarType)BitRange(369, 368); public readonly CwdMembarType CwdMembarType => (CwdMembarType)BitRange(369, 368);
public bool SequentiallyRunCtas => Bit(370); public readonly bool SequentiallyRunCtas => Bit(370);
public bool CwdReferenceCountDecrEnable => Bit(371); public readonly bool CwdReferenceCountDecrEnable => Bit(371);
public bool Throttled => Bit(372); public readonly bool Throttled => Bit(372);
public Fp32NanBehavior Fp32NanBehavior => (Fp32NanBehavior)BitRange(376, 376); public readonly Fp32NanBehavior Fp32NanBehavior => (Fp32NanBehavior)BitRange(376, 376);
public Fp32F2iNanBehavior Fp32F2iNanBehavior => (Fp32F2iNanBehavior)BitRange(377, 377); public readonly Fp32F2iNanBehavior Fp32F2iNanBehavior => (Fp32F2iNanBehavior)BitRange(377, 377);
public ApiVisibleCallLimit ApiVisibleCallLimit => (ApiVisibleCallLimit)BitRange(378, 378); public readonly ApiVisibleCallLimit ApiVisibleCallLimit => (ApiVisibleCallLimit)BitRange(378, 378);
public SharedMemoryBankMapping SharedMemoryBankMapping => (SharedMemoryBankMapping)BitRange(379, 379); public readonly SharedMemoryBankMapping SharedMemoryBankMapping => (SharedMemoryBankMapping)BitRange(379, 379);
public SamplerIndex SamplerIndex => (SamplerIndex)BitRange(382, 382); public readonly SamplerIndex SamplerIndex => (SamplerIndex)BitRange(382, 382);
public Fp32NarrowInstruction Fp32NarrowInstruction => (Fp32NarrowInstruction)BitRange(383, 383); public readonly Fp32NarrowInstruction Fp32NarrowInstruction => (Fp32NarrowInstruction)BitRange(383, 383);
public int CtaRasterWidth => BitRange(415, 384); public readonly int CtaRasterWidth => BitRange(415, 384);
public int CtaRasterHeight => BitRange(431, 416); public readonly int CtaRasterHeight => BitRange(431, 416);
public int CtaRasterDepth => BitRange(447, 432); public readonly int CtaRasterDepth => BitRange(447, 432);
public int CtaRasterWidthResume => BitRange(479, 448); public readonly int CtaRasterWidthResume => BitRange(479, 448);
public int CtaRasterHeightResume => BitRange(495, 480); public readonly int CtaRasterHeightResume => BitRange(495, 480);
public int CtaRasterDepthResume => BitRange(511, 496); public readonly int CtaRasterDepthResume => BitRange(511, 496);
public int QueueEntriesPerCtaMinusOne => BitRange(518, 512); public readonly int QueueEntriesPerCtaMinusOne => BitRange(518, 512);
public int CoalesceWaitingPeriod => BitRange(529, 522); public readonly int CoalesceWaitingPeriod => BitRange(529, 522);
public int SharedMemorySize => BitRange(561, 544); public readonly int SharedMemorySize => BitRange(561, 544);
public int QmdReservedG => BitRange(575, 562); public readonly int QmdReservedG => BitRange(575, 562);
public int QmdVersion => BitRange(579, 576); public readonly int QmdVersion => BitRange(579, 576);
public int QmdMajorVersion => BitRange(583, 580); public readonly int QmdMajorVersion => BitRange(583, 580);
public int QmdReservedH => BitRange(591, 584); public readonly int QmdReservedH => BitRange(591, 584);
public int CtaThreadDimension0 => BitRange(607, 592); public readonly int CtaThreadDimension0 => BitRange(607, 592);
public int CtaThreadDimension1 => BitRange(623, 608); public readonly int CtaThreadDimension1 => BitRange(623, 608);
public int CtaThreadDimension2 => BitRange(639, 624); public readonly int CtaThreadDimension2 => BitRange(639, 624);
public bool ConstantBufferValid(int i) => Bit(640 + i * 1); public readonly bool ConstantBufferValid(int i) => Bit(640 + i * 1);
public int QmdReservedI => BitRange(668, 648); public readonly int QmdReservedI => BitRange(668, 648);
public L1Configuration L1Configuration => (L1Configuration)BitRange(671, 669); public readonly L1Configuration L1Configuration => (L1Configuration)BitRange(671, 669);
public int SmDisableMaskLower => BitRange(703, 672); public readonly int SmDisableMaskLower => BitRange(703, 672);
public int SmDisableMaskUpper => BitRange(735, 704); public readonly int SmDisableMaskUpper => BitRange(735, 704);
public int Release0AddressLower => BitRange(767, 736); public readonly int Release0AddressLower => BitRange(767, 736);
public int Release0AddressUpper => BitRange(775, 768); public readonly int Release0AddressUpper => BitRange(775, 768);
public int QmdReservedJ => BitRange(783, 776); public readonly int QmdReservedJ => BitRange(783, 776);
public ReductionOp Release0ReductionOp => (ReductionOp)BitRange(790, 788); public readonly ReductionOp Release0ReductionOp => (ReductionOp)BitRange(790, 788);
public bool QmdReservedK => Bit(791); public readonly bool QmdReservedK => Bit(791);
public ReductionFormat Release0ReductionFormat => (ReductionFormat)BitRange(793, 792); public readonly ReductionFormat Release0ReductionFormat => (ReductionFormat)BitRange(793, 792);
public bool Release0ReductionEnable => Bit(794); public readonly bool Release0ReductionEnable => Bit(794);
public StructureSize Release0StructureSize => (StructureSize)BitRange(799, 799); public readonly StructureSize Release0StructureSize => (StructureSize)BitRange(799, 799);
public int Release0Payload => BitRange(831, 800); public readonly int Release0Payload => BitRange(831, 800);
public int Release1AddressLower => BitRange(863, 832); public readonly int Release1AddressLower => BitRange(863, 832);
public int Release1AddressUpper => BitRange(871, 864); public readonly int Release1AddressUpper => BitRange(871, 864);
public int QmdReservedL => BitRange(879, 872); public readonly int QmdReservedL => BitRange(879, 872);
public ReductionOp Release1ReductionOp => (ReductionOp)BitRange(886, 884); public readonly ReductionOp Release1ReductionOp => (ReductionOp)BitRange(886, 884);
public bool QmdReservedM => Bit(887); public readonly bool QmdReservedM => Bit(887);
public ReductionFormat Release1ReductionFormat => (ReductionFormat)BitRange(889, 888); public readonly ReductionFormat Release1ReductionFormat => (ReductionFormat)BitRange(889, 888);
public bool Release1ReductionEnable => Bit(890); public readonly bool Release1ReductionEnable => Bit(890);
public StructureSize Release1StructureSize => (StructureSize)BitRange(895, 895); public readonly StructureSize Release1StructureSize => (StructureSize)BitRange(895, 895);
public int Release1Payload => BitRange(927, 896); public readonly int Release1Payload => BitRange(927, 896);
public int ConstantBufferAddrLower(int i) => BitRange(959 + i * 64, 928 + i * 64); public readonly int ConstantBufferAddrLower(int i) => BitRange(959 + i * 64, 928 + i * 64);
public int ConstantBufferAddrUpper(int i) => BitRange(967 + i * 64, 960 + i * 64); public readonly int ConstantBufferAddrUpper(int i) => BitRange(967 + i * 64, 960 + i * 64);
public int ConstantBufferReservedAddr(int i) => BitRange(973 + i * 64, 968 + i * 64); public readonly int ConstantBufferReservedAddr(int i) => BitRange(973 + i * 64, 968 + i * 64);
public bool ConstantBufferInvalidate(int i) => Bit(974 + i * 64); public readonly bool ConstantBufferInvalidate(int i) => Bit(974 + i * 64);
public int ConstantBufferSize(int i) => BitRange(991 + i * 64, 975 + i * 64); public readonly int ConstantBufferSize(int i) => BitRange(991 + i * 64, 975 + i * 64);
public int ShaderLocalMemoryLowSize => BitRange(1463, 1440); public readonly int ShaderLocalMemoryLowSize => BitRange(1463, 1440);
public int QmdReservedN => BitRange(1466, 1464); public readonly int QmdReservedN => BitRange(1466, 1464);
public int BarrierCount => BitRange(1471, 1467); public readonly int BarrierCount => BitRange(1471, 1467);
public int ShaderLocalMemoryHighSize => BitRange(1495, 1472); public readonly int ShaderLocalMemoryHighSize => BitRange(1495, 1472);
public int RegisterCount => BitRange(1503, 1496); public readonly int RegisterCount => BitRange(1503, 1496);
public int ShaderLocalMemoryCrsSize => BitRange(1527, 1504); public readonly int ShaderLocalMemoryCrsSize => BitRange(1527, 1504);
public int SassVersion => BitRange(1535, 1528); public readonly int SassVersion => BitRange(1535, 1528);
public int HwOnlyInnerGet => BitRange(1566, 1536); public readonly int HwOnlyInnerGet => BitRange(1566, 1536);
public bool HwOnlyRequireSchedulingPcas => Bit(1567); public readonly bool HwOnlyRequireSchedulingPcas => Bit(1567);
public int HwOnlyInnerPut => BitRange(1598, 1568); public readonly int HwOnlyInnerPut => BitRange(1598, 1568);
public bool HwOnlyScgType => Bit(1599); public readonly bool HwOnlyScgType => Bit(1599);
public int HwOnlySpanListHeadIndex => BitRange(1629, 1600); public readonly int HwOnlySpanListHeadIndex => BitRange(1629, 1600);
public bool QmdReservedQ => Bit(1630); public readonly bool QmdReservedQ => Bit(1630);
public bool HwOnlySpanListHeadIndexValid => Bit(1631); public readonly bool HwOnlySpanListHeadIndexValid => Bit(1631);
public int HwOnlySkedNextQmdPointer => BitRange(1663, 1632); public readonly int HwOnlySkedNextQmdPointer => BitRange(1663, 1632);
public int QmdSpareE => BitRange(1695, 1664); public readonly int QmdSpareE => BitRange(1695, 1664);
public int QmdSpareF => BitRange(1727, 1696); public readonly int QmdSpareF => BitRange(1727, 1696);
public int QmdSpareG => BitRange(1759, 1728); public readonly int QmdSpareG => BitRange(1759, 1728);
public int QmdSpareH => BitRange(1791, 1760); public readonly int QmdSpareH => BitRange(1791, 1760);
public int QmdSpareI => BitRange(1823, 1792); public readonly int QmdSpareI => BitRange(1823, 1792);
public int QmdSpareJ => BitRange(1855, 1824); public readonly int QmdSpareJ => BitRange(1855, 1824);
public int QmdSpareK => BitRange(1887, 1856); public readonly int QmdSpareK => BitRange(1887, 1856);
public int QmdSpareL => BitRange(1919, 1888); public readonly int QmdSpareL => BitRange(1919, 1888);
public int QmdSpareM => BitRange(1951, 1920); public readonly int QmdSpareM => BitRange(1951, 1920);
public int QmdSpareN => BitRange(1983, 1952); public readonly int QmdSpareN => BitRange(1983, 1952);
public int DebugIdUpper => BitRange(2015, 1984); public readonly int DebugIdUpper => BitRange(2015, 1984);
public int DebugIdLower => BitRange(2047, 2016); public readonly int DebugIdLower => BitRange(2047, 2016);
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool Bit(int bit) private readonly bool Bit(int bit)
{ {
if ((uint)bit >= 64 * 32) if ((uint)bit >= 64 * 32)
{ {
@ -260,7 +260,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private int BitRange(int upper, int lower) private readonly int BitRange(int upper, int lower)
{ {
if ((uint)lower >= 64 * 32) if ((uint)lower >= 64 * 32)
{ {

View file

@ -7,6 +7,6 @@
{ {
False, False,
True, True,
Host Host,
} }
} }

View file

@ -30,13 +30,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
SrcLinear = 1 << 7, SrcLinear = 1 << 7,
DstLinear = 1 << 8, DstLinear = 1 << 8,
MultiLineEnable = 1 << 9, MultiLineEnable = 1 << 9,
RemapEnable = 1 << 10 RemapEnable = 1 << 10,
} }
/// <summary> /// <summary>
/// Texture parameters for copy. /// Texture parameters for copy.
/// </summary> /// </summary>
private struct TextureParams private readonly struct TextureParams
{ {
/// <summary> /// <summary>
/// Copy region X coordinate. /// Copy region X coordinate.
@ -109,7 +109,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
_3dEngine = threedEngine; _3dEngine = threedEngine;
_state = new DeviceState<DmaClassState>(new Dictionary<string, RwCallback> _state = new DeviceState<DmaClassState>(new Dictionary<string, RwCallback>
{ {
{ nameof(DmaClassState.LaunchDma), new RwCallback(LaunchDma, null) } { nameof(DmaClassState.LaunchDma), new RwCallback(LaunchDma, null) },
}); });
} }
@ -345,8 +345,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
// all be rewritten to use pooled arrays, but that gets complicated with packed data and strides // all be rewritten to use pooled arrays, but that gets complicated with packed data and strides
Span<byte> dstSpan = memoryManager.GetSpan(dstGpuVa + (ulong)dstBaseOffset, dstSize).ToArray(); Span<byte> dstSpan = memoryManager.GetSpan(dstGpuVa + (ulong)dstBaseOffset, dstSize).ToArray();
TextureParams srcParams = new TextureParams(srcRegionX, srcRegionY, srcBaseOffset, srcBpp, srcLinear, srcCalculator); TextureParams srcParams = new(srcRegionX, srcRegionY, srcBaseOffset, srcBpp, srcLinear, srcCalculator);
TextureParams dstParams = new TextureParams(dstRegionX, dstRegionY, dstBaseOffset, dstBpp, dstLinear, dstCalculator); TextureParams dstParams = new(dstRegionX, dstRegionY, dstBaseOffset, dstBpp, dstLinear, dstCalculator);
// If remapping is enabled, we always copy the components directly, in order. // If remapping is enabled, we always copy the components directly, in order.
// If it's enabled, but the mapping is just XYZW, we also copy them in order. // If it's enabled, but the mapping is just XYZW, we also copy them in order.
@ -363,13 +363,26 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
switch (srcBpp) switch (srcBpp)
{ {
case 1: Copy<byte>(dstSpan, srcSpan, dstParams, srcParams); break; case 1:
case 2: Copy<ushort>(dstSpan, srcSpan, dstParams, srcParams); break; Copy<byte>(dstSpan, srcSpan, dstParams, srcParams);
case 4: Copy<uint>(dstSpan, srcSpan, dstParams, srcParams); break; break;
case 8: Copy<ulong>(dstSpan, srcSpan, dstParams, srcParams); break; case 2:
case 12: Copy<Bpp12Pixel>(dstSpan, srcSpan, dstParams, srcParams); break; Copy<ushort>(dstSpan, srcSpan, dstParams, srcParams);
case 16: Copy<Vector128<byte>>(dstSpan, srcSpan, dstParams, srcParams); break; break;
default: throw new NotSupportedException($"Unable to copy ${srcBpp} bpp pixel format."); case 4:
Copy<uint>(dstSpan, srcSpan, dstParams, srcParams);
break;
case 8:
Copy<ulong>(dstSpan, srcSpan, dstParams, srcParams);
break;
case 12:
Copy<Bpp12Pixel>(dstSpan, srcSpan, dstParams, srcParams);
break;
case 16:
Copy<Vector128<byte>>(dstSpan, srcSpan, dstParams, srcParams);
break;
default:
throw new NotSupportedException($"Unable to copy ${srcBpp} bpp pixel format.");
} }
} }
else else
@ -378,11 +391,20 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
switch (componentSize) switch (componentSize)
{ {
case 1: CopyShuffle<byte>(dstSpan, srcSpan, dstParams, srcParams); break; case 1:
case 2: CopyShuffle<ushort>(dstSpan, srcSpan, dstParams, srcParams); break; CopyShuffle<byte>(dstSpan, srcSpan, dstParams, srcParams);
case 3: CopyShuffle<UInt24>(dstSpan, srcSpan, dstParams, srcParams); break; break;
case 4: CopyShuffle<uint>(dstSpan, srcSpan, dstParams, srcParams); break; case 2:
default: throw new NotSupportedException($"Unable to copy ${componentSize} component size."); CopyShuffle<ushort>(dstSpan, srcSpan, dstParams, srcParams);
break;
case 3:
CopyShuffle<UInt24>(dstSpan, srcSpan, dstParams, srcParams);
break;
case 4:
CopyShuffle<uint>(dstSpan, srcSpan, dstParams, srcParams);
break;
default:
throw new NotSupportedException($"Unable to copy ${componentSize} component size.");
} }
} }
@ -526,28 +548,28 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
0 => _state.State.SetRemapComponentsDstX, 0 => _state.State.SetRemapComponentsDstX,
1 => _state.State.SetRemapComponentsDstY, 1 => _state.State.SetRemapComponentsDstY,
2 => _state.State.SetRemapComponentsDstZ, 2 => _state.State.SetRemapComponentsDstZ,
_ => _state.State.SetRemapComponentsDstW _ => _state.State.SetRemapComponentsDstW,
}; };
switch (componentsDst) switch (componentsDst)
{ {
case SetRemapComponentsDst.SrcX: case SetRemapComponentsDst.SrcX:
Copy<T>(dstSpan.Slice(Unsafe.SizeOf<T>() * i), srcSpan, dst, src); Copy<T>(dstSpan[(Unsafe.SizeOf<T>() * i)..], srcSpan, dst, src);
break; break;
case SetRemapComponentsDst.SrcY: case SetRemapComponentsDst.SrcY:
Copy<T>(dstSpan.Slice(Unsafe.SizeOf<T>() * i), srcSpan.Slice(Unsafe.SizeOf<T>()), dst, src); Copy<T>(dstSpan[(Unsafe.SizeOf<T>() * i)..], srcSpan[Unsafe.SizeOf<T>()..], dst, src);
break; break;
case SetRemapComponentsDst.SrcZ: case SetRemapComponentsDst.SrcZ:
Copy<T>(dstSpan.Slice(Unsafe.SizeOf<T>() * i), srcSpan.Slice(Unsafe.SizeOf<T>() * 2), dst, src); Copy<T>(dstSpan[(Unsafe.SizeOf<T>() * i)..], srcSpan[(Unsafe.SizeOf<T>() * 2)..], dst, src);
break; break;
case SetRemapComponentsDst.SrcW: case SetRemapComponentsDst.SrcW:
Copy<T>(dstSpan.Slice(Unsafe.SizeOf<T>() * i), srcSpan.Slice(Unsafe.SizeOf<T>() * 3), dst, src); Copy<T>(dstSpan[(Unsafe.SizeOf<T>() * i)..], srcSpan[(Unsafe.SizeOf<T>() * 3)..], dst, src);
break; break;
case SetRemapComponentsDst.ConstA: case SetRemapComponentsDst.ConstA:
Fill<T>(dstSpan.Slice(Unsafe.SizeOf<T>() * i), dst, Unsafe.As<uint, T>(ref _state.State.SetRemapConstA)); Fill<T>(dstSpan[(Unsafe.SizeOf<T>() * i)..], dst, Unsafe.As<uint, T>(ref _state.State.SetRemapConstA));
break; break;
case SetRemapComponentsDst.ConstB: case SetRemapComponentsDst.ConstB:
Fill<T>(dstSpan.Slice(Unsafe.SizeOf<T>() * i), dst, Unsafe.As<uint, T>(ref _state.State.SetRemapConstB)); Fill<T>(dstSpan[(Unsafe.SizeOf<T>() * i)..], dst, Unsafe.As<uint, T>(ref _state.State.SetRemapConstB));
break; break;
} }
} }

View file

@ -179,49 +179,49 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
/// </summary> /// </summary>
unsafe struct DmaClassState unsafe struct DmaClassState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public fixed uint Reserved00[64]; public fixed uint Reserved00[64];
public uint Nop; public uint Nop;
public fixed uint Reserved104[15]; public fixed uint Reserved104[15];
public uint PmTrigger; public uint PmTrigger;
public fixed uint Reserved144[63]; public fixed uint Reserved144[63];
public uint SetSemaphoreA; public uint SetSemaphoreA;
public int SetSemaphoreAUpper => (int)(SetSemaphoreA & 0xFF); public readonly int SetSemaphoreAUpper => (int)(SetSemaphoreA & 0xFF);
public uint SetSemaphoreB; public uint SetSemaphoreB;
public uint SetSemaphorePayload; public uint SetSemaphorePayload;
public fixed uint Reserved24C[2]; public fixed uint Reserved24C[2];
public uint SetRenderEnableA; public uint SetRenderEnableA;
public int SetRenderEnableAUpper => (int)(SetRenderEnableA & 0xFF); public readonly int SetRenderEnableAUpper => (int)(SetRenderEnableA & 0xFF);
public uint SetRenderEnableB; public uint SetRenderEnableB;
public uint SetRenderEnableC; public uint SetRenderEnableC;
public int SetRenderEnableCMode => (int)(SetRenderEnableC & 0x7); public readonly int SetRenderEnableCMode => (int)(SetRenderEnableC & 0x7);
public uint SetSrcPhysMode; public uint SetSrcPhysMode;
public SetPhysModeTarget SetSrcPhysModeTarget => (SetPhysModeTarget)(SetSrcPhysMode & 0x3); public readonly SetPhysModeTarget SetSrcPhysModeTarget => (SetPhysModeTarget)(SetSrcPhysMode & 0x3);
public uint SetDstPhysMode; public uint SetDstPhysMode;
public SetPhysModeTarget SetDstPhysModeTarget => (SetPhysModeTarget)(SetDstPhysMode & 0x3); public readonly SetPhysModeTarget SetDstPhysModeTarget => (SetPhysModeTarget)(SetDstPhysMode & 0x3);
public fixed uint Reserved268[38]; public fixed uint Reserved268[38];
public uint LaunchDma; public uint LaunchDma;
public LaunchDmaDataTransferType LaunchDmaDataTransferType => (LaunchDmaDataTransferType)(LaunchDma & 0x3); public readonly LaunchDmaDataTransferType LaunchDmaDataTransferType => (LaunchDmaDataTransferType)(LaunchDma & 0x3);
public bool LaunchDmaFlushEnable => (LaunchDma & 0x4) != 0; public readonly bool LaunchDmaFlushEnable => (LaunchDma & 0x4) != 0;
public LaunchDmaSemaphoreType LaunchDmaSemaphoreType => (LaunchDmaSemaphoreType)((LaunchDma >> 3) & 0x3); public readonly LaunchDmaSemaphoreType LaunchDmaSemaphoreType => (LaunchDmaSemaphoreType)((LaunchDma >> 3) & 0x3);
public LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 5) & 0x3); public readonly LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 5) & 0x3);
public LaunchDmaMemoryLayout LaunchDmaSrcMemoryLayout => (LaunchDmaMemoryLayout)((LaunchDma >> 7) & 0x1); public readonly LaunchDmaMemoryLayout LaunchDmaSrcMemoryLayout => (LaunchDmaMemoryLayout)((LaunchDma >> 7) & 0x1);
public LaunchDmaMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaMemoryLayout)((LaunchDma >> 8) & 0x1); public readonly LaunchDmaMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaMemoryLayout)((LaunchDma >> 8) & 0x1);
public bool LaunchDmaMultiLineEnable => (LaunchDma & 0x200) != 0; public readonly bool LaunchDmaMultiLineEnable => (LaunchDma & 0x200) != 0;
public bool LaunchDmaRemapEnable => (LaunchDma & 0x400) != 0; public readonly bool LaunchDmaRemapEnable => (LaunchDma & 0x400) != 0;
public bool LaunchDmaForceRmwdisable => (LaunchDma & 0x800) != 0; public readonly bool LaunchDmaForceRmwdisable => (LaunchDma & 0x800) != 0;
public LaunchDmaType LaunchDmaSrcType => (LaunchDmaType)((LaunchDma >> 12) & 0x1); public readonly LaunchDmaType LaunchDmaSrcType => (LaunchDmaType)((LaunchDma >> 12) & 0x1);
public LaunchDmaType LaunchDmaDstType => (LaunchDmaType)((LaunchDma >> 13) & 0x1); public readonly LaunchDmaType LaunchDmaDstType => (LaunchDmaType)((LaunchDma >> 13) & 0x1);
public LaunchDmaSemaphoreReduction LaunchDmaSemaphoreReduction => (LaunchDmaSemaphoreReduction)((LaunchDma >> 14) & 0xF); public readonly LaunchDmaSemaphoreReduction LaunchDmaSemaphoreReduction => (LaunchDmaSemaphoreReduction)((LaunchDma >> 14) & 0xF);
public LaunchDmaSemaphoreReductionSign LaunchDmaSemaphoreReductionSign => (LaunchDmaSemaphoreReductionSign)((LaunchDma >> 18) & 0x1); public readonly LaunchDmaSemaphoreReductionSign LaunchDmaSemaphoreReductionSign => (LaunchDmaSemaphoreReductionSign)((LaunchDma >> 18) & 0x1);
public bool LaunchDmaSemaphoreReductionEnable => (LaunchDma & 0x80000) != 0; public readonly bool LaunchDmaSemaphoreReductionEnable => (LaunchDma & 0x80000) != 0;
public LaunchDmaBypassL2 LaunchDmaBypassL2 => (LaunchDmaBypassL2)((LaunchDma >> 20) & 0x1); public readonly LaunchDmaBypassL2 LaunchDmaBypassL2 => (LaunchDmaBypassL2)((LaunchDma >> 20) & 0x1);
public fixed uint Reserved304[63]; public fixed uint Reserved304[63];
public uint OffsetInUpper; public uint OffsetInUpper;
public int OffsetInUpperUpper => (int)(OffsetInUpper & 0xFF); public readonly int OffsetInUpperUpper => (int)(OffsetInUpper & 0xFF);
public uint OffsetInLower; public uint OffsetInLower;
public uint OffsetOutUpper; public uint OffsetOutUpper;
public int OffsetOutUpperUpper => (int)(OffsetOutUpper & 0xFF); public readonly int OffsetOutUpperUpper => (int)(OffsetOutUpper & 0xFF);
public uint OffsetOutLower; public uint OffsetOutLower;
public uint PitchIn; public uint PitchIn;
public uint PitchOut; public uint PitchOut;
@ -231,38 +231,38 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
public uint SetRemapConstA; public uint SetRemapConstA;
public uint SetRemapConstB; public uint SetRemapConstB;
public uint SetRemapComponents; public uint SetRemapComponents;
public SetRemapComponentsDst SetRemapComponentsDstX => (SetRemapComponentsDst)(SetRemapComponents & 0x7); public readonly SetRemapComponentsDst SetRemapComponentsDstX => (SetRemapComponentsDst)(SetRemapComponents & 0x7);
public SetRemapComponentsDst SetRemapComponentsDstY => (SetRemapComponentsDst)((SetRemapComponents >> 4) & 0x7); public readonly SetRemapComponentsDst SetRemapComponentsDstY => (SetRemapComponentsDst)((SetRemapComponents >> 4) & 0x7);
public SetRemapComponentsDst SetRemapComponentsDstZ => (SetRemapComponentsDst)((SetRemapComponents >> 8) & 0x7); public readonly SetRemapComponentsDst SetRemapComponentsDstZ => (SetRemapComponentsDst)((SetRemapComponents >> 8) & 0x7);
public SetRemapComponentsDst SetRemapComponentsDstW => (SetRemapComponentsDst)((SetRemapComponents >> 12) & 0x7); public readonly SetRemapComponentsDst SetRemapComponentsDstW => (SetRemapComponentsDst)((SetRemapComponents >> 12) & 0x7);
public SetRemapComponentsComponentSize SetRemapComponentsComponentSize => (SetRemapComponentsComponentSize)((SetRemapComponents >> 16) & 0x3); public readonly SetRemapComponentsComponentSize SetRemapComponentsComponentSize => (SetRemapComponentsComponentSize)((SetRemapComponents >> 16) & 0x3);
public SetRemapComponentsNumComponents SetRemapComponentsNumSrcComponents => (SetRemapComponentsNumComponents)((SetRemapComponents >> 20) & 0x3); public readonly SetRemapComponentsNumComponents SetRemapComponentsNumSrcComponents => (SetRemapComponentsNumComponents)((SetRemapComponents >> 20) & 0x3);
public SetRemapComponentsNumComponents SetRemapComponentsNumDstComponents => (SetRemapComponentsNumComponents)((SetRemapComponents >> 24) & 0x3); public readonly SetRemapComponentsNumComponents SetRemapComponentsNumDstComponents => (SetRemapComponentsNumComponents)((SetRemapComponents >> 24) & 0x3);
public uint SetDstBlockSize; public uint SetDstBlockSize;
public SetBlockSizeWidth SetDstBlockSizeWidth => (SetBlockSizeWidth)(SetDstBlockSize & 0xF); public readonly SetBlockSizeWidth SetDstBlockSizeWidth => (SetBlockSizeWidth)(SetDstBlockSize & 0xF);
public SetBlockSizeHeight SetDstBlockSizeHeight => (SetBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF); public readonly SetBlockSizeHeight SetDstBlockSizeHeight => (SetBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
public SetBlockSizeDepth SetDstBlockSizeDepth => (SetBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF); public readonly SetBlockSizeDepth SetDstBlockSizeDepth => (SetBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
public SetBlockSizeGobHeight SetDstBlockSizeGobHeight => (SetBlockSizeGobHeight)((SetDstBlockSize >> 12) & 0xF); public readonly SetBlockSizeGobHeight SetDstBlockSizeGobHeight => (SetBlockSizeGobHeight)((SetDstBlockSize >> 12) & 0xF);
public uint SetDstWidth; public uint SetDstWidth;
public uint SetDstHeight; public uint SetDstHeight;
public uint SetDstDepth; public uint SetDstDepth;
public uint SetDstLayer; public uint SetDstLayer;
public uint SetDstOrigin; public uint SetDstOrigin;
public int SetDstOriginX => (int)(SetDstOrigin & 0xFFFF); public readonly int SetDstOriginX => (int)(SetDstOrigin & 0xFFFF);
public int SetDstOriginY => (int)((SetDstOrigin >> 16) & 0xFFFF); public readonly int SetDstOriginY => (int)((SetDstOrigin >> 16) & 0xFFFF);
public uint Reserved724; public uint Reserved724;
public uint SetSrcBlockSize; public uint SetSrcBlockSize;
public SetBlockSizeWidth SetSrcBlockSizeWidth => (SetBlockSizeWidth)(SetSrcBlockSize & 0xF); public readonly SetBlockSizeWidth SetSrcBlockSizeWidth => (SetBlockSizeWidth)(SetSrcBlockSize & 0xF);
public SetBlockSizeHeight SetSrcBlockSizeHeight => (SetBlockSizeHeight)((SetSrcBlockSize >> 4) & 0xF); public readonly SetBlockSizeHeight SetSrcBlockSizeHeight => (SetBlockSizeHeight)((SetSrcBlockSize >> 4) & 0xF);
public SetBlockSizeDepth SetSrcBlockSizeDepth => (SetBlockSizeDepth)((SetSrcBlockSize >> 8) & 0xF); public readonly SetBlockSizeDepth SetSrcBlockSizeDepth => (SetBlockSizeDepth)((SetSrcBlockSize >> 8) & 0xF);
public SetBlockSizeGobHeight SetSrcBlockSizeGobHeight => (SetBlockSizeGobHeight)((SetSrcBlockSize >> 12) & 0xF); public readonly SetBlockSizeGobHeight SetSrcBlockSizeGobHeight => (SetBlockSizeGobHeight)((SetSrcBlockSize >> 12) & 0xF);
public uint SetSrcWidth; public uint SetSrcWidth;
public uint SetSrcHeight; public uint SetSrcHeight;
public uint SetSrcDepth; public uint SetSrcDepth;
public uint SetSrcLayer; public uint SetSrcLayer;
public uint SetSrcOrigin; public uint SetSrcOrigin;
public int SetSrcOriginX => (int)(SetSrcOrigin & 0xFFFF); public readonly int SetSrcOriginX => (int)(SetSrcOrigin & 0xFFFF);
public int SetSrcOriginY => (int)((SetSrcOrigin >> 16) & 0xFFFF); public readonly int SetSrcOriginY => (int)((SetSrcOrigin >> 16) & 0xFFFF);
public fixed uint Reserved740[629]; public fixed uint Reserved740[629];
public uint PmTriggerEnd; public uint PmTriggerEnd;
public fixed uint Reserved1118[2490]; public fixed uint Reserved1118[2490];

View file

@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
/// </summary> /// </summary>
struct DmaTexture struct DmaTexture
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public MemoryLayout MemoryLayout; public MemoryLayout MemoryLayout;
public int Width; public int Width;
public int Height; public int Height;

View file

@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
Grp0SetSubDevMask = 1, Grp0SetSubDevMask = 1,
Grp0StoreSubDevMask = 2, Grp0StoreSubDevMask = 2,
Grp0UseSubDevMask = 3, Grp0UseSubDevMask = 3,
Grp2NonIncMethod = 0 Grp2NonIncMethod = Grp0IncMethod,
} }
enum SecOp enum SecOp
@ -20,22 +20,22 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
ImmdDataMethod = 4, ImmdDataMethod = 4,
OneInc = 5, OneInc = 5,
Reserved6 = 6, Reserved6 = 6,
EndPbSegment = 7 EndPbSegment = 7,
} }
struct CompressedMethod struct CompressedMethod
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint Method; public uint Method;
#pragma warning restore CS0649 #pragma warning restore CS0649
public int MethodAddressOld => (int)((Method >> 2) & 0x7FF); public readonly int MethodAddressOld => (int)((Method >> 2) & 0x7FF);
public int MethodAddress => (int)(Method & 0xFFF); public readonly int MethodAddress => (int)(Method & 0xFFF);
public int SubdeviceMask => (int)((Method >> 4) & 0xFFF); public readonly int SubdeviceMask => (int)((Method >> 4) & 0xFFF);
public int MethodSubchannel => (int)((Method >> 13) & 0x7); public readonly int MethodSubchannel => (int)((Method >> 13) & 0x7);
public TertOp TertOp => (TertOp)((Method >> 16) & 0x3); public readonly TertOp TertOp => (TertOp)((Method >> 16) & 0x3);
public int MethodCountOld => (int)((Method >> 18) & 0x7FF); public readonly int MethodCountOld => (int)((Method >> 18) & 0x7FF);
public int MethodCount => (int)((Method >> 16) & 0x1FFF); public readonly int MethodCount => (int)((Method >> 16) & 0x1FFF);
public int ImmdData => (int)((Method >> 16) & 0x1FFF); public readonly int ImmdData => (int)((Method >> 16) & 0x1FFF);
public SecOp SecOp => (SecOp)((Method >> 29) & 0x7); public readonly SecOp SecOp => (SecOp)((Method >> 29) & 0x7);
} }
} }

View file

@ -36,20 +36,20 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
struct GPEntry struct GPEntry
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint Entry0; public uint Entry0;
#pragma warning restore CS0649 #pragma warning restore CS0649
public Entry0Fetch Entry0Fetch => (Entry0Fetch)(Entry0 & 0x1); public readonly Entry0Fetch Entry0Fetch => (Entry0Fetch)(Entry0 & 0x1);
public int Entry0Get => (int)((Entry0 >> 2) & 0x3FFFFFFF); public readonly int Entry0Get => (int)((Entry0 >> 2) & 0x3FFFFFFF);
public int Entry0Operand => (int)(Entry0); public readonly int Entry0Operand => (int)(Entry0);
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint Entry1; public uint Entry1;
#pragma warning restore CS0649 #pragma warning restore CS0649
public int Entry1GetHi => (int)(Entry1 & 0xFF); public readonly int Entry1GetHi => (int)(Entry1 & 0xFF);
public Entry1Priv Entry1Priv => (Entry1Priv)((Entry1 >> 8) & 0x1); public readonly Entry1Priv Entry1Priv => (Entry1Priv)((Entry1 >> 8) & 0x1);
public Entry1Level Entry1Level => (Entry1Level)((Entry1 >> 9) & 0x1); public readonly Entry1Level Entry1Level => (Entry1Level)((Entry1 >> 9) & 0x1);
public int Entry1Length => (int)((Entry1 >> 10) & 0x1FFFFF); public readonly int Entry1Length => (int)((Entry1 >> 10) & 0x1FFFFF);
public Entry1Sync Entry1Sync => (Entry1Sync)((Entry1 >> 31) & 0x1); public readonly Entry1Sync Entry1Sync => (Entry1Sync)((Entry1 >> 31) & 0x1);
public Entry1Opcode Entry1Opcode => (Entry1Opcode)(Entry1 & 0xFF); public readonly Entry1Opcode Entry1Opcode => (Entry1Opcode)(Entry1 & 0xFF);
} }
} }

View file

@ -16,7 +16,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
private readonly GPFifoProcessor _parent; private readonly GPFifoProcessor _parent;
private readonly DeviceState<GPFifoClassState> _state; private readonly DeviceState<GPFifoClassState> _state;
private int _previousSubChannel;
private bool _createSyncPending; private bool _createSyncPending;
private const int MacrosCount = 0x80; private const int MacrosCount = 0x80;
@ -45,7 +44,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
{ nameof(GPFifoClassState.SetReference), new RwCallback(SetReference, null) }, { nameof(GPFifoClassState.SetReference), new RwCallback(SetReference, null) },
{ nameof(GPFifoClassState.LoadMmeInstructionRam), new RwCallback(LoadMmeInstructionRam, null) }, { nameof(GPFifoClassState.LoadMmeInstructionRam), new RwCallback(LoadMmeInstructionRam, null) },
{ nameof(GPFifoClassState.LoadMmeStartAddressRam), new RwCallback(LoadMmeStartAddressRam, null) }, { nameof(GPFifoClassState.LoadMmeStartAddressRam), new RwCallback(LoadMmeStartAddressRam, null) },
{ nameof(GPFifoClassState.SetMmeShadowRamControl), new RwCallback(SetMmeShadowRamControl, null) } { nameof(GPFifoClassState.SetMmeShadowRamControl), new RwCallback(SetMmeShadowRamControl, null) },
}); });
_macros = new Macro[MacrosCount]; _macros = new Macro[MacrosCount];

View file

@ -13,7 +13,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
Release = 2, Release = 2,
AcqGeq = 4, AcqGeq = 4,
AcqAnd = 8, AcqAnd = 8,
Reduction = 16 Reduction = 16,
} }
/// <summary> /// <summary>
@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum SemaphoredAcquireSwitch enum SemaphoredAcquireSwitch
{ {
Disabled = 0, Disabled = 0,
Enabled = 1 Enabled = 1,
} }
/// <summary> /// <summary>
@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum SemaphoredReleaseWfi enum SemaphoredReleaseWfi
{ {
En = 0, En = 0,
Dis = 1 Dis = 1,
} }
/// <summary> /// <summary>
@ -40,7 +40,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum SemaphoredReleaseSize enum SemaphoredReleaseSize
{ {
SixteenBytes = 0, SixteenBytes = 0,
FourBytes = 1 FourBytes = 1,
} }
/// <summary> /// <summary>
@ -55,7 +55,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
Or = 4, Or = 4,
Add = 5, Add = 5,
Inc = 6, Inc = 6,
Dec = 7 Dec = 7,
} }
/// <summary> /// <summary>
@ -64,7 +64,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum SemaphoredFormat enum SemaphoredFormat
{ {
Signed = 0, Signed = 0,
Unsigned = 1 Unsigned = 1,
} }
/// <summary> /// <summary>
@ -73,7 +73,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum MemOpCTlbInvalidatePdb enum MemOpCTlbInvalidatePdb
{ {
One = 0, One = 0,
All = 1 All = 1,
} }
/// <summary> /// <summary>
@ -82,7 +82,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum MemOpCTlbInvalidateGpc enum MemOpCTlbInvalidateGpc
{ {
Enable = 0, Enable = 0,
Disable = 1 Disable = 1,
} }
/// <summary> /// <summary>
@ -92,7 +92,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
{ {
VidMem = 0, VidMem = 0,
SysMemCoherent = 2, SysMemCoherent = 2,
SysMemNoncoherent = 3 SysMemNoncoherent = 3,
} }
/// <summary> /// <summary>
@ -105,7 +105,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
L2PeermemInvalidate = 13, L2PeermemInvalidate = 13,
L2SysmemInvalidate = 14, L2SysmemInvalidate = 14,
L2CleanComptags = 15, L2CleanComptags = 15,
L2FlushDirty = 16 L2FlushDirty = 16,
} }
/// <summary> /// <summary>
@ -114,7 +114,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum SyncpointbOperation enum SyncpointbOperation
{ {
Wait = 0, Wait = 0,
Incr = 1 Incr = 1,
} }
/// <summary> /// <summary>
@ -123,7 +123,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum SyncpointbWaitSwitch enum SyncpointbWaitSwitch
{ {
Dis = 0, Dis = 0,
En = 1 En = 1,
} }
/// <summary> /// <summary>
@ -132,7 +132,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
enum WfiScope enum WfiScope
{ {
CurrentScgType = 0, CurrentScgType = 0,
All = 1 All = 1,
} }
/// <summary> /// <summary>
@ -143,7 +143,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
Nop = 0, Nop = 0,
PbdmaTimeslice = 1, PbdmaTimeslice = 1,
RunlistTimeslice = 2, RunlistTimeslice = 2,
Tsg = 3 Tsg = 3,
} }
/// <summary> /// <summary>
@ -151,44 +151,44 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
/// </summary> /// </summary>
struct GPFifoClassState struct GPFifoClassState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint SetObject; public uint SetObject;
public int SetObjectNvclass => (int)(SetObject & 0xFFFF); public readonly int SetObjectNvclass => (int)(SetObject & 0xFFFF);
public int SetObjectEngine => (int)((SetObject >> 16) & 0x1F); public readonly int SetObjectEngine => (int)((SetObject >> 16) & 0x1F);
public uint Illegal; public uint Illegal;
public int IllegalHandle => (int)(Illegal); public readonly int IllegalHandle => (int)(Illegal);
public uint Nop; public uint Nop;
public int NopHandle => (int)(Nop); public readonly int NopHandle => (int)(Nop);
public uint Reserved0C; public uint Reserved0C;
public uint Semaphorea; public uint Semaphorea;
public int SemaphoreaOffsetUpper => (int)(Semaphorea & 0xFF); public readonly int SemaphoreaOffsetUpper => (int)(Semaphorea & 0xFF);
public uint Semaphoreb; public uint Semaphoreb;
public int SemaphorebOffsetLower => (int)((Semaphoreb >> 2) & 0x3FFFFFFF); public readonly int SemaphorebOffsetLower => (int)((Semaphoreb >> 2) & 0x3FFFFFFF);
public uint Semaphorec; public uint Semaphorec;
public int SemaphorecPayload => (int)(Semaphorec); public readonly int SemaphorecPayload => (int)(Semaphorec);
public uint Semaphored; public uint Semaphored;
public SemaphoredOperation SemaphoredOperation => (SemaphoredOperation)(Semaphored & 0x1F); public readonly SemaphoredOperation SemaphoredOperation => (SemaphoredOperation)(Semaphored & 0x1F);
public SemaphoredAcquireSwitch SemaphoredAcquireSwitch => (SemaphoredAcquireSwitch)((Semaphored >> 12) & 0x1); public readonly SemaphoredAcquireSwitch SemaphoredAcquireSwitch => (SemaphoredAcquireSwitch)((Semaphored >> 12) & 0x1);
public SemaphoredReleaseWfi SemaphoredReleaseWfi => (SemaphoredReleaseWfi)((Semaphored >> 20) & 0x1); public readonly SemaphoredReleaseWfi SemaphoredReleaseWfi => (SemaphoredReleaseWfi)((Semaphored >> 20) & 0x1);
public SemaphoredReleaseSize SemaphoredReleaseSize => (SemaphoredReleaseSize)((Semaphored >> 24) & 0x1); public readonly SemaphoredReleaseSize SemaphoredReleaseSize => (SemaphoredReleaseSize)((Semaphored >> 24) & 0x1);
public SemaphoredReduction SemaphoredReduction => (SemaphoredReduction)((Semaphored >> 27) & 0xF); public readonly SemaphoredReduction SemaphoredReduction => (SemaphoredReduction)((Semaphored >> 27) & 0xF);
public SemaphoredFormat SemaphoredFormat => (SemaphoredFormat)((Semaphored >> 31) & 0x1); public readonly SemaphoredFormat SemaphoredFormat => (SemaphoredFormat)((Semaphored >> 31) & 0x1);
public uint NonStallInterrupt; public uint NonStallInterrupt;
public int NonStallInterruptHandle => (int)(NonStallInterrupt); public readonly int NonStallInterruptHandle => (int)(NonStallInterrupt);
public uint FbFlush; public uint FbFlush;
public int FbFlushHandle => (int)(FbFlush); public readonly int FbFlushHandle => (int)(FbFlush);
public uint Reserved28; public uint Reserved28;
public uint Reserved2C; public uint Reserved2C;
public uint MemOpC; public uint MemOpC;
public int MemOpCOperandLow => (int)((MemOpC >> 2) & 0x3FFFFFFF); public readonly int MemOpCOperandLow => (int)((MemOpC >> 2) & 0x3FFFFFFF);
public MemOpCTlbInvalidatePdb MemOpCTlbInvalidatePdb => (MemOpCTlbInvalidatePdb)(MemOpC & 0x1); public readonly MemOpCTlbInvalidatePdb MemOpCTlbInvalidatePdb => (MemOpCTlbInvalidatePdb)(MemOpC & 0x1);
public MemOpCTlbInvalidateGpc MemOpCTlbInvalidateGpc => (MemOpCTlbInvalidateGpc)((MemOpC >> 1) & 0x1); public readonly MemOpCTlbInvalidateGpc MemOpCTlbInvalidateGpc => (MemOpCTlbInvalidateGpc)((MemOpC >> 1) & 0x1);
public MemOpCTlbInvalidateTarget MemOpCTlbInvalidateTarget => (MemOpCTlbInvalidateTarget)((MemOpC >> 10) & 0x3); public readonly MemOpCTlbInvalidateTarget MemOpCTlbInvalidateTarget => (MemOpCTlbInvalidateTarget)((MemOpC >> 10) & 0x3);
public int MemOpCTlbInvalidateAddrLo => (int)((MemOpC >> 12) & 0xFFFFF); public readonly int MemOpCTlbInvalidateAddrLo => (int)((MemOpC >> 12) & 0xFFFFF);
public uint MemOpD; public uint MemOpD;
public int MemOpDOperandHigh => (int)(MemOpD & 0xFF); public readonly int MemOpDOperandHigh => (int)(MemOpD & 0xFF);
public MemOpDOperation MemOpDOperation => (MemOpDOperation)((MemOpD >> 27) & 0x1F); public readonly MemOpDOperation MemOpDOperation => (MemOpDOperation)((MemOpD >> 27) & 0x1F);
public int MemOpDTlbInvalidateAddrHi => (int)(MemOpD & 0xFF); public readonly int MemOpDTlbInvalidateAddrHi => (int)(MemOpD & 0xFF);
public uint Reserved38; public uint Reserved38;
public uint Reserved3C; public uint Reserved3C;
public uint Reserved40; public uint Reserved40;
@ -196,7 +196,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
public uint Reserved48; public uint Reserved48;
public uint Reserved4C; public uint Reserved4C;
public uint SetReference; public uint SetReference;
public int SetReferenceCount => (int)(SetReference); public readonly int SetReferenceCount => (int)(SetReference);
public uint Reserved54; public uint Reserved54;
public uint Reserved58; public uint Reserved58;
public uint Reserved5C; public uint Reserved5C;
@ -205,17 +205,17 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
public uint Reserved68; public uint Reserved68;
public uint Reserved6C; public uint Reserved6C;
public uint Syncpointa; public uint Syncpointa;
public int SyncpointaPayload => (int)(Syncpointa); public readonly int SyncpointaPayload => (int)(Syncpointa);
public uint Syncpointb; public uint Syncpointb;
public SyncpointbOperation SyncpointbOperation => (SyncpointbOperation)(Syncpointb & 0x1); public readonly SyncpointbOperation SyncpointbOperation => (SyncpointbOperation)(Syncpointb & 0x1);
public SyncpointbWaitSwitch SyncpointbWaitSwitch => (SyncpointbWaitSwitch)((Syncpointb >> 4) & 0x1); public readonly SyncpointbWaitSwitch SyncpointbWaitSwitch => (SyncpointbWaitSwitch)((Syncpointb >> 4) & 0x1);
public int SyncpointbSyncptIndex => (int)((Syncpointb >> 8) & 0xFFF); public readonly int SyncpointbSyncptIndex => (int)((Syncpointb >> 8) & 0xFFF);
public uint Wfi; public uint Wfi;
public WfiScope WfiScope => (WfiScope)(Wfi & 0x1); public readonly WfiScope WfiScope => (WfiScope)(Wfi & 0x1);
public uint CrcCheck; public uint CrcCheck;
public int CrcCheckValue => (int)(CrcCheck); public readonly int CrcCheckValue => (int)(CrcCheck);
public uint Yield; public uint Yield;
public YieldOp YieldOp => (YieldOp)(Yield & 0x3); public readonly YieldOp YieldOp => (YieldOp)(Yield & 0x3);
// TODO: Eventually move this to per-engine state. // TODO: Eventually move this to per-engine state.
public Array31<uint> Reserved84; public Array31<uint> Reserved84;
public uint NoOperation; public uint NoOperation;

View file

@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
private enum CommandBufferType private enum CommandBufferType
{ {
Prefetch, Prefetch,
NoPrefetch NoPrefetch,
} }
/// <summary> /// <summary>
@ -57,7 +57,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
/// <param name="memoryManager">The memory manager used to fetch the data</param> /// <param name="memoryManager">The memory manager used to fetch the data</param>
/// <param name="flush">If true, flushes potential GPU written data before reading the command buffer</param> /// <param name="flush">If true, flushes potential GPU written data before reading the command buffer</param>
/// <returns>The fetched data</returns> /// <returns>The fetched data</returns>
private ReadOnlySpan<int> GetWords(MemoryManager memoryManager, bool flush) private readonly ReadOnlySpan<int> GetWords(MemoryManager memoryManager, bool flush)
{ {
return MemoryMarshal.Cast<byte, int>(memoryManager.GetSpan(EntryAddress, (int)EntryCount * 4, flush)); return MemoryMarshal.Cast<byte, int>(memoryManager.GetSpan(EntryAddress, (int)EntryCount * 4, flush));
} }
@ -77,7 +77,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
/// <param name="memoryManager">The memory manager used to fetch the data</param> /// <param name="memoryManager">The memory manager used to fetch the data</param>
/// <param name="flush">If true, flushes potential GPU written data before reading the command buffer</param> /// <param name="flush">If true, flushes potential GPU written data before reading the command buffer</param>
/// <returns>The command buffer words</returns> /// <returns>The command buffer words</returns>
public ReadOnlySpan<int> Fetch(MemoryManager memoryManager, bool flush) public readonly ReadOnlySpan<int> Fetch(MemoryManager memoryManager, bool flush)
{ {
return Words ?? GetWords(memoryManager, flush); return Words ?? GetWords(memoryManager, flush);
} }
@ -85,7 +85,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
private readonly ConcurrentQueue<CommandBuffer> _commandBufferQueue; private readonly ConcurrentQueue<CommandBuffer> _commandBufferQueue;
private CommandBuffer _currentCommandBuffer;
private GPFifoProcessor _prevChannelProcessor; private GPFifoProcessor _prevChannelProcessor;
private readonly bool _ibEnable; private readonly bool _ibEnable;
@ -129,7 +128,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
Type = CommandBufferType.Prefetch, Type = CommandBufferType.Prefetch,
Words = commandBuffer, Words = commandBuffer,
EntryAddress = ulong.MaxValue, EntryAddress = ulong.MaxValue,
EntryCount = (uint)commandBuffer.Length EntryCount = (uint)commandBuffer.Length,
}); });
} }
@ -156,7 +155,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
Type = type, Type = type,
Words = null, Words = null,
EntryAddress = startAddress, EntryAddress = startAddress,
EntryCount = (uint)entry.Entry1Length EntryCount = (uint)entry.Entry1Length,
}; };
} }
@ -217,7 +216,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
flushCommandBuffer = false; flushCommandBuffer = false;
} }
_currentCommandBuffer = entry;
ReadOnlySpan<int> words = entry.Fetch(entry.Processor.MemoryManager, flushCommandBuffer); ReadOnlySpan<int> words = entry.Fetch(entry.Processor.MemoryManager, flushCommandBuffer);
// If we are changing the current channel, // If we are changing the current channel,

View file

@ -243,7 +243,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.GPFifo
{ {
0 => _3dClass, 0 => _3dClass,
3 => _2dClass, 3 => _2dClass,
_ => null _ => null,
}; };
if (state != null) if (state != null)

View file

@ -53,7 +53,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
_state = new DeviceState<InlineToMemoryClassState>(new Dictionary<string, RwCallback> _state = new DeviceState<InlineToMemoryClassState>(new Dictionary<string, RwCallback>
{ {
{ nameof(InlineToMemoryClassState.LaunchDma), new RwCallback(LaunchDma, null) }, { nameof(InlineToMemoryClassState.LaunchDma), new RwCallback(LaunchDma, null) },
{ nameof(InlineToMemoryClassState.LoadInlineData), new RwCallback(LoadInlineData, null) } { nameof(InlineToMemoryClassState.LoadInlineData), new RwCallback(LoadInlineData, null) },
}); });
} }
} }
@ -134,7 +134,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
if (!_finished) if (!_finished)
{ {
int copySize = Math.Min(data.Length, _buffer.Length - _offset); int copySize = Math.Min(data.Length, _buffer.Length - _offset);
data.Slice(0, copySize).CopyTo(new Span<int>(_buffer).Slice(_offset, copySize)); data[..copySize].CopyTo(new Span<int>(_buffer).Slice(_offset, copySize));
_offset += copySize; _offset += copySize;
@ -169,11 +169,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
{ {
var memoryManager = _channel.MemoryManager; var memoryManager = _channel.MemoryManager;
var data = MemoryMarshal.Cast<int, byte>(_buffer).Slice(0, _size); var data = MemoryMarshal.Cast<int, byte>(_buffer)[.._size];
if (_isLinear && _lineCount == 1) if (_isLinear && _lineCount == 1)
{ {
memoryManager.WriteTrackedResource(_dstGpuVa, data.Slice(0, _lineLengthIn)); memoryManager.WriteTrackedResource(_dstGpuVa, data[.._lineLengthIn]);
_context.AdvanceSequence(); _context.AdvanceSequence();
} }
else else

View file

@ -1,5 +1,7 @@
// This file was auto-generated from NVIDIA official Maxwell definitions. // This file was auto-generated from NVIDIA official Maxwell definitions.
using Ryujinx.Common.Memory;
namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
{ {
/// <summary> /// <summary>
@ -111,24 +113,24 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
/// </summary> /// </summary>
unsafe struct InlineToMemoryClassState unsafe struct InlineToMemoryClassState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint SetObject; public uint SetObject;
public int SetObjectClassId => (int)(SetObject & 0xFFFF); public readonly int SetObjectClassId => (int)(SetObject & 0xFFFF);
public int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F); public readonly int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
public fixed uint Reserved04[63]; public fixed uint Reserved04[63];
public uint NoOperation; public uint NoOperation;
public uint SetNotifyA; public uint SetNotifyA;
public int SetNotifyAAddressUpper => (int)(SetNotifyA & 0xFF); public readonly int SetNotifyAAddressUpper => (int)(SetNotifyA & 0xFF);
public uint SetNotifyB; public uint SetNotifyB;
public uint Notify; public uint Notify;
public NotifyType NotifyType => (NotifyType)(Notify); public readonly NotifyType NotifyType => (NotifyType)(Notify);
public uint WaitForIdle; public uint WaitForIdle;
public fixed uint Reserved114[7]; public fixed uint Reserved114[7];
public uint SetGlobalRenderEnableA; public uint SetGlobalRenderEnableA;
public int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF); public readonly int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
public uint SetGlobalRenderEnableB; public uint SetGlobalRenderEnableB;
public uint SetGlobalRenderEnableC; public uint SetGlobalRenderEnableC;
public int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7); public readonly int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
public uint SendGoIdle; public uint SendGoIdle;
public uint PmTrigger; public uint PmTrigger;
public uint PmTriggerWfi; public uint PmTriggerWfi;
@ -139,34 +141,34 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
public uint LineLengthIn; public uint LineLengthIn;
public uint LineCount; public uint LineCount;
public uint OffsetOutUpper; public uint OffsetOutUpper;
public int OffsetOutUpperValue => (int)(OffsetOutUpper & 0xFF); public readonly int OffsetOutUpperValue => (int)(OffsetOutUpper & 0xFF);
public uint OffsetOut; public uint OffsetOut;
public uint PitchOut; public uint PitchOut;
public uint SetDstBlockSize; public uint SetDstBlockSize;
public SetDstBlockSizeWidth SetDstBlockSizeWidth => (SetDstBlockSizeWidth)(SetDstBlockSize & 0xF); public readonly SetDstBlockSizeWidth SetDstBlockSizeWidth => (SetDstBlockSizeWidth)(SetDstBlockSize & 0xF);
public SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF); public readonly SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
public SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF); public readonly SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
public uint SetDstWidth; public uint SetDstWidth;
public uint SetDstHeight; public uint SetDstHeight;
public uint SetDstDepth; public uint SetDstDepth;
public uint SetDstLayer; public uint SetDstLayer;
public uint SetDstOriginBytesX; public uint SetDstOriginBytesX;
public int SetDstOriginBytesXV => (int)(SetDstOriginBytesX & 0xFFFFF); public readonly int SetDstOriginBytesXV => (int)(SetDstOriginBytesX & 0xFFFFF);
public uint SetDstOriginSamplesY; public uint SetDstOriginSamplesY;
public int SetDstOriginSamplesYV => (int)(SetDstOriginSamplesY & 0xFFFF); public readonly int SetDstOriginSamplesYV => (int)(SetDstOriginSamplesY & 0xFFFF);
public uint LaunchDma; public uint LaunchDma;
public LaunchDmaDstMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaDstMemoryLayout)(LaunchDma & 0x1); public readonly LaunchDmaDstMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaDstMemoryLayout)(LaunchDma & 0x1);
public LaunchDmaCompletionType LaunchDmaCompletionType => (LaunchDmaCompletionType)((LaunchDma >> 4) & 0x3); public readonly LaunchDmaCompletionType LaunchDmaCompletionType => (LaunchDmaCompletionType)((LaunchDma >> 4) & 0x3);
public LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 8) & 0x3); public readonly LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 8) & 0x3);
public LaunchDmaSemaphoreStructSize LaunchDmaSemaphoreStructSize => (LaunchDmaSemaphoreStructSize)((LaunchDma >> 12) & 0x1); public readonly LaunchDmaSemaphoreStructSize LaunchDmaSemaphoreStructSize => (LaunchDmaSemaphoreStructSize)((LaunchDma >> 12) & 0x1);
public bool LaunchDmaReductionEnable => (LaunchDma & 0x2) != 0; public readonly bool LaunchDmaReductionEnable => (LaunchDma & 0x2) != 0;
public LaunchDmaReductionOp LaunchDmaReductionOp => (LaunchDmaReductionOp)((LaunchDma >> 13) & 0x7); public readonly LaunchDmaReductionOp LaunchDmaReductionOp => (LaunchDmaReductionOp)((LaunchDma >> 13) & 0x7);
public LaunchDmaReductionFormat LaunchDmaReductionFormat => (LaunchDmaReductionFormat)((LaunchDma >> 2) & 0x3); public readonly LaunchDmaReductionFormat LaunchDmaReductionFormat => (LaunchDmaReductionFormat)((LaunchDma >> 2) & 0x3);
public bool LaunchDmaSysmembarDisable => (LaunchDma & 0x40) != 0; public readonly bool LaunchDmaSysmembarDisable => (LaunchDma & 0x40) != 0;
public uint LoadInlineData; public uint LoadInlineData;
public fixed uint Reserved1B8[9]; public fixed uint Reserved1B8[9];
public uint SetI2mSemaphoreA; public uint SetI2mSemaphoreA;
public int SetI2mSemaphoreAOffsetUpper => (int)(SetI2mSemaphoreA & 0xFF); public readonly int SetI2mSemaphoreAOffsetUpper => (int)(SetI2mSemaphoreA & 0xFF);
public uint SetI2mSemaphoreB; public uint SetI2mSemaphoreB;
public uint SetI2mSemaphoreC; public uint SetI2mSemaphoreC;
public fixed uint Reserved1E8[2]; public fixed uint Reserved1E8[2];
@ -175,7 +177,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
public uint SetI2mSpareNoop02; public uint SetI2mSpareNoop02;
public uint SetI2mSpareNoop03; public uint SetI2mSpareNoop03;
public fixed uint Reserved200[3200]; public fixed uint Reserved200[3200];
public MmeShadowScratch SetMmeShadowScratch; public Array256<uint> SetMmeShadowScratch;
#pragma warning restore CS0649 #pragma warning restore CS0649
} }
} }

View file

@ -10,6 +10,6 @@
BitfieldReplace = 2, BitfieldReplace = 2,
BitfieldExtractLslImm = 3, BitfieldExtractLslImm = 3,
BitfieldExtractLslReg = 4, BitfieldExtractLslReg = 4,
ReadImmediate = 5 ReadImmediate = 5,
} }
} }

View file

@ -13,6 +13,6 @@
BitwiseOr = 9, BitwiseOr = 9,
BitwiseAnd = 10, BitwiseAnd = 10,
BitwiseAndNot = 11, BitwiseAndNot = 11,
BitwiseNotAnd = 12 BitwiseNotAnd = 12,
} }
} }

View file

@ -12,6 +12,6 @@
MoveAndSend = 4, MoveAndSend = 4,
FetchAndSetMaddr = 5, FetchAndSetMaddr = 5,
MoveAndSetMaddrThenFetchAndSend = 6, MoveAndSetMaddrThenFetchAndSend = 6,
MoveAndSetMaddrThenSendHigh = 7 MoveAndSetMaddrThenSendHigh = 7,
} }
} }

View file

@ -48,7 +48,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
if (_executionEngine == null) if (_executionEngine == null)
{ {
if (GraphicsConfig.EnableMacroHLE && MacroHLETable.TryGetMacroHLEFunction(code.Slice(Position), context.Capabilities, out _hleFunction)) if (GraphicsConfig.EnableMacroHLE && MacroHLETable.TryGetMacroHLEFunction(code[Position..], context.Capabilities, out _hleFunction))
{ {
_executionEngine = new MacroHLE(processor, _hleFunction); _executionEngine = new MacroHLE(processor, _hleFunction);
} }
@ -84,7 +84,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
if (_executionPending) if (_executionPending)
{ {
_executionPending = false; _executionPending = false;
_executionEngine?.Execute(code.Slice(Position), state, _argument); _executionEngine?.Execute(code[Position..], state, _argument);
} }
} }
@ -93,7 +93,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
/// </summary> /// </summary>
/// <param name="gpuVa">GPU virtual address where the command word is located</param> /// <param name="gpuVa">GPU virtual address where the command word is located</param>
/// <param name="argument">Argument to be pushed</param> /// <param name="argument">Argument to be pushed</param>
public void PushArgument(ulong gpuVa, int argument) public readonly void PushArgument(ulong gpuVa, int argument)
{ {
_executionEngine?.Fifo.Enqueue(new FifoWord(gpuVa, argument)); _executionEngine?.Fifo.Enqueue(new FifoWord(gpuVa, argument));
} }

View file

@ -16,7 +16,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
private const int ColorStructSize = 0x40; private const int ColorStructSize = 0x40;
private const int ZetaLayerCountOffset = 0x1230; private const int ZetaLayerCountOffset = 0x1230;
private const int IndirectDataEntrySize = 0x10;
private const int IndirectIndexedDataEntrySize = 0x14; private const int IndirectIndexedDataEntrySize = 0x14;
private readonly GPFifoProcessor _processor; private readonly GPFifoProcessor _processor;
@ -262,10 +261,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
for (int i = 0; i < maxDrawCount; i++) for (int i = 0; i < maxDrawCount; i++)
{ {
var count = FetchParam(); var count = FetchParam();
#pragma warning disable IDE0059 // Remove unnecessary value assignment
var instanceCount = FetchParam(); var instanceCount = FetchParam();
var firstIndex = FetchParam(); var firstIndex = FetchParam();
var firstVertex = FetchParam(); var firstVertex = FetchParam();
var firstInstance = FetchParam(); var firstInstance = FetchParam();
#pragma warning restore IDE0059
if (i == 0) if (i == 0)
{ {

View file

@ -11,6 +11,6 @@
DrawArraysInstanced, DrawArraysInstanced,
DrawElementsInstanced, DrawElementsInstanced,
DrawElementsIndirect, DrawElementsIndirect,
MultiDrawElementsIndirectCount MultiDrawElementsIndirectCount,
} }
} }

View file

@ -46,12 +46,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
private static readonly TableEntry[] _table = new TableEntry[] private static readonly TableEntry[] _table = new TableEntry[]
{ {
new TableEntry(MacroHLEFunctionName.ClearColor, new Hash128(0xA9FB28D1DC43645A, 0xB177E5D2EAE67FB0), 0x28), new(MacroHLEFunctionName.ClearColor, new Hash128(0xA9FB28D1DC43645A, 0xB177E5D2EAE67FB0), 0x28),
new TableEntry(MacroHLEFunctionName.ClearDepthStencil, new Hash128(0x1B96CB77D4879F4F, 0x8557032FE0C965FB), 0x24), new(MacroHLEFunctionName.ClearDepthStencil, new Hash128(0x1B96CB77D4879F4F, 0x8557032FE0C965FB), 0x24),
new TableEntry(MacroHLEFunctionName.DrawArraysInstanced, new Hash128(0x197FB416269DBC26, 0x34288C01DDA82202), 0x48), new(MacroHLEFunctionName.DrawArraysInstanced, new Hash128(0x197FB416269DBC26, 0x34288C01DDA82202), 0x48),
new TableEntry(MacroHLEFunctionName.DrawElementsInstanced, new Hash128(0x1A501FD3D54EC8E0, 0x6CF570CF79DA74D6), 0x5c), new(MacroHLEFunctionName.DrawElementsInstanced, new Hash128(0x1A501FD3D54EC8E0, 0x6CF570CF79DA74D6), 0x5c),
new TableEntry(MacroHLEFunctionName.DrawElementsIndirect, new Hash128(0x86A3E8E903AF8F45, 0xD35BBA07C23860A4), 0x7c), new(MacroHLEFunctionName.DrawElementsIndirect, new Hash128(0x86A3E8E903AF8F45, 0xD35BBA07C23860A4), 0x7c),
new TableEntry(MacroHLEFunctionName.MultiDrawElementsIndirectCount, new Hash128(0x890AF57ED3FB1C37, 0x35D0C95C61F5386F), 0x19C) new(MacroHLEFunctionName.MultiDrawElementsIndirectCount, new Hash128(0x890AF57ED3FB1C37, 0x35D0C95C61F5386F), 0x19C),
}; };
/// <summary> /// <summary>
@ -93,7 +93,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
{ {
ref var entry = ref _table[i]; ref var entry = ref _table[i];
var hash = XXHash128.ComputeHash(mc.Slice(0, entry.Length)); var hash = XXHash128.ComputeHash(mc[..entry.Length]);
if (hash == entry.Hash) if (hash == entry.Hash)
{ {
if (IsMacroHLESupported(caps, entry.Name)) if (IsMacroHLESupported(caps, entry.Name))

View file

@ -15,7 +15,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
/// </summary> /// </summary>
public Queue<FifoWord> Fifo { get; } public Queue<FifoWord> Fifo { get; }
private int[] _gprs; private readonly int[] _gprs;
private int _methAddr; private int _methAddr;
private int _methIncr; private int _methIncr;
@ -291,11 +291,16 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
return (int)result; return (int)result;
case AluRegOperation.BitwiseExclusiveOr: return a ^ b; case AluRegOperation.BitwiseExclusiveOr:
case AluRegOperation.BitwiseOr: return a | b; return a ^ b;
case AluRegOperation.BitwiseAnd: return a & b; case AluRegOperation.BitwiseOr:
case AluRegOperation.BitwiseAndNot: return a & ~b; return a | b;
case AluRegOperation.BitwiseNotAnd: return ~(a & b); case AluRegOperation.BitwiseAnd:
return a & b;
case AluRegOperation.BitwiseAndNot:
return a & ~b;
case AluRegOperation.BitwiseNotAnd:
return ~(a & b);
} }
throw new InvalidOperationException($"Invalid operation \"{aluOp}\" on instruction 0x{_opCode:X8}."); throw new InvalidOperationException($"Invalid operation \"{aluOp}\" on instruction 0x{_opCode:X8}.");
@ -380,7 +385,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
/// <param name="state">Current GPU state</param> /// <param name="state">Current GPU state</param>
/// <param name="reg">Register offset to read</param> /// <param name="reg">Register offset to read</param>
/// <returns>GPU register value</returns> /// <returns>GPU register value</returns>
private int Read(IDeviceState state, int reg) private static int Read(IDeviceState state, int reg)
{ {
return state.Read(reg * 4); return state.Read(reg * 4);
} }

View file

@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
/// </summary> /// </summary>
class MacroJit : IMacroEE class MacroJit : IMacroEE
{ {
private readonly MacroJitContext _context = new MacroJitContext(); private readonly MacroJitContext _context = new();
/// <summary> /// <summary>
/// Arguments FIFO. /// Arguments FIFO.
@ -28,7 +28,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
{ {
if (_execute == null) if (_execute == null)
{ {
MacroJitCompiler compiler = new MacroJitCompiler(); MacroJitCompiler compiler = new();
_execute = compiler.Compile(code); _execute = compiler.Compile(code);
} }

View file

@ -48,7 +48,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
/// <returns>Delegate of the host compiled code</returns> /// <returns>Delegate of the host compiled code</returns>
public MacroExecute Compile(ReadOnlySpan<int> code) public MacroExecute Compile(ReadOnlySpan<int> code)
{ {
Dictionary<int, Label> labels = new Dictionary<int, Label>(); Dictionary<int, Label> labels = new();
int lastTarget = 0; int lastTarget = 0;
int i; int i;

View file

@ -12,7 +12,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
/// <summary> /// <summary>
/// Arguments FIFO. /// Arguments FIFO.
/// </summary> /// </summary>
public Queue<FifoWord> Fifo { get; } = new Queue<FifoWord>(); public Queue<FifoWord> Fifo { get; } = new();
/// <summary> /// <summary>
/// Fetches a arguments from the arguments FIFO. /// Fetches a arguments from the arguments FIFO.

View file

@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
[StructLayout(LayoutKind.Sequential, Size = 1024)] [StructLayout(LayoutKind.Sequential, Size = 1024)]
struct MmeShadowScratch struct MmeShadowScratch
{ {
#pragma warning disable CS0169 #pragma warning disable CS0169 // The private field is never used
private uint _e0; private uint _e0;
#pragma warning restore CS0169 #pragma warning restore CS0169
public ref uint this[int index] => ref AsSpan()[index]; public ref uint this[int index] => ref AsSpan()[index];

View file

@ -65,6 +65,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
{ {
return format switch return format switch
{ {
#pragma warning disable IDE0055 // Disable formatting
TextureFormat.R8Unorm => Format.R8Unorm, TextureFormat.R8Unorm => Format.R8Unorm,
TextureFormat.R8Snorm => Format.R8Snorm, TextureFormat.R8Snorm => Format.R8Snorm,
TextureFormat.R8Uint => Format.R8Uint, TextureFormat.R8Uint => Format.R8Uint,
@ -104,7 +105,8 @@ namespace Ryujinx.Graphics.Gpu.Engine
TextureFormat.R10G10B10A2Unorm => Format.R10G10B10A2Unorm, TextureFormat.R10G10B10A2Unorm => Format.R10G10B10A2Unorm,
TextureFormat.R10G10B10A2Uint => Format.R10G10B10A2Uint, TextureFormat.R10G10B10A2Uint => Format.R10G10B10A2Uint,
TextureFormat.R11G11B10Float => Format.R11G11B10Float, TextureFormat.R11G11B10Float => Format.R11G11B10Float,
_ => 0 _ => 0,
#pragma warning restore IDE0055
}; };
} }
} }

View file

@ -209,14 +209,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
new AdvancedBlendUcode(AdvancedBlendOp.HslHue, AdvancedBlendOverlap.Conjoint, false, GenConjointHslHue), new AdvancedBlendUcode(AdvancedBlendOp.HslHue, AdvancedBlendOverlap.Conjoint, false, GenConjointHslHue),
new AdvancedBlendUcode(AdvancedBlendOp.HslSaturation, AdvancedBlendOverlap.Conjoint, false, GenConjointHslSaturation), new AdvancedBlendUcode(AdvancedBlendOp.HslSaturation, AdvancedBlendOverlap.Conjoint, false, GenConjointHslSaturation),
new AdvancedBlendUcode(AdvancedBlendOp.HslColor, AdvancedBlendOverlap.Conjoint, false, GenConjointHslColor), new AdvancedBlendUcode(AdvancedBlendOp.HslColor, AdvancedBlendOverlap.Conjoint, false, GenConjointHslColor),
new AdvancedBlendUcode(AdvancedBlendOp.HslLuminosity, AdvancedBlendOverlap.Conjoint, false, GenConjointHslLuminosity) new AdvancedBlendUcode(AdvancedBlendOp.HslLuminosity, AdvancedBlendOverlap.Conjoint, false, GenConjointHslLuminosity),
}; };
public static string GenTable() public static string GenTable()
{ {
// This can be used to generate the table on AdvancedBlendPreGenTable. // This can be used to generate the table on AdvancedBlendPreGenTable.
StringBuilder sb = new StringBuilder(); StringBuilder sb = new();
sb.AppendLine($"private static Dictionary<Hash128, AdvancedBlendEntry> _entries = new()"); sb.AppendLine($"private static Dictionary<Hash128, AdvancedBlendEntry> _entries = new()");
sb.AppendLine("{"); sb.AppendLine("{");

View file

@ -54,12 +54,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
/// <returns>True if the function was found, false otherwise</returns> /// <returns>True if the function was found, false otherwise</returns>
public bool TryGetAdvancedBlend(out AdvancedBlendDescriptor descriptor) public bool TryGetAdvancedBlend(out AdvancedBlendDescriptor descriptor)
{ {
Span<uint> currentCode = new Span<uint>(_code); Span<uint> currentCode = new(_code);
byte codeLength = (byte)_state.State.BlendUcodeSize; byte codeLength = (byte)_state.State.BlendUcodeSize;
if (currentCode.Length > codeLength) if (currentCode.Length > codeLength)
{ {
currentCode = currentCode.Slice(0, codeLength); currentCode = currentCode[..codeLength];
} }
Hash128 hash = XXHash128.ComputeHash(MemoryMarshal.Cast<uint, byte>(currentCode)); Hash128 hash = XXHash128.ComputeHash(MemoryMarshal.Cast<uint, byte>(currentCode));

View file

@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
/// <summary> /// <summary>
/// Advanced blend function entry. /// Advanced blend function entry.
/// </summary> /// </summary>
struct AdvancedBlendEntry readonly struct AdvancedBlendEntry
{ {
/// <summary> /// <summary>
/// Advanced blend operation. /// Advanced blend operation.

View file

@ -5,12 +5,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
/// <summary> /// <summary>
/// Fixed function alpha state used for a advanced blend function. /// Fixed function alpha state used for a advanced blend function.
/// </summary> /// </summary>
struct FixedFunctionAlpha readonly struct FixedFunctionAlpha
{ {
/// <summary> /// <summary>
/// Fixed function alpha state with alpha blending disabled. /// Fixed function alpha state with alpha blending disabled.
/// </summary> /// </summary>
public static FixedFunctionAlpha Disabled => new FixedFunctionAlpha(BlendUcodeEnable.EnableRGBA, default, default, default); public static FixedFunctionAlpha Disabled => new(BlendUcodeEnable.EnableRGBA, default, default, default);
/// <summary> /// <summary>
/// Individual enable bits for the RGB and alpha components. /// Individual enable bits for the RGB and alpha components.
@ -68,7 +68,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
/// <summary> /// <summary>
/// Advanced blend microcode state. /// Advanced blend microcode state.
/// </summary> /// </summary>
struct AdvancedBlendUcode readonly struct AdvancedBlendUcode
{ {
/// <summary> /// <summary>
/// Advanced blend operation. /// Advanced blend operation.
@ -117,7 +117,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Overlap = overlap; Overlap = overlap;
SrcPreMultiplied = srcPreMultiplied; SrcPreMultiplied = srcPreMultiplied;
UcodeAssembler asm = new UcodeAssembler(); UcodeAssembler asm = new();
Alpha = genFunc(ref asm); Alpha = genFunc(ref asm);
Code = asm.GetCode(); Code = asm.GetCode();
Constants = asm.GetConstants(); Constants = asm.GetConstants();

View file

@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Max = 3, Max = 3,
Rcp = 4, Rcp = 4,
Add = 5, Add = 5,
Sub = 6 Sub = 6,
} }
/// <summary> /// <summary>
@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
LT = 4, LT = 4,
LE = 5, LE = 5,
GT = 6, GT = 6,
GE = 7 GE = 7,
} }
/// <summary> /// <summary>
@ -49,7 +49,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Temp1 = 0xa, Temp1 = 0xa,
Temp2 = 0xb, Temp2 = 0xb,
PBR = 0xc, PBR = 0xc,
ConstantRGB = 0xd ConstantRGB = 0xd,
} }
/// <summary> /// <summary>
@ -64,7 +64,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Temp0 = 4, Temp0 = 4,
Temp1 = 5, Temp1 = 5,
Temp2 = 6, Temp2 = 6,
PBR = 7 PBR = 7,
} }
/// <summary> /// <summary>
@ -75,7 +75,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
Temp0 = 0, Temp0 = 0,
Temp1 = 1, Temp1 = 1,
Temp2 = 2, Temp2 = 2,
PBR = 3 PBR = 3,
} }
/// <summary> /// <summary>
@ -88,7 +88,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
RRR = 2, RRR = 2,
GGG = 3, GGG = 3,
BBB = 4, BBB = 4,
RToA = 5 RToA = 5,
} }
/// <summary> /// <summary>
@ -99,13 +99,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
RGB = 0, RGB = 0,
R = 1, R = 1,
G = 2, G = 2,
B = 3 B = 3,
} }
/// <summary> /// <summary>
/// Floating-point RGB color values. /// Floating-point RGB color values.
/// </summary> /// </summary>
struct RgbFloat readonly struct RgbFloat
{ {
/// <summary> /// <summary>
/// Red component value. /// Red component value.
@ -139,24 +139,24 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
/// <summary> /// <summary>
/// Blend microcode destination operand, including swizzle, write mask and condition code update flag. /// Blend microcode destination operand, including swizzle, write mask and condition code update flag.
/// </summary> /// </summary>
struct Dest readonly struct Dest
{ {
public static Dest Temp0 => new Dest(OpDst.Temp0, Swizzle.RGB, WriteMask.RGB, false); public static Dest Temp0 => new(OpDst.Temp0, Swizzle.RGB, WriteMask.RGB, false);
public static Dest Temp1 => new Dest(OpDst.Temp1, Swizzle.RGB, WriteMask.RGB, false); public static Dest Temp1 => new(OpDst.Temp1, Swizzle.RGB, WriteMask.RGB, false);
public static Dest Temp2 => new Dest(OpDst.Temp2, Swizzle.RGB, WriteMask.RGB, false); public static Dest Temp2 => new(OpDst.Temp2, Swizzle.RGB, WriteMask.RGB, false);
public static Dest PBR => new Dest(OpDst.PBR, Swizzle.RGB, WriteMask.RGB, false); public static Dest PBR => new(OpDst.PBR, Swizzle.RGB, WriteMask.RGB, false);
public Dest GBR => new Dest(Dst, Swizzle.GBR, WriteMask, WriteCC); public Dest GBR => new(Dst, Swizzle.GBR, WriteMask, WriteCC);
public Dest RRR => new Dest(Dst, Swizzle.RRR, WriteMask, WriteCC); public Dest RRR => new(Dst, Swizzle.RRR, WriteMask, WriteCC);
public Dest GGG => new Dest(Dst, Swizzle.GGG, WriteMask, WriteCC); public Dest GGG => new(Dst, Swizzle.GGG, WriteMask, WriteCC);
public Dest BBB => new Dest(Dst, Swizzle.BBB, WriteMask, WriteCC); public Dest BBB => new(Dst, Swizzle.BBB, WriteMask, WriteCC);
public Dest RToA => new Dest(Dst, Swizzle.RToA, WriteMask, WriteCC); public Dest RToA => new(Dst, Swizzle.RToA, WriteMask, WriteCC);
public Dest R => new Dest(Dst, Swizzle, WriteMask.R, WriteCC); public Dest R => new(Dst, Swizzle, WriteMask.R, WriteCC);
public Dest G => new Dest(Dst, Swizzle, WriteMask.G, WriteCC); public Dest G => new(Dst, Swizzle, WriteMask.G, WriteCC);
public Dest B => new Dest(Dst, Swizzle, WriteMask.B, WriteCC); public Dest B => new(Dst, Swizzle, WriteMask.B, WriteCC);
public Dest CC => new Dest(Dst, Swizzle, WriteMask, true); public Dest CC => new(Dst, Swizzle, WriteMask, true);
public OpDst Dst { get; } public OpDst Dst { get; }
public Swizzle Swizzle { get; } public Swizzle Swizzle { get; }
@ -182,7 +182,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
/// <summary> /// <summary>
/// Blend microcode operaiton. /// Blend microcode operaiton.
/// </summary> /// </summary>
struct UcodeOp readonly struct UcodeOp
{ {
public readonly uint Word; public readonly uint Word;
@ -292,12 +292,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.Blender
_constantIndex = index; _constantIndex = index;
} }
public uint[] GetCode() public readonly uint[] GetCode()
{ {
return _code?.ToArray(); return _code?.ToArray();
} }
public RgbFloat[] GetConstants() public readonly RgbFloat[] GetConstants()
{ {
return _constants; return _constants;
} }

View file

@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
private ulong _ubFollowUpAddress = 0; private ulong _ubFollowUpAddress = 0;
private ulong _ubByteCount = 0; private ulong _ubByteCount = 0;
private int _ubIndex = 0; private int _ubIndex = 0;
private int[] _ubData = new int[UniformDataCacheSize]; private readonly int[] _ubData = new int[UniformDataCacheSize];
/// <summary> /// <summary>
/// Creates a new instance of the constant buffer updater. /// Creates a new instance of the constant buffer updater.

View file

@ -186,7 +186,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{ {
int firstVertex = (int)_state.State.FirstVertex; int firstVertex = (int)_state.State.FirstVertex;
BufferRange br = new BufferRange(_drawState.IbStreamer.GetInlineIndexBuffer(), 0, inlineIndexCount * 4); BufferRange br = new(_drawState.IbStreamer.GetInlineIndexBuffer(), 0, inlineIndexCount * 4);
_channel.BufferManager.SetIndexBuffer(br, IndexType.UInt); _channel.BufferManager.SetIndexBuffer(br, IndexType.UInt);
@ -200,7 +200,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
} }
else else
{ {
#pragma warning disable IDE0059 // Remove unnecessary value assignment
var drawState = _state.State.VertexBufferDrawState; var drawState = _state.State.VertexBufferDrawState;
#pragma warning restore IDE0059
_context.Renderer.Pipeline.Draw(drawVertexCount, 1, drawFirstVertex, firstInstance); _context.Renderer.Pipeline.Draw(drawVertexCount, 1, drawFirstVertex, firstInstance);
} }
@ -679,7 +681,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
if (indexedInline) if (indexedInline)
{ {
int inlineIndexCount = _drawState.IbStreamer.GetAndResetInlineIndexCount(_context.Renderer); int inlineIndexCount = _drawState.IbStreamer.GetAndResetInlineIndexCount(_context.Renderer);
BufferRange br = new BufferRange(_drawState.IbStreamer.GetInlineIndexBuffer(), 0, inlineIndexCount * 4); BufferRange br = new(_drawState.IbStreamer.GetInlineIndexBuffer(), 0, inlineIndexCount * 4);
_channel.BufferManager.SetIndexBuffer(br, IndexType.UInt); _channel.BufferManager.SetIndexBuffer(br, IndexType.UInt);
} }
@ -809,7 +811,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
Span<Rectangle<int>> scissors = stackalloc Rectangle<int>[] Span<Rectangle<int>> scissors = stackalloc Rectangle<int>[]
{ {
new Rectangle<int>(scissorX, scissorY, scissorW, scissorH) new Rectangle<int>(scissorX, scissorY, scissorW, scissorH),
}; };
_context.Renderer.Pipeline.SetScissors(scissors); _context.Renderer.Pipeline.SetScissors(scissors);
@ -821,7 +823,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{ {
var clearColor = _state.State.ClearColors; var clearColor = _state.State.ClearColors;
ColorF color = new ColorF(clearColor.Red, clearColor.Green, clearColor.Blue, clearColor.Alpha); ColorF color = new(clearColor.Red, clearColor.Green, clearColor.Blue, clearColor.Alpha);
_context.Renderer.Pipeline.ClearRenderTargetColor(index, layer, layerCount, componentMask, color); _context.Renderer.Pipeline.ClearRenderTargetColor(index, layer, layerCount, componentMask, color);
} }

View file

@ -60,6 +60,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// <summary> /// <summary>
/// Index buffer data streamer for inline index buffer updates, such as those used in legacy OpenGL. /// Index buffer data streamer for inline index buffer updates, such as those used in legacy OpenGL.
/// </summary> /// </summary>
public IbStreamer IbStreamer = new IbStreamer(); public IbStreamer IbStreamer = new();
} }
} }

View file

@ -1,6 +1,5 @@
using Ryujinx.Common; using Ryujinx.Common;
using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.GAL;
using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Ryujinx.Graphics.Gpu.Engine.Threed namespace Ryujinx.Graphics.Gpu.Engine.Threed
@ -17,33 +16,35 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
private int _inlineIndexBufferSize; private int _inlineIndexBufferSize;
private int _inlineIndexCount; private int _inlineIndexCount;
private uint[] _buffer; private uint[] _buffer;
private int _bufferOffset; #pragma warning disable IDE0051 // Remove unused private member
private readonly int _bufferOffset;
#pragma warning restore IDE0051
/// <summary> /// <summary>
/// Indicates if any index buffer data has been pushed. /// Indicates if any index buffer data has been pushed.
/// </summary> /// </summary>
public bool HasInlineIndexData => _inlineIndexCount != 0; public readonly bool HasInlineIndexData => _inlineIndexCount != 0;
/// <summary> /// <summary>
/// Total numbers of indices that have been pushed. /// Total numbers of indices that have been pushed.
/// </summary> /// </summary>
public int InlineIndexCount => _inlineIndexCount; public readonly int InlineIndexCount => _inlineIndexCount;
/// <summary> /// <summary>
/// Gets the handle for the host buffer currently holding the inline index buffer data. /// Gets the handle for the host buffer currently holding the inline index buffer data.
/// </summary> /// </summary>
/// <returns>Host buffer handle</returns> /// <returns>Host buffer handle</returns>
public BufferHandle GetInlineIndexBuffer() public readonly BufferHandle GetInlineIndexBuffer()
{ {
return _inlineIndexBuffer; return _inlineIndexBuffer;
} }
/// <summary> /// <summary>
/// Gets the number of elements on the current inline index buffer, /// Gets the number of elements on the current inline index buffer,
/// while also reseting it to zero for the next draw. /// while also resetting it to zero for the next draw.
/// </summary> /// </summary>
/// <param name="renderer">Host renderer</param> /// <param name="renderer">Host renderer</param>
/// <returns>Inline index bufffer count</returns> /// <returns>Inline index buffer count</returns>
public int GetAndResetInlineIndexCount(IRenderer renderer) public int GetAndResetInlineIndexCount(IRenderer renderer)
{ {
UpdateRemaining(renderer); UpdateRemaining(renderer);
@ -114,10 +115,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// <param name="value">Index value to be written</param> /// <param name="value">Index value to be written</param>
private void PushData(IRenderer renderer, int offset, uint value) private void PushData(IRenderer renderer, int offset, uint value)
{ {
if (_buffer == null) _buffer ??= new uint[BufferCapacity];
{
_buffer = new uint[BufferCapacity];
}
// We upload data in chunks. // We upload data in chunks.
// If we are at the start of a chunk, then the buffer might be full, // If we are at the start of a chunk, then the buffer might be full,
@ -155,7 +153,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
int baseOffset = (offset - count) * sizeof(uint); int baseOffset = (offset - count) * sizeof(uint);
int length = count * sizeof(uint); int length = count * sizeof(uint);
BufferHandle buffer = GetInlineIndexBuffer(renderer, baseOffset, length); BufferHandle buffer = GetInlineIndexBuffer(renderer, baseOffset, length);
renderer.SetBufferData(buffer, baseOffset, MemoryMarshal.Cast<uint, byte>(_buffer).Slice(0, length)); renderer.SetBufferData(buffer, baseOffset, MemoryMarshal.Cast<uint, byte>(_buffer)[..length]);
} }
/// <summary> /// <summary>

View file

@ -1,8 +1,11 @@
using System.Diagnostics.CodeAnalysis;
namespace Ryujinx.Graphics.Gpu.Engine.Threed namespace Ryujinx.Graphics.Gpu.Engine.Threed
{ {
/// <summary> /// <summary>
/// Indirect draw type, which can be indexed or non-indexed, with or without a draw count. /// Indirect draw type, which can be indexed or non-indexed, with or without a draw count.
/// </summary> /// </summary>
[SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
enum IndirectDrawType enum IndirectDrawType
{ {
/// <summary> /// <summary>
@ -33,6 +36,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// <summary> /// <summary>
/// Draw count flag. /// Draw count flag.
/// </summary> /// </summary>
Count = 1 << 1 Count = 1 << 1,
} }
} }

View file

@ -36,6 +36,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// <summary> /// <summary>
/// Default update flags for draw. /// Default update flags for draw.
/// </summary> /// </summary>
UpdateAll = UseControl | UpdateDepthStencil UpdateAll = UseControl | UpdateDepthStencil,
} }
} }

View file

@ -1,5 +1,4 @@
using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.GAL;
using System;
namespace Ryujinx.Graphics.Gpu.Engine.Threed namespace Ryujinx.Graphics.Gpu.Engine.Threed
{ {
@ -15,7 +14,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{ {
Release = 0, Release = 0,
Acquire = 1, Acquire = 1,
Counter = 2 Counter = 2,
} }
/// <summary> /// <summary>
@ -37,7 +36,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
ClipperInputPrimitives = 0x1c, ClipperInputPrimitives = 0x1c,
ClipperOutputPrimitives = 0x1d, ClipperOutputPrimitives = 0x1d,
FragmentShaderInvocations = 0x1e, FragmentShaderInvocations = 0x1e,
PrimitivesGenerated = 0x1f PrimitivesGenerated = 0x1f,
} }
/// <summary> /// <summary>
@ -64,7 +63,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
TransformFeedbackOffset = 0x1a, TransformFeedbackOffset = 0x1a,
TessControlShaderInvocations = 0x1b, TessControlShaderInvocations = 0x1b,
TessEvaluationShaderInvocations = 0x1d, TessEvaluationShaderInvocations = 0x1d,
TessEvaluationShaderPrimitives = 0x1f TessEvaluationShaderPrimitives = 0x1f,
} }
private readonly GpuContext _context; private readonly GpuContext _context;
@ -117,8 +116,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
switch (op) switch (op)
{ {
case SemaphoreOperation.Release: ReleaseSemaphore(); break; case SemaphoreOperation.Release:
case SemaphoreOperation.Counter: ReportCounter(type); break; ReleaseSemaphore();
break;
case SemaphoreOperation.Counter:
ReportCounter(type);
break;
} }
} }
@ -156,10 +159,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
void resultHandler(object evt, ulong result) void resultHandler(object evt, ulong result)
{ {
CounterData counterData = new CounterData CounterData counterData = new()
{ {
Counter = result, Counter = result,
Timestamp = ticks Timestamp = ticks,
}; };
if (counter?.Invalid != true) if (counter?.Invalid != true)

View file

@ -227,7 +227,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{ {
VertexAttribType.Sint => AttributeType.Sint, VertexAttribType.Sint => AttributeType.Sint,
VertexAttribType.Uint => AttributeType.Uint, VertexAttribType.Uint => AttributeType.Uint,
_ => AttributeType.Float _ => AttributeType.Float,
}; };
if (attributeTypes[location] != value) if (attributeTypes[location] != value)

View file

@ -33,7 +33,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
private readonly ShaderProgramInfo[] _currentProgramInfo; private readonly ShaderProgramInfo[] _currentProgramInfo;
private ShaderSpecializationState _shaderSpecState; private ShaderSpecializationState _shaderSpecState;
private SpecializationStateUpdater _currentSpecState; private readonly SpecializationStateUpdater _currentSpecState;
private ProgramPipelineState _pipeline; private ProgramPipelineState _pipeline;
@ -43,7 +43,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
private uint _vbEnableMask; private uint _vbEnableMask;
private bool _prevDrawIndexed; private bool _prevDrawIndexed;
private bool _prevDrawIndirect; private readonly bool _prevDrawIndirect;
private IndexType _prevIndexType; private IndexType _prevIndexType;
private uint _prevFirstVertex; private uint _prevFirstVertex;
private bool _prevTfEnable; private bool _prevTfEnable;
@ -448,7 +448,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
int samplesInY = msaaMode.SamplesInY(); int samplesInY = msaaMode.SamplesInY();
var scissor = _state.State.ScreenScissorState; var scissor = _state.State.ScreenScissorState;
Size sizeHint = new Size((scissor.X + scissor.Width) * samplesInX, (scissor.Y + scissor.Height) * samplesInY, 1); Size sizeHint = new((scissor.X + scissor.Width) * samplesInX, (scissor.Y + scissor.Height) * samplesInY, 1);
int clipRegionWidth = int.MaxValue; int clipRegionWidth = int.MaxValue;
int clipRegionHeight = int.MaxValue; int clipRegionHeight = int.MaxValue;
@ -669,7 +669,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
private void UpdateDepthTestState() private void UpdateDepthTestState()
{ {
DepthTestDescriptor descriptor = new DepthTestDescriptor( DepthTestDescriptor descriptor = new(
_state.State.DepthTestEnable, _state.State.DepthTestEnable,
_state.State.DepthWriteEnable, _state.State.DepthWriteEnable,
_state.State.DepthTestFunc); _state.State.DepthTestFunc);
@ -739,7 +739,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
height *= scale; height *= scale;
} }
Rectangle<float> region = new Rectangle<float>(x, y, width, height); Rectangle<float> region = new(x, y, width, height);
ViewportSwizzle swizzleX = transform.UnpackSwizzleX(); ViewportSwizzle swizzleX = transform.UnpackSwizzleX();
ViewportSwizzle swizzleY = transform.UnpackSwizzleY(); ViewportSwizzle swizzleY = transform.UnpackSwizzleY();
@ -751,9 +751,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
if (transform.ScaleZ < 0) if (transform.ScaleZ < 0)
{ {
float temp = depthNear; (depthFar, depthNear) = (depthNear, depthFar);
depthNear = depthFar;
depthFar = temp;
} }
viewports[index] = new Viewport(region, swizzleX, swizzleY, swizzleZ, swizzleW, depthNear, depthFar); viewports[index] = new Viewport(region, swizzleX, swizzleY, swizzleZ, swizzleW, depthNear, depthFar);
@ -845,7 +843,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
backMask = test.FrontMask; backMask = test.FrontMask;
} }
StencilTestDescriptor descriptor = new StencilTestDescriptor( StencilTestDescriptor descriptor = new(
test.Enable, test.Enable,
test.FrontFunc, test.FrontFunc,
test.FrontSFail, test.FrontSFail,
@ -939,7 +937,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{ {
VertexAttribType.Sint => Format.R32G32B32A32Sint, VertexAttribType.Sint => Format.R32G32B32A32Sint,
VertexAttribType.Uint => Format.R32G32B32A32Uint, VertexAttribType.Uint => Format.R32G32B32A32Uint,
_ => Format.R32G32B32A32Float _ => Format.R32G32B32A32Float,
}; };
} }
@ -1017,8 +1015,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
switch (indexBuffer.Type) switch (indexBuffer.Type)
{ {
case IndexType.UShort: size *= 2; break; case IndexType.UShort:
case IndexType.UInt: size *= 4; break; size *= 2;
break;
case IndexType.UInt:
size *= 4;
break;
} }
_channel.BufferManager.SetIndexBuffer(gpuVa, size, indexBuffer.Type); _channel.BufferManager.SetIndexBuffer(gpuVa, size, indexBuffer.Type);
@ -1338,7 +1340,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
_vtgWritesRtLayer = false; _vtgWritesRtLayer = false;
ShaderAddresses addresses = new ShaderAddresses(); ShaderAddresses addresses = new();
Span<ulong> addressesSpan = addresses.AsSpan(); Span<ulong> addressesSpan = addresses.AsSpan();
ulong baseAddress = _state.State.ShaderBaseAddress.Pack(); ulong baseAddress = _state.State.ShaderBaseAddress.Pack();
@ -1453,7 +1455,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
// ScaleZ = (Far - Near) / 2 // ScaleZ = (Far - Near) / 2
// DepthNear/Far are sorted such as that Near is always less than Far. // DepthNear/Far are sorted such as that Near is always less than Far.
depthMode = extents.DepthNear != transform.TranslateZ && depthMode = extents.DepthNear != transform.TranslateZ &&
extents.DepthFar != transform.TranslateZ extents.DepthFar != transform.TranslateZ
? DepthMode.MinusOneToOne ? DepthMode.MinusOneToOne
: DepthMode.ZeroToOne; : DepthMode.ZeroToOne;
} }

View file

@ -71,7 +71,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{ nameof(ThreedClassState.UniformBufferBindTessControl), new RwCallback(ConstantBufferBindTessControl, null) }, { nameof(ThreedClassState.UniformBufferBindTessControl), new RwCallback(ConstantBufferBindTessControl, null) },
{ nameof(ThreedClassState.UniformBufferBindTessEvaluation), new RwCallback(ConstantBufferBindTessEvaluation, null) }, { nameof(ThreedClassState.UniformBufferBindTessEvaluation), new RwCallback(ConstantBufferBindTessEvaluation, null) },
{ nameof(ThreedClassState.UniformBufferBindGeometry), new RwCallback(ConstantBufferBindGeometry, null) }, { nameof(ThreedClassState.UniformBufferBindGeometry), new RwCallback(ConstantBufferBindGeometry, null) },
{ nameof(ThreedClassState.UniformBufferBindFragment), new RwCallback(ConstantBufferBindFragment, null) } { nameof(ThreedClassState.UniformBufferBindFragment), new RwCallback(ConstantBufferBindFragment, null) },
}); });
_i2mClass = new InlineToMemoryClass(context, channel, initializeState: false); _i2mClass = new InlineToMemoryClass(context, channel, initializeState: false);

View file

@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
TessellationControl, TessellationControl,
TessellationEvaluation, TessellationEvaluation,
Geometry, Geometry,
Fragment Fragment,
} }
/// <summary> /// <summary>
@ -26,7 +26,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct TessMode struct TessMode
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint Packed; public uint Packed;
#pragma warning restore CS0649 #pragma warning restore CS0649
@ -34,7 +34,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the tessellation abstract patch type. /// Unpacks the tessellation abstract patch type.
/// </summary> /// </summary>
/// <returns>Abtract patch type</returns> /// <returns>Abtract patch type</returns>
public TessPatchType UnpackPatchType() public readonly TessPatchType UnpackPatchType()
{ {
return (TessPatchType)(Packed & 3); return (TessPatchType)(Packed & 3);
} }
@ -43,7 +43,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the spacing between tessellated vertices of the patch. /// Unpacks the spacing between tessellated vertices of the patch.
/// </summary> /// </summary>
/// <returns>Spacing between tessellated vertices</returns> /// <returns>Spacing between tessellated vertices</returns>
public TessSpacing UnpackSpacing() public readonly TessSpacing UnpackSpacing()
{ {
return (TessSpacing)((Packed >> 4) & 3); return (TessSpacing)((Packed >> 4) & 3);
} }
@ -52,7 +52,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the primitive winding order. /// Unpacks the primitive winding order.
/// </summary> /// </summary>
/// <returns>True if clockwise, false if counter-clockwise</returns> /// <returns>True if clockwise, false if counter-clockwise</returns>
public bool UnpackCw() public readonly bool UnpackCw()
{ {
return (Packed & (1 << 8)) != 0; return (Packed & (1 << 8)) != 0;
} }
@ -63,7 +63,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct TfBufferState struct TfBufferState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable; public Boolean32 Enable;
public GpuVa Address; public GpuVa Address;
public int Size; public int Size;
@ -79,7 +79,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct TfState struct TfState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public int BufferIndex; public int BufferIndex;
public int VaryingsCount; public int VaryingsCount;
public int Stride; public int Stride;
@ -92,7 +92,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct RtColorState struct RtColorState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public GpuVa Address; public GpuVa Address;
public int WidthOrStride; public int WidthOrStride;
public int Height; public int Height;
@ -116,7 +116,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct ViewportTransform struct ViewportTransform
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public float ScaleX; public float ScaleX;
public float ScaleY; public float ScaleY;
public float ScaleZ; public float ScaleZ;
@ -131,7 +131,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks viewport swizzle of the position X component. /// Unpacks viewport swizzle of the position X component.
/// </summary> /// </summary>
/// <returns>Swizzle enum value</returns> /// <returns>Swizzle enum value</returns>
public ViewportSwizzle UnpackSwizzleX() public readonly ViewportSwizzle UnpackSwizzleX()
{ {
return (ViewportSwizzle)(Swizzle & 7); return (ViewportSwizzle)(Swizzle & 7);
} }
@ -140,7 +140,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks viewport swizzle of the position Y component. /// Unpacks viewport swizzle of the position Y component.
/// </summary> /// </summary>
/// <returns>Swizzle enum value</returns> /// <returns>Swizzle enum value</returns>
public ViewportSwizzle UnpackSwizzleY() public readonly ViewportSwizzle UnpackSwizzleY()
{ {
return (ViewportSwizzle)((Swizzle >> 4) & 7); return (ViewportSwizzle)((Swizzle >> 4) & 7);
} }
@ -149,7 +149,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks viewport swizzle of the position Z component. /// Unpacks viewport swizzle of the position Z component.
/// </summary> /// </summary>
/// <returns>Swizzle enum value</returns> /// <returns>Swizzle enum value</returns>
public ViewportSwizzle UnpackSwizzleZ() public readonly ViewportSwizzle UnpackSwizzleZ()
{ {
return (ViewportSwizzle)((Swizzle >> 8) & 7); return (ViewportSwizzle)((Swizzle >> 8) & 7);
} }
@ -158,7 +158,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks viewport swizzle of the position W component. /// Unpacks viewport swizzle of the position W component.
/// </summary> /// </summary>
/// <returns>Swizzle enum value</returns> /// <returns>Swizzle enum value</returns>
public ViewportSwizzle UnpackSwizzleW() public readonly ViewportSwizzle UnpackSwizzleW()
{ {
return (ViewportSwizzle)((Swizzle >> 12) & 7); return (ViewportSwizzle)((Swizzle >> 12) & 7);
} }
@ -169,7 +169,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct ViewportExtents struct ViewportExtents
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public ushort X; public ushort X;
public ushort Width; public ushort Width;
public ushort Y; public ushort Y;
@ -184,7 +184,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct VertexBufferDrawState struct VertexBufferDrawState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public int First; public int First;
public int Count; public int Count;
#pragma warning restore CS0649 #pragma warning restore CS0649
@ -195,7 +195,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct ClearColors struct ClearColors
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public float Red; public float Red;
public float Green; public float Green;
public float Blue; public float Blue;
@ -208,7 +208,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct DepthBiasState struct DepthBiasState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public Boolean32 PointEnable; public Boolean32 PointEnable;
public Boolean32 LineEnable; public Boolean32 LineEnable;
public Boolean32 FillEnable; public Boolean32 FillEnable;
@ -223,7 +223,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
Disabled = 0, Disabled = 0,
EnableRGB = 1, EnableRGB = 1,
EnableAlpha = 2, EnableAlpha = 2,
EnableRGBA = 3 EnableRGBA = 3,
} }
/// <summary> /// <summary>
@ -231,7 +231,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct ScissorState struct ScissorState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable; public Boolean32 Enable;
public ushort X1; public ushort X1;
public ushort X2; public ushort X2;
@ -246,7 +246,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct StencilBackMasks struct StencilBackMasks
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public int FuncRef; public int FuncRef;
public int Mask; public int Mask;
public int FuncMask; public int FuncMask;
@ -258,7 +258,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct RtDepthStencilState struct RtDepthStencilState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public GpuVa Address; public GpuVa Address;
public ZetaFormat Format; public ZetaFormat Format;
public MemoryLayout MemoryLayout; public MemoryLayout MemoryLayout;
@ -271,7 +271,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct ScreenScissorState struct ScreenScissorState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public ushort X; public ushort X;
public ushort Width; public ushort Width;
public ushort Y; public ushort Y;
@ -297,7 +297,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
Size16 = 0x1b, Size16 = 0x1b,
Size8 = 0x1d, Size8 = 0x1d,
Rgb10A2 = 0x30, Rgb10A2 = 0x30,
Rg11B10 = 0x31 Rg11B10 = 0x31,
} }
/// <summary> /// <summary>
@ -311,7 +311,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
Uint = 4, Uint = 4,
Uscaled = 5, Uscaled = 5,
Sscaled = 6, Sscaled = 6,
Float = 7 Float = 7,
} }
/// <summary> /// <summary>
@ -319,7 +319,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct VertexAttribState struct VertexAttribState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint Attribute; public uint Attribute;
#pragma warning restore CS0649 #pragma warning restore CS0649
@ -327,7 +327,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the index of the vertex buffer this attribute belongs to. /// Unpacks the index of the vertex buffer this attribute belongs to.
/// </summary> /// </summary>
/// <returns>Vertex buffer index</returns> /// <returns>Vertex buffer index</returns>
public int UnpackBufferIndex() public readonly int UnpackBufferIndex()
{ {
return (int)(Attribute & 0x1f); return (int)(Attribute & 0x1f);
} }
@ -336,7 +336,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the attribute constant flag. /// Unpacks the attribute constant flag.
/// </summary> /// </summary>
/// <returns>True if the attribute is constant, false otherwise</returns> /// <returns>True if the attribute is constant, false otherwise</returns>
public bool UnpackIsConstant() public readonly bool UnpackIsConstant()
{ {
return (Attribute & 0x40) != 0; return (Attribute & 0x40) != 0;
} }
@ -345,7 +345,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the offset, in bytes, of the attribute on the vertex buffer. /// Unpacks the offset, in bytes, of the attribute on the vertex buffer.
/// </summary> /// </summary>
/// <returns>Attribute offset in bytes</returns> /// <returns>Attribute offset in bytes</returns>
public int UnpackOffset() public readonly int UnpackOffset()
{ {
return (int)((Attribute >> 7) & 0x3fff); return (int)((Attribute >> 7) & 0x3fff);
} }
@ -354,7 +354,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the Maxwell attribute format integer. /// Unpacks the Maxwell attribute format integer.
/// </summary> /// </summary>
/// <returns>Attribute format integer</returns> /// <returns>Attribute format integer</returns>
public uint UnpackFormat() public readonly uint UnpackFormat()
{ {
return Attribute & 0x3fe00000; return Attribute & 0x3fe00000;
} }
@ -363,7 +363,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the Maxwell attribute size. /// Unpacks the Maxwell attribute size.
/// </summary> /// </summary>
/// <returns>Attribute size</returns> /// <returns>Attribute size</returns>
public VertexAttribSize UnpackSize() public readonly VertexAttribSize UnpackSize()
{ {
return (VertexAttribSize)((Attribute >> 21) & 0x3f); return (VertexAttribSize)((Attribute >> 21) & 0x3f);
} }
@ -372,7 +372,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the Maxwell attribute component type. /// Unpacks the Maxwell attribute component type.
/// </summary> /// </summary>
/// <returns>Attribute component type</returns> /// <returns>Attribute component type</returns>
public VertexAttribType UnpackType() public readonly VertexAttribType UnpackType()
{ {
return (VertexAttribType)((Attribute >> 27) & 7); return (VertexAttribType)((Attribute >> 27) & 7);
} }
@ -383,7 +383,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct RtControl struct RtControl
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint Packed; public uint Packed;
#pragma warning restore CS0649 #pragma warning restore CS0649
@ -391,7 +391,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the number of active draw buffers. /// Unpacks the number of active draw buffers.
/// </summary> /// </summary>
/// <returns>Number of active draw buffers</returns> /// <returns>Number of active draw buffers</returns>
public int UnpackCount() public readonly int UnpackCount()
{ {
return (int)(Packed & 0xf); return (int)(Packed & 0xf);
} }
@ -401,7 +401,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
/// <param name="index">Index of the draw buffer</param> /// <param name="index">Index of the draw buffer</param>
/// <returns>Attachment index</returns> /// <returns>Attachment index</returns>
public int UnpackPermutationIndex(int index) public readonly int UnpackPermutationIndex(int index)
{ {
return (int)((Packed >> (4 + index * 3)) & 7); return (int)((Packed >> (4 + index * 3)) & 7);
} }
@ -412,7 +412,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct Size3D struct Size3D
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public int Width; public int Width;
public int Height; public int Height;
public int Depth; public int Depth;
@ -424,7 +424,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct StencilTestState struct StencilTestState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable; public Boolean32 Enable;
public StencilOp FrontSFail; public StencilOp FrontSFail;
public StencilOp FrontDpFail; public StencilOp FrontDpFail;
@ -443,7 +443,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
enum YControl enum YControl
{ {
NegateY = 1 << 0, NegateY = 1 << 0,
TriangleRastFlip = 1 << 4 TriangleRastFlip = 1 << 4,
} }
/// <summary> /// <summary>
@ -451,7 +451,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct RgbHalf struct RgbHalf
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint R; public uint R;
public uint G; public uint G;
public uint B; public uint B;
@ -462,7 +462,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the red color component as a 16-bit float value. /// Unpacks the red color component as a 16-bit float value.
/// </summary> /// </summary>
/// <returns>The component value</returns> /// <returns>The component value</returns>
public Half UnpackR() public readonly Half UnpackR()
{ {
ushort value = (ushort)R; ushort value = (ushort)R;
return Unsafe.As<ushort, Half>(ref value); return Unsafe.As<ushort, Half>(ref value);
@ -472,7 +472,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the green color component as a 16-bit float value. /// Unpacks the green color component as a 16-bit float value.
/// </summary> /// </summary>
/// <returns>The component value</returns> /// <returns>The component value</returns>
public Half UnpackG() public readonly Half UnpackG()
{ {
ushort value = (ushort)G; ushort value = (ushort)G;
return Unsafe.As<ushort, Half>(ref value); return Unsafe.As<ushort, Half>(ref value);
@ -482,7 +482,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks the blue color component as a 16-bit float value. /// Unpacks the blue color component as a 16-bit float value.
/// </summary> /// </summary>
/// <returns>The component value</returns> /// <returns>The component value</returns>
public Half UnpackB() public readonly Half UnpackB()
{ {
ushort value = (ushort)B; ushort value = (ushort)B;
return Unsafe.As<ushort, Half>(ref value); return Unsafe.As<ushort, Half>(ref value);
@ -498,7 +498,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
Always, Always,
ResultNonZero, ResultNonZero,
Equal, Equal,
NotEqual NotEqual,
} }
/// <summary> /// <summary>
@ -506,7 +506,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct PoolState struct PoolState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public GpuVa Address; public GpuVa Address;
public int MaximumId; public int MaximumId;
#pragma warning restore CS0649 #pragma warning restore CS0649
@ -517,7 +517,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct StencilBackTestState struct StencilBackTestState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public Boolean32 TwoSided; public Boolean32 TwoSided;
public StencilOp BackSFail; public StencilOp BackSFail;
public StencilOp BackDpFail; public StencilOp BackDpFail;
@ -531,7 +531,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct PrimitiveRestartState struct PrimitiveRestartState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable; public Boolean32 Enable;
public int Index; public int Index;
#pragma warning restore CS0649 #pragma warning restore CS0649
@ -543,7 +543,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct IndexBufferState struct IndexBufferState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public GpuVa Address; public GpuVa Address;
public GpuVa EndAddress; public GpuVa EndAddress;
public IndexType Type; public IndexType Type;
@ -556,7 +556,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct FaceState struct FaceState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public Boolean32 CullEnable; public Boolean32 CullEnable;
public FrontFace FrontFace; public FrontFace FrontFace;
public Face CullFace; public Face CullFace;
@ -570,7 +570,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
enum ViewVolumeClipControl enum ViewVolumeClipControl
{ {
ForceDepthRangeZeroToOne = 1 << 0, ForceDepthRangeZeroToOne = 1 << 0,
DepthClampDisabled = 1 << 11 DepthClampDisabled = 1 << 11,
} }
/// <summary> /// <summary>
@ -578,7 +578,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct LogicalOpState struct LogicalOpState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public Boolean32 Enable; public Boolean32 Enable;
public LogicalOp LogicalOp; public LogicalOp LogicalOp;
#pragma warning restore CS0649 #pragma warning restore CS0649
@ -590,7 +590,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct RtColorMask struct RtColorMask
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint Packed; public uint Packed;
#pragma warning restore CS0649 #pragma warning restore CS0649
@ -598,7 +598,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks red channel enable. /// Unpacks red channel enable.
/// </summary> /// </summary>
/// <returns>True to write the new red channel color, false to keep the old value</returns> /// <returns>True to write the new red channel color, false to keep the old value</returns>
public bool UnpackRed() public readonly bool UnpackRed()
{ {
return (Packed & 0x1) != 0; return (Packed & 0x1) != 0;
} }
@ -607,7 +607,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks green channel enable. /// Unpacks green channel enable.
/// </summary> /// </summary>
/// <returns>True to write the new green channel color, false to keep the old value</returns> /// <returns>True to write the new green channel color, false to keep the old value</returns>
public bool UnpackGreen() public readonly bool UnpackGreen()
{ {
return (Packed & 0x10) != 0; return (Packed & 0x10) != 0;
} }
@ -616,7 +616,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks blue channel enable. /// Unpacks blue channel enable.
/// </summary> /// </summary>
/// <returns>True to write the new blue channel color, false to keep the old value</returns> /// <returns>True to write the new blue channel color, false to keep the old value</returns>
public bool UnpackBlue() public readonly bool UnpackBlue()
{ {
return (Packed & 0x100) != 0; return (Packed & 0x100) != 0;
} }
@ -625,7 +625,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Unpacks alpha channel enable. /// Unpacks alpha channel enable.
/// </summary> /// </summary>
/// <returns>True to write the new alpha channel color, false to keep the old value</returns> /// <returns>True to write the new alpha channel color, false to keep the old value</returns>
public bool UnpackAlpha() public readonly bool UnpackAlpha()
{ {
return (Packed & 0x1000) != 0; return (Packed & 0x1000) != 0;
} }
@ -636,7 +636,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct VertexBufferState struct VertexBufferState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint Control; public uint Control;
public GpuVa Address; public GpuVa Address;
public int Divisor; public int Divisor;
@ -646,7 +646,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Vertex buffer stride, defined as the number of bytes occupied by each vertex in memory. /// Vertex buffer stride, defined as the number of bytes occupied by each vertex in memory.
/// </summary> /// </summary>
/// <returns>Vertex buffer stride</returns> /// <returns>Vertex buffer stride</returns>
public int UnpackStride() public readonly int UnpackStride()
{ {
return (int)(Control & 0xfff); return (int)(Control & 0xfff);
} }
@ -655,7 +655,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Vertex buffer enable. /// Vertex buffer enable.
/// </summary> /// </summary>
/// <returns>True if the vertex buffer is enabled, false otherwise</returns> /// <returns>True if the vertex buffer is enabled, false otherwise</returns>
public bool UnpackEnable() public readonly bool UnpackEnable()
{ {
return (Control & (1 << 12)) != 0; return (Control & (1 << 12)) != 0;
} }
@ -666,7 +666,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct BlendStateCommon struct BlendStateCommon
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public Boolean32 SeparateAlpha; public Boolean32 SeparateAlpha;
public BlendOp ColorOp; public BlendOp ColorOp;
public BlendFactor ColorSrcFactor; public BlendFactor ColorSrcFactor;
@ -683,7 +683,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct BlendState struct BlendState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public Boolean32 SeparateAlpha; public Boolean32 SeparateAlpha;
public BlendOp ColorOp; public BlendOp ColorOp;
public BlendFactor ColorSrcFactor; public BlendFactor ColorSrcFactor;
@ -700,7 +700,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct ShaderState struct ShaderState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint Control; public uint Control;
public uint Offset; public uint Offset;
public uint Unknown0x8; public uint Unknown0x8;
@ -724,7 +724,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// Must be ignored for vertex shaders, those are always enabled. /// Must be ignored for vertex shaders, those are always enabled.
/// </summary> /// </summary>
/// <returns>True if the stage is enabled, false otherwise</returns> /// <returns>True if the stage is enabled, false otherwise</returns>
public bool UnpackEnable() public readonly bool UnpackEnable()
{ {
return (Control & 1) != 0; return (Control & 1) != 0;
} }
@ -735,7 +735,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
/// </summary> /// </summary>
struct UniformBufferState struct UniformBufferState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public int Size; public int Size;
public GpuVa Address; public GpuVa Address;
public int Offset; public int Offset;
@ -744,30 +744,30 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
unsafe struct ThreedClassState : IShadowState unsafe struct ThreedClassState : IShadowState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint SetObject; public uint SetObject;
public int SetObjectClassId => (int)(SetObject & 0xFFFF); public readonly int SetObjectClassId => (int)(SetObject & 0xFFFF);
public int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F); public readonly int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
public fixed uint Reserved04[63]; public fixed uint Reserved04[63];
public uint NoOperation; public uint NoOperation;
public uint SetNotifyA; public uint SetNotifyA;
public int SetNotifyAAddressUpper => (int)(SetNotifyA & 0xFF); public readonly int SetNotifyAAddressUpper => (int)(SetNotifyA & 0xFF);
public uint SetNotifyB; public uint SetNotifyB;
public uint Notify; public uint Notify;
public NotifyType NotifyType => (NotifyType)(Notify); public readonly NotifyType NotifyType => (NotifyType)(Notify);
public uint WaitForIdle; public uint WaitForIdle;
public uint LoadMmeInstructionRamPointer; public uint LoadMmeInstructionRamPointer;
public uint LoadMmeInstructionRam; public uint LoadMmeInstructionRam;
public uint LoadMmeStartAddressRamPointer; public uint LoadMmeStartAddressRamPointer;
public uint LoadMmeStartAddressRam; public uint LoadMmeStartAddressRam;
public uint SetMmeShadowRamControl; public uint SetMmeShadowRamControl;
public SetMmeShadowRamControlMode SetMmeShadowRamControlMode => (SetMmeShadowRamControlMode)(SetMmeShadowRamControl & 0x3); public readonly SetMmeShadowRamControlMode SetMmeShadowRamControlMode => (SetMmeShadowRamControlMode)(SetMmeShadowRamControl & 0x3);
public fixed uint Reserved128[2]; public fixed uint Reserved128[2];
public uint SetGlobalRenderEnableA; public uint SetGlobalRenderEnableA;
public int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF); public readonly int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
public uint SetGlobalRenderEnableB; public uint SetGlobalRenderEnableB;
public uint SetGlobalRenderEnableC; public uint SetGlobalRenderEnableC;
public int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7); public readonly int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
public uint SendGoIdle; public uint SendGoIdle;
public uint PmTrigger; public uint PmTrigger;
public uint PmTriggerWfi; public uint PmTriggerWfi;
@ -778,30 +778,30 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
public uint LineLengthIn; public uint LineLengthIn;
public uint LineCount; public uint LineCount;
public uint OffsetOutUpper; public uint OffsetOutUpper;
public int OffsetOutUpperValue => (int)(OffsetOutUpper & 0xFF); public readonly int OffsetOutUpperValue => (int)(OffsetOutUpper & 0xFF);
public uint OffsetOut; public uint OffsetOut;
public uint PitchOut; public uint PitchOut;
public uint SetDstBlockSize; public uint SetDstBlockSize;
public SetDstBlockSizeWidth SetDstBlockSizeWidth => (SetDstBlockSizeWidth)(SetDstBlockSize & 0xF); public readonly SetDstBlockSizeWidth SetDstBlockSizeWidth => (SetDstBlockSizeWidth)(SetDstBlockSize & 0xF);
public SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF); public readonly SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0xF);
public SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF); public readonly SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0xF);
public uint SetDstWidth; public uint SetDstWidth;
public uint SetDstHeight; public uint SetDstHeight;
public uint SetDstDepth; public uint SetDstDepth;
public uint SetDstLayer; public uint SetDstLayer;
public uint SetDstOriginBytesX; public uint SetDstOriginBytesX;
public int SetDstOriginBytesXV => (int)(SetDstOriginBytesX & 0xFFFFF); public readonly int SetDstOriginBytesXV => (int)(SetDstOriginBytesX & 0xFFFFF);
public uint SetDstOriginSamplesY; public uint SetDstOriginSamplesY;
public int SetDstOriginSamplesYV => (int)(SetDstOriginSamplesY & 0xFFFF); public readonly int SetDstOriginSamplesYV => (int)(SetDstOriginSamplesY & 0xFFFF);
public uint LaunchDma; public uint LaunchDma;
public LaunchDmaDstMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaDstMemoryLayout)(LaunchDma & 0x1); public readonly LaunchDmaDstMemoryLayout LaunchDmaDstMemoryLayout => (LaunchDmaDstMemoryLayout)(LaunchDma & 0x1);
public LaunchDmaCompletionType LaunchDmaCompletionType => (LaunchDmaCompletionType)((LaunchDma >> 4) & 0x3); public readonly LaunchDmaCompletionType LaunchDmaCompletionType => (LaunchDmaCompletionType)((LaunchDma >> 4) & 0x3);
public LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 8) & 0x3); public readonly LaunchDmaInterruptType LaunchDmaInterruptType => (LaunchDmaInterruptType)((LaunchDma >> 8) & 0x3);
public LaunchDmaSemaphoreStructSize LaunchDmaSemaphoreStructSize => (LaunchDmaSemaphoreStructSize)((LaunchDma >> 12) & 0x1); public readonly LaunchDmaSemaphoreStructSize LaunchDmaSemaphoreStructSize => (LaunchDmaSemaphoreStructSize)((LaunchDma >> 12) & 0x1);
public bool LaunchDmaReductionEnable => (LaunchDma & 0x2) != 0; public readonly bool LaunchDmaReductionEnable => (LaunchDma & 0x2) != 0;
public LaunchDmaReductionOp LaunchDmaReductionOp => (LaunchDmaReductionOp)((LaunchDma >> 13) & 0x7); public readonly LaunchDmaReductionOp LaunchDmaReductionOp => (LaunchDmaReductionOp)((LaunchDma >> 13) & 0x7);
public LaunchDmaReductionFormat LaunchDmaReductionFormat => (LaunchDmaReductionFormat)((LaunchDma >> 2) & 0x3); public readonly LaunchDmaReductionFormat LaunchDmaReductionFormat => (LaunchDmaReductionFormat)((LaunchDma >> 2) & 0x3);
public bool LaunchDmaSysmembarDisable => (LaunchDma & 0x40) != 0; public readonly bool LaunchDmaSysmembarDisable => (LaunchDma & 0x40) != 0;
public uint LoadInlineData; public uint LoadInlineData;
public fixed uint Reserved1B8[22]; public fixed uint Reserved1B8[22];
public Boolean32 EarlyZForce; public Boolean32 EarlyZForce;
@ -1042,7 +1042,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
public fixed uint Reserved260C[125]; public fixed uint Reserved260C[125];
public Array4<Array32<uint>> TfVaryingLocations; public Array4<Array32<uint>> TfVaryingLocations;
public fixed uint Reserved2A00[640]; public fixed uint Reserved2A00[640];
public MmeShadowScratch SetMmeShadowScratch; public Array256<uint> SetMmeShadowScratch;
#pragma warning restore CS0649 #pragma warning restore CS0649
} }
} }

View file

@ -30,7 +30,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
_channel = channel; _channel = channel;
_state = new DeviceState<TwodClassState>(new Dictionary<string, RwCallback> _state = new DeviceState<TwodClassState>(new Dictionary<string, RwCallback>
{ {
{ nameof(TwodClassState.PixelsFromMemorySrcY0Int), new RwCallback(PixelsFromMemorySrcY0Int, null) } { nameof(TwodClassState.PixelsFromMemorySrcY0Int), new RwCallback(PixelsFromMemorySrcY0Int, null) },
}); });
} }
@ -57,7 +57,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
/// <param name="lhsFormat">Format of the first texture</param> /// <param name="lhsFormat">Format of the first texture</param>
/// <param name="rhsFormat">Format of the second texture</param> /// <param name="rhsFormat">Format of the second texture</param>
/// <returns>True if the data is compatible, false otherwise</returns> /// <returns>True if the data is compatible, false otherwise</returns>
private bool IsDataCompatible(TwodTexture lhs, TwodTexture rhs, FormatInfo lhsFormat, FormatInfo rhsFormat) private static bool IsDataCompatible(TwodTexture lhs, TwodTexture rhs, FormatInfo lhsFormat, FormatInfo rhsFormat)
{ {
if (lhsFormat.BytesPerPixel != rhsFormat.BytesPerPixel || if (lhsFormat.BytesPerPixel != rhsFormat.BytesPerPixel ||
lhs.Height != rhs.Height || lhs.Height != rhs.Height ||
@ -88,7 +88,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
/// <param name="x2">Region end x</param> /// <param name="x2">Region end x</param>
/// <param name="y2">Region end y</param> /// <param name="y2">Region end y</param>
/// <returns>True if the region covers the full texture, false otherwise</returns> /// <returns>True if the region covers the full texture, false otherwise</returns>
private bool IsCopyRegionComplete(TwodTexture texture, FormatInfo formatInfo, int x1, int y1, int x2, int y2) private static bool IsCopyRegionComplete(TwodTexture texture, FormatInfo formatInfo, int x1, int y1, int x2, int y2)
{ {
if (x1 != 0 || y1 != 0 || y2 != texture.Height) if (x1 != 0 || y1 != 0 || y2 != texture.Height)
{ {
@ -172,7 +172,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
srcSpan.Slice(offset, lineSize).CopyTo(dstSpan.Slice(offset)); srcSpan.Slice(offset, lineSize).CopyTo(dstSpan[offset..]);
offset += stride; offset += stride;
} }
@ -364,13 +364,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
float scale = srcTexture.ScaleFactor; float scale = srcTexture.ScaleFactor;
float dstScale = dstTexture.ScaleFactor; float dstScale = dstTexture.ScaleFactor;
Extents2D srcRegion = new Extents2D( Extents2D srcRegion = new(
(int)Math.Ceiling(scale * (srcX1 / srcTexture.Info.SamplesInX)), (int)Math.Ceiling(scale * (srcX1 / srcTexture.Info.SamplesInX)),
(int)Math.Ceiling(scale * (srcY1 / srcTexture.Info.SamplesInY)), (int)Math.Ceiling(scale * (srcY1 / srcTexture.Info.SamplesInY)),
(int)Math.Ceiling(scale * (srcX2 / srcTexture.Info.SamplesInX)), (int)Math.Ceiling(scale * (srcX2 / srcTexture.Info.SamplesInX)),
(int)Math.Ceiling(scale * (srcY2 / srcTexture.Info.SamplesInY))); (int)Math.Ceiling(scale * (srcY2 / srcTexture.Info.SamplesInY)));
Extents2D dstRegion = new Extents2D( Extents2D dstRegion = new(
(int)Math.Ceiling(dstScale * (dstX1 / dstTexture.Info.SamplesInX)), (int)Math.Ceiling(dstScale * (dstX1 / dstTexture.Info.SamplesInX)),
(int)Math.Ceiling(dstScale * (dstY1 / dstTexture.Info.SamplesInY)), (int)Math.Ceiling(dstScale * (dstY1 / dstTexture.Info.SamplesInY)),
(int)Math.Ceiling(dstScale * (dstX2 / dstTexture.Info.SamplesInX)), (int)Math.Ceiling(dstScale * (dstX2 / dstTexture.Info.SamplesInX)),

View file

@ -486,7 +486,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
/// </summary> /// </summary>
struct RenderSolidPrimPoint struct RenderSolidPrimPoint
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint SetX; public uint SetX;
public uint Y; public uint Y;
#pragma warning restore CS0649 #pragma warning restore CS0649
@ -497,30 +497,30 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
/// </summary> /// </summary>
unsafe struct TwodClassState : IShadowState unsafe struct TwodClassState : IShadowState
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint SetObject; public uint SetObject;
public int SetObjectClassId => (int)(SetObject & 0xFFFF); public readonly int SetObjectClassId => (int)(SetObject & 0xFFFF);
public int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F); public readonly int SetObjectEngineId => (int)((SetObject >> 16) & 0x1F);
public fixed uint Reserved04[63]; public fixed uint Reserved04[63];
public uint NoOperation; public uint NoOperation;
public uint SetNotifyA; public uint SetNotifyA;
public int SetNotifyAAddressUpper => (int)(SetNotifyA & 0x1FFFFFF); public readonly int SetNotifyAAddressUpper => (int)(SetNotifyA & 0x1FFFFFF);
public uint SetNotifyB; public uint SetNotifyB;
public uint Notify; public uint Notify;
public NotifyType NotifyType => (NotifyType)(Notify); public readonly NotifyType NotifyType => (NotifyType)(Notify);
public uint WaitForIdle; public uint WaitForIdle;
public uint LoadMmeInstructionRamPointer; public uint LoadMmeInstructionRamPointer;
public uint LoadMmeInstructionRam; public uint LoadMmeInstructionRam;
public uint LoadMmeStartAddressRamPointer; public uint LoadMmeStartAddressRamPointer;
public uint LoadMmeStartAddressRam; public uint LoadMmeStartAddressRam;
public uint SetMmeShadowRamControl; public uint SetMmeShadowRamControl;
public SetMmeShadowRamControlMode SetMmeShadowRamControlMode => (SetMmeShadowRamControlMode)(SetMmeShadowRamControl & 0x3); public readonly SetMmeShadowRamControlMode SetMmeShadowRamControlMode => (SetMmeShadowRamControlMode)(SetMmeShadowRamControl & 0x3);
public fixed uint Reserved128[2]; public fixed uint Reserved128[2];
public uint SetGlobalRenderEnableA; public uint SetGlobalRenderEnableA;
public int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF); public readonly int SetGlobalRenderEnableAOffsetUpper => (int)(SetGlobalRenderEnableA & 0xFF);
public uint SetGlobalRenderEnableB; public uint SetGlobalRenderEnableB;
public uint SetGlobalRenderEnableC; public uint SetGlobalRenderEnableC;
public int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7); public readonly int SetGlobalRenderEnableCMode => (int)(SetGlobalRenderEnableC & 0x7);
public uint SendGoIdle; public uint SendGoIdle;
public uint PmTrigger; public uint PmTrigger;
public fixed uint Reserved144[3]; public fixed uint Reserved144[3];
@ -528,54 +528,54 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public uint SetInstrumentationMethodData; public uint SetInstrumentationMethodData;
public fixed uint Reserved158[37]; public fixed uint Reserved158[37];
public uint SetMmeSwitchState; public uint SetMmeSwitchState;
public bool SetMmeSwitchStateValid => (SetMmeSwitchState & 0x1) != 0; public readonly bool SetMmeSwitchStateValid => (SetMmeSwitchState & 0x1) != 0;
public int SetMmeSwitchStateSaveMacro => (int)((SetMmeSwitchState >> 4) & 0xFF); public readonly int SetMmeSwitchStateSaveMacro => (int)((SetMmeSwitchState >> 4) & 0xFF);
public int SetMmeSwitchStateRestoreMacro => (int)((SetMmeSwitchState >> 12) & 0xFF); public readonly int SetMmeSwitchStateRestoreMacro => (int)((SetMmeSwitchState >> 12) & 0xFF);
public fixed uint Reserved1F0[4]; public fixed uint Reserved1F0[4];
public uint SetDstFormat; public uint SetDstFormat;
public SetDstFormatV SetDstFormatV => (SetDstFormatV)(SetDstFormat & 0xFF); public readonly SetDstFormatV SetDstFormatV => (SetDstFormatV)(SetDstFormat & 0xFF);
public uint SetDstMemoryLayout; public uint SetDstMemoryLayout;
public SetDstMemoryLayoutV SetDstMemoryLayoutV => (SetDstMemoryLayoutV)(SetDstMemoryLayout & 0x1); public readonly SetDstMemoryLayoutV SetDstMemoryLayoutV => (SetDstMemoryLayoutV)(SetDstMemoryLayout & 0x1);
public uint SetDstBlockSize; public uint SetDstBlockSize;
public SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0x7); public readonly SetDstBlockSizeHeight SetDstBlockSizeHeight => (SetDstBlockSizeHeight)((SetDstBlockSize >> 4) & 0x7);
public SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0x7); public readonly SetDstBlockSizeDepth SetDstBlockSizeDepth => (SetDstBlockSizeDepth)((SetDstBlockSize >> 8) & 0x7);
public uint SetDstDepth; public uint SetDstDepth;
public uint SetDstLayer; public uint SetDstLayer;
public uint SetDstPitch; public uint SetDstPitch;
public uint SetDstWidth; public uint SetDstWidth;
public uint SetDstHeight; public uint SetDstHeight;
public uint SetDstOffsetUpper; public uint SetDstOffsetUpper;
public int SetDstOffsetUpperV => (int)(SetDstOffsetUpper & 0xFF); public readonly int SetDstOffsetUpperV => (int)(SetDstOffsetUpper & 0xFF);
public uint SetDstOffsetLower; public uint SetDstOffsetLower;
public uint FlushAndInvalidateRopMiniCache; public uint FlushAndInvalidateRopMiniCache;
public bool FlushAndInvalidateRopMiniCacheV => (FlushAndInvalidateRopMiniCache & 0x1) != 0; public readonly bool FlushAndInvalidateRopMiniCacheV => (FlushAndInvalidateRopMiniCache & 0x1) != 0;
public uint SetSpareNoop06; public uint SetSpareNoop06;
public uint SetSrcFormat; public uint SetSrcFormat;
public SetSrcFormatV SetSrcFormatV => (SetSrcFormatV)(SetSrcFormat & 0xFF); public readonly SetSrcFormatV SetSrcFormatV => (SetSrcFormatV)(SetSrcFormat & 0xFF);
public uint SetSrcMemoryLayout; public uint SetSrcMemoryLayout;
public SetSrcMemoryLayoutV SetSrcMemoryLayoutV => (SetSrcMemoryLayoutV)(SetSrcMemoryLayout & 0x1); public readonly SetSrcMemoryLayoutV SetSrcMemoryLayoutV => (SetSrcMemoryLayoutV)(SetSrcMemoryLayout & 0x1);
public uint SetSrcBlockSize; public uint SetSrcBlockSize;
public SetSrcBlockSizeHeight SetSrcBlockSizeHeight => (SetSrcBlockSizeHeight)((SetSrcBlockSize >> 4) & 0x7); public readonly SetSrcBlockSizeHeight SetSrcBlockSizeHeight => (SetSrcBlockSizeHeight)((SetSrcBlockSize >> 4) & 0x7);
public SetSrcBlockSizeDepth SetSrcBlockSizeDepth => (SetSrcBlockSizeDepth)((SetSrcBlockSize >> 8) & 0x7); public readonly SetSrcBlockSizeDepth SetSrcBlockSizeDepth => (SetSrcBlockSizeDepth)((SetSrcBlockSize >> 8) & 0x7);
public uint SetSrcDepth; public uint SetSrcDepth;
public uint TwodInvalidateTextureDataCache; public uint TwodInvalidateTextureDataCache;
public TwodInvalidateTextureDataCacheV TwodInvalidateTextureDataCacheV => (TwodInvalidateTextureDataCacheV)(TwodInvalidateTextureDataCache & 0x3); public readonly TwodInvalidateTextureDataCacheV TwodInvalidateTextureDataCacheV => (TwodInvalidateTextureDataCacheV)(TwodInvalidateTextureDataCache & 0x3);
public uint SetSrcPitch; public uint SetSrcPitch;
public uint SetSrcWidth; public uint SetSrcWidth;
public uint SetSrcHeight; public uint SetSrcHeight;
public uint SetSrcOffsetUpper; public uint SetSrcOffsetUpper;
public int SetSrcOffsetUpperV => (int)(SetSrcOffsetUpper & 0xFF); public readonly int SetSrcOffsetUpperV => (int)(SetSrcOffsetUpper & 0xFF);
public uint SetSrcOffsetLower; public uint SetSrcOffsetLower;
public uint SetPixelsFromMemorySectorPromotion; public uint SetPixelsFromMemorySectorPromotion;
public SetPixelsFromMemorySectorPromotionV SetPixelsFromMemorySectorPromotionV => (SetPixelsFromMemorySectorPromotionV)(SetPixelsFromMemorySectorPromotion & 0x3); public readonly SetPixelsFromMemorySectorPromotionV SetPixelsFromMemorySectorPromotionV => (SetPixelsFromMemorySectorPromotionV)(SetPixelsFromMemorySectorPromotion & 0x3);
public uint SetSpareNoop12; public uint SetSpareNoop12;
public uint SetNumProcessingClusters; public uint SetNumProcessingClusters;
public SetNumProcessingClustersV SetNumProcessingClustersV => (SetNumProcessingClustersV)(SetNumProcessingClusters & 0x1); public readonly SetNumProcessingClustersV SetNumProcessingClustersV => (SetNumProcessingClustersV)(SetNumProcessingClusters & 0x1);
public uint SetRenderEnableA; public uint SetRenderEnableA;
public int SetRenderEnableAOffsetUpper => (int)(SetRenderEnableA & 0xFF); public readonly int SetRenderEnableAOffsetUpper => (int)(SetRenderEnableA & 0xFF);
public uint SetRenderEnableB; public uint SetRenderEnableB;
public uint SetRenderEnableC; public uint SetRenderEnableC;
public int SetRenderEnableCMode => (int)(SetRenderEnableC & 0x7); public readonly int SetRenderEnableCMode => (int)(SetRenderEnableC & 0x7);
public uint SetSpareNoop08; public uint SetSpareNoop08;
public uint SetSpareNoop01; public uint SetSpareNoop01;
public uint SetSpareNoop11; public uint SetSpareNoop11;
@ -585,29 +585,29 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public uint SetClipWidth; public uint SetClipWidth;
public uint SetClipHeight; public uint SetClipHeight;
public uint SetClipEnable; public uint SetClipEnable;
public bool SetClipEnableV => (SetClipEnable & 0x1) != 0; public readonly bool SetClipEnableV => (SetClipEnable & 0x1) != 0;
public uint SetColorKeyFormat; public uint SetColorKeyFormat;
public SetColorKeyFormatV SetColorKeyFormatV => (SetColorKeyFormatV)(SetColorKeyFormat & 0x7); public readonly SetColorKeyFormatV SetColorKeyFormatV => (SetColorKeyFormatV)(SetColorKeyFormat & 0x7);
public uint SetColorKey; public uint SetColorKey;
public uint SetColorKeyEnable; public uint SetColorKeyEnable;
public bool SetColorKeyEnableV => (SetColorKeyEnable & 0x1) != 0; public readonly bool SetColorKeyEnableV => (SetColorKeyEnable & 0x1) != 0;
public uint SetRop; public uint SetRop;
public int SetRopV => (int)(SetRop & 0xFF); public readonly int SetRopV => (int)(SetRop & 0xFF);
public uint SetBeta1; public uint SetBeta1;
public uint SetBeta4; public uint SetBeta4;
public int SetBeta4B => (int)(SetBeta4 & 0xFF); public readonly int SetBeta4B => (int)(SetBeta4 & 0xFF);
public int SetBeta4G => (int)((SetBeta4 >> 8) & 0xFF); public readonly int SetBeta4G => (int)((SetBeta4 >> 8) & 0xFF);
public int SetBeta4R => (int)((SetBeta4 >> 16) & 0xFF); public readonly int SetBeta4R => (int)((SetBeta4 >> 16) & 0xFF);
public int SetBeta4A => (int)((SetBeta4 >> 24) & 0xFF); public readonly int SetBeta4A => (int)((SetBeta4 >> 24) & 0xFF);
public uint SetOperation; public uint SetOperation;
public SetOperationV SetOperationV => (SetOperationV)(SetOperation & 0x7); public readonly SetOperationV SetOperationV => (SetOperationV)(SetOperation & 0x7);
public uint SetPatternOffset; public uint SetPatternOffset;
public int SetPatternOffsetX => (int)(SetPatternOffset & 0x3F); public readonly int SetPatternOffsetX => (int)(SetPatternOffset & 0x3F);
public int SetPatternOffsetY => (int)((SetPatternOffset >> 8) & 0x3F); public readonly int SetPatternOffsetY => (int)((SetPatternOffset >> 8) & 0x3F);
public uint SetPatternSelect; public uint SetPatternSelect;
public SetPatternSelectV SetPatternSelectV => (SetPatternSelectV)(SetPatternSelect & 0x3); public readonly SetPatternSelectV SetPatternSelectV => (SetPatternSelectV)(SetPatternSelect & 0x3);
public uint SetDstColorRenderToZetaSurface; public uint SetDstColorRenderToZetaSurface;
public bool SetDstColorRenderToZetaSurfaceV => (SetDstColorRenderToZetaSurface & 0x1) != 0; public readonly bool SetDstColorRenderToZetaSurfaceV => (SetDstColorRenderToZetaSurface & 0x1) != 0;
public uint SetSpareNoop04; public uint SetSpareNoop04;
public uint SetSpareNoop15; public uint SetSpareNoop15;
public uint SetSpareNoop13; public uint SetSpareNoop13;
@ -615,18 +615,18 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public uint SetSpareNoop14; public uint SetSpareNoop14;
public uint SetSpareNoop02; public uint SetSpareNoop02;
public uint SetCompression; public uint SetCompression;
public bool SetCompressionEnable => (SetCompression & 0x1) != 0; public readonly bool SetCompressionEnable => (SetCompression & 0x1) != 0;
public uint SetSpareNoop09; public uint SetSpareNoop09;
public uint SetRenderEnableOverride; public uint SetRenderEnableOverride;
public SetRenderEnableOverrideMode SetRenderEnableOverrideMode => (SetRenderEnableOverrideMode)(SetRenderEnableOverride & 0x3); public readonly SetRenderEnableOverrideMode SetRenderEnableOverrideMode => (SetRenderEnableOverrideMode)(SetRenderEnableOverride & 0x3);
public uint SetPixelsFromMemoryDirection; public uint SetPixelsFromMemoryDirection;
public SetPixelsFromMemoryDirectionHorizontal SetPixelsFromMemoryDirectionHorizontal => (SetPixelsFromMemoryDirectionHorizontal)(SetPixelsFromMemoryDirection & 0x3); public readonly SetPixelsFromMemoryDirectionHorizontal SetPixelsFromMemoryDirectionHorizontal => (SetPixelsFromMemoryDirectionHorizontal)(SetPixelsFromMemoryDirection & 0x3);
public SetPixelsFromMemoryDirectionVertical SetPixelsFromMemoryDirectionVertical => (SetPixelsFromMemoryDirectionVertical)((SetPixelsFromMemoryDirection >> 4) & 0x3); public readonly SetPixelsFromMemoryDirectionVertical SetPixelsFromMemoryDirectionVertical => (SetPixelsFromMemoryDirectionVertical)((SetPixelsFromMemoryDirection >> 4) & 0x3);
public uint SetSpareNoop10; public uint SetSpareNoop10;
public uint SetMonochromePatternColorFormat; public uint SetMonochromePatternColorFormat;
public SetMonochromePatternColorFormatV SetMonochromePatternColorFormatV => (SetMonochromePatternColorFormatV)(SetMonochromePatternColorFormat & 0x7); public readonly SetMonochromePatternColorFormatV SetMonochromePatternColorFormatV => (SetMonochromePatternColorFormatV)(SetMonochromePatternColorFormat & 0x7);
public uint SetMonochromePatternFormat; public uint SetMonochromePatternFormat;
public SetMonochromePatternFormatV SetMonochromePatternFormatV => (SetMonochromePatternFormatV)(SetMonochromePatternFormat & 0x1); public readonly SetMonochromePatternFormatV SetMonochromePatternFormatV => (SetMonochromePatternFormatV)(SetMonochromePatternFormat & 0x1);
public uint SetMonochromePatternColor0; public uint SetMonochromePatternColor0;
public uint SetMonochromePatternColor1; public uint SetMonochromePatternColor1;
public uint SetMonochromePattern0; public uint SetMonochromePattern0;
@ -662,52 +662,52 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public uint SetRenderSolidPrimColor2; public uint SetRenderSolidPrimColor2;
public uint SetRenderSolidPrimColor3; public uint SetRenderSolidPrimColor3;
public uint SetMmeMemAddressA; public uint SetMmeMemAddressA;
public int SetMmeMemAddressAUpper => (int)(SetMmeMemAddressA & 0x1FFFFFF); public readonly int SetMmeMemAddressAUpper => (int)(SetMmeMemAddressA & 0x1FFFFFF);
public uint SetMmeMemAddressB; public uint SetMmeMemAddressB;
public uint SetMmeDataRamAddress; public uint SetMmeDataRamAddress;
public uint MmeDmaRead; public uint MmeDmaRead;
public uint MmeDmaReadFifoed; public uint MmeDmaReadFifoed;
public uint MmeDmaWrite; public uint MmeDmaWrite;
public uint MmeDmaReduction; public uint MmeDmaReduction;
public MmeDmaReductionReductionOp MmeDmaReductionReductionOp => (MmeDmaReductionReductionOp)(MmeDmaReduction & 0x7); public readonly MmeDmaReductionReductionOp MmeDmaReductionReductionOp => (MmeDmaReductionReductionOp)(MmeDmaReduction & 0x7);
public MmeDmaReductionReductionFormat MmeDmaReductionReductionFormat => (MmeDmaReductionReductionFormat)((MmeDmaReduction >> 4) & 0x3); public readonly MmeDmaReductionReductionFormat MmeDmaReductionReductionFormat => (MmeDmaReductionReductionFormat)((MmeDmaReduction >> 4) & 0x3);
public MmeDmaReductionReductionSize MmeDmaReductionReductionSize => (MmeDmaReductionReductionSize)((MmeDmaReduction >> 8) & 0x1); public readonly MmeDmaReductionReductionSize MmeDmaReductionReductionSize => (MmeDmaReductionReductionSize)((MmeDmaReduction >> 8) & 0x1);
public uint MmeDmaSysmembar; public uint MmeDmaSysmembar;
public bool MmeDmaSysmembarV => (MmeDmaSysmembar & 0x1) != 0; public readonly bool MmeDmaSysmembarV => (MmeDmaSysmembar & 0x1) != 0;
public uint MmeDmaSync; public uint MmeDmaSync;
public uint SetMmeDataFifoConfig; public uint SetMmeDataFifoConfig;
public SetMmeDataFifoConfigFifoSize SetMmeDataFifoConfigFifoSize => (SetMmeDataFifoConfigFifoSize)(SetMmeDataFifoConfig & 0x7); public readonly SetMmeDataFifoConfigFifoSize SetMmeDataFifoConfigFifoSize => (SetMmeDataFifoConfigFifoSize)(SetMmeDataFifoConfig & 0x7);
public fixed uint Reserved578[2]; public fixed uint Reserved578[2];
public uint RenderSolidPrimMode; public uint RenderSolidPrimMode;
public RenderSolidPrimModeV RenderSolidPrimModeV => (RenderSolidPrimModeV)(RenderSolidPrimMode & 0x7); public readonly RenderSolidPrimModeV RenderSolidPrimModeV => (RenderSolidPrimModeV)(RenderSolidPrimMode & 0x7);
public uint SetRenderSolidPrimColorFormat; public uint SetRenderSolidPrimColorFormat;
public SetRenderSolidPrimColorFormatV SetRenderSolidPrimColorFormatV => (SetRenderSolidPrimColorFormatV)(SetRenderSolidPrimColorFormat & 0xFF); public readonly SetRenderSolidPrimColorFormatV SetRenderSolidPrimColorFormatV => (SetRenderSolidPrimColorFormatV)(SetRenderSolidPrimColorFormat & 0xFF);
public uint SetRenderSolidPrimColor; public uint SetRenderSolidPrimColor;
public uint SetRenderSolidLineTieBreakBits; public uint SetRenderSolidLineTieBreakBits;
public bool SetRenderSolidLineTieBreakBitsXmajXincYinc => (SetRenderSolidLineTieBreakBits & 0x1) != 0; public readonly bool SetRenderSolidLineTieBreakBitsXmajXincYinc => (SetRenderSolidLineTieBreakBits & 0x1) != 0;
public bool SetRenderSolidLineTieBreakBitsXmajXdecYinc => (SetRenderSolidLineTieBreakBits & 0x10) != 0; public readonly bool SetRenderSolidLineTieBreakBitsXmajXdecYinc => (SetRenderSolidLineTieBreakBits & 0x10) != 0;
public bool SetRenderSolidLineTieBreakBitsYmajXincYinc => (SetRenderSolidLineTieBreakBits & 0x100) != 0; public readonly bool SetRenderSolidLineTieBreakBitsYmajXincYinc => (SetRenderSolidLineTieBreakBits & 0x100) != 0;
public bool SetRenderSolidLineTieBreakBitsYmajXdecYinc => (SetRenderSolidLineTieBreakBits & 0x1000) != 0; public readonly bool SetRenderSolidLineTieBreakBitsYmajXdecYinc => (SetRenderSolidLineTieBreakBits & 0x1000) != 0;
public fixed uint Reserved590[20]; public fixed uint Reserved590[20];
public uint RenderSolidPrimPointXY; public uint RenderSolidPrimPointXY;
public int RenderSolidPrimPointXYX => (int)(RenderSolidPrimPointXY & 0xFFFF); public readonly int RenderSolidPrimPointXYX => (int)(RenderSolidPrimPointXY & 0xFFFF);
public int RenderSolidPrimPointXYY => (int)((RenderSolidPrimPointXY >> 16) & 0xFFFF); public readonly int RenderSolidPrimPointXYY => (int)((RenderSolidPrimPointXY >> 16) & 0xFFFF);
public fixed uint Reserved5E4[7]; public fixed uint Reserved5E4[7];
public Array64<RenderSolidPrimPoint> RenderSolidPrimPoint; public Array64<RenderSolidPrimPoint> RenderSolidPrimPoint;
public uint SetPixelsFromCpuDataType; public uint SetPixelsFromCpuDataType;
public SetPixelsFromCpuDataTypeV SetPixelsFromCpuDataTypeV => (SetPixelsFromCpuDataTypeV)(SetPixelsFromCpuDataType & 0x1); public readonly SetPixelsFromCpuDataTypeV SetPixelsFromCpuDataTypeV => (SetPixelsFromCpuDataTypeV)(SetPixelsFromCpuDataType & 0x1);
public uint SetPixelsFromCpuColorFormat; public uint SetPixelsFromCpuColorFormat;
public SetPixelsFromCpuColorFormatV SetPixelsFromCpuColorFormatV => (SetPixelsFromCpuColorFormatV)(SetPixelsFromCpuColorFormat & 0xFF); public readonly SetPixelsFromCpuColorFormatV SetPixelsFromCpuColorFormatV => (SetPixelsFromCpuColorFormatV)(SetPixelsFromCpuColorFormat & 0xFF);
public uint SetPixelsFromCpuIndexFormat; public uint SetPixelsFromCpuIndexFormat;
public SetPixelsFromCpuIndexFormatV SetPixelsFromCpuIndexFormatV => (SetPixelsFromCpuIndexFormatV)(SetPixelsFromCpuIndexFormat & 0x3); public readonly SetPixelsFromCpuIndexFormatV SetPixelsFromCpuIndexFormatV => (SetPixelsFromCpuIndexFormatV)(SetPixelsFromCpuIndexFormat & 0x3);
public uint SetPixelsFromCpuMonoFormat; public uint SetPixelsFromCpuMonoFormat;
public SetPixelsFromCpuMonoFormatV SetPixelsFromCpuMonoFormatV => (SetPixelsFromCpuMonoFormatV)(SetPixelsFromCpuMonoFormat & 0x1); public readonly SetPixelsFromCpuMonoFormatV SetPixelsFromCpuMonoFormatV => (SetPixelsFromCpuMonoFormatV)(SetPixelsFromCpuMonoFormat & 0x1);
public uint SetPixelsFromCpuWrap; public uint SetPixelsFromCpuWrap;
public SetPixelsFromCpuWrapV SetPixelsFromCpuWrapV => (SetPixelsFromCpuWrapV)(SetPixelsFromCpuWrap & 0x3); public readonly SetPixelsFromCpuWrapV SetPixelsFromCpuWrapV => (SetPixelsFromCpuWrapV)(SetPixelsFromCpuWrap & 0x3);
public uint SetPixelsFromCpuColor0; public uint SetPixelsFromCpuColor0;
public uint SetPixelsFromCpuColor1; public uint SetPixelsFromCpuColor1;
public uint SetPixelsFromCpuMonoOpacity; public uint SetPixelsFromCpuMonoOpacity;
public SetPixelsFromCpuMonoOpacityV SetPixelsFromCpuMonoOpacityV => (SetPixelsFromCpuMonoOpacityV)(SetPixelsFromCpuMonoOpacity & 0x1); public readonly SetPixelsFromCpuMonoOpacityV SetPixelsFromCpuMonoOpacityV => (SetPixelsFromCpuMonoOpacityV)(SetPixelsFromCpuMonoOpacity & 0x1);
public fixed uint Reserved820[6]; public fixed uint Reserved820[6];
public uint SetPixelsFromCpuSrcWidth; public uint SetPixelsFromCpuSrcWidth;
public uint SetPixelsFromCpuSrcHeight; public uint SetPixelsFromCpuSrcHeight;
@ -722,45 +722,45 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public uint PixelsFromCpuData; public uint PixelsFromCpuData;
public fixed uint Reserved864[3]; public fixed uint Reserved864[3];
public uint SetBigEndianControl; public uint SetBigEndianControl;
public bool SetBigEndianControlX32Swap1 => (SetBigEndianControl & 0x1) != 0; public readonly bool SetBigEndianControlX32Swap1 => (SetBigEndianControl & 0x1) != 0;
public bool SetBigEndianControlX32Swap4 => (SetBigEndianControl & 0x2) != 0; public readonly bool SetBigEndianControlX32Swap4 => (SetBigEndianControl & 0x2) != 0;
public bool SetBigEndianControlX32Swap8 => (SetBigEndianControl & 0x4) != 0; public readonly bool SetBigEndianControlX32Swap8 => (SetBigEndianControl & 0x4) != 0;
public bool SetBigEndianControlX32Swap16 => (SetBigEndianControl & 0x8) != 0; public readonly bool SetBigEndianControlX32Swap16 => (SetBigEndianControl & 0x8) != 0;
public bool SetBigEndianControlX16Swap1 => (SetBigEndianControl & 0x10) != 0; public readonly bool SetBigEndianControlX16Swap1 => (SetBigEndianControl & 0x10) != 0;
public bool SetBigEndianControlX16Swap4 => (SetBigEndianControl & 0x20) != 0; public readonly bool SetBigEndianControlX16Swap4 => (SetBigEndianControl & 0x20) != 0;
public bool SetBigEndianControlX16Swap8 => (SetBigEndianControl & 0x40) != 0; public readonly bool SetBigEndianControlX16Swap8 => (SetBigEndianControl & 0x40) != 0;
public bool SetBigEndianControlX16Swap16 => (SetBigEndianControl & 0x80) != 0; public readonly bool SetBigEndianControlX16Swap16 => (SetBigEndianControl & 0x80) != 0;
public bool SetBigEndianControlX8Swap1 => (SetBigEndianControl & 0x100) != 0; public readonly bool SetBigEndianControlX8Swap1 => (SetBigEndianControl & 0x100) != 0;
public bool SetBigEndianControlX8Swap4 => (SetBigEndianControl & 0x200) != 0; public readonly bool SetBigEndianControlX8Swap4 => (SetBigEndianControl & 0x200) != 0;
public bool SetBigEndianControlX8Swap8 => (SetBigEndianControl & 0x400) != 0; public readonly bool SetBigEndianControlX8Swap8 => (SetBigEndianControl & 0x400) != 0;
public bool SetBigEndianControlX8Swap16 => (SetBigEndianControl & 0x800) != 0; public readonly bool SetBigEndianControlX8Swap16 => (SetBigEndianControl & 0x800) != 0;
public bool SetBigEndianControlI1X8Cga6Swap1 => (SetBigEndianControl & 0x1000) != 0; public readonly bool SetBigEndianControlI1X8Cga6Swap1 => (SetBigEndianControl & 0x1000) != 0;
public bool SetBigEndianControlI1X8Cga6Swap4 => (SetBigEndianControl & 0x2000) != 0; public readonly bool SetBigEndianControlI1X8Cga6Swap4 => (SetBigEndianControl & 0x2000) != 0;
public bool SetBigEndianControlI1X8Cga6Swap8 => (SetBigEndianControl & 0x4000) != 0; public readonly bool SetBigEndianControlI1X8Cga6Swap8 => (SetBigEndianControl & 0x4000) != 0;
public bool SetBigEndianControlI1X8Cga6Swap16 => (SetBigEndianControl & 0x8000) != 0; public readonly bool SetBigEndianControlI1X8Cga6Swap16 => (SetBigEndianControl & 0x8000) != 0;
public bool SetBigEndianControlI1X8LeSwap1 => (SetBigEndianControl & 0x10000) != 0; public readonly bool SetBigEndianControlI1X8LeSwap1 => (SetBigEndianControl & 0x10000) != 0;
public bool SetBigEndianControlI1X8LeSwap4 => (SetBigEndianControl & 0x20000) != 0; public readonly bool SetBigEndianControlI1X8LeSwap4 => (SetBigEndianControl & 0x20000) != 0;
public bool SetBigEndianControlI1X8LeSwap8 => (SetBigEndianControl & 0x40000) != 0; public readonly bool SetBigEndianControlI1X8LeSwap8 => (SetBigEndianControl & 0x40000) != 0;
public bool SetBigEndianControlI1X8LeSwap16 => (SetBigEndianControl & 0x80000) != 0; public readonly bool SetBigEndianControlI1X8LeSwap16 => (SetBigEndianControl & 0x80000) != 0;
public bool SetBigEndianControlI4Swap1 => (SetBigEndianControl & 0x100000) != 0; public readonly bool SetBigEndianControlI4Swap1 => (SetBigEndianControl & 0x100000) != 0;
public bool SetBigEndianControlI4Swap4 => (SetBigEndianControl & 0x200000) != 0; public readonly bool SetBigEndianControlI4Swap4 => (SetBigEndianControl & 0x200000) != 0;
public bool SetBigEndianControlI4Swap8 => (SetBigEndianControl & 0x400000) != 0; public readonly bool SetBigEndianControlI4Swap8 => (SetBigEndianControl & 0x400000) != 0;
public bool SetBigEndianControlI4Swap16 => (SetBigEndianControl & 0x800000) != 0; public readonly bool SetBigEndianControlI4Swap16 => (SetBigEndianControl & 0x800000) != 0;
public bool SetBigEndianControlI8Swap1 => (SetBigEndianControl & 0x1000000) != 0; public readonly bool SetBigEndianControlI8Swap1 => (SetBigEndianControl & 0x1000000) != 0;
public bool SetBigEndianControlI8Swap4 => (SetBigEndianControl & 0x2000000) != 0; public readonly bool SetBigEndianControlI8Swap4 => (SetBigEndianControl & 0x2000000) != 0;
public bool SetBigEndianControlI8Swap8 => (SetBigEndianControl & 0x4000000) != 0; public readonly bool SetBigEndianControlI8Swap8 => (SetBigEndianControl & 0x4000000) != 0;
public bool SetBigEndianControlI8Swap16 => (SetBigEndianControl & 0x8000000) != 0; public readonly bool SetBigEndianControlI8Swap16 => (SetBigEndianControl & 0x8000000) != 0;
public bool SetBigEndianControlOverride => (SetBigEndianControl & 0x10000000) != 0; public readonly bool SetBigEndianControlOverride => (SetBigEndianControl & 0x10000000) != 0;
public fixed uint Reserved874[3]; public fixed uint Reserved874[3];
public uint SetPixelsFromMemoryBlockShape; public uint SetPixelsFromMemoryBlockShape;
public SetPixelsFromMemoryBlockShapeV SetPixelsFromMemoryBlockShapeV => (SetPixelsFromMemoryBlockShapeV)(SetPixelsFromMemoryBlockShape & 0x7); public readonly SetPixelsFromMemoryBlockShapeV SetPixelsFromMemoryBlockShapeV => (SetPixelsFromMemoryBlockShapeV)(SetPixelsFromMemoryBlockShape & 0x7);
public uint SetPixelsFromMemoryCorralSize; public uint SetPixelsFromMemoryCorralSize;
public int SetPixelsFromMemoryCorralSizeV => (int)(SetPixelsFromMemoryCorralSize & 0x3FF); public readonly int SetPixelsFromMemoryCorralSizeV => (int)(SetPixelsFromMemoryCorralSize & 0x3FF);
public uint SetPixelsFromMemorySafeOverlap; public uint SetPixelsFromMemorySafeOverlap;
public bool SetPixelsFromMemorySafeOverlapV => (SetPixelsFromMemorySafeOverlap & 0x1) != 0; public readonly bool SetPixelsFromMemorySafeOverlapV => (SetPixelsFromMemorySafeOverlap & 0x1) != 0;
public uint SetPixelsFromMemorySampleMode; public uint SetPixelsFromMemorySampleMode;
public SetPixelsFromMemorySampleModeOrigin SetPixelsFromMemorySampleModeOrigin => (SetPixelsFromMemorySampleModeOrigin)(SetPixelsFromMemorySampleMode & 0x1); public readonly SetPixelsFromMemorySampleModeOrigin SetPixelsFromMemorySampleModeOrigin => (SetPixelsFromMemorySampleModeOrigin)(SetPixelsFromMemorySampleMode & 0x1);
public SetPixelsFromMemorySampleModeFilter SetPixelsFromMemorySampleModeFilter => (SetPixelsFromMemorySampleModeFilter)((SetPixelsFromMemorySampleMode >> 4) & 0x1); public readonly SetPixelsFromMemorySampleModeFilter SetPixelsFromMemorySampleModeFilter => (SetPixelsFromMemorySampleModeFilter)((SetPixelsFromMemorySampleMode >> 4) & 0x1);
public fixed uint Reserved890[8]; public fixed uint Reserved890[8];
public uint SetPixelsFromMemoryDstX0; public uint SetPixelsFromMemoryDstX0;
public uint SetPixelsFromMemoryDstY0; public uint SetPixelsFromMemoryDstY0;
@ -808,9 +808,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
public uint SetFalcon31; public uint SetFalcon31;
public fixed uint Reserved960[291]; public fixed uint Reserved960[291];
public uint MmeDmaWriteMethodBarrier; public uint MmeDmaWriteMethodBarrier;
public bool MmeDmaWriteMethodBarrierV => (MmeDmaWriteMethodBarrier & 0x1) != 0; public readonly bool MmeDmaWriteMethodBarrierV => (MmeDmaWriteMethodBarrier & 0x1) != 0;
public fixed uint ReservedDF0[2436]; public fixed uint ReservedDF0[2436];
public MmeShadowScratch SetMmeShadowScratch; public Array256<uint> SetMmeShadowScratch;
#pragma warning restore CS0649 #pragma warning restore CS0649
} }
} }

View file

@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
/// </summary> /// </summary>
struct TwodTexture struct TwodTexture
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public ColorFormat Format; public ColorFormat Format;
public Boolean32 LinearLayout; public Boolean32 LinearLayout;
public MemoryLayout MemoryLayout; public MemoryLayout MemoryLayout;

View file

@ -3,10 +3,10 @@
/// <summary> /// <summary>
/// Boolean value, stored as a 32-bits integer in memory. /// Boolean value, stored as a 32-bits integer in memory.
/// </summary> /// </summary>
struct Boolean32 readonly struct Boolean32
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
private uint _value; private readonly uint _value;
#pragma warning restore CS0649 #pragma warning restore CS0649
public static implicit operator bool(Boolean32 value) public static implicit operator bool(Boolean32 value)

View file

@ -9,58 +9,58 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
enum ColorFormat enum ColorFormat
{ {
R32G32B32A32Float = 0xc0, R32G32B32A32Float = 0xc0,
R32G32B32A32Sint = 0xc1, R32G32B32A32Sint = 0xc1,
R32G32B32A32Uint = 0xc2, R32G32B32A32Uint = 0xc2,
R32G32B32X32Float = 0xc3, R32G32B32X32Float = 0xc3,
R32G32B32X32Sint = 0xc4, R32G32B32X32Sint = 0xc4,
R32G32B32X32Uint = 0xc5, R32G32B32X32Uint = 0xc5,
R16G16B16X16Unorm = 0xc6, R16G16B16X16Unorm = 0xc6,
R16G16B16X16Snorm = 0xc7, R16G16B16X16Snorm = 0xc7,
R16G16B16X16Sint = 0xc8, R16G16B16X16Sint = 0xc8,
R16G16B16X16Uint = 0xc9, R16G16B16X16Uint = 0xc9,
R16G16B16A16Float = 0xca, R16G16B16A16Float = 0xca,
R32G32Float = 0xcb, R32G32Float = 0xcb,
R32G32Sint = 0xcc, R32G32Sint = 0xcc,
R32G32Uint = 0xcd, R32G32Uint = 0xcd,
R16G16B16X16Float = 0xce, R16G16B16X16Float = 0xce,
B8G8R8A8Unorm = 0xcf, B8G8R8A8Unorm = 0xcf,
B8G8R8A8Srgb = 0xd0, B8G8R8A8Srgb = 0xd0,
R10G10B10A2Unorm = 0xd1, R10G10B10A2Unorm = 0xd1,
R10G10B10A2Uint = 0xd2, R10G10B10A2Uint = 0xd2,
R8G8B8A8Unorm = 0xd5, R8G8B8A8Unorm = 0xd5,
R8G8B8A8Srgb = 0xd6, R8G8B8A8Srgb = 0xd6,
R8G8B8X8Snorm = 0xd7, R8G8B8X8Snorm = 0xd7,
R8G8B8X8Sint = 0xd8, R8G8B8X8Sint = 0xd8,
R8G8B8X8Uint = 0xd9, R8G8B8X8Uint = 0xd9,
R16G16Unorm = 0xda, R16G16Unorm = 0xda,
R16G16Snorm = 0xdb, R16G16Snorm = 0xdb,
R16G16Sint = 0xdc, R16G16Sint = 0xdc,
R16G16Uint = 0xdd, R16G16Uint = 0xdd,
R16G16Float = 0xde, R16G16Float = 0xde,
R11G11B10Float = 0xe0, R11G11B10Float = 0xe0,
R32Sint = 0xe3, R32Sint = 0xe3,
R32Uint = 0xe4, R32Uint = 0xe4,
R32Float = 0xe5, R32Float = 0xe5,
B8G8R8X8Unorm = 0xe6, B8G8R8X8Unorm = 0xe6,
B8G8R8X8Srgb = 0xe7, B8G8R8X8Srgb = 0xe7,
B5G6R5Unorm = 0xe8, B5G6R5Unorm = 0xe8,
B5G5R5A1Unorm = 0xe9, B5G5R5A1Unorm = 0xe9,
R8G8Unorm = 0xea, R8G8Unorm = 0xea,
R8G8Snorm = 0xeb, R8G8Snorm = 0xeb,
R8G8Sint = 0xec, R8G8Sint = 0xec,
R8G8Uint = 0xed, R8G8Uint = 0xed,
R16Unorm = 0xee, R16Unorm = 0xee,
R16Snorm = 0xef, R16Snorm = 0xef,
R16Sint = 0xf0, R16Sint = 0xf0,
R16Uint = 0xf1, R16Uint = 0xf1,
R16Float = 0xf2, R16Float = 0xf2,
R8Unorm = 0xf3, R8Unorm = 0xf3,
R8Snorm = 0xf4, R8Snorm = 0xf4,
R8Sint = 0xf5, R8Sint = 0xf5,
R8Uint = 0xf6, R8Uint = 0xf6,
B5G5R5X1Unorm = 0xf8, B5G5R5X1Unorm = 0xf8,
R8G8B8X8Unorm = 0xf9, R8G8B8X8Unorm = 0xf9,
R8G8B8X8Srgb = 0xfa R8G8B8X8Srgb = 0xfa,
} }
static class ColorFormatConverter static class ColorFormatConverter
@ -74,6 +74,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
{ {
return format switch return format switch
{ {
#pragma warning disable IDE0055 // Disable formatting
ColorFormat.R32G32B32A32Float => new FormatInfo(Format.R32G32B32A32Float, 1, 1, 16, 4), ColorFormat.R32G32B32A32Float => new FormatInfo(Format.R32G32B32A32Float, 1, 1, 16, 4),
ColorFormat.R32G32B32A32Sint => new FormatInfo(Format.R32G32B32A32Sint, 1, 1, 16, 4), ColorFormat.R32G32B32A32Sint => new FormatInfo(Format.R32G32B32A32Sint, 1, 1, 16, 4),
ColorFormat.R32G32B32A32Uint => new FormatInfo(Format.R32G32B32A32Uint, 1, 1, 16, 4), ColorFormat.R32G32B32A32Uint => new FormatInfo(Format.R32G32B32A32Uint, 1, 1, 16, 4),
@ -127,7 +128,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
ColorFormat.B5G5R5X1Unorm => new FormatInfo(Format.B5G5R5A1Unorm, 1, 1, 2, 4), ColorFormat.B5G5R5X1Unorm => new FormatInfo(Format.B5G5R5A1Unorm, 1, 1, 2, 4),
ColorFormat.R8G8B8X8Unorm => new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4, 4), ColorFormat.R8G8B8X8Unorm => new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4, 4),
ColorFormat.R8G8B8X8Srgb => new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4, 4), ColorFormat.R8G8B8X8Srgb => new FormatInfo(Format.R8G8B8A8Srgb, 1, 1, 4, 4),
_ => FormatInfo.Default _ => FormatInfo.Default,
#pragma warning restore IDE0055
}; };
} }
@ -157,9 +159,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
case ColorFormat.R8G8B8X8Unorm: case ColorFormat.R8G8B8X8Unorm:
case ColorFormat.R8G8B8X8Srgb: case ColorFormat.R8G8B8X8Srgb:
return true; return true;
default:
return false;
} }
return false;
} }
} }
} }

View file

@ -5,7 +5,7 @@
/// </summary> /// </summary>
struct GpuVa struct GpuVa
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint High; public uint High;
public uint Low; public uint Low;
#pragma warning restore CS0649 #pragma warning restore CS0649
@ -14,7 +14,7 @@
/// Packs the split address into a 64-bits address value. /// Packs the split address into a 64-bits address value.
/// </summary> /// </summary>
/// <returns>The 64-bits address value</returns> /// <returns>The 64-bits address value</returns>
public ulong Pack() public readonly ulong Pack()
{ {
return Low | ((ulong)High << 32); return Low | ((ulong)High << 32);
} }

View file

@ -5,31 +5,31 @@
/// </summary> /// </summary>
struct MemoryLayout struct MemoryLayout
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint Packed; public uint Packed;
#pragma warning restore CS0649 #pragma warning restore CS0649
public int UnpackGobBlocksInX() public readonly int UnpackGobBlocksInX()
{ {
return 1 << (int)(Packed & 0xf); return 1 << (int)(Packed & 0xf);
} }
public int UnpackGobBlocksInY() public readonly int UnpackGobBlocksInY()
{ {
return 1 << (int)((Packed >> 4) & 0xf); return 1 << (int)((Packed >> 4) & 0xf);
} }
public int UnpackGobBlocksInZ() public readonly int UnpackGobBlocksInZ()
{ {
return 1 << (int)((Packed >> 8) & 0xf); return 1 << (int)((Packed >> 8) & 0xf);
} }
public bool UnpackIsLinear() public readonly bool UnpackIsLinear()
{ {
return (Packed & 0x1000) != 0; return (Packed & 0x1000) != 0;
} }
public bool UnpackIsTarget3D() public readonly bool UnpackIsTarget3D()
{ {
return (Packed & 0x10000) != 0; return (Packed & 0x10000) != 0;
} }

View file

@ -21,7 +21,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
LineStripAdjacency, LineStripAdjacency,
TrianglesAdjacency, TrianglesAdjacency,
TriangleStripAdjacency, TriangleStripAdjacency,
Patches Patches,
} }
/// <summary> /// <summary>
@ -39,7 +39,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
LineStripAdjacency = 11, LineStripAdjacency = 11,
TrianglesAdjacency = 12, TrianglesAdjacency = 12,
TriangleStripAdjacency = 13, TriangleStripAdjacency = 13,
Patches = 14 Patches = 14,
} }
static class PrimitiveTypeConverter static class PrimitiveTypeConverter
@ -53,6 +53,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
{ {
return type switch return type switch
{ {
#pragma warning disable IDE0055 // Disable formatting
PrimitiveType.Points => PrimitiveTopology.Points, PrimitiveType.Points => PrimitiveTopology.Points,
PrimitiveType.Lines => PrimitiveTopology.Lines, PrimitiveType.Lines => PrimitiveTopology.Lines,
PrimitiveType.LineLoop => PrimitiveTopology.LineLoop, PrimitiveType.LineLoop => PrimitiveTopology.LineLoop,
@ -68,7 +69,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
PrimitiveType.TrianglesAdjacency => PrimitiveTopology.TrianglesAdjacency, PrimitiveType.TrianglesAdjacency => PrimitiveTopology.TrianglesAdjacency,
PrimitiveType.TriangleStripAdjacency => PrimitiveTopology.TriangleStripAdjacency, PrimitiveType.TriangleStripAdjacency => PrimitiveTopology.TriangleStripAdjacency,
PrimitiveType.Patches => PrimitiveTopology.Patches, PrimitiveType.Patches => PrimitiveTopology.Patches,
_ => PrimitiveTopology.Triangles _ => PrimitiveTopology.Triangles,
#pragma warning restore IDE0055
}; };
} }
@ -81,6 +83,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
{ {
return type switch return type switch
{ {
#pragma warning disable IDE0055 // Disable formatting
PrimitiveTypeOverride.Points => PrimitiveTopology.Points, PrimitiveTypeOverride.Points => PrimitiveTopology.Points,
PrimitiveTypeOverride.Lines => PrimitiveTopology.Lines, PrimitiveTypeOverride.Lines => PrimitiveTopology.Lines,
PrimitiveTypeOverride.LineStrip => PrimitiveTopology.LineStrip, PrimitiveTypeOverride.LineStrip => PrimitiveTopology.LineStrip,
@ -92,7 +95,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
PrimitiveTypeOverride.TrianglesAdjacency => PrimitiveTopology.TrianglesAdjacency, PrimitiveTypeOverride.TrianglesAdjacency => PrimitiveTopology.TrianglesAdjacency,
PrimitiveTypeOverride.TriangleStripAdjacency => PrimitiveTopology.TriangleStripAdjacency, PrimitiveTypeOverride.TriangleStripAdjacency => PrimitiveTopology.TriangleStripAdjacency,
PrimitiveTypeOverride.Patches => PrimitiveTopology.Patches, PrimitiveTypeOverride.Patches => PrimitiveTopology.Patches,
_ => PrimitiveTopology.Triangles _ => PrimitiveTopology.Triangles,
#pragma warning restore IDE0055
}; };
} }
} }

View file

@ -5,7 +5,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
/// </summary> /// </summary>
enum SamplerIndex enum SamplerIndex
{ {
Independently = 0, Independently = 0,
ViaHeaderIndex = 1 ViaHeaderIndex = 1,
} }
} }

View file

@ -5,14 +5,14 @@
/// </summary> /// </summary>
struct SbDescriptor struct SbDescriptor
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint AddressLow; public uint AddressLow;
public uint AddressHigh; public uint AddressHigh;
public int Size; public int Size;
public int Padding; public int Padding;
#pragma warning restore CS0649 #pragma warning restore CS0649
public ulong PackAddress() public readonly ulong PackAddress()
{ {
return AddressLow | ((ulong)AddressHigh << 32); return AddressLow | ((ulong)AddressHigh << 32);
} }

View file

@ -8,13 +8,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
/// </summary> /// </summary>
enum ZetaFormat enum ZetaFormat
{ {
D32Float = 0xa, D32Float = 0xa,
D16Unorm = 0x13, D16Unorm = 0x13,
D24UnormS8Uint = 0x14, D24UnormS8Uint = 0x14,
D24Unorm = 0x15, D24Unorm = 0x15,
S8UintD24Unorm = 0x16, S8UintD24Unorm = 0x16,
S8Uint = 0x17, S8Uint = 0x17,
D32FloatS8Uint = 0x19 D32FloatS8Uint = 0x19,
} }
static class ZetaFormatConverter static class ZetaFormatConverter
@ -28,6 +28,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
{ {
return format switch return format switch
{ {
#pragma warning disable IDE0055 // Disable formatting
ZetaFormat.D32Float => new FormatInfo(Format.D32Float, 1, 1, 4, 1), ZetaFormat.D32Float => new FormatInfo(Format.D32Float, 1, 1, 4, 1),
ZetaFormat.D16Unorm => new FormatInfo(Format.D16Unorm, 1, 1, 2, 1), ZetaFormat.D16Unorm => new FormatInfo(Format.D16Unorm, 1, 1, 2, 1),
ZetaFormat.D24UnormS8Uint => new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4, 2), ZetaFormat.D24UnormS8Uint => new FormatInfo(Format.D24UnormS8Uint, 1, 1, 4, 2),
@ -35,7 +36,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Types
ZetaFormat.S8UintD24Unorm => new FormatInfo(Format.S8UintD24Unorm, 1, 1, 4, 2), ZetaFormat.S8UintD24Unorm => new FormatInfo(Format.S8UintD24Unorm, 1, 1, 4, 2),
ZetaFormat.S8Uint => new FormatInfo(Format.S8Uint, 1, 1, 1, 1), ZetaFormat.S8Uint => new FormatInfo(Format.S8Uint, 1, 1, 1, 1),
ZetaFormat.D32FloatS8Uint => new FormatInfo(Format.D32FloatS8Uint, 1, 1, 8, 2), ZetaFormat.D32FloatS8Uint => new FormatInfo(Format.D32FloatS8Uint, 1, 1, 8, 2),
_ => FormatInfo.Default _ => FormatInfo.Default,
#pragma warning restore IDE0055
}; };
} }
} }

View file

@ -125,6 +125,7 @@ namespace Ryujinx.Graphics.Gpu
/// </summary> /// </summary>
public void Dispose() public void Dispose()
{ {
GC.SuppressFinalize(this);
_context.DeferredActions.Enqueue(Destroy); _context.DeferredActions.Enqueue(Destroy);
} }

View file

@ -99,7 +99,7 @@ namespace Ryujinx.Graphics.Gpu
private bool _pendingSync; private bool _pendingSync;
private long _modifiedSequence; private long _modifiedSequence;
private ulong _firstTimestamp; private readonly ulong _firstTimestamp;
/// <summary> /// <summary>
/// Creates a new instance of the GPU emulation context. /// Creates a new instance of the GPU emulation context.

View file

@ -1,5 +1,6 @@
namespace Ryujinx.Graphics.Gpu namespace Ryujinx.Graphics.Gpu
{ {
#pragma warning disable CA2211 // Non-constant fields should not be visible
/// <summary> /// <summary>
/// General GPU and graphics configuration. /// General GPU and graphics configuration.
/// </summary> /// </summary>
@ -67,4 +68,5 @@ namespace Ryujinx.Graphics.Gpu
/// </summary> /// </summary>
public static bool EnableTextureRecompression = false; public static bool EnableTextureRecompression = false;
} }
#pragma warning restore CA2211
} }

View file

@ -54,7 +54,7 @@ namespace Ryujinx.Graphics.Gpu.Image
private HashSet<ShortTextureCacheEntry> _shortCacheBuilder; private HashSet<ShortTextureCacheEntry> _shortCacheBuilder;
private HashSet<ShortTextureCacheEntry> _shortCache; private HashSet<ShortTextureCacheEntry> _shortCache;
private Dictionary<TextureDescriptor, ShortTextureCacheEntry> _shortCacheLookup; private readonly Dictionary<TextureDescriptor, ShortTextureCacheEntry> _shortCacheLookup;
/// <summary> /// <summary>
/// Creates a new instance of the automatic deletion cache. /// Creates a new instance of the automatic deletion cache.

View file

@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <summary> /// <summary>
/// A default, generic RGBA8 texture format. /// A default, generic RGBA8 texture format.
/// </summary> /// </summary>
public static FormatInfo Default { get; } = new FormatInfo(Format.R8G8B8A8Unorm, 1, 1, 4, 4); public static FormatInfo Default { get; } = new(Format.R8G8B8A8Unorm, 1, 1, 4, 4);
/// <summary> /// <summary>
/// The format of the texture data. /// The format of the texture data.
@ -57,16 +57,16 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <param name="bytesPerPixel">The number of bytes occupied by a single pixel in memory of the texture data</param> /// <param name="bytesPerPixel">The number of bytes occupied by a single pixel in memory of the texture data</param>
public FormatInfo( public FormatInfo(
Format format, Format format,
int blockWidth, int blockWidth,
int blockHeight, int blockHeight,
int bytesPerPixel, int bytesPerPixel,
int components) int components)
{ {
Format = format; Format = format;
BlockWidth = blockWidth; BlockWidth = blockWidth;
BlockHeight = blockHeight; BlockHeight = blockHeight;
BytesPerPixel = bytesPerPixel; BytesPerPixel = bytesPerPixel;
Components = components; Components = components;
} }
} }
} }

View file

@ -1,5 +1,6 @@
using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.GAL;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
namespace Ryujinx.Graphics.Gpu.Image namespace Ryujinx.Graphics.Gpu.Image
{ {
@ -8,6 +9,8 @@ namespace Ryujinx.Graphics.Gpu.Image
/// </summary> /// </summary>
static class FormatTable static class FormatTable
{ {
#pragma warning disable IDE0055 // Disable formatting
[SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
private enum TextureFormat : uint private enum TextureFormat : uint
{ {
// Formats // Formats
@ -244,6 +247,7 @@ namespace Ryujinx.Graphics.Gpu.Image
A5B5G5R1Unorm = A5B5G5R1 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24913 A5B5G5R1Unorm = A5B5G5R1 | RUnorm | GUnorm | BUnorm | AUnorm, // 0x24913
} }
[SuppressMessage("Design", "CA1069: Enums values should not be duplicated")]
private enum VertexAttributeFormat : uint private enum VertexAttributeFormat : uint
{ {
// Width // Width
@ -357,7 +361,7 @@ namespace Ryujinx.Graphics.Gpu.Image
A2B10G10R10Sscaled = (A2B10G10R10 << 21) | (Sscaled << 27), // 0x36000000 A2B10G10R10Sscaled = (A2B10G10R10 << 21) | (Sscaled << 27), // 0x36000000
} }
private static readonly Dictionary<TextureFormat, FormatInfo> _textureFormats = new Dictionary<TextureFormat, FormatInfo>() private static readonly Dictionary<TextureFormat, FormatInfo> _textureFormats = new()
{ {
{ TextureFormat.R8Unorm, new FormatInfo(Format.R8Unorm, 1, 1, 1, 1) }, { TextureFormat.R8Unorm, new FormatInfo(Format.R8Unorm, 1, 1, 1, 1) },
{ TextureFormat.R8Snorm, new FormatInfo(Format.R8Snorm, 1, 1, 1, 1) }, { TextureFormat.R8Snorm, new FormatInfo(Format.R8Snorm, 1, 1, 1, 1) },
@ -464,10 +468,10 @@ namespace Ryujinx.Graphics.Gpu.Image
{ TextureFormat.Astc2D10x10UnormSrgb, new FormatInfo(Format.Astc10x10Srgb, 10, 10, 16, 4) }, { TextureFormat.Astc2D10x10UnormSrgb, new FormatInfo(Format.Astc10x10Srgb, 10, 10, 16, 4) },
{ TextureFormat.Astc2D12x10UnormSrgb, new FormatInfo(Format.Astc12x10Srgb, 12, 10, 16, 4) }, { TextureFormat.Astc2D12x10UnormSrgb, new FormatInfo(Format.Astc12x10Srgb, 12, 10, 16, 4) },
{ TextureFormat.Astc2D12x12UnormSrgb, new FormatInfo(Format.Astc12x12Srgb, 12, 12, 16, 4) }, { TextureFormat.Astc2D12x12UnormSrgb, new FormatInfo(Format.Astc12x12Srgb, 12, 12, 16, 4) },
{ TextureFormat.A5B5G5R1Unorm, new FormatInfo(Format.A1B5G5R5Unorm, 1, 1, 2, 4) } { TextureFormat.A5B5G5R1Unorm, new FormatInfo(Format.A1B5G5R5Unorm, 1, 1, 2, 4) },
}; };
private static readonly Dictionary<VertexAttributeFormat, Format> _attribFormats = new Dictionary<VertexAttributeFormat, Format>() private static readonly Dictionary<VertexAttributeFormat, Format> _attribFormats = new()
{ {
{ VertexAttributeFormat.R8Unorm, Format.R8Unorm }, { VertexAttributeFormat.R8Unorm, Format.R8Unorm },
{ VertexAttributeFormat.R8Snorm, Format.R8Snorm }, { VertexAttributeFormat.R8Snorm, Format.R8Snorm },
@ -547,8 +551,9 @@ namespace Ryujinx.Graphics.Gpu.Image
{ VertexAttributeFormat.A2B10G10R10Snorm, Format.R10G10B10A2Snorm }, { VertexAttributeFormat.A2B10G10R10Snorm, Format.R10G10B10A2Snorm },
{ VertexAttributeFormat.A2B10G10R10Sint, Format.R10G10B10A2Sint }, { VertexAttributeFormat.A2B10G10R10Sint, Format.R10G10B10A2Sint },
{ VertexAttributeFormat.A2B10G10R10Uscaled, Format.R10G10B10A2Uscaled }, { VertexAttributeFormat.A2B10G10R10Uscaled, Format.R10G10B10A2Uscaled },
{ VertexAttributeFormat.A2B10G10R10Sscaled, Format.R10G10B10A2Sscaled } { VertexAttributeFormat.A2B10G10R10Sscaled, Format.R10G10B10A2Sscaled },
}; };
#pragma warning restore IDE0055
/// <summary> /// <summary>
/// Try getting the texture format from an encoded format integer from the Maxwell texture descriptor. /// Try getting the texture format from an encoded format integer from the Maxwell texture descriptor.

View file

@ -67,7 +67,7 @@ namespace Ryujinx.Graphics.Gpu.Image
DescriptorCache = new T2[count]; DescriptorCache = new T2[count];
Address = address; Address = address;
Size = size; Size = size;
_memoryTracking = physicalMemory.BeginGranularTracking(address, size, ResourceKind.Pool); _memoryTracking = physicalMemory.BeginGranularTracking(address, size, ResourceKind.Pool);
_memoryTracking.RegisterPreciseAction(address, size, PreciseAction); _memoryTracking.RegisterPreciseAction(address, size, PreciseAction);

View file

@ -10,6 +10,6 @@ namespace Ryujinx.Graphics.Gpu.Image
{ {
Average, Average,
Minimum, Minimum,
Maximum Maximum,
} }
} }

View file

@ -40,16 +40,16 @@ namespace Ryujinx.Graphics.Gpu.Image
AddressMode addressP = descriptor.UnpackAddressP(); AddressMode addressP = descriptor.UnpackAddressP();
CompareMode compareMode = descriptor.UnpackCompareMode(); CompareMode compareMode = descriptor.UnpackCompareMode();
CompareOp compareOp = descriptor.UnpackCompareOp(); CompareOp compareOp = descriptor.UnpackCompareOp();
ColorF color = new ColorF( ColorF color = new(
descriptor.BorderColorR, descriptor.BorderColorR,
descriptor.BorderColorG, descriptor.BorderColorG,
descriptor.BorderColorB, descriptor.BorderColorB,
descriptor.BorderColorA); descriptor.BorderColorA);
float minLod = descriptor.UnpackMinLod(); float minLod = descriptor.UnpackMinLod();
float maxLod = descriptor.UnpackMaxLod(); float maxLod = descriptor.UnpackMaxLod();
float mipLodBias = descriptor.UnpackMipLodBias(); float mipLodBias = descriptor.UnpackMipLodBias();
float maxRequestedAnisotropy = descriptor.UnpackMaxAnisotropy(); float maxRequestedAnisotropy = descriptor.UnpackMaxAnisotropy();

View file

@ -43,17 +43,17 @@ namespace Ryujinx.Graphics.Gpu.Image
0.45833334f, 0.45833334f,
0.46153846f, 0.46153846f,
0.4642857f, 0.4642857f,
0.46666667f 0.46666667f,
}; };
private static readonly float[] _maxAnisotropyLut = new float[] private static readonly float[] _maxAnisotropyLut = new float[]
{ {
1, 2, 4, 6, 8, 10, 12, 16 1, 2, 4, 6, 8, 10, 12, 16,
}; };
private const float Frac8ToF32 = 1.0f / 256.0f; private const float Frac8ToF32 = 1.0f / 256.0f;
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint Word0; public uint Word0;
public uint Word1; public uint Word1;
public uint Word2; public uint Word2;
@ -68,7 +68,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the texture wrap mode along the X axis. /// Unpacks the texture wrap mode along the X axis.
/// </summary> /// </summary>
/// <returns>The texture wrap mode enum</returns> /// <returns>The texture wrap mode enum</returns>
public AddressMode UnpackAddressU() public readonly AddressMode UnpackAddressU()
{ {
return (AddressMode)(Word0 & 7); return (AddressMode)(Word0 & 7);
} }
@ -77,7 +77,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the texture wrap mode along the Y axis. /// Unpacks the texture wrap mode along the Y axis.
/// </summary> /// </summary>
/// <returns>The texture wrap mode enum</returns> /// <returns>The texture wrap mode enum</returns>
public AddressMode UnpackAddressV() public readonly AddressMode UnpackAddressV()
{ {
return (AddressMode)((Word0 >> 3) & 7); return (AddressMode)((Word0 >> 3) & 7);
} }
@ -86,7 +86,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the texture wrap mode along the Z axis. /// Unpacks the texture wrap mode along the Z axis.
/// </summary> /// </summary>
/// <returns>The texture wrap mode enum</returns> /// <returns>The texture wrap mode enum</returns>
public AddressMode UnpackAddressP() public readonly AddressMode UnpackAddressP()
{ {
return (AddressMode)((Word0 >> 6) & 7); return (AddressMode)((Word0 >> 6) & 7);
} }
@ -97,7 +97,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// This is only relevant for shaders with shadow samplers. /// This is only relevant for shaders with shadow samplers.
/// </summary> /// </summary>
/// <returns>The depth comparison mode enum</returns> /// <returns>The depth comparison mode enum</returns>
public CompareMode UnpackCompareMode() public readonly CompareMode UnpackCompareMode()
{ {
return (CompareMode)((Word0 >> 9) & 1); return (CompareMode)((Word0 >> 9) & 1);
} }
@ -108,7 +108,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// This is only relevant for shaders with shadow samplers. /// This is only relevant for shaders with shadow samplers.
/// </summary> /// </summary>
/// <returns>The depth comparison operation enum</returns> /// <returns>The depth comparison operation enum</returns>
public CompareOp UnpackCompareOp() public readonly CompareOp UnpackCompareOp()
{ {
return (CompareOp)(((Word0 >> 10) & 7) + 1); return (CompareOp)(((Word0 >> 10) & 7) + 1);
} }
@ -117,7 +117,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks and converts the maximum anisotropy value used for texture anisotropic filtering. /// Unpacks and converts the maximum anisotropy value used for texture anisotropic filtering.
/// </summary> /// </summary>
/// <returns>The maximum anisotropy</returns> /// <returns>The maximum anisotropy</returns>
public float UnpackMaxAnisotropy() public readonly float UnpackMaxAnisotropy()
{ {
return _maxAnisotropyLut[(Word0 >> 20) & 7]; return _maxAnisotropyLut[(Word0 >> 20) & 7];
} }
@ -128,7 +128,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// that is larger than the texture size. /// that is larger than the texture size.
/// </summary> /// </summary>
/// <returns>The magnification filter</returns> /// <returns>The magnification filter</returns>
public MagFilter UnpackMagFilter() public readonly MagFilter UnpackMagFilter()
{ {
return (MagFilter)(Word1 & 3); return (MagFilter)(Word1 & 3);
} }
@ -139,7 +139,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// that is smaller than the texture size. /// that is smaller than the texture size.
/// </summary> /// </summary>
/// <returns>The minification filter</returns> /// <returns>The minification filter</returns>
public MinFilter UnpackMinFilter() public readonly MinFilter UnpackMinFilter()
{ {
SamplerMinFilter minFilter = (SamplerMinFilter)((Word1 >> 4) & 3); SamplerMinFilter minFilter = (SamplerMinFilter)((Word1 >> 4) & 3);
SamplerMipFilter mipFilter = (SamplerMipFilter)((Word1 >> 6) & 3); SamplerMipFilter mipFilter = (SamplerMipFilter)((Word1 >> 6) & 3);
@ -161,24 +161,30 @@ namespace Ryujinx.Graphics.Gpu.Image
case SamplerMipFilter.None: case SamplerMipFilter.None:
switch (minFilter) switch (minFilter)
{ {
case SamplerMinFilter.Nearest: return MinFilter.Nearest; case SamplerMinFilter.Nearest:
case SamplerMinFilter.Linear: return MinFilter.Linear; return MinFilter.Nearest;
case SamplerMinFilter.Linear:
return MinFilter.Linear;
} }
break; break;
case SamplerMipFilter.Nearest: case SamplerMipFilter.Nearest:
switch (minFilter) switch (minFilter)
{ {
case SamplerMinFilter.Nearest: return MinFilter.NearestMipmapNearest; case SamplerMinFilter.Nearest:
case SamplerMinFilter.Linear: return MinFilter.LinearMipmapNearest; return MinFilter.NearestMipmapNearest;
case SamplerMinFilter.Linear:
return MinFilter.LinearMipmapNearest;
} }
break; break;
case SamplerMipFilter.Linear: case SamplerMipFilter.Linear:
switch (minFilter) switch (minFilter)
{ {
case SamplerMinFilter.Nearest: return MinFilter.NearestMipmapLinear; case SamplerMinFilter.Nearest:
case SamplerMinFilter.Linear: return MinFilter.LinearMipmapLinear; return MinFilter.NearestMipmapLinear;
case SamplerMinFilter.Linear:
return MinFilter.LinearMipmapLinear;
} }
break; break;
} }
@ -190,7 +196,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the seamless cubemap flag. /// Unpacks the seamless cubemap flag.
/// </summary> /// </summary>
/// <returns>The seamless cubemap flag</returns> /// <returns>The seamless cubemap flag</returns>
public bool UnpackSeamlessCubemap() public readonly bool UnpackSeamlessCubemap()
{ {
return (Word1 & (1 << 9)) != 0; return (Word1 & (1 << 9)) != 0;
} }
@ -200,7 +206,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// This describes how the final value will be computed from neighbouring pixels. /// This describes how the final value will be computed from neighbouring pixels.
/// </summary> /// </summary>
/// <returns>The reduction filter</returns> /// <returns>The reduction filter</returns>
public ReductionFilter UnpackReductionFilter() public readonly ReductionFilter UnpackReductionFilter()
{ {
return (ReductionFilter)((Word1 >> 10) & 3); return (ReductionFilter)((Word1 >> 10) & 3);
} }
@ -211,7 +217,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// which mipmap level to use from a given texture. /// which mipmap level to use from a given texture.
/// </summary> /// </summary>
/// <returns>The level-of-detail bias value</returns> /// <returns>The level-of-detail bias value</returns>
public float UnpackMipLodBias() public readonly float UnpackMipLodBias()
{ {
int fixedValue = (int)(Word1 >> 12) & 0x1fff; int fixedValue = (int)(Word1 >> 12) & 0x1fff;
@ -224,7 +230,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the level-of-detail snap value. /// Unpacks the level-of-detail snap value.
/// </summary> /// </summary>
/// <returns>The level-of-detail snap value</returns> /// <returns>The level-of-detail snap value</returns>
public float UnpackLodSnap() public readonly float UnpackLodSnap()
{ {
return _f5ToF32ConversionLut[(Word1 >> 26) & 0x1f]; return _f5ToF32ConversionLut[(Word1 >> 26) & 0x1f];
} }
@ -233,7 +239,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the minimum level-of-detail value. /// Unpacks the minimum level-of-detail value.
/// </summary> /// </summary>
/// <returns>The minimum level-of-detail value</returns> /// <returns>The minimum level-of-detail value</returns>
public float UnpackMinLod() public readonly float UnpackMinLod()
{ {
return (Word2 & 0xfff) * Frac8ToF32; return (Word2 & 0xfff) * Frac8ToF32;
} }
@ -242,7 +248,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the maximum level-of-detail value. /// Unpacks the maximum level-of-detail value.
/// </summary> /// </summary>
/// <returns>The maximum level-of-detail value</returns> /// <returns>The maximum level-of-detail value</returns>
public float UnpackMaxLod() public readonly float UnpackMaxLod()
{ {
return ((Word2 >> 12) & 0xfff) * Frac8ToF32; return ((Word2 >> 12) & 0xfff) * Frac8ToF32;
} }

View file

@ -6,6 +6,6 @@ namespace Ryujinx.Graphics.Gpu.Image
enum SamplerMinFilter enum SamplerMinFilter
{ {
Nearest = 1, Nearest = 1,
Linear Linear,
} }
} }

View file

@ -7,6 +7,6 @@ namespace Ryujinx.Graphics.Gpu.Image
{ {
None = 1, None = 1,
Nearest, Nearest,
Linear Linear,
} }
} }

View file

@ -119,7 +119,7 @@ namespace Ryujinx.Graphics.Gpu.Image
private bool _modifiedStale = true; private bool _modifiedStale = true;
private ITexture _arrayViewTexture; private ITexture _arrayViewTexture;
private Target _arrayViewTarget; private Target _arrayViewTarget;
private ITexture _flushHostTexture; private ITexture _flushHostTexture;
private ITexture _setHostTexture; private ITexture _setHostTexture;
@ -334,7 +334,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <returns>The child texture</returns> /// <returns>The child texture</returns>
public Texture CreateView(TextureInfo info, SizeInfo sizeInfo, MultiRange range, int firstLayer, int firstLevel) public Texture CreateView(TextureInfo info, SizeInfo sizeInfo, MultiRange range, int firstLayer, int firstLevel)
{ {
Texture texture = new Texture( Texture texture = new(
_context, _context,
_physicalMemory, _physicalMemory,
info, info,
@ -523,7 +523,7 @@ namespace Ryujinx.Graphics.Gpu.Image
if (ScaleFactor != scale) if (ScaleFactor != scale)
{ {
Logger.Debug?.Print(LogClass.Gpu, $"Rescaling {Info.Width}x{Info.Height} {Info.FormatInfo.Format.ToString()} to ({ScaleFactor} to {scale}). "); Logger.Debug?.Print(LogClass.Gpu, $"Rescaling {Info.Width}x{Info.Height} {Info.FormatInfo.Format} to ({ScaleFactor} to {scale}). ");
ScaleFactor = scale; ScaleFactor = scale;
@ -537,7 +537,7 @@ namespace Ryujinx.Graphics.Gpu.Image
foreach (var view in _views) foreach (var view in _views)
{ {
Logger.Debug?.Print(LogClass.Gpu, $" Recreating view {Info.Width}x{Info.Height} {Info.FormatInfo.Format.ToString()}."); Logger.Debug?.Print(LogClass.Gpu, $" Recreating view {Info.Width}x{Info.Height} {Info.FormatInfo.Format}.");
view.ScaleFactor = scale; view.ScaleFactor = scale;
TextureCreateInfo viewCreateInfo = TextureCache.GetCreateInfo(view.Info, _context.Capabilities, scale); TextureCreateInfo viewCreateInfo = TextureCache.GetCreateInfo(view.Info, _context.Capabilities, scale);
@ -1254,7 +1254,7 @@ namespace Ryujinx.Graphics.Gpu.Image
{ {
FormatInfo formatInfo = TextureCompatibility.ToHostCompatibleFormat(Info, _context.Capabilities); FormatInfo formatInfo = TextureCompatibility.ToHostCompatibleFormat(Info, _context.Capabilities);
TextureCreateInfo createInfo = new TextureCreateInfo( TextureCreateInfo createInfo = new(
Info.Width, Info.Width,
Info.Height, Info.Height,
target == Target.CubemapArray ? 6 : 1, target == Target.CubemapArray ? 6 : 1,
@ -1274,7 +1274,7 @@ namespace Ryujinx.Graphics.Gpu.Image
ITexture viewTexture = HostTexture.CreateView(createInfo, 0, 0); ITexture viewTexture = HostTexture.CreateView(createInfo, 0, 0);
_arrayViewTexture = viewTexture; _arrayViewTexture = viewTexture;
_arrayViewTarget = target; _arrayViewTarget = target;
return viewTexture; return viewTexture;
} }
@ -1317,29 +1317,21 @@ namespace Ryujinx.Graphics.Gpu.Image
{ {
case Target.Texture1D: case Target.Texture1D:
case Target.Texture1DArray: case Target.Texture1DArray:
return target == Target.Texture1D || return target == Target.Texture1D || target == Target.Texture1DArray;
target == Target.Texture1DArray;
case Target.Texture2D: case Target.Texture2D:
case Target.Texture2DArray: case Target.Texture2DArray:
return target == Target.Texture2D || return target == Target.Texture2D || target == Target.Texture2DArray;
target == Target.Texture2DArray;
case Target.Cubemap: case Target.Cubemap:
case Target.CubemapArray: case Target.CubemapArray:
return target == Target.Cubemap || return target == Target.Cubemap || target == Target.CubemapArray;
target == Target.CubemapArray;
case Target.Texture2DMultisample: case Target.Texture2DMultisample:
case Target.Texture2DMultisampleArray: case Target.Texture2DMultisampleArray:
return target == Target.Texture2DMultisample || return target == Target.Texture2DMultisample || target == Target.Texture2DMultisampleArray;
target == Target.Texture2DMultisampleArray;
case Target.Texture3D: case Target.Texture3D:
return target == Target.Texture3D; return target == Target.Texture3D;
default:
return false;
} }
return false;
} }
/// <summary> /// <summary>
@ -1398,7 +1390,7 @@ namespace Ryujinx.Graphics.Gpu.Image
Height = info.Height; Height = info.Height;
CanForceAnisotropy = CanTextureForceAnisotropy(); CanForceAnisotropy = CanTextureForceAnisotropy();
_depth = info.GetDepth(); _depth = info.GetDepth();
_layers = info.GetLayers(); _layers = info.GetLayers();
} }

View file

@ -50,12 +50,12 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <param name="flags">The texture's usage flags, indicating how it is used in the shader</param> /// <param name="flags">The texture's usage flags, indicating how it is used in the shader</param>
public TextureBindingInfo(Target target, Format format, int binding, int cbufSlot, int handle, TextureUsageFlags flags) public TextureBindingInfo(Target target, Format format, int binding, int cbufSlot, int handle, TextureUsageFlags flags)
{ {
Target = target; Target = target;
Format = format; Format = format;
Binding = binding; Binding = binding;
CbufSlot = cbufSlot; CbufSlot = cbufSlot;
Handle = handle; Handle = handle;
Flags = flags; Flags = flags;
} }
/// <summary> /// <summary>

View file

@ -93,10 +93,10 @@ namespace Ryujinx.Graphics.Gpu.Image
int stages = isCompute ? 1 : Constants.ShaderStages; int stages = isCompute ? 1 : Constants.ShaderStages;
_textureBindings = new TextureBindingInfo[stages][]; _textureBindings = new TextureBindingInfo[stages][];
_imageBindings = new TextureBindingInfo[stages][]; _imageBindings = new TextureBindingInfo[stages][];
_textureState = new TextureState[InitialTextureStateSize]; _textureState = new TextureState[InitialTextureStateSize];
_imageState = new TextureState[InitialImageStateSize]; _imageState = new TextureState[InitialImageStateSize];
for (int stage = 0; stage < stages; stage++) for (int stage = 0; stage < stages; stage++)
{ {
@ -418,6 +418,7 @@ namespace Ryujinx.Graphics.Gpu.Image
} }
} }
#pragma warning disable IDE0051 // Remove unused private member
/// <summary> /// <summary>
/// Counts the total number of texture bindings used by all shader stages. /// Counts the total number of texture bindings used by all shader stages.
/// </summary> /// </summary>
@ -426,16 +427,17 @@ namespace Ryujinx.Graphics.Gpu.Image
{ {
int count = 0; int count = 0;
for (int i = 0; i < _textureBindings.Length; i++) foreach (TextureBindingInfo[] textureInfo in _textureBindings)
{ {
if (_textureBindings[i] != null) if (textureInfo != null)
{ {
count += _textureBindings[i].Length; count += textureInfo.Length;
} }
} }
return count; return count;
} }
#pragma warning restore IDE0051
/// <summary> /// <summary>
/// Ensures that the texture bindings are visible to the host GPU. /// Ensures that the texture bindings are visible to the host GPU.

View file

@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.Gpu.Image
} }
private const int OverlapsBufferInitialCapacity = 10; private const int OverlapsBufferInitialCapacity = 10;
private const int OverlapsBufferMaxCapacity = 10000; private const int OverlapsBufferMaxCapacity = 10000;
private readonly GpuContext _context; private readonly GpuContext _context;
private readonly PhysicalMemory _physicalMemory; private readonly PhysicalMemory _physicalMemory;
@ -278,7 +278,7 @@ namespace Ryujinx.Graphics.Gpu.Image
width = copyTexture.Width; width = copyTexture.Width;
} }
TextureInfo info = new TextureInfo( TextureInfo info = new(
copyTexture.Address.Pack() + offset, copyTexture.Address.Pack() + offset,
GetMinimumWidthInGob(width, sizeHint.Width, formatInfo.BytesPerPixel, copyTexture.LinearLayout), GetMinimumWidthInGob(width, sizeHint.Width, formatInfo.BytesPerPixel, copyTexture.LinearLayout),
copyTexture.Height, copyTexture.Height,
@ -371,16 +371,16 @@ namespace Ryujinx.Graphics.Gpu.Image
// so the width we get here is the aligned width. // so the width we get here is the aligned width.
if (isLinear) if (isLinear)
{ {
width = colorState.WidthOrStride / formatInfo.BytesPerPixel; width = colorState.WidthOrStride / formatInfo.BytesPerPixel;
stride = colorState.WidthOrStride; stride = colorState.WidthOrStride;
} }
else else
{ {
width = colorState.WidthOrStride; width = colorState.WidthOrStride;
stride = 0; stride = 0;
} }
TextureInfo info = new TextureInfo( TextureInfo info = new(
colorState.Address.Pack(), colorState.Address.Pack(),
GetMinimumWidthInGob(width, sizeHint.Width, formatInfo.BytesPerPixel, isLinear), GetMinimumWidthInGob(width, sizeHint.Width, formatInfo.BytesPerPixel, isLinear),
colorState.Height, colorState.Height,
@ -449,7 +449,7 @@ namespace Ryujinx.Graphics.Gpu.Image
FormatInfo formatInfo = dsState.Format.Convert(); FormatInfo formatInfo = dsState.Format.Convert();
TextureInfo info = new TextureInfo( TextureInfo info = new(
dsState.Address.Pack(), dsState.Address.Pack(),
GetMinimumWidthInGob(size.Width, sizeHint.Width, formatInfo.BytesPerPixel, false), GetMinimumWidthInGob(size.Width, sizeHint.Width, formatInfo.BytesPerPixel, false),
size.Height, size.Height,
@ -1136,14 +1136,14 @@ namespace Ryujinx.Graphics.Gpu.Image
} }
} }
int width = info.Width / info.SamplesInX; int width = info.Width / info.SamplesInX;
int height = info.Height / info.SamplesInY; int height = info.Height / info.SamplesInY;
int depth = info.GetDepth() * info.GetLayers(); int depth = info.GetDepth() * info.GetLayers();
if (scale != 1f) if (scale != 1f)
{ {
width = (int)MathF.Ceiling(width * scale); width = (int)MathF.Ceiling(width * scale);
height = (int)MathF.Ceiling(height * scale); height = (int)MathF.Ceiling(height * scale);
} }

View file

@ -35,7 +35,7 @@ namespace Ryujinx.Graphics.Gpu.Image
Astc10x8, Astc10x8,
Astc10x10, Astc10x10,
Astc12x10, Astc12x10,
Astc12x12 Astc12x12,
} }
/// <summary> /// <summary>
@ -629,7 +629,7 @@ namespace Ryujinx.Graphics.Gpu.Image
{ {
TextureMatchQuality.Perfect => TextureViewCompatibility.Full, TextureMatchQuality.Perfect => TextureViewCompatibility.Full,
TextureMatchQuality.FormatAlias => TextureViewCompatibility.FormatAlias, TextureMatchQuality.FormatAlias => TextureViewCompatibility.FormatAlias,
_ => TextureViewCompatibility.Incompatible _ => TextureViewCompatibility.Incompatible,
}; };
} }
@ -783,80 +783,33 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <returns>Format class</returns> /// <returns>Format class</returns>
private static FormatClass GetFormatClass(Format format) private static FormatClass GetFormatClass(Format format)
{ {
switch (format) return format switch
{ {
case Format.Bc1RgbaSrgb: Format.Bc1RgbaSrgb or Format.Bc1RgbaUnorm => FormatClass.Bc1Rgba,
case Format.Bc1RgbaUnorm: Format.Bc2Srgb or Format.Bc2Unorm => FormatClass.Bc2,
return FormatClass.Bc1Rgba; Format.Bc3Srgb or Format.Bc3Unorm => FormatClass.Bc3,
case Format.Bc2Srgb: Format.Bc4Snorm or Format.Bc4Unorm => FormatClass.Bc4,
case Format.Bc2Unorm: Format.Bc5Snorm or Format.Bc5Unorm => FormatClass.Bc5,
return FormatClass.Bc2; Format.Bc6HSfloat or Format.Bc6HUfloat => FormatClass.Bc6,
case Format.Bc3Srgb: Format.Bc7Srgb or Format.Bc7Unorm => FormatClass.Bc7,
case Format.Bc3Unorm: Format.Etc2RgbSrgb or Format.Etc2RgbUnorm => FormatClass.Etc2Rgb,
return FormatClass.Bc3; Format.Etc2RgbaSrgb or Format.Etc2RgbaUnorm => FormatClass.Etc2Rgba,
case Format.Bc4Snorm: Format.Astc4x4Srgb or Format.Astc4x4Unorm => FormatClass.Astc4x4,
case Format.Bc4Unorm: Format.Astc5x4Srgb or Format.Astc5x4Unorm => FormatClass.Astc5x4,
return FormatClass.Bc4; Format.Astc5x5Srgb or Format.Astc5x5Unorm => FormatClass.Astc5x5,
case Format.Bc5Snorm: Format.Astc6x5Srgb or Format.Astc6x5Unorm => FormatClass.Astc6x5,
case Format.Bc5Unorm: Format.Astc6x6Srgb or Format.Astc6x6Unorm => FormatClass.Astc6x6,
return FormatClass.Bc5; Format.Astc8x5Srgb or Format.Astc8x5Unorm => FormatClass.Astc8x5,
case Format.Bc6HSfloat: Format.Astc8x6Srgb or Format.Astc8x6Unorm => FormatClass.Astc8x6,
case Format.Bc6HUfloat: Format.Astc8x8Srgb or Format.Astc8x8Unorm => FormatClass.Astc8x8,
return FormatClass.Bc6; Format.Astc10x5Srgb or Format.Astc10x5Unorm => FormatClass.Astc10x5,
case Format.Bc7Srgb: Format.Astc10x6Srgb or Format.Astc10x6Unorm => FormatClass.Astc10x6,
case Format.Bc7Unorm: Format.Astc10x8Srgb or Format.Astc10x8Unorm => FormatClass.Astc10x8,
return FormatClass.Bc7; Format.Astc10x10Srgb or Format.Astc10x10Unorm => FormatClass.Astc10x10,
case Format.Etc2RgbSrgb: Format.Astc12x10Srgb or Format.Astc12x10Unorm => FormatClass.Astc12x10,
case Format.Etc2RgbUnorm: Format.Astc12x12Srgb or Format.Astc12x12Unorm => FormatClass.Astc12x12,
return FormatClass.Etc2Rgb; _ => FormatClass.Unclassified,
case Format.Etc2RgbaSrgb: };
case Format.Etc2RgbaUnorm:
return FormatClass.Etc2Rgba;
case Format.Astc4x4Srgb:
case Format.Astc4x4Unorm:
return FormatClass.Astc4x4;
case Format.Astc5x4Srgb:
case Format.Astc5x4Unorm:
return FormatClass.Astc5x4;
case Format.Astc5x5Srgb:
case Format.Astc5x5Unorm:
return FormatClass.Astc5x5;
case Format.Astc6x5Srgb:
case Format.Astc6x5Unorm:
return FormatClass.Astc6x5;
case Format.Astc6x6Srgb:
case Format.Astc6x6Unorm:
return FormatClass.Astc6x6;
case Format.Astc8x5Srgb:
case Format.Astc8x5Unorm:
return FormatClass.Astc8x5;
case Format.Astc8x6Srgb:
case Format.Astc8x6Unorm:
return FormatClass.Astc8x6;
case Format.Astc8x8Srgb:
case Format.Astc8x8Unorm:
return FormatClass.Astc8x8;
case Format.Astc10x5Srgb:
case Format.Astc10x5Unorm:
return FormatClass.Astc10x5;
case Format.Astc10x6Srgb:
case Format.Astc10x6Unorm:
return FormatClass.Astc10x6;
case Format.Astc10x8Srgb:
case Format.Astc10x8Unorm:
return FormatClass.Astc10x8;
case Format.Astc10x10Srgb:
case Format.Astc10x10Unorm:
return FormatClass.Astc10x10;
case Format.Astc12x10Srgb:
case Format.Astc12x10Unorm:
return FormatClass.Astc12x10;
case Format.Astc12x12Srgb:
case Format.Astc12x12Unorm:
return FormatClass.Astc12x12;
}
return FormatClass.Unclassified;
} }
} }
} }

View file

@ -7,13 +7,13 @@ namespace Ryujinx.Graphics.Gpu.Image
/// </summary> /// </summary>
enum TextureComponent enum TextureComponent
{ {
Zero = 0, Zero = 0,
Red = 2, Red = 2,
Green = 3, Green = 3,
Blue = 4, Blue = 4,
Alpha = 5, Alpha = 5,
OneSI = 6, OneSI = 6,
OneF = 7 OneF = 7,
} }
static class TextureComponentConverter static class TextureComponentConverter
@ -25,19 +25,16 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <returns>Converted enum</returns> /// <returns>Converted enum</returns>
public static SwizzleComponent Convert(this TextureComponent component) public static SwizzleComponent Convert(this TextureComponent component)
{ {
switch (component) return component switch
{ {
case TextureComponent.Zero: return SwizzleComponent.Zero; TextureComponent.Zero => SwizzleComponent.Zero,
case TextureComponent.Red: return SwizzleComponent.Red; TextureComponent.Red => SwizzleComponent.Red,
case TextureComponent.Green: return SwizzleComponent.Green; TextureComponent.Green => SwizzleComponent.Green,
case TextureComponent.Blue: return SwizzleComponent.Blue; TextureComponent.Blue => SwizzleComponent.Blue,
case TextureComponent.Alpha: return SwizzleComponent.Alpha; TextureComponent.Alpha => SwizzleComponent.Alpha,
case TextureComponent.OneSI: TextureComponent.OneSI or TextureComponent.OneF => SwizzleComponent.One,
case TextureComponent.OneF: _ => SwizzleComponent.Zero,
return SwizzleComponent.One; };
}
return SwizzleComponent.Zero;
} }
} }
} }

View file

@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// </summary> /// </summary>
struct TextureDescriptor : ITextureDescriptor, IEquatable<TextureDescriptor> struct TextureDescriptor : ITextureDescriptor, IEquatable<TextureDescriptor>
{ {
#pragma warning disable CS0649 #pragma warning disable CS0649 // Field is never assigned to
public uint Word0; public uint Word0;
public uint Word1; public uint Word1;
public uint Word2; public uint Word2;
@ -24,7 +24,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks Maxwell texture format integer. /// Unpacks Maxwell texture format integer.
/// </summary> /// </summary>
/// <returns>The texture format integer</returns> /// <returns>The texture format integer</returns>
public uint UnpackFormat() public readonly uint UnpackFormat()
{ {
return Word0 & 0x8007ffff; return Word0 & 0x8007ffff;
} }
@ -33,43 +33,43 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the swizzle component for the texture red color channel. /// Unpacks the swizzle component for the texture red color channel.
/// </summary> /// </summary>
/// <returns>The swizzle component</returns> /// <returns>The swizzle component</returns>
public TextureComponent UnpackSwizzleR() public readonly TextureComponent UnpackSwizzleR()
{ {
return(TextureComponent)((Word0 >> 19) & 7); return (TextureComponent)((Word0 >> 19) & 7);
} }
/// <summary> /// <summary>
/// Unpacks the swizzle component for the texture green color channel. /// Unpacks the swizzle component for the texture green color channel.
/// </summary> /// </summary>
/// <returns>The swizzle component</returns> /// <returns>The swizzle component</returns>
public TextureComponent UnpackSwizzleG() public readonly TextureComponent UnpackSwizzleG()
{ {
return(TextureComponent)((Word0 >> 22) & 7); return (TextureComponent)((Word0 >> 22) & 7);
} }
/// <summary> /// <summary>
/// Unpacks the swizzle component for the texture blue color channel. /// Unpacks the swizzle component for the texture blue color channel.
/// </summary> /// </summary>
/// <returns>The swizzle component</returns> /// <returns>The swizzle component</returns>
public TextureComponent UnpackSwizzleB() public readonly TextureComponent UnpackSwizzleB()
{ {
return(TextureComponent)((Word0 >> 25) & 7); return (TextureComponent)((Word0 >> 25) & 7);
} }
/// <summary> /// <summary>
/// Unpacks the swizzle component for the texture alpha color channel. /// Unpacks the swizzle component for the texture alpha color channel.
/// </summary> /// </summary>
/// <returns>The swizzle component</returns> /// <returns>The swizzle component</returns>
public TextureComponent UnpackSwizzleA() public readonly TextureComponent UnpackSwizzleA()
{ {
return(TextureComponent)((Word0 >> 28) & 7); return (TextureComponent)((Word0 >> 28) & 7);
} }
/// <summary> /// <summary>
/// Unpacks the 40-bits texture GPU virtual address. /// Unpacks the 40-bits texture GPU virtual address.
/// </summary> /// </summary>
/// <returns>The GPU virtual address</returns> /// <returns>The GPU virtual address</returns>
public ulong UnpackAddress() public readonly ulong UnpackAddress()
{ {
return Word1 | ((ulong)(Word2 & 0xffff) << 32); return Word1 | ((ulong)(Word2 & 0xffff) << 32);
} }
@ -79,7 +79,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// This defines the texture layout, among other things. /// This defines the texture layout, among other things.
/// </summary> /// </summary>
/// <returns>The texture descriptor type</returns> /// <returns>The texture descriptor type</returns>
public TextureDescriptorType UnpackTextureDescriptorType() public readonly TextureDescriptorType UnpackTextureDescriptorType()
{ {
return (TextureDescriptorType)((Word2 >> 21) & 7); return (TextureDescriptorType)((Word2 >> 21) & 7);
} }
@ -89,7 +89,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Always 32-bytes aligned. /// Always 32-bytes aligned.
/// </summary> /// </summary>
/// <returns>The linear texture stride</returns> /// <returns>The linear texture stride</returns>
public int UnpackStride() public readonly int UnpackStride()
{ {
return (int)(Word3 & 0xffff) << 5; return (int)(Word3 & 0xffff) << 5;
} }
@ -99,7 +99,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Must be always 1, ignored by the GPU. /// Must be always 1, ignored by the GPU.
/// </summary> /// </summary>
/// <returns>THe GOB block X size</returns> /// <returns>THe GOB block X size</returns>
public int UnpackGobBlocksInX() public readonly int UnpackGobBlocksInX()
{ {
return 1 << (int)(Word3 & 7); return 1 << (int)(Word3 & 7);
} }
@ -109,7 +109,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Must be always a power of 2, with a maximum value of 32. /// Must be always a power of 2, with a maximum value of 32.
/// </summary> /// </summary>
/// <returns>THe GOB block Y size</returns> /// <returns>THe GOB block Y size</returns>
public int UnpackGobBlocksInY() public readonly int UnpackGobBlocksInY()
{ {
return 1 << (int)((Word3 >> 3) & 7); return 1 << (int)((Word3 >> 3) & 7);
} }
@ -120,7 +120,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Must be 1 for any texture target other than 3D textures. /// Must be 1 for any texture target other than 3D textures.
/// </summary> /// </summary>
/// <returns>The GOB block Z size</returns> /// <returns>The GOB block Z size</returns>
public int UnpackGobBlocksInZ() public readonly int UnpackGobBlocksInZ()
{ {
return 1 << (int)((Word3 >> 6) & 7); return 1 << (int)((Word3 >> 6) & 7);
} }
@ -130,7 +130,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// This is only used for sparse textures, should be 1 otherwise. /// This is only used for sparse textures, should be 1 otherwise.
/// </summary> /// </summary>
/// <returns>The number of GOB blocks per tile</returns> /// <returns>The number of GOB blocks per tile</returns>
public int UnpackGobBlocksInTileX() public readonly int UnpackGobBlocksInTileX()
{ {
return 1 << (int)((Word3 >> 10) & 7); return 1 << (int)((Word3 >> 10) & 7);
} }
@ -139,7 +139,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the number of mipmap levels of the texture. /// Unpacks the number of mipmap levels of the texture.
/// </summary> /// </summary>
/// <returns>The number of mipmap levels</returns> /// <returns>The number of mipmap levels</returns>
public int UnpackLevels() public readonly int UnpackLevels()
{ {
return (int)(Word3 >> 28) + 1; return (int)(Word3 >> 28) + 1;
} }
@ -148,7 +148,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpack the base level texture width size. /// Unpack the base level texture width size.
/// </summary> /// </summary>
/// <returns>The texture width</returns> /// <returns>The texture width</returns>
public int UnpackWidth() public readonly int UnpackWidth()
{ {
return (int)(Word4 & 0xffff) + 1; return (int)(Word4 & 0xffff) + 1;
} }
@ -157,7 +157,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpack the width of a buffer texture. /// Unpack the width of a buffer texture.
/// </summary> /// </summary>
/// <returns>The texture width</returns> /// <returns>The texture width</returns>
public int UnpackBufferTextureWidth() public readonly int UnpackBufferTextureWidth()
{ {
return (int)((Word4 & 0xffff) | (Word3 << 16)) + 1; return (int)((Word4 & 0xffff) | (Word3 << 16)) + 1;
} }
@ -166,7 +166,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the texture sRGB format flag. /// Unpacks the texture sRGB format flag.
/// </summary> /// </summary>
/// <returns>True if the texture is sRGB, false otherwise</returns> /// <returns>True if the texture is sRGB, false otherwise</returns>
public bool UnpackSrgb() public readonly bool UnpackSrgb()
{ {
return (Word4 & (1 << 22)) != 0; return (Word4 & (1 << 22)) != 0;
} }
@ -175,7 +175,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the texture target. /// Unpacks the texture target.
/// </summary> /// </summary>
/// <returns>The texture target</returns> /// <returns>The texture target</returns>
public TextureTarget UnpackTextureTarget() public readonly TextureTarget UnpackTextureTarget()
{ {
return (TextureTarget)((Word4 >> 23) & 0xf); return (TextureTarget)((Word4 >> 23) & 0xf);
} }
@ -185,7 +185,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Should be ignored for 1D or buffer textures. /// Should be ignored for 1D or buffer textures.
/// </summary> /// </summary>
/// <returns>The texture height or layers count</returns> /// <returns>The texture height or layers count</returns>
public int UnpackHeight() public readonly int UnpackHeight()
{ {
return (int)(Word5 & 0xffff) + 1; return (int)(Word5 & 0xffff) + 1;
} }
@ -195,7 +195,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// The meaning of this value depends on the texture target. /// The meaning of this value depends on the texture target.
/// </summary> /// </summary>
/// <returns>The texture depth, layer or faces count</returns> /// <returns>The texture depth, layer or faces count</returns>
public int UnpackDepth() public readonly int UnpackDepth()
{ {
return (int)((Word5 >> 16) & 0x3fff) + 1; return (int)((Word5 >> 16) & 0x3fff) + 1;
} }
@ -207,7 +207,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// It must be set to false (by the guest driver) for rectangle textures. /// It must be set to false (by the guest driver) for rectangle textures.
/// </summary> /// </summary>
/// <returns>The texture coordinates normalized flag</returns> /// <returns>The texture coordinates normalized flag</returns>
public bool UnpackTextureCoordNormalized() public readonly bool UnpackTextureCoordNormalized()
{ {
return (Word5 & (1 << 31)) != 0; return (Word5 & (1 << 31)) != 0;
} }
@ -216,7 +216,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Unpacks the base mipmap level of the texture. /// Unpacks the base mipmap level of the texture.
/// </summary> /// </summary>
/// <returns>The base mipmap level of the texture</returns> /// <returns>The base mipmap level of the texture</returns>
public int UnpackBaseLevel() public readonly int UnpackBaseLevel()
{ {
return (int)(Word7 & 0xf); return (int)(Word7 & 0xf);
} }
@ -226,7 +226,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Usually equal to Levels minus 1. /// Usually equal to Levels minus 1.
/// </summary> /// </summary>
/// <returns>The maximum mipmap level (inclusive) of the texture</returns> /// <returns>The maximum mipmap level (inclusive) of the texture</returns>
public int UnpackMaxLevelInclusive() public readonly int UnpackMaxLevelInclusive()
{ {
return (int)((Word7 >> 4) & 0xf); return (int)((Word7 >> 4) & 0xf);
} }
@ -236,7 +236,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Must be ignored for non-multisample textures. /// Must be ignored for non-multisample textures.
/// </summary> /// </summary>
/// <returns>The multisample counts enum</returns> /// <returns>The multisample counts enum</returns>
public TextureMsaaMode UnpackTextureMsaaMode() public readonly TextureMsaaMode UnpackTextureMsaaMode()
{ {
return (TextureMsaaMode)((Word7 >> 8) & 0xf); return (TextureMsaaMode)((Word7 >> 8) & 0xf);
} }
@ -269,5 +269,10 @@ namespace Ryujinx.Graphics.Gpu.Image
{ {
return Unsafe.As<TextureDescriptor, Vector256<byte>>(ref this).GetHashCode(); return Unsafe.As<TextureDescriptor, Vector256<byte>>(ref this).GetHashCode();
} }
public override bool Equals(object obj)
{
return obj is TextureDescriptor descriptor && Equals(descriptor);
}
} }
} }

View file

@ -11,6 +11,6 @@ namespace Ryujinx.Graphics.Gpu.Image
LinearColorKey, LinearColorKey,
Linear, Linear,
BlockLinear, BlockLinear,
BlockLinearColorKey BlockLinearColorKey,
} }
} }

View file

@ -78,11 +78,11 @@ namespace Ryujinx.Graphics.Gpu.Image
private int[] _allOffsets; private int[] _allOffsets;
private int[] _sliceSizes; private int[] _sliceSizes;
private bool _is3D; private readonly bool _is3D;
private bool _hasMipViews; private bool _hasMipViews;
private bool _hasLayerViews; private bool _hasLayerViews;
private int _layers; private readonly int _layers;
private int _levels; private readonly int _levels;
private MultiRange TextureRange => Storage.Range; private MultiRange TextureRange => Storage.Range;
@ -96,9 +96,9 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <summary> /// <summary>
/// Other texture groups that have incompatible overlaps with this one. /// Other texture groups that have incompatible overlaps with this one.
/// </summary> /// </summary>
private List<TextureIncompatibleOverlap> _incompatibleOverlaps; private readonly List<TextureIncompatibleOverlap> _incompatibleOverlaps;
private bool _incompatibleOverlapsDirty = true; private bool _incompatibleOverlapsDirty = true;
private bool _flushIncompatibleOverlaps; private readonly bool _flushIncompatibleOverlaps;
private BufferHandle _flushBuffer; private BufferHandle _flushBuffer;
private bool _flushBufferImported; private bool _flushBufferImported;
@ -423,7 +423,7 @@ namespace Ryujinx.Graphics.Gpu.Image
int offsetIndex = GetOffsetIndex(info.BaseLayer + layer, info.BaseLevel + level); int offsetIndex = GetOffsetIndex(info.BaseLayer + layer, info.BaseLevel + level);
int offset = _allOffsets[offsetIndex]; int offset = _allOffsets[offsetIndex];
ReadOnlySpan<byte> data = dataSpan.Slice(offset - spanBase); ReadOnlySpan<byte> data = dataSpan[(offset - spanBase)..];
SpanOrArray<byte> result = Storage.ConvertToHostCompatibleFormat(data, info.BaseLevel + level, true); SpanOrArray<byte> result = Storage.ConvertToHostCompatibleFormat(data, info.BaseLevel + level, true);
@ -1500,13 +1500,13 @@ namespace Ryujinx.Graphics.Gpu.Image
{ {
for (int i = 0; i < _allOffsets.Length; i++) for (int i = 0; i < _allOffsets.Length; i++)
{ {
(int layer, int level) = GetLayerLevelForView(i); (_, int level) = GetLayerLevelForView(i);
MultiRange handleRange = Storage.Range.Slice((ulong)_allOffsets[i], 1); MultiRange handleRange = Storage.Range.Slice((ulong)_allOffsets[i], 1);
ulong handleBase = handleRange.GetSubRange(0).Address; ulong handleBase = handleRange.GetSubRange(0).Address;
for (int j = 0; j < other._handles.Length; j++) for (int j = 0; j < other._handles.Length; j++)
{ {
(int otherLayer, int otherLevel) = other.GetLayerLevelForView(j); (_, int otherLevel) = other.GetLayerLevelForView(j);
MultiRange otherHandleRange = other.Storage.Range.Slice((ulong)other._allOffsets[j], 1); MultiRange otherHandleRange = other.Storage.Range.Slice((ulong)other._allOffsets[j], 1);
ulong otherHandleBase = otherHandleRange.GetSubRange(0).Address; ulong otherHandleBase = otherHandleRange.GetSubRange(0).Address;

View file

@ -22,10 +22,10 @@ namespace Ryujinx.Graphics.Gpu.Image
private const int FlushBalanceMax = 60; private const int FlushBalanceMax = 60;
private const int FlushBalanceMin = -10; private const int FlushBalanceMin = -10;
private TextureGroup _group; private readonly TextureGroup _group;
private int _bindCount; private int _bindCount;
private int _firstLevel; private readonly int _firstLevel;
private int _firstLayer; private readonly int _firstLayer;
// Sync state for texture flush. // Sync state for texture flush.
@ -463,8 +463,8 @@ namespace Ryujinx.Graphics.Gpu.Image
_group.HasCopyDependencies = true; _group.HasCopyDependencies = true;
other._group.HasCopyDependencies = true; other._group.HasCopyDependencies = true;
TextureDependency dependency = new TextureDependency(this); TextureDependency dependency = new(this);
TextureDependency otherDependency = new TextureDependency(other); TextureDependency otherDependency = new(other);
dependency.Other = otherDependency; dependency.Other = otherDependency;
otherDependency.Other = dependency; otherDependency.Other = dependency;

View file

@ -134,45 +134,45 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <param name="swizzleB">Swizzle for the blue color channel</param> /// <param name="swizzleB">Swizzle for the blue color channel</param>
/// <param name="swizzleA">Swizzle for the alpha color channel</param> /// <param name="swizzleA">Swizzle for the alpha color channel</param>
public TextureInfo( public TextureInfo(
ulong gpuAddress, ulong gpuAddress,
int width, int width,
int height, int height,
int depthOrLayers, int depthOrLayers,
int levels, int levels,
int samplesInX, int samplesInX,
int samplesInY, int samplesInY,
int stride, int stride,
bool isLinear, bool isLinear,
int gobBlocksInY, int gobBlocksInY,
int gobBlocksInZ, int gobBlocksInZ,
int gobBlocksInTileX, int gobBlocksInTileX,
Target target, Target target,
FormatInfo formatInfo, FormatInfo formatInfo,
DepthStencilMode depthStencilMode = DepthStencilMode.Depth, DepthStencilMode depthStencilMode = DepthStencilMode.Depth,
SwizzleComponent swizzleR = SwizzleComponent.Red, SwizzleComponent swizzleR = SwizzleComponent.Red,
SwizzleComponent swizzleG = SwizzleComponent.Green, SwizzleComponent swizzleG = SwizzleComponent.Green,
SwizzleComponent swizzleB = SwizzleComponent.Blue, SwizzleComponent swizzleB = SwizzleComponent.Blue,
SwizzleComponent swizzleA = SwizzleComponent.Alpha) SwizzleComponent swizzleA = SwizzleComponent.Alpha)
{ {
GpuAddress = gpuAddress; GpuAddress = gpuAddress;
Width = width; Width = width;
Height = height; Height = height;
DepthOrLayers = depthOrLayers; DepthOrLayers = depthOrLayers;
Levels = levels; Levels = levels;
SamplesInX = samplesInX; SamplesInX = samplesInX;
SamplesInY = samplesInY; SamplesInY = samplesInY;
Stride = stride; Stride = stride;
IsLinear = isLinear; IsLinear = isLinear;
GobBlocksInY = gobBlocksInY; GobBlocksInY = gobBlocksInY;
GobBlocksInZ = gobBlocksInZ; GobBlocksInZ = gobBlocksInZ;
GobBlocksInTileX = gobBlocksInTileX; GobBlocksInTileX = gobBlocksInTileX;
Target = target; Target = target;
FormatInfo = formatInfo; FormatInfo = formatInfo;
DepthStencilMode = depthStencilMode; DepthStencilMode = depthStencilMode;
SwizzleR = swizzleR; SwizzleR = swizzleR;
SwizzleG = swizzleG; SwizzleG = swizzleG;
SwizzleB = swizzleB; SwizzleB = swizzleB;
SwizzleA = swizzleA; SwizzleA = swizzleA;
} }
/// <summary> /// <summary>
@ -318,17 +318,17 @@ namespace Ryujinx.Graphics.Gpu.Image
// - If the parent format is not compressed, and the view is, the view // - If the parent format is not compressed, and the view is, the view
// size is calculated as described on the first point, but the width and height // size is calculated as described on the first point, but the width and height
// of the view must be also multiplied by the block width and height. // of the view must be also multiplied by the block width and height.
int width = Math.Max(1, parent.Info.Width >> firstLevel); int width = Math.Max(1, parent.Info.Width >> firstLevel);
int height = Math.Max(1, parent.Info.Height >> firstLevel); int height = Math.Max(1, parent.Info.Height >> firstLevel);
if (parent.Info.FormatInfo.IsCompressed && !FormatInfo.IsCompressed) if (parent.Info.FormatInfo.IsCompressed && !FormatInfo.IsCompressed)
{ {
width = BitUtils.DivRoundUp(width, parent.Info.FormatInfo.BlockWidth); width = BitUtils.DivRoundUp(width, parent.Info.FormatInfo.BlockWidth);
height = BitUtils.DivRoundUp(height, parent.Info.FormatInfo.BlockHeight); height = BitUtils.DivRoundUp(height, parent.Info.FormatInfo.BlockHeight);
} }
else if (!parent.Info.FormatInfo.IsCompressed && FormatInfo.IsCompressed) else if (!parent.Info.FormatInfo.IsCompressed && FormatInfo.IsCompressed)
{ {
width *= FormatInfo.BlockWidth; width *= FormatInfo.BlockWidth;
height *= FormatInfo.BlockHeight; height *= FormatInfo.BlockHeight;
} }

View file

@ -41,8 +41,8 @@ namespace Ryujinx.Graphics.Gpu.Image
_context = context; _context = context;
_channel = channel; _channel = channel;
TexturePoolCache texturePoolCache = new TexturePoolCache(context); TexturePoolCache texturePoolCache = new(context);
SamplerPoolCache samplerPoolCache = new SamplerPoolCache(context); SamplerPoolCache samplerPoolCache = new(context);
float[] scales = new float[64]; float[] scales = new float[64];
new Span<float>(scales).Fill(1f); new Span<float>(scales).Fill(1f);
@ -139,7 +139,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// </summary> /// </summary>
/// <param name="texture">The texture to check</param> /// <param name="texture">The texture to check</param>
/// <returns>True if the scale needs updating, false if the scale is up to date</returns> /// <returns>True if the scale needs updating, false if the scale is up to date</returns>
private bool ScaleNeedsUpdated(Texture texture) private static bool ScaleNeedsUpdated(Texture texture)
{ {
return texture != null && !(texture.ScaleMode == TextureScaleMode.Blacklisted || texture.ScaleMode == TextureScaleMode.Undesired) && texture.ScaleFactor != GraphicsConfig.ResScale; return texture != null && !(texture.ScaleMode == TextureScaleMode.Blacklisted || texture.ScaleMode == TextureScaleMode.Undesired) && texture.ScaleFactor != GraphicsConfig.ResScale;
} }
@ -234,7 +234,11 @@ namespace Ryujinx.Graphics.Gpu.Image
void ConsiderTarget(Texture target) void ConsiderTarget(Texture target)
{ {
if (target == null) return; if (target == null)
{
return;
}
float scale = target.ScaleFactor; float scale = target.ScaleFactor;
switch (target.ScaleMode) switch (target.ScaleMode)
@ -445,7 +449,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// </remarks> /// </remarks>
public void UpdateRenderTargetDepthStencil() public void UpdateRenderTargetDepthStencil()
{ {
new Span<ITexture>(_rtHostColors).Fill(null); new Span<ITexture>(_rtHostColors).Clear();
_rtHostDs = _rtDepthStencil?.HostTexture; _rtHostDs = _rtDepthStencil?.HostTexture;
_context.Renderer.Pipeline.SetRenderTargets(_rtHostColors, _rtHostDs); _context.Renderer.Pipeline.SetRenderTargets(_rtHostColors, _rtHostDs);

View file

@ -4,6 +4,6 @@
{ {
NoMatch, NoMatch,
FormatAlias, FormatAlias,
Perfect Perfect,
} }
} }

View file

@ -9,7 +9,7 @@ namespace Ryujinx.Graphics.Gpu.Image
Ms2x2 = 2, Ms2x2 = 2,
Ms4x2 = 4, Ms4x2 = 4,
Ms2x1 = 5, Ms2x1 = 5,
Ms4x4 = 6 Ms4x4 = 6,
} }
static class TextureMsaaModeConverter static class TextureMsaaModeConverter
@ -27,7 +27,7 @@ namespace Ryujinx.Graphics.Gpu.Image
TextureMsaaMode.Ms2x2 => 4, TextureMsaaMode.Ms2x2 => 4,
TextureMsaaMode.Ms4x2 => 8, TextureMsaaMode.Ms4x2 => 8,
TextureMsaaMode.Ms4x4 => 16, TextureMsaaMode.Ms4x4 => 16,
_ => 1 _ => 1,
}; };
} }
@ -44,7 +44,7 @@ namespace Ryujinx.Graphics.Gpu.Image
TextureMsaaMode.Ms2x2 => 2, TextureMsaaMode.Ms2x2 => 2,
TextureMsaaMode.Ms4x2 => 4, TextureMsaaMode.Ms4x2 => 4,
TextureMsaaMode.Ms4x4 => 4, TextureMsaaMode.Ms4x4 => 4,
_ => 1 _ => 1,
}; };
} }
@ -61,7 +61,7 @@ namespace Ryujinx.Graphics.Gpu.Image
TextureMsaaMode.Ms2x2 => 2, TextureMsaaMode.Ms2x2 => 2,
TextureMsaaMode.Ms4x2 => 2, TextureMsaaMode.Ms4x2 => 2,
TextureMsaaMode.Ms4x4 => 4, TextureMsaaMode.Ms4x4 => 4,
_ => 1 _ => 1,
}; };
} }
} }

View file

@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <summary> /// <summary>
/// A request to dereference a texture from a pool. /// A request to dereference a texture from a pool.
/// </summary> /// </summary>
private struct DereferenceRequest private readonly struct DereferenceRequest
{ {
/// <summary> /// <summary>
/// Whether the dereference is due to a mapping change or not. /// Whether the dereference is due to a mapping change or not.
@ -71,7 +71,7 @@ namespace Ryujinx.Graphics.Gpu.Image
} }
private readonly GpuChannel _channel; private readonly GpuChannel _channel;
private readonly ConcurrentQueue<DereferenceRequest> _dereferenceQueue = new ConcurrentQueue<DereferenceRequest>(); private readonly ConcurrentQueue<DereferenceRequest> _dereferenceQueue = new();
private TextureDescriptor _defaultDescriptor; private TextureDescriptor _defaultDescriptor;
/// <summary> /// <summary>
@ -379,10 +379,10 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <param name="descriptor">The texture descriptor</param> /// <param name="descriptor">The texture descriptor</param>
/// <param name="layerSize">Layer size for textures using a sub-range of mipmap levels, otherwise 0</param> /// <param name="layerSize">Layer size for textures using a sub-range of mipmap levels, otherwise 0</param>
/// <returns>The texture information</returns> /// <returns>The texture information</returns>
private TextureInfo GetInfo(in TextureDescriptor descriptor, out int layerSize) private static TextureInfo GetInfo(in TextureDescriptor descriptor, out int layerSize)
{ {
int depthOrLayers = descriptor.UnpackDepth(); int depthOrLayers = descriptor.UnpackDepth();
int levels = descriptor.UnpackLevels(); int levels = descriptor.UnpackLevels();
TextureMsaaMode msaaMode = descriptor.UnpackTextureMsaaMode(); TextureMsaaMode msaaMode = descriptor.UnpackTextureMsaaMode();
@ -424,7 +424,7 @@ namespace Ryujinx.Graphics.Gpu.Image
} }
uint format = descriptor.UnpackFormat(); uint format = descriptor.UnpackFormat();
bool srgb = descriptor.UnpackSrgb(); bool srgb = descriptor.UnpackSrgb();
ulong gpuVa = descriptor.UnpackAddress(); ulong gpuVa = descriptor.UnpackAddress();
@ -451,7 +451,7 @@ namespace Ryujinx.Graphics.Gpu.Image
// Linear textures don't support mipmaps, so we don't handle this case here. // Linear textures don't support mipmaps, so we don't handle this case here.
if ((minLod != 0 || maxLod + 1 != levels) && target != Target.TextureBuffer && !isLinear) if ((minLod != 0 || maxLod + 1 != levels) && target != Target.TextureBuffer && !isLinear)
{ {
int depth = TextureInfo.GetDepth(target, depthOrLayers); int depth = TextureInfo.GetDepth(target, depthOrLayers);
int layers = TextureInfo.GetLayers(target, depthOrLayers); int layers = TextureInfo.GetLayers(target, depthOrLayers);
SizeInfo sizeInfo = SizeCalculator.GetBlockLinearTextureSize( SizeInfo sizeInfo = SizeCalculator.GetBlockLinearTextureSize(
@ -476,7 +476,7 @@ namespace Ryujinx.Graphics.Gpu.Image
// address if there is a overlapping texture on the cache that can contain the new texture. // address if there is a overlapping texture on the cache that can contain the new texture.
gpuVa += (ulong)sizeInfo.GetMipOffset(minLod); gpuVa += (ulong)sizeInfo.GetMipOffset(minLod);
width = Math.Max(1, width >> minLod); width = Math.Max(1, width >> minLod);
height = Math.Max(1, height >> minLod); height = Math.Max(1, height >> minLod);
if (target == Target.Texture3D) if (target == Target.Texture3D)

View file

@ -11,6 +11,6 @@
Eligible = 0, Eligible = 0,
Scaled = 1, Scaled = 1,
Blacklisted = 2, Blacklisted = 2,
Undesired = 3 Undesired = 3,
} }
} }

View file

@ -8,11 +8,11 @@ namespace Ryujinx.Graphics.Gpu.Image
[Flags] [Flags]
enum TextureSearchFlags enum TextureSearchFlags
{ {
None = 0, None = 0,
ForSampler = 1 << 1, ForSampler = 1 << 1,
ForCopy = 1 << 2, ForCopy = 1 << 2,
DepthAlias = 1 << 3, DepthAlias = 1 << 3,
WithUpscale = 1 << 4, WithUpscale = 1 << 4,
NoCreate = 1 << 5 NoCreate = 1 << 5,
} }
} }

View file

@ -16,7 +16,7 @@ namespace Ryujinx.Graphics.Gpu.Image
Texture2DArray, Texture2DArray,
TextureBuffer, TextureBuffer,
Texture2DRect, Texture2DRect,
CubemapArray CubemapArray,
} }
static class TextureTargetConverter static class TextureTargetConverter
@ -33,23 +33,34 @@ namespace Ryujinx.Graphics.Gpu.Image
{ {
switch (target) switch (target)
{ {
case TextureTarget.Texture2D: return Target.Texture2DMultisample; case TextureTarget.Texture2D:
case TextureTarget.Texture2DArray: return Target.Texture2DMultisampleArray; return Target.Texture2DMultisample;
case TextureTarget.Texture2DArray:
return Target.Texture2DMultisampleArray;
} }
} }
else else
{ {
switch (target) switch (target)
{ {
case TextureTarget.Texture1D: return Target.Texture1D; case TextureTarget.Texture1D:
case TextureTarget.Texture2D: return Target.Texture2D; return Target.Texture1D;
case TextureTarget.Texture2DRect: return Target.Texture2D; case TextureTarget.Texture2D:
case TextureTarget.Texture3D: return Target.Texture3D; return Target.Texture2D;
case TextureTarget.Texture1DArray: return Target.Texture1DArray; case TextureTarget.Texture2DRect:
case TextureTarget.Texture2DArray: return Target.Texture2DArray; return Target.Texture2D;
case TextureTarget.Cubemap: return Target.Cubemap; case TextureTarget.Texture3D:
case TextureTarget.CubemapArray: return Target.CubemapArray; return Target.Texture3D;
case TextureTarget.TextureBuffer: return Target.TextureBuffer; case TextureTarget.Texture1DArray:
return Target.Texture1DArray;
case TextureTarget.Texture2DArray:
return Target.Texture2DArray;
case TextureTarget.Cubemap:
return Target.Cubemap;
case TextureTarget.CubemapArray:
return Target.CubemapArray;
case TextureTarget.TextureBuffer:
return Target.TextureBuffer;
} }
} }
@ -65,16 +76,16 @@ namespace Ryujinx.Graphics.Gpu.Image
{ {
return target switch return target switch
{ {
TextureTarget.Texture1D => SamplerType.Texture1D, TextureTarget.Texture1D => SamplerType.Texture1D,
TextureTarget.Texture2D => SamplerType.Texture2D, TextureTarget.Texture2D => SamplerType.Texture2D,
TextureTarget.Texture3D => SamplerType.Texture3D, TextureTarget.Texture3D => SamplerType.Texture3D,
TextureTarget.Cubemap => SamplerType.TextureCube, TextureTarget.Cubemap => SamplerType.TextureCube,
TextureTarget.Texture1DArray => SamplerType.Texture1D | SamplerType.Array, TextureTarget.Texture1DArray => SamplerType.Texture1D | SamplerType.Array,
TextureTarget.Texture2DArray => SamplerType.Texture2D | SamplerType.Array, TextureTarget.Texture2DArray => SamplerType.Texture2D | SamplerType.Array,
TextureTarget.TextureBuffer => SamplerType.TextureBuffer, TextureTarget.TextureBuffer => SamplerType.TextureBuffer,
TextureTarget.Texture2DRect => SamplerType.Texture2D, TextureTarget.Texture2DRect => SamplerType.Texture2D,
TextureTarget.CubemapArray => SamplerType.TextureCube | SamplerType.Array, TextureTarget.CubemapArray => SamplerType.TextureCube | SamplerType.Array,
_ => SamplerType.Texture2D _ => SamplerType.Texture2D,
}; };
} }
} }

View file

@ -10,6 +10,6 @@
LayoutIncompatible, LayoutIncompatible,
CopyOnly, CopyOnly,
FormatAlias, FormatAlias,
Full Full,
} }
} }

View file

@ -62,7 +62,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
private int _sequenceNumber; private int _sequenceNumber;
private bool _useGranular; private readonly bool _useGranular;
private bool _syncActionRegistered; private bool _syncActionRegistered;
private int _referenceCount = 1; private int _referenceCount = 1;
@ -80,10 +80,10 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// <param name="baseBuffers">Buffers which this buffer contains, and will inherit tracking handles from</param> /// <param name="baseBuffers">Buffers which this buffer contains, and will inherit tracking handles from</param>
public Buffer(GpuContext context, PhysicalMemory physicalMemory, ulong address, ulong size, IEnumerable<Buffer> baseBuffers = null) public Buffer(GpuContext context, PhysicalMemory physicalMemory, ulong address, ulong size, IEnumerable<Buffer> baseBuffers = null)
{ {
_context = context; _context = context;
_physicalMemory = physicalMemory; _physicalMemory = physicalMemory;
Address = address; Address = address;
Size = size; Size = size;
Handle = context.Renderer.CreateBuffer((int)size, baseBuffers?.MaxBy(x => x.Size).Handle ?? BufferHandle.Null); Handle = context.Renderer.CreateBuffer((int)size, baseBuffers?.MaxBy(x => x.Size).Handle ?? BufferHandle.Null);
@ -252,10 +252,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// </summary> /// </summary>
private void EnsureRangeList() private void EnsureRangeList()
{ {
if (_modifiedRanges == null) _modifiedRanges ??= new BufferModifiedRangeList(_context, this, Flush);
{
_modifiedRanges = new BufferModifiedRangeList(_context, this, Flush);
}
} }
/// <summary> /// <summary>
@ -326,7 +323,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
_syncActionRegistered = true; _syncActionRegistered = true;
} }
Action<ulong, ulong> registerRangeAction = (ulong address, ulong size) => void registerRangeAction(ulong address, ulong size)
{ {
if (_useGranular) if (_useGranular)
{ {
@ -336,7 +333,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
{ {
_memoryTracking.RegisterAction(_externalFlushDelegate); _memoryTracking.RegisterAction(_externalFlushDelegate);
} }
}; }
EnsureRangeList(); EnsureRangeList();

View file

@ -12,7 +12,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
class BufferCache : IDisposable class BufferCache : IDisposable
{ {
private const int OverlapsBufferInitialCapacity = 10; private const int OverlapsBufferInitialCapacity = 10;
private const int OverlapsBufferMaxCapacity = 10000; private const int OverlapsBufferMaxCapacity = 10000;
private const ulong BufferAlignmentSize = 0x1000; private const ulong BufferAlignmentSize = 0x1000;
private const ulong BufferAlignmentMask = BufferAlignmentSize - 1; private const ulong BufferAlignmentMask = BufferAlignmentSize - 1;
@ -246,7 +246,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
{ {
Buffer buffer = _bufferOverlaps[index]; Buffer buffer = _bufferOverlaps[index];
address = Math.Min(address, buffer.Address); address = Math.Min(address, buffer.Address);
endAddress = Math.Max(endAddress, buffer.EndAddress); endAddress = Math.Max(endAddress, buffer.EndAddress);
lock (_buffers) lock (_buffers)
@ -257,7 +257,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
ulong newSize = endAddress - address; ulong newSize = endAddress - address;
Buffer newBuffer = new Buffer(_context, _physicalMemory, address, newSize, _bufferOverlaps.Take(overlapsCount)); Buffer newBuffer = new(_context, _physicalMemory, address, newSize, _bufferOverlaps.Take(overlapsCount));
lock (_buffers) lock (_buffers)
{ {
@ -285,7 +285,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
else else
{ {
// No overlap, just create a new buffer. // No overlap, just create a new buffer.
Buffer buffer = new Buffer(_context, _physicalMemory, address, size); Buffer buffer = new(_context, _physicalMemory, address, size);
lock (_buffers) lock (_buffers)
{ {
@ -446,7 +446,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// </summary> /// </summary>
/// <param name="dictionary">Dictionary to prune</param> /// <param name="dictionary">Dictionary to prune</param>
/// <param name="toDelete">List used to track entries to delete</param> /// <param name="toDelete">List used to track entries to delete</param>
private void Prune(Dictionary<ulong, BufferCacheEntry> dictionary, ref List<ulong> toDelete) private static void Prune(Dictionary<ulong, BufferCacheEntry> dictionary, ref List<ulong> toDelete)
{ {
foreach (var entry in dictionary) foreach (var entry in dictionary)
{ {

View file

@ -105,7 +105,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
private readonly BuffersPerStage[] _gpUniformBuffers; private readonly BuffersPerStage[] _gpUniformBuffers;
private BufferHandle _tfInfoBuffer; private BufferHandle _tfInfoBuffer;
private int[] _tfInfoData; private readonly int[] _tfInfoData;
private bool _gpStorageBuffersDirty; private bool _gpStorageBuffersDirty;
private bool _gpUniformBuffersDirty; private bool _gpUniformBuffersDirty;
@ -777,11 +777,11 @@ namespace Ryujinx.Graphics.Gpu.Memory
{ {
if (isStorage) if (isStorage)
{ {
_context.Renderer.Pipeline.SetStorageBuffers(ranges.Slice(0, count)); _context.Renderer.Pipeline.SetStorageBuffers(ranges[..count]);
} }
else else
{ {
_context.Renderer.Pipeline.SetUniformBuffers(ranges.Slice(0, count)); _context.Renderer.Pipeline.SetUniformBuffers(ranges[..count]);
} }
} }

View file

@ -1,5 +1,4 @@
using Ryujinx.Common.Logging; using Ryujinx.Common.Pools;
using Ryujinx.Common.Pools;
using Ryujinx.Memory.Range; using Ryujinx.Memory.Range;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -71,9 +70,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
{ {
private const int BackingInitialSize = 8; private const int BackingInitialSize = 8;
private GpuContext _context; private readonly GpuContext _context;
private Buffer _parent; private readonly Buffer _parent;
private Action<ulong, ulong> _flushAction; private readonly Action<ulong, ulong> _flushAction;
private List<BufferMigration> _sources; private List<BufferMigration> _sources;
private BufferMigration _migrationTarget; private BufferMigration _migrationTarget;

View file

@ -34,11 +34,12 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// Adds a new counter to the counter cache, or updates a existing one. /// Adds a new counter to the counter cache, or updates a existing one.
/// </summary> /// </summary>
/// <param name="gpuVa">GPU virtual address where the counter will be written in memory</param> /// <param name="gpuVa">GPU virtual address where the counter will be written in memory</param>
/// <param name="evt">The new counter</param>
public void AddOrUpdate(ulong gpuVa, ICounterEvent evt) public void AddOrUpdate(ulong gpuVa, ICounterEvent evt)
{ {
int index = BinarySearch(gpuVa); int index = BinarySearch(gpuVa);
CounterEntry entry = new CounterEntry(gpuVa, evt); CounterEntry entry = new(gpuVa, evt);
if (index < 0) if (index < 0)
{ {
@ -168,7 +169,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
int middle = left + (range >> 1); int middle = left + (range >> 1);
CounterEntry item = _items[middle]; CounterEntry item = _items[middle];
if (item.Address == address) if (item.Address == address)
{ {

View file

@ -14,15 +14,15 @@ namespace Ryujinx.Graphics.Gpu.Memory
{ {
private const int PtLvl0Bits = 14; private const int PtLvl0Bits = 14;
private const int PtLvl1Bits = 14; private const int PtLvl1Bits = 14;
public const int PtPageBits = 12; public const int PtPageBits = 12;
private const ulong PtLvl0Size = 1UL << PtLvl0Bits; private const ulong PtLvl0Size = 1UL << PtLvl0Bits;
private const ulong PtLvl1Size = 1UL << PtLvl1Bits; private const ulong PtLvl1Size = 1UL << PtLvl1Bits;
public const ulong PageSize = 1UL << PtPageBits; public const ulong PageSize = 1UL << PtPageBits;
private const ulong PtLvl0Mask = PtLvl0Size - 1; private const ulong PtLvl0Mask = PtLvl0Size - 1;
private const ulong PtLvl1Mask = PtLvl1Size - 1; private const ulong PtLvl1Mask = PtLvl1Size - 1;
public const ulong PageMask = PageSize - 1; public const ulong PageMask = PageSize - 1;
private const int PtLvl0Bit = PtPageBits + PtLvl1Bits; private const int PtLvl0Bit = PtPageBits + PtLvl1Bits;
private const int PtLvl1Bit = PtPageBits; private const int PtLvl1Bit = PtPageBits;
@ -203,7 +203,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
size = Math.Min(data.Length, (int)PageSize - (int)(va & PageMask)); size = Math.Min(data.Length, (int)PageSize - (int)(va & PageMask));
Physical.GetSpan(pa, size, tracked).CopyTo(data.Slice(0, size)); Physical.GetSpan(pa, size, tracked).CopyTo(data[..size]);
offset += size; offset += size;
} }
@ -306,7 +306,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
size = Math.Min(data.Length, (int)PageSize - (int)(va & PageMask)); size = Math.Min(data.Length, (int)PageSize - (int)(va & PageMask));
writeCallback(pa, data.Slice(0, size)); writeCallback(pa, data[..size]);
offset += size; offset += size;
} }
@ -345,7 +345,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
if (pa != PteUnmapped && Physical.IsMapped(pa)) if (pa != PteUnmapped && Physical.IsMapped(pa))
{ {
Physical.Write(pa, data.Slice(0, size)); Physical.Write(pa, data[..size]);
} }
offset += size; offset += size;
@ -370,7 +370,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// These must run after the mapping completes. /// These must run after the mapping completes.
/// </summary> /// </summary>
/// <param name="e">Event with remap actions</param> /// <param name="e">Event with remap actions</param>
private void RunRemapActions(UnmapEventArgs e) private static void RunRemapActions(UnmapEventArgs e)
{ {
if (e.RemapActions != null) if (e.RemapActions != null)
{ {

View file

@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
class PhysicalMemory : IDisposable class PhysicalMemory : IDisposable
{ {
private readonly GpuContext _context; private readonly GpuContext _context;
private IVirtualMemoryManagerTracked _cpuMemory; private readonly IVirtualMemoryManagerTracked _cpuMemory;
private int _referenceCount; private int _referenceCount;
/// <summary> /// <summary>

View file

@ -250,7 +250,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
X8C24 = 0xfc, X8C24 = 0xfc,
PitchNoSwizzle = 0xfd, PitchNoSwizzle = 0xfd,
SmSkedMessage = 0xca, SmSkedMessage = 0xca,
SmHostMessage = 0xcb SmHostMessage = 0xcb,
} }
static class PteKindExtensions static class PteKindExtensions

View file

@ -8,6 +8,6 @@ namespace Ryujinx.Graphics.Gpu.Memory
None, None,
Buffer, Buffer,
Texture, Texture,
Pool Pool,
} }
} }

View file

@ -7,7 +7,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
{ {
public ulong Address; public ulong Address;
public ulong Size; public ulong Size;
public int Stride; public int Stride;
public int Divisor; public int Divisor;
} }
} }

View file

@ -50,8 +50,9 @@ namespace Ryujinx.Graphics.Gpu.Shader
out byte[] cachedGuestCode) out byte[] cachedGuestCode)
{ {
program = null; program = null;
ShaderCodeAccessor codeAccessor = new ShaderCodeAccessor(channel.MemoryManager, gpuVa); ShaderCodeAccessor codeAccessor = new(channel.MemoryManager, gpuVa);
bool hasSpecList = _cache.TryFindItem(codeAccessor, out var specList, out cachedGuestCode); bool hasSpecList = _cache.TryFindItem(codeAccessor, out var specList, out cachedGuestCode);
return hasSpecList && specList.TryFindForCompute(channel, poolState, computeState, out program); return hasSpecList && specList.TryFindForCompute(channel, poolState, computeState, out program);
} }

View file

@ -18,7 +18,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <summary> /// <summary>
/// Operation to add a shader to the cache. /// Operation to add a shader to the cache.
/// </summary> /// </summary>
AddShader AddShader,
} }
/// <summary> /// <summary>

View file

@ -29,12 +29,12 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// </summary> /// </summary>
/// <typeparam name="T">Type of the data</typeparam> /// <typeparam name="T">Type of the data</typeparam>
/// <param name="data">Data read</param> /// <param name="data">Data read</param>
public void Read<T>(ref T data) where T : unmanaged public readonly void Read<T>(ref T data) where T : unmanaged
{ {
Span<byte> buffer = MemoryMarshal.Cast<T, byte>(MemoryMarshal.CreateSpan(ref data, 1)); Span<byte> buffer = MemoryMarshal.Cast<T, byte>(MemoryMarshal.CreateSpan(ref data, 1));
for (int offset = 0; offset < buffer.Length;) for (int offset = 0; offset < buffer.Length;)
{ {
offset += _activeStream.Read(buffer.Slice(offset)); offset += _activeStream.Read(buffer[offset..]);
} }
} }
@ -44,7 +44,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <typeparam name="T">Type of the data</typeparam> /// <typeparam name="T">Type of the data</typeparam>
/// <param name="data">Data read</param> /// <param name="data">Data read</param>
/// <returns>True if the read was successful, false otherwise</returns> /// <returns>True if the read was successful, false otherwise</returns>
public bool TryRead<T>(ref T data) where T : unmanaged public readonly bool TryRead<T>(ref T data) where T : unmanaged
{ {
// Length is unknown on compressed streams. // Length is unknown on compressed streams.
if (_activeStream == _stream) if (_activeStream == _stream)
@ -66,7 +66,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <typeparam name="T">Type of the data</typeparam> /// <typeparam name="T">Type of the data</typeparam>
/// <param name="data">Data read</param> /// <param name="data">Data read</param>
/// <param name="magic">Expected magic value, for validation</param> /// <param name="magic">Expected magic value, for validation</param>
public void ReadWithMagicAndSize<T>(ref T data, uint magic) where T : unmanaged public readonly void ReadWithMagicAndSize<T>(ref T data, uint magic) where T : unmanaged
{ {
uint actualMagic = 0; uint actualMagic = 0;
int size = 0; int size = 0;
@ -84,10 +84,10 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
throw new DiskCacheLoadException(DiskCacheLoadResult.FileCorruptedInvalidLength); throw new DiskCacheLoadException(DiskCacheLoadResult.FileCorruptedInvalidLength);
} }
Span<byte> buffer = MemoryMarshal.Cast<T, byte>(MemoryMarshal.CreateSpan(ref data, 1)).Slice(0, size); Span<byte> buffer = MemoryMarshal.Cast<T, byte>(MemoryMarshal.CreateSpan(ref data, 1))[..size];
for (int offset = 0; offset < buffer.Length;) for (int offset = 0; offset < buffer.Length;)
{ {
offset += _activeStream.Read(buffer.Slice(offset)); offset += _activeStream.Read(buffer[offset..]);
} }
} }
@ -96,7 +96,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// </summary> /// </summary>
/// <typeparam name="T">Type of the data</typeparam> /// <typeparam name="T">Type of the data</typeparam>
/// <param name="data">Data to be written</param> /// <param name="data">Data to be written</param>
public void Write<T>(ref T data) where T : unmanaged public readonly void Write<T>(ref T data) where T : unmanaged
{ {
Span<byte> buffer = MemoryMarshal.Cast<T, byte>(MemoryMarshal.CreateSpan(ref data, 1)); Span<byte> buffer = MemoryMarshal.Cast<T, byte>(MemoryMarshal.CreateSpan(ref data, 1));
_activeStream.Write(buffer); _activeStream.Write(buffer);
@ -108,7 +108,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
/// <typeparam name="T">Type of the data</typeparam> /// <typeparam name="T">Type of the data</typeparam>
/// <param name="data">Data to write</param> /// <param name="data">Data to write</param>
/// <param name="magic">Magic value to write</param> /// <param name="magic">Magic value to write</param>
public void WriteWithMagicAndSize<T>(ref T data, uint magic) where T : unmanaged public readonly void WriteWithMagicAndSize<T>(ref T data, uint magic) where T : unmanaged
{ {
int size = Unsafe.SizeOf<T>(); int size = Unsafe.SizeOf<T>();
Write(ref magic); Write(ref magic);
@ -183,7 +183,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
stream = new DeflateStream(stream, CompressionMode.Decompress, true); stream = new DeflateStream(stream, CompressionMode.Decompress, true);
for (int offset = 0; offset < data.Length;) for (int offset = 0; offset < data.Length;)
{ {
offset += stream.Read(data.Slice(offset)); offset += stream.Read(data[offset..]);
} }
stream.Dispose(); stream.Dispose();
break; break;

Some files were not shown because too many files have changed in this diff Show more