Compare commits
26 Commits
f2ade5f1f8
...
1.2.82
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b16b844760 | ||
|
|
bc07bc482d | ||
|
|
61975ca44d | ||
|
|
66054dd225 | ||
|
|
b1f61e5143 | ||
|
|
0d7d0e8092 | ||
|
|
aa2178dbe5 | ||
|
|
f92d09711b | ||
|
|
45ee8cd0e8 | ||
|
|
395bbd144a | ||
|
|
744d813b87 | ||
|
|
7d59ada798 | ||
|
|
a4b5304935 | ||
|
|
0965ee905d | ||
|
|
855161b23b | ||
|
|
6b55d158b7 | ||
|
|
91f73a4891 | ||
|
|
883d4d863a | ||
|
|
ca5de909a1 | ||
|
|
5172567b08 | ||
|
|
6fe4cee7c0 | ||
|
|
8623452abc | ||
|
|
17e8ae1d9a | ||
|
|
7591b07fce | ||
|
|
89b4389ed2 | ||
|
|
d9ee729199 |
4
.github/workflows/canary.yml
vendored
4
.github/workflows/canary.yml
vendored
@@ -29,7 +29,7 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
tag:
|
tag:
|
||||||
name: Create tag
|
name: Create tag
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Get version info
|
- name: Get version info
|
||||||
id: version_info
|
id: version_info
|
||||||
@@ -202,7 +202,7 @@ jobs:
|
|||||||
|
|
||||||
macos_release:
|
macos_release:
|
||||||
name: Release MacOS universal
|
name: Release MacOS universal
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
|||||||
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@@ -18,7 +18,7 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
tag:
|
tag:
|
||||||
name: Create tag
|
name: Create tag
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Get version info
|
- name: Get version info
|
||||||
id: version_info
|
id: version_info
|
||||||
@@ -183,7 +183,7 @@ jobs:
|
|||||||
|
|
||||||
macos_release:
|
macos_release:
|
||||||
name: Release MacOS universal
|
name: Release MacOS universal
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
|||||||
@@ -39,12 +39,12 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
Click below to join the Discord:
|
Click below to join the Discord:
|
||||||
<br>
|
<br>
|
||||||
<a href="https://discord.gg/dHPrkBkkyA">
|
<a href="https://discord.gg/PEuzjrFXUA">
|
||||||
<img src="https://img.shields.io/discord/1294443224030511104?color=5865F2&label=Ryubing&logo=discord&logoColor=white" alt="Discord">
|
<img src="https://img.shields.io/discord/1294443224030511104?color=5865F2&label=Ryubing&logo=discord&logoColor=white" alt="Discord">
|
||||||
</a>
|
</a>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<img src="https://raw.githubusercontent.com/GreemDev/Ryujinx/refs/heads/master/docs/shell.png">
|
<img src="https://raw.githubusercontent.com/Ryubing/Ryujinx/refs/heads/master/docs/shell.png">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|||||||
@@ -969,6 +969,7 @@
|
|||||||
0100751007ADA000,"Don't Starve: Nintendo Switch Edition",nvdec,playable,2022-02-05 20:43:34
|
0100751007ADA000,"Don't Starve: Nintendo Switch Edition",nvdec,playable,2022-02-05 20:43:34
|
||||||
010088B010DD2000,"Dongo Adventure",,playable,2022-10-04 16:22:26
|
010088B010DD2000,"Dongo Adventure",,playable,2022-10-04 16:22:26
|
||||||
0100C1F0051B6000,"Donkey Kong Country™: Tropical Freeze",,playable,2024-08-05 16:46:10
|
0100C1F0051B6000,"Donkey Kong Country™: Tropical Freeze",,playable,2024-08-05 16:46:10
|
||||||
|
01009D901BC56000,"Donkey Kong Country™: Returns HD",gpu,ingame,2025-02-16 13:44:12
|
||||||
0100F2C00F060000,"Doodle Derby",,boots,2020-12-04 22:51:48
|
0100F2C00F060000,"Doodle Derby",,boots,2020-12-04 22:51:48
|
||||||
0100416004C00000,"DOOM",gpu;slow;nvdec;online-broken,ingame,2024-09-23 15:40:07
|
0100416004C00000,"DOOM",gpu;slow;nvdec;online-broken,ingame,2024-09-23 15:40:07
|
||||||
010018900DD00000,"DOOM (1993)",nvdec;online-broken,menus,2022-09-06 13:32:19
|
010018900DD00000,"DOOM (1993)",nvdec;online-broken,menus,2022-09-06 13:32:19
|
||||||
@@ -1249,7 +1250,7 @@
|
|||||||
0100A6B00D4EC000,"Furwind",,playable,2021-02-19 19:44:08
|
0100A6B00D4EC000,"Furwind",,playable,2021-02-19 19:44:08
|
||||||
0100ECE00C0C4000,"Fury Unleashed",crash;services,ingame,2020-10-18 11:52:40
|
0100ECE00C0C4000,"Fury Unleashed",crash;services,ingame,2020-10-18 11:52:40
|
||||||
010070000ED9E000,"Fury Unleashed Demo",,playable,2020-10-08 20:09:21
|
010070000ED9E000,"Fury Unleashed Demo",,playable,2020-10-08 20:09:21
|
||||||
0100E1F013674000,"FUSER™",nvdec;UE4,playable,2022-10-17 20:58:32
|
0100E1F013674000,"FUSER™",nvdec;UE4;slow;gpu,ingame,2025-02-12 16:03:00
|
||||||
0100A7A015E4C000,"Fushigi no Gensokyo Lotus Labyrinth",Needs Update;audio;gpu;nvdec,ingame,2021-01-20 15:30:02
|
0100A7A015E4C000,"Fushigi no Gensokyo Lotus Labyrinth",Needs Update;audio;gpu;nvdec,ingame,2021-01-20 15:30:02
|
||||||
01003C300B274000,"Futari de! Nyanko Daisensou",,playable,2024-01-05 22:26:52
|
01003C300B274000,"Futari de! Nyanko Daisensou",,playable,2024-01-05 22:26:52
|
||||||
010055801134E000,"FUZE Player",online-broken;vulkan-backend-bug,ingame,2022-10-18 12:23:53
|
010055801134E000,"FUZE Player",online-broken;vulkan-backend-bug,ingame,2022-10-18 12:23:53
|
||||||
@@ -2988,8 +2989,8 @@
|
|||||||
010015D003EE4000,"The Jackbox Party Pack 2",online-working,playable,2022-08-22 18:23:40
|
010015D003EE4000,"The Jackbox Party Pack 2",online-working,playable,2022-08-22 18:23:40
|
||||||
0100CC80013D6000,"The Jackbox Party Pack 3",slow;online-working,playable,2022-08-22 18:41:06
|
0100CC80013D6000,"The Jackbox Party Pack 3",slow;online-working,playable,2022-08-22 18:41:06
|
||||||
0100E1F003EE8000,"The Jackbox Party Pack 4",online-working,playable,2022-08-22 18:56:34
|
0100E1F003EE8000,"The Jackbox Party Pack 4",online-working,playable,2022-08-22 18:56:34
|
||||||
01006fe0096ac000,"The Jackbox Party Pack 5",ldn-untested,boots,2025-02-03 22:32:00
|
01006fe0096ac000,"The Jackbox Party Pack 5",slow;online-working,ingame,2025-02-14 05:32:00
|
||||||
01005a400db52000,"The Jackbox Party Pack 6",ldn-untested,boots,2025-02-03 22:32:00
|
01005a400db52000,"The Jackbox Party Pack 6",slow;online-working,ingame,2025-02-14 05:26:00
|
||||||
010052C00B184000,"The Journey Down: Chapter One",nvdec,playable,2021-02-24 13:32:41
|
010052C00B184000,"The Journey Down: Chapter One",nvdec,playable,2021-02-24 13:32:41
|
||||||
01006BC00B188000,"The Journey Down: Chapter Three",nvdec,playable,2021-02-24 13:45:27
|
01006BC00B188000,"The Journey Down: Chapter Three",nvdec,playable,2021-02-24 13:45:27
|
||||||
01009AB00B186000,"The Journey Down: Chapter Two",nvdec,playable,2021-02-24 13:32:13
|
01009AB00B186000,"The Journey Down: Chapter Two",nvdec,playable,2021-02-24 13:32:13
|
||||||
|
|||||||
|
@@ -186,7 +186,7 @@ namespace ARMeilleure.Translation.Cache
|
|||||||
|
|
||||||
int newRegionNumber = _activeRegionIndex;
|
int newRegionNumber = _activeRegionIndex;
|
||||||
|
|
||||||
Logger.Warning?.Print(LogClass.Cpu, $"JIT Cache Region {exhaustedRegion} exhausted, creating new Cache Region {newRegionNumber} ({((newRegionNumber + 1) * CacheSize).Bytes()} Total Allocation).");
|
Logger.Warning?.Print(LogClass.Cpu, $"JIT Cache Region {exhaustedRegion} exhausted, creating new Cache Region {newRegionNumber} ({((long)(newRegionNumber + 1) * CacheSize).Bytes()} Total Allocation).");
|
||||||
|
|
||||||
_cacheAllocator = new CacheMemoryAllocator(CacheSize);
|
_cacheAllocator = new CacheMemoryAllocator(CacheSize);
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using Ryujinx.Memory.Tracking;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ryujinx.Memory
|
namespace Ryujinx.Cpu
|
||||||
{
|
{
|
||||||
public interface IVirtualMemoryManagerTracked : IVirtualMemoryManager
|
public interface IVirtualMemoryManagerTracked : IVirtualMemoryManager
|
||||||
{
|
{
|
||||||
@@ -166,7 +166,7 @@ namespace Ryujinx.Cpu.LightningJit.Cache
|
|||||||
|
|
||||||
int newRegionNumber = _activeRegionIndex;
|
int newRegionNumber = _activeRegionIndex;
|
||||||
|
|
||||||
Logger.Warning?.Print(LogClass.Cpu, $"JIT Cache Region {exhaustedRegion} exhausted, creating new Cache Region {newRegionNumber} ({((newRegionNumber + 1) * CacheSize).Bytes()} Total Allocation).");
|
Logger.Warning?.Print(LogClass.Cpu, $"JIT Cache Region {exhaustedRegion} exhausted, creating new Cache Region {newRegionNumber} ({((long)(newRegionNumber + 1) * CacheSize).Bytes()} Total Allocation).");
|
||||||
|
|
||||||
_cacheAllocator = new CacheMemoryAllocator(CacheSize);
|
_cacheAllocator = new CacheMemoryAllocator(CacheSize);
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
|
|||||||
|
|
||||||
// Make sure all pending uniform buffer data is written to memory.
|
// Make sure all pending uniform buffer data is written to memory.
|
||||||
_3dEngine.FlushUboDirty();
|
_3dEngine.FlushUboDirty();
|
||||||
|
|
||||||
uint qmdAddress = _state.State.SendPcasA;
|
uint qmdAddress = _state.State.SendPcasA;
|
||||||
|
|
||||||
ComputeQmd qmd = _channel.MemoryManager.Read<ComputeQmd>((ulong)qmdAddress << 8);
|
ComputeQmd qmd = _channel.MemoryManager.Read<ComputeQmd>((ulong)qmdAddress << 8);
|
||||||
@@ -106,8 +106,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
|
|||||||
ulong shaderGpuVa = ((ulong)_state.State.SetProgramRegionAAddressUpper << 32) | _state.State.SetProgramRegionB;
|
ulong shaderGpuVa = ((ulong)_state.State.SetProgramRegionAAddressUpper << 32) | _state.State.SetProgramRegionB;
|
||||||
|
|
||||||
shaderGpuVa += (uint)qmd.ProgramOffset;
|
shaderGpuVa += (uint)qmd.ProgramOffset;
|
||||||
|
|
||||||
ShaderCache shaderCache = memoryManager.GetBackingMemory(shaderGpuVa).ShaderCache;
|
|
||||||
|
|
||||||
int localMemorySize = qmd.ShaderLocalMemoryLowSize + qmd.ShaderLocalMemoryHighSize;
|
int localMemorySize = qmd.ShaderLocalMemoryLowSize + qmd.ShaderLocalMemoryHighSize;
|
||||||
|
|
||||||
@@ -144,7 +142,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
|
|||||||
sharedMemorySize,
|
sharedMemorySize,
|
||||||
_channel.BufferManager.HasUnalignedStorageBuffers);
|
_channel.BufferManager.HasUnalignedStorageBuffers);
|
||||||
|
|
||||||
CachedShaderProgram cs = shaderCache.GetComputeShader(_channel, samplerPoolMaximumId, poolState, computeState, shaderGpuVa);
|
CachedShaderProgram cs = memoryManager.Physical.ShaderCache.GetComputeShader(_channel, samplerPoolMaximumId, poolState, computeState, shaderGpuVa);
|
||||||
|
|
||||||
_context.Renderer.Pipeline.SetProgram(cs.HostProgram);
|
_context.Renderer.Pipeline.SetProgram(cs.HostProgram);
|
||||||
|
|
||||||
@@ -158,10 +156,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
|
|||||||
{
|
{
|
||||||
BufferDescriptor sb = info.SBuffers[index];
|
BufferDescriptor sb = info.SBuffers[index];
|
||||||
|
|
||||||
(PhysicalMemory physical, ulong sbDescAddress) = _channel.BufferManager.GetComputeUniformBufferAddress(sb.SbCbSlot);
|
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 = _channel.MemoryManager.Physical.Read<SbDescriptor>(sbDescAddress);
|
||||||
|
|
||||||
uint size;
|
uint size;
|
||||||
if (sb.SbCbSlot == Constants.DriverReservedUniformBuffer)
|
if (sb.SbCbSlot == Constants.DriverReservedUniformBuffer)
|
||||||
@@ -189,7 +187,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Compute
|
|||||||
sharedMemorySize,
|
sharedMemorySize,
|
||||||
_channel.BufferManager.HasUnalignedStorageBuffers);
|
_channel.BufferManager.HasUnalignedStorageBuffers);
|
||||||
|
|
||||||
cs = shaderCache.GetComputeShader(_channel, samplerPoolMaximumId, poolState, computeState, shaderGpuVa);
|
cs = memoryManager.Physical.ShaderCache.GetComputeShader(_channel, samplerPoolMaximumId, poolState, computeState, shaderGpuVa);
|
||||||
|
|
||||||
_context.Renderer.Pipeline.SetProgram(cs.HostProgram);
|
_context.Renderer.Pipeline.SetProgram(cs.HostProgram);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -215,10 +215,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
|
|||||||
_channel.TextureManager.RefreshModifiedTextures();
|
_channel.TextureManager.RefreshModifiedTextures();
|
||||||
_3dEngine.CreatePendingSyncs();
|
_3dEngine.CreatePendingSyncs();
|
||||||
_3dEngine.FlushUboDirty();
|
_3dEngine.FlushUboDirty();
|
||||||
|
|
||||||
PhysicalMemory srcPhysical = memoryManager.GetBackingMemory(srcGpuVa);
|
|
||||||
PhysicalMemory dstPhysical = memoryManager.GetBackingMemory(dstGpuVa);
|
|
||||||
|
|
||||||
if (copy2D)
|
if (copy2D)
|
||||||
{
|
{
|
||||||
// Buffer to texture copy.
|
// Buffer to texture copy.
|
||||||
@@ -296,7 +293,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
|
|||||||
|
|
||||||
if (completeSource && completeDest && !srcLinear && isIdentityRemap)
|
if (completeSource && completeDest && !srcLinear && isIdentityRemap)
|
||||||
{
|
{
|
||||||
Image.Texture source = srcPhysical.TextureCache.FindTexture(
|
Image.Texture source = memoryManager.Physical.TextureCache.FindTexture(
|
||||||
memoryManager,
|
memoryManager,
|
||||||
srcGpuVa,
|
srcGpuVa,
|
||||||
srcBpp,
|
srcBpp,
|
||||||
@@ -312,7 +309,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
|
|||||||
{
|
{
|
||||||
source.SynchronizeMemory();
|
source.SynchronizeMemory();
|
||||||
|
|
||||||
Image.Texture target = dstPhysical.TextureCache.FindOrCreateTexture(
|
Image.Texture target = memoryManager.Physical.TextureCache.FindOrCreateTexture(
|
||||||
memoryManager,
|
memoryManager,
|
||||||
source.Info.FormatInfo,
|
source.Info.FormatInfo,
|
||||||
dstGpuVa,
|
dstGpuVa,
|
||||||
@@ -342,7 +339,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
|
|||||||
|
|
||||||
if (completeSource && completeDest && !(dstLinear && !srcLinear) && isIdentityRemap)
|
if (completeSource && completeDest && !(dstLinear && !srcLinear) && isIdentityRemap)
|
||||||
{
|
{
|
||||||
Image.Texture target = dstPhysical.TextureCache.FindTexture(
|
Image.Texture target = memoryManager.Physical.TextureCache.FindTexture(
|
||||||
memoryManager,
|
memoryManager,
|
||||||
dstGpuVa,
|
dstGpuVa,
|
||||||
dstBpp,
|
dstBpp,
|
||||||
@@ -465,7 +462,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
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 &&
|
||||||
@@ -476,7 +472,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
|
|||||||
_state.State.SetRemapComponentsComponentSize == SetRemapComponentsComponentSize.Four)
|
_state.State.SetRemapComponentsComponentSize == SetRemapComponentsComponentSize.Four)
|
||||||
{
|
{
|
||||||
// Fast path for clears when remap is enabled.
|
// Fast path for clears when remap is enabled.
|
||||||
bufferCache.ClearBuffer(memoryManager, dstGpuVa, size * 4, _state.State.SetRemapConstA);
|
memoryManager.Physical.BufferCache.ClearBuffer(memoryManager, dstGpuVa, size * 4, _state.State.SetRemapConstA);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -496,7 +492,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Dma
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BufferCache.CopyBuffer(_context,memoryManager, srcGpuVa, dstGpuVa, size);
|
memoryManager.Physical.BufferCache.CopyBuffer(memoryManager, srcGpuVa, dstGpuVa, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
{
|
{
|
||||||
Image.Texture target = memoryManager.GetBackingMemory(_dstGpuVa).TextureCache.FindTexture(
|
Image.Texture target = memoryManager.Physical.TextureCache.FindTexture(
|
||||||
memoryManager,
|
memoryManager,
|
||||||
_dstGpuVa,
|
_dstGpuVa,
|
||||||
1,
|
1,
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
|
|||||||
|
|
||||||
ulong indirectBufferGpuVa = count.GpuVa;
|
ulong indirectBufferGpuVa = count.GpuVa;
|
||||||
|
|
||||||
BufferCache bufferCache = _processor.MemoryManager.GetBackingMemory(indirectBufferGpuVa).BufferCache;
|
BufferCache bufferCache = _processor.MemoryManager.Physical.BufferCache;
|
||||||
|
|
||||||
bool useBuffer = bufferCache.CheckModified(_processor.MemoryManager, indirectBufferGpuVa, IndirectIndexedDataEntrySize, out ulong indirectBufferAddress);
|
bool useBuffer = bufferCache.CheckModified(_processor.MemoryManager, indirectBufferGpuVa, IndirectIndexedDataEntrySize, out ulong indirectBufferAddress);
|
||||||
|
|
||||||
@@ -394,8 +394,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
|
|||||||
|
|
||||||
_processor.ThreedClass.DrawIndirect(
|
_processor.ThreedClass.DrawIndirect(
|
||||||
topology,
|
topology,
|
||||||
bufferCache,
|
|
||||||
null,
|
|
||||||
new MultiRange(indirectBufferAddress, IndirectIndexedDataEntrySize),
|
new MultiRange(indirectBufferAddress, IndirectIndexedDataEntrySize),
|
||||||
default,
|
default,
|
||||||
1,
|
1,
|
||||||
@@ -493,24 +491,22 @@ namespace Ryujinx.Graphics.Gpu.Engine.MME
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BufferCache indirectBufferCache = _processor.MemoryManager.GetBackingMemory(indirectBufferGpuVa).BufferCache;
|
|
||||||
BufferCache parameterBufferCache = _processor.MemoryManager.GetBackingMemory(parameterBufferGpuVa).BufferCache;
|
BufferCache bufferCache = _processor.MemoryManager.Physical.BufferCache;
|
||||||
|
|
||||||
ulong indirectBufferSize = (ulong)maxDrawCount * (ulong)stride;
|
ulong indirectBufferSize = (ulong)maxDrawCount * (ulong)stride;
|
||||||
|
|
||||||
MultiRange indirectBufferRange = indirectBufferCache.TranslateAndCreateMultiBuffers(_processor.MemoryManager, indirectBufferGpuVa, indirectBufferSize, BufferStage.Indirect);
|
MultiRange indirectBufferRange = bufferCache.TranslateAndCreateMultiBuffers(_processor.MemoryManager, indirectBufferGpuVa, indirectBufferSize, BufferStage.Indirect);
|
||||||
MultiRange parameterBufferRange = parameterBufferCache.TranslateAndCreateMultiBuffers(_processor.MemoryManager, parameterBufferGpuVa, 4, BufferStage.Indirect);
|
MultiRange parameterBufferRange = bufferCache.TranslateAndCreateMultiBuffers(_processor.MemoryManager, parameterBufferGpuVa, 4, BufferStage.Indirect);
|
||||||
|
|
||||||
_processor.ThreedClass.DrawIndirect(
|
_processor.ThreedClass.DrawIndirect(
|
||||||
topology,
|
topology,
|
||||||
indirectBufferCache,
|
|
||||||
parameterBufferCache,
|
|
||||||
indirectBufferRange,
|
indirectBufferRange,
|
||||||
parameterBufferRange,
|
parameterBufferRange,
|
||||||
maxDrawCount,
|
maxDrawCount,
|
||||||
stride,
|
stride,
|
||||||
indexCount,
|
indexCount,
|
||||||
IndirectDrawType.DrawIndexedIndirectCount);
|
Threed.IndirectDrawType.DrawIndexedIndirectCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
class VtgAsComputeContext : IDisposable
|
class VtgAsComputeContext : IDisposable
|
||||||
{
|
{
|
||||||
private const int DummyBufferSize = 16;
|
|
||||||
|
|
||||||
private readonly GpuContext _context;
|
private readonly GpuContext _context;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -48,7 +46,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
|
|||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
1,
|
format.GetBytesPerElement(),
|
||||||
format,
|
format,
|
||||||
DepthStencilMode.Depth,
|
DepthStencilMode.Depth,
|
||||||
Target.TextureBuffer,
|
Target.TextureBuffer,
|
||||||
@@ -521,21 +519,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
|
|||||||
return new BufferRange(_geometryIndexDataBuffer.Handle, offset, size, write);
|
return new BufferRange(_geometryIndexDataBuffer.Handle, offset, size, write);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the range for a dummy 16 bytes buffer, filled with zeros.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Dummy buffer range</returns>
|
|
||||||
public BufferRange GetDummyBufferRange()
|
|
||||||
{
|
|
||||||
if (_dummyBuffer == BufferHandle.Null)
|
|
||||||
{
|
|
||||||
_dummyBuffer = _context.Renderer.CreateBuffer(DummyBufferSize, BufferAccess.DeviceMemory);
|
|
||||||
_context.Renderer.Pipeline.ClearBuffer(_dummyBuffer, 0, DummyBufferSize, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new BufferRange(_dummyBuffer, 0, DummyBufferSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the range for a sequential index buffer, with ever incrementing index values.
|
/// Gets the range for a sequential index buffer, with ever incrementing index values.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -147,7 +147,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
|
|||||||
{
|
{
|
||||||
_vacContext.VertexInfoBufferUpdater.SetVertexStride(index, 0, componentsCount);
|
_vacContext.VertexInfoBufferUpdater.SetVertexStride(index, 0, componentsCount);
|
||||||
_vacContext.VertexInfoBufferUpdater.SetVertexOffset(index, 0, 0);
|
_vacContext.VertexInfoBufferUpdater.SetVertexOffset(index, 0, 0);
|
||||||
SetDummyBufferTexture(_vertexAsCompute.Reservations, index, format);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,15 +162,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
|
|||||||
{
|
{
|
||||||
_vacContext.VertexInfoBufferUpdater.SetVertexStride(index, 0, componentsCount);
|
_vacContext.VertexInfoBufferUpdater.SetVertexStride(index, 0, componentsCount);
|
||||||
_vacContext.VertexInfoBufferUpdater.SetVertexOffset(index, 0, 0);
|
_vacContext.VertexInfoBufferUpdater.SetVertexOffset(index, 0, 0);
|
||||||
SetDummyBufferTexture(_vertexAsCompute.Reservations, index, format);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vbStride = vertexBuffer.UnpackStride();
|
int vbStride = vertexBuffer.UnpackStride();
|
||||||
ulong vbSize = GetVertexBufferSize(address, endAddress.Pack(), vbStride, _indexed, instanced, _firstVertex, _count);
|
ulong vbSize = GetVertexBufferSize(address, endAddress.Pack(), vbStride, _indexed, instanced, _firstVertex, _count);
|
||||||
|
|
||||||
ulong oldVbSize = vbSize;
|
|
||||||
|
|
||||||
ulong attributeOffset = (ulong)vertexAttrib.UnpackOffset();
|
ulong attributeOffset = (ulong)vertexAttrib.UnpackOffset();
|
||||||
int componentSize = format.GetScalarSize();
|
int componentSize = format.GetScalarSize();
|
||||||
|
|
||||||
@@ -200,11 +196,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
|
|||||||
|
|
||||||
int vertexInfoBinding = _vertexAsCompute.Reservations.VertexInfoConstantBufferBinding;
|
int vertexInfoBinding = _vertexAsCompute.Reservations.VertexInfoConstantBufferBinding;
|
||||||
BufferRange vertexInfoRange = new(_vacContext.VertexInfoBufferUpdater.Handle, 0, VertexInfoBuffer.RequiredSize);
|
BufferRange vertexInfoRange = new(_vacContext.VertexInfoBufferUpdater.Handle, 0, VertexInfoBuffer.RequiredSize);
|
||||||
_context.Renderer.Pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(vertexInfoBinding, vertexInfoRange) });
|
_context.Renderer.Pipeline.SetUniformBuffers([new BufferAssignment(vertexInfoBinding, vertexInfoRange)]);
|
||||||
|
|
||||||
int vertexDataBinding = _vertexAsCompute.Reservations.VertexOutputStorageBufferBinding;
|
int vertexDataBinding = _vertexAsCompute.Reservations.VertexOutputStorageBufferBinding;
|
||||||
BufferRange vertexDataRange = _vacContext.GetVertexDataBufferRange(_vertexDataOffset, _vertexDataSize, write: true);
|
BufferRange vertexDataRange = _vacContext.GetVertexDataBufferRange(_vertexDataOffset, _vertexDataSize, write: true);
|
||||||
_context.Renderer.Pipeline.SetStorageBuffers(stackalloc[] { new BufferAssignment(vertexDataBinding, vertexDataRange) });
|
_context.Renderer.Pipeline.SetStorageBuffers([new BufferAssignment(vertexDataBinding, vertexDataRange)]);
|
||||||
|
|
||||||
_vacContext.VertexInfoBufferUpdater.Commit();
|
_vacContext.VertexInfoBufferUpdater.Commit();
|
||||||
|
|
||||||
@@ -232,7 +228,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
|
|||||||
|
|
||||||
int vertexInfoBinding = _vertexAsCompute.Reservations.VertexInfoConstantBufferBinding;
|
int vertexInfoBinding = _vertexAsCompute.Reservations.VertexInfoConstantBufferBinding;
|
||||||
BufferRange vertexInfoRange = new(_vacContext.VertexInfoBufferUpdater.Handle, 0, VertexInfoBuffer.RequiredSize);
|
BufferRange vertexInfoRange = new(_vacContext.VertexInfoBufferUpdater.Handle, 0, VertexInfoBuffer.RequiredSize);
|
||||||
_context.Renderer.Pipeline.SetUniformBuffers(stackalloc[] { new BufferAssignment(vertexInfoBinding, vertexInfoRange) });
|
_context.Renderer.Pipeline.SetUniformBuffers([new BufferAssignment(vertexInfoBinding, vertexInfoRange)]);
|
||||||
|
|
||||||
int vertexDataBinding = _vertexAsCompute.Reservations.VertexOutputStorageBufferBinding;
|
int vertexDataBinding = _vertexAsCompute.Reservations.VertexOutputStorageBufferBinding;
|
||||||
|
|
||||||
@@ -250,12 +246,11 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
|
|||||||
BufferRange vertexBuffer = _vacContext.GetGeometryVertexDataBufferRange(_geometryVertexDataOffset, _geometryVertexDataSize, write: true);
|
BufferRange vertexBuffer = _vacContext.GetGeometryVertexDataBufferRange(_geometryVertexDataOffset, _geometryVertexDataSize, write: true);
|
||||||
BufferRange indexBuffer = _vacContext.GetGeometryIndexDataBufferRange(_geometryIndexDataOffset, _geometryIndexDataSize, write: true);
|
BufferRange indexBuffer = _vacContext.GetGeometryIndexDataBufferRange(_geometryIndexDataOffset, _geometryIndexDataSize, write: true);
|
||||||
|
|
||||||
_context.Renderer.Pipeline.SetStorageBuffers(stackalloc[]
|
_context.Renderer.Pipeline.SetStorageBuffers([
|
||||||
{
|
|
||||||
new BufferAssignment(vertexDataBinding, vertexDataRange),
|
new BufferAssignment(vertexDataBinding, vertexDataRange),
|
||||||
new BufferAssignment(geometryVbBinding, vertexBuffer),
|
new BufferAssignment(geometryVbBinding, vertexBuffer),
|
||||||
new BufferAssignment(geometryIbBinding, indexBuffer),
|
new BufferAssignment(geometryIbBinding, indexBuffer)
|
||||||
});
|
]);
|
||||||
|
|
||||||
_context.Renderer.Pipeline.DispatchCompute(
|
_context.Renderer.Pipeline.DispatchCompute(
|
||||||
BitUtils.DivRoundUp(primitivesCount, ComputeLocalSize),
|
BitUtils.DivRoundUp(primitivesCount, ComputeLocalSize),
|
||||||
@@ -299,7 +294,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
|
|||||||
|
|
||||||
_context.Renderer.Pipeline.SetProgram(_vertexPassthroughProgram);
|
_context.Renderer.Pipeline.SetProgram(_vertexPassthroughProgram);
|
||||||
_context.Renderer.Pipeline.SetIndexBuffer(indexBuffer, IndexType.UInt);
|
_context.Renderer.Pipeline.SetIndexBuffer(indexBuffer, IndexType.UInt);
|
||||||
_context.Renderer.Pipeline.SetStorageBuffers(stackalloc[] { new BufferAssignment(vertexDataBinding, vertexBuffer) });
|
_context.Renderer.Pipeline.SetStorageBuffers([new BufferAssignment(vertexDataBinding, vertexBuffer)]);
|
||||||
|
|
||||||
_context.Renderer.Pipeline.SetPrimitiveRestart(true, -1);
|
_context.Renderer.Pipeline.SetPrimitiveRestart(true, -1);
|
||||||
_context.Renderer.Pipeline.SetPrimitiveTopology(GetGeometryOutputTopology(_geometryAsCompute.Info.GeometryVerticesPerPrimitive));
|
_context.Renderer.Pipeline.SetPrimitiveTopology(GetGeometryOutputTopology(_geometryAsCompute.Info.GeometryVerticesPerPrimitive));
|
||||||
@@ -314,7 +309,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
|
|||||||
BufferRange vertexDataRange = _vacContext.GetVertexDataBufferRange(_vertexDataOffset, _vertexDataSize, write: false);
|
BufferRange vertexDataRange = _vacContext.GetVertexDataBufferRange(_vertexDataOffset, _vertexDataSize, write: false);
|
||||||
|
|
||||||
_context.Renderer.Pipeline.SetProgram(_vertexPassthroughProgram);
|
_context.Renderer.Pipeline.SetProgram(_vertexPassthroughProgram);
|
||||||
_context.Renderer.Pipeline.SetStorageBuffers(stackalloc[] { new BufferAssignment(vertexDataBinding, vertexDataRange) });
|
_context.Renderer.Pipeline.SetStorageBuffers([new BufferAssignment(vertexDataBinding, vertexDataRange)]);
|
||||||
_context.Renderer.Pipeline.Draw(_count, _instanceCount, 0, 0);
|
_context.Renderer.Pipeline.Draw(_count, _instanceCount, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -345,20 +340,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
|
|||||||
return maxOutputVertices / verticesPerPrimitive;
|
return maxOutputVertices / verticesPerPrimitive;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Binds a dummy buffer as vertex buffer into a buffer texture.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="reservations">Shader resource binding reservations</param>
|
|
||||||
/// <param name="index">Buffer texture index</param>
|
|
||||||
/// <param name="format">Buffer texture format</param>
|
|
||||||
private readonly void SetDummyBufferTexture(ResourceReservations reservations, int index, Format format)
|
|
||||||
{
|
|
||||||
ITexture bufferTexture = _vacContext.EnsureBufferTexture(index + 2, format);
|
|
||||||
bufferTexture.SetStorage(_vacContext.GetDummyBufferRange());
|
|
||||||
|
|
||||||
_context.Renderer.Pipeline.SetTextureAndSampler(ShaderStage.Compute, reservations.GetVertexBufferTextureBinding(index), bufferTexture, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Binds a vertex buffer into a buffer texture.
|
/// Binds a vertex buffer into a buffer texture.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -371,7 +352,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
|
|||||||
{
|
{
|
||||||
MemoryManager memoryManager = _channel.MemoryManager;
|
MemoryManager memoryManager = _channel.MemoryManager;
|
||||||
|
|
||||||
BufferRange range = memoryManager.GetBackingMemory(address).BufferCache.GetBufferRange(memoryManager.GetPhysicalRegions(address, size), BufferStage.VertexBuffer);
|
BufferRange range = memoryManager.Physical.BufferCache.GetBufferRange(memoryManager.GetPhysicalRegions(address, size), BufferStage.VertexBuffer);
|
||||||
|
|
||||||
ITexture bufferTexture = _vacContext.EnsureBufferTexture(index + 2, format);
|
ITexture bufferTexture = _vacContext.EnsureBufferTexture(index + 2, format);
|
||||||
bufferTexture.SetStorage(range);
|
bufferTexture.SetStorage(range);
|
||||||
@@ -413,7 +394,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed.ComputeDraw
|
|||||||
MemoryManager 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.Physical.BufferCache.GetBufferRange(
|
||||||
memoryManager.GetPhysicalRegions(address + indexOffset - misalign, size + misalign),
|
memoryManager.GetPhysicalRegions(address + indexOffset - misalign, size + misalign),
|
||||||
BufferStage.IndexBuffer);
|
BufferStage.IndexBuffer);
|
||||||
misalignedOffset = (int)misalign >> shift;
|
misalignedOffset = (int)misalign >> shift;
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||||||
|
|
||||||
// State associated with direct uniform buffer updates.
|
// State associated with direct uniform buffer updates.
|
||||||
// This state is used to attempt to batch together consecutive updates.
|
// This state is used to attempt to batch together consecutive updates.
|
||||||
private ulong _ubBeginGpuAddress = 0;
|
|
||||||
private ulong _ubBeginCpuAddress = 0;
|
private ulong _ubBeginCpuAddress = 0;
|
||||||
private ulong _ubFollowUpAddress = 0;
|
private ulong _ubFollowUpAddress = 0;
|
||||||
private ulong _ubByteCount = 0;
|
private ulong _ubByteCount = 0;
|
||||||
@@ -114,13 +113,12 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||||||
if (_ubFollowUpAddress != 0)
|
if (_ubFollowUpAddress != 0)
|
||||||
{
|
{
|
||||||
MemoryManager memoryManager = _channel.MemoryManager;
|
MemoryManager memoryManager = _channel.MemoryManager;
|
||||||
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)));
|
||||||
|
|
||||||
if (physicalMemory.WriteWithRedundancyCheck(_ubBeginCpuAddress, data))
|
if (memoryManager.Physical.WriteWithRedundancyCheck(_ubBeginCpuAddress, data))
|
||||||
{
|
{
|
||||||
physicalMemory.BufferCache.ForceDirty(memoryManager, _ubFollowUpAddress - _ubByteCount, _ubByteCount);
|
memoryManager.Physical.BufferCache.ForceDirty(memoryManager, _ubFollowUpAddress - _ubByteCount, _ubByteCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
_ubFollowUpAddress = 0;
|
_ubFollowUpAddress = 0;
|
||||||
|
|||||||
@@ -641,8 +641,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||||||
public void DrawIndirect(
|
public void DrawIndirect(
|
||||||
ThreedClass engine,
|
ThreedClass engine,
|
||||||
PrimitiveTopology topology,
|
PrimitiveTopology topology,
|
||||||
BufferCache indirectBufferCache,
|
|
||||||
BufferCache parameterBufferCache,
|
|
||||||
MultiRange indirectBufferRange,
|
MultiRange indirectBufferRange,
|
||||||
MultiRange parameterBufferRange,
|
MultiRange parameterBufferRange,
|
||||||
int maxDrawCount,
|
int maxDrawCount,
|
||||||
@@ -664,6 +662,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PhysicalMemory memory = _channel.MemoryManager.Physical;
|
||||||
|
|
||||||
bool hasCount = (drawType & IndirectDrawType.Count) != 0;
|
bool hasCount = (drawType & IndirectDrawType.Count) != 0;
|
||||||
bool indexed = (drawType & IndirectDrawType.Indexed) != 0;
|
bool indexed = (drawType & IndirectDrawType.Indexed) != 0;
|
||||||
|
|
||||||
@@ -684,8 +684,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||||||
|
|
||||||
if (hasCount)
|
if (hasCount)
|
||||||
{
|
{
|
||||||
BufferRange indirectBuffer = indirectBufferCache.GetBufferRange(indirectBufferRange, BufferStage.Indirect);
|
BufferRange indirectBuffer = memory.BufferCache.GetBufferRange(indirectBufferRange, BufferStage.Indirect);
|
||||||
BufferRange parameterBuffer = parameterBufferCache.GetBufferRange(parameterBufferRange, BufferStage.Indirect);
|
BufferRange parameterBuffer = memory.BufferCache.GetBufferRange(parameterBufferRange, BufferStage.Indirect);
|
||||||
|
|
||||||
if (indexed)
|
if (indexed)
|
||||||
{
|
{
|
||||||
@@ -698,7 +698,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BufferRange indirectBuffer = indirectBufferCache.GetBufferRange(indirectBufferRange, BufferStage.Indirect);
|
BufferRange indirectBuffer = memory.BufferCache.GetBufferRange(indirectBufferRange, BufferStage.Indirect);
|
||||||
|
|
||||||
if (indexed)
|
if (indexed)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -381,10 +381,10 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||||||
{
|
{
|
||||||
BufferDescriptor sb = info.SBuffers[index];
|
BufferDescriptor sb = info.SBuffers[index];
|
||||||
|
|
||||||
(PhysicalMemory physical, ulong sbDescAddress) = _channel.BufferManager.GetGraphicsUniformBufferAddress(stage, sb.SbCbSlot);
|
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 = _channel.MemoryManager.Physical.Read<SbDescriptor>(sbDescAddress);
|
||||||
|
|
||||||
uint size;
|
uint size;
|
||||||
if (sb.SbCbSlot == Constants.DriverReservedUniformBuffer)
|
if (sb.SbCbSlot == Constants.DriverReservedUniformBuffer)
|
||||||
@@ -505,9 +505,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||||||
rtNoAlphaMask |= 1u << index;
|
rtNoAlphaMask |= 1u << index;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCache colorTextureCache = memoryManager.GetBackingMemory(colorState.Address.Pack()).TextureCache;
|
Image.Texture color = memoryManager.Physical.TextureCache.FindOrCreateTexture(
|
||||||
|
|
||||||
Image.Texture color = colorTextureCache.FindOrCreateTexture(
|
|
||||||
memoryManager,
|
memoryManager,
|
||||||
colorState,
|
colorState,
|
||||||
_vtgWritesRtLayer || layered,
|
_vtgWritesRtLayer || layered,
|
||||||
@@ -515,7 +513,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||||||
samplesInX,
|
samplesInX,
|
||||||
samplesInY,
|
samplesInY,
|
||||||
sizeHint);
|
sizeHint);
|
||||||
|
|
||||||
changedScale |= _channel.TextureManager.SetRenderTargetColor(index, color);
|
changedScale |= _channel.TextureManager.SetRenderTargetColor(index, color);
|
||||||
|
|
||||||
if (color != null)
|
if (color != null)
|
||||||
@@ -545,9 +543,8 @@ 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;
|
||||||
TextureCache dsTextureCache = memoryManager.GetBackingMemory(dsState.Address.Pack()).TextureCache;
|
|
||||||
|
depthStencil = memoryManager.Physical.TextureCache.FindOrCreateTexture(
|
||||||
depthStencil = dsTextureCache.FindOrCreateTexture(
|
|
||||||
memoryManager,
|
memoryManager,
|
||||||
dsState,
|
dsState,
|
||||||
dsSize,
|
dsSize,
|
||||||
@@ -1412,6 +1409,8 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void UpdateShaderState()
|
private void UpdateShaderState()
|
||||||
{
|
{
|
||||||
|
ShaderCache shaderCache = _channel.MemoryManager.Physical.ShaderCache;
|
||||||
|
|
||||||
_vtgWritesRtLayer = false;
|
_vtgWritesRtLayer = false;
|
||||||
|
|
||||||
ShaderAddresses addresses = new();
|
ShaderAddresses addresses = new();
|
||||||
@@ -1434,9 +1433,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||||||
? _state.State.TexturePoolState.MaximumId
|
? _state.State.TexturePoolState.MaximumId
|
||||||
: _state.State.SamplerPoolState.MaximumId;
|
: _state.State.SamplerPoolState.MaximumId;
|
||||||
|
|
||||||
// Shader stages on different address spaces are not supported right now,
|
|
||||||
// but it should never happen in practice anyway.
|
|
||||||
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,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ using Ryujinx.Graphics.Gpu.Engine.GPFifo;
|
|||||||
using Ryujinx.Graphics.Gpu.Engine.InlineToMemory;
|
using Ryujinx.Graphics.Gpu.Engine.InlineToMemory;
|
||||||
using Ryujinx.Graphics.Gpu.Engine.Threed.Blender;
|
using Ryujinx.Graphics.Gpu.Engine.Threed.Blender;
|
||||||
using Ryujinx.Graphics.Gpu.Engine.Types;
|
using Ryujinx.Graphics.Gpu.Engine.Types;
|
||||||
using Ryujinx.Graphics.Gpu.Memory;
|
|
||||||
using Ryujinx.Graphics.Gpu.Synchronization;
|
using Ryujinx.Graphics.Gpu.Synchronization;
|
||||||
using Ryujinx.Memory.Range;
|
using Ryujinx.Memory.Range;
|
||||||
using System;
|
using System;
|
||||||
@@ -805,8 +804,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||||||
/// Performs a indirect draw, with parameters from a GPU buffer.
|
/// Performs a indirect draw, with parameters from a GPU buffer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="topology">Primitive topology</param>
|
/// <param name="topology">Primitive topology</param>
|
||||||
/// <param name="indirectBufferCache">Buffer cache owning the buffer with the draw parameters</param>
|
|
||||||
/// <param name="parameterBufferCache">Buffer cache owning the buffer with the draw count</param>
|
|
||||||
/// <param name="indirectBufferRange">Memory range of the buffer with the draw parameters, such as count, first index, etc</param>
|
/// <param name="indirectBufferRange">Memory range of the buffer with the draw parameters, such as count, first index, etc</param>
|
||||||
/// <param name="parameterBufferRange">Memory range of the buffer with the draw count</param>
|
/// <param name="parameterBufferRange">Memory range of the buffer with the draw count</param>
|
||||||
/// <param name="maxDrawCount">Maximum number of draws that can be made</param>
|
/// <param name="maxDrawCount">Maximum number of draws that can be made</param>
|
||||||
@@ -815,8 +812,6 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||||||
/// <param name="drawType">Type of the indirect draw, which can be indexed or non-indexed, with or without a draw count</param>
|
/// <param name="drawType">Type of the indirect draw, which can be indexed or non-indexed, with or without a draw count</param>
|
||||||
public void DrawIndirect(
|
public void DrawIndirect(
|
||||||
PrimitiveTopology topology,
|
PrimitiveTopology topology,
|
||||||
BufferCache indirectBufferCache,
|
|
||||||
BufferCache parameterBufferCache,
|
|
||||||
MultiRange indirectBufferRange,
|
MultiRange indirectBufferRange,
|
||||||
MultiRange parameterBufferRange,
|
MultiRange parameterBufferRange,
|
||||||
int maxDrawCount,
|
int maxDrawCount,
|
||||||
@@ -824,7 +819,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
|||||||
int indexCount,
|
int indexCount,
|
||||||
IndirectDrawType drawType)
|
IndirectDrawType drawType)
|
||||||
{
|
{
|
||||||
_drawManager.DrawIndirect(this, topology, indirectBufferCache, parameterBufferCache, indirectBufferRange, parameterBufferRange, maxDrawCount, stride, indexCount, drawType);
|
_drawManager.DrawIndirect(this, topology, indirectBufferRange, parameterBufferRange, maxDrawCount, stride, indexCount, drawType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -233,9 +233,6 @@ 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);
|
||||||
|
|
||||||
TextureCache srcTextureCache = memoryManager.GetBackingMemory(srcCopyTexture.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;
|
||||||
@@ -308,7 +305,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
|
|||||||
// are the same, as we can't blit between different depth formats.
|
// are the same, as we can't blit between different depth formats.
|
||||||
bool srcDepthAlias = srcCopyTexture.Format == dstCopyTexture.Format;
|
bool srcDepthAlias = srcCopyTexture.Format == dstCopyTexture.Format;
|
||||||
|
|
||||||
Image.Texture srcTexture = srcTextureCache.FindOrCreateTexture(
|
Image.Texture srcTexture = memoryManager.Physical.TextureCache.FindOrCreateTexture(
|
||||||
memoryManager,
|
memoryManager,
|
||||||
srcCopyTexture,
|
srcCopyTexture,
|
||||||
offset,
|
offset,
|
||||||
@@ -329,7 +326,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
srcTextureCache.Lift(srcTexture);
|
memoryManager.Physical.TextureCache.Lift(srcTexture);
|
||||||
|
|
||||||
// When the source texture that was found has a depth format,
|
// When the source texture that was found has a depth format,
|
||||||
// we must enforce the target texture also has a depth format,
|
// we must enforce the target texture also has a depth format,
|
||||||
@@ -345,7 +342,7 @@ namespace Ryujinx.Graphics.Gpu.Engine.Twod
|
|||||||
dstCopyTextureFormat = dstCopyTexture.Format.Convert();
|
dstCopyTextureFormat = dstCopyTexture.Format.Convert();
|
||||||
}
|
}
|
||||||
|
|
||||||
Image.Texture dstTexture = dstTextureCache.FindOrCreateTexture(
|
Image.Texture dstTexture = memoryManager.Physical.TextureCache.FindOrCreateTexture(
|
||||||
memoryManager,
|
memoryManager,
|
||||||
dstCopyTexture,
|
dstCopyTexture,
|
||||||
0,
|
0,
|
||||||
|
|||||||
@@ -58,24 +58,22 @@ namespace Ryujinx.Graphics.Gpu
|
|||||||
public void BindMemory(MemoryManager memoryManager)
|
public void BindMemory(MemoryManager memoryManager)
|
||||||
{
|
{
|
||||||
MemoryManager oldMemoryManager = Interlocked.Exchange(ref _memoryManager, memoryManager ?? throw new ArgumentNullException(nameof(memoryManager)));
|
MemoryManager oldMemoryManager = Interlocked.Exchange(ref _memoryManager, memoryManager ?? throw new ArgumentNullException(nameof(memoryManager)));
|
||||||
if (oldMemoryManager == memoryManager)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
memoryManager.AttachToChannel(BufferManager.Rebind);
|
memoryManager.Physical.IncrementReferenceCount();
|
||||||
|
|
||||||
if (oldMemoryManager != null)
|
if (oldMemoryManager != null)
|
||||||
{
|
{
|
||||||
oldMemoryManager.DetachFromChannel(BufferManager.Rebind);
|
oldMemoryManager.Physical.BufferCache.NotifyBuffersModified -= BufferManager.Rebind;
|
||||||
|
oldMemoryManager.Physical.DecrementReferenceCount();
|
||||||
oldMemoryManager.MemoryUnmapped -= MemoryUnmappedHandler;
|
oldMemoryManager.MemoryUnmapped -= MemoryUnmappedHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memoryManager.Physical.BufferCache.NotifyBuffersModified += BufferManager.Rebind;
|
||||||
memoryManager.MemoryUnmapped += MemoryUnmappedHandler;
|
memoryManager.MemoryUnmapped += MemoryUnmappedHandler;
|
||||||
|
|
||||||
// Since the memory manager changed, make sure we will get pools from addresses of the new memory manager.
|
// Since the memory manager changed, make sure we will get pools from addresses of the new memory manager.
|
||||||
TextureManager.ReloadPools();
|
TextureManager.ReloadPools();
|
||||||
memoryManager.QueuePrune();
|
memoryManager.Physical.BufferCache.QueuePrune();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -88,7 +86,7 @@ namespace Ryujinx.Graphics.Gpu
|
|||||||
TextureManager.ReloadPools();
|
TextureManager.ReloadPools();
|
||||||
|
|
||||||
MemoryManager memoryManager = Volatile.Read(ref _memoryManager);
|
MemoryManager memoryManager = Volatile.Read(ref _memoryManager);
|
||||||
memoryManager?.QueuePrune();
|
memoryManager?.Physical.BufferCache.QueuePrune();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -143,7 +141,8 @@ namespace Ryujinx.Graphics.Gpu
|
|||||||
MemoryManager oldMemoryManager = Interlocked.Exchange(ref _memoryManager, null);
|
MemoryManager oldMemoryManager = Interlocked.Exchange(ref _memoryManager, null);
|
||||||
if (oldMemoryManager != null)
|
if (oldMemoryManager != null)
|
||||||
{
|
{
|
||||||
oldMemoryManager.DetachFromChannel(BufferManager.Rebind);
|
oldMemoryManager.Physical.BufferCache.NotifyBuffersModified -= BufferManager.Rebind;
|
||||||
|
oldMemoryManager.Physical.DecrementReferenceCount();
|
||||||
oldMemoryManager.MemoryUnmapped -= MemoryUnmappedHandler;
|
oldMemoryManager.MemoryUnmapped -= MemoryUnmappedHandler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ using Ryujinx.Graphics.Gpu.Engine.GPFifo;
|
|||||||
using Ryujinx.Graphics.Gpu.Memory;
|
using Ryujinx.Graphics.Gpu.Memory;
|
||||||
using Ryujinx.Graphics.Gpu.Shader;
|
using Ryujinx.Graphics.Gpu.Shader;
|
||||||
using Ryujinx.Graphics.Gpu.Synchronization;
|
using Ryujinx.Graphics.Gpu.Synchronization;
|
||||||
using Ryujinx.Memory;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -173,7 +172,7 @@ namespace Ryujinx.Graphics.Gpu
|
|||||||
throw new ArgumentException("The PID is invalid or the process was not registered", nameof(pid));
|
throw new ArgumentException("The PID is invalid or the process was not registered", nameof(pid));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new MemoryManager(this, physicalMemory, cpuMemorySize);
|
return new MemoryManager(physicalMemory, cpuMemorySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -198,7 +197,7 @@ namespace Ryujinx.Graphics.Gpu
|
|||||||
/// <param name="pid">ID of the process that owns <paramref name="cpuMemory"/></param>
|
/// <param name="pid">ID of the process that owns <paramref name="cpuMemory"/></param>
|
||||||
/// <param name="cpuMemory">Virtual memory owned by the process</param>
|
/// <param name="cpuMemory">Virtual memory owned by the process</param>
|
||||||
/// <exception cref="ArgumentException">Thrown if <paramref name="pid"/> was already registered</exception>
|
/// <exception cref="ArgumentException">Thrown if <paramref name="pid"/> was already registered</exception>
|
||||||
public void RegisterProcess(ulong pid, IVirtualMemoryManagerTracked cpuMemory)
|
public void RegisterProcess(ulong pid, Cpu.IVirtualMemoryManagerTracked cpuMemory)
|
||||||
{
|
{
|
||||||
PhysicalMemory physicalMemory = new(this, cpuMemory);
|
PhysicalMemory physicalMemory = new(this, cpuMemory);
|
||||||
if (!PhysicalMemoryRegistry.TryAdd(pid, physicalMemory))
|
if (!PhysicalMemoryRegistry.TryAdd(pid, physicalMemory))
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using Ryujinx.Graphics.Gpu.Memory;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
@@ -65,7 +64,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
/// <param name="maximumId">Maximum ID of the texture pool</param>
|
/// <param name="maximumId">Maximum ID of the texture pool</param>
|
||||||
/// <param name="bindingsArrayCache">Cache of texture array bindings</param>
|
/// <param name="bindingsArrayCache">Cache of texture array bindings</param>
|
||||||
/// <returns>The found or newly created texture pool</returns>
|
/// <returns>The found or newly created texture pool</returns>
|
||||||
public T FindOrCreate(GpuChannel channel, PhysicalMemory physicalMemory, ulong address, int maximumId, TextureBindingsArrayCache bindingsArrayCache)
|
public T FindOrCreate(GpuChannel channel, ulong address, int maximumId, TextureBindingsArrayCache bindingsArrayCache)
|
||||||
{
|
{
|
||||||
// Remove old entries from the cache, if possible.
|
// Remove old entries from the cache, if possible.
|
||||||
while (_pools.Count > MaxCapacity && (_currentTimestamp - _pools.First.Value.CacheTimestamp) >= MinDeltaForRemoval)
|
while (_pools.Count > MaxCapacity && (_currentTimestamp - _pools.First.Value.CacheTimestamp) >= MinDeltaForRemoval)
|
||||||
@@ -100,7 +99,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If not found, create a new one.
|
// If not found, create a new one.
|
||||||
pool = CreatePool(_context, channel, physicalMemory, address, maximumId);
|
pool = CreatePool(_context, channel, address, maximumId);
|
||||||
|
|
||||||
pool.CacheNode = _pools.AddLast(pool);
|
pool.CacheNode = _pools.AddLast(pool);
|
||||||
pool.CacheTimestamp = _currentTimestamp;
|
pool.CacheTimestamp = _currentTimestamp;
|
||||||
@@ -113,10 +112,9 @@ 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 physicalMemory, ulong address, int maximumId);
|
protected abstract T CreatePool(GpuContext context, GpuChannel channel, ulong address, int maximumId);
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
using Ryujinx.Graphics.Gpu.Memory;
|
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.Image
|
namespace Ryujinx.Graphics.Gpu.Image
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -22,12 +20,11 @@ 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, ulong address, int maximumId)
|
||||||
{
|
{
|
||||||
return new SamplerPool(context, physicalMemory, address, maximumId);
|
return new SamplerPool(context, channel.MemoryManager.Physical, address, maximumId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -660,7 +660,6 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
|
|
||||||
ISampler[] samplers = isImage ? null : new ISampler[bindingInfo.ArrayLength];
|
ISampler[] samplers = isImage ? null : new ISampler[bindingInfo.ArrayLength];
|
||||||
ITexture[] textures = new ITexture[bindingInfo.ArrayLength];
|
ITexture[] textures = new ITexture[bindingInfo.ArrayLength];
|
||||||
BufferCache bufferCache = null;
|
|
||||||
|
|
||||||
for (int index = 0; index < length; index++)
|
for (int index = 0; index < length; index++)
|
||||||
{
|
{
|
||||||
@@ -674,7 +673,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ref readonly TextureDescriptor descriptor = ref texturePool.GetForBinding(index, bindingInfo.FormatInfo, out texture);
|
ref readonly TextureDescriptor descriptor = ref texturePool.GetForBinding(index, bindingInfo.FormatInfo, out texture);
|
||||||
bufferCache = _channel.MemoryManager.GetBackingMemory(descriptor.UnpackAddress()).BufferCache;
|
|
||||||
if (texture != null)
|
if (texture != null)
|
||||||
{
|
{
|
||||||
entry.Textures[texture] = texture.InvalidatedSequence;
|
entry.Textures[texture] = texture.InvalidatedSequence;
|
||||||
@@ -703,10 +702,11 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
// 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.
|
||||||
if (isImage)
|
if (isImage)
|
||||||
{
|
{
|
||||||
_channel.BufferManager.SetBufferTextureStorage(stage, entry.ImageArray, hostTexture, bufferCache, texture.Range, bindingInfo, index); }
|
_channel.BufferManager.SetBufferTextureStorage(stage, entry.ImageArray, hostTexture, texture.Range, bindingInfo, index);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_channel.BufferManager.SetBufferTextureStorage(stage, entry.TextureArray, hostTexture, bufferCache, texture.Range, bindingInfo, index);
|
_channel.BufferManager.SetBufferTextureStorage(stage, entry.TextureArray, hostTexture, texture.Range, bindingInfo, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isImage)
|
else if (isImage)
|
||||||
@@ -797,11 +797,11 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cachedTextureBuffer = MemoryMarshal.Cast<byte, int>(textureBufferBounds.Physical.GetSpan(textureBufferBounds.Range));
|
cachedTextureBuffer = MemoryMarshal.Cast<byte, int>(_channel.MemoryManager.Physical.GetSpan(textureBufferBounds.Range));
|
||||||
|
|
||||||
if (separateSamplerBuffer)
|
if (separateSamplerBuffer)
|
||||||
{
|
{
|
||||||
cachedSamplerBuffer = MemoryMarshal.Cast<byte, int>(samplerBufferBounds.Physical.GetSpan(samplerBufferBounds.Range));
|
cachedSamplerBuffer = MemoryMarshal.Cast<byte, int>(_channel.MemoryManager.Physical.GetSpan(samplerBufferBounds.Range));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -828,10 +828,11 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cachedTextureBuffer = MemoryMarshal.Cast<byte, int>(textureBufferBounds.Physical.GetSpan(textureBufferBounds.Range));
|
cachedTextureBuffer = MemoryMarshal.Cast<byte, int>(_channel.MemoryManager.Physical.GetSpan(textureBufferBounds.Range));
|
||||||
|
|
||||||
if (separateSamplerBuffer)
|
if (separateSamplerBuffer)
|
||||||
{
|
{
|
||||||
cachedSamplerBuffer = MemoryMarshal.Cast<byte, int>(samplerBufferBounds.Physical.GetSpan(samplerBufferBounds.Range));
|
cachedSamplerBuffer = MemoryMarshal.Cast<byte, int>(_channel.MemoryManager.Physical.GetSpan(samplerBufferBounds.Range));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -900,18 +901,16 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
|
|
||||||
if (hostTexture != null && texture.Target == Target.TextureBuffer)
|
if (hostTexture != null && texture.Target == Target.TextureBuffer)
|
||||||
{
|
{
|
||||||
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
|
||||||
// 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.
|
||||||
if (isImage)
|
if (isImage)
|
||||||
{
|
{
|
||||||
_channel.BufferManager.SetBufferTextureStorage(stage, entry.ImageArray, hostTexture, bufferCache, texture.Range, bindingInfo, index);
|
_channel.BufferManager.SetBufferTextureStorage(stage, entry.ImageArray, hostTexture, texture.Range, bindingInfo, index);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_channel.BufferManager.SetBufferTextureStorage(stage, entry.TextureArray, hostTexture, bufferCache, texture.Range, bindingInfo, index);
|
_channel.BufferManager.SetBufferTextureStorage(stage, entry.TextureArray, hostTexture, texture.Range, bindingInfo, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isImage)
|
else if (isImage)
|
||||||
|
|||||||
@@ -396,7 +396,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
{
|
{
|
||||||
ref BufferBounds bounds = ref _channel.BufferManager.GetUniformBufferBounds(_isCompute, stageIndex, textureBufferIndex);
|
ref BufferBounds bounds = ref _channel.BufferManager.GetUniformBufferBounds(_isCompute, stageIndex, textureBufferIndex);
|
||||||
|
|
||||||
cachedTextureBuffer = MemoryMarshal.Cast<byte, int>(bounds.Physical.GetSpan(bounds.Range));
|
cachedTextureBuffer = MemoryMarshal.Cast<byte, int>(_channel.MemoryManager.Physical.GetSpan(bounds.Range));
|
||||||
cachedTextureBufferIndex = textureBufferIndex;
|
cachedTextureBufferIndex = textureBufferIndex;
|
||||||
|
|
||||||
if (samplerBufferIndex == textureBufferIndex)
|
if (samplerBufferIndex == textureBufferIndex)
|
||||||
@@ -410,7 +410,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
{
|
{
|
||||||
ref BufferBounds bounds = ref _channel.BufferManager.GetUniformBufferBounds(_isCompute, stageIndex, samplerBufferIndex);
|
ref BufferBounds bounds = ref _channel.BufferManager.GetUniformBufferBounds(_isCompute, stageIndex, samplerBufferIndex);
|
||||||
|
|
||||||
cachedSamplerBuffer = MemoryMarshal.Cast<byte, int>(bounds.Physical.GetSpan(bounds.Range));
|
cachedSamplerBuffer = MemoryMarshal.Cast<byte, int>(_channel.MemoryManager.Physical.GetSpan(bounds.Range));
|
||||||
cachedSamplerBufferIndex = samplerBufferIndex;
|
cachedSamplerBufferIndex = samplerBufferIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -524,8 +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.
|
||||||
BufferCache bufferCache = _channel.MemoryManager.GetBackingMemory(descriptor.UnpackAddress()).BufferCache;
|
_channel.BufferManager.SetBufferTextureStorage(stage, hostTexture, 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.
|
||||||
state.CachedTexture = null;
|
state.CachedTexture = null;
|
||||||
@@ -660,8 +659,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.
|
||||||
|
|
||||||
BufferCache bufferCache = _channel.MemoryManager.GetBackingMemory(descriptor.UnpackAddress()).BufferCache;
|
_channel.BufferManager.SetBufferTextureStorage(stage, hostTexture, 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.
|
||||||
state.CachedTexture = null;
|
state.CachedTexture = null;
|
||||||
@@ -717,10 +715,9 @@ 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);
|
||||||
|
|
||||||
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, poolAddress, maximumId, _bindingsArrayCache);
|
||||||
|
|
||||||
TextureDescriptor descriptor;
|
TextureDescriptor descriptor;
|
||||||
|
|
||||||
@@ -754,12 +751,12 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
{
|
{
|
||||||
(int textureWordOffset, int samplerWordOffset, TextureHandleType handleType) = TextureHandle.UnpackOffsets(wordOffset);
|
(int textureWordOffset, int samplerWordOffset, TextureHandleType handleType) = TextureHandle.UnpackOffsets(wordOffset);
|
||||||
|
|
||||||
(PhysicalMemory texturePhysicalMemory, ulong textureBufferAddress) = _isCompute
|
ulong textureBufferAddress = _isCompute
|
||||||
? _channel.BufferManager.GetComputeUniformBufferAddress(textureBufferIndex)
|
? _channel.BufferManager.GetComputeUniformBufferAddress(textureBufferIndex)
|
||||||
: _channel.BufferManager.GetGraphicsUniformBufferAddress(stageIndex, textureBufferIndex);
|
: _channel.BufferManager.GetGraphicsUniformBufferAddress(stageIndex, textureBufferIndex);
|
||||||
|
|
||||||
int handle = textureBufferAddress != MemoryManager.PteUnmapped
|
int handle = textureBufferAddress != MemoryManager.PteUnmapped
|
||||||
? texturePhysicalMemory.Read<int>(textureBufferAddress + (uint)textureWordOffset * 4)
|
? _channel.MemoryManager.Physical.Read<int>(textureBufferAddress + (uint)textureWordOffset * 4)
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
// The "wordOffset" (which is really the immediate value used on texture instructions on the shader)
|
// The "wordOffset" (which is really the immediate value used on texture instructions on the shader)
|
||||||
@@ -774,12 +771,12 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
|
|
||||||
if (handleType != TextureHandleType.SeparateConstantSamplerHandle)
|
if (handleType != TextureHandleType.SeparateConstantSamplerHandle)
|
||||||
{
|
{
|
||||||
(PhysicalMemory samplerPhysicalMemory, ulong samplerBufferAddress) = _isCompute
|
ulong samplerBufferAddress = _isCompute
|
||||||
? _channel.BufferManager.GetComputeUniformBufferAddress(samplerBufferIndex)
|
? _channel.BufferManager.GetComputeUniformBufferAddress(samplerBufferIndex)
|
||||||
: _channel.BufferManager.GetGraphicsUniformBufferAddress(stageIndex, samplerBufferIndex);
|
: _channel.BufferManager.GetGraphicsUniformBufferAddress(stageIndex, samplerBufferIndex);
|
||||||
|
|
||||||
samplerHandle = samplerBufferAddress != MemoryManager.PteUnmapped
|
samplerHandle = samplerBufferAddress != MemoryManager.PteUnmapped
|
||||||
? samplerPhysicalMemory.Read<int>(samplerBufferAddress + (uint)samplerWordOffset * 4)
|
? _channel.MemoryManager.Physical.Read<int>(samplerBufferAddress + (uint)samplerWordOffset * 4)
|
||||||
: 0;
|
: 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -816,8 +813,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
|
|
||||||
if (poolAddress != MemoryManager.PteUnmapped)
|
if (poolAddress != MemoryManager.PteUnmapped)
|
||||||
{
|
{
|
||||||
PhysicalMemory physical = _channel.MemoryManager.GetBackingMemory(_texturePoolGpuVa);
|
texturePool = _texturePoolCache.FindOrCreate(_channel, poolAddress, _texturePoolMaximumId, _bindingsArrayCache);
|
||||||
texturePool = _texturePoolCache.FindOrCreate(_channel, physical, poolAddress, _texturePoolMaximumId, _bindingsArrayCache);
|
|
||||||
_texturePool = texturePool;
|
_texturePool = texturePool;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -828,8 +824,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
|
|
||||||
if (poolAddress != MemoryManager.PteUnmapped)
|
if (poolAddress != MemoryManager.PteUnmapped)
|
||||||
{
|
{
|
||||||
PhysicalMemory physical = _channel.MemoryManager.GetBackingMemory(_samplerPoolGpuVa);
|
samplerPool = _samplerPoolCache.FindOrCreate(_channel, poolAddress, _samplerPoolMaximumId, _bindingsArrayCache);
|
||||||
samplerPool = _samplerPoolCache.FindOrCreate(_channel, physical, poolAddress, _samplerPoolMaximumId, _bindingsArrayCache);
|
|
||||||
_samplerPool = samplerPool;
|
_samplerPool = samplerPool;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
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;
|
||||||
|
|
||||||
@@ -386,9 +385,8 @@ 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);
|
||||||
PhysicalMemory physical = _channel.MemoryManager.GetBackingMemory(poolAddress);
|
|
||||||
|
|
||||||
TexturePool texturePool = _texturePoolCache.FindOrCreate(_channel, physical, poolAddress, maximumId, _bindingsArrayCache);
|
TexturePool texturePool = _texturePoolCache.FindOrCreate(_channel, poolAddress, maximumId, _bindingsArrayCache);
|
||||||
|
|
||||||
return texturePool;
|
return texturePool;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,10 +160,9 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">GPU context that the texture pool belongs to</param>
|
/// <param name="context">GPU context that the texture 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">Backing memory of the pool</param>
|
|
||||||
/// <param name="address">Address of the texture pool in guest memory</param>
|
/// <param name="address">Address of the texture pool in guest memory</param>
|
||||||
/// <param name="maximumId">Maximum texture ID of the texture pool (equal to maximum textures minus one)</param>
|
/// <param name="maximumId">Maximum texture ID of the texture pool (equal to maximum textures minus one)</param>
|
||||||
public TexturePool(GpuContext context, GpuChannel channel, PhysicalMemory physicalMemory, ulong address, int maximumId) : base(context, physicalMemory, address, maximumId)
|
public TexturePool(GpuContext context, GpuChannel channel, ulong address, int maximumId) : base(context, channel.MemoryManager.Physical, address, maximumId)
|
||||||
{
|
{
|
||||||
_channel = channel;
|
_channel = channel;
|
||||||
_aliasLists = new Dictionary<Texture, TextureAliasList>();
|
_aliasLists = new Dictionary<Texture, TextureAliasList>();
|
||||||
@@ -194,9 +193,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
}
|
}
|
||||||
|
|
||||||
TextureInfo info = GetInfo(descriptor, out int layerSize);
|
TextureInfo info = GetInfo(descriptor, out int layerSize);
|
||||||
MemoryManager memoryManager = _channel.MemoryManager;
|
texture = PhysicalMemory.TextureCache.FindOrCreateTexture(_channel.MemoryManager, TextureSearchFlags.ForSampler, info, layerSize);
|
||||||
TextureCache textureCache = memoryManager.GetBackingMemory(descriptor.UnpackAddress()).TextureCache;
|
|
||||||
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.
|
||||||
if (texture == null)
|
if (texture == null)
|
||||||
@@ -424,8 +421,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureCache textureCache = _channel.MemoryManager.GetBackingMemory(address).TextureCache;
|
MultiRange range = _channel.MemoryManager.Physical.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.
|
||||||
|
|
||||||
@@ -450,7 +446,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
if (!range.Equals(texture.Range))
|
if (!range.Equals(texture.Range))
|
||||||
{
|
{
|
||||||
// Part of the texture was mapped or unmapped. Replace the range and regenerate tracking handles.
|
// Part of the texture was mapped or unmapped. Replace the range and regenerate tracking handles.
|
||||||
if (!textureCache.UpdateMapping(texture, range))
|
if (!_channel.MemoryManager.Physical.TextureCache.UpdateMapping(texture, range))
|
||||||
{
|
{
|
||||||
// Texture could not be remapped due to a collision, just delete it.
|
// Texture could not be remapped due to a collision, just delete it.
|
||||||
if (Interlocked.Exchange(ref Items[request.ID], null) != null)
|
if (Interlocked.Exchange(ref Items[request.ID], null) != null)
|
||||||
@@ -485,7 +481,6 @@ 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)
|
||||||
{
|
{
|
||||||
MemoryManager memoryManager = _channel.MemoryManager;
|
|
||||||
ProcessDereferenceQueue();
|
ProcessDereferenceQueue();
|
||||||
|
|
||||||
ulong endAddress = address + size;
|
ulong endAddress = address + size;
|
||||||
@@ -510,8 +505,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
|
|
||||||
if (texture.HasOneReference())
|
if (texture.HasOneReference())
|
||||||
{
|
{
|
||||||
TextureCache textureCache = memoryManager.GetBackingMemory(descriptor.UnpackAddress()).TextureCache;
|
_channel.MemoryManager.Physical.TextureCache.AddShortCache(texture, ref cachedDescriptor);
|
||||||
textureCache.AddShortCache(texture, ref cachedDescriptor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Interlocked.Exchange(ref Items[id], null) != null)
|
if (Interlocked.Exchange(ref Items[id], null) != null)
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
using Ryujinx.Graphics.Gpu.Memory;
|
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.Image
|
namespace Ryujinx.Graphics.Gpu.Image
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -22,17 +20,11 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">GPU context that the texture pool belongs to</param>
|
/// <param name="context">GPU context that the texture 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">Backing memory of the pool</param>
|
|
||||||
/// <param name="address">Address of the texture pool in guest memory</param>
|
/// <param name="address">Address of the texture pool in guest memory</param>
|
||||||
/// <param name="maximumId">Maximum texture ID of the texture pool (equal to maximum textures minus one)</param>
|
/// <param name="maximumId">Maximum texture ID of the texture pool (equal to maximum textures minus one)</param>
|
||||||
protected override TexturePool CreatePool(
|
protected override TexturePool CreatePool(GpuContext context, GpuChannel channel, ulong address, int maximumId)
|
||||||
GpuContext context,
|
|
||||||
GpuChannel channel,
|
|
||||||
PhysicalMemory physicalMemory,
|
|
||||||
ulong address,
|
|
||||||
int maximumId)
|
|
||||||
{
|
{
|
||||||
return new TexturePool(context, channel, physicalMemory, address, maximumId);
|
return new TexturePool(context, channel, address, maximumId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,16 +9,6 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
readonly struct BufferBounds : IEquatable<BufferBounds>
|
readonly struct BufferBounds : IEquatable<BufferBounds>
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Physical memory backing the buffer.
|
|
||||||
/// </summary>
|
|
||||||
public PhysicalMemory Physical { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Buffer cache that owns the buffer.
|
|
||||||
/// </summary>
|
|
||||||
public BufferCache BufferCache => Physical.BufferCache;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Physical memory ranges where the buffer is mapped.
|
/// Physical memory ranges where the buffer is mapped.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -39,9 +29,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="range">Physical memory ranges where the buffer is mapped</param>
|
/// <param name="range">Physical memory ranges where the buffer is mapped</param>
|
||||||
/// <param name="flags">Buffer usage flags</param>
|
/// <param name="flags">Buffer usage flags</param>
|
||||||
public BufferBounds(PhysicalMemory physical, MultiRange range, BufferUsageFlags flags = BufferUsageFlags.None)
|
public BufferBounds(MultiRange range, BufferUsageFlags flags = BufferUsageFlags.None)
|
||||||
{
|
{
|
||||||
Physical = physical;
|
|
||||||
Range = range;
|
Range = range;
|
||||||
Flags = flags;
|
Flags = flags;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -735,22 +735,18 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// This does a GPU side copy.
|
/// This does a GPU side copy.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="context">GPU context</param>
|
|
||||||
/// <param name="memoryManager">GPU memory manager where the buffer is mapped</param>
|
/// <param name="memoryManager">GPU memory manager where the buffer is mapped</param>
|
||||||
/// <param name="srcVa">GPU virtual address of the copy source</param>
|
/// <param name="srcVa">GPU virtual address of the copy source</param>
|
||||||
/// <param name="dstVa">GPU virtual address of the copy destination</param>
|
/// <param name="dstVa">GPU virtual address of the copy destination</param>
|
||||||
/// <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 void CopyBuffer(MemoryManager memoryManager, ulong srcVa, ulong dstVa, ulong size)
|
||||||
{
|
{
|
||||||
PhysicalMemory srcPhysical = memoryManager.GetBackingMemory(srcVa);
|
MultiRange srcRange = TranslateAndCreateMultiBuffersPhysicalOnly(memoryManager, srcVa, size, BufferStage.Copy);
|
||||||
PhysicalMemory dstPhysical = memoryManager.GetBackingMemory(dstVa);
|
MultiRange dstRange = TranslateAndCreateMultiBuffersPhysicalOnly(memoryManager, dstVa, size, BufferStage.Copy);
|
||||||
|
|
||||||
MultiRange srcRange = srcPhysical.BufferCache.TranslateAndCreateBuffer(memoryManager, srcVa, 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)
|
||||||
{
|
{
|
||||||
CopyBufferSingleRange(context, srcPhysical, dstPhysical, srcRange.GetSubRange(0).Address, dstRange.GetSubRange(0).Address, size);
|
CopyBufferSingleRange(memoryManager, srcRange.GetSubRange(0).Address, dstRange.GetSubRange(0).Address, size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -781,7 +777,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
ulong dstSize = dstSubRange.Size - dstOffset;
|
ulong dstSize = dstSubRange.Size - dstOffset;
|
||||||
ulong copySize = Math.Min(srcSize, dstSize);
|
ulong copySize = Math.Min(srcSize, dstSize);
|
||||||
|
|
||||||
CopyBufferSingleRange(context, srcPhysical, dstPhysical, srcSubRange.Address + srcOffset, dstSubRange.Address + dstOffset, copySize);
|
CopyBufferSingleRange(memoryManager, srcSubRange.Address + srcOffset, dstSubRange.Address + dstOffset, copySize);
|
||||||
|
|
||||||
srcOffset += copySize;
|
srcOffset += copySize;
|
||||||
dstOffset += copySize;
|
dstOffset += copySize;
|
||||||
@@ -797,26 +793,18 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// This does a GPU side copy.
|
/// This does a GPU side copy.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="memoryManager">GPU memory manager where the buffer is mapped</param>
|
/// <param name="memoryManager">GPU memory manager where the buffer is mapped</param>
|
||||||
/// <param name="srcPhysical">Physical memory backing the source buffer.</param>
|
|
||||||
/// <param name="dstPhysical">Physical memory backing the destination buffer.</param>
|
|
||||||
/// <param name="srcAddress">Physical address of the copy source</param>
|
/// <param name="srcAddress">Physical address of the copy source</param>
|
||||||
/// <param name="dstAddress">Physical address of the copy destination</param>
|
/// <param name="dstAddress">Physical address of the copy destination</param>
|
||||||
/// <param name="size">Size in bytes of the copy</param>
|
/// <param name="size">Size in bytes of the copy</param>
|
||||||
private static void CopyBufferSingleRange(
|
private void CopyBufferSingleRange(MemoryManager memoryManager, ulong srcAddress, ulong dstAddress, ulong size)
|
||||||
GpuContext context,
|
|
||||||
PhysicalMemory srcPhysical,
|
|
||||||
PhysicalMemory dstPhysical,
|
|
||||||
ulong srcAddress,
|
|
||||||
ulong dstAddress,
|
|
||||||
ulong size)
|
|
||||||
{
|
{
|
||||||
Buffer srcBuffer = srcPhysical.BufferCache.GetBuffer(srcAddress, size, BufferStage.Copy);
|
Buffer srcBuffer = GetBuffer(srcAddress, size, BufferStage.Copy);
|
||||||
Buffer dstBuffer = dstPhysical.BufferCache.GetBuffer(dstAddress, size, BufferStage.Copy);
|
Buffer dstBuffer = 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);
|
||||||
|
|
||||||
context.Renderer.Pipeline.CopyBuffer(
|
_context.Renderer.Pipeline.CopyBuffer(
|
||||||
srcBuffer.Handle,
|
srcBuffer.Handle,
|
||||||
dstBuffer.Handle,
|
dstBuffer.Handle,
|
||||||
srcOffset,
|
srcOffset,
|
||||||
@@ -832,7 +820,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
// Optimization: If the data being copied is already in memory, then copy it directly instead of flushing from GPU.
|
// Optimization: If the data being copied is already in memory, then copy it directly instead of flushing from GPU.
|
||||||
|
|
||||||
dstBuffer.ClearModified(dstAddress, size);
|
dstBuffer.ClearModified(dstAddress, size);
|
||||||
dstPhysical.WriteTrackedResource(dstAddress, srcPhysical.GetSpan(srcAddress, (int)size), ResourceKind.Buffer);
|
memoryManager.Physical.WriteTrackedResource(dstAddress, memoryManager.Physical.GetSpan(srcAddress, (int)size), ResourceKind.Buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
dstBuffer.CopyToDependantVirtualBuffers(dstAddress, size);
|
dstBuffer.CopyToDependantVirtualBuffers(dstAddress, size);
|
||||||
@@ -861,7 +849,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
|
|
||||||
_context.Renderer.Pipeline.ClearBuffer(buffer.Handle, offset, (int)subRange.Size, value);
|
_context.Renderer.Pipeline.ClearBuffer(buffer.Handle, offset, (int)subRange.Size, value);
|
||||||
|
|
||||||
memoryManager.GetBackingMemory(gpuVa).FillTrackedResource(subRange.Address, subRange.Size, value, ResourceKind.Buffer);
|
memoryManager.Physical.FillTrackedResource(subRange.Address, subRange.Size, value, ResourceKind.Buffer);
|
||||||
|
|
||||||
buffer.CopyToDependantVirtualBuffers(subRange.Address, subRange.Size);
|
buffer.CopyToDependantVirtualBuffers(subRange.Address, subRange.Size);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,19 +66,18 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
Buffers = new BufferBounds[count];
|
Buffers = new BufferBounds[count];
|
||||||
Unaligned = new bool[count];
|
Unaligned = new bool[count];
|
||||||
|
|
||||||
Buffers.AsSpan().Fill(new BufferBounds(null, new MultiRange(MemoryManager.PteUnmapped, 0UL)));
|
Buffers.AsSpan().Fill(new BufferBounds(new MultiRange(MemoryManager.PteUnmapped, 0UL)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the region of a buffer at a given slot.
|
/// Sets the region of a buffer at a given slot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="index">Buffer slot</param>
|
/// <param name="index">Buffer slot</param>
|
||||||
/// <param name="physical">Physical memory backing the buffer</param>
|
|
||||||
/// <param name="range">Physical memory regions where the buffer is mapped</param>
|
/// <param name="range">Physical memory regions where the buffer is mapped</param>
|
||||||
/// <param name="flags">Buffer usage flags</param>
|
/// <param name="flags">Buffer usage flags</param>
|
||||||
public void SetBounds(int index, PhysicalMemory physical, MultiRange range, BufferUsageFlags flags = BufferUsageFlags.None)
|
public void SetBounds(int index, MultiRange range, BufferUsageFlags flags = BufferUsageFlags.None)
|
||||||
{
|
{
|
||||||
Buffers[index] = new BufferBounds(physical, range, flags);
|
Buffers[index] = new BufferBounds(range, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -157,10 +156,8 @@ 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)
|
||||||
{
|
{
|
||||||
BufferCache bufferCache = _channel.MemoryManager.GetBackingMemory(gpuVa).BufferCache;
|
MultiRange range = _channel.MemoryManager.Physical.BufferCache.TranslateAndCreateBuffer(_channel.MemoryManager, gpuVa, size, BufferStage.IndexBuffer);
|
||||||
MultiRange range = bufferCache.TranslateAndCreateBuffer(_channel.MemoryManager, gpuVa, size, BufferStage.IndexBuffer);
|
|
||||||
|
|
||||||
_indexBuffer.BufferCache = bufferCache;
|
|
||||||
_indexBuffer.Range = range;
|
_indexBuffer.Range = range;
|
||||||
_indexBuffer.Type = type;
|
_indexBuffer.Type = type;
|
||||||
|
|
||||||
@@ -189,15 +186,11 @@ 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)
|
||||||
{
|
{
|
||||||
BufferCache bufferCache = _channel.MemoryManager.GetBackingMemory(gpuVa).BufferCache;
|
MultiRange range = _channel.MemoryManager.Physical.BufferCache.TranslateAndCreateBuffer(_channel.MemoryManager, gpuVa, size, BufferStage.VertexBuffer);
|
||||||
MultiRange range = bufferCache.TranslateAndCreateBuffer(_channel.MemoryManager, gpuVa, size, BufferStage.VertexBuffer);
|
|
||||||
|
|
||||||
ref VertexBuffer vb = ref _vertexBuffers[index];
|
_vertexBuffers[index].Range = range;
|
||||||
|
_vertexBuffers[index].Stride = stride;
|
||||||
vb.BufferCache = bufferCache;
|
_vertexBuffers[index].Divisor = divisor;
|
||||||
vb.Range = range;
|
|
||||||
vb.Stride = stride;
|
|
||||||
vb.Divisor = divisor;
|
|
||||||
|
|
||||||
_vertexBuffersDirty = true;
|
_vertexBuffersDirty = true;
|
||||||
|
|
||||||
@@ -220,10 +213,9 @@ 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)
|
||||||
{
|
{
|
||||||
PhysicalMemory physical = _channel.MemoryManager.GetBackingMemory(gpuVa);
|
MultiRange range = _channel.MemoryManager.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(range);
|
||||||
_transformFeedbackBuffersDirty = true;
|
_transformFeedbackBuffersDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,12 +258,11 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
|
|
||||||
RecordStorageAlignment(_cpStorageBuffers, index, gpuVa);
|
RecordStorageAlignment(_cpStorageBuffers, index, gpuVa);
|
||||||
|
|
||||||
gpuVa = BitUtils.AlignDown(gpuVa, (ulong)_context.Capabilities.StorageBufferOffsetAlignment);
|
gpuVa = BitUtils.AlignDown<ulong>(gpuVa, (ulong)_context.Capabilities.StorageBufferOffsetAlignment);
|
||||||
|
|
||||||
PhysicalMemory physical = _channel.MemoryManager.GetBackingMemory(gpuVa);
|
MultiRange range = _channel.MemoryManager.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, range, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -291,17 +282,16 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
|
|
||||||
RecordStorageAlignment(buffers, index, gpuVa);
|
RecordStorageAlignment(buffers, index, gpuVa);
|
||||||
|
|
||||||
gpuVa = BitUtils.AlignDown(gpuVa, (ulong)_context.Capabilities.StorageBufferOffsetAlignment);
|
gpuVa = BitUtils.AlignDown<ulong>(gpuVa, (ulong)_context.Capabilities.StorageBufferOffsetAlignment);
|
||||||
|
|
||||||
PhysicalMemory physical = _channel.MemoryManager.GetBackingMemory(gpuVa);
|
MultiRange range = _channel.MemoryManager.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))
|
||||||
{
|
{
|
||||||
_gpStorageBuffersDirty = true;
|
_gpStorageBuffersDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffers.SetBounds(index, physical, range, flags);
|
buffers.SetBounds(index, range, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -313,10 +303,9 @@ 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)
|
||||||
{
|
{
|
||||||
PhysicalMemory physical = _channel.MemoryManager.GetBackingMemory(gpuVa);
|
MultiRange range = _channel.MemoryManager.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, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -329,10 +318,9 @@ 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)
|
||||||
{
|
{
|
||||||
PhysicalMemory physical = _channel.MemoryManager.GetBackingMemory(gpuVa);
|
MultiRange range = _channel.MemoryManager.Physical.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, range);
|
||||||
_gpUniformBuffersDirty = true;
|
_gpUniformBuffersDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,10 +416,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="index">Index of the uniform buffer binding</param>
|
/// <param name="index">Index of the uniform buffer binding</param>
|
||||||
/// <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 ulong GetComputeUniformBufferAddress(int index)
|
||||||
{
|
{
|
||||||
ref BufferBounds buffer = ref _cpUniformBuffers.Buffers[index];
|
return _cpUniformBuffers.Buffers[index].Range.GetSubRange(0).Address;
|
||||||
return (buffer.Physical, buffer.Range.GetSubRange(0).Address);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -450,10 +437,9 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// <param name="stage">Index of the shader stage</param>
|
/// <param name="stage">Index of the shader stage</param>
|
||||||
/// <param name="index">Index of the uniform buffer binding</param>
|
/// <param name="index">Index of the uniform buffer binding</param>
|
||||||
/// <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 ulong GetGraphicsUniformBufferAddress(int stage, int index)
|
||||||
{
|
{
|
||||||
ref BufferBounds buffer = ref _gpUniformBuffers[stage].Buffers[index];
|
return _gpUniformBuffers[stage].Buffers[index].Range.GetSubRange(0).Address;
|
||||||
return (buffer.Physical, buffer.Range.GetSubRange(0).Address);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -492,10 +478,12 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void CommitComputeBindings()
|
public void CommitComputeBindings()
|
||||||
{
|
{
|
||||||
BindBuffers(_cpStorageBuffers, isStorage: true);
|
BufferCache bufferCache = _channel.MemoryManager.Physical.BufferCache;
|
||||||
BindBuffers(_cpUniformBuffers, isStorage: false);
|
|
||||||
|
|
||||||
CommitBufferTextureBindings();
|
BindBuffers(bufferCache, _cpStorageBuffers, isStorage: true);
|
||||||
|
BindBuffers(bufferCache, _cpUniformBuffers, isStorage: false);
|
||||||
|
|
||||||
|
CommitBufferTextureBindings(bufferCache);
|
||||||
|
|
||||||
// Force rebind after doing compute work.
|
// Force rebind after doing compute work.
|
||||||
Rebind();
|
Rebind();
|
||||||
@@ -507,14 +495,14 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// Commit any queued buffer texture bindings.
|
/// Commit any queued buffer texture bindings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="bufferCache">Buffer cache</param>
|
/// <param name="bufferCache">Buffer cache</param>
|
||||||
private void CommitBufferTextureBindings()
|
private void CommitBufferTextureBindings(BufferCache bufferCache)
|
||||||
{
|
{
|
||||||
if (_bufferTextures.Count > 0)
|
if (_bufferTextures.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (BufferTextureBinding binding in _bufferTextures)
|
foreach (BufferTextureBinding binding in _bufferTextures)
|
||||||
{
|
{
|
||||||
bool isStore = binding.BindingInfo.Flags.HasFlag(TextureUsageFlags.ImageStore);
|
bool isStore = binding.BindingInfo.Flags.HasFlag(TextureUsageFlags.ImageStore);
|
||||||
BufferRange range = binding.BufferCache.GetBufferRange(binding.Range, BufferStageUtils.TextureBuffer(binding.Stage, binding.BindingInfo.Flags), isStore);
|
BufferRange range = 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.
|
||||||
@@ -538,7 +526,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
|
|
||||||
foreach (BufferTextureArrayBinding<ITextureArray> binding in _bufferTextureArrays)
|
foreach (BufferTextureArrayBinding<ITextureArray> binding in _bufferTextureArrays)
|
||||||
{
|
{
|
||||||
BufferRange range = binding.BufferCache.GetBufferRange(binding.Range, BufferStage.None);
|
BufferRange range = bufferCache.GetBufferRange(binding.Range, BufferStage.None);
|
||||||
binding.Texture.SetStorage(range);
|
binding.Texture.SetStorage(range);
|
||||||
|
|
||||||
textureArray[0] = binding.Texture;
|
textureArray[0] = binding.Texture;
|
||||||
@@ -548,7 +536,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
foreach (BufferTextureArrayBinding<IImageArray> binding in _bufferImageArrays)
|
foreach (BufferTextureArrayBinding<IImageArray> binding in _bufferImageArrays)
|
||||||
{
|
{
|
||||||
bool isStore = binding.BindingInfo.Flags.HasFlag(TextureUsageFlags.ImageStore);
|
bool isStore = binding.BindingInfo.Flags.HasFlag(TextureUsageFlags.ImageStore);
|
||||||
BufferRange range = binding.BufferCache.GetBufferRange(binding.Range, BufferStage.None, isStore);
|
BufferRange range = bufferCache.GetBufferRange(binding.Range, BufferStage.None, isStore);
|
||||||
binding.Texture.SetStorage(range);
|
binding.Texture.SetStorage(range);
|
||||||
|
|
||||||
textureArray[0] = binding.Texture;
|
textureArray[0] = binding.Texture;
|
||||||
@@ -567,6 +555,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// <param name="indexed">True if the index buffer is in use</param>
|
/// <param name="indexed">True if the index buffer is in use</param>
|
||||||
public void CommitGraphicsBindings(bool indexed)
|
public void CommitGraphicsBindings(bool indexed)
|
||||||
{
|
{
|
||||||
|
BufferCache bufferCache = _channel.MemoryManager.Physical.BufferCache;
|
||||||
|
|
||||||
if (indexed)
|
if (indexed)
|
||||||
{
|
{
|
||||||
if (_indexBufferDirty || _rebind)
|
if (_indexBufferDirty || _rebind)
|
||||||
@@ -575,14 +565,14 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
|
|
||||||
if (!_indexBuffer.Range.IsUnmapped)
|
if (!_indexBuffer.Range.IsUnmapped)
|
||||||
{
|
{
|
||||||
BufferRange buffer = _indexBuffer.BufferCache.GetBufferRange(_indexBuffer.Range, BufferStage.IndexBuffer);
|
BufferRange buffer = bufferCache.GetBufferRange(_indexBuffer.Range, BufferStage.IndexBuffer);
|
||||||
|
|
||||||
_context.Renderer.Pipeline.SetIndexBuffer(buffer, _indexBuffer.Type);
|
_context.Renderer.Pipeline.SetIndexBuffer(buffer, _indexBuffer.Type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!_indexBuffer.Range.IsUnmapped)
|
else if (!_indexBuffer.Range.IsUnmapped)
|
||||||
{
|
{
|
||||||
_indexBuffer.BufferCache.SynchronizeBufferRange(_indexBuffer.Range);
|
bufferCache.SynchronizeBufferRange(_indexBuffer.Range);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (_rebind)
|
else if (_rebind)
|
||||||
@@ -607,7 +597,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferRange buffer = vb.BufferCache.GetBufferRange(vb.Range, BufferStage.VertexBuffer);
|
BufferRange buffer = bufferCache.GetBufferRange(vb.Range, BufferStage.VertexBuffer);
|
||||||
|
|
||||||
vertexBuffers[index] = new VertexBufferDescriptor(buffer, vb.Stride, vb.Divisor);
|
vertexBuffers[index] = new VertexBufferDescriptor(buffer, vb.Stride, vb.Divisor);
|
||||||
}
|
}
|
||||||
@@ -625,7 +615,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
vb.BufferCache.SynchronizeBufferRange(vb.Range);
|
bufferCache.SynchronizeBufferRange(vb.Range);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -647,7 +637,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tfbs[index] = tfb.BufferCache.GetBufferRange(tfb.Range, BufferStage.TransformFeedback, write: true);
|
tfbs[index] = bufferCache.GetBufferRange(tfb.Range, BufferStage.TransformFeedback, write: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
_context.Renderer.Pipeline.SetTransformFeedbackBuffers(tfbs);
|
_context.Renderer.Pipeline.SetTransformFeedbackBuffers(tfbs);
|
||||||
@@ -694,7 +684,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
|
|
||||||
_context.SupportBufferUpdater.SetTfeOffset(index, tfeOffset);
|
_context.SupportBufferUpdater.SetTfeOffset(index, tfeOffset);
|
||||||
|
|
||||||
buffers[index] = new BufferAssignment(index, tfb.BufferCache.GetBufferRange(range, BufferStage.TransformFeedback, write: true));
|
buffers[index] = new BufferAssignment(index, bufferCache.GetBufferRange(range, BufferStage.TransformFeedback, write: true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -712,7 +702,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tfb.BufferCache.SynchronizeBufferRange(tfb.Range);
|
bufferCache.SynchronizeBufferRange(tfb.Range);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -720,7 +710,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
{
|
{
|
||||||
_gpStorageBuffersDirty = false;
|
_gpStorageBuffersDirty = false;
|
||||||
|
|
||||||
BindBuffers(_gpStorageBuffers, isStorage: true);
|
BindBuffers(bufferCache, _gpStorageBuffers, isStorage: true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -731,14 +721,14 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
{
|
{
|
||||||
_gpUniformBuffersDirty = false;
|
_gpUniformBuffersDirty = false;
|
||||||
|
|
||||||
BindBuffers(_gpUniformBuffers, isStorage: false);
|
BindBuffers(bufferCache, _gpUniformBuffers, isStorage: false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UpdateBuffers(_gpUniformBuffers);
|
UpdateBuffers(_gpUniformBuffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
CommitBufferTextureBindings();
|
CommitBufferTextureBindings(bufferCache);
|
||||||
|
|
||||||
_rebind = false;
|
_rebind = false;
|
||||||
|
|
||||||
@@ -752,7 +742,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// <param name="bindings">Buffer memory ranges to bind</param>
|
/// <param name="bindings">Buffer memory ranges to bind</param>
|
||||||
/// <param name="isStorage">True to bind as storage buffer, false to bind as uniform buffer</param>
|
/// <param name="isStorage">True to bind as storage buffer, false to bind as uniform buffer</param>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void BindBuffers(BuffersPerStage[] bindings, bool isStorage)
|
private void BindBuffers(BufferCache bufferCache, BuffersPerStage[] bindings, bool isStorage)
|
||||||
{
|
{
|
||||||
int rangesCount = 0;
|
int rangesCount = 0;
|
||||||
|
|
||||||
@@ -773,8 +763,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
{
|
{
|
||||||
bool isWrite = bounds.Flags.HasFlag(BufferUsageFlags.Write);
|
bool isWrite = bounds.Flags.HasFlag(BufferUsageFlags.Write);
|
||||||
BufferRange range = isStorage
|
BufferRange range = isStorage
|
||||||
? bounds.BufferCache.GetBufferRangeAligned(bounds.Range, bufferStage | BufferStageUtils.FromUsage(bounds.Flags), isWrite)
|
? bufferCache.GetBufferRangeAligned(bounds.Range, bufferStage | BufferStageUtils.FromUsage(bounds.Flags), isWrite)
|
||||||
: bounds.BufferCache.GetBufferRange(bounds.Range, bufferStage);
|
: bufferCache.GetBufferRange(bounds.Range, bufferStage);
|
||||||
|
|
||||||
ranges[rangesCount++] = new BufferAssignment(bindingInfo.Binding, range);
|
ranges[rangesCount++] = new BufferAssignment(bindingInfo.Binding, range);
|
||||||
}
|
}
|
||||||
@@ -790,10 +780,11 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Bind respective buffer bindings on the host API.
|
/// Bind respective buffer bindings on the host API.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="bufferCache">Buffer cache holding the buffers for the specified ranges</param>
|
||||||
/// <param name="buffers">Buffer memory ranges to bind</param>
|
/// <param name="buffers">Buffer memory ranges to bind</param>
|
||||||
/// <param name="isStorage">True to bind as storage buffer, false to bind as uniform buffer</param>
|
/// <param name="isStorage">True to bind as storage buffer, false to bind as uniform buffer</param>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private void BindBuffers(BuffersPerStage buffers, bool isStorage)
|
private void BindBuffers(BufferCache bufferCache, BuffersPerStage buffers, bool isStorage)
|
||||||
{
|
{
|
||||||
int rangesCount = 0;
|
int rangesCount = 0;
|
||||||
|
|
||||||
@@ -809,8 +800,8 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
{
|
{
|
||||||
bool isWrite = bounds.Flags.HasFlag(BufferUsageFlags.Write);
|
bool isWrite = bounds.Flags.HasFlag(BufferUsageFlags.Write);
|
||||||
BufferRange range = isStorage
|
BufferRange range = isStorage
|
||||||
? bounds.BufferCache.GetBufferRangeAligned(bounds.Range, BufferStageUtils.ComputeStorage(bounds.Flags), isWrite)
|
? bufferCache.GetBufferRangeAligned(bounds.Range, BufferStageUtils.ComputeStorage(bounds.Flags), isWrite)
|
||||||
: bounds.BufferCache.GetBufferRange(bounds.Range, BufferStage.Compute);
|
: bufferCache.GetBufferRange(bounds.Range, BufferStage.Compute);
|
||||||
|
|
||||||
ranges[rangesCount++] = new BufferAssignment(bindingInfo.Binding, range);
|
ranges[rangesCount++] = new BufferAssignment(bindingInfo.Binding, range);
|
||||||
}
|
}
|
||||||
@@ -863,7 +854,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bounds.BufferCache.SynchronizeBufferRange(bounds.Range);
|
_channel.MemoryManager.Physical.BufferCache.SynchronizeBufferRange(bounds.Range);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -880,14 +871,13 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
public void SetBufferTextureStorage(
|
public void SetBufferTextureStorage(
|
||||||
ShaderStage stage,
|
ShaderStage stage,
|
||||||
ITexture texture,
|
ITexture texture,
|
||||||
BufferCache bufferCache,
|
|
||||||
MultiRange range,
|
MultiRange range,
|
||||||
TextureBindingInfo bindingInfo,
|
TextureBindingInfo bindingInfo,
|
||||||
bool isImage)
|
bool isImage)
|
||||||
{
|
{
|
||||||
bufferCache.CreateBuffer(range, BufferStageUtils.TextureBuffer(stage, bindingInfo.Flags));
|
_channel.MemoryManager.Physical.BufferCache.CreateBuffer(range, BufferStageUtils.TextureBuffer(stage, bindingInfo.Flags));
|
||||||
|
|
||||||
_bufferTextures.Add(new BufferTextureBinding(stage, texture, bufferCache, range, bindingInfo, isImage));
|
_bufferTextures.Add(new BufferTextureBinding(stage, texture, range, bindingInfo, isImage));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -904,14 +894,13 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
ShaderStage stage,
|
ShaderStage stage,
|
||||||
ITextureArray array,
|
ITextureArray array,
|
||||||
ITexture texture,
|
ITexture texture,
|
||||||
BufferCache bufferCache,
|
|
||||||
MultiRange range,
|
MultiRange range,
|
||||||
TextureBindingInfo bindingInfo,
|
TextureBindingInfo bindingInfo,
|
||||||
int index)
|
int index)
|
||||||
{
|
{
|
||||||
bufferCache.CreateBuffer(range, BufferStageUtils.TextureBuffer(stage, bindingInfo.Flags));
|
_channel.MemoryManager.Physical.BufferCache.CreateBuffer(range, BufferStageUtils.TextureBuffer(stage, bindingInfo.Flags));
|
||||||
|
|
||||||
_bufferTextureArrays.Add(new BufferTextureArrayBinding<ITextureArray>(array, texture, bufferCache, range, bindingInfo, index));
|
_bufferTextureArrays.Add(new BufferTextureArrayBinding<ITextureArray>(array, texture, range, bindingInfo, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -928,14 +917,13 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
ShaderStage stage,
|
ShaderStage stage,
|
||||||
IImageArray array,
|
IImageArray array,
|
||||||
ITexture texture,
|
ITexture texture,
|
||||||
BufferCache bufferCache,
|
|
||||||
MultiRange range,
|
MultiRange range,
|
||||||
TextureBindingInfo bindingInfo,
|
TextureBindingInfo bindingInfo,
|
||||||
int index)
|
int index)
|
||||||
{
|
{
|
||||||
bufferCache.CreateBuffer(range, BufferStageUtils.TextureBuffer(stage, bindingInfo.Flags));
|
_channel.MemoryManager.Physical.BufferCache.CreateBuffer(range, BufferStageUtils.TextureBuffer(stage, bindingInfo.Flags));
|
||||||
|
|
||||||
_bufferImageArrays.Add(new BufferTextureArrayBinding<IImageArray>(array, texture, bufferCache, range, bindingInfo, index));
|
_bufferImageArrays.Add(new BufferTextureArrayBinding<IImageArray>(array, texture, range, bindingInfo, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -19,11 +19,6 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ITexture Texture { get; }
|
public ITexture Texture { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Buffer cache that owns the buffer.
|
|
||||||
/// </summary>
|
|
||||||
public BufferCache BufferCache { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Physical ranges of memory where the buffer texture data is located.
|
/// Physical ranges of memory where the buffer texture data is located.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -44,21 +39,18 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="array">Array</param>
|
/// <param name="array">Array</param>
|
||||||
/// <param name="texture">Buffer texture</param>
|
/// <param name="texture">Buffer texture</param>
|
||||||
/// <param name="bufferCache">Buffer cache that owns the buffer</param>
|
|
||||||
/// <param name="range">Physical ranges of memory where the buffer texture data is located</param>
|
/// <param name="range">Physical ranges of memory where the buffer texture data is located</param>
|
||||||
/// <param name="bindingInfo">Binding info</param>
|
/// <param name="bindingInfo">Binding info</param>
|
||||||
/// <param name="index">Index of the binding on the array</param>
|
/// <param name="index">Index of the binding on the array</param>
|
||||||
public BufferTextureArrayBinding(
|
public BufferTextureArrayBinding(
|
||||||
T array,
|
T array,
|
||||||
ITexture texture,
|
ITexture texture,
|
||||||
BufferCache bufferCache,
|
|
||||||
MultiRange range,
|
MultiRange range,
|
||||||
TextureBindingInfo bindingInfo,
|
TextureBindingInfo bindingInfo,
|
||||||
int index)
|
int index)
|
||||||
{
|
{
|
||||||
Array = array;
|
Array = array;
|
||||||
Texture = texture;
|
Texture = texture;
|
||||||
BufferCache = bufferCache;
|
|
||||||
Range = range;
|
Range = range;
|
||||||
BindingInfo = bindingInfo;
|
BindingInfo = bindingInfo;
|
||||||
Index = index;
|
Index = index;
|
||||||
|
|||||||
@@ -20,11 +20,6 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ITexture Texture { get; }
|
public ITexture Texture { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Buffer cache that owns the buffer.
|
|
||||||
/// </summary>
|
|
||||||
public BufferCache BufferCache { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Physical ranges of memory where the buffer texture data is located.
|
/// Physical ranges of memory where the buffer texture data is located.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -45,21 +40,18 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="stage">Shader stage accessing the texture</param>
|
/// <param name="stage">Shader stage accessing the texture</param>
|
||||||
/// <param name="texture">Buffer texture</param>
|
/// <param name="texture">Buffer texture</param>
|
||||||
/// <param name="bufferCache">Buffer cache that owns the buffer</param>
|
|
||||||
/// <param name="range">Physical ranges of memory where the buffer texture data is located</param>
|
/// <param name="range">Physical ranges of memory where the buffer texture data is located</param>
|
||||||
/// <param name="bindingInfo">Binding info</param>
|
/// <param name="bindingInfo">Binding info</param>
|
||||||
/// <param name="isImage">Whether the binding is for an image or a sampler</param>
|
/// <param name="isImage">Whether the binding is for an image or a sampler</param>
|
||||||
public BufferTextureBinding(
|
public BufferTextureBinding(
|
||||||
ShaderStage stage,
|
ShaderStage stage,
|
||||||
ITexture texture,
|
ITexture texture,
|
||||||
BufferCache bufferCache,
|
|
||||||
MultiRange range,
|
MultiRange range,
|
||||||
TextureBindingInfo bindingInfo,
|
TextureBindingInfo bindingInfo,
|
||||||
bool isImage)
|
bool isImage)
|
||||||
{
|
{
|
||||||
Stage = stage;
|
Stage = stage;
|
||||||
Texture = texture;
|
Texture = texture;
|
||||||
BufferCache = bufferCache;
|
|
||||||
Range = range;
|
Range = range;
|
||||||
BindingInfo = bindingInfo;
|
BindingInfo = bindingInfo;
|
||||||
IsImage = isImage;
|
IsImage = isImage;
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
struct IndexBuffer
|
struct IndexBuffer
|
||||||
{
|
{
|
||||||
public BufferCache BufferCache;
|
|
||||||
public MultiRange Range;
|
public MultiRange Range;
|
||||||
public IndexType Type;
|
public IndexType Type;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Ryujinx.Common.Memory;
|
using Ryujinx.Common.Memory;
|
||||||
using Ryujinx.Graphics.Gpu.Image;
|
|
||||||
using Ryujinx.Memory;
|
using Ryujinx.Memory;
|
||||||
using Ryujinx.Memory.Range;
|
using Ryujinx.Memory.Range;
|
||||||
using System;
|
using System;
|
||||||
@@ -36,9 +35,10 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
|
|
||||||
public event EventHandler<UnmapEventArgs> MemoryUnmapped;
|
public event EventHandler<UnmapEventArgs> MemoryUnmapped;
|
||||||
|
|
||||||
private readonly GpuContext _context;
|
/// <summary>
|
||||||
private readonly List<PhysicalMemory> _physicalMemoryList;
|
/// Physical memory where the virtual memory is mapped into.
|
||||||
private readonly Dictionary<PhysicalMemory, byte> _physicalMemoryMap;
|
/// </summary>
|
||||||
|
internal PhysicalMemory Physical { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Virtual range cache.
|
/// Virtual range cache.
|
||||||
@@ -53,65 +53,19 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new instance of the GPU memory manager.
|
/// Creates a new instance of the GPU memory manager.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="context">GPU context</param>
|
|
||||||
/// <param name="physicalMemory">Physical memory that this memory manager will map into</param>
|
/// <param name="physicalMemory">Physical memory that this memory manager will map into</param>
|
||||||
/// <param name="cpuMemorySize">The amount of physical CPU Memory Avaiable on the device.</param>
|
/// <param name="cpuMemorySize">The amount of physical CPU Memory Avaiable on the device.</param>
|
||||||
|
internal MemoryManager(PhysicalMemory physicalMemory, ulong cpuMemorySize)
|
||||||
internal MemoryManager(GpuContext context, PhysicalMemory physicalMemory, ulong cpuMemorySize)
|
|
||||||
{
|
{
|
||||||
_context = context;
|
Physical = physicalMemory;
|
||||||
|
|
||||||
_physicalMemoryList = new List<PhysicalMemory>()
|
|
||||||
{
|
|
||||||
physicalMemory
|
|
||||||
};
|
|
||||||
|
|
||||||
_physicalMemoryMap = new Dictionary<PhysicalMemory, byte>
|
|
||||||
{
|
|
||||||
{ physicalMemory, 0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
VirtualRangeCache = new VirtualRangeCache(this);
|
VirtualRangeCache = new VirtualRangeCache(this);
|
||||||
CounterCache = new CounterCache();
|
CounterCache = new CounterCache();
|
||||||
_pageTable = new ulong[PtLvl0Size][];
|
_pageTable = new ulong[PtLvl0Size][];
|
||||||
MemoryUnmapped += physicalMemory.TextureCache.MemoryUnmappedHandler;
|
MemoryUnmapped += Physical.TextureCache.MemoryUnmappedHandler;
|
||||||
MemoryUnmapped += physicalMemory.BufferCache.MemoryUnmappedHandler;
|
MemoryUnmapped += Physical.BufferCache.MemoryUnmappedHandler;
|
||||||
MemoryUnmapped += VirtualRangeCache.MemoryUnmappedHandler;
|
MemoryUnmapped += VirtualRangeCache.MemoryUnmappedHandler;
|
||||||
MemoryUnmapped += CounterCache.MemoryUnmappedHandler;
|
MemoryUnmapped += CounterCache.MemoryUnmappedHandler;
|
||||||
physicalMemory.TextureCache.Initialize(cpuMemorySize);
|
Physical.TextureCache.Initialize(cpuMemorySize);
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Attaches the memory manager to a new GPU channel.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="rebind">Action to be performed when the buffer cache changes</param>
|
|
||||||
internal void AttachToChannel(Action rebind)
|
|
||||||
{
|
|
||||||
PhysicalMemory physicalMemory = GetOwnPhysicalMemory();
|
|
||||||
|
|
||||||
physicalMemory.IncrementReferenceCount();
|
|
||||||
physicalMemory.BufferCache.NotifyBuffersModified += rebind;
|
|
||||||
physicalMemory.BufferCache.QueuePrune();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Attaches the memory manager to a new GPU channel.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="rebind">Action that was performed when the buffer cache changed</param>
|
|
||||||
internal void DetachFromChannel(Action rebind)
|
|
||||||
{
|
|
||||||
PhysicalMemory physicalMemory = GetOwnPhysicalMemory();
|
|
||||||
|
|
||||||
physicalMemory.BufferCache.NotifyBuffersModified -= rebind;
|
|
||||||
physicalMemory.DecrementReferenceCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Queues a prune of invalid entries on the buffer cache.
|
|
||||||
/// </summary>
|
|
||||||
internal void QueuePrune()
|
|
||||||
{
|
|
||||||
GetOwnPhysicalMemory().BufferCache.QueuePrune();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -127,15 +81,15 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
|
|
||||||
if (IsContiguous(va, size))
|
if (IsContiguous(va, size))
|
||||||
{
|
{
|
||||||
(PhysicalMemory physicalMemory, ulong address) = TranslateWithPhysicalMemory(va);
|
ulong address = Translate(va);
|
||||||
|
|
||||||
if (tracked)
|
if (tracked)
|
||||||
{
|
{
|
||||||
return physicalMemory.ReadTracked<T>(address);
|
return Physical.ReadTracked<T>(address);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return physicalMemory.Read<T>(address);
|
return Physical.Read<T>(address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -159,9 +113,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
{
|
{
|
||||||
if (IsContiguous(va, size))
|
if (IsContiguous(va, size))
|
||||||
{
|
{
|
||||||
(PhysicalMemory physicalMemory, ulong address) = TranslateWithPhysicalMemory(va);
|
return Physical.GetSpan(Translate(va), size, tracked);
|
||||||
|
|
||||||
return physicalMemory.GetSpan(address, size, tracked);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -186,7 +138,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
bool isContiguous = true;
|
bool isContiguous = true;
|
||||||
int mappedSize;
|
int mappedSize;
|
||||||
|
|
||||||
if (ValidateAddress(va) && IsMappedOnGpuAndPhysical(va))
|
if (ValidateAddress(va) && GetPte(va) != PteUnmapped && Physical.IsMapped(Translate(va)))
|
||||||
{
|
{
|
||||||
ulong endVa = va + (ulong)size;
|
ulong endVa = va + (ulong)size;
|
||||||
ulong endVaAligned = (endVa + PageMask) & ~PageMask;
|
ulong endVaAligned = (endVa + PageMask) & ~PageMask;
|
||||||
@@ -199,7 +151,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
ulong nextVa = currentVa + PageSize;
|
ulong nextVa = currentVa + PageSize;
|
||||||
ulong nextPa = Translate(nextVa);
|
ulong nextPa = Translate(nextVa);
|
||||||
|
|
||||||
if (!ValidateAddress(nextVa) || !IsMappedOnGpuAndPhysical(nextVa))
|
if (!ValidateAddress(nextVa) || GetPte(nextVa) == PteUnmapped || !Physical.IsMapped(nextPa))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -228,9 +180,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
|
|
||||||
if (isContiguous)
|
if (isContiguous)
|
||||||
{
|
{
|
||||||
(PhysicalMemory physicalMemory, ulong address) = TranslateWithPhysicalMemory(va);
|
return Physical.GetSpan(Translate(va), mappedSize, tracked);
|
||||||
|
|
||||||
return physicalMemory.GetSpan(address, mappedSize, tracked);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -242,23 +192,6 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Checks if a page of memory is mapped on the GPU and its backing memory.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="va">GPU virtual address of the page</param>
|
|
||||||
/// <returns>True if mapped, false otherwise</returns>
|
|
||||||
private bool IsMappedOnGpuAndPhysical(ulong va)
|
|
||||||
{
|
|
||||||
(PhysicalMemory physicalMemory, ulong address) = TranslateWithPhysicalMemory(va);
|
|
||||||
|
|
||||||
if (address == PteUnmapped)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return physicalMemory.IsMapped(address);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reads data from a possibly non-contiguous region of GPU mapped memory.
|
/// Reads data from a possibly non-contiguous region of GPU mapped memory.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -276,22 +209,22 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
|
|
||||||
if ((va & PageMask) != 0)
|
if ((va & PageMask) != 0)
|
||||||
{
|
{
|
||||||
(PhysicalMemory physicalMemory, ulong pa) = TranslateWithPhysicalMemory(va);
|
ulong pa = Translate(va);
|
||||||
|
|
||||||
size = Math.Min(data.Length, (int)PageSize - (int)(va & PageMask));
|
size = Math.Min(data.Length, (int)PageSize - (int)(va & PageMask));
|
||||||
|
|
||||||
physicalMemory.GetSpan(pa, size, tracked).CopyTo(data[..size]);
|
Physical.GetSpan(pa, size, tracked).CopyTo(data[..size]);
|
||||||
|
|
||||||
offset += size;
|
offset += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; offset < data.Length; offset += size)
|
for (; offset < data.Length; offset += size)
|
||||||
{
|
{
|
||||||
(PhysicalMemory physicalMemory, ulong pa) = TranslateWithPhysicalMemory(va + (ulong)offset);
|
ulong pa = Translate(va + (ulong)offset);
|
||||||
|
|
||||||
size = Math.Min(data.Length - offset, (int)PageSize);
|
size = Math.Min(data.Length - offset, (int)PageSize);
|
||||||
|
|
||||||
physicalMemory.GetSpan(pa, size, tracked).CopyTo(data.Slice(offset, size));
|
Physical.GetSpan(pa, size, tracked).CopyTo(data.Slice(offset, size));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,17 +239,15 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
{
|
{
|
||||||
if (IsContiguous(va, size))
|
if (IsContiguous(va, size))
|
||||||
{
|
{
|
||||||
(PhysicalMemory physicalMemory, ulong address) = TranslateWithPhysicalMemory(va);
|
return Physical.GetWritableRegion(Translate(va), size, tracked);
|
||||||
|
|
||||||
return physicalMemory.GetWritableRegion(address, size, tracked);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Memory<byte> memory = new byte[size];
|
MemoryOwner<byte> memoryOwner = MemoryOwner<byte>.Rent(size);
|
||||||
|
|
||||||
GetSpan(va, size).CopyTo(memory.Span);
|
ReadImpl(va, memoryOwner.Span, tracked);
|
||||||
|
|
||||||
return new WritableRegion(this, va, memory, tracked);
|
return new WritableRegion(this, va, memoryOwner, tracked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -338,7 +269,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// <param name="data">The data to be written</param>
|
/// <param name="data">The data to be written</param>
|
||||||
public void Write(ulong va, ReadOnlySpan<byte> data)
|
public void Write(ulong va, ReadOnlySpan<byte> data)
|
||||||
{
|
{
|
||||||
WriteImpl(va, data, (physical, va, data) => physical.Write(va, data));
|
WriteImpl(va, data, Physical.Write);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -348,7 +279,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// <param name="data">The data to be written</param>
|
/// <param name="data">The data to be written</param>
|
||||||
public void WriteTrackedResource(ulong va, ReadOnlySpan<byte> data)
|
public void WriteTrackedResource(ulong va, ReadOnlySpan<byte> data)
|
||||||
{
|
{
|
||||||
WriteImpl(va, data, (physical, va, data) => physical.WriteTrackedResource(va, data));
|
WriteImpl(va, data, Physical.WriteTrackedResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -358,10 +289,10 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// <param name="data">The data to be written</param>
|
/// <param name="data">The data to be written</param>
|
||||||
public void WriteUntracked(ulong va, ReadOnlySpan<byte> data)
|
public void WriteUntracked(ulong va, ReadOnlySpan<byte> data)
|
||||||
{
|
{
|
||||||
WriteImpl(va, data, (physical, va, data) => physical.WriteUntracked(va, data));
|
WriteImpl(va, data, Physical.WriteUntracked);
|
||||||
}
|
}
|
||||||
|
|
||||||
private delegate void WriteCallback(PhysicalMemory physicalMemory, ulong address, ReadOnlySpan<byte> data);
|
private delegate void WriteCallback(ulong address, ReadOnlySpan<byte> data);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Writes data to possibly non-contiguous GPU mapped memory.
|
/// Writes data to possibly non-contiguous GPU mapped memory.
|
||||||
@@ -373,9 +304,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
{
|
{
|
||||||
if (IsContiguous(va, data.Length))
|
if (IsContiguous(va, data.Length))
|
||||||
{
|
{
|
||||||
(PhysicalMemory physicalMemory, ulong address) = TranslateWithPhysicalMemory(va);
|
writeCallback(Translate(va), data);
|
||||||
|
|
||||||
writeCallback(physicalMemory, address, data);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -383,67 +312,22 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
|
|
||||||
if ((va & PageMask) != 0)
|
if ((va & PageMask) != 0)
|
||||||
{
|
{
|
||||||
(PhysicalMemory physicalMemory, ulong pa) = TranslateWithPhysicalMemory(va);
|
ulong pa = Translate(va);
|
||||||
|
|
||||||
size = Math.Min(data.Length, (int)PageSize - (int)(va & PageMask));
|
size = Math.Min(data.Length, (int)PageSize - (int)(va & PageMask));
|
||||||
|
|
||||||
writeCallback(physicalMemory, pa, data[..size]);
|
writeCallback(pa, data[..size]);
|
||||||
|
|
||||||
offset += size;
|
offset += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; offset < data.Length; offset += size)
|
for (; offset < data.Length; offset += size)
|
||||||
{
|
{
|
||||||
(PhysicalMemory physicalMemory, ulong pa) = TranslateWithPhysicalMemory(va + (ulong)offset);
|
ulong pa = Translate(va + (ulong)offset);
|
||||||
|
|
||||||
size = Math.Min(data.Length - offset, (int)PageSize);
|
size = Math.Min(data.Length - offset, (int)PageSize);
|
||||||
|
|
||||||
writeCallback(physicalMemory, pa, data.Slice(offset, size));
|
writeCallback(pa, data.Slice(offset, size));
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Writes data to GPU mapped memory, stopping at the first unmapped page at the memory region, if any.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="va">GPU virtual address to write the data into</param>
|
|
||||||
/// <param name="data">The data to be written</param>
|
|
||||||
public void WriteMapped(ulong va, ReadOnlySpan<byte> data)
|
|
||||||
{
|
|
||||||
if (IsContiguous(va, data.Length))
|
|
||||||
{
|
|
||||||
(PhysicalMemory physicalMemory, ulong address) = TranslateWithPhysicalMemory(va);
|
|
||||||
|
|
||||||
physicalMemory.Write(address, data);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int offset = 0, size;
|
|
||||||
|
|
||||||
if ((va & PageMask) != 0)
|
|
||||||
{
|
|
||||||
(PhysicalMemory physicalMemory, ulong pa) = TranslateWithPhysicalMemory(va);
|
|
||||||
|
|
||||||
size = Math.Min(data.Length, (int)PageSize - (int)(va & PageMask));
|
|
||||||
|
|
||||||
if (pa != PteUnmapped && physicalMemory.IsMapped(pa))
|
|
||||||
{
|
|
||||||
physicalMemory.Write(pa, data[..size]);
|
|
||||||
}
|
|
||||||
|
|
||||||
offset += size;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (; offset < data.Length; offset += size)
|
|
||||||
{
|
|
||||||
(PhysicalMemory physicalMemory, ulong pa) = TranslateWithPhysicalMemory(va + (ulong)offset);
|
|
||||||
|
|
||||||
size = Math.Min(data.Length - offset, (int)PageSize);
|
|
||||||
|
|
||||||
if (pa != PteUnmapped && physicalMemory.IsMapped(pa))
|
|
||||||
{
|
|
||||||
physicalMemory.Write(pa, data.Slice(offset, size));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -475,51 +359,15 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// <param name="size">Size in bytes of the mapping</param>
|
/// <param name="size">Size in bytes of the mapping</param>
|
||||||
/// <param name="kind">Kind of the resource located at the mapping</param>
|
/// <param name="kind">Kind of the resource located at the mapping</param>
|
||||||
public void Map(ulong pa, ulong va, ulong size, PteKind kind)
|
public void Map(ulong pa, ulong va, ulong size, PteKind kind)
|
||||||
{
|
|
||||||
MapImpl(pa, va, size, kind);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Maps a given range of pages to the specified CPU virtual address from a different process.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// All addresses and sizes must be page aligned.
|
|
||||||
/// </remarks>
|
|
||||||
/// <param name="pa">CPU virtual address to map into</param>
|
|
||||||
/// <param name="va">GPU virtual address to be mapped</param>
|
|
||||||
/// <param name="size">Size in bytes of the mapping</param>
|
|
||||||
/// <param name="kind">Kind of the resource located at the mapping</param>
|
|
||||||
/// <param name="ownedPid">PID of the process that owns the mapping</param>
|
|
||||||
public void MapForeign(ulong pa, ulong va, ulong size, PteKind kind, ulong ownedPid)
|
|
||||||
{
|
|
||||||
if (_context.PhysicalMemoryRegistry.TryGetValue(ownedPid, out PhysicalMemory physicalMemory))
|
|
||||||
{
|
|
||||||
MapImpl(pa, va, size, kind, physicalMemory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Maps a given range of pages to the specified CPU virtual address.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// All addresses and sizes must be page aligned.
|
|
||||||
/// </remarks>
|
|
||||||
/// <param name="pa">CPU virtual address to map into</param>
|
|
||||||
/// <param name="va">GPU virtual address to be mapped</param>
|
|
||||||
/// <param name="size">Size in bytes of the mapping</param>
|
|
||||||
/// <param name="kind">Kind of the resource located at the mapping</param>
|
|
||||||
/// <param name="physicalMemory">Optional physical memory to import for the mapping</param>
|
|
||||||
private void MapImpl(ulong pa, ulong va, ulong size, PteKind kind, PhysicalMemory physicalMemory = null)
|
|
||||||
{
|
{
|
||||||
lock (_pageTable)
|
lock (_pageTable)
|
||||||
{
|
{
|
||||||
UnmapEventArgs e = new(va, size);
|
UnmapEventArgs e = new(va, size);
|
||||||
MemoryUnmapped?.Invoke(this, e);
|
MemoryUnmapped?.Invoke(this, e);
|
||||||
byte pIndex = physicalMemory != null ? GetOrAddPhysicalMemory(physicalMemory) : (byte)0;
|
|
||||||
|
|
||||||
for (ulong offset = 0; offset < size; offset += PageSize)
|
for (ulong offset = 0; offset < size; offset += PageSize)
|
||||||
{
|
{
|
||||||
SetPte(va + offset, PackPte(pa + offset, pIndex, kind));
|
SetPte(va + offset, PackPte(pa + offset, kind));
|
||||||
}
|
}
|
||||||
|
|
||||||
RunRemapActions(e);
|
RunRemapActions(e);
|
||||||
@@ -570,14 +418,12 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
|
|
||||||
for (int page = 0; page < pages - 1; page++)
|
for (int page = 0; page < pages - 1; page++)
|
||||||
{
|
{
|
||||||
ulong nextPte = GetPte(va + PageSize);
|
if (!ValidateAddress(va + PageSize) || GetPte(va + PageSize) == PteUnmapped)
|
||||||
|
|
||||||
if (!ValidateAddress(va + PageSize) || nextPte == PteUnmapped)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetPte(va) + PageSize != nextPte)
|
if (Translate(va) + PageSize != Translate(va + PageSize))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -611,7 +457,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
|
|
||||||
int pages = (int)((endVaRounded - va) / PageSize);
|
int pages = (int)((endVaRounded - va) / PageSize);
|
||||||
|
|
||||||
List<MemoryRange> regions = new();
|
List<MemoryRange> regions = [];
|
||||||
|
|
||||||
for (int page = 0; page < pages - 1; page++)
|
for (int page = 0; page < pages - 1; page++)
|
||||||
{
|
{
|
||||||
@@ -689,49 +535,6 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the backing memory for a given GPU virtual address.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="va">GPU virtual address to get the backing memory from</param>
|
|
||||||
/// <returns>The backing memory for the specified GPU virtual address</returns>
|
|
||||||
internal PhysicalMemory GetBackingMemory(ulong va)
|
|
||||||
{
|
|
||||||
ulong pte = GetPte(va);
|
|
||||||
|
|
||||||
if (pte == PteUnmapped)
|
|
||||||
{
|
|
||||||
return GetOwnPhysicalMemory();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _physicalMemoryList[UnpackPIndexFromPte(pte)];
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the backing memory that is owned by this GPU memory manager.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>The backing memory owned by this memory manager</returns>
|
|
||||||
private PhysicalMemory GetOwnPhysicalMemory()
|
|
||||||
{
|
|
||||||
return _physicalMemoryList[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the index for a given physical memory on the list, adding it to the list if needed.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="physicalMemory">Physical memory to get the index from</param>
|
|
||||||
/// <returns>The index of the physical memory on the list</returns>
|
|
||||||
private byte GetOrAddPhysicalMemory(PhysicalMemory physicalMemory)
|
|
||||||
{
|
|
||||||
if (!_physicalMemoryMap.TryGetValue(physicalMemory, out byte pIndex))
|
|
||||||
{
|
|
||||||
pIndex = checked((byte)_physicalMemoryList.Count);
|
|
||||||
_physicalMemoryList.Add(physicalMemory);
|
|
||||||
_physicalMemoryMap.Add(physicalMemory, pIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return pIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validates a GPU virtual address.
|
/// Validates a GPU virtual address.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -833,28 +636,6 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
return Math.Min(maxSize, va - startVa);
|
return Math.Min(maxSize, va - startVa);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Translates a GPU virtual address to a CPU virtual address and the associated physical memory.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="va">GPU virtual address to be translated</param>
|
|
||||||
/// <returns>CPU virtual address with the physical memory, or <see cref="PteUnmapped"/> if unmapped</returns>
|
|
||||||
private (PhysicalMemory, ulong) TranslateWithPhysicalMemory(ulong va)
|
|
||||||
{
|
|
||||||
if (!ValidateAddress(va))
|
|
||||||
{
|
|
||||||
return (GetOwnPhysicalMemory(), PteUnmapped);
|
|
||||||
}
|
|
||||||
|
|
||||||
ulong pte = GetPte(va);
|
|
||||||
|
|
||||||
if (pte == PteUnmapped)
|
|
||||||
{
|
|
||||||
return (GetOwnPhysicalMemory(), PteUnmapped);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (_physicalMemoryList[UnpackPIndexFromPte(pte)], UnpackPaFromPte(pte) + (va & PageMask));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the kind of a given memory page.
|
/// Gets the kind of a given memory page.
|
||||||
/// This might indicate the type of resource that can be allocated on the page, and also texture tiling.
|
/// This might indicate the type of resource that can be allocated on the page, and also texture tiling.
|
||||||
@@ -878,18 +659,6 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
return UnpackKindFromPte(pte);
|
return UnpackKindFromPte(pte);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsForeignMapping(ulong va)
|
|
||||||
{
|
|
||||||
ulong pte = GetPte(va);
|
|
||||||
|
|
||||||
if (pte == PteUnmapped)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return UnpackPIndexFromPte(pte) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the Page Table entry for a given GPU virtual address.
|
/// Gets the Page Table entry for a given GPU virtual address.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -935,12 +704,11 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// Creates a page table entry from a physical address and kind.
|
/// Creates a page table entry from a physical address and kind.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="pa">Physical address</param>
|
/// <param name="pa">Physical address</param>
|
||||||
/// <param name="pIndex">Index of the physical memory on the list</param>
|
|
||||||
/// <param name="kind">Kind</param>
|
/// <param name="kind">Kind</param>
|
||||||
/// <returns>Page table entry</returns>
|
/// <returns>Page table entry</returns>
|
||||||
private static ulong PackPte(ulong pa, byte pIndex, PteKind kind)
|
private static ulong PackPte(ulong pa, PteKind kind)
|
||||||
{
|
{
|
||||||
return pa | ((ulong)pIndex << 48) | ((ulong)kind << 56);
|
return pa | ((ulong)kind << 56);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -953,16 +721,6 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
return (PteKind)(pte >> 56);
|
return (PteKind)(pte >> 56);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Unpacks the physical memory index in the list from a page table entry.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="pte">Page table entry</param>
|
|
||||||
/// <returns>Physical memory index</returns>
|
|
||||||
private static byte UnpackPIndexFromPte(ulong pte)
|
|
||||||
{
|
|
||||||
return (byte)(pte >> 48);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unpacks physical address from a page table entry.
|
/// Unpacks physical address from a page table entry.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -970,7 +728,7 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// <returns>Physical address</returns>
|
/// <returns>Physical address</returns>
|
||||||
private static ulong UnpackPaFromPte(ulong pte)
|
private static ulong UnpackPaFromPte(ulong pte)
|
||||||
{
|
{
|
||||||
return pte & 0xffffffffffffUL;
|
return pte & 0xffffffffffffffUL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ namespace Ryujinx.Graphics.Gpu.Memory
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
struct VertexBuffer
|
struct VertexBuffer
|
||||||
{
|
{
|
||||||
public BufferCache BufferCache;
|
|
||||||
public MultiRange Range;
|
public MultiRange Range;
|
||||||
public int Stride;
|
public int Stride;
|
||||||
public int Divisor;
|
public int Divisor;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
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;
|
||||||
@@ -67,11 +66,11 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public uint ConstantBuffer1Read(int offset)
|
public uint ConstantBuffer1Read(int offset)
|
||||||
{
|
{
|
||||||
(PhysicalMemory physical, ulong baseAddress) = _compute
|
ulong baseAddress = _compute
|
||||||
? _channel.BufferManager.GetComputeUniformBufferAddress(1)
|
? _channel.BufferManager.GetComputeUniformBufferAddress(1)
|
||||||
: _channel.BufferManager.GetGraphicsUniformBufferAddress(_stageIndex, 1);
|
: _channel.BufferManager.GetGraphicsUniformBufferAddress(_stageIndex, 1);
|
||||||
|
|
||||||
return physical.Read<uint>(baseAddress + (ulong)offset);
|
return _channel.MemoryManager.Physical.Read<uint>(baseAddress + (ulong)offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@@ -733,15 +733,15 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||||||
byte[] codeB,
|
byte[] codeB,
|
||||||
bool asCompute)
|
bool asCompute)
|
||||||
{
|
{
|
||||||
(PhysicalMemory physical, ulong cb1DataAddress) = channel.BufferManager.GetGraphicsUniformBufferAddress(0, 1);
|
ulong cb1DataAddress = channel.BufferManager.GetGraphicsUniformBufferAddress(0, 1);
|
||||||
|
|
||||||
MemoryManager memoryManager = channel.MemoryManager;
|
MemoryManager memoryManager = channel.MemoryManager;
|
||||||
|
|
||||||
codeA ??= memoryManager.GetSpan(vertexA.Address, vertexA.Size).ToArray();
|
codeA ??= memoryManager.GetSpan(vertexA.Address, vertexA.Size).ToArray();
|
||||||
codeB ??= memoryManager.GetSpan(currentStage.Address, currentStage.Size).ToArray();
|
codeB ??= memoryManager.GetSpan(currentStage.Address, currentStage.Size).ToArray();
|
||||||
byte[] cb1DataA = ReadArray(physical, cb1DataAddress, vertexA.Cb1DataSize);
|
byte[] cb1DataA = ReadArray(memoryManager, cb1DataAddress, vertexA.Cb1DataSize);
|
||||||
byte[] cb1DataB = ReadArray(physical, cb1DataAddress, currentStage.Cb1DataSize);
|
byte[] cb1DataB = ReadArray(memoryManager, cb1DataAddress, currentStage.Cb1DataSize);
|
||||||
|
|
||||||
ShaderDumpPaths pathsA = default;
|
ShaderDumpPaths pathsA = default;
|
||||||
ShaderDumpPaths pathsB = default;
|
ShaderDumpPaths pathsB = default;
|
||||||
|
|
||||||
@@ -775,11 +775,11 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||||||
{
|
{
|
||||||
MemoryManager memoryManager = channel.MemoryManager;
|
MemoryManager memoryManager = channel.MemoryManager;
|
||||||
|
|
||||||
(PhysicalMemory physical, ulong cb1DataAddress) = context.Stage == ShaderStage.Compute
|
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);
|
||||||
|
|
||||||
byte[] cb1Data = ReadArray(physical, cb1DataAddress, context.Cb1DataSize);
|
byte[] cb1Data = ReadArray(memoryManager, cb1DataAddress, context.Cb1DataSize);
|
||||||
code ??= memoryManager.GetSpan(context.Address, context.Size).ToArray();
|
code ??= memoryManager.GetSpan(context.Address, context.Size).ToArray();
|
||||||
|
|
||||||
ShaderDumpPaths paths = dumper?.Dump(code, context.Stage == ShaderStage.Compute) ?? default;
|
ShaderDumpPaths paths = dumper?.Dump(code, context.Stage == ShaderStage.Compute) ?? default;
|
||||||
@@ -793,18 +793,18 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reads data from physical memory, returns an empty array if the memory is unmapped or size is 0.
|
/// Reads data from physical memory, returns an empty array if the memory is unmapped or size is 0.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="physicalMemory">Physical memory to read the data from, might be null</param>
|
/// <param name="memoryManager">Memory manager with the physical memory to read from</param>
|
||||||
/// <param name="address">Physical address of the region to read</param>
|
/// <param name="address">Physical address of the region to read</param>
|
||||||
/// <param name="size">Size in bytes of the data</param>
|
/// <param name="size">Size in bytes of the data</param>
|
||||||
/// <returns>An array with the data at the specified memory location</returns>
|
/// <returns>An array with the data at the specified memory location</returns>
|
||||||
private static byte[] ReadArray(PhysicalMemory physicalMemory, ulong address, int size)
|
private static byte[] ReadArray(MemoryManager memoryManager, ulong address, int size)
|
||||||
{
|
{
|
||||||
if (address == MemoryManager.PteUnmapped || size == 0 || physicalMemory == null)
|
if (address == MemoryManager.PteUnmapped || size == 0)
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return physicalMemory.GetSpan(address, size).ToArray();
|
return memoryManager.Physical.GetSpan(address, size).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -696,7 +696,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||||||
{
|
{
|
||||||
ref BufferBounds bounds = ref channel.BufferManager.GetUniformBufferBounds(isCompute, stageIndex, textureBufferIndex);
|
ref BufferBounds bounds = ref channel.BufferManager.GetUniformBufferBounds(isCompute, stageIndex, textureBufferIndex);
|
||||||
|
|
||||||
cachedTextureBuffer = MemoryMarshal.Cast<byte, int>(bounds.Physical.GetSpan(bounds.Range));
|
cachedTextureBuffer = MemoryMarshal.Cast<byte, int>(channel.MemoryManager.Physical.GetSpan(bounds.Range));
|
||||||
cachedTextureBufferIndex = textureBufferIndex;
|
cachedTextureBufferIndex = textureBufferIndex;
|
||||||
|
|
||||||
if (samplerBufferIndex == textureBufferIndex)
|
if (samplerBufferIndex == textureBufferIndex)
|
||||||
@@ -710,7 +710,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
|||||||
{
|
{
|
||||||
ref BufferBounds bounds = ref channel.BufferManager.GetUniformBufferBounds(isCompute, stageIndex, samplerBufferIndex);
|
ref BufferBounds bounds = ref channel.BufferManager.GetUniformBufferBounds(isCompute, stageIndex, samplerBufferIndex);
|
||||||
|
|
||||||
cachedSamplerBuffer = MemoryMarshal.Cast<byte, int>(bounds.Physical.GetSpan(bounds.Range));
|
cachedSamplerBuffer = MemoryMarshal.Cast<byte, int>(channel.MemoryManager.Physical.GetSpan(bounds.Range));
|
||||||
cachedSamplerBufferIndex = samplerBufferIndex;
|
cachedSamplerBufferIndex = samplerBufferIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,18 +9,11 @@ using System.Threading;
|
|||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu
|
namespace Ryujinx.Graphics.Gpu
|
||||||
{
|
{
|
||||||
using Texture = Image.Texture;
|
|
||||||
|
|
||||||
public record TextureData(int Width, int Height, byte[] Data);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// GPU image presentation window.
|
/// GPU image presentation window.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Window
|
public class Window
|
||||||
{
|
{
|
||||||
private const int CaptureTextureWidth = 1280;
|
|
||||||
private const int CaptureTextureHeight = 720;
|
|
||||||
|
|
||||||
private readonly GpuContext _context;
|
private readonly GpuContext _context;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -92,21 +85,7 @@ namespace Ryujinx.Graphics.Gpu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PresentedTexture
|
|
||||||
{
|
|
||||||
public readonly Texture Texture;
|
|
||||||
public readonly ImageCrop Crop;
|
|
||||||
|
|
||||||
public PresentedTexture(Texture texture, ImageCrop crop)
|
|
||||||
{
|
|
||||||
Texture = texture;
|
|
||||||
Crop = crop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly ConcurrentQueue<PresentationTexture> _frameQueue;
|
private readonly ConcurrentQueue<PresentationTexture> _frameQueue;
|
||||||
private PresentedTexture _lastPresentedTexture;
|
|
||||||
private ITexture _captureTexture;
|
|
||||||
|
|
||||||
private int _framesAvailable;
|
private int _framesAvailable;
|
||||||
|
|
||||||
@@ -209,51 +188,6 @@ namespace Ryujinx.Graphics.Gpu
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextureData GetLastPresentedData()
|
|
||||||
{
|
|
||||||
PresentedTexture pt = Volatile.Read(ref _lastPresentedTexture);
|
|
||||||
|
|
||||||
if (pt != null)
|
|
||||||
{
|
|
||||||
byte[] inputData = CaptureLastFrame(pt.Texture.HostTexture, pt.Crop);
|
|
||||||
|
|
||||||
int size = SizeCalculator.GetBlockLinearTextureSize(
|
|
||||||
CaptureTextureWidth,
|
|
||||||
CaptureTextureHeight,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
4,
|
|
||||||
16,
|
|
||||||
1,
|
|
||||||
1).TotalSize;
|
|
||||||
|
|
||||||
byte[] data = new byte[size];
|
|
||||||
|
|
||||||
LayoutConverter.ConvertLinearToBlockLinear(data, CaptureTextureWidth, CaptureTextureHeight, CaptureTextureWidth * 4, 4, 16, inputData);
|
|
||||||
|
|
||||||
return new TextureData(CaptureTextureWidth, CaptureTextureHeight, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new TextureData(0, 0, Array.Empty<byte>());
|
|
||||||
}
|
|
||||||
|
|
||||||
public TextureData GetLastPresentedDataLinear()
|
|
||||||
{
|
|
||||||
PresentedTexture pt = Volatile.Read(ref _lastPresentedTexture);
|
|
||||||
|
|
||||||
if (pt != null)
|
|
||||||
{
|
|
||||||
byte[] inputData = CaptureLastFrame(pt.Texture.HostTexture, new ImageCrop());
|
|
||||||
|
|
||||||
return new TextureData(pt.Texture.Info.Width, pt.Texture.Info.Height, inputData);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new TextureData(0, 0, Array.Empty<byte>());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Presents a texture on the queue.
|
/// Presents a texture on the queue.
|
||||||
/// If the queue is empty, then no texture is presented.
|
/// If the queue is empty, then no texture is presented.
|
||||||
@@ -271,10 +205,6 @@ namespace Ryujinx.Graphics.Gpu
|
|||||||
|
|
||||||
pt.Cache.Tick();
|
pt.Cache.Tick();
|
||||||
|
|
||||||
EnsureCaptureTexture();
|
|
||||||
|
|
||||||
Volatile.Write(ref _lastPresentedTexture, new PresentedTexture(texture, pt.Crop));
|
|
||||||
|
|
||||||
texture.SynchronizeMemory();
|
texture.SynchronizeMemory();
|
||||||
|
|
||||||
ImageCrop crop = new(
|
ImageCrop crop = new(
|
||||||
@@ -314,96 +244,6 @@ namespace Ryujinx.Graphics.Gpu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EnsureCaptureTexture()
|
|
||||||
{
|
|
||||||
if (_captureTexture == null)
|
|
||||||
{
|
|
||||||
_captureTexture = _context.Renderer.CreateTexture(new TextureCreateInfo(
|
|
||||||
1280,
|
|
||||||
720,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
4,
|
|
||||||
Format.R8G8B8A8Unorm,
|
|
||||||
DepthStencilMode.Depth,
|
|
||||||
Target.Texture2D,
|
|
||||||
SwizzleComponent.Red,
|
|
||||||
SwizzleComponent.Green,
|
|
||||||
SwizzleComponent.Blue,
|
|
||||||
SwizzleComponent.Alpha));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] CaptureLastFrame(ITexture lastFrame, ImageCrop crop)
|
|
||||||
{
|
|
||||||
int cropLeft, cropRight, cropTop, cropBottom;
|
|
||||||
|
|
||||||
if (crop.Left == 0 && crop.Right == 0)
|
|
||||||
{
|
|
||||||
cropLeft = 0;
|
|
||||||
cropRight = lastFrame.Width;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cropLeft = crop.Left;
|
|
||||||
cropRight = crop.Right;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (crop.Top == 0 && crop.Bottom == 0)
|
|
||||||
{
|
|
||||||
cropTop = 0;
|
|
||||||
cropBottom = lastFrame.Height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cropTop = crop.Top;
|
|
||||||
cropBottom = crop.Bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
int x1, y1, x2, y2;
|
|
||||||
|
|
||||||
if (crop.FlipX)
|
|
||||||
{
|
|
||||||
x1 = cropRight;
|
|
||||||
x2 = cropLeft;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
x1 = cropLeft;
|
|
||||||
x2 = cropRight;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (crop.FlipY)
|
|
||||||
{
|
|
||||||
y1 = cropBottom;
|
|
||||||
y2 = cropTop;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
y1 = cropTop;
|
|
||||||
y2 = cropBottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
Extents2D srcRegion = new(x1, y1, x2, y2);
|
|
||||||
Extents2D dstRegion = new(0, 0, CaptureTextureWidth, CaptureTextureHeight);
|
|
||||||
|
|
||||||
byte[] outputData = null;
|
|
||||||
|
|
||||||
_context.Renderer.BackgroundContextAction(() =>
|
|
||||||
{
|
|
||||||
lastFrame.CopyTo(_captureTexture, srcRegion, dstRegion, true);
|
|
||||||
|
|
||||||
using var data = _captureTexture.GetData();
|
|
||||||
|
|
||||||
outputData = data.Get().ToArray();
|
|
||||||
});
|
|
||||||
|
|
||||||
return outputData;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicate that a frame on the queue is ready to be acquired.
|
/// Indicate that a frame on the queue is ready to be acquired.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace Ryujinx.HLE.HOS
|
|||||||
private readonly ICpuContext _cpuContext;
|
private readonly ICpuContext _cpuContext;
|
||||||
private T _memoryManager;
|
private T _memoryManager;
|
||||||
|
|
||||||
public IVirtualMemoryManagerTracked AddressSpace => _memoryManager;
|
public IVirtualMemoryManager AddressSpace => _memoryManager;
|
||||||
|
|
||||||
public ulong AddressSpaceSize { get; }
|
public ulong AddressSpaceSize { get; }
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ namespace Ryujinx.HLE.HOS
|
|||||||
internal ServerBase TimeServer { get; private set; }
|
internal ServerBase TimeServer { get; private set; }
|
||||||
internal ServerBase ViServer { get; private set; }
|
internal ServerBase ViServer { get; private set; }
|
||||||
internal ServerBase ViServerM { get; private set; }
|
internal ServerBase ViServerM { get; private set; }
|
||||||
internal ViServer ViServerS { get; private set; }
|
internal ServerBase ViServerS { get; private set; }
|
||||||
internal ServerBase LdnServer { get; private set; }
|
internal ServerBase LdnServer { get; private set; }
|
||||||
|
|
||||||
internal KSharedMemory HidSharedMem { get; private set; }
|
internal KSharedMemory HidSharedMem { get; private set; }
|
||||||
@@ -254,7 +254,7 @@ namespace Ryujinx.HLE.HOS
|
|||||||
TimeServer = new ServerBase(KernelContext, "TimeServer");
|
TimeServer = new ServerBase(KernelContext, "TimeServer");
|
||||||
ViServer = new ServerBase(KernelContext, "ViServerU");
|
ViServer = new ServerBase(KernelContext, "ViServerU");
|
||||||
ViServerM = new ServerBase(KernelContext, "ViServerM");
|
ViServerM = new ServerBase(KernelContext, "ViServerM");
|
||||||
ViServerS = new ViServer(KernelContext, "ViServerS");
|
ViServerS = new ServerBase(KernelContext, "ViServerS");
|
||||||
LdnServer = new ServerBase(KernelContext, "LdnServer");
|
LdnServer = new ServerBase(KernelContext, "LdnServer");
|
||||||
|
|
||||||
StartNewServices();
|
StartNewServices();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
|||||||
{
|
{
|
||||||
interface IProcessContext : IDisposable
|
interface IProcessContext : IDisposable
|
||||||
{
|
{
|
||||||
IVirtualMemoryManagerTracked AddressSpace { get; }
|
IVirtualMemoryManager AddressSpace { get; }
|
||||||
|
|
||||||
ulong AddressSpaceSize { get; }
|
ulong AddressSpaceSize { get; }
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
|||||||
|
|
||||||
private IProcessContextFactory _contextFactory;
|
private IProcessContextFactory _contextFactory;
|
||||||
public IProcessContext Context { get; private set; }
|
public IProcessContext Context { get; private set; }
|
||||||
public IVirtualMemoryManagerTracked CpuMemory => Context.AddressSpace;
|
public IVirtualMemoryManager CpuMemory => Context.AddressSpace;
|
||||||
|
|
||||||
public HleProcessDebugger Debugger { get; private set; }
|
public HleProcessDebugger Debugger { get; private set; }
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
|
|||||||
{
|
{
|
||||||
class ProcessContext : IProcessContext
|
class ProcessContext : IProcessContext
|
||||||
{
|
{
|
||||||
public IVirtualMemoryManagerTracked AddressSpace { get; }
|
public IVirtualMemoryManager AddressSpace { get; }
|
||||||
|
|
||||||
public ulong AddressSpaceSize { get; }
|
public ulong AddressSpaceSize { get; }
|
||||||
|
|
||||||
public ProcessContext(IVirtualMemoryManagerTracked asManager, ulong addressSpaceSize)
|
public ProcessContext(IVirtualMemoryManager asManager, ulong addressSpaceSize)
|
||||||
{
|
{
|
||||||
AddressSpace = asManager;
|
AddressSpace = asManager;
|
||||||
AddressSpaceSize = addressSpaceSize;
|
AddressSpaceSize = addressSpaceSize;
|
||||||
|
|||||||
@@ -102,34 +102,5 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
|||||||
|
|
||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
[CommandCmif(22)]
|
|
||||||
// AcquireLastApplicationCaptureSharedBuffer() -> (b8, u32)
|
|
||||||
public ResultCode AcquireLastApplicationCaptureSharedBuffer(ServiceCtx context)
|
|
||||||
{
|
|
||||||
context.ResponseData.Write(1);
|
|
||||||
context.ResponseData.Write(context.Device.System.ViServerS.GetApplicationLastPresentedFrameHandle(context.Device.Gpu));
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(26)]
|
|
||||||
|
|
||||||
// AcquireCallerAppletCaptureSharedBuffer() -> (b8, u32)
|
|
||||||
public ResultCode AcquireCallerAppletCaptureSharedBuffer(ServiceCtx context)
|
|
||||||
{
|
|
||||||
// TODO: How does the handling for applets differ from the one for applications?
|
|
||||||
context.ResponseData.Write(1);
|
|
||||||
context.ResponseData.Write(context.Device.System.ViServerS.GetApplicationLastPresentedFrameHandle(context.Device.Gpu));
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(27)]
|
|
||||||
public ResultCode ReleaseCallerAppletCaptureSharedBuffer(ServiceCtx context)
|
|
||||||
{
|
|
||||||
context.ResponseData.Write(2);
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,6 +225,7 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
|||||||
public ResultCode CreateManagedDisplayLayer(ServiceCtx context)
|
public ResultCode CreateManagedDisplayLayer(ServiceCtx context)
|
||||||
{
|
{
|
||||||
context.Device.System.SurfaceFlinger.CreateLayer(out long layerId, _pid);
|
context.Device.System.SurfaceFlinger.CreateLayer(out long layerId, _pid);
|
||||||
|
context.Device.System.SurfaceFlinger.SetRenderLayer(layerId);
|
||||||
|
|
||||||
context.ResponseData.Write(layerId);
|
context.ResponseData.Write(layerId);
|
||||||
|
|
||||||
@@ -235,27 +236,18 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
|||||||
// IsSystemBufferSharingEnabled()
|
// IsSystemBufferSharingEnabled()
|
||||||
public ResultCode IsSystemBufferSharingEnabled(ServiceCtx context)
|
public ResultCode IsSystemBufferSharingEnabled(ServiceCtx context)
|
||||||
{
|
{
|
||||||
// TODO: Implement this once we have a way to check if we're not an AppletId.Application
|
// NOTE: Service checks a private field and return an error if the SystemBufferSharing is disabled.
|
||||||
return ResultCode.Success;
|
|
||||||
|
return ResultCode.NotImplemented;
|
||||||
}
|
}
|
||||||
|
|
||||||
[CommandCmif(42)] // 4.0.0+
|
|
||||||
// GetSystemSharedLayerHandle() -> (nn::vi::fbshare::SharedBufferHandle, nn::vi::fbshare::SharedLayerHandle)
|
|
||||||
public ResultCode GetSystemSharedLayerHandle(ServiceCtx context)
|
|
||||||
{
|
|
||||||
context.ResponseData.Write((ulong)context.Device.System.ViServerS.GetSharedBufferNvMapId());
|
|
||||||
context.ResponseData.Write(context.Device.System.ViServerS.GetSharedLayerId());
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(44)] // 10.0.0+
|
[CommandCmif(44)] // 10.0.0+
|
||||||
// CreateManagedDisplaySeparableLayer() -> (u64, u64)
|
// CreateManagedDisplaySeparableLayer() -> (u64, u64)
|
||||||
public ResultCode CreateManagedDisplaySeparableLayer(ServiceCtx context)
|
public ResultCode CreateManagedDisplaySeparableLayer(ServiceCtx context)
|
||||||
{
|
{
|
||||||
context.Device.System.SurfaceFlinger.CreateLayer(out long displayLayerId, _pid);
|
context.Device.System.SurfaceFlinger.CreateLayer(out long displayLayerId, _pid);
|
||||||
context.Device.System.SurfaceFlinger.CreateLayer(out long recordingLayerId, _pid);
|
context.Device.System.SurfaceFlinger.CreateLayer(out long recordingLayerId, _pid);
|
||||||
//context.Device.System.SurfaceFlinger.SetRenderLayer(displayLayerId);
|
context.Device.System.SurfaceFlinger.SetRenderLayer(displayLayerId);
|
||||||
|
|
||||||
context.ResponseData.Write(displayLayerId);
|
context.ResponseData.Write(displayLayerId);
|
||||||
context.ResponseData.Write(recordingLayerId);
|
context.ResponseData.Write(recordingLayerId);
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
|||||||
|
|
||||||
public Dictionary<PlayerIndex, ConcurrentQueue<(VibrationValue, VibrationValue)>> RumbleQueues = new();
|
public Dictionary<PlayerIndex, ConcurrentQueue<(VibrationValue, VibrationValue)>> RumbleQueues = new();
|
||||||
public Dictionary<PlayerIndex, (VibrationValue, VibrationValue)> LastVibrationValues = new();
|
public Dictionary<PlayerIndex, (VibrationValue, VibrationValue)> LastVibrationValues = new();
|
||||||
|
|
||||||
internal PlayerIndex LastActiveNpad { get; set; }
|
|
||||||
|
|
||||||
public NpadDevices(Switch device, bool active = true) : base(device, active)
|
public NpadDevices(Switch device, bool active = true) : base(device, active)
|
||||||
{
|
{
|
||||||
@@ -386,8 +384,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LastActiveNpad = state.PlayerId;
|
|
||||||
|
|
||||||
ref RingLifo<NpadCommonState> lifo = ref GetCommonStateLifo(ref currentNpad);
|
ref RingLifo<NpadCommonState> lifo = ref GetCommonStateLifo(ref currentNpad);
|
||||||
|
|
||||||
NpadCommonState newState = new()
|
NpadCommonState newState = new()
|
||||||
@@ -643,20 +639,5 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
|||||||
|
|
||||||
return rumbleQueue;
|
return rumbleQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NpadIdType GetLastActiveNpadId()
|
|
||||||
{
|
|
||||||
return LastActiveNpad switch {
|
|
||||||
PlayerIndex.Player1 => NpadIdType.Player1,
|
|
||||||
PlayerIndex.Player2 => NpadIdType.Player2,
|
|
||||||
PlayerIndex.Player3 => NpadIdType.Player3,
|
|
||||||
PlayerIndex.Player4 => NpadIdType.Player4,
|
|
||||||
PlayerIndex.Player5 => NpadIdType.Player5,
|
|
||||||
PlayerIndex.Player6 => NpadIdType.Player6,
|
|
||||||
PlayerIndex.Player7 => NpadIdType.Player7,
|
|
||||||
PlayerIndex.Player8 => NpadIdType.Player8,
|
|
||||||
_ => NpadIdType.Handheld,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,15 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
|||||||
// GetLastActiveNpad(u32) -> u8, u8
|
// GetLastActiveNpad(u32) -> u8, u8
|
||||||
public ResultCode GetLastActiveNpad(ServiceCtx context)
|
public ResultCode GetLastActiveNpad(ServiceCtx context)
|
||||||
{
|
{
|
||||||
context.ResponseData.Write((byte)context.Device.Hid.Npads.GetLastActiveNpadId());
|
// TODO: RequestData seems to have garbage data, reading an extra uint seems to fix the issue.
|
||||||
|
context.RequestData.ReadUInt32();
|
||||||
|
|
||||||
return ResultCode.Success;
|
ResultCode resultCode = GetAppletFooterUiTypeImpl(context, out AppletFooterUiType appletFooterUiType);
|
||||||
|
|
||||||
|
context.ResponseData.Write((byte)appletFooterUiType);
|
||||||
|
context.ResponseData.Write((byte)0);
|
||||||
|
|
||||||
|
return resultCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
[CommandCmif(307)]
|
[CommandCmif(307)]
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using Ryujinx.Common;
|
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.HLE.HOS.Ipc;
|
using Ryujinx.HLE.HOS.Ipc;
|
||||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||||
@@ -106,26 +105,6 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
|
|||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
[CommandCmif(6)]
|
|
||||||
// SetRequirementPreset(u32)
|
|
||||||
public ResultCode SetRequirementPreset(ServiceCtx context)
|
|
||||||
{
|
|
||||||
Logger.Stub?.PrintStub(LogClass.ServiceNifm);
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(9)]
|
|
||||||
// SetNetworkProfileId(nn::util::Uuid)
|
|
||||||
public ResultCode SetNetworkProfileId(ServiceCtx context)
|
|
||||||
{
|
|
||||||
UInt128 uuid = context.RequestData.ReadStruct<UInt128>();
|
|
||||||
|
|
||||||
Logger.Stub?.PrintStub(LogClass.ServiceNifm, new { uuid });
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(11)]
|
[CommandCmif(11)]
|
||||||
// SetConnectionConfirmationOption(i8)
|
// SetConnectionConfirmationOption(i8)
|
||||||
public ResultCode SetConnectionConfirmationOption(ServiceCtx context)
|
public ResultCode SetConnectionConfirmationOption(ServiceCtx context)
|
||||||
@@ -163,38 +142,5 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
|
|||||||
|
|
||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
[CommandCmif(23)]
|
|
||||||
// SetKeptInSleep(bool)
|
|
||||||
public ResultCode SetKeptInSleep(ServiceCtx context)
|
|
||||||
{
|
|
||||||
bool keptInSleep = context.RequestData.ReadBoolean();
|
|
||||||
|
|
||||||
Logger.Stub?.PrintStub(LogClass.ServiceNifm, new { keptInSleep });
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(24)]
|
|
||||||
// RegisterSocketDescriptor(s32)
|
|
||||||
public ResultCode RegisterSocketDescriptor(ServiceCtx context)
|
|
||||||
{
|
|
||||||
int socketDescriptor = context.RequestData.ReadInt32();
|
|
||||||
|
|
||||||
Logger.Stub?.PrintStub(LogClass.ServiceNifm, new { socketDescriptor });
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(25)]
|
|
||||||
// UnregisterSocketDescriptor(s32)
|
|
||||||
public ResultCode UnregisterSocketDescriptor(ServiceCtx context)
|
|
||||||
{
|
|
||||||
int socketDescriptor = context.RequestData.ReadInt32();
|
|
||||||
|
|
||||||
Logger.Stub?.PrintStub(LogClass.ServiceNifm, new { socketDescriptor });
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,8 +245,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(arguments.NvMapHandle);
|
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(Owner, arguments.NvMapHandle);
|
||||||
|
|
||||||
if (map == null)
|
if (map == null)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceNv, $"Invalid NvMap handle 0x{arguments.NvMapHandle:x8}!");
|
Logger.Warning?.Print(LogClass.ServiceNv, $"Invalid NvMap handle 0x{arguments.NvMapHandle:x8}!");
|
||||||
@@ -282,7 +282,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||||||
{
|
{
|
||||||
if (_asContext.ValidateFixedBuffer(arguments.Offset, size, pageSize))
|
if (_asContext.ValidateFixedBuffer(arguments.Offset, size, pageSize))
|
||||||
{
|
{
|
||||||
Map(physicalAddress, arguments.Offset, size, (PteKind)arguments.Kind, map.OwnerPid);
|
_asContext.Gmm.Map(physicalAddress, arguments.Offset, size, (PteKind)arguments.Kind);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -301,7 +301,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||||||
_memoryAllocator.AllocateRange(va, size, freeAddressStartPosition);
|
_memoryAllocator.AllocateRange(va, size, freeAddressStartPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map(physicalAddress, va, size, (PteKind)arguments.Kind, map.OwnerPid);
|
_asContext.Gmm.Map(physicalAddress, va, size, (PteKind)arguments.Kind);
|
||||||
arguments.Offset = va;
|
arguments.Offset = va;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,8 +380,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||||||
ulong mapOffs = (ulong)argument.MapOffset << 16;
|
ulong mapOffs = (ulong)argument.MapOffset << 16;
|
||||||
PteKind kind = (PteKind)argument.Kind;
|
PteKind kind = (PteKind)argument.Kind;
|
||||||
|
|
||||||
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(nvmapHandle);
|
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(Owner, nvmapHandle);
|
||||||
|
|
||||||
if (map == null)
|
if (map == null)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceNv, $"Invalid NvMap handle 0x{nvmapHandle:x8}!");
|
Logger.Warning?.Print(LogClass.ServiceNv, $"Invalid NvMap handle 0x{nvmapHandle:x8}!");
|
||||||
@@ -389,25 +389,13 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostAsGpu
|
|||||||
return NvInternalResult.InvalidInput;
|
return NvInternalResult.InvalidInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map(mapOffs + map.Address, gpuVa, size, kind, map.OwnerPid);
|
gmm.Map(mapOffs + map.Address, gpuVa, size, kind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NvInternalResult.Success;
|
return NvInternalResult.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Map(ulong pa, ulong va, ulong size, PteKind kind, ulong ownerPid)
|
|
||||||
{
|
|
||||||
if (Owner == ownerPid)
|
|
||||||
{
|
|
||||||
_asContext.Gmm.Map(pa, va, size, kind);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_asContext.Gmm.MapForeign(pa, va, size, kind, ownerPid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Close() { }
|
public override void Close() { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,8 +167,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||||||
|
|
||||||
foreach (CommandBuffer commandBuffer in commandBuffers)
|
foreach (CommandBuffer commandBuffer in commandBuffers)
|
||||||
{
|
{
|
||||||
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(commandBuffer.Mem);
|
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(Owner, commandBuffer.Mem);
|
||||||
|
|
||||||
ReadOnlySpan<byte> data = _memory.GetSpan(map.Address + commandBuffer.Offset, commandBuffer.WordsCount * 4);
|
ReadOnlySpan<byte> data = _memory.GetSpan(map.Address + commandBuffer.Offset, commandBuffer.WordsCount * 4);
|
||||||
|
|
||||||
_host1xContext.Host1x.Submit(MemoryMarshal.Cast<byte, int>(data), _contextId);
|
_host1xContext.Host1x.Submit(MemoryMarshal.Cast<byte, int>(data), _contextId);
|
||||||
@@ -237,8 +237,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||||||
|
|
||||||
foreach (ref CommandBufferHandle commandBufferEntry in commandBufferEntries)
|
foreach (ref CommandBufferHandle commandBufferEntry in commandBufferEntries)
|
||||||
{
|
{
|
||||||
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(commandBufferEntry.MapHandle);
|
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(Owner, commandBufferEntry.MapHandle);
|
||||||
|
|
||||||
if (map == null)
|
if (map == null)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceNv, $"Invalid handle 0x{commandBufferEntry.MapHandle:x8}!");
|
Logger.Warning?.Print(LogClass.ServiceNv, $"Invalid handle 0x{commandBufferEntry.MapHandle:x8}!");
|
||||||
@@ -279,8 +279,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostChannel
|
|||||||
|
|
||||||
foreach (ref CommandBufferHandle commandBufferEntry in commandBufferEntries)
|
foreach (ref CommandBufferHandle commandBufferEntry in commandBufferEntries)
|
||||||
{
|
{
|
||||||
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(commandBufferEntry.MapHandle);
|
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(Owner, commandBufferEntry.MapHandle);
|
||||||
|
|
||||||
if (map == null)
|
if (map == null)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceNv, $"Invalid handle 0x{commandBufferEntry.MapHandle:x8}!");
|
Logger.Warning?.Print(LogClass.ServiceNv, $"Invalid handle 0x{commandBufferEntry.MapHandle:x8}!");
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||||||
|
|
||||||
uint size = BitUtils.AlignUp(arguments.Size, (uint)MemoryManager.PageSize);
|
uint size = BitUtils.AlignUp(arguments.Size, (uint)MemoryManager.PageSize);
|
||||||
|
|
||||||
arguments.Handle = CreateHandleFromMap(new NvMapHandle(size) { OwnerPid = Owner });
|
arguments.Handle = CreateHandleFromMap(new NvMapHandle(size));
|
||||||
|
|
||||||
Logger.Debug?.Print(LogClass.ServiceNv, $"Created map {arguments.Handle} with size 0x{size:x8}!");
|
Logger.Debug?.Print(LogClass.ServiceNv, $"Created map {arguments.Handle} with size 0x{size:x8}!");
|
||||||
|
|
||||||
return NvInternalResult.Success;
|
return NvInternalResult.Success;
|
||||||
@@ -80,8 +80,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||||||
|
|
||||||
private NvInternalResult FromId(ref NvMapFromId arguments)
|
private NvInternalResult FromId(ref NvMapFromId arguments)
|
||||||
{
|
{
|
||||||
NvMapHandle map = GetMapFromHandle(arguments.Id);
|
NvMapHandle map = GetMapFromHandle(Owner, arguments.Id);
|
||||||
|
|
||||||
if (map == null)
|
if (map == null)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceNv, $"Invalid handle 0x{arguments.Handle:x8}!");
|
Logger.Warning?.Print(LogClass.ServiceNv, $"Invalid handle 0x{arguments.Handle:x8}!");
|
||||||
@@ -98,8 +98,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||||||
|
|
||||||
private NvInternalResult Alloc(ref NvMapAlloc arguments)
|
private NvInternalResult Alloc(ref NvMapAlloc arguments)
|
||||||
{
|
{
|
||||||
NvMapHandle map = GetMapFromHandle(arguments.Handle);
|
NvMapHandle map = GetMapFromHandle(Owner, arguments.Handle);
|
||||||
|
|
||||||
if (map == null)
|
if (map == null)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceNv, $"Invalid handle 0x{arguments.Handle:x8}!");
|
Logger.Warning?.Print(LogClass.ServiceNv, $"Invalid handle 0x{arguments.Handle:x8}!");
|
||||||
@@ -152,8 +152,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||||||
|
|
||||||
private NvInternalResult Free(ref NvMapFree arguments)
|
private NvInternalResult Free(ref NvMapFree arguments)
|
||||||
{
|
{
|
||||||
NvMapHandle map = GetMapFromHandle(arguments.Handle);
|
NvMapHandle map = GetMapFromHandle(Owner, arguments.Handle);
|
||||||
|
|
||||||
if (map == null)
|
if (map == null)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceNv, $"Invalid handle 0x{arguments.Handle:x8}!");
|
Logger.Warning?.Print(LogClass.ServiceNv, $"Invalid handle 0x{arguments.Handle:x8}!");
|
||||||
@@ -179,8 +179,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||||||
|
|
||||||
private NvInternalResult Param(ref NvMapParam arguments)
|
private NvInternalResult Param(ref NvMapParam arguments)
|
||||||
{
|
{
|
||||||
NvMapHandle map = GetMapFromHandle(arguments.Handle);
|
NvMapHandle map = GetMapFromHandle(Owner, arguments.Handle);
|
||||||
|
|
||||||
if (map == null)
|
if (map == null)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceNv, $"Invalid handle 0x{arguments.Handle:x8}!");
|
Logger.Warning?.Print(LogClass.ServiceNv, $"Invalid handle 0x{arguments.Handle:x8}!");
|
||||||
@@ -217,8 +217,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||||||
|
|
||||||
private NvInternalResult GetId(ref NvMapGetId arguments)
|
private NvInternalResult GetId(ref NvMapGetId arguments)
|
||||||
{
|
{
|
||||||
NvMapHandle map = GetMapFromHandle(arguments.Handle);
|
NvMapHandle map = GetMapFromHandle(Owner, arguments.Handle);
|
||||||
|
|
||||||
if (map == null)
|
if (map == null)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.ServiceNv, $"Invalid handle 0x{arguments.Handle:x8}!");
|
Logger.Warning?.Print(LogClass.ServiceNv, $"Invalid handle 0x{arguments.Handle:x8}!");
|
||||||
@@ -237,30 +237,25 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||||||
// _maps.TryRemove(GetOwner(), out _);
|
// _maps.TryRemove(GetOwner(), out _);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int CreateMap(ulong pid, ulong address, uint size)
|
private int CreateHandleFromMap(NvMapHandle map)
|
||||||
{
|
|
||||||
return CreateHandleFromMap(new NvMapHandle(size) { Address = address, OwnerPid = pid });
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int CreateHandleFromMap(NvMapHandle map)
|
|
||||||
{
|
{
|
||||||
return _maps.Add(map);
|
return _maps.Add(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool DeleteMapWithHandle(int handle)
|
private static bool DeleteMapWithHandle(ulong pid, int handle)
|
||||||
{
|
{
|
||||||
return _maps.Delete(handle) != null;
|
return _maps.Delete(handle) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void IncrementMapRefCount(ulong pid, int handle)
|
public static void IncrementMapRefCount(ulong pid, int handle)
|
||||||
{
|
{
|
||||||
GetMapFromHandle(handle)?.IncrementRefCount();
|
GetMapFromHandle(pid, handle)?.IncrementRefCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool DecrementMapRefCount(ulong pid, int handle)
|
public static bool DecrementMapRefCount(ulong pid, int handle)
|
||||||
{
|
{
|
||||||
NvMapHandle map = GetMapFromHandle(handle);
|
NvMapHandle map = GetMapFromHandle(pid, handle);
|
||||||
|
|
||||||
if (map == null)
|
if (map == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -268,8 +263,8 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||||||
|
|
||||||
if (map.DecrementRefCount() <= 0)
|
if (map.DecrementRefCount() <= 0)
|
||||||
{
|
{
|
||||||
DeleteMapWithHandle(handle);
|
DeleteMapWithHandle(pid, handle);
|
||||||
|
|
||||||
Logger.Debug?.Print(LogClass.ServiceNv, $"Deleted map {handle}!");
|
Logger.Debug?.Print(LogClass.ServiceNv, $"Deleted map {handle}!");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -280,7 +275,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NvMapHandle GetMapFromHandle(int handle)
|
public static NvMapHandle GetMapFromHandle(ulong pid, int handle)
|
||||||
{
|
{
|
||||||
return _maps.Get(handle);
|
return _maps.Get(handle);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ namespace Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap
|
|||||||
public ulong Address;
|
public ulong Address;
|
||||||
public bool Allocated;
|
public bool Allocated;
|
||||||
public ulong DmaMapAddress;
|
public ulong DmaMapAddress;
|
||||||
public ulong OwnerPid;
|
|
||||||
|
|
||||||
private long _dupes;
|
private long _dupes;
|
||||||
|
|
||||||
public NvMapHandle()
|
public NvMapHandle()
|
||||||
|
|||||||
@@ -172,15 +172,6 @@ namespace Ryujinx.HLE.HOS.Services
|
|||||||
{
|
{
|
||||||
ServerLoop();
|
ServerLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual ulong CalculateRequiredHeapSize()
|
|
||||||
{
|
|
||||||
return 0UL;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void CustomInit(KernelContext context, ulong pid, ulong heapAddress)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ServerLoop()
|
private void ServerLoop()
|
||||||
{
|
{
|
||||||
@@ -205,14 +196,10 @@ namespace Ryujinx.HLE.HOS.Services
|
|||||||
Result result = _selfProcess.HandleTable.GenerateHandle(_wakeEvent.ReadableEvent, out _wakeHandle);
|
Result result = _selfProcess.HandleTable.GenerateHandle(_wakeEvent.ReadableEvent, out _wakeHandle);
|
||||||
|
|
||||||
InitDone.Set();
|
InitDone.Set();
|
||||||
|
|
||||||
ulong heapSize = CalculateRequiredHeapSize() + PointerBufferSize;
|
|
||||||
|
|
||||||
ulong messagePtr = _selfThread.TlsAddress;
|
ulong messagePtr = _selfThread.TlsAddress;
|
||||||
_context.Syscall.SetHeapSize(out ulong heapAddr, BitUtils.AlignUp(heapSize, 0x200000UL));
|
_context.Syscall.SetHeapSize(out ulong heapAddr, 0x200000);
|
||||||
|
|
||||||
CustomInit(_context, _selfProcess.Pid, heapAddr + PointerBufferSize);
|
|
||||||
|
|
||||||
_selfProcess.CpuMemory.Write(messagePtr + 0x0, 0);
|
_selfProcess.CpuMemory.Write(messagePtr + 0x0, 0);
|
||||||
_selfProcess.CpuMemory.Write(messagePtr + 0x4, 2 << 10);
|
_selfProcess.CpuMemory.Write(messagePtr + 0x4, 2 << 10);
|
||||||
_selfProcess.CpuMemory.Write(messagePtr + 0x8, heapAddr | ((ulong)PointerBufferSize << 48));
|
_selfProcess.CpuMemory.Write(messagePtr + 0x8, heapAddr | ((ulong)PointerBufferSize << 48));
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
|||||||
{
|
{
|
||||||
if (errorCode != LinuxError.SUCCESS)
|
if (errorCode != LinuxError.SUCCESS)
|
||||||
{
|
{
|
||||||
|
if (errorCode != LinuxError.EWOULDBLOCK)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Operation failed with error {errorCode}.");
|
||||||
|
}
|
||||||
result = -1;
|
result = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +70,8 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
|||||||
BsdSocketType type = (BsdSocketType)context.RequestData.ReadInt32();
|
BsdSocketType type = (BsdSocketType)context.RequestData.ReadInt32();
|
||||||
ProtocolType protocol = (ProtocolType)context.RequestData.ReadInt32();
|
ProtocolType protocol = (ProtocolType)context.RequestData.ReadInt32();
|
||||||
|
|
||||||
|
Logger.Info?.PrintMsg(LogClass.ServiceBsd, $"Creating socket with domain={domain}, type={type}, protocol={protocol}");
|
||||||
|
|
||||||
BsdSocketCreationFlags creationFlags = (BsdSocketCreationFlags)((int)type >> (int)BsdSocketCreationFlags.FlagsShift);
|
BsdSocketCreationFlags creationFlags = (BsdSocketCreationFlags)((int)type >> (int)BsdSocketCreationFlags.FlagsShift);
|
||||||
type &= BsdSocketType.TypeMask;
|
type &= BsdSocketType.TypeMask;
|
||||||
|
|
||||||
@@ -95,12 +101,21 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ISocket newBsdSocket = new ManagedSocket(netDomain, (SocketType)type, protocol, context.Device.Configuration.MultiplayerLanInterfaceId)
|
|
||||||
{
|
|
||||||
Blocking = !creationFlags.HasFlag(BsdSocketCreationFlags.NonBlocking),
|
|
||||||
};
|
|
||||||
|
|
||||||
LinuxError errno = LinuxError.SUCCESS;
|
LinuxError errno = LinuxError.SUCCESS;
|
||||||
|
ISocket newBsdSocket;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
newBsdSocket = new ManagedSocket(netDomain, (SocketType)type, protocol, context.Device.Configuration.MultiplayerLanInterfaceId)
|
||||||
|
{
|
||||||
|
Blocking = !creationFlags.HasFlag(BsdSocketCreationFlags.NonBlocking),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (SocketException exception)
|
||||||
|
{
|
||||||
|
LinuxError errNo = WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
|
return WriteBsdResult(context, 0, errNo);
|
||||||
|
}
|
||||||
|
|
||||||
int newSockFd = _context.RegisterFileDescriptor(newBsdSocket);
|
int newSockFd = _context.RegisterFileDescriptor(newBsdSocket);
|
||||||
|
|
||||||
@@ -111,6 +126,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
|||||||
|
|
||||||
if (exempt)
|
if (exempt)
|
||||||
{
|
{
|
||||||
|
Logger.Info?.Print(LogClass.ServiceBsd, "Disconnecting exempt socket.");
|
||||||
newBsdSocket.Disconnect();
|
newBsdSocket.Disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -797,7 +813,11 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd
|
|||||||
{
|
{
|
||||||
errno = socket.Listen(backlog);
|
errno = socket.Listen(backlog);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.Warning?.PrintMsg(LogClass.ServiceBsd, $"Invalid socket fd '{socketFd}'.");
|
||||||
|
}
|
||||||
|
|
||||||
return WriteBsdResult(context, 0, errno);
|
return WriteBsdResult(context, 0, errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,18 +92,30 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
{
|
{
|
||||||
newSocket = new ManagedSocket(Socket.Accept());
|
newSocket = new ManagedSocket(Socket.Accept());
|
||||||
|
|
||||||
|
IPEndPoint remoteEndPoint = newSocket.RemoteEndPoint;
|
||||||
|
bool isPrivateIp = remoteEndPoint.Address.ToString().StartsWith("192.168.");
|
||||||
|
Logger.Info?.PrintMsg(LogClass.ServiceBsd,
|
||||||
|
isPrivateIp
|
||||||
|
? $"Accepted connection from {ProtocolType}/{remoteEndPoint.Address}:{remoteEndPoint.Port}"
|
||||||
|
: $"Accepted connection from {ProtocolType}/***:{remoteEndPoint.Port}");
|
||||||
|
|
||||||
return LinuxError.SUCCESS;
|
return LinuxError.SUCCESS;
|
||||||
}
|
}
|
||||||
catch (SocketException exception)
|
catch (SocketException exception)
|
||||||
{
|
{
|
||||||
newSocket = null;
|
newSocket = null;
|
||||||
|
|
||||||
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
|
}
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinuxError Bind(IPEndPoint localEndPoint)
|
public LinuxError Bind(IPEndPoint localEndPoint)
|
||||||
{
|
{
|
||||||
|
Logger.Info?.PrintMsg(LogClass.ServiceBsd, $"Socket binding to: {ProtocolType}/{localEndPoint.Port}");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Socket.Bind(localEndPoint);
|
Socket.Bind(localEndPoint);
|
||||||
@@ -112,6 +124,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
}
|
}
|
||||||
catch (SocketException exception)
|
catch (SocketException exception)
|
||||||
{
|
{
|
||||||
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
|
}
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,6 +139,15 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
|
|
||||||
public LinuxError Connect(IPEndPoint remoteEndPoint)
|
public LinuxError Connect(IPEndPoint remoteEndPoint)
|
||||||
{
|
{
|
||||||
|
bool isLDNPrivateIP = remoteEndPoint.Address.ToString().StartsWith("192.168.");
|
||||||
|
if (isLDNPrivateIP)
|
||||||
|
{
|
||||||
|
Logger.Info?.PrintMsg(LogClass.ServiceBsd, $"Connecting to: {ProtocolType}/{remoteEndPoint.Address}:{remoteEndPoint.Port}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.Info?.PrintMsg(LogClass.ServiceBsd, $"Connecting to: {ProtocolType}/***:{remoteEndPoint.Port}");
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Socket.Connect(remoteEndPoint);
|
Socket.Connect(remoteEndPoint);
|
||||||
@@ -137,6 +162,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
|
}
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -144,11 +173,13 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
|
|
||||||
public void Disconnect()
|
public void Disconnect()
|
||||||
{
|
{
|
||||||
|
Logger.Info?.Print(LogClass.ServiceBsd, "Socket disconnecting");
|
||||||
Socket.Disconnect(true);
|
Socket.Disconnect(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
Logger.Info?.Print(LogClass.ServiceBsd, "Socket closed");
|
||||||
Socket.Close();
|
Socket.Close();
|
||||||
Socket.Dispose();
|
Socket.Dispose();
|
||||||
}
|
}
|
||||||
@@ -159,10 +190,16 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
{
|
{
|
||||||
Socket.Listen(backlog);
|
Socket.Listen(backlog);
|
||||||
|
|
||||||
|
Logger.Info?.PrintMsg(LogClass.ServiceBsd, $"Socket listening: {ProtocolType}/{(Socket.LocalEndPoint as IPEndPoint).Port}");
|
||||||
|
|
||||||
return LinuxError.SUCCESS;
|
return LinuxError.SUCCESS;
|
||||||
}
|
}
|
||||||
catch (SocketException exception)
|
catch (SocketException exception)
|
||||||
{
|
{
|
||||||
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
|
}
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -182,11 +219,15 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
}
|
}
|
||||||
catch (SocketException exception)
|
catch (SocketException exception)
|
||||||
{
|
{
|
||||||
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
|
}
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasEmittedBlockingWarning = false;
|
private bool _hasEmittedBlockingWarning;
|
||||||
|
|
||||||
public LinuxError Receive(out int receiveSize, Span<byte> buffer, BsdSocketFlags flags)
|
public LinuxError Receive(out int receiveSize, Span<byte> buffer, BsdSocketFlags flags)
|
||||||
{
|
{
|
||||||
@@ -202,10 +243,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
shouldBlockAfterOperation = true;
|
shouldBlockAfterOperation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Blocking && !hasEmittedBlockingWarning)
|
if (Blocking && !_hasEmittedBlockingWarning)
|
||||||
{
|
{
|
||||||
Logger.Warning?.PrintMsg(LogClass.ServiceBsd, "Blocking socket operations are not yet working properly. Expect network errors.");
|
Logger.Warning?.PrintMsg(LogClass.ServiceBsd, "Blocking socket operations are not yet working properly. Expect network errors.");
|
||||||
hasEmittedBlockingWarning = true;
|
_hasEmittedBlockingWarning = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
receiveSize = Socket.Receive(buffer, ConvertBsdSocketFlags(flags));
|
receiveSize = Socket.Receive(buffer, ConvertBsdSocketFlags(flags));
|
||||||
@@ -214,6 +255,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
}
|
}
|
||||||
catch (SocketException exception)
|
catch (SocketException exception)
|
||||||
{
|
{
|
||||||
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
|
}
|
||||||
receiveSize = -1;
|
receiveSize = -1;
|
||||||
|
|
||||||
result = WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
result = WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
@@ -245,10 +290,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
shouldBlockAfterOperation = true;
|
shouldBlockAfterOperation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Blocking && !hasEmittedBlockingWarning)
|
if (Blocking && !_hasEmittedBlockingWarning)
|
||||||
{
|
{
|
||||||
Logger.Warning?.PrintMsg(LogClass.ServiceBsd, "Blocking socket operations are not yet working properly. Expect network errors.");
|
Logger.Warning?.PrintMsg(LogClass.ServiceBsd, "Blocking socket operations are not yet working properly. Expect network errors.");
|
||||||
hasEmittedBlockingWarning = true;
|
_hasEmittedBlockingWarning = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Socket.IsBound)
|
if (!Socket.IsBound)
|
||||||
@@ -265,6 +310,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
}
|
}
|
||||||
catch (SocketException exception)
|
catch (SocketException exception)
|
||||||
{
|
{
|
||||||
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
|
}
|
||||||
receiveSize = -1;
|
receiveSize = -1;
|
||||||
|
|
||||||
result = WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
result = WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
@@ -288,6 +337,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
}
|
}
|
||||||
catch (SocketException exception)
|
catch (SocketException exception)
|
||||||
{
|
{
|
||||||
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
|
}
|
||||||
sendSize = -1;
|
sendSize = -1;
|
||||||
|
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
@@ -304,6 +357,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
}
|
}
|
||||||
catch (SocketException exception)
|
catch (SocketException exception)
|
||||||
{
|
{
|
||||||
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
|
}
|
||||||
sendSize = -1;
|
sendSize = -1;
|
||||||
|
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
@@ -341,6 +398,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
}
|
}
|
||||||
catch (SocketException exception)
|
catch (SocketException exception)
|
||||||
{
|
{
|
||||||
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
|
}
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -387,6 +448,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
}
|
}
|
||||||
catch (SocketException exception)
|
catch (SocketException exception)
|
||||||
{
|
{
|
||||||
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
|
}
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -519,6 +584,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
}
|
}
|
||||||
catch (SocketException exception)
|
catch (SocketException exception)
|
||||||
{
|
{
|
||||||
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
|
}
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -557,6 +626,10 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
}
|
}
|
||||||
catch (SocketException exception)
|
catch (SocketException exception)
|
||||||
{
|
{
|
||||||
|
if (exception.SocketErrorCode != SocketError.WouldBlock)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.ServiceBsd, $"Socket Exception: {exception}");
|
||||||
|
}
|
||||||
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
return WinSockHelper.ConvertError((WsaError)exception.ErrorCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy;
|
using Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy;
|
||||||
|
using Ryujinx.HLE.HOS.Services.Sockets.Bsd.Types;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -64,10 +66,18 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Proxy
|
|||||||
{
|
{
|
||||||
if (_proxy.Supported(domain, type, protocol))
|
if (_proxy.Supported(domain, type, protocol))
|
||||||
{
|
{
|
||||||
|
Logger.Info?.PrintMsg(LogClass.ServiceBsd, $"Socket is using LDN proxy");
|
||||||
return new LdnProxySocket(domain, type, protocol, _proxy);
|
return new LdnProxySocket(domain, type, protocol, _proxy);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.Warning?.PrintMsg(LogClass.ServiceBsd, $"LDN proxy does not support socket {domain}, {type}, {protocol}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.Info?.PrintMsg(LogClass.ServiceBsd, $"Opening socket using host networking stack");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DefaultSocket(domain, type, protocol, lanInterfaceId);
|
return new DefaultSocket(domain, type, protocol, lanInterfaceId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using Ryujinx.Common.Logging;
|
|||||||
using Ryujinx.Common.PreciseSleep;
|
using Ryujinx.Common.PreciseSleep;
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.Gpu;
|
using Ryujinx.Graphics.Gpu;
|
||||||
using Ryujinx.HLE.HOS.Kernel.Process;
|
|
||||||
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap;
|
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -39,6 +38,8 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||||||
|
|
||||||
private readonly Lock _lock = new();
|
private readonly Lock _lock = new();
|
||||||
|
|
||||||
|
public long RenderLayerId { get; private set; }
|
||||||
|
|
||||||
private class Layer
|
private class Layer
|
||||||
{
|
{
|
||||||
public int ProducerBinderId;
|
public int ProducerBinderId;
|
||||||
@@ -59,6 +60,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||||||
{
|
{
|
||||||
_device = device;
|
_device = device;
|
||||||
_layers = new Dictionary<long, Layer>();
|
_layers = new Dictionary<long, Layer>();
|
||||||
|
RenderLayerId = 0;
|
||||||
|
|
||||||
_composerThread = new Thread(HandleComposition)
|
_composerThread = new Thread(HandleComposition)
|
||||||
{
|
{
|
||||||
@@ -237,12 +239,34 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||||||
|
|
||||||
private void CloseLayer(long layerId, Layer layer)
|
private void CloseLayer(long layerId, Layer layer)
|
||||||
{
|
{
|
||||||
|
// If the layer was removed and the current in use, we need to change the current layer in use.
|
||||||
|
if (RenderLayerId == layerId)
|
||||||
|
{
|
||||||
|
// If no layer is availaible, reset to default value.
|
||||||
|
if (_layers.Count == 0)
|
||||||
|
{
|
||||||
|
SetRenderLayer(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetRenderLayer(_layers.Last().Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (layer.State == LayerState.ManagedOpened)
|
if (layer.State == LayerState.ManagedOpened)
|
||||||
{
|
{
|
||||||
layer.State = LayerState.ManagedClosed;
|
layer.State = LayerState.ManagedClosed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetRenderLayer(long layerId)
|
||||||
|
{
|
||||||
|
lock (_lock)
|
||||||
|
{
|
||||||
|
RenderLayerId = layerId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Layer GetLayerByIdLocked(long layerId)
|
private Layer GetLayerByIdLocked(long layerId)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<long, Layer> pair in _layers)
|
foreach (KeyValuePair<long, Layer> pair in _layers)
|
||||||
@@ -336,55 +360,41 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
foreach (var (layerId, layer) in _layers)
|
// TODO: support multilayers (& multidisplay ?)
|
||||||
|
if (RenderLayerId == 0)
|
||||||
{
|
{
|
||||||
if (layer.State == LayerState.NotInitialized || layer.State == LayerState.ManagedClosed)
|
return;
|
||||||
continue;
|
}
|
||||||
|
|
||||||
if (_device.System.KernelContext.Processes.TryGetValue(layer.Owner, out var process))
|
|
||||||
{
|
|
||||||
if (process.State == ProcessState.Exiting || process.State == ProcessState.Exited)
|
|
||||||
{
|
|
||||||
HOSBinderDriverServer.UnregisterBinderObject(layer.ProducerBinderId);
|
|
||||||
|
|
||||||
if (_layers.Remove(layerId))
|
Layer layer = GetLayerByIdLocked(RenderLayerId);
|
||||||
{
|
|
||||||
CloseLayer(layerId, layer);
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
Status acquireStatus = layer.Consumer.AcquireBuffer(out BufferItem item, 0);
|
||||||
}
|
|
||||||
}
|
if (acquireStatus == Status.Success)
|
||||||
|
{
|
||||||
Status acquireStatus = layer.Consumer.AcquireBuffer(out BufferItem item, 0);
|
if (_device.VSyncMode == VSyncMode.Unbounded)
|
||||||
|
|
||||||
if (acquireStatus == Status.Success)
|
|
||||||
{
|
{
|
||||||
if (_device.VSyncMode == VSyncMode.Unbounded)
|
if (_swapInterval != 0)
|
||||||
{
|
{
|
||||||
if (_swapInterval != 0)
|
UpdateSwapInterval(0);
|
||||||
{
|
|
||||||
UpdateSwapInterval(0);
|
|
||||||
_vSyncMode = _device.VSyncMode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (_device.VSyncMode != _vSyncMode)
|
|
||||||
{
|
|
||||||
UpdateSwapInterval(_device.VSyncMode == VSyncMode.Unbounded ? 0 : item.SwapInterval);
|
|
||||||
_vSyncMode = _device.VSyncMode;
|
_vSyncMode = _device.VSyncMode;
|
||||||
}
|
}
|
||||||
else if (item.SwapInterval != _swapInterval || _device.TargetVSyncInterval != _targetVSyncInterval)
|
|
||||||
{
|
|
||||||
UpdateSwapInterval(item.SwapInterval);
|
|
||||||
}
|
|
||||||
|
|
||||||
PostFrameBuffer(layer, item);
|
|
||||||
}
|
}
|
||||||
else if (acquireStatus != Status.NoBufferAvailaible && acquireStatus != Status.InvalidOperation)
|
else if (_device.VSyncMode != _vSyncMode)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.SurfaceFlinger, $"Failed to acquire buffer for layer {layerId} (status: {acquireStatus})");
|
UpdateSwapInterval(_device.VSyncMode == VSyncMode.Unbounded ? 0 : item.SwapInterval);
|
||||||
continue;
|
_vSyncMode = _device.VSyncMode;
|
||||||
}
|
}
|
||||||
|
else if (item.SwapInterval != _swapInterval || _device.TargetVSyncInterval != _targetVSyncInterval)
|
||||||
|
{
|
||||||
|
UpdateSwapInterval(item.SwapInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
PostFrameBuffer(layer, item);
|
||||||
|
}
|
||||||
|
else if (acquireStatus != Status.NoBufferAvailaible && acquireStatus != Status.InvalidOperation)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -403,8 +413,8 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||||||
|
|
||||||
ulong bufferOffset = (ulong)item.GraphicBuffer.Object.Buffer.Surfaces[0].Offset;
|
ulong bufferOffset = (ulong)item.GraphicBuffer.Object.Buffer.Surfaces[0].Offset;
|
||||||
|
|
||||||
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(nvMapHandle);
|
NvMapHandle map = NvMapDeviceFile.GetMapFromHandle(layer.Owner, nvMapHandle);
|
||||||
|
|
||||||
ulong frameBufferAddress = map.Address + bufferOffset;
|
ulong frameBufferAddress = map.Address + bufferOffset;
|
||||||
|
|
||||||
Format format = ConvertColorFormat(item.GraphicBuffer.Object.Buffer.Surfaces[0].ColorFormat);
|
Format format = ConvertColorFormat(item.GraphicBuffer.Object.Buffer.Surfaces[0].ColorFormat);
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using Ryujinx.Common.Memory;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
||||||
@@ -37,6 +36,6 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||||||
public int PlanesCount;
|
public int PlanesCount;
|
||||||
|
|
||||||
[FieldOffset(0x34)]
|
[FieldOffset(0x34)]
|
||||||
public Array3<NvGraphicBufferSurface> Surfaces;
|
public NvGraphicBufferSurfaceArray Surfaces;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService
|
|||||||
ulong pid = context.Device.System.AppletState.AppletResourceUserIds.GetData<ulong>((int)appletResourceUserId);
|
ulong pid = context.Device.System.AppletState.AppletResourceUserIds.GetData<ulong>((int)appletResourceUserId);
|
||||||
|
|
||||||
context.Device.System.SurfaceFlinger.CreateLayer(out long layerId, pid);
|
context.Device.System.SurfaceFlinger.CreateLayer(out long layerId, pid);
|
||||||
|
context.Device.System.SurfaceFlinger.SetRenderLayer(layerId);
|
||||||
|
|
||||||
context.ResponseData.Write(layerId);
|
context.ResponseData.Write(layerId);
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,4 @@
|
|||||||
using Ryujinx.Common;
|
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.HLE.HOS.Ipc;
|
|
||||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
|
||||||
using Ryujinx.HLE.HOS.Services.SurfaceFlinger;
|
|
||||||
using Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService.Types.Fbshare;
|
|
||||||
using Ryujinx.Horizon.Common;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService
|
namespace Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService
|
||||||
{
|
{
|
||||||
@@ -14,9 +7,6 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService
|
|||||||
#pragma warning disable IDE0052 // Remove unread private member
|
#pragma warning disable IDE0052 // Remove unread private member
|
||||||
private readonly IApplicationDisplayService _applicationDisplayService;
|
private readonly IApplicationDisplayService _applicationDisplayService;
|
||||||
#pragma warning restore IDE0052
|
#pragma warning restore IDE0052
|
||||||
|
|
||||||
private KEvent _sharedFramebufferAcquirableEvent;
|
|
||||||
private int _sharedFramebufferAcquirableEventHandle;
|
|
||||||
|
|
||||||
public ISystemDisplayService(IApplicationDisplayService applicationDisplayService)
|
public ISystemDisplayService(IApplicationDisplayService applicationDisplayService)
|
||||||
{
|
{
|
||||||
@@ -67,138 +57,5 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService
|
|||||||
|
|
||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
[CommandCmif(8225)] // 4.0.0+
|
|
||||||
// GetSharedBufferMemoryHandleId()
|
|
||||||
public ResultCode GetSharedBufferMemoryHandleId(ServiceCtx context)
|
|
||||||
{
|
|
||||||
context.ResponseData.Write((ulong)context.Device.System.ViServerS.GetSharedBufferNvMapId());
|
|
||||||
context.ResponseData.Write(context.Device.System.ViServerS.GetSharedBufferSize());
|
|
||||||
|
|
||||||
(ulong mapAddress, ulong mapSize) = context.Request.GetBufferType0x22();
|
|
||||||
|
|
||||||
context.Memory.Write(mapAddress, context.Device.System.ViServerS.GetSharedBufferMap());
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(8250)] // 4.0.0+
|
|
||||||
// OpenSharedLayer(nn::vi::fbshare::SharedLayerHandle, nn::applet::AppletResourceUserId, pid)
|
|
||||||
public ResultCode OpenSharedLayer(ServiceCtx context)
|
|
||||||
{
|
|
||||||
long sharedLayerHandle = context.RequestData.ReadInt64();
|
|
||||||
long appletResourceUserId = context.RequestData.ReadInt64();
|
|
||||||
|
|
||||||
context.Device.System.ViServerS.OpenSharedLayer(sharedLayerHandle);
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(8251)] // 4.0.0+
|
|
||||||
// CloseSharedLayer(nn::vi::fbshare::SharedLayerHandle)
|
|
||||||
public ResultCode CloseSharedLayer(ServiceCtx context)
|
|
||||||
{
|
|
||||||
long sharedLayerHandle = context.RequestData.ReadInt64();
|
|
||||||
|
|
||||||
context.Device.System.ViServerS.CloseSharedLayer(sharedLayerHandle);
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(8252)] // 4.0.0+
|
|
||||||
// ConnectSharedLayer(nn::vi::fbshare::SharedLayerHandle)
|
|
||||||
public ResultCode ConnectSharedLayer(ServiceCtx context)
|
|
||||||
{
|
|
||||||
long sharedLayerHandle = context.RequestData.ReadInt64();
|
|
||||||
|
|
||||||
context.Device.System.ViServerS.ConnectSharedLayer(sharedLayerHandle);
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(8253)] // 4.0.0+
|
|
||||||
// DisconnectSharedLayer(nn::vi::fbshare::SharedLayerHandle)
|
|
||||||
public ResultCode DisconnectSharedLayer(ServiceCtx context)
|
|
||||||
{
|
|
||||||
long sharedLayerHandle = context.RequestData.ReadInt64();
|
|
||||||
|
|
||||||
context.Device.System.ViServerS.DisconnectSharedLayer(sharedLayerHandle);
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(8254)] // 4.0.0+
|
|
||||||
// AcquireSharedFrameBuffer(nn::vi::fbshare::SharedLayerHandle) -> (nn::vi::native::NativeSync, nn::vi::fbshare::SharedLayerTextureIndexList, u64)
|
|
||||||
public ResultCode AcquireSharedFrameBuffer(ServiceCtx context)
|
|
||||||
{
|
|
||||||
long sharedLayerHandle = context.RequestData.ReadInt64();
|
|
||||||
|
|
||||||
int slot = context.Device.System.ViServerS.DequeueFrameBuffer(sharedLayerHandle, out AndroidFence fence);
|
|
||||||
|
|
||||||
var indexList = new SharedLayerTextureIndexList();
|
|
||||||
|
|
||||||
for (int i = 0; i < indexList.Indices.Length; i++)
|
|
||||||
{
|
|
||||||
indexList.Indices[i] = context.Device.System.ViServerS.GetFrameBufferMapIndex(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
context.ResponseData.WriteStruct(fence);
|
|
||||||
context.ResponseData.WriteStruct(indexList);
|
|
||||||
context.ResponseData.Write(0); // Padding
|
|
||||||
context.ResponseData.Write((ulong)slot);
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(8255)] // 4.0.0+
|
|
||||||
// PresentSharedFrameBuffer(nn::vi::native::NativeSync, nn::vi::CropRegion, u32, u32, nn::vi::fbshare::SharedLayerHandle, u64)
|
|
||||||
public ResultCode PresentSharedFrameBuffer(ServiceCtx context)
|
|
||||||
{
|
|
||||||
AndroidFence nativeSync = context.RequestData.ReadStruct<AndroidFence>();
|
|
||||||
Rect cropRegion = context.RequestData.ReadStruct<Rect>();
|
|
||||||
|
|
||||||
NativeWindowTransform transform = (NativeWindowTransform)context.RequestData.ReadUInt32();
|
|
||||||
int swapInterval = context.RequestData.ReadInt32();
|
|
||||||
int padding = context.RequestData.ReadInt32();
|
|
||||||
|
|
||||||
long sharedLayerHandle = context.RequestData.ReadInt64();
|
|
||||||
ulong slot = context.RequestData.ReadUInt64();
|
|
||||||
|
|
||||||
context.Device.System.ViServerS.QueueFrameBuffer(sharedLayerHandle, (int)slot, cropRegion, transform, swapInterval, nativeSync);
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(8256)] // 4.0.0+
|
|
||||||
// GetSharedFrameBufferAcquirableEvent(nn::vi::fbshare::SharedLayerHandle) -> handle<copy>
|
|
||||||
public ResultCode GetSharedFrameBufferAcquirableEvent(ServiceCtx context)
|
|
||||||
{
|
|
||||||
if (_sharedFramebufferAcquirableEventHandle == 0)
|
|
||||||
{
|
|
||||||
_sharedFramebufferAcquirableEvent = new KEvent(context.Device.System.KernelContext);
|
|
||||||
_sharedFramebufferAcquirableEvent.WritableEvent.Signal();
|
|
||||||
|
|
||||||
if (context.Process.HandleTable.GenerateHandle(_sharedFramebufferAcquirableEvent.ReadableEvent, out _sharedFramebufferAcquirableEventHandle) != Result.Success)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("Out of handles!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_sharedFramebufferAcquirableEventHandle);
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandCmif(8258)] // 5.0.0+
|
|
||||||
// CancelSharedFrameBuffer(nn::vi::fbshare::SharedLayerHandle, u64)
|
|
||||||
public ResultCode CancelSharedFrameBuffer(ServiceCtx context)
|
|
||||||
{
|
|
||||||
long sharedLayerHandle = context.RequestData.ReadInt64();
|
|
||||||
ulong slot = context.RequestData.ReadUInt64();
|
|
||||||
|
|
||||||
context.Device.System.ViServerS.CancelFrameBuffer(sharedLayerHandle, (int)slot);
|
|
||||||
|
|
||||||
return ResultCode.Success;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
using Ryujinx.Common.Memory;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace Ryujinx.HLE.HOS.Services.Vi.RootService.ApplicationDisplayService.Types.Fbshare
|
|
||||||
{
|
|
||||||
[StructLayout(LayoutKind.Sequential, Size = 0x10, Pack = 0x4)]
|
|
||||||
struct SharedLayerTextureIndexList
|
|
||||||
{
|
|
||||||
public Array4<int> Indices;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -248,6 +248,8 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context.Device.System.SurfaceFlinger.SetRenderLayer(layerId);
|
||||||
|
|
||||||
using Parcel parcel = new(0x28, 0x4);
|
using Parcel parcel = new(0x28, 0x4);
|
||||||
|
|
||||||
parcel.WriteObject(producer, "dispdrv\0");
|
parcel.WriteObject(producer, "dispdrv\0");
|
||||||
@@ -283,7 +285,9 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService
|
|||||||
|
|
||||||
// TODO: support multi display.
|
// TODO: support multi display.
|
||||||
IBinder producer = context.Device.System.SurfaceFlinger.CreateLayer(out long layerId, 0, LayerState.Stray);
|
IBinder producer = context.Device.System.SurfaceFlinger.CreateLayer(out long layerId, 0, LayerState.Stray);
|
||||||
|
|
||||||
|
context.Device.System.SurfaceFlinger.SetRenderLayer(layerId);
|
||||||
|
|
||||||
using Parcel parcel = new(0x28, 0x4);
|
using Parcel parcel = new(0x28, 0x4);
|
||||||
|
|
||||||
parcel.WriteObject(producer, "dispdrv\0");
|
parcel.WriteObject(producer, "dispdrv\0");
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
using Ryujinx.Common.Memory;
|
|
||||||
|
|
||||||
namespace Ryujinx.HLE.HOS.Services.Vi.Types
|
|
||||||
{
|
|
||||||
struct SharedBufferMap
|
|
||||||
{
|
|
||||||
public struct Entry
|
|
||||||
{
|
|
||||||
public ulong Offset;
|
|
||||||
public ulong Size;
|
|
||||||
public uint Width;
|
|
||||||
public uint Height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Count;
|
|
||||||
public int Padding;
|
|
||||||
public Array16<Entry> SharedBuffers;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,235 +0,0 @@
|
|||||||
using Ryujinx.Common;
|
|
||||||
using Ryujinx.Graphics.Gpu;
|
|
||||||
using Ryujinx.HLE.HOS.Kernel;
|
|
||||||
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvMap;
|
|
||||||
using Ryujinx.HLE.HOS.Services.SurfaceFlinger;
|
|
||||||
using Ryujinx.HLE.HOS.Services.SurfaceFlinger.Types;
|
|
||||||
using Ryujinx.HLE.HOS.Services.Vi.Types;
|
|
||||||
using Ryujinx.Memory;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
|
|
||||||
namespace Ryujinx.HLE.HOS.Services
|
|
||||||
{
|
|
||||||
class ViServer : ServerBase
|
|
||||||
{
|
|
||||||
private const int TotalFramebuffers = 16;
|
|
||||||
|
|
||||||
private SurfaceFlinger.SurfaceFlinger _surfaceFlinger;
|
|
||||||
|
|
||||||
private readonly uint _fbWidth;
|
|
||||||
private readonly uint _fbHeight;
|
|
||||||
private readonly PixelFormat _fbFormat;
|
|
||||||
private readonly int _fbUsage;
|
|
||||||
private readonly uint _fbCount;
|
|
||||||
private uint _fbSlotsRequested;
|
|
||||||
|
|
||||||
private ulong _pid;
|
|
||||||
private ulong _fbsBaseAddress;
|
|
||||||
private int _bufferNvMapId;
|
|
||||||
private SharedBufferMap _bufferMap;
|
|
||||||
private long _sharedLayerId;
|
|
||||||
|
|
||||||
public ViServer(KernelContext context, string name) : base(context, name)
|
|
||||||
{
|
|
||||||
_fbWidth = 1280;
|
|
||||||
_fbHeight = 720;
|
|
||||||
_fbFormat = PixelFormat.Rgba8888;
|
|
||||||
_fbUsage = 0x100 | 0x200 | 0x800;
|
|
||||||
_fbCount = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override ulong CalculateRequiredHeapSize()
|
|
||||||
{
|
|
||||||
return GetSharedBufferSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void CustomInit(KernelContext context, ulong pid, ulong heapAddress)
|
|
||||||
{
|
|
||||||
_pid = pid;
|
|
||||||
_fbsBaseAddress = heapAddress;
|
|
||||||
|
|
||||||
context.Device.Gpu.RegisterProcess(pid, KernelStatic.GetCurrentProcess().CpuMemory);
|
|
||||||
|
|
||||||
ulong bufferSize = CalculateFramebufferSize();
|
|
||||||
ulong totalSize = bufferSize * TotalFramebuffers;
|
|
||||||
|
|
||||||
KernelStatic.GetCurrentProcess().CpuMemory.Fill(heapAddress, totalSize, 0xff);
|
|
||||||
|
|
||||||
int mapId = NvMapDeviceFile.CreateMap(pid, heapAddress, (uint)totalSize);
|
|
||||||
|
|
||||||
_bufferNvMapId = mapId;
|
|
||||||
_bufferMap.Count = TotalFramebuffers;
|
|
||||||
|
|
||||||
ulong offset = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < TotalFramebuffers; i++)
|
|
||||||
{
|
|
||||||
_bufferMap.SharedBuffers[i].Offset = offset;
|
|
||||||
_bufferMap.SharedBuffers[i].Size = bufferSize;
|
|
||||||
_bufferMap.SharedBuffers[i].Width = _fbWidth;
|
|
||||||
_bufferMap.SharedBuffers[i].Height = _fbHeight;
|
|
||||||
|
|
||||||
offset += bufferSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
_surfaceFlinger = context.Device.System.SurfaceFlinger;
|
|
||||||
_surfaceFlinger.CreateLayer(out _sharedLayerId, pid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OpenSharedLayer(long layerId)
|
|
||||||
{
|
|
||||||
_surfaceFlinger.OpenLayer(_pid, layerId, out _);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CloseSharedLayer(long layerId)
|
|
||||||
{
|
|
||||||
_surfaceFlinger.CloseLayer(layerId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ConnectSharedLayer(long layerId)
|
|
||||||
{
|
|
||||||
IGraphicBufferProducer producer = _surfaceFlinger.GetProducerByLayerId(layerId);
|
|
||||||
|
|
||||||
producer.Connect(null, NativeWindowApi.NVN, false, out IGraphicBufferProducer.QueueBufferOutput output);
|
|
||||||
|
|
||||||
GraphicBuffer graphicBuffer = new GraphicBuffer();
|
|
||||||
|
|
||||||
int gobHeightLog2 = 4;
|
|
||||||
int blockHeight = 8 * (1 << gobHeightLog2);
|
|
||||||
uint widthAlignedBytes = BitUtils.AlignUp(_fbWidth * 4, 64u);
|
|
||||||
uint widthAligned = widthAlignedBytes / 4;
|
|
||||||
uint heightAligned = BitUtils.AlignUp(_fbHeight, (uint)blockHeight);
|
|
||||||
uint totalSize = widthAlignedBytes * heightAligned;
|
|
||||||
|
|
||||||
graphicBuffer.Header.Magic = 0x47424652;
|
|
||||||
graphicBuffer.Header.Width = (int)_fbWidth;
|
|
||||||
graphicBuffer.Header.Height = (int)_fbHeight;
|
|
||||||
graphicBuffer.Header.Stride = (int)widthAligned;
|
|
||||||
graphicBuffer.Header.Format = _fbFormat;
|
|
||||||
graphicBuffer.Header.Usage = _fbUsage;
|
|
||||||
graphicBuffer.Header.IntsCount = (Unsafe.SizeOf<GraphicBuffer>() - Unsafe.SizeOf<GraphicBufferHeader>()) / sizeof(int);
|
|
||||||
graphicBuffer.Buffer.NvMapId = _bufferNvMapId;
|
|
||||||
graphicBuffer.Buffer.Magic = unchecked((int)0xDAFFCAFF);
|
|
||||||
graphicBuffer.Buffer.Pid = 42;
|
|
||||||
graphicBuffer.Buffer.Usage = _fbUsage;
|
|
||||||
graphicBuffer.Buffer.PixelFormat = (int)_fbFormat;
|
|
||||||
graphicBuffer.Buffer.ExternalPixelFormat = (int)_fbFormat;
|
|
||||||
graphicBuffer.Buffer.Stride = (int)widthAligned;
|
|
||||||
graphicBuffer.Buffer.FrameBufferSize = (int)totalSize;
|
|
||||||
graphicBuffer.Buffer.PlanesCount = 1;
|
|
||||||
graphicBuffer.Buffer.Surfaces[0].Width = _fbWidth;
|
|
||||||
graphicBuffer.Buffer.Surfaces[0].Height = _fbHeight;
|
|
||||||
graphicBuffer.Buffer.Surfaces[0].ColorFormat = ColorFormat.A8B8G8R8;
|
|
||||||
graphicBuffer.Buffer.Surfaces[0].Layout = 3; // Block linear
|
|
||||||
graphicBuffer.Buffer.Surfaces[0].Pitch = (int)widthAlignedBytes;
|
|
||||||
graphicBuffer.Buffer.Surfaces[0].Kind = 0xfe; // Generic 16Bx2
|
|
||||||
graphicBuffer.Buffer.Surfaces[0].BlockHeightLog2 = gobHeightLog2;
|
|
||||||
graphicBuffer.Buffer.Surfaces[0].Size = (int)totalSize;
|
|
||||||
|
|
||||||
for (int slot = 0; slot < _fbCount; slot++)
|
|
||||||
{
|
|
||||||
graphicBuffer.Buffer.Surfaces[0].Offset = slot * (int)totalSize;
|
|
||||||
|
|
||||||
producer.SetPreallocatedBuffer(slot, new AndroidStrongPointer<GraphicBuffer>(graphicBuffer));
|
|
||||||
}
|
|
||||||
|
|
||||||
_fbSlotsRequested = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DisconnectSharedLayer(long layerId)
|
|
||||||
{
|
|
||||||
IGraphicBufferProducer producer = _surfaceFlinger.GetProducerByLayerId(layerId);
|
|
||||||
|
|
||||||
producer.Disconnect(NativeWindowApi.NVN);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int DequeueFrameBuffer(long layerId, out AndroidFence fence)
|
|
||||||
{
|
|
||||||
IGraphicBufferProducer producer = _surfaceFlinger.GetProducerByLayerId(layerId);
|
|
||||||
|
|
||||||
Status status = producer.DequeueBuffer(out int slot, out fence, false, _fbWidth, _fbHeight, _fbFormat, (uint)_fbUsage);
|
|
||||||
|
|
||||||
if (status == Status.Success)
|
|
||||||
{
|
|
||||||
if ((_fbSlotsRequested & (1u << slot)) == 0)
|
|
||||||
{
|
|
||||||
status = producer.RequestBuffer(slot, out _);
|
|
||||||
|
|
||||||
if (status != Status.Success)
|
|
||||||
{
|
|
||||||
producer.CancelBuffer(slot, ref fence);
|
|
||||||
}
|
|
||||||
|
|
||||||
_fbSlotsRequested |= 1u << slot;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return slot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void QueueFrameBuffer(long layerId, int slot, Rect crop, NativeWindowTransform transform, int swapInterval, AndroidFence fence)
|
|
||||||
{
|
|
||||||
IGraphicBufferProducer producer = _surfaceFlinger.GetProducerByLayerId(layerId);
|
|
||||||
|
|
||||||
IGraphicBufferProducer.QueueBufferInput input = new();
|
|
||||||
|
|
||||||
input.Crop = crop;
|
|
||||||
input.Transform = transform;
|
|
||||||
input.SwapInterval = swapInterval;
|
|
||||||
input.Fence = fence;
|
|
||||||
|
|
||||||
Status status = producer.QueueBuffer(slot, ref input, out _);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CancelFrameBuffer(long layerId, int slot)
|
|
||||||
{
|
|
||||||
IGraphicBufferProducer producer = _surfaceFlinger.GetProducerByLayerId(layerId);
|
|
||||||
AndroidFence fence = default;
|
|
||||||
|
|
||||||
producer.CancelBuffer(slot, ref fence);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetFrameBufferMapIndex(int index)
|
|
||||||
{
|
|
||||||
return (uint)index < _fbCount ? index : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetSharedBufferNvMapId()
|
|
||||||
{
|
|
||||||
return _bufferNvMapId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ulong GetSharedBufferSize()
|
|
||||||
{
|
|
||||||
return CalculateFramebufferSize() * TotalFramebuffers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long GetSharedLayerId()
|
|
||||||
{
|
|
||||||
return _sharedLayerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ulong CalculateFramebufferSize()
|
|
||||||
{
|
|
||||||
// Each GOB dimension is 512 bytes x 8 lines.
|
|
||||||
// Assume 16 GOBs, for a total of 16 x 8 = 128 lines.
|
|
||||||
return BitUtils.AlignUp(_fbWidth * 4, 512u) * BitUtils.AlignUp(_fbHeight, 128u);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SharedBufferMap GetSharedBufferMap()
|
|
||||||
{
|
|
||||||
return _bufferMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetApplicationLastPresentedFrameHandle(GpuContext gpuContext)
|
|
||||||
{
|
|
||||||
TextureData texture = gpuContext.Window.GetLastPresentedData();
|
|
||||||
IVirtualMemoryManagerTracked selfAs = KernelStatic.GetProcessByPid(_pid).CpuMemory;
|
|
||||||
int fbIndex = (int)_fbCount; // Place it after all our frame buffers.
|
|
||||||
|
|
||||||
selfAs.Write(_fbsBaseAddress + _bufferMap.SharedBuffers[fbIndex].Offset, texture.Data);
|
|
||||||
|
|
||||||
return fbIndex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using Ryujinx.Memory.Range;
|
using Ryujinx.Memory.Range;
|
||||||
using Ryujinx.Memory.Tracking;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
@@ -10,7 +9,7 @@ namespace Ryujinx.Memory
|
|||||||
/// Represents a address space manager.
|
/// Represents a address space manager.
|
||||||
/// Supports virtual memory region mapping, address translation and read/write access to mapped regions.
|
/// Supports virtual memory region mapping, address translation and read/write access to mapped regions.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class AddressSpaceManager : VirtualMemoryManagerBase, IVirtualMemoryManagerTracked
|
public sealed class AddressSpaceManager : VirtualMemoryManagerBase, IVirtualMemoryManager
|
||||||
{
|
{
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public bool UsesPrivateAllocations => false;
|
public bool UsesPrivateAllocations => false;
|
||||||
@@ -22,8 +21,6 @@ namespace Ryujinx.Memory
|
|||||||
|
|
||||||
private readonly MemoryBlock _backingMemory;
|
private readonly MemoryBlock _backingMemory;
|
||||||
private readonly PageTable<nuint> _pageTable;
|
private readonly PageTable<nuint> _pageTable;
|
||||||
private readonly MemoryTracking _tracking;
|
|
||||||
private bool _writeTracked;
|
|
||||||
|
|
||||||
protected override ulong AddressSpaceSize { get; }
|
protected override ulong AddressSpaceSize { get; }
|
||||||
|
|
||||||
@@ -47,7 +44,6 @@ namespace Ryujinx.Memory
|
|||||||
AddressSpaceSize = asSize;
|
AddressSpaceSize = asSize;
|
||||||
_backingMemory = backingMemory;
|
_backingMemory = backingMemory;
|
||||||
_pageTable = new PageTable<nuint>();
|
_pageTable = new PageTable<nuint>();
|
||||||
_tracking = new MemoryTracking(this, 0x1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
@@ -231,7 +227,7 @@ namespace Ryujinx.Memory
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public void TrackingReprotect(ulong va, ulong size, MemoryPermission protection, bool guest = false)
|
public void TrackingReprotect(ulong va, ulong size, MemoryPermission protection, bool guest = false)
|
||||||
{
|
{
|
||||||
_writeTracked = true;
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected unsafe override Memory<byte> GetPhysicalAddressMemory(nuint pa, int size)
|
protected unsafe override Memory<byte> GetPhysicalAddressMemory(nuint pa, int size)
|
||||||
@@ -244,29 +240,5 @@ namespace Ryujinx.Memory
|
|||||||
|
|
||||||
protected override nuint TranslateVirtualAddressUnchecked(ulong va)
|
protected override nuint TranslateVirtualAddressUnchecked(ulong va)
|
||||||
=> GetHostAddress(va);
|
=> GetHostAddress(va);
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public override void SignalMemoryTracking(ulong va, ulong size, bool write, bool precise = false, int? exemptId = null)
|
|
||||||
{
|
|
||||||
if (_writeTracked)
|
|
||||||
{
|
|
||||||
_tracking.VirtualMemoryEvent(va, size, write, precise);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public RegionHandle BeginTracking(ulong address, ulong size, int id, RegionFlags flags = RegionFlags.None)
|
|
||||||
{
|
|
||||||
return _tracking.BeginTracking(address, size, id, flags);
|
|
||||||
}
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public MultiRegionHandle BeginGranularTracking(ulong address, ulong size, IEnumerable<IRegionHandle> handles, ulong granularity, int id, RegionFlags flags = RegionFlags.None)
|
|
||||||
{
|
|
||||||
return _tracking.BeginGranularTracking(address, size, handles, granularity, id, flags);
|
|
||||||
}
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public SmartMultiRegionHandle BeginSmartGranularTracking(ulong address, ulong size, ulong granularity, int id)
|
|
||||||
{
|
|
||||||
return _tracking.BeginSmartGranularTracking(address, size, granularity, id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -517,7 +517,7 @@ namespace Ryujinx.Ava
|
|||||||
Device?.System.ChangeDockedModeState(e.NewValue);
|
Device?.System.ChangeDockedModeState(e.NewValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateAudioVolumeState(object sender, ReactiveEventArgs<float> e)
|
public void UpdateAudioVolumeState(object sender, ReactiveEventArgs<float> e)
|
||||||
{
|
{
|
||||||
Device?.SetVolume(e.NewValue);
|
Device?.SetVolume(e.NewValue);
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Common
|
|
||||||
{
|
|
||||||
public static class ThemeManager
|
|
||||||
{
|
|
||||||
public static event Action ThemeChanged;
|
|
||||||
|
|
||||||
public static void OnThemeChanged()
|
|
||||||
{
|
|
||||||
ThemeChanged?.Invoke();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -24,7 +24,7 @@ namespace Ryujinx.Ava
|
|||||||
|
|
||||||
private static readonly string _description =
|
private static readonly string _description =
|
||||||
ReleaseInformation.IsValid
|
ReleaseInformation.IsValid
|
||||||
? $"{VersionString} {ReleaseInformation.ReleaseChannelOwner}/{ReleaseInformation.ReleaseChannelSourceRepo}@{ReleaseInformation.BuildGitHash}"
|
? $"{VersionString} {ReleaseInformation.ReleaseChannelOwner}/{ReleaseInformation.ReleaseChannelSourceRepo}"
|
||||||
: "dev build";
|
: "dev build";
|
||||||
|
|
||||||
private const string ApplicationId = "1293250299716173864";
|
private const string ApplicationId = "1293250299716173864";
|
||||||
@@ -56,6 +56,7 @@ namespace Ryujinx.Ava
|
|||||||
ConfigurationState.Instance.EnableDiscordIntegration.Event += Update;
|
ConfigurationState.Instance.EnableDiscordIntegration.Event += Update;
|
||||||
TitleIDs.CurrentApplication.Event += (_, e) => Use(e.NewValue);
|
TitleIDs.CurrentApplication.Event += (_, e) => Use(e.NewValue);
|
||||||
HorizonStatic.PlayReport += HandlePlayReport;
|
HorizonStatic.PlayReport += HandlePlayReport;
|
||||||
|
PlayReports.Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Update(object sender, ReactiveEventArgs<bool> evnt)
|
private static void Update(object sender, ReactiveEventArgs<bool> evnt)
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ namespace Ryujinx.Headless
|
|||||||
IgnoreMissingServices = configurationState.System.IgnoreMissingServices;
|
IgnoreMissingServices = configurationState.System.IgnoreMissingServices;
|
||||||
|
|
||||||
if (NeedsOverride(nameof(IgnoreControllerApplet)))
|
if (NeedsOverride(nameof(IgnoreControllerApplet)))
|
||||||
IgnoreControllerApplet = configurationState.System.IgnoreApplet;
|
IgnoreControllerApplet = configurationState.System.IgnoreControllerApplet;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ namespace Ryujinx.Ava
|
|||||||
{
|
{
|
||||||
public class RyujinxApp : Application
|
public class RyujinxApp : Application
|
||||||
{
|
{
|
||||||
|
public static event Action ThemeChanged;
|
||||||
|
|
||||||
internal static string FormatTitle(LocaleKeys? windowTitleKey = null, bool includeVersion = true)
|
internal static string FormatTitle(LocaleKeys? windowTitleKey = null, bool includeVersion = true)
|
||||||
=> windowTitleKey is null
|
=> windowTitleKey is null
|
||||||
? $"{FullAppName}{(includeVersion ? $" {Program.Version}" : string.Empty)}"
|
? $"{FullAppName}{(includeVersion ? $" {Program.Version}" : string.Empty)}"
|
||||||
@@ -112,7 +114,7 @@ namespace Ryujinx.Ava
|
|||||||
baseStyle = ConfigurationState.Instance.UI.BaseStyle;
|
baseStyle = ConfigurationState.Instance.UI.BaseStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
ThemeManager.OnThemeChanged();
|
ThemeChanged?.Invoke();
|
||||||
|
|
||||||
RequestedThemeVariant = baseStyle switch
|
RequestedThemeVariant = baseStyle switch
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace Ryujinx.Ava.UI.Applet
|
|||||||
|
|
||||||
bool okPressed = false;
|
bool okPressed = false;
|
||||||
|
|
||||||
if (ConfigurationState.Instance.System.IgnoreApplet)
|
if (ConfigurationState.Instance.System.IgnoreControllerApplet)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Dispatcher.UIThread.InvokeAsync(async () =>
|
Dispatcher.UIThread.InvokeAsync(async () =>
|
||||||
|
|||||||
@@ -119,17 +119,23 @@
|
|||||||
TextWrapping="Wrap" >
|
TextWrapping="Wrap" >
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal" Spacing="5">
|
<StackPanel Orientation="Horizontal" Spacing="5" ToolTip.Tip="{Binding DynamicRichPresenceDescription}">
|
||||||
<ui:SymbolIcon Foreground="ForestGreen" Symbol="Checkmark" IsVisible="{Binding AppData.HasDynamicRichPresenceSupport}"/>
|
<ui:SymbolIcon
|
||||||
|
Foreground="ForestGreen"
|
||||||
|
Symbol="Checkmark"
|
||||||
|
IsVisible="{Binding AppData.HasDynamicRichPresenceSupport}"/>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Foreground="ForestGreen"
|
Foreground="ForestGreen"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
IsVisible="{Binding AppData.HasDynamicRichPresenceSupport}"
|
IsVisible="{Binding AppData.HasDynamicRichPresenceSupport}"
|
||||||
Text="{ext:Locale GameInfoRpcDynamic}"
|
Text="{ext:Locale GameInfoRpcDynamic}"
|
||||||
TextAlignment="Start"
|
TextAlignment="Start"
|
||||||
TextWrapping="Wrap" >
|
TextWrapping="Wrap">
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
<ui:SymbolIcon Foreground="Red" Symbol="Cancel" IsVisible="{Binding !AppData.HasDynamicRichPresenceSupport}"/>
|
<ui:SymbolIcon
|
||||||
|
Foreground="Red"
|
||||||
|
Symbol="Cancel"
|
||||||
|
IsVisible="{Binding !AppData.HasDynamicRichPresenceSupport}"/>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Foreground="Red"
|
Foreground="Red"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
Version = RyujinxApp.FullAppName + "\n" + Program.Version;
|
Version = RyujinxApp.FullAppName + "\n" + Program.Version;
|
||||||
UpdateLogoTheme(ConfigurationState.Instance.UI.BaseStyle.Value);
|
UpdateLogoTheme(ConfigurationState.Instance.UI.BaseStyle.Value);
|
||||||
|
|
||||||
ThemeManager.ThemeChanged += ThemeManager_ThemeChanged;
|
RyujinxApp.ThemeChanged += Ryujinx_ThemeChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ThemeManager_ThemeChanged()
|
private void Ryujinx_ThemeChanged()
|
||||||
{
|
{
|
||||||
Dispatcher.UIThread.Post(() => UpdateLogoTheme(ConfigurationState.Instance.UI.BaseStyle.Value));
|
Dispatcher.UIThread.Post(() => UpdateLogoTheme(ConfigurationState.Instance.UI.BaseStyle.Value));
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
ThemeManager.ThemeChanged -= ThemeManager_ThemeChanged;
|
RyujinxApp.ThemeChanged -= Ryujinx_ThemeChanged;
|
||||||
|
|
||||||
GithubLogo.Dispose();
|
GithubLogo.Dispose();
|
||||||
DiscordLogo.Dispose();
|
DiscordLogo.Dispose();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Gommon;
|
using Gommon;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
using Ryujinx.Ava.Utilities.AppLibrary;
|
using Ryujinx.Ava.Utilities.AppLibrary;
|
||||||
|
using Ryujinx.Ava.Utilities.PlayReport;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.ViewModels
|
namespace Ryujinx.Ava.UI.ViewModels
|
||||||
{
|
{
|
||||||
@@ -10,6 +11,11 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
|
|
||||||
public ApplicationDataViewModel(ApplicationData appData) => AppData = appData;
|
public ApplicationDataViewModel(ApplicationData appData) => AppData = appData;
|
||||||
|
|
||||||
|
public string DynamicRichPresenceDescription =>
|
||||||
|
AppData.HasDynamicRichPresenceSupport
|
||||||
|
? AppData.RichPresenceSpec.Value.Description
|
||||||
|
: GameSpec.DefaultDescription;
|
||||||
|
|
||||||
public string FormattedVersion => LocaleManager.Instance[LocaleKeys.GameListHeaderVersion].Format(AppData.Version);
|
public string FormattedVersion => LocaleManager.Instance[LocaleKeys.GameListHeaderVersion].Format(AppData.Version);
|
||||||
public string FormattedDeveloper => LocaleManager.Instance[LocaleKeys.GameListHeaderDeveloper].Format(AppData.Developer);
|
public string FormattedDeveloper => LocaleManager.Instance[LocaleKeys.GameListHeaderDeveloper].Format(AppData.Developer);
|
||||||
public string FormattedFileExtension => LocaleManager.Instance[LocaleKeys.GameListHeaderFileExtension].Format(AppData.FileExtension);
|
public string FormattedFileExtension => LocaleManager.Instance[LocaleKeys.GameListHeaderFileExtension].Format(AppData.FileExtension);
|
||||||
|
|||||||
@@ -1347,6 +1347,25 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
OpenHelper.OpenFolder(AppDataManager.BaseDirPath);
|
OpenHelper.OpenFolder(AppDataManager.BaseDirPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OpenScreenshotsFolder()
|
||||||
|
{
|
||||||
|
string screenshotsDir = Path.Combine(AppDataManager.BaseDirPath, "screenshots");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(screenshotsDir))
|
||||||
|
Directory.CreateDirectory(screenshotsDir);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Error?.Print(LogClass.Application, $"Failed to create directory at path {screenshotsDir}. Error : {ex.GetType().Name}", "Screenshot");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenHelper.OpenFolder(screenshotsDir);
|
||||||
|
}
|
||||||
|
|
||||||
public void OpenLogsFolder()
|
public void OpenLogsFolder()
|
||||||
{
|
{
|
||||||
string logPath = AppDataManager.GetOrCreateLogsDir();
|
string logPath = AppDataManager.GetOrCreateLogsDir();
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
private int _graphicsBackendMultithreadingIndex;
|
private int _graphicsBackendMultithreadingIndex;
|
||||||
private float _volume;
|
private float _volume;
|
||||||
[ObservableProperty] private bool _isVulkanAvailable = true;
|
[ObservableProperty] private bool _isVulkanAvailable = true;
|
||||||
[ObservableProperty] private bool _gameDirectoryChanged;
|
[ObservableProperty] private bool _gameListNeedsRefresh;
|
||||||
[ObservableProperty] private bool _autoloadDirectoryChanged;
|
|
||||||
private readonly List<string> _gpuIds = [];
|
private readonly List<string> _gpuIds = [];
|
||||||
private int _graphicsBackendIndex;
|
private int _graphicsBackendIndex;
|
||||||
private int _scalingFilter;
|
private int _scalingFilter;
|
||||||
@@ -128,6 +127,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
public bool EnableMouse { get; set; }
|
public bool EnableMouse { get; set; }
|
||||||
public bool DisableInputWhenOutOfFocus { get; set; }
|
public bool DisableInputWhenOutOfFocus { get; set; }
|
||||||
|
|
||||||
|
public int FocusLostActionType { get; set; }
|
||||||
|
|
||||||
public VSyncMode VSyncMode
|
public VSyncMode VSyncMode
|
||||||
{
|
{
|
||||||
get => _vSyncMode;
|
get => _vSyncMode;
|
||||||
@@ -481,6 +482,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
ShowTitleBar = config.ShowTitleBar;
|
ShowTitleBar = config.ShowTitleBar;
|
||||||
HideCursor = (int)config.HideCursor.Value;
|
HideCursor = (int)config.HideCursor.Value;
|
||||||
UpdateCheckerType = (int)config.UpdateCheckerType.Value;
|
UpdateCheckerType = (int)config.UpdateCheckerType.Value;
|
||||||
|
FocusLostActionType = (int)config.FocusLostActionType.Value;
|
||||||
|
|
||||||
GameDirectories.Clear();
|
GameDirectories.Clear();
|
||||||
GameDirectories.AddRange(config.UI.GameDirs.Value);
|
GameDirectories.AddRange(config.UI.GameDirs.Value);
|
||||||
@@ -524,7 +526,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
EnableFsIntegrityChecks = config.System.EnableFsIntegrityChecks;
|
EnableFsIntegrityChecks = config.System.EnableFsIntegrityChecks;
|
||||||
DramSize = config.System.DramSize;
|
DramSize = config.System.DramSize;
|
||||||
IgnoreMissingServices = config.System.IgnoreMissingServices;
|
IgnoreMissingServices = config.System.IgnoreMissingServices;
|
||||||
IgnoreApplet = config.System.IgnoreApplet;
|
IgnoreApplet = config.System.IgnoreControllerApplet;
|
||||||
|
|
||||||
// CPU
|
// CPU
|
||||||
EnablePptc = config.System.EnablePtc;
|
EnablePptc = config.System.EnablePtc;
|
||||||
@@ -589,16 +591,9 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
config.ShowTitleBar.Value = ShowTitleBar;
|
config.ShowTitleBar.Value = ShowTitleBar;
|
||||||
config.HideCursor.Value = (HideCursorMode)HideCursor;
|
config.HideCursor.Value = (HideCursorMode)HideCursor;
|
||||||
config.UpdateCheckerType.Value = (UpdaterType)UpdateCheckerType;
|
config.UpdateCheckerType.Value = (UpdaterType)UpdateCheckerType;
|
||||||
|
config.FocusLostActionType.Value = (FocusLostType)FocusLostActionType;
|
||||||
if (GameDirectoryChanged)
|
config.UI.GameDirs.Value = [..GameDirectories];
|
||||||
{
|
config.UI.AutoloadDirs.Value = [..AutoloadDirectories];
|
||||||
config.UI.GameDirs.Value = [..GameDirectories];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (AutoloadDirectoryChanged)
|
|
||||||
{
|
|
||||||
config.UI.AutoloadDirs.Value = [..AutoloadDirectories];
|
|
||||||
}
|
|
||||||
|
|
||||||
config.UI.BaseStyle.Value = BaseStyleIndex switch
|
config.UI.BaseStyle.Value = BaseStyleIndex switch
|
||||||
{
|
{
|
||||||
@@ -619,8 +614,11 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
|
|
||||||
// System
|
// System
|
||||||
config.System.Region.Value = (Region)Region;
|
config.System.Region.Value = (Region)Region;
|
||||||
|
|
||||||
|
if (config.System.Language.Value != (Language)Language)
|
||||||
|
GameListNeedsRefresh = true;
|
||||||
|
|
||||||
config.System.Language.Value = (Language)Language;
|
config.System.Language.Value = (Language)Language;
|
||||||
|
|
||||||
if (_validTzRegions.Contains(TimeZone))
|
if (_validTzRegions.Contains(TimeZone))
|
||||||
{
|
{
|
||||||
config.System.TimeZone.Value = TimeZone;
|
config.System.TimeZone.Value = TimeZone;
|
||||||
@@ -631,7 +629,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
config.System.EnableFsIntegrityChecks.Value = EnableFsIntegrityChecks;
|
config.System.EnableFsIntegrityChecks.Value = EnableFsIntegrityChecks;
|
||||||
config.System.DramSize.Value = DramSize;
|
config.System.DramSize.Value = DramSize;
|
||||||
config.System.IgnoreMissingServices.Value = IgnoreMissingServices;
|
config.System.IgnoreMissingServices.Value = IgnoreMissingServices;
|
||||||
config.System.IgnoreApplet.Value = IgnoreApplet;
|
config.System.IgnoreControllerApplet.Value = IgnoreApplet;
|
||||||
|
|
||||||
// CPU
|
// CPU
|
||||||
config.System.EnablePtc.Value = EnablePptc;
|
config.System.EnablePtc.Value = EnablePptc;
|
||||||
@@ -711,8 +709,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
|
|
||||||
SaveSettingsEvent?.Invoke();
|
SaveSettingsEvent?.Invoke();
|
||||||
|
|
||||||
GameDirectoryChanged = false;
|
GameListNeedsRefresh = false;
|
||||||
AutoloadDirectoryChanged = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void RevertIfNotSaved()
|
private static void RevertIfNotSaved()
|
||||||
|
|||||||
@@ -66,6 +66,10 @@
|
|||||||
Command="{Binding OpenRyujinxFolder}"
|
Command="{Binding OpenRyujinxFolder}"
|
||||||
Header="{ext:Locale MenuBarFileOpenEmuFolder}"
|
Header="{ext:Locale MenuBarFileOpenEmuFolder}"
|
||||||
ToolTip.Tip="{ext:Locale OpenRyujinxFolderTooltip}" />
|
ToolTip.Tip="{ext:Locale OpenRyujinxFolderTooltip}" />
|
||||||
|
<MenuItem
|
||||||
|
Command="{Binding OpenScreenshotsFolder}"
|
||||||
|
Header="{ext:Locale MenuBarFileOpenScreenshotsFolder}"
|
||||||
|
ToolTip.Tip="{ext:Locale OpenScreenshotFolderTooltip}"/>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
Command="{Binding OpenLogsFolder}"
|
Command="{Binding OpenLogsFolder}"
|
||||||
Header="{ext:Locale MenuBarFileOpenLogsFolder}"
|
Header="{ext:Locale MenuBarFileOpenLogsFolder}"
|
||||||
|
|||||||
@@ -316,8 +316,8 @@
|
|||||||
</CheckBox>
|
</CheckBox>
|
||||||
<CheckBox
|
<CheckBox
|
||||||
IsChecked="{Binding IgnoreApplet}"
|
IsChecked="{Binding IgnoreApplet}"
|
||||||
ToolTip.Tip="{ext:Locale IgnoreAppletTooltip}">
|
ToolTip.Tip="{ext:Locale IgnoreControllerAppletTooltip}">
|
||||||
<TextBlock Text="{ext:Locale SettingsTabSystemIgnoreApplet}" />
|
<TextBlock Text="{ext:Locale SettingsTabSystemIgnoreControllerApplet}" />
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
<CheckBox
|
<CheckBox
|
||||||
IsChecked="{Binding EnableCustomVSyncInterval}"
|
IsChecked="{Binding EnableCustomVSyncInterval}"
|
||||||
|
|||||||
@@ -37,12 +37,33 @@
|
|||||||
<CheckBox IsChecked="{Binding RememberWindowState}">
|
<CheckBox IsChecked="{Binding RememberWindowState}">
|
||||||
<TextBlock Text="{ext:Locale SettingsTabGeneralRememberWindowState}" />
|
<TextBlock Text="{ext:Locale SettingsTabGeneralRememberWindowState}" />
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
<CheckBox IsChecked="{Binding DisableInputWhenOutOfFocus}">
|
|
||||||
<TextBlock Text="{ext:Locale SettingsTabGeneralDisableInputWhenOutOfFocus}" />
|
|
||||||
</CheckBox>
|
|
||||||
<CheckBox IsChecked="{Binding ShowTitleBar}" IsVisible="{x:Static helper:RunningPlatform.IsWindows}">
|
<CheckBox IsChecked="{Binding ShowTitleBar}" IsVisible="{x:Static helper:RunningPlatform.IsWindows}">
|
||||||
<TextBlock Text="{ext:Locale SettingsTabGeneralShowTitleBar}" />
|
<TextBlock Text="{ext:Locale SettingsTabGeneralShowTitleBar}" />
|
||||||
</CheckBox>
|
</CheckBox>
|
||||||
|
<StackPanel Margin="0, 15, 0, 0" Orientation="Horizontal">
|
||||||
|
<TextBlock VerticalAlignment="Center"
|
||||||
|
Text="{ext:Locale SettingsTabGeneralFocusLossType}"
|
||||||
|
Width="150" />
|
||||||
|
<ComboBox SelectedIndex="{Binding FocusLostActionType}"
|
||||||
|
HorizontalContentAlignment="Left"
|
||||||
|
MinWidth="100">
|
||||||
|
<ComboBoxItem>
|
||||||
|
<TextBlock Text="{ext:Locale SettingsTabGeneralFocusLossTypeDoNothing}" />
|
||||||
|
</ComboBoxItem>
|
||||||
|
<ComboBoxItem>
|
||||||
|
<TextBlock Text="{ext:Locale SettingsTabGeneralFocusLossTypeBlockInput}" />
|
||||||
|
</ComboBoxItem>
|
||||||
|
<ComboBoxItem>
|
||||||
|
<TextBlock Text="{ext:Locale SettingsTabGeneralFocusLossTypeMuteAudio}" />
|
||||||
|
</ComboBoxItem>
|
||||||
|
<ComboBoxItem>
|
||||||
|
<TextBlock Text="{ext:Locale SettingsTabGeneralFocusLossTypeBlockInputAndMuteAudio}" />
|
||||||
|
</ComboBoxItem>
|
||||||
|
<ComboBoxItem>
|
||||||
|
<TextBlock Text="{ext:Locale SettingsTabGeneralFocusLossTypePauseEmulation}" />
|
||||||
|
</ComboBoxItem>
|
||||||
|
</ComboBox>
|
||||||
|
</StackPanel>
|
||||||
<StackPanel Margin="0, 15, 0, 0" Orientation="Horizontal">
|
<StackPanel Margin="0, 15, 0, 0" Orientation="Horizontal">
|
||||||
<TextBlock VerticalAlignment="Center"
|
<TextBlock VerticalAlignment="Center"
|
||||||
Text="{ext:Locale SettingsTabGeneralCheckUpdatesOnLaunch}"
|
Text="{ext:Locale SettingsTabGeneralCheckUpdatesOnLaunch}"
|
||||||
|
|||||||
@@ -36,11 +36,8 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
|||||||
directories.Add(path);
|
directories.Add(path);
|
||||||
|
|
||||||
addDirBox.Clear();
|
addDirBox.Clear();
|
||||||
|
|
||||||
if (isGameList)
|
ViewModel.GameListNeedsRefresh = true;
|
||||||
ViewModel.GameDirectoryChanged = true;
|
|
||||||
else
|
|
||||||
ViewModel.AutoloadDirectoryChanged = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -50,10 +47,7 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
|||||||
{
|
{
|
||||||
directories.Add(folder.Value.Path.LocalPath);
|
directories.Add(folder.Value.Path.LocalPath);
|
||||||
|
|
||||||
if (isGameList)
|
ViewModel.GameListNeedsRefresh = true;
|
||||||
ViewModel.GameDirectoryChanged = true;
|
|
||||||
else
|
|
||||||
ViewModel.AutoloadDirectoryChanged = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,7 +59,7 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
|||||||
foreach (string path in new List<string>(GameDirsList.SelectedItems.Cast<string>()))
|
foreach (string path in new List<string>(GameDirsList.SelectedItems.Cast<string>()))
|
||||||
{
|
{
|
||||||
ViewModel.GameDirectories.Remove(path);
|
ViewModel.GameDirectories.Remove(path);
|
||||||
ViewModel.GameDirectoryChanged = true;
|
ViewModel.GameListNeedsRefresh = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameDirsList.ItemCount > 0)
|
if (GameDirsList.ItemCount > 0)
|
||||||
@@ -81,7 +75,7 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
|||||||
foreach (string path in new List<string>(AutoloadDirsList.SelectedItems.Cast<string>()))
|
foreach (string path in new List<string>(AutoloadDirsList.SelectedItems.Cast<string>()))
|
||||||
{
|
{
|
||||||
ViewModel.AutoloadDirectories.Remove(path);
|
ViewModel.AutoloadDirectories.Remove(path);
|
||||||
ViewModel.AutoloadDirectoryChanged = true;
|
ViewModel.GameListNeedsRefresh = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AutoloadDirsList.ItemCount > 0)
|
if (AutoloadDirsList.ItemCount > 0)
|
||||||
|
|||||||
@@ -765,31 +765,116 @@ namespace Ryujinx.Ava.UI.Windows
|
|||||||
|
|
||||||
private void InputElement_OnGotFocus(object sender, GotFocusEventArgs e)
|
private void InputElement_OnGotFocus(object sender, GotFocusEventArgs e)
|
||||||
{
|
{
|
||||||
if (!_didDisableInputUpdates)
|
if (ViewModel.AppHost is null) return;
|
||||||
|
|
||||||
|
if (!_focusLoss.Active)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!ConfigurationState.Instance.Hid.DisableInputWhenOutOfFocus)
|
switch (_focusLoss.Type)
|
||||||
return;
|
{
|
||||||
|
case FocusLostType.BlockInput:
|
||||||
|
{
|
||||||
|
if (!ViewModel.AppHost.NpadManager.InputUpdatesBlocked)
|
||||||
|
{
|
||||||
|
_focusLoss = default;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ViewModel.AppHost is not { NpadManager.InputUpdatesBlocked: true } appHost)
|
ViewModel.AppHost.NpadManager.UnblockInputUpdates();
|
||||||
return;
|
_focusLoss = default;
|
||||||
|
break;
|
||||||
appHost.NpadManager.UnblockInputUpdates();
|
}
|
||||||
_didDisableInputUpdates = appHost.NpadManager.InputUpdatesBlocked;
|
case FocusLostType.MuteAudio:
|
||||||
|
{
|
||||||
|
if (!ViewModel.AppHost.Device.IsAudioMuted())
|
||||||
|
{
|
||||||
|
_focusLoss = default;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewModel.AppHost.Device.SetVolume(ViewModel.VolumeBeforeMute);
|
||||||
|
|
||||||
|
_focusLoss = default;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FocusLostType.BlockInputAndMuteAudio:
|
||||||
|
{
|
||||||
|
if (!ViewModel.AppHost.Device.IsAudioMuted())
|
||||||
|
goto case FocusLostType.BlockInput;
|
||||||
|
|
||||||
|
ViewModel.AppHost.Device.SetVolume(ViewModel.VolumeBeforeMute);
|
||||||
|
ViewModel.AppHost.NpadManager.UnblockInputUpdates();
|
||||||
|
|
||||||
|
_focusLoss = default;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FocusLostType.PauseEmulation:
|
||||||
|
{
|
||||||
|
if (!ViewModel.AppHost.Device.System.IsPaused)
|
||||||
|
{
|
||||||
|
_focusLoss = default;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewModel.AppHost.Resume();
|
||||||
|
|
||||||
|
_focusLoss = default;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _didDisableInputUpdates;
|
private (FocusLostType Type, bool Active) _focusLoss;
|
||||||
|
|
||||||
private void InputElement_OnLostFocus(object sender, RoutedEventArgs e)
|
private void InputElement_OnLostFocus(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (!ConfigurationState.Instance.Hid.DisableInputWhenOutOfFocus)
|
if (ConfigurationState.Instance.FocusLostActionType.Value is FocusLostType.DoNothing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ViewModel.AppHost is not { NpadManager.InputUpdatesBlocked: false } appHost)
|
if (ViewModel.AppHost is null) return;
|
||||||
return;
|
|
||||||
|
switch (ConfigurationState.Instance.FocusLostActionType.Value)
|
||||||
|
{
|
||||||
|
case FocusLostType.BlockInput:
|
||||||
|
{
|
||||||
|
if (ViewModel.AppHost.NpadManager.InputUpdatesBlocked)
|
||||||
|
return;
|
||||||
|
|
||||||
appHost.NpadManager.BlockInputUpdates();
|
ViewModel.AppHost.NpadManager.BlockInputUpdates();
|
||||||
_didDisableInputUpdates = appHost.NpadManager.InputUpdatesBlocked;
|
_focusLoss = (FocusLostType.BlockInput, ViewModel.AppHost.NpadManager.InputUpdatesBlocked);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FocusLostType.MuteAudio:
|
||||||
|
{
|
||||||
|
if (ViewModel.AppHost.Device.GetVolume() is 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ViewModel.VolumeBeforeMute = ViewModel.AppHost.Device.GetVolume();
|
||||||
|
ViewModel.AppHost.Device.SetVolume(0);
|
||||||
|
_focusLoss = (FocusLostType.MuteAudio, ViewModel.AppHost.Device.GetVolume() is 0f);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FocusLostType.BlockInputAndMuteAudio:
|
||||||
|
{
|
||||||
|
if (ViewModel.AppHost.Device.GetVolume() is 0)
|
||||||
|
goto case FocusLostType.BlockInput;
|
||||||
|
|
||||||
|
ViewModel.VolumeBeforeMute = ViewModel.AppHost.Device.GetVolume();
|
||||||
|
ViewModel.AppHost.Device.SetVolume(0);
|
||||||
|
ViewModel.AppHost.NpadManager.BlockInputUpdates();
|
||||||
|
_focusLoss = (FocusLostType.BlockInputAndMuteAudio, ViewModel.AppHost.Device.GetVolume() is 0f && ViewModel.AppHost.NpadManager.InputUpdatesBlocked);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FocusLostType.PauseEmulation:
|
||||||
|
{
|
||||||
|
if (ViewModel.AppHost.Device.System.IsPaused)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ViewModel.AppHost.Pause();
|
||||||
|
_focusLoss = (FocusLostType.PauseEmulation, ViewModel.AppHost.Device.System.IsPaused);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||||||
{
|
{
|
||||||
InputPage.InputView?.SaveCurrentProfile();
|
InputPage.InputView?.SaveCurrentProfile();
|
||||||
|
|
||||||
if (Owner is MainWindow window && (ViewModel.GameDirectoryChanged || ViewModel.AutoloadDirectoryChanged))
|
if (Owner is MainWindow window && ViewModel.GameListNeedsRefresh)
|
||||||
{
|
{
|
||||||
window.LoadApplications();
|
window.LoadApplications();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using LibHac.Tools.FsSystem;
|
|||||||
using LibHac.Tools.FsSystem.NcaUtils;
|
using LibHac.Tools.FsSystem.NcaUtils;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
using Ryujinx.Ava.Utilities.Compat;
|
using Ryujinx.Ava.Utilities.Compat;
|
||||||
|
using Ryujinx.Ava.Utilities.PlayReport;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.HLE.FileSystem;
|
using Ryujinx.HLE.FileSystem;
|
||||||
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
using Ryujinx.HLE.Loaders.Processes.Extensions;
|
||||||
@@ -35,9 +36,14 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
|
|||||||
{
|
{
|
||||||
_id = value;
|
_id = value;
|
||||||
|
|
||||||
Compatibility = CompatibilityCsv.Find(Id);
|
Compatibility = CompatibilityCsv.Find(value);
|
||||||
|
RichPresenceSpec = PlayReports.Analyzer.TryGetSpec(IdString, out GameSpec gameSpec)
|
||||||
|
? gameSpec
|
||||||
|
: default(Optional<GameSpec>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public Optional<GameSpec> RichPresenceSpec { get; set; }
|
||||||
|
|
||||||
public string Developer { get; set; } = "Unknown";
|
public string Developer { get; set; } = "Unknown";
|
||||||
public string Version { get; set; } = "0";
|
public string Version { get; set; } = "0";
|
||||||
public int PlayerCount { get; set; }
|
public int PlayerCount { get; set; }
|
||||||
@@ -46,7 +52,7 @@ namespace Ryujinx.Ava.Utilities.AppLibrary
|
|||||||
public bool HasLdnGames => PlayerCount != 0 && GameCount != 0;
|
public bool HasLdnGames => PlayerCount != 0 && GameCount != 0;
|
||||||
|
|
||||||
public bool HasRichPresenceAsset => DiscordIntegrationModule.HasAssetImage(IdString);
|
public bool HasRichPresenceAsset => DiscordIntegrationModule.HasAssetImage(IdString);
|
||||||
public bool HasDynamicRichPresenceSupport => DiscordIntegrationModule.HasAnalyzer(IdString);
|
public bool HasDynamicRichPresenceSupport => RichPresenceSpec.HasValue;
|
||||||
|
|
||||||
public TimeSpan TimePlayed { get; set; }
|
public TimeSpan TimePlayed { get; set; }
|
||||||
public DateTime? LastPlayed { get; set; }
|
public DateTime? LastPlayed { get; set; }
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current version of the file format
|
/// The current version of the file format
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const int CurrentVersion = 66;
|
public const int CurrentVersion = 67;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Version of the configuration file format
|
/// Version of the configuration file format
|
||||||
@@ -171,6 +171,11 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
/// Checks for updates when Ryujinx starts when enabled, either prompting when an update is found or just showing a notification.
|
/// Checks for updates when Ryujinx starts when enabled, either prompting when an update is found or just showing a notification.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public UpdaterType UpdateCheckerType { get; set; }
|
public UpdaterType UpdateCheckerType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How the emulator should behave when you click off/on the window.
|
||||||
|
/// </summary>
|
||||||
|
public FocusLostType FocusLostActionType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Show "Confirm Exit" Dialog
|
/// Show "Confirm Exit" Dialog
|
||||||
@@ -178,7 +183,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
public bool ShowConfirmExit { get; set; }
|
public bool ShowConfirmExit { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ignore "Applet" dialog
|
/// Ignore Controller Applet dialog
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IgnoreApplet { get; set; }
|
public bool IgnoreApplet { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
EnableDiscordIntegration.Value = cff.EnableDiscordIntegration;
|
EnableDiscordIntegration.Value = cff.EnableDiscordIntegration;
|
||||||
CheckUpdatesOnStart.Value = cff.CheckUpdatesOnStart;
|
CheckUpdatesOnStart.Value = cff.CheckUpdatesOnStart;
|
||||||
UpdateCheckerType.Value = cff.UpdateCheckerType;
|
UpdateCheckerType.Value = cff.UpdateCheckerType;
|
||||||
|
FocusLostActionType.Value = cff.FocusLostActionType;
|
||||||
ShowConfirmExit.Value = cff.ShowConfirmExit;
|
ShowConfirmExit.Value = cff.ShowConfirmExit;
|
||||||
RememberWindowState.Value = cff.RememberWindowState;
|
RememberWindowState.Value = cff.RememberWindowState;
|
||||||
ShowTitleBar.Value = cff.ShowTitleBar;
|
ShowTitleBar.Value = cff.ShowTitleBar;
|
||||||
@@ -87,6 +88,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
System.Region.Value = cff.SystemRegion;
|
System.Region.Value = cff.SystemRegion;
|
||||||
System.TimeZone.Value = cff.SystemTimeZone;
|
System.TimeZone.Value = cff.SystemTimeZone;
|
||||||
System.SystemTimeOffset.Value = cff.SystemTimeOffset;
|
System.SystemTimeOffset.Value = cff.SystemTimeOffset;
|
||||||
|
System.MatchSystemTime.Value = cff.MatchSystemTime;
|
||||||
System.EnableDockedMode.Value = cff.DockedMode;
|
System.EnableDockedMode.Value = cff.DockedMode;
|
||||||
System.EnablePtc.Value = cff.EnablePtc;
|
System.EnablePtc.Value = cff.EnablePtc;
|
||||||
System.EnableLowPowerPtc.Value = cff.EnableLowPowerPtc;
|
System.EnableLowPowerPtc.Value = cff.EnableLowPowerPtc;
|
||||||
@@ -98,7 +100,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
System.MemoryManagerMode.Value = cff.MemoryManagerMode;
|
System.MemoryManagerMode.Value = cff.MemoryManagerMode;
|
||||||
System.DramSize.Value = cff.DramSize;
|
System.DramSize.Value = cff.DramSize;
|
||||||
System.IgnoreMissingServices.Value = cff.IgnoreMissingServices;
|
System.IgnoreMissingServices.Value = cff.IgnoreMissingServices;
|
||||||
System.IgnoreApplet.Value = cff.IgnoreApplet;
|
System.IgnoreControllerApplet.Value = cff.IgnoreApplet;
|
||||||
System.UseHypervisor.Value = cff.UseHypervisor;
|
System.UseHypervisor.Value = cff.UseHypervisor;
|
||||||
|
|
||||||
UI.GuiColumns.FavColumn.Value = cff.GuiColumns.FavColumn;
|
UI.GuiColumns.FavColumn.Value = cff.GuiColumns.FavColumn;
|
||||||
@@ -435,7 +437,8 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
(63, static cff => cff.MatchSystemTime = false),
|
(63, static cff => cff.MatchSystemTime = false),
|
||||||
(64, static cff => cff.LoggingEnableAvalonia = false),
|
(64, static cff => cff.LoggingEnableAvalonia = false),
|
||||||
(65, static cff => cff.UpdateCheckerType = cff.CheckUpdatesOnStart ? UpdaterType.PromptAtStartup : UpdaterType.Off),
|
(65, static cff => cff.UpdateCheckerType = cff.CheckUpdatesOnStart ? UpdaterType.PromptAtStartup : UpdaterType.Off),
|
||||||
(66, static cff => cff.DisableInputWhenOutOfFocus = false)
|
(66, static cff => cff.DisableInputWhenOutOfFocus = false),
|
||||||
|
(67, static cff => cff.FocusLostActionType = cff.DisableInputWhenOutOfFocus ? FocusLostType.BlockInput : FocusLostType.DoNothing)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ignore Controller Applet
|
/// Ignore Controller Applet
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ReactiveObject<bool> IgnoreApplet { get; private set; }
|
public ReactiveObject<bool> IgnoreControllerApplet { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Uses Hypervisor over JIT if available
|
/// Uses Hypervisor over JIT if available
|
||||||
@@ -424,8 +424,8 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
DramSize.LogChangesToValue(nameof(DramSize));
|
DramSize.LogChangesToValue(nameof(DramSize));
|
||||||
IgnoreMissingServices = new ReactiveObject<bool>();
|
IgnoreMissingServices = new ReactiveObject<bool>();
|
||||||
IgnoreMissingServices.LogChangesToValue(nameof(IgnoreMissingServices));
|
IgnoreMissingServices.LogChangesToValue(nameof(IgnoreMissingServices));
|
||||||
IgnoreApplet = new ReactiveObject<bool>();
|
IgnoreControllerApplet = new ReactiveObject<bool>();
|
||||||
IgnoreApplet.LogChangesToValue(nameof(IgnoreApplet));
|
IgnoreControllerApplet.LogChangesToValue(nameof(IgnoreControllerApplet));
|
||||||
AudioVolume = new ReactiveObject<float>();
|
AudioVolume = new ReactiveObject<float>();
|
||||||
AudioVolume.LogChangesToValue(nameof(AudioVolume));
|
AudioVolume.LogChangesToValue(nameof(AudioVolume));
|
||||||
UseHypervisor = new ReactiveObject<bool>();
|
UseHypervisor = new ReactiveObject<bool>();
|
||||||
@@ -779,6 +779,11 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
/// Checks for updates when Ryujinx starts when enabled, either prompting when an update is found or just showing a notification.
|
/// Checks for updates when Ryujinx starts when enabled, either prompting when an update is found or just showing a notification.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ReactiveObject<UpdaterType> UpdateCheckerType { get; private set; }
|
public ReactiveObject<UpdaterType> UpdateCheckerType { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How the emulator should behave when you click off/on the window.
|
||||||
|
/// </summary>
|
||||||
|
public ReactiveObject<FocusLostType> FocusLostActionType { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Show "Confirm Exit" Dialog
|
/// Show "Confirm Exit" Dialog
|
||||||
@@ -817,6 +822,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
EnableDiscordIntegration = new ReactiveObject<bool>();
|
EnableDiscordIntegration = new ReactiveObject<bool>();
|
||||||
CheckUpdatesOnStart = new ReactiveObject<bool>();
|
CheckUpdatesOnStart = new ReactiveObject<bool>();
|
||||||
UpdateCheckerType = new ReactiveObject<UpdaterType>();
|
UpdateCheckerType = new ReactiveObject<UpdaterType>();
|
||||||
|
FocusLostActionType = new ReactiveObject<FocusLostType>();
|
||||||
ShowConfirmExit = new ReactiveObject<bool>();
|
ShowConfirmExit = new ReactiveObject<bool>();
|
||||||
RememberWindowState = new ReactiveObject<bool>();
|
RememberWindowState = new ReactiveObject<bool>();
|
||||||
ShowTitleBar = new ReactiveObject<bool>();
|
ShowTitleBar = new ReactiveObject<bool>();
|
||||||
|
|||||||
@@ -53,10 +53,12 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
SystemRegion = System.Region,
|
SystemRegion = System.Region,
|
||||||
SystemTimeZone = System.TimeZone,
|
SystemTimeZone = System.TimeZone,
|
||||||
SystemTimeOffset = System.SystemTimeOffset,
|
SystemTimeOffset = System.SystemTimeOffset,
|
||||||
|
MatchSystemTime = System.MatchSystemTime,
|
||||||
DockedMode = System.EnableDockedMode,
|
DockedMode = System.EnableDockedMode,
|
||||||
EnableDiscordIntegration = EnableDiscordIntegration,
|
EnableDiscordIntegration = EnableDiscordIntegration,
|
||||||
CheckUpdatesOnStart = CheckUpdatesOnStart,
|
CheckUpdatesOnStart = CheckUpdatesOnStart,
|
||||||
UpdateCheckerType = UpdateCheckerType,
|
UpdateCheckerType = UpdateCheckerType,
|
||||||
|
FocusLostActionType = FocusLostActionType,
|
||||||
ShowConfirmExit = ShowConfirmExit,
|
ShowConfirmExit = ShowConfirmExit,
|
||||||
RememberWindowState = RememberWindowState,
|
RememberWindowState = RememberWindowState,
|
||||||
ShowTitleBar = ShowTitleBar,
|
ShowTitleBar = ShowTitleBar,
|
||||||
@@ -79,7 +81,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
MemoryManagerMode = System.MemoryManagerMode,
|
MemoryManagerMode = System.MemoryManagerMode,
|
||||||
DramSize = System.DramSize,
|
DramSize = System.DramSize,
|
||||||
IgnoreMissingServices = System.IgnoreMissingServices,
|
IgnoreMissingServices = System.IgnoreMissingServices,
|
||||||
IgnoreApplet = System.IgnoreApplet,
|
IgnoreApplet = System.IgnoreControllerApplet,
|
||||||
UseHypervisor = System.UseHypervisor,
|
UseHypervisor = System.UseHypervisor,
|
||||||
GuiColumns = new GuiColumns
|
GuiColumns = new GuiColumns
|
||||||
{
|
{
|
||||||
@@ -178,6 +180,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
System.EnableDockedMode.Value = true;
|
System.EnableDockedMode.Value = true;
|
||||||
EnableDiscordIntegration.Value = true;
|
EnableDiscordIntegration.Value = true;
|
||||||
UpdateCheckerType.Value = UpdaterType.PromptAtStartup;
|
UpdateCheckerType.Value = UpdaterType.PromptAtStartup;
|
||||||
|
FocusLostActionType.Value = FocusLostType.DoNothing;
|
||||||
ShowConfirmExit.Value = true;
|
ShowConfirmExit.Value = true;
|
||||||
RememberWindowState.Value = true;
|
RememberWindowState.Value = true;
|
||||||
ShowTitleBar.Value = !OperatingSystem.IsWindows();
|
ShowTitleBar.Value = !OperatingSystem.IsWindows();
|
||||||
@@ -202,7 +205,7 @@ namespace Ryujinx.Ava.Utilities.Configuration
|
|||||||
System.MemoryManagerMode.Value = MemoryManagerMode.HostMappedUnsafe;
|
System.MemoryManagerMode.Value = MemoryManagerMode.HostMappedUnsafe;
|
||||||
System.DramSize.Value = MemoryConfiguration.MemoryConfiguration4GiB;
|
System.DramSize.Value = MemoryConfiguration.MemoryConfiguration4GiB;
|
||||||
System.IgnoreMissingServices.Value = false;
|
System.IgnoreMissingServices.Value = false;
|
||||||
System.IgnoreApplet.Value = false;
|
System.IgnoreControllerApplet.Value = false;
|
||||||
System.UseHypervisor.Value = true;
|
System.UseHypervisor.Value = true;
|
||||||
Multiplayer.LanInterfaceId.Value = "0";
|
Multiplayer.LanInterfaceId.Value = "0";
|
||||||
Multiplayer.Mode.Value = MultiplayerMode.Disabled;
|
Multiplayer.Mode.Value = MultiplayerMode.Disabled;
|
||||||
|
|||||||
15
src/Ryujinx/Utilities/Configuration/UI/FocusLostType.cs
Normal file
15
src/Ryujinx/Utilities/Configuration/UI/FocusLostType.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using Ryujinx.Common.Utilities;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.Utilities.Configuration.UI
|
||||||
|
{
|
||||||
|
[JsonConverter(typeof(TypedStringEnumConverter<FocusLostType>))]
|
||||||
|
public enum FocusLostType
|
||||||
|
{
|
||||||
|
DoNothing,
|
||||||
|
BlockInput,
|
||||||
|
MuteAudio,
|
||||||
|
BlockInputAndMuteAudio,
|
||||||
|
PauseEmulation
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using Gommon;
|
using Gommon;
|
||||||
using Ryujinx.Ava.Utilities.AppLibrary;
|
using Ryujinx.Ava.Utilities.AppLibrary;
|
||||||
|
using Ryujinx.Common.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
@@ -19,6 +20,11 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
|
|
||||||
public IReadOnlyList<GameSpec> Specs => new ReadOnlyCollection<GameSpec>(_specs);
|
public IReadOnlyList<GameSpec> Specs => new ReadOnlyCollection<GameSpec>(_specs);
|
||||||
|
|
||||||
|
public GameSpec GetSpec(string titleId) => _specs.First(x => x.TitleIds.ContainsIgnoreCase(titleId));
|
||||||
|
|
||||||
|
public bool TryGetSpec(string titleId, out GameSpec gameSpec)
|
||||||
|
=> (gameSpec = _specs.FirstOrDefault(x => x.TitleIds.ContainsIgnoreCase(titleId))) != null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add an analysis spec matching a specific game by title ID, with the provided spec configuration.
|
/// Add an analysis spec matching a specific game by title ID, with the provided spec configuration.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -27,10 +33,12 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
/// <returns>The current <see cref="Analyzer"/>, for chaining convenience.</returns>
|
/// <returns>The current <see cref="Analyzer"/>, for chaining convenience.</returns>
|
||||||
public Analyzer AddSpec(string titleId, Func<GameSpec, GameSpec> transform)
|
public Analyzer AddSpec(string titleId, Func<GameSpec, GameSpec> transform)
|
||||||
{
|
{
|
||||||
Guard.Ensure(ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _),
|
if (ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _))
|
||||||
$"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
|
return AddSpec(transform(GameSpec.Create(titleId)));
|
||||||
|
|
||||||
return AddSpec(transform(GameSpec.Create(titleId)));
|
Logger.Notice.PrintMsg(LogClass.Application,
|
||||||
|
$"Tried to add a {nameof(GameSpec)} with a non-hexadecimal title ID value. Input: '{titleId}'");
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -41,10 +49,12 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
/// <returns>The current <see cref="Analyzer"/>, for chaining convenience.</returns>
|
/// <returns>The current <see cref="Analyzer"/>, for chaining convenience.</returns>
|
||||||
public Analyzer AddSpec(string titleId, Action<GameSpec> transform)
|
public Analyzer AddSpec(string titleId, Action<GameSpec> transform)
|
||||||
{
|
{
|
||||||
Guard.Ensure(ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _),
|
if (ulong.TryParse(titleId, NumberStyles.HexNumber, null, out _))
|
||||||
$"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
|
return AddSpec(GameSpec.Create(titleId).Apply(transform));
|
||||||
|
|
||||||
return AddSpec(GameSpec.Create(titleId).Apply(transform));
|
Logger.Notice.PrintMsg(LogClass.Application,
|
||||||
|
$"Tried to add a {nameof(GameSpec)} with a non-hexadecimal title ID value. Input: '{titleId}'");
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -57,10 +67,19 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
Func<GameSpec, GameSpec> transform)
|
Func<GameSpec, GameSpec> transform)
|
||||||
{
|
{
|
||||||
string[] tids = titleIds.ToArray();
|
string[] tids = titleIds.ToArray();
|
||||||
Guard.Ensure(tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _)),
|
if (tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _) && !string.IsNullOrEmpty(x)))
|
||||||
$"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
|
return AddSpec(transform(GameSpec.Create(tids)));
|
||||||
|
|
||||||
return AddSpec(transform(GameSpec.Create(tids)));
|
Logger.Notice.PrintMsg(LogClass.Application,
|
||||||
|
$"Tried to add a {nameof(GameSpec)} with a non-hexadecimal title ID value. Input: '{
|
||||||
|
tids.FormatCollection(
|
||||||
|
x => x,
|
||||||
|
separator: ", ",
|
||||||
|
prefix: "[",
|
||||||
|
suffix: "]"
|
||||||
|
)
|
||||||
|
}'");
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -72,12 +91,21 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
public Analyzer AddSpec(IEnumerable<string> titleIds, Action<GameSpec> transform)
|
public Analyzer AddSpec(IEnumerable<string> titleIds, Action<GameSpec> transform)
|
||||||
{
|
{
|
||||||
string[] tids = titleIds.ToArray();
|
string[] tids = titleIds.ToArray();
|
||||||
Guard.Ensure(tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _)),
|
if (tids.All(x => ulong.TryParse(x, NumberStyles.HexNumber, null, out _) && !string.IsNullOrEmpty(x)))
|
||||||
$"Cannot use a non-hexadecimal string as the Title ID for a {nameof(GameSpec)}.");
|
return AddSpec(GameSpec.Create(tids).Apply(transform));
|
||||||
|
|
||||||
return AddSpec(GameSpec.Create(tids).Apply(transform));
|
Logger.Notice.PrintMsg(LogClass.Application,
|
||||||
|
$"Tried to add a {nameof(GameSpec)} with a non-hexadecimal title ID value. Input: '{
|
||||||
|
tids.FormatCollection(
|
||||||
|
x => x,
|
||||||
|
separator: ", ",
|
||||||
|
prefix: "[",
|
||||||
|
suffix: "]"
|
||||||
|
)
|
||||||
|
}'");
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add an analysis spec matching a specific game by title ID, with the provided pre-configured spec.
|
/// Add an analysis spec matching a specific game by title ID, with the provided pre-configured spec.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -105,13 +133,13 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
{
|
{
|
||||||
if (!playReport.ReportData.IsDictionary)
|
if (!playReport.ReportData.IsDictionary)
|
||||||
return FormattedValue.Unhandled;
|
return FormattedValue.Unhandled;
|
||||||
|
|
||||||
if (!_specs.TryGetFirst(s => runningGameId.EqualsAnyIgnoreCase(s.TitleIds), out GameSpec spec))
|
if (!TryGetSpec(runningGameId, out GameSpec spec))
|
||||||
return FormattedValue.Unhandled;
|
return FormattedValue.Unhandled;
|
||||||
|
|
||||||
foreach (FormatterSpecBase formatSpec in spec.ValueFormatters.OrderBy(x => x.Priority))
|
foreach (FormatterSpecBase formatSpec in spec.ValueFormatters.OrderBy(x => x.Priority))
|
||||||
{
|
{
|
||||||
if (!formatSpec.Format(appMeta, playReport, out FormattedValue value))
|
if (!formatSpec.TryFormat(appMeta, playReport, out FormattedValue value))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Gommon;
|
using Gommon;
|
||||||
|
using Humanizer;
|
||||||
using System;
|
using System;
|
||||||
using System.Buffers.Binary;
|
using System.Buffers.Binary;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -18,6 +19,9 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
< -201d => "Exploring the Depths",
|
< -201d => "Exploring the Depths",
|
||||||
_ => "Roaming Hyrule"
|
_ => "Roaming Hyrule"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static FormattedValue SkywardSwordHD_Rupees(SingleValue value)
|
||||||
|
=> "rupee".ToQuantity(value.Matched.IntValue);
|
||||||
|
|
||||||
private static FormattedValue SuperMarioOdyssey_AssistMode(SingleValue value)
|
private static FormattedValue SuperMarioOdyssey_AssistMode(SingleValue value)
|
||||||
=> value.Matched.BoxedValue is 1 ? "Playing in Assist Mode" : "Playing in Regular Mode";
|
=> value.Matched.BoxedValue is 1 ? "Playing in Assist Mode" : "Playing in Regular Mode";
|
||||||
|
|||||||
@@ -1,11 +1,22 @@
|
|||||||
namespace Ryujinx.Ava.Utilities.PlayReport
|
using System;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.Utilities.PlayReport
|
||||||
{
|
{
|
||||||
public static partial class PlayReports
|
public static partial class PlayReports
|
||||||
{
|
{
|
||||||
public static Analyzer Analyzer { get; } = new Analyzer()
|
public static void Initialize()
|
||||||
|
{
|
||||||
|
// init lazy value
|
||||||
|
_ = Analyzer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Analyzer Analyzer => _analyzerLazy.Value;
|
||||||
|
|
||||||
|
private static readonly Lazy<Analyzer> _analyzerLazy = new(() => new Analyzer()
|
||||||
.AddSpec(
|
.AddSpec(
|
||||||
"01007ef00011e000",
|
"01007ef00011e000",
|
||||||
spec => spec
|
spec => spec
|
||||||
|
.WithDescription("based on being in Master Mode.")
|
||||||
.AddValueFormatter("IsHardMode", BreathOfTheWild_MasterMode)
|
.AddValueFormatter("IsHardMode", BreathOfTheWild_MasterMode)
|
||||||
// reset to normal status when switching between normal & master mode in title screen
|
// reset to normal status when switching between normal & master mode in title screen
|
||||||
.AddValueFormatter("AoCVer", FormattedValue.SingleAlwaysResets)
|
.AddValueFormatter("AoCVer", FormattedValue.SingleAlwaysResets)
|
||||||
@@ -13,34 +24,49 @@
|
|||||||
.AddSpec(
|
.AddSpec(
|
||||||
"0100f2c0115b6000",
|
"0100f2c0115b6000",
|
||||||
spec => spec
|
spec => spec
|
||||||
|
.WithDescription("based on where you are in Hyrule (Depths, Surface, Sky).")
|
||||||
.AddValueFormatter("PlayerPosY", TearsOfTheKingdom_CurrentField))
|
.AddValueFormatter("PlayerPosY", TearsOfTheKingdom_CurrentField))
|
||||||
|
.AddSpec(
|
||||||
|
"01002da013484000",
|
||||||
|
spec => spec
|
||||||
|
.WithDescription("based on how many Rupees you have.")
|
||||||
|
.AddValueFormatter("rupees", SkywardSwordHD_Rupees))
|
||||||
.AddSpec(
|
.AddSpec(
|
||||||
"0100000000010000",
|
"0100000000010000",
|
||||||
spec =>
|
spec => spec
|
||||||
spec.AddValueFormatter("is_kids_mode", SuperMarioOdyssey_AssistMode)
|
.WithDescription("based on if you're playing with Assist Mode.")
|
||||||
|
.AddValueFormatter("is_kids_mode", SuperMarioOdyssey_AssistMode)
|
||||||
)
|
)
|
||||||
.AddSpec(
|
.AddSpec(
|
||||||
"010075000ecbe000",
|
"010075000ecbe000",
|
||||||
spec =>
|
spec => spec
|
||||||
spec.AddValueFormatter("is_kids_mode", SuperMarioOdysseyChina_AssistMode)
|
.WithDescription("based on if you're playing with Assist Mode.")
|
||||||
|
.AddValueFormatter("is_kids_mode", SuperMarioOdysseyChina_AssistMode)
|
||||||
)
|
)
|
||||||
.AddSpec(
|
.AddSpec(
|
||||||
"010028600ebda000",
|
"010028600ebda000",
|
||||||
spec => spec.AddValueFormatter("mode", SuperMario3DWorldOrBowsersFury)
|
spec => spec
|
||||||
|
.WithDescription("based on being in either Super Mario 3D World or Bowser's Fury.")
|
||||||
|
.AddValueFormatter("mode", SuperMario3DWorldOrBowsersFury)
|
||||||
)
|
)
|
||||||
.AddSpec( // Global & China IDs
|
.AddSpec( // Global & China IDs
|
||||||
["0100152000022000", "010075100e8ec000"],
|
["0100152000022000", "010075100e8ec000"],
|
||||||
spec => spec.AddValueFormatter("To", MarioKart8Deluxe_Mode)
|
spec => spec
|
||||||
|
.WithDescription(
|
||||||
|
"based on what modes you're selecting in the menu & whether or not you're in a race.")
|
||||||
|
.AddValueFormatter("To", MarioKart8Deluxe_Mode)
|
||||||
)
|
)
|
||||||
.AddSpec(
|
.AddSpec(
|
||||||
["0100a3d008c5c000", "01008f6008c5e000"],
|
["0100a3d008c5c000", "01008f6008c5e000"],
|
||||||
spec => spec
|
spec => spec
|
||||||
|
.WithDescription("based on what area of Paldea you're exploring.")
|
||||||
.AddValueFormatter("area_no", PokemonSVArea)
|
.AddValueFormatter("area_no", PokemonSVArea)
|
||||||
.AddValueFormatter("team_circle", PokemonSVUnionCircle)
|
.AddValueFormatter("team_circle", PokemonSVUnionCircle)
|
||||||
)
|
)
|
||||||
.AddSpec(
|
.AddSpec(
|
||||||
"01006a800016e000",
|
"01006a800016e000",
|
||||||
spec => spec
|
spec => spec
|
||||||
|
.WithDescription("based on what mode you're playing, who won, and what characters were present.")
|
||||||
.AddSparseMultiValueFormatter(
|
.AddSparseMultiValueFormatter(
|
||||||
[
|
[
|
||||||
// Metadata to figure out what PlayReport we have.
|
// Metadata to figure out what PlayReport we have.
|
||||||
@@ -58,10 +84,15 @@
|
|||||||
)
|
)
|
||||||
.AddSpec(
|
.AddSpec(
|
||||||
[
|
[
|
||||||
"0100c9a00ece6000", "01008d300c50c000", "0100d870045b6000",
|
"0100c9a00ece6000", "01008d300c50c000", "0100d870045b6000",
|
||||||
"010012f017576000", "0100c62011050000", "0100b3c014bda000"],
|
"010012f017576000", "0100c62011050000", "0100b3c014bda000"
|
||||||
spec => spec.AddValueFormatter("launch_title_id", NsoEmulator_LaunchedGame)
|
],
|
||||||
);
|
spec => spec
|
||||||
|
.WithDescription(
|
||||||
|
"based on what game you first launch.\n\nNSO emulators do not print any Play Report information past the first game launch so it's all we got.")
|
||||||
|
.AddValueFormatter("launch_title_id", NsoEmulator_LaunchedGame)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
private static string Playing(string game) => $"Playing {game}";
|
private static string Playing(string game) => $"Playing {game}";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,20 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
|
|
||||||
public required string[] TitleIds { get; init; }
|
public required string[] TitleIds { get; init; }
|
||||||
|
|
||||||
|
public const string DefaultDescription = "Formats the details on your Discord presence based on logged data from the game.";
|
||||||
|
|
||||||
|
private string _valueDescription;
|
||||||
|
|
||||||
|
public string Description => _valueDescription ?? DefaultDescription;
|
||||||
|
|
||||||
|
public GameSpec WithDescription(string description)
|
||||||
|
{
|
||||||
|
_valueDescription = description != null
|
||||||
|
? $"Formats the details on your Discord presence {description}"
|
||||||
|
: null;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public List<FormatterSpecBase> ValueFormatters { get; } = [];
|
public List<FormatterSpecBase> ValueFormatters { get; } = [];
|
||||||
|
|
||||||
|
|
||||||
@@ -197,7 +211,7 @@ namespace Ryujinx.Ava.Utilities.PlayReport
|
|||||||
public string[] ReportKeys { get; init; }
|
public string[] ReportKeys { get; init; }
|
||||||
public Delegate Formatter { get; init; }
|
public Delegate Formatter { get; init; }
|
||||||
|
|
||||||
public bool Format(ApplicationMetadata appMeta, Horizon.Prepo.Types.PlayReport playReport,
|
public bool TryFormat(ApplicationMetadata appMeta, Horizon.Prepo.Types.PlayReport playReport,
|
||||||
out FormattedValue formattedValue)
|
out FormattedValue formattedValue)
|
||||||
{
|
{
|
||||||
formattedValue = default;
|
formattedValue = default;
|
||||||
|
|||||||
Reference in New Issue
Block a user