Memory Changes part 2 (ryubing/ryujinx!123)

See merge request ryubing/ryujinx!123
This commit is contained in:
LotP
2025-08-25 17:44:15 -05:00
parent d499449f57
commit 50ab108ee1
90 changed files with 2133 additions and 1159 deletions

View File

@@ -1,5 +1,6 @@
using Ryujinx.Common.Configuration;
using Ryujinx.Common.Logging;
using Ryujinx.Common.Memory;
using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Gpu.Engine.Threed;
using Ryujinx.Graphics.Gpu.Engine.Types;
@@ -258,21 +259,25 @@ namespace Ryujinx.Graphics.Gpu.Shader
int count = rtControl.UnpackCount();
Span<RtColorState> rtColorStateSpan = state.RtColorState.AsSpan();
Span<bool> attachmentEnableSpan = pipeline.AttachmentEnable.AsSpan();
Span<Format> attachmentFormatsSpan = pipeline.AttachmentFormats.AsSpan();
for (int index = 0; index < Constants.TotalRenderTargets; index++)
{
int rtIndex = rtControl.UnpackPermutationIndex(index);
var colorState = state.RtColorState[rtIndex];
var colorState = rtColorStateSpan[rtIndex];
if (index >= count || colorState.Format == 0 || colorState.WidthOrStride == 0)
{
pipeline.AttachmentEnable[index] = false;
pipeline.AttachmentFormats[index] = Format.R8G8B8A8Unorm;
attachmentEnableSpan[index] = false;
attachmentFormatsSpan[index] = Format.R8G8B8A8Unorm;
}
else
{
pipeline.AttachmentEnable[index] = true;
pipeline.AttachmentFormats[index] = colorState.Format.Convert().Format;
attachmentEnableSpan[index] = true;
attachmentFormatsSpan[index] = colorState.Format.Convert().Format;
}
}
@@ -580,15 +585,18 @@ namespace Ryujinx.Graphics.Gpu.Shader
TransformFeedbackDescriptor[] descs = new TransformFeedbackDescriptor[Constants.TotalTransformFeedbackBuffers];
Span<TfState> tfStateSpan = state.TfState.AsSpan();
Span<Array32<uint>> tfVaryingLocationsSpan = state.TfVaryingLocations.AsSpan();
for (int i = 0; i < Constants.TotalTransformFeedbackBuffers; i++)
{
var tf = state.TfState[i];
var tf = tfStateSpan[i];
descs[i] = new TransformFeedbackDescriptor(
tf.BufferIndex,
tf.Stride,
tf.VaryingsCount,
ref state.TfVaryingLocations[i]);
ref tfVaryingLocationsSpan[i]);
}
return descs;

View File

@@ -580,10 +580,13 @@ namespace Ryujinx.Graphics.Gpu.Shader
if (ShaderCache.MayConvertVtgToCompute(ref channel.Capabilities) && !vertexAsCompute)
{
for (int index = 0; index < graphicsState.AttributeTypes.Length; index++)
Span<AttributeType> attributeTypesSpan = graphicsState.AttributeTypes.AsSpan();
Span<AttributeType> gAttributeTypesSpan = GraphicsState.AttributeTypes.AsSpan();
for (int index = 0; index < attributeTypesSpan.Length; index++)
{
AttributeType lType = FilterAttributeType(channel, graphicsState.AttributeTypes[index]);
AttributeType rType = FilterAttributeType(channel, GraphicsState.AttributeTypes[index]);
AttributeType lType = FilterAttributeType(channel, attributeTypesSpan[index]);
AttributeType rType = FilterAttributeType(channel, gAttributeTypesSpan[index]);
if (lType != rType)
{
@@ -729,6 +732,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
{
int constantBufferUsePerStageMask = _constantBufferUsePerStage;
Span<uint> constantBufferUseSpan = ConstantBufferUse.AsSpan();
while (constantBufferUsePerStageMask != 0)
{
int index = BitOperations.TrailingZeroCount(constantBufferUsePerStageMask);
@@ -737,7 +742,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
? channel.BufferManager.GetComputeUniformBufferUseMask()
: channel.BufferManager.GetGraphicsUniformBufferUseMask(index);
if (ConstantBufferUse[index] != useMask)
if (constantBufferUseSpan[index] != useMask)
{
return false;
}
@@ -801,7 +806,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
{
if (specializationState != null)
{
if (specializationState.Value.QueriedFlags.HasFlag(QueriedTextureStateFlags.CoordNormalized) &&
if ((specializationState.Value.QueriedFlags & QueriedTextureStateFlags.CoordNormalized) == QueriedTextureStateFlags.CoordNormalized &&
specializationState.Value.CoordNormalized != descriptor.UnpackTextureCoordNormalized())
{
return false;
@@ -877,10 +882,12 @@ namespace Ryujinx.Graphics.Gpu.Shader
int constantBufferUsePerStageMask = specState._constantBufferUsePerStage;
Span<uint> constantBufferUseSpan = specState.ConstantBufferUse.AsSpan();
while (constantBufferUsePerStageMask != 0)
{
int index = BitOperations.TrailingZeroCount(constantBufferUsePerStageMask);
dataReader.Read(ref specState.ConstantBufferUse[index]);
dataReader.Read(ref constantBufferUseSpan[index]);
constantBufferUsePerStageMask &= ~(1 << index);
}
@@ -979,11 +986,13 @@ namespace Ryujinx.Graphics.Gpu.Shader
dataWriter.Write(ref _constantBufferUsePerStage);
int constantBufferUsePerStageMask = _constantBufferUsePerStage;
Span<uint> constantBufferUseSpan = ConstantBufferUse.AsSpan();
while (constantBufferUsePerStageMask != 0)
{
int index = BitOperations.TrailingZeroCount(constantBufferUsePerStageMask);
dataWriter.Write(ref ConstantBufferUse[index]);
dataWriter.Write(ref constantBufferUseSpan[index]);
constantBufferUsePerStageMask &= ~(1 << index);
}