mirror of
https://git.ryujinx.app/kenji-nx/ryujinx.git
synced 2025-12-17 16:37:04 +00:00
Memory Changes part 2
* Slightly refactors RangeLists from the last Memory Changes MR, which fixes issue 61. * Convert as many const size array iterators to span iterators as possible. When iterating over a const size array, every iteration created a Span, now only the first iteration does in most places. * Now using object pooling for a few object types that were rapidly deleted and recreated. * Converted a few flag checks to binary operations to save memory allocations.
This commit is contained in:
parent
01cb33f658
commit
171624e7f0
89 changed files with 2121 additions and 1157 deletions
|
|
@ -578,10 +578,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)
|
||||
{
|
||||
|
|
@ -727,6 +730,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
{
|
||||
int constantBufferUsePerStageMask = _constantBufferUsePerStage;
|
||||
|
||||
Span<uint> constantBufferUseSpan = ConstantBufferUse.AsSpan();
|
||||
|
||||
while (constantBufferUsePerStageMask != 0)
|
||||
{
|
||||
int index = BitOperations.TrailingZeroCount(constantBufferUsePerStageMask);
|
||||
|
|
@ -735,7 +740,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||
? channel.BufferManager.GetComputeUniformBufferUseMask()
|
||||
: channel.BufferManager.GetGraphicsUniformBufferUseMask(index);
|
||||
|
||||
if (ConstantBufferUse[index] != useMask)
|
||||
if (constantBufferUseSpan[index] != useMask)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -799,7 +804,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;
|
||||
|
|
@ -875,10 +880,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);
|
||||
}
|
||||
|
||||
|
|
@ -977,11 +984,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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue