mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-05-27 07:29:14 +00:00
Memory Changes part 2 (ryubing/ryujinx!123)
See merge request ryubing/ryujinx!123
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.Graphics.Gpu.Memory;
|
||||
using Ryujinx.Graphics.Shader;
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -76,9 +77,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
|
||||
/// <param name="componentCount">Number of components that the format has</param>
|
||||
public void SetVertexStride(int index, int stride, int componentCount)
|
||||
{
|
||||
if (_data.VertexStrides[index].X != stride)
|
||||
Span<Vector4<int>> vertexStridesSpan = _data.VertexStrides.AsSpan();
|
||||
|
||||
if (vertexStridesSpan[index].X != stride)
|
||||
{
|
||||
_data.VertexStrides[index].X = stride;
|
||||
vertexStridesSpan[index].X = stride;
|
||||
MarkDirty(VertexInfoBuffer.VertexStridesOffset + index * Unsafe.SizeOf<Vector4<int>>(), sizeof(int));
|
||||
}
|
||||
|
||||
@@ -86,7 +89,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
|
||||
{
|
||||
int value = c < componentCount ? 1 : 0;
|
||||
|
||||
ref int currentValue = ref GetElementRef(ref _data.VertexStrides[index], c);
|
||||
ref int currentValue = ref GetElementRef(ref vertexStridesSpan[index], c);
|
||||
|
||||
if (currentValue != value)
|
||||
{
|
||||
@@ -104,15 +107,17 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
|
||||
/// <param name="divisor">If the draw is instanced, should have the vertex divisor value, otherwise should be zero</param>
|
||||
public void SetVertexOffset(int index, int offset, int divisor)
|
||||
{
|
||||
if (_data.VertexOffsets[index].X != offset)
|
||||
Span<Vector4<int>> vertexOffsetsSpan = _data.VertexOffsets.AsSpan();
|
||||
|
||||
if (vertexOffsetsSpan[index].X != offset)
|
||||
{
|
||||
_data.VertexOffsets[index].X = offset;
|
||||
vertexOffsetsSpan[index].X = offset;
|
||||
MarkDirty(VertexInfoBuffer.VertexOffsetsOffset + index * Unsafe.SizeOf<Vector4<int>>(), sizeof(int));
|
||||
}
|
||||
|
||||
if (_data.VertexOffsets[index].Y != divisor)
|
||||
if (vertexOffsetsSpan[index].Y != divisor)
|
||||
{
|
||||
_data.VertexOffsets[index].Y = divisor;
|
||||
vertexOffsetsSpan[index].Y = divisor;
|
||||
MarkDirty(VertexInfoBuffer.VertexOffsetsOffset + index * Unsafe.SizeOf<Vector4<int>>() + sizeof(int), sizeof(int));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,9 +125,14 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
|
||||
_vacContext.VertexInfoBufferUpdater.SetVertexCounts(_count, _instanceCount, _firstVertex, _firstInstance);
|
||||
_vacContext.VertexInfoBufferUpdater.SetGeometryCounts(primitivesCount);
|
||||
|
||||
Span<VertexAttribState> vertexAttribStateSpan = _state.State.VertexAttribState.AsSpan();
|
||||
Span<GpuVa> vertexBufferEndAddressSpan = _state.State.VertexBufferEndAddress.AsSpan();
|
||||
Span<VertexBufferState> vertexBufferStateSpan = _state.State.VertexBufferState.AsSpan();
|
||||
Span<Boolean32> vertexBufferInstancedSpan = _state.State.VertexBufferInstanced.AsSpan();
|
||||
|
||||
for (int index = 0; index < Constants.TotalVertexAttribs; index++)
|
||||
{
|
||||
VertexAttribState vertexAttrib = _state.State.VertexAttribState[index];
|
||||
VertexAttribState vertexAttrib = vertexAttribStateSpan[index];
|
||||
|
||||
if (!FormatTable.TryGetSingleComponentAttribFormat(vertexAttrib.UnpackFormat(), out Format format, out int componentsCount))
|
||||
{
|
||||
@@ -153,9 +158,9 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
|
||||
|
||||
int bufferIndex = vertexAttrib.UnpackBufferIndex();
|
||||
|
||||
GpuVa endAddress = _state.State.VertexBufferEndAddress[bufferIndex];
|
||||
VertexBufferState vertexBuffer = _state.State.VertexBufferState[bufferIndex];
|
||||
bool instanced = _state.State.VertexBufferInstanced[bufferIndex];
|
||||
GpuVa endAddress = vertexBufferEndAddressSpan[bufferIndex];
|
||||
VertexBufferState vertexBuffer = vertexBufferStateSpan[bufferIndex];
|
||||
bool instanced = vertexBufferInstancedSpan[bufferIndex];
|
||||
|
||||
ulong address = vertexBuffer.Address.Pack();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user