Refactor Share Buffer Implementation to Follow Code Style Guidelines

This commit is contained in:
Jacobwasbeast 2025-02-07 04:16:27 -06:00
parent 3ca8618f5f
commit 7f27b791f8
22 changed files with 92 additions and 87 deletions

View File

@ -107,7 +107,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
shaderGpuVa += (uint)qmd.ProgramOffset; shaderGpuVa += (uint)qmd.ProgramOffset;
var shaderCache = memoryManager.GetBackingMemory(shaderGpuVa).ShaderCache; ShaderCache shaderCache = memoryManager.GetBackingMemory(shaderGpuVa).ShaderCache;
int localMemorySize = qmd.ShaderLocalMemoryLowSize + qmd.ShaderLocalMemoryHighSize; int localMemorySize = qmd.ShaderLocalMemoryLowSize + qmd.ShaderLocalMemoryHighSize;
@ -158,7 +158,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
{ {
BufferDescriptor sb = info.SBuffers[index]; BufferDescriptor sb = info.SBuffers[index];
(var physical, ulong sbDescAddress) = _channel.BufferManager.GetComputeUniformBufferAddress(sb.SbCbSlot); (PhysicalMemory physical, ulong sbDescAddress) = _channel.BufferManager.GetComputeUniformBufferAddress(sb.SbCbSlot);
sbDescAddress += (ulong)sb.SbCbOffset * 4; sbDescAddress += (ulong)sb.SbCbOffset * 4;
SbDescriptor sbDescriptor = physical.Read<SbDescriptor>(sbDescAddress); SbDescriptor sbDescriptor = physical.Read<SbDescriptor>(sbDescAddress);

View File

@ -216,8 +216,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
_3dEngine.CreatePendingSyncs(); _3dEngine.CreatePendingSyncs();
_3dEngine.FlushUboDirty(); _3dEngine.FlushUboDirty();
var srcPhysical = memoryManager.GetBackingMemory(srcGpuVa); PhysicalMemory srcPhysical = memoryManager.GetBackingMemory(srcGpuVa);
var dstPhysical = memoryManager.GetBackingMemory(dstGpuVa); PhysicalMemory dstPhysical = memoryManager.GetBackingMemory(dstGpuVa);
if (copy2D) if (copy2D)
{ {
@ -465,7 +465,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
} }
else else
{ {
var bufferCache = dstPhysical.BufferCache; BufferCache bufferCache = dstPhysical.BufferCache;
if (remap && if (remap &&
_state.State.SetRemapComponentsDstX == SetRemapComponentsDst.ConstA && _state.State.SetRemapComponentsDstX == SetRemapComponentsDst.ConstA &&
_state.State.SetRemapComponentsDstY == SetRemapComponentsDst.ConstA && _state.State.SetRemapComponentsDstY == SetRemapComponentsDst.ConstA &&

View File

@ -185,7 +185,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.InlineToMemory
// Right now the copy code at the bottom assumes that it is used on both which might be incorrect. // Right now the copy code at the bottom assumes that it is used on both which might be incorrect.
if (!_isLinear) if (!_isLinear)
{ {
var target = memoryManager.GetBackingMemory(_dstGpuVa).TextureCache.FindTexture( Image.Texture target = memoryManager.GetBackingMemory(_dstGpuVa).TextureCache.FindTexture(
memoryManager, memoryManager,
_dstGpuVa, _dstGpuVa,
1, 1,

View File

@ -493,8 +493,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
} }
} }
} }
var indirectBufferCache = _processor.MemoryManager.GetBackingMemory(indirectBufferGpuVa).BufferCache; BufferCache indirectBufferCache = _processor.MemoryManager.GetBackingMemory(indirectBufferGpuVa).BufferCache;
var parameterBufferCache = _processor.MemoryManager.GetBackingMemory(parameterBufferGpuVa).BufferCache; BufferCache parameterBufferCache = _processor.MemoryManager.GetBackingMemory(parameterBufferGpuVa).BufferCache;
ulong indirectBufferSize = (ulong)maxDrawCount * (ulong)stride; ulong indirectBufferSize = (ulong)maxDrawCount * (ulong)stride;

View File

@ -67,7 +67,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
{ {
if (disposing) if (disposing)
{ {
foreach (var texture in _cache.Values) foreach (ITexture texture in _cache.Values)
{ {
texture.Release(); texture.Release();
} }
@ -620,7 +620,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
DestroyIfNotNull(ref _geometryIndexDataBuffer.Handle); DestroyIfNotNull(ref _geometryIndexDataBuffer.Handle);
DestroyIfNotNull(ref _sequentialIndexBuffer); DestroyIfNotNull(ref _sequentialIndexBuffer);
foreach (var indexBuffer in _topologyRemapBuffers.Values) foreach (IndexBuffer indexBuffer in _topologyRemapBuffers.Values)
{ {
_context.Renderer.DeleteBuffer(indexBuffer.Handle); _context.Renderer.DeleteBuffer(indexBuffer.Handle);
} }

View File

@ -127,7 +127,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
for (int index = 0; index < Constants.TotalVertexAttribs; index++) for (int index = 0; index < Constants.TotalVertexAttribs; index++)
{ {
var vertexAttrib = _state.State.VertexAttribState[index]; VertexAttribState vertexAttrib = _state.State.VertexAttribState[index];
if (!FormatTable.TryGetSingleComponentAttribFormat(vertexAttrib.UnpackFormat(), out Format format, out int componentsCount)) if (!FormatTable.TryGetSingleComponentAttribFormat(vertexAttrib.UnpackFormat(), out Format format, out int componentsCount))
{ {
@ -154,7 +154,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
int bufferIndex = vertexAttrib.UnpackBufferIndex(); int bufferIndex = vertexAttrib.UnpackBufferIndex();
GpuVa endAddress = _state.State.VertexBufferEndAddress[bufferIndex]; GpuVa endAddress = _state.State.VertexBufferEndAddress[bufferIndex];
var vertexBuffer = _state.State.VertexBufferState[bufferIndex]; VertexBufferState vertexBuffer = _state.State.VertexBufferState[bufferIndex];
bool instanced = _state.State.VertexBufferInstanced[bufferIndex]; bool instanced = _state.State.VertexBufferInstanced[bufferIndex];
ulong address = vertexBuffer.Address.Pack(); ulong address = vertexBuffer.Address.Pack();
@ -369,7 +369,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
/// <param name="size">Size of the buffer in bytes</param> /// <param name="size">Size of the buffer in bytes</param>
private readonly void SetBufferTexture(ResourceReservations reservations, int index, Format format, ulong address, ulong size) private readonly void SetBufferTexture(ResourceReservations reservations, int index, Format format, ulong address, ulong size)
{ {
var memoryManager = _channel.MemoryManager; MemoryManager memoryManager = _channel.MemoryManager;
BufferRange range = memoryManager.GetBackingMemory(address).BufferCache.GetBufferRange(memoryManager.GetPhysicalRegions(address, size), BufferStage.VertexBuffer); BufferRange range = memoryManager.GetBackingMemory(address).BufferCache.GetBufferRange(memoryManager.GetPhysicalRegions(address, size), BufferStage.VertexBuffer);
@ -410,7 +410,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
indexOffset <<= shift; indexOffset <<= shift;
size <<= shift; size <<= shift;
var memoryManager = _channel.MemoryManager; MemoryManager memoryManager = _channel.MemoryManager;
ulong misalign = address & ((ulong)_context.Capabilities.TextureBufferOffsetAlignment - 1); ulong misalign = address & ((ulong)_context.Capabilities.TextureBufferOffsetAlignment - 1);
BufferRange range = memoryManager.GetBackingMemory(address).BufferCache.GetBufferRange( BufferRange range = memoryManager.GetBackingMemory(address).BufferCache.GetBufferRange(

View File

@ -114,7 +114,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
if (_ubFollowUpAddress != 0) if (_ubFollowUpAddress != 0)
{ {
MemoryManager memoryManager = _channel.MemoryManager; MemoryManager memoryManager = _channel.MemoryManager;
var physicalMemory = memoryManager.GetBackingMemory(_ubBeginGpuAddress); PhysicalMemory physicalMemory = memoryManager.GetBackingMemory(_ubBeginGpuAddress);
Span<byte> data = MemoryMarshal.Cast<int, byte>(_ubData.AsSpan(0, (int)(_ubByteCount / 4))); Span<byte> data = MemoryMarshal.Cast<int, byte>(_ubData.AsSpan(0, (int)(_ubByteCount / 4)));

View File

@ -381,7 +381,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{ {
BufferDescriptor sb = info.SBuffers[index]; BufferDescriptor sb = info.SBuffers[index];
(var physical, ulong sbDescAddress) = _channel.BufferManager.GetGraphicsUniformBufferAddress(stage, sb.SbCbSlot); (PhysicalMemory physical, ulong sbDescAddress) = _channel.BufferManager.GetGraphicsUniformBufferAddress(stage, sb.SbCbSlot);
sbDescAddress += (ulong)sb.SbCbOffset * 4; sbDescAddress += (ulong)sb.SbCbOffset * 4;
SbDescriptor sbDescriptor = physical.Read<SbDescriptor>(sbDescAddress); SbDescriptor sbDescriptor = physical.Read<SbDescriptor>(sbDescAddress);
@ -505,7 +505,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
rtNoAlphaMask |= 1u << index; rtNoAlphaMask |= 1u << index;
} }
var colorTextureCache = memoryManager.GetBackingMemory(colorState.Address.Pack()).TextureCache; TextureCache colorTextureCache = memoryManager.GetBackingMemory(colorState.Address.Pack()).TextureCache;
Image.Texture color = colorTextureCache.FindOrCreateTexture( Image.Texture color = colorTextureCache.FindOrCreateTexture(
memoryManager, memoryManager,
@ -545,7 +545,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
{ {
RtDepthStencilState dsState = _state.State.RtDepthStencilState; RtDepthStencilState dsState = _state.State.RtDepthStencilState;
Size3D dsSize = _state.State.RtDepthStencilSize; Size3D dsSize = _state.State.RtDepthStencilSize;
var dsTextureCache = memoryManager.GetBackingMemory(dsState.Address.Pack()).TextureCache; TextureCache dsTextureCache = memoryManager.GetBackingMemory(dsState.Address.Pack()).TextureCache;
depthStencil = dsTextureCache.FindOrCreateTexture( depthStencil = dsTextureCache.FindOrCreateTexture(
memoryManager, memoryManager,
@ -1436,7 +1436,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
// Shader stages on different address spaces are not supported right now, // Shader stages on different address spaces are not supported right now,
// but it should never happen in practice anyway. // but it should never happen in practice anyway.
var shaderCache = _channel.MemoryManager.GetBackingMemory(addresses.VertexB).ShaderCache; ShaderCache shaderCache = _channel.MemoryManager.GetBackingMemory(addresses.VertexB).ShaderCache;
CachedShaderProgram gs = shaderCache.GetGraphicsShader( CachedShaderProgram gs = shaderCache.GetGraphicsShader(
ref _state.State, ref _state.State,
ref _pipeline, ref _pipeline,

View File

@ -234,8 +234,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
TwodTexture dstCopyTexture = Unsafe.As<uint, TwodTexture>(ref _state.State.SetDstFormat); TwodTexture dstCopyTexture = Unsafe.As<uint, TwodTexture>(ref _state.State.SetDstFormat);
TwodTexture srcCopyTexture = Unsafe.As<uint, TwodTexture>(ref _state.State.SetSrcFormat); TwodTexture srcCopyTexture = Unsafe.As<uint, TwodTexture>(ref _state.State.SetSrcFormat);
var srcTextureCache = memoryManager.GetBackingMemory(srcCopyTexture.Address.Pack()).TextureCache; TextureCache srcTextureCache = memoryManager.GetBackingMemory(srcCopyTexture.Address.Pack()).TextureCache;
var dstTextureCache = memoryManager.GetBackingMemory(dstCopyTexture.Address.Pack()).TextureCache; TextureCache dstTextureCache = memoryManager.GetBackingMemory(dstCopyTexture.Address.Pack()).TextureCache;
long srcX = ((long)_state.State.SetPixelsFromMemorySrcX0Int << 32) | (long)(ulong)_state.State.SetPixelsFromMemorySrcX0Frac; long srcX = ((long)_state.State.SetPixelsFromMemorySrcX0Int << 32) | (long)(ulong)_state.State.SetPixelsFromMemorySrcX0Frac;
long srcY = ((long)_state.State.PixelsFromMemorySrcY0Int << 32) | (long)(ulong)_state.State.SetPixelsFromMemorySrcY0Frac; long srcY = ((long)_state.State.PixelsFromMemorySrcY0Int << 32) | (long)(ulong)_state.State.SetPixelsFromMemorySrcY0Frac;

View File

@ -140,7 +140,7 @@ namespace Ryujinx.Graphics.Gpu
_processor.Dispose(); _processor.Dispose();
TextureManager.Dispose(); TextureManager.Dispose();
var oldMemoryManager = Interlocked.Exchange(ref _memoryManager, null); MemoryManager oldMemoryManager = Interlocked.Exchange(ref _memoryManager, null);
if (oldMemoryManager != null) if (oldMemoryManager != null)
{ {
oldMemoryManager.DetachFromChannel(BufferManager.Rebind); oldMemoryManager.DetachFromChannel(BufferManager.Rebind);

View File

@ -113,9 +113,10 @@ namespace Ryujinx.Graphics.Gpu.Image
/// </summary> /// </summary>
/// <param name="context">GPU context that the pool belongs to</param> /// <param name="context">GPU context that the pool belongs to</param>
/// <param name="channel">GPU channel that the pool belongs to</param> /// <param name="channel">GPU channel that the pool belongs to</param>
/// <param name="physicalMemory">GPU backing memory of the pool</param>
/// <param name="address">Address of the pool in guest memory</param> /// <param name="address">Address of the pool in guest memory</param>
/// <param name="maximumId">Maximum ID of the pool (equal to maximum minus one)</param> /// <param name="maximumId">Maximum ID of the pool (equal to maximum minus one)</param>
protected abstract T CreatePool(GpuContext context, GpuChannel channel, PhysicalMemory physical, ulong address, int maximumId); protected abstract T CreatePool(GpuContext context, GpuChannel channel, PhysicalMemory physicalMemory, ulong address, int maximumId);
public void Dispose() public void Dispose()
{ {

View File

@ -22,6 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// </summary> /// </summary>
/// <param name="context">GPU context that the sampler pool belongs to</param> /// <param name="context">GPU context that the sampler pool belongs to</param>
/// <param name="channel">GPU channel that the texture pool belongs to</param> /// <param name="channel">GPU channel that the texture pool belongs to</param>
/// <param name="physicalMemory">GPU backing memory of the pool</param>
/// <param name="address">Address of the sampler pool in guest memory</param> /// <param name="address">Address of the sampler pool in guest memory</param>
/// <param name="maximumId">Maximum sampler ID of the sampler pool (equal to maximum samplers minus one)</param> /// <param name="maximumId">Maximum sampler ID of the sampler pool (equal to maximum samplers minus one)</param>
protected override SamplerPool CreatePool(GpuContext context, GpuChannel channel, PhysicalMemory physicalMemory, ulong address, int maximumId) protected override SamplerPool CreatePool(GpuContext context, GpuChannel channel, PhysicalMemory physicalMemory, ulong address, int maximumId)

View File

@ -900,7 +900,7 @@ namespace Ryujinx.Graphics.Gpu.Image
if (hostTexture != null && texture.Target == Target.TextureBuffer) if (hostTexture != null && texture.Target == Target.TextureBuffer)
{ {
var bufferCache = textureBufferBounds.BufferCache; BufferCache bufferCache = textureBufferBounds.BufferCache;
// Ensure that the buffer texture is using the correct buffer as storage. // Ensure that the buffer texture is using the correct buffer as storage.
// Buffers are frequently re-created to accommodate larger data, so we need to re-bind // Buffers are frequently re-created to accommodate larger data, so we need to re-bind

View File

@ -524,7 +524,7 @@ namespace Ryujinx.Graphics.Gpu.Image
// Ensure that the buffer texture is using the correct buffer as storage. // Ensure that the buffer texture is using the correct buffer as storage.
// Buffers are frequently re-created to accommodate larger data, so we need to re-bind // Buffers are frequently re-created to accommodate larger data, so we need to re-bind
// to ensure we're not using a old buffer that was already deleted. // to ensure we're not using a old buffer that was already deleted.
var bufferCache = _channel.MemoryManager.GetBackingMemory(descriptor.UnpackAddress()).BufferCache; BufferCache bufferCache = _channel.MemoryManager.GetBackingMemory(descriptor.UnpackAddress()).BufferCache;
_channel.BufferManager.SetBufferTextureStorage(stage, hostTexture, bufferCache, texture.Range, bindingInfo, false); _channel.BufferManager.SetBufferTextureStorage(stage, hostTexture, bufferCache, texture.Range, bindingInfo, false);
// Cache is not used for buffer texture, it must always rebind. // Cache is not used for buffer texture, it must always rebind.
@ -660,7 +660,7 @@ namespace Ryujinx.Graphics.Gpu.Image
// Buffers are frequently re-created to accommodate larger data, so we need to re-bind // Buffers are frequently re-created to accommodate larger data, so we need to re-bind
// to ensure we're not using a old buffer that was already deleted. // to ensure we're not using a old buffer that was already deleted.
var bufferCache = _channel.MemoryManager.GetBackingMemory(descriptor.UnpackAddress()).BufferCache; BufferCache bufferCache = _channel.MemoryManager.GetBackingMemory(descriptor.UnpackAddress()).BufferCache;
_channel.BufferManager.SetBufferTextureStorage(stage, hostTexture, bufferCache, texture.Range, bindingInfo, true); _channel.BufferManager.SetBufferTextureStorage(stage, hostTexture, bufferCache, texture.Range, bindingInfo, true);
// Cache is not used for buffer texture, it must always rebind. // Cache is not used for buffer texture, it must always rebind.
@ -717,7 +717,7 @@ namespace Ryujinx.Graphics.Gpu.Image
int packedId = ReadPackedId(stageIndex, handle, textureBufferIndex, samplerBufferIndex); int packedId = ReadPackedId(stageIndex, handle, textureBufferIndex, samplerBufferIndex);
int textureId = TextureHandle.UnpackTextureId(packedId); int textureId = TextureHandle.UnpackTextureId(packedId);
var physical = _channel.MemoryManager.GetBackingMemory(poolGpuVa); PhysicalMemory physical = _channel.MemoryManager.GetBackingMemory(poolGpuVa);
ulong poolAddress = _channel.MemoryManager.Translate(poolGpuVa); ulong poolAddress = _channel.MemoryManager.Translate(poolGpuVa);
TexturePool texturePool = _texturePoolCache.FindOrCreate(_channel, physical, poolAddress, maximumId, _bindingsArrayCache); TexturePool texturePool = _texturePoolCache.FindOrCreate(_channel, physical, poolAddress, maximumId, _bindingsArrayCache);
@ -754,7 +754,7 @@ namespace Ryujinx.Graphics.Gpu.Image
{ {
(int textureWordOffset, int samplerWordOffset, TextureHandleType handleType) = TextureHandle.UnpackOffsets(wordOffset); (int textureWordOffset, int samplerWordOffset, TextureHandleType handleType) = TextureHandle.UnpackOffsets(wordOffset);
(var texturePhysicalMemory, ulong textureBufferAddress) = _isCompute (PhysicalMemory texturePhysicalMemory, ulong textureBufferAddress) = _isCompute
? _channel.BufferManager.GetComputeUniformBufferAddress(textureBufferIndex) ? _channel.BufferManager.GetComputeUniformBufferAddress(textureBufferIndex)
: _channel.BufferManager.GetGraphicsUniformBufferAddress(stageIndex, textureBufferIndex); : _channel.BufferManager.GetGraphicsUniformBufferAddress(stageIndex, textureBufferIndex);
@ -774,7 +774,7 @@ namespace Ryujinx.Graphics.Gpu.Image
if (handleType != TextureHandleType.SeparateConstantSamplerHandle) if (handleType != TextureHandleType.SeparateConstantSamplerHandle)
{ {
(var samplerPhysicalMemory, ulong samplerBufferAddress) = _isCompute (PhysicalMemory samplerPhysicalMemory, ulong samplerBufferAddress) = _isCompute
? _channel.BufferManager.GetComputeUniformBufferAddress(samplerBufferIndex) ? _channel.BufferManager.GetComputeUniformBufferAddress(samplerBufferIndex)
: _channel.BufferManager.GetGraphicsUniformBufferAddress(stageIndex, samplerBufferIndex); : _channel.BufferManager.GetGraphicsUniformBufferAddress(stageIndex, samplerBufferIndex);
@ -816,7 +816,7 @@ namespace Ryujinx.Graphics.Gpu.Image
if (poolAddress != MemoryManager.PteUnmapped) if (poolAddress != MemoryManager.PteUnmapped)
{ {
var physical = _channel.MemoryManager.GetBackingMemory(_texturePoolGpuVa); PhysicalMemory physical = _channel.MemoryManager.GetBackingMemory(_texturePoolGpuVa);
texturePool = _texturePoolCache.FindOrCreate(_channel, physical, poolAddress, _texturePoolMaximumId, _bindingsArrayCache); texturePool = _texturePoolCache.FindOrCreate(_channel, physical, poolAddress, _texturePoolMaximumId, _bindingsArrayCache);
_texturePool = texturePool; _texturePool = texturePool;
} }
@ -828,7 +828,7 @@ namespace Ryujinx.Graphics.Gpu.Image
if (poolAddress != MemoryManager.PteUnmapped) if (poolAddress != MemoryManager.PteUnmapped)
{ {
var physical = _channel.MemoryManager.GetBackingMemory(_samplerPoolGpuVa); PhysicalMemory physical = _channel.MemoryManager.GetBackingMemory(_samplerPoolGpuVa);
samplerPool = _samplerPoolCache.FindOrCreate(_channel, physical, poolAddress, _samplerPoolMaximumId, _bindingsArrayCache); samplerPool = _samplerPoolCache.FindOrCreate(_channel, physical, poolAddress, _samplerPoolMaximumId, _bindingsArrayCache);
_samplerPool = samplerPool; _samplerPool = samplerPool;
} }

View File

@ -1,5 +1,6 @@
using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Gpu.Engine.Types; using Ryujinx.Graphics.Gpu.Engine.Types;
using Ryujinx.Graphics.Gpu.Memory;
using Ryujinx.Graphics.Gpu.Shader; using Ryujinx.Graphics.Gpu.Shader;
using System; using System;
@ -385,7 +386,7 @@ namespace Ryujinx.Graphics.Gpu.Image
public TexturePool GetTexturePool(ulong poolGpuVa, int maximumId) public TexturePool GetTexturePool(ulong poolGpuVa, int maximumId)
{ {
ulong poolAddress = _channel.MemoryManager.Translate(poolGpuVa); ulong poolAddress = _channel.MemoryManager.Translate(poolGpuVa);
var physical = _channel.MemoryManager.GetBackingMemory(poolAddress); PhysicalMemory physical = _channel.MemoryManager.GetBackingMemory(poolAddress);
TexturePool texturePool = _texturePoolCache.FindOrCreate(_channel, physical, poolAddress, maximumId, _bindingsArrayCache); TexturePool texturePool = _texturePoolCache.FindOrCreate(_channel, physical, poolAddress, maximumId, _bindingsArrayCache);

View File

@ -193,9 +193,9 @@ namespace Ryujinx.Graphics.Gpu.Image
return ref descriptor; return ref descriptor;
} }
var info = GetInfo(descriptor, out int layerSize); TextureInfo info = GetInfo(descriptor, out int layerSize);
var memoryManager = _channel.MemoryManager; MemoryManager memoryManager = _channel.MemoryManager;
var textureCache = memoryManager.GetBackingMemory(descriptor.UnpackAddress()).TextureCache; TextureCache textureCache = memoryManager.GetBackingMemory(descriptor.UnpackAddress()).TextureCache;
texture = textureCache.FindOrCreateTexture(memoryManager, TextureSearchFlags.ForSampler, info, layerSize); texture = textureCache.FindOrCreateTexture(memoryManager, TextureSearchFlags.ForSampler, info, layerSize);
// If this happens, then the texture address is invalid, we can't add it to the cache. // If this happens, then the texture address is invalid, we can't add it to the cache.
@ -424,8 +424,8 @@ namespace Ryujinx.Graphics.Gpu.Image
continue; continue;
} }
var textureCache = _channel.MemoryManager.GetBackingMemory(address).TextureCache; TextureCache textureCache = _channel.MemoryManager.GetBackingMemory(address).TextureCache;
var range = textureCache.UpdatePartiallyMapped(_channel.MemoryManager, address, texture); MultiRange range = textureCache.UpdatePartiallyMapped(_channel.MemoryManager, address, texture);
// If the texture is not mapped at all, delete its reference. // If the texture is not mapped at all, delete its reference.
@ -485,7 +485,7 @@ namespace Ryujinx.Graphics.Gpu.Image
/// <param name="size">Size of the range being invalidated</param> /// <param name="size">Size of the range being invalidated</param>
protected override void InvalidateRangeImpl(ulong address, ulong size) protected override void InvalidateRangeImpl(ulong address, ulong size)
{ {
var memoryManager = _channel.MemoryManager; MemoryManager memoryManager = _channel.MemoryManager;
ProcessDereferenceQueue(); ProcessDereferenceQueue();
ulong endAddress = address + size; ulong endAddress = address + size;
@ -510,7 +510,7 @@ namespace Ryujinx.Graphics.Gpu.Image
if (texture.HasOneReference()) if (texture.HasOneReference())
{ {
var textureCache = memoryManager.GetBackingMemory(descriptor.UnpackAddress()).TextureCache; TextureCache textureCache = memoryManager.GetBackingMemory(descriptor.UnpackAddress()).TextureCache;
textureCache.AddShortCache(texture, ref cachedDescriptor); textureCache.AddShortCache(texture, ref cachedDescriptor);
} }

View File

@ -742,11 +742,11 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// <param name="size">Size in bytes of the copy</param> /// <param name="size">Size in bytes of the copy</param>
public static void CopyBuffer(GpuContext context, MemoryManager memoryManager, ulong srcVa, ulong dstVa, ulong size) public static void CopyBuffer(GpuContext context, MemoryManager memoryManager, ulong srcVa, ulong dstVa, ulong size)
{ {
var srcPhysical = memoryManager.GetBackingMemory(srcVa); PhysicalMemory srcPhysical = memoryManager.GetBackingMemory(srcVa);
var dstPhysical = memoryManager.GetBackingMemory(dstVa); PhysicalMemory dstPhysical = memoryManager.GetBackingMemory(dstVa);
var srcRange = srcPhysical.BufferCache.TranslateAndCreateBuffer(memoryManager, srcVa, size, BufferStage.Copy); MultiRange srcRange = srcPhysical.BufferCache.TranslateAndCreateBuffer(memoryManager, srcVa, size, BufferStage.Copy);
var dstRange = dstPhysical.BufferCache.TranslateAndCreateBuffer(memoryManager, dstVa, size, BufferStage.Copy); MultiRange dstRange = dstPhysical.BufferCache.TranslateAndCreateBuffer(memoryManager, dstVa, size, BufferStage.Copy);
if (srcRange.Count == 1 && dstRange.Count == 1) if (srcRange.Count == 1 && dstRange.Count == 1)
{ {
@ -810,8 +810,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
ulong dstAddress, ulong dstAddress,
ulong size) ulong size)
{ {
var srcBuffer = srcPhysical.BufferCache.GetBuffer(srcAddress, size, BufferStage.Copy); Buffer srcBuffer = srcPhysical.BufferCache.GetBuffer(srcAddress, size, BufferStage.Copy);
var dstBuffer = dstPhysical.BufferCache.GetBuffer(dstAddress, size, BufferStage.Copy); Buffer dstBuffer = dstPhysical.BufferCache.GetBuffer(dstAddress, size, BufferStage.Copy);
int srcOffset = (int)(srcAddress - srcBuffer.Address); int srcOffset = (int)(srcAddress - srcBuffer.Address);
int dstOffset = (int)(dstAddress - dstBuffer.Address); int dstOffset = (int)(dstAddress - dstBuffer.Address);

View File

@ -157,7 +157,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// <param name="type">Type of each index buffer element</param> /// <param name="type">Type of each index buffer element</param>
public void SetIndexBuffer(ulong gpuVa, ulong size, IndexType type) public void SetIndexBuffer(ulong gpuVa, ulong size, IndexType type)
{ {
var bufferCache = _channel.MemoryManager.GetBackingMemory(gpuVa).BufferCache; BufferCache bufferCache = _channel.MemoryManager.GetBackingMemory(gpuVa).BufferCache;
MultiRange range = bufferCache.TranslateAndCreateBuffer(_channel.MemoryManager, gpuVa, size, BufferStage.IndexBuffer); MultiRange range = bufferCache.TranslateAndCreateBuffer(_channel.MemoryManager, gpuVa, size, BufferStage.IndexBuffer);
_indexBuffer.BufferCache = bufferCache; _indexBuffer.BufferCache = bufferCache;
@ -189,7 +189,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// <param name="divisor">Vertex divisor of the buffer, for instanced draws</param> /// <param name="divisor">Vertex divisor of the buffer, for instanced draws</param>
public void SetVertexBuffer(int index, ulong gpuVa, ulong size, int stride, int divisor) public void SetVertexBuffer(int index, ulong gpuVa, ulong size, int stride, int divisor)
{ {
var bufferCache = _channel.MemoryManager.GetBackingMemory(gpuVa).BufferCache; BufferCache bufferCache = _channel.MemoryManager.GetBackingMemory(gpuVa).BufferCache;
MultiRange range = bufferCache.TranslateAndCreateBuffer(_channel.MemoryManager, gpuVa, size, BufferStage.VertexBuffer); MultiRange range = bufferCache.TranslateAndCreateBuffer(_channel.MemoryManager, gpuVa, size, BufferStage.VertexBuffer);
ref VertexBuffer vb = ref _vertexBuffers[index]; ref VertexBuffer vb = ref _vertexBuffers[index];
@ -220,8 +220,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// <param name="size">Size in bytes of the transform feedback buffer</param> /// <param name="size">Size in bytes of the transform feedback buffer</param>
public void SetTransformFeedbackBuffer(int index, ulong gpuVa, ulong size) public void SetTransformFeedbackBuffer(int index, ulong gpuVa, ulong size)
{ {
var physical = _channel.MemoryManager.GetBackingMemory(gpuVa); PhysicalMemory physical = _channel.MemoryManager.GetBackingMemory(gpuVa);
var range = physical.BufferCache.TranslateAndCreateMultiBuffers(_channel.MemoryManager, gpuVa, size, BufferStage.TransformFeedback); MultiRange range = physical.BufferCache.TranslateAndCreateMultiBuffers(_channel.MemoryManager, gpuVa, size, BufferStage.TransformFeedback);
_transformFeedbackBuffers[index] = new BufferBounds(physical, range); _transformFeedbackBuffers[index] = new BufferBounds(physical, range);
_transformFeedbackBuffersDirty = true; _transformFeedbackBuffersDirty = true;
@ -268,8 +268,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
gpuVa = BitUtils.AlignDown(gpuVa, (ulong)_context.Capabilities.StorageBufferOffsetAlignment); gpuVa = BitUtils.AlignDown(gpuVa, (ulong)_context.Capabilities.StorageBufferOffsetAlignment);
var physical = _channel.MemoryManager.GetBackingMemory(gpuVa); PhysicalMemory physical = _channel.MemoryManager.GetBackingMemory(gpuVa);
var range = physical.BufferCache.TranslateAndCreateMultiBuffers(_channel.MemoryManager, gpuVa, size, BufferStageUtils.ComputeStorage(flags)); MultiRange range = physical.BufferCache.TranslateAndCreateMultiBuffers(_channel.MemoryManager, gpuVa, size, BufferStageUtils.ComputeStorage(flags));
_cpStorageBuffers.SetBounds(index, physical, range, flags); _cpStorageBuffers.SetBounds(index, physical, range, flags);
} }
@ -293,7 +293,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
gpuVa = BitUtils.AlignDown(gpuVa, (ulong)_context.Capabilities.StorageBufferOffsetAlignment); gpuVa = BitUtils.AlignDown(gpuVa, (ulong)_context.Capabilities.StorageBufferOffsetAlignment);
var physical = _channel.MemoryManager.GetBackingMemory(gpuVa); PhysicalMemory physical = _channel.MemoryManager.GetBackingMemory(gpuVa);
MultiRange range = physical.BufferCache.TranslateAndCreateMultiBuffers(_channel.MemoryManager, gpuVa, size, BufferStageUtils.GraphicsStorage(stage, flags)); MultiRange range = physical.BufferCache.TranslateAndCreateMultiBuffers(_channel.MemoryManager, gpuVa, size, BufferStageUtils.GraphicsStorage(stage, flags));
if (!buffers.Buffers[index].Range.Equals(range)) if (!buffers.Buffers[index].Range.Equals(range))
@ -313,7 +313,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// <param name="size">Size in bytes of the storage buffer</param> /// <param name="size">Size in bytes of the storage buffer</param>
public void SetComputeUniformBuffer(int index, ulong gpuVa, ulong size) public void SetComputeUniformBuffer(int index, ulong gpuVa, ulong size)
{ {
var physical = _channel.MemoryManager.GetBackingMemory(gpuVa); PhysicalMemory physical = _channel.MemoryManager.GetBackingMemory(gpuVa);
MultiRange range = physical.BufferCache.TranslateAndCreateBuffer(_channel.MemoryManager, gpuVa, size, BufferStage.Compute); MultiRange range = physical.BufferCache.TranslateAndCreateBuffer(_channel.MemoryManager, gpuVa, size, BufferStage.Compute);
_cpUniformBuffers.SetBounds(index, physical, range); _cpUniformBuffers.SetBounds(index, physical, range);
@ -329,7 +329,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// <param name="size">Size in bytes of the storage buffer</param> /// <param name="size">Size in bytes of the storage buffer</param>
public void SetGraphicsUniformBuffer(int stage, int index, ulong gpuVa, ulong size) public void SetGraphicsUniformBuffer(int stage, int index, ulong gpuVa, ulong size)
{ {
var physical = _channel.MemoryManager.GetBackingMemory(gpuVa); PhysicalMemory physical = _channel.MemoryManager.GetBackingMemory(gpuVa);
MultiRange range = _channel.MemoryManager.GetBackingMemory(gpuVa).BufferCache.TranslateAndCreateBuffer(_channel.MemoryManager, gpuVa, size, BufferStageUtils.FromShaderStage(stage)); MultiRange range = _channel.MemoryManager.GetBackingMemory(gpuVa).BufferCache.TranslateAndCreateBuffer(_channel.MemoryManager, gpuVa, size, BufferStageUtils.FromShaderStage(stage));
_gpUniformBuffers[stage].SetBounds(index, physical, range); _gpUniformBuffers[stage].SetBounds(index, physical, range);
@ -430,7 +430,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// <returns>The uniform buffer address, or an undefined value if the buffer is not currently bound</returns> /// <returns>The uniform buffer address, or an undefined value if the buffer is not currently bound</returns>
public (PhysicalMemory, ulong) GetComputeUniformBufferAddress(int index) public (PhysicalMemory, ulong) GetComputeUniformBufferAddress(int index)
{ {
ref var buffer = ref _cpUniformBuffers.Buffers[index]; ref BufferBounds buffer = ref _cpUniformBuffers.Buffers[index];
return (buffer.Physical, buffer.Range.GetSubRange(0).Address); return (buffer.Physical, buffer.Range.GetSubRange(0).Address);
} }
@ -452,7 +452,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
/// <returns>The uniform buffer address, or an undefined value if the buffer is not currently bound</returns> /// <returns>The uniform buffer address, or an undefined value if the buffer is not currently bound</returns>
public (PhysicalMemory, ulong) GetGraphicsUniformBufferAddress(int stage, int index) public (PhysicalMemory, ulong) GetGraphicsUniformBufferAddress(int stage, int index)
{ {
ref var buffer = ref _gpUniformBuffers[stage].Buffers[index]; ref BufferBounds buffer = ref _gpUniformBuffers[stage].Buffers[index];
return (buffer.Physical, buffer.Range.GetSubRange(0).Address); return (buffer.Physical, buffer.Range.GetSubRange(0).Address);
} }
@ -511,10 +511,10 @@ namespace Ryujinx.Graphics.Gpu.Memory
{ {
if (_bufferTextures.Count > 0) if (_bufferTextures.Count > 0)
{ {
foreach (var binding in _bufferTextures) foreach (BufferTextureBinding binding in _bufferTextures)
{ {
var isStore = binding.BindingInfo.Flags.HasFlag(TextureUsageFlags.ImageStore); bool isStore = binding.BindingInfo.Flags.HasFlag(TextureUsageFlags.ImageStore);
var range = binding.BufferCache.GetBufferRange(binding.Range, BufferStageUtils.TextureBuffer(binding.Stage, binding.BindingInfo.Flags), isStore); BufferRange range = binding.BufferCache.GetBufferRange(binding.Range, BufferStageUtils.TextureBuffer(binding.Stage, binding.BindingInfo.Flags), isStore);
binding.Texture.SetStorage(range); binding.Texture.SetStorage(range);
// The texture must be rebound to use the new storage if it was updated. // The texture must be rebound to use the new storage if it was updated.
@ -536,19 +536,19 @@ namespace Ryujinx.Graphics.Gpu.Memory
{ {
ITexture[] textureArray = new ITexture[1]; ITexture[] textureArray = new ITexture[1];
foreach (var binding in _bufferTextureArrays) foreach (BufferTextureArrayBinding<ITextureArray> binding in _bufferTextureArrays)
{ {
var range = binding.BufferCache.GetBufferRange(binding.Range, BufferStage.None); BufferRange range = binding.BufferCache.GetBufferRange(binding.Range, BufferStage.None);
binding.Texture.SetStorage(range); binding.Texture.SetStorage(range);
textureArray[0] = binding.Texture; textureArray[0] = binding.Texture;
binding.Array.SetTextures(binding.Index, textureArray); binding.Array.SetTextures(binding.Index, textureArray);
} }
foreach (var binding in _bufferImageArrays) foreach (BufferTextureArrayBinding<IImageArray> binding in _bufferImageArrays)
{ {
var isStore = binding.BindingInfo.Flags.HasFlag(TextureUsageFlags.ImageStore); bool isStore = binding.BindingInfo.Flags.HasFlag(TextureUsageFlags.ImageStore);
var range = binding.BufferCache.GetBufferRange(binding.Range, BufferStage.None, isStore); BufferRange range = binding.BufferCache.GetBufferRange(binding.Range, BufferStage.None, isStore);
binding.Texture.SetStorage(range); binding.Texture.SetStorage(range);
textureArray[0] = binding.Texture; textureArray[0] = binding.Texture;
@ -760,19 +760,19 @@ namespace Ryujinx.Graphics.Gpu.Memory
for (ShaderStage stage = ShaderStage.Vertex; stage <= ShaderStage.Fragment; stage++) for (ShaderStage stage = ShaderStage.Vertex; stage <= ShaderStage.Fragment; stage++)
{ {
ref var buffers = ref bindings[(int)stage - 1]; ref BuffersPerStage buffers = ref bindings[(int)stage - 1];
BufferStage bufferStage = BufferStageUtils.FromShaderStage(stage); BufferStage bufferStage = BufferStageUtils.FromShaderStage(stage);
for (int index = 0; index < buffers.Count; index++) for (int index = 0; index < buffers.Count; index++)
{ {
ref var bindingInfo = ref buffers.Bindings[index]; ref BufferDescriptor bindingInfo = ref buffers.Bindings[index];
BufferBounds bounds = buffers.Buffers[bindingInfo.Slot]; BufferBounds bounds = buffers.Buffers[bindingInfo.Slot];
if (!bounds.IsUnmapped) if (!bounds.IsUnmapped)
{ {
var isWrite = bounds.Flags.HasFlag(BufferUsageFlags.Write); bool isWrite = bounds.Flags.HasFlag(BufferUsageFlags.Write);
var range = isStorage BufferRange range = isStorage
? bounds.BufferCache.GetBufferRangeAligned(bounds.Range, bufferStage | BufferStageUtils.FromUsage(bounds.Flags), isWrite) ? bounds.BufferCache.GetBufferRangeAligned(bounds.Range, bufferStage | BufferStageUtils.FromUsage(bounds.Flags), isWrite)
: bounds.BufferCache.GetBufferRange(bounds.Range, bufferStage); : bounds.BufferCache.GetBufferRange(bounds.Range, bufferStage);
@ -801,14 +801,14 @@ namespace Ryujinx.Graphics.Gpu.Memory
for (int index = 0; index < buffers.Count; index++) for (int index = 0; index < buffers.Count; index++)
{ {
ref var bindingInfo = ref buffers.Bindings[index]; ref BufferDescriptor bindingInfo = ref buffers.Bindings[index];
BufferBounds bounds = buffers.Buffers[bindingInfo.Slot]; BufferBounds bounds = buffers.Buffers[bindingInfo.Slot];
if (!bounds.IsUnmapped) if (!bounds.IsUnmapped)
{ {
var isWrite = bounds.Flags.HasFlag(BufferUsageFlags.Write); bool isWrite = bounds.Flags.HasFlag(BufferUsageFlags.Write);
var range = isStorage BufferRange range = isStorage
? bounds.BufferCache.GetBufferRangeAligned(bounds.Range, BufferStageUtils.ComputeStorage(bounds.Flags), isWrite) ? bounds.BufferCache.GetBufferRangeAligned(bounds.Range, BufferStageUtils.ComputeStorage(bounds.Flags), isWrite)
: bounds.BufferCache.GetBufferRange(bounds.Range, BufferStage.Compute); : bounds.BufferCache.GetBufferRange(bounds.Range, BufferStage.Compute);
@ -850,11 +850,11 @@ namespace Ryujinx.Graphics.Gpu.Memory
{ {
for (ShaderStage stage = ShaderStage.Vertex; stage <= ShaderStage.Fragment; stage++) for (ShaderStage stage = ShaderStage.Vertex; stage <= ShaderStage.Fragment; stage++)
{ {
ref var buffers = ref bindings[(int)stage - 1]; ref BuffersPerStage buffers = ref bindings[(int)stage - 1];
for (int index = 0; index < buffers.Count; index++) for (int index = 0; index < buffers.Count; index++)
{ {
ref var binding = ref buffers.Bindings[index]; ref BufferDescriptor binding = ref buffers.Bindings[index];
BufferBounds bounds = buffers.Buffers[binding.Slot]; BufferBounds bounds = buffers.Buffers[binding.Slot];

View File

@ -611,7 +611,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
int pages = (int)((endVaRounded - va) / PageSize); int pages = (int)((endVaRounded - va) / PageSize);
var regions = new List<MemoryRange>(); List<MemoryRange> regions = new();
for (int page = 0; page < pages - 1; page++) for (int page = 0; page < pages - 1; page++)
{ {

View File

@ -1,5 +1,6 @@
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using Ryujinx.Graphics.Gpu.Image; using Ryujinx.Graphics.Gpu.Image;
using Ryujinx.Graphics.Gpu.Memory;
using Ryujinx.Graphics.Shader; using Ryujinx.Graphics.Shader;
using Ryujinx.Graphics.Shader.Translation; using Ryujinx.Graphics.Shader.Translation;
using System; using System;
@ -66,7 +67,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <inheritdoc/> /// <inheritdoc/>
public uint ConstantBuffer1Read(int offset) public uint ConstantBuffer1Read(int offset)
{ {
(var physical, ulong baseAddress) = _compute (PhysicalMemory physical, ulong baseAddress) = _compute
? _channel.BufferManager.GetComputeUniformBufferAddress(1) ? _channel.BufferManager.GetComputeUniformBufferAddress(1)
: _channel.BufferManager.GetGraphicsUniformBufferAddress(_stageIndex, 1); : _channel.BufferManager.GetGraphicsUniformBufferAddress(_stageIndex, 1);

View File

@ -733,7 +733,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
byte[] codeB, byte[] codeB,
bool asCompute) bool asCompute)
{ {
(var physical, ulong cb1DataAddress) = channel.BufferManager.GetGraphicsUniformBufferAddress(0, 1); (PhysicalMemory physical, ulong cb1DataAddress) = channel.BufferManager.GetGraphicsUniformBufferAddress(0, 1);
MemoryManager memoryManager = channel.MemoryManager; MemoryManager memoryManager = channel.MemoryManager;
@ -775,7 +775,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
{ {
MemoryManager memoryManager = channel.MemoryManager; MemoryManager memoryManager = channel.MemoryManager;
(var physical, ulong cb1DataAddress) = context.Stage == ShaderStage.Compute (PhysicalMemory physical, ulong cb1DataAddress) = context.Stage == ShaderStage.Compute
? channel.BufferManager.GetComputeUniformBufferAddress(1) ? channel.BufferManager.GetComputeUniformBufferAddress(1)
: channel.BufferManager.GetGraphicsUniformBufferAddress(StageToStageIndex(context.Stage), 1); : channel.BufferManager.GetGraphicsUniformBufferAddress(StageToStageIndex(context.Stage), 1);

View File

@ -5,6 +5,7 @@ using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap;
using Ryujinx.HLE.HOS.Services.SurfaceFlinger; using Ryujinx.HLE.HOS.Services.SurfaceFlinger;
using Ryujinx.HLE.HOS.Services.SurfaceFlinger.Types; using Ryujinx.HLE.HOS.Services.SurfaceFlinger.Types;
using Ryujinx.HLE.HOS.Services.Vi.Types; using Ryujinx.HLE.HOS.Services.Vi.Types;
using Ryujinx.Memory;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
namespace Ryujinx.HLE.HOS.Services namespace Ryujinx.HLE.HOS.Services
@ -87,9 +88,9 @@ namespace Ryujinx.HLE.HOS.Services
public void ConnectSharedLayer(long layerId) public void ConnectSharedLayer(long layerId)
{ {
var producer = _surfaceFlinger.GetProducerByLayerId(layerId); IGraphicBufferProducer producer = _surfaceFlinger.GetProducerByLayerId(layerId);
producer.Connect(null, NativeWindowApi.NVN, false, out var output); producer.Connect(null, NativeWindowApi.NVN, false, out IGraphicBufferProducer.QueueBufferOutput output);
GraphicBuffer graphicBuffer = new GraphicBuffer(); GraphicBuffer graphicBuffer = new GraphicBuffer();
@ -137,14 +138,14 @@ namespace Ryujinx.HLE.HOS.Services
public void DisconnectSharedLayer(long layerId) public void DisconnectSharedLayer(long layerId)
{ {
var producer = _surfaceFlinger.GetProducerByLayerId(layerId); IGraphicBufferProducer producer = _surfaceFlinger.GetProducerByLayerId(layerId);
producer.Disconnect(NativeWindowApi.NVN); producer.Disconnect(NativeWindowApi.NVN);
} }
public int DequeueFrameBuffer(long layerId, out AndroidFence fence) public int DequeueFrameBuffer(long layerId, out AndroidFence fence)
{ {
var producer = _surfaceFlinger.GetProducerByLayerId(layerId); IGraphicBufferProducer producer = _surfaceFlinger.GetProducerByLayerId(layerId);
Status status = producer.DequeueBuffer(out int slot, out fence, false, _fbWidth, _fbHeight, _fbFormat, (uint)_fbUsage); Status status = producer.DequeueBuffer(out int slot, out fence, false, _fbWidth, _fbHeight, _fbFormat, (uint)_fbUsage);
@ -168,9 +169,9 @@ namespace Ryujinx.HLE.HOS.Services
public void QueueFrameBuffer(long layerId, int slot, Rect crop, NativeWindowTransform transform, int swapInterval, AndroidFence fence) public void QueueFrameBuffer(long layerId, int slot, Rect crop, NativeWindowTransform transform, int swapInterval, AndroidFence fence)
{ {
var producer = _surfaceFlinger.GetProducerByLayerId(layerId); IGraphicBufferProducer producer = _surfaceFlinger.GetProducerByLayerId(layerId);
var input = new IGraphicBufferProducer.QueueBufferInput(); IGraphicBufferProducer.QueueBufferInput input = new();
input.Crop = crop; input.Crop = crop;
input.Transform = transform; input.Transform = transform;
@ -182,7 +183,7 @@ namespace Ryujinx.HLE.HOS.Services
public void CancelFrameBuffer(long layerId, int slot) public void CancelFrameBuffer(long layerId, int slot)
{ {
var producer = _surfaceFlinger.GetProducerByLayerId(layerId); IGraphicBufferProducer producer = _surfaceFlinger.GetProducerByLayerId(layerId);
AndroidFence fence = default; AndroidFence fence = default;
producer.CancelBuffer(slot, ref fence); producer.CancelBuffer(slot, ref fence);
@ -222,8 +223,8 @@ namespace Ryujinx.HLE.HOS.Services
public int GetApplicationLastPresentedFrameHandle(GpuContext gpuContext) public int GetApplicationLastPresentedFrameHandle(GpuContext gpuContext)
{ {
var texture = gpuContext.Window.GetLastPresentedData(); TextureData texture = gpuContext.Window.GetLastPresentedData();
var selfAs = KernelStatic.GetProcessByPid(_pid).CpuMemory; IVirtualMemoryManagerTracked selfAs = KernelStatic.GetProcessByPid(_pid).CpuMemory;
int fbIndex = (int)_fbCount; // Place it after all our frame buffers. int fbIndex = (int)_fbCount; // Place it after all our frame buffers.
selfAs.Write(_fbsBaseAddress + _bufferMap.SharedBuffers[fbIndex].Offset, texture.Data); selfAs.Write(_fbsBaseAddress + _bufferMap.SharedBuffers[fbIndex].Offset, texture.Data);