2021-06-25 00:54:50 +02:00
|
|
|
|
using OpenTK.Graphics;
|
Memory Read/Write Tracking using Region Handles (#1272)
* WIP Range Tracking
- Texture invalidation seems to have large problems
- Buffer/Pool invalidation may have problems
- Mirror memory tracking puts an additional `add` in compiled code, we likely just want to make HLE access slower if this is the final solution.
- Native project is in the messiest possible location.
- [HACK] JIT memory access always uses native "fast" path
- [HACK] Trying some things with texture invalidation and views.
It works :)
Still a few hacks, messy things, slow things
More work in progress stuff (also move to memory project)
Quite a bit faster now.
- Unmapping GPU VA and CPU VA will now correctly update write tracking regions, and invalidate textures for the former.
- The Virtual range list is now non-overlapping like the physical one.
- Fixed some bugs where regions could leak.
- Introduced a weird bug that I still need to track down (consistent invalid buffer in MK8 ribbon road)
Move some stuff.
I think we'll eventually just put the dll and so for this in a nuget package.
Fix rebase.
[WIP] MultiRegionHandle variable size ranges
- Avoid reprotecting regions that change often (needs some tweaking)
- There's still a bug in buffers, somehow.
- Might want different api for minimum granularity
Fix rebase issue
Commit everything needed for software only tracking.
Remove native components.
Remove more native stuff.
Cleanup
Use a separate window for the background context, update opentk. (fixes linux)
Some experimental changes
Should get things working up to scratch - still need to try some things with flush/modification and res scale.
Include address with the region action.
Initial work to make range tracking work
Still a ton of bugs
Fix some issues with the new stuff.
* Fix texture flush instability
There's still some weird behaviour, but it's much improved without this. (textures with cpu modified data were flushing over it)
* Find the destination texture for Buffer->Texture full copy
Greatly improves performance for nvdec videos (with range tracking)
* Further improve texture tracking
* Disable Memory Tracking for view parents
This is a temporary approach to better match behaviour on master (where invalidations would be soaked up by views, rather than trigger twice)
The assumption is that when views are created to a texture, they will cover all of its data anyways. Of course, this can easily be improved in future.
* Introduce some tracking tests.
WIP
* Complete base tests.
* Add more tests for multiregion, fix existing test.
* Cleanup Part 1
* Remove unnecessary code from memory tracking
* Fix some inconsistencies with 3D texture rule.
* Add dispose tests.
* Use a background thread for the background context.
Rather than setting and unsetting a context as current, doing the work on a dedicated thread with signals seems to be a bit faster.
Also nerf the multithreading test a bit.
* Copy to texture with matching alignment
This extends the copy to work for some videos with unusual size, such as tutorial videos in SMO. It will only occur if the destination texture already exists at XCount size.
* Track reads for buffer copies. Synchronize new buffers before copying overlaps.
* Remove old texture flushing mechanisms.
Range tracking all the way, baby.
* Wake the background thread when disposing.
Avoids a deadlock when games are closed.
* Address Feedback 1
* Separate TextureCopy instance for background thread
Also `BackgroundContextWorker.InBackground` for a more sensible idenfifier for if we're in a background thread.
* Add missing XML docs.
* Address Feedback
* Maybe I should start drinking coffee.
* Some more feedback.
* Remove flush warning, Refocus window after making background context
2020-10-16 22:18:35 +02:00
|
|
|
|
using OpenTK.Graphics.OpenGL;
|
2020-08-02 16:41:24 +02:00
|
|
|
|
using Ryujinx.Common.Configuration;
|
2020-01-10 01:35:50 +01:00
|
|
|
|
using Ryujinx.Common.Logging;
|
2019-10-13 08:02:07 +02:00
|
|
|
|
using Ryujinx.Graphics.GAL;
|
2020-05-23 11:46:09 +02:00
|
|
|
|
using Ryujinx.Graphics.OpenGL.Image;
|
2020-05-04 04:24:59 +02:00
|
|
|
|
using Ryujinx.Graphics.OpenGL.Queries;
|
2019-10-13 08:02:07 +02:00
|
|
|
|
using Ryujinx.Graphics.Shader;
|
2020-05-04 04:24:59 +02:00
|
|
|
|
using System;
|
2019-10-13 08:02:07 +02:00
|
|
|
|
|
|
|
|
|
namespace Ryujinx.Graphics.OpenGL
|
|
|
|
|
{
|
2019-12-31 23:09:49 +01:00
|
|
|
|
public sealed class Renderer : IRenderer
|
2019-10-13 08:02:07 +02:00
|
|
|
|
{
|
2020-03-29 05:02:58 +02:00
|
|
|
|
private readonly Pipeline _pipeline;
|
2019-12-31 23:09:49 +01:00
|
|
|
|
|
|
|
|
|
public IPipeline Pipeline => _pipeline;
|
2019-10-13 08:02:07 +02:00
|
|
|
|
|
2019-12-29 18:41:50 +01:00
|
|
|
|
private readonly Counters _counters;
|
2019-10-13 08:02:07 +02:00
|
|
|
|
|
2019-12-29 18:41:50 +01:00
|
|
|
|
private readonly Window _window;
|
2019-10-13 08:02:07 +02:00
|
|
|
|
|
|
|
|
|
public IWindow Window => _window;
|
|
|
|
|
|
Memory Read/Write Tracking using Region Handles (#1272)
* WIP Range Tracking
- Texture invalidation seems to have large problems
- Buffer/Pool invalidation may have problems
- Mirror memory tracking puts an additional `add` in compiled code, we likely just want to make HLE access slower if this is the final solution.
- Native project is in the messiest possible location.
- [HACK] JIT memory access always uses native "fast" path
- [HACK] Trying some things with texture invalidation and views.
It works :)
Still a few hacks, messy things, slow things
More work in progress stuff (also move to memory project)
Quite a bit faster now.
- Unmapping GPU VA and CPU VA will now correctly update write tracking regions, and invalidate textures for the former.
- The Virtual range list is now non-overlapping like the physical one.
- Fixed some bugs where regions could leak.
- Introduced a weird bug that I still need to track down (consistent invalid buffer in MK8 ribbon road)
Move some stuff.
I think we'll eventually just put the dll and so for this in a nuget package.
Fix rebase.
[WIP] MultiRegionHandle variable size ranges
- Avoid reprotecting regions that change often (needs some tweaking)
- There's still a bug in buffers, somehow.
- Might want different api for minimum granularity
Fix rebase issue
Commit everything needed for software only tracking.
Remove native components.
Remove more native stuff.
Cleanup
Use a separate window for the background context, update opentk. (fixes linux)
Some experimental changes
Should get things working up to scratch - still need to try some things with flush/modification and res scale.
Include address with the region action.
Initial work to make range tracking work
Still a ton of bugs
Fix some issues with the new stuff.
* Fix texture flush instability
There's still some weird behaviour, but it's much improved without this. (textures with cpu modified data were flushing over it)
* Find the destination texture for Buffer->Texture full copy
Greatly improves performance for nvdec videos (with range tracking)
* Further improve texture tracking
* Disable Memory Tracking for view parents
This is a temporary approach to better match behaviour on master (where invalidations would be soaked up by views, rather than trigger twice)
The assumption is that when views are created to a texture, they will cover all of its data anyways. Of course, this can easily be improved in future.
* Introduce some tracking tests.
WIP
* Complete base tests.
* Add more tests for multiregion, fix existing test.
* Cleanup Part 1
* Remove unnecessary code from memory tracking
* Fix some inconsistencies with 3D texture rule.
* Add dispose tests.
* Use a background thread for the background context.
Rather than setting and unsetting a context as current, doing the work on a dedicated thread with signals seems to be a bit faster.
Also nerf the multithreading test a bit.
* Copy to texture with matching alignment
This extends the copy to work for some videos with unusual size, such as tutorial videos in SMO. It will only occur if the destination texture already exists at XCount size.
* Track reads for buffer copies. Synchronize new buffers before copying overlaps.
* Remove old texture flushing mechanisms.
Range tracking all the way, baby.
* Wake the background thread when disposing.
Avoids a deadlock when games are closed.
* Address Feedback 1
* Separate TextureCopy instance for background thread
Also `BackgroundContextWorker.InBackground` for a more sensible idenfifier for if we're in a background thread.
* Add missing XML docs.
* Address Feedback
* Maybe I should start drinking coffee.
* Some more feedback.
* Remove flush warning, Refocus window after making background context
2020-10-16 22:18:35 +02:00
|
|
|
|
private TextureCopy _textureCopy;
|
|
|
|
|
private TextureCopy _backgroundTextureCopy;
|
|
|
|
|
internal TextureCopy TextureCopy => BackgroundContextWorker.InBackground ? _backgroundTextureCopy : _textureCopy;
|
2019-10-13 08:02:07 +02:00
|
|
|
|
|
2021-01-17 21:08:06 +01:00
|
|
|
|
private Sync _sync;
|
|
|
|
|
|
2021-06-28 22:09:43 +02:00
|
|
|
|
public event EventHandler<ScreenCaptureImageInfo> ScreenCaptured;
|
|
|
|
|
|
2021-07-16 23:10:20 +02:00
|
|
|
|
internal PersistentBuffers PersistentBuffers { get; }
|
|
|
|
|
|
2020-09-10 21:44:04 +02:00
|
|
|
|
internal ResourcePool ResourcePool { get; }
|
|
|
|
|
|
2021-03-08 22:43:39 +01:00
|
|
|
|
internal int BufferCount { get; private set; }
|
|
|
|
|
|
2020-03-24 22:54:09 +01:00
|
|
|
|
public string GpuVendor { get; private set; }
|
|
|
|
|
public string GpuRenderer { get; private set; }
|
|
|
|
|
public string GpuVersion { get; private set; }
|
|
|
|
|
|
2019-10-13 08:02:07 +02:00
|
|
|
|
public Renderer()
|
|
|
|
|
{
|
2019-12-31 23:09:49 +01:00
|
|
|
|
_pipeline = new Pipeline();
|
2019-10-13 08:02:07 +02:00
|
|
|
|
_counters = new Counters();
|
2020-03-29 05:02:58 +02:00
|
|
|
|
_window = new Window(this);
|
Memory Read/Write Tracking using Region Handles (#1272)
* WIP Range Tracking
- Texture invalidation seems to have large problems
- Buffer/Pool invalidation may have problems
- Mirror memory tracking puts an additional `add` in compiled code, we likely just want to make HLE access slower if this is the final solution.
- Native project is in the messiest possible location.
- [HACK] JIT memory access always uses native "fast" path
- [HACK] Trying some things with texture invalidation and views.
It works :)
Still a few hacks, messy things, slow things
More work in progress stuff (also move to memory project)
Quite a bit faster now.
- Unmapping GPU VA and CPU VA will now correctly update write tracking regions, and invalidate textures for the former.
- The Virtual range list is now non-overlapping like the physical one.
- Fixed some bugs where regions could leak.
- Introduced a weird bug that I still need to track down (consistent invalid buffer in MK8 ribbon road)
Move some stuff.
I think we'll eventually just put the dll and so for this in a nuget package.
Fix rebase.
[WIP] MultiRegionHandle variable size ranges
- Avoid reprotecting regions that change often (needs some tweaking)
- There's still a bug in buffers, somehow.
- Might want different api for minimum granularity
Fix rebase issue
Commit everything needed for software only tracking.
Remove native components.
Remove more native stuff.
Cleanup
Use a separate window for the background context, update opentk. (fixes linux)
Some experimental changes
Should get things working up to scratch - still need to try some things with flush/modification and res scale.
Include address with the region action.
Initial work to make range tracking work
Still a ton of bugs
Fix some issues with the new stuff.
* Fix texture flush instability
There's still some weird behaviour, but it's much improved without this. (textures with cpu modified data were flushing over it)
* Find the destination texture for Buffer->Texture full copy
Greatly improves performance for nvdec videos (with range tracking)
* Further improve texture tracking
* Disable Memory Tracking for view parents
This is a temporary approach to better match behaviour on master (where invalidations would be soaked up by views, rather than trigger twice)
The assumption is that when views are created to a texture, they will cover all of its data anyways. Of course, this can easily be improved in future.
* Introduce some tracking tests.
WIP
* Complete base tests.
* Add more tests for multiregion, fix existing test.
* Cleanup Part 1
* Remove unnecessary code from memory tracking
* Fix some inconsistencies with 3D texture rule.
* Add dispose tests.
* Use a background thread for the background context.
Rather than setting and unsetting a context as current, doing the work on a dedicated thread with signals seems to be a bit faster.
Also nerf the multithreading test a bit.
* Copy to texture with matching alignment
This extends the copy to work for some videos with unusual size, such as tutorial videos in SMO. It will only occur if the destination texture already exists at XCount size.
* Track reads for buffer copies. Synchronize new buffers before copying overlaps.
* Remove old texture flushing mechanisms.
Range tracking all the way, baby.
* Wake the background thread when disposing.
Avoids a deadlock when games are closed.
* Address Feedback 1
* Separate TextureCopy instance for background thread
Also `BackgroundContextWorker.InBackground` for a more sensible idenfifier for if we're in a background thread.
* Add missing XML docs.
* Address Feedback
* Maybe I should start drinking coffee.
* Some more feedback.
* Remove flush warning, Refocus window after making background context
2020-10-16 22:18:35 +02:00
|
|
|
|
_textureCopy = new TextureCopy(this);
|
|
|
|
|
_backgroundTextureCopy = new TextureCopy(this);
|
2021-01-17 21:08:06 +01:00
|
|
|
|
_sync = new Sync();
|
2021-07-16 23:10:20 +02:00
|
|
|
|
PersistentBuffers = new PersistentBuffers();
|
2020-09-10 21:44:04 +02:00
|
|
|
|
ResourcePool = new ResourcePool();
|
2019-10-13 08:02:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-08 12:10:00 +01:00
|
|
|
|
public IShader CompileShader(ShaderStage stage, string code)
|
2019-10-13 08:02:07 +02:00
|
|
|
|
{
|
2020-11-08 12:10:00 +01:00
|
|
|
|
return new Shader(stage, code);
|
2019-10-13 08:02:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-23 11:46:09 +02:00
|
|
|
|
public BufferHandle CreateBuffer(int size)
|
2019-10-13 08:02:07 +02:00
|
|
|
|
{
|
2021-03-08 22:43:39 +01:00
|
|
|
|
BufferCount++;
|
|
|
|
|
|
2020-05-23 11:46:09 +02:00
|
|
|
|
return Buffer.Create(size);
|
2019-10-13 08:02:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-15 05:01:10 +02:00
|
|
|
|
public IProgram CreateProgram(IShader[] shaders, TransformFeedbackDescriptor[] transformFeedbackDescriptors)
|
2019-10-13 08:02:07 +02:00
|
|
|
|
{
|
2020-07-15 05:01:10 +02:00
|
|
|
|
return new Program(shaders, transformFeedbackDescriptors);
|
2019-10-13 08:02:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ISampler CreateSampler(SamplerCreateInfo info)
|
|
|
|
|
{
|
|
|
|
|
return new Sampler(info);
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-07 04:41:07 +02:00
|
|
|
|
public ITexture CreateTexture(TextureCreateInfo info, float scaleFactor)
|
2019-10-13 08:02:07 +02:00
|
|
|
|
{
|
2020-09-10 21:44:04 +02:00
|
|
|
|
if (info.Target == Target.TextureBuffer)
|
|
|
|
|
{
|
2021-03-08 22:43:39 +01:00
|
|
|
|
return new TextureBuffer(this, info);
|
2020-09-10 21:44:04 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return ResourcePool.GetTextureOrNull(info, scaleFactor) ?? new TextureStorage(this, info, scaleFactor).CreateDefaultView();
|
|
|
|
|
}
|
2019-10-13 08:02:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-23 11:46:09 +02:00
|
|
|
|
public void DeleteBuffer(BufferHandle buffer)
|
|
|
|
|
{
|
|
|
|
|
Buffer.Delete(buffer);
|
|
|
|
|
}
|
|
|
|
|
|
Return mapped buffer pointer directly for flush, WriteableRegion for textures (#2494)
* Return mapped buffer pointer directly for flush, WriteableRegion for textures
A few changes here to generally improve performance, even for platforms not using the persistent buffer flush.
- Texture and buffer flush now return a ReadOnlySpan<byte>. It's guaranteed that this span is pinned in memory, but it will be overwritten on the next flush from that thread, so it is expected that the data is used before calling again.
- As a result, persistent mappings no longer copy to a new array - rather the persistent map is returned directly as a Span<>. A similar host array is used for the glGet flushes instead of allocating new arrays each time.
- Texture flushes now do their layout conversion into a WriteableRegion when the texture is not MultiRange, which allows the flush to happen directly into guest memory rather than into a temporary span, then copied over. This avoids another copy when doing layout conversion.
Overall, this saves 1 data copy for buffer flush, 1 copy for linear textures with matching source/target stride, and 2 copies for block textures or linear textures with mismatching strides.
* Fix tests
* Fix array pointer for Mesa/Intel path
* Address some feedback
* Update method for getting array pointer.
2021-07-20 00:10:54 +02:00
|
|
|
|
public ReadOnlySpan<byte> GetBufferData(BufferHandle buffer, int offset, int size)
|
2020-05-23 11:46:09 +02:00
|
|
|
|
{
|
Return mapped buffer pointer directly for flush, WriteableRegion for textures (#2494)
* Return mapped buffer pointer directly for flush, WriteableRegion for textures
A few changes here to generally improve performance, even for platforms not using the persistent buffer flush.
- Texture and buffer flush now return a ReadOnlySpan<byte>. It's guaranteed that this span is pinned in memory, but it will be overwritten on the next flush from that thread, so it is expected that the data is used before calling again.
- As a result, persistent mappings no longer copy to a new array - rather the persistent map is returned directly as a Span<>. A similar host array is used for the glGet flushes instead of allocating new arrays each time.
- Texture flushes now do their layout conversion into a WriteableRegion when the texture is not MultiRange, which allows the flush to happen directly into guest memory rather than into a temporary span, then copied over. This avoids another copy when doing layout conversion.
Overall, this saves 1 data copy for buffer flush, 1 copy for linear textures with matching source/target stride, and 2 copies for block textures or linear textures with mismatching strides.
* Fix tests
* Fix array pointer for Mesa/Intel path
* Address some feedback
* Update method for getting array pointer.
2021-07-20 00:10:54 +02:00
|
|
|
|
return Buffer.GetData(this, buffer, offset, size);
|
2020-05-23 11:46:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-13 08:02:07 +02:00
|
|
|
|
public Capabilities GetCapabilities()
|
|
|
|
|
{
|
2019-12-01 03:53:09 +01:00
|
|
|
|
return new Capabilities(
|
|
|
|
|
HwCapabilities.SupportsAstcCompression,
|
2020-05-27 11:00:21 +02:00
|
|
|
|
HwCapabilities.SupportsImageLoadFormatted,
|
2021-05-16 20:43:27 +02:00
|
|
|
|
HwCapabilities.SupportsMismatchingViewFormat,
|
2021-06-25 00:54:50 +02:00
|
|
|
|
HwCapabilities.SupportsNonConstantTextureOffset,
|
|
|
|
|
HwCapabilities.SupportsTextureShadowLod,
|
2020-05-28 01:03:07 +02:00
|
|
|
|
HwCapabilities.SupportsViewportSwizzle,
|
2019-12-09 03:55:22 +01:00
|
|
|
|
HwCapabilities.MaximumComputeSharedMemorySize,
|
2020-05-28 01:03:07 +02:00
|
|
|
|
HwCapabilities.MaximumSupportedAnisotropy,
|
|
|
|
|
HwCapabilities.StorageBufferOffsetAlignment);
|
2019-10-13 08:02:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-23 11:46:09 +02:00
|
|
|
|
public void SetBufferData(BufferHandle buffer, int offset, ReadOnlySpan<byte> data)
|
|
|
|
|
{
|
|
|
|
|
Buffer.SetData(buffer, offset, data);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-04 04:24:59 +02:00
|
|
|
|
public void UpdateCounters()
|
2019-10-13 08:02:07 +02:00
|
|
|
|
{
|
2020-05-04 04:24:59 +02:00
|
|
|
|
_counters.Update();
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-10 21:44:04 +02:00
|
|
|
|
public void PreFrame()
|
|
|
|
|
{
|
2021-01-17 21:08:06 +01:00
|
|
|
|
_sync.Cleanup();
|
2020-09-10 21:44:04 +02:00
|
|
|
|
ResourcePool.Tick();
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-04 04:24:59 +02:00
|
|
|
|
public ICounterEvent ReportCounter(CounterType type, EventHandler<ulong> resultHandler)
|
|
|
|
|
{
|
2020-12-03 19:42:59 +01:00
|
|
|
|
return _counters.QueueReport(type, resultHandler, _pipeline.DrawCount);
|
2019-10-13 08:02:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-08-02 16:41:24 +02:00
|
|
|
|
public void Initialize(GraphicsDebugLevel glLogLevel)
|
2019-10-13 08:02:07 +02:00
|
|
|
|
{
|
2020-08-02 16:41:24 +02:00
|
|
|
|
Debugger.Initialize(glLogLevel);
|
|
|
|
|
|
2020-01-10 01:40:55 +01:00
|
|
|
|
PrintGpuInformation();
|
2020-01-10 01:35:50 +01:00
|
|
|
|
|
2021-03-29 22:52:25 +02:00
|
|
|
|
if (HwCapabilities.SupportsParallelShaderCompile)
|
|
|
|
|
{
|
|
|
|
|
GL.Arb.MaxShaderCompilerThreads(Math.Min(Environment.ProcessorCount, 8));
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-13 08:02:07 +02:00
|
|
|
|
_counters.Initialize();
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-10 01:40:55 +01:00
|
|
|
|
private void PrintGpuInformation()
|
2020-01-10 01:35:50 +01:00
|
|
|
|
{
|
2020-03-24 22:54:09 +01:00
|
|
|
|
GpuVendor = GL.GetString(StringName.Vendor);
|
|
|
|
|
GpuRenderer = GL.GetString(StringName.Renderer);
|
|
|
|
|
GpuVersion = GL.GetString(StringName.Version);
|
2020-01-10 01:35:50 +01:00
|
|
|
|
|
2020-08-04 01:32:53 +02:00
|
|
|
|
Logger.Notice.Print(LogClass.Gpu, $"{GpuVendor} {GpuRenderer} ({GpuVersion})");
|
2020-01-10 01:35:50 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-13 08:02:07 +02:00
|
|
|
|
public void ResetCounter(CounterType type)
|
|
|
|
|
{
|
2020-05-04 04:24:59 +02:00
|
|
|
|
_counters.QueueReset(type);
|
2019-10-13 08:02:07 +02:00
|
|
|
|
}
|
2019-12-31 23:09:49 +01:00
|
|
|
|
|
Memory Read/Write Tracking using Region Handles (#1272)
* WIP Range Tracking
- Texture invalidation seems to have large problems
- Buffer/Pool invalidation may have problems
- Mirror memory tracking puts an additional `add` in compiled code, we likely just want to make HLE access slower if this is the final solution.
- Native project is in the messiest possible location.
- [HACK] JIT memory access always uses native "fast" path
- [HACK] Trying some things with texture invalidation and views.
It works :)
Still a few hacks, messy things, slow things
More work in progress stuff (also move to memory project)
Quite a bit faster now.
- Unmapping GPU VA and CPU VA will now correctly update write tracking regions, and invalidate textures for the former.
- The Virtual range list is now non-overlapping like the physical one.
- Fixed some bugs where regions could leak.
- Introduced a weird bug that I still need to track down (consistent invalid buffer in MK8 ribbon road)
Move some stuff.
I think we'll eventually just put the dll and so for this in a nuget package.
Fix rebase.
[WIP] MultiRegionHandle variable size ranges
- Avoid reprotecting regions that change often (needs some tweaking)
- There's still a bug in buffers, somehow.
- Might want different api for minimum granularity
Fix rebase issue
Commit everything needed for software only tracking.
Remove native components.
Remove more native stuff.
Cleanup
Use a separate window for the background context, update opentk. (fixes linux)
Some experimental changes
Should get things working up to scratch - still need to try some things with flush/modification and res scale.
Include address with the region action.
Initial work to make range tracking work
Still a ton of bugs
Fix some issues with the new stuff.
* Fix texture flush instability
There's still some weird behaviour, but it's much improved without this. (textures with cpu modified data were flushing over it)
* Find the destination texture for Buffer->Texture full copy
Greatly improves performance for nvdec videos (with range tracking)
* Further improve texture tracking
* Disable Memory Tracking for view parents
This is a temporary approach to better match behaviour on master (where invalidations would be soaked up by views, rather than trigger twice)
The assumption is that when views are created to a texture, they will cover all of its data anyways. Of course, this can easily be improved in future.
* Introduce some tracking tests.
WIP
* Complete base tests.
* Add more tests for multiregion, fix existing test.
* Cleanup Part 1
* Remove unnecessary code from memory tracking
* Fix some inconsistencies with 3D texture rule.
* Add dispose tests.
* Use a background thread for the background context.
Rather than setting and unsetting a context as current, doing the work on a dedicated thread with signals seems to be a bit faster.
Also nerf the multithreading test a bit.
* Copy to texture with matching alignment
This extends the copy to work for some videos with unusual size, such as tutorial videos in SMO. It will only occur if the destination texture already exists at XCount size.
* Track reads for buffer copies. Synchronize new buffers before copying overlaps.
* Remove old texture flushing mechanisms.
Range tracking all the way, baby.
* Wake the background thread when disposing.
Avoids a deadlock when games are closed.
* Address Feedback 1
* Separate TextureCopy instance for background thread
Also `BackgroundContextWorker.InBackground` for a more sensible idenfifier for if we're in a background thread.
* Add missing XML docs.
* Address Feedback
* Maybe I should start drinking coffee.
* Some more feedback.
* Remove flush warning, Refocus window after making background context
2020-10-16 22:18:35 +02:00
|
|
|
|
public void BackgroundContextAction(Action action)
|
|
|
|
|
{
|
2021-04-14 12:28:43 +02:00
|
|
|
|
if (IOpenGLContext.HasContext())
|
Memory Read/Write Tracking using Region Handles (#1272)
* WIP Range Tracking
- Texture invalidation seems to have large problems
- Buffer/Pool invalidation may have problems
- Mirror memory tracking puts an additional `add` in compiled code, we likely just want to make HLE access slower if this is the final solution.
- Native project is in the messiest possible location.
- [HACK] JIT memory access always uses native "fast" path
- [HACK] Trying some things with texture invalidation and views.
It works :)
Still a few hacks, messy things, slow things
More work in progress stuff (also move to memory project)
Quite a bit faster now.
- Unmapping GPU VA and CPU VA will now correctly update write tracking regions, and invalidate textures for the former.
- The Virtual range list is now non-overlapping like the physical one.
- Fixed some bugs where regions could leak.
- Introduced a weird bug that I still need to track down (consistent invalid buffer in MK8 ribbon road)
Move some stuff.
I think we'll eventually just put the dll and so for this in a nuget package.
Fix rebase.
[WIP] MultiRegionHandle variable size ranges
- Avoid reprotecting regions that change often (needs some tweaking)
- There's still a bug in buffers, somehow.
- Might want different api for minimum granularity
Fix rebase issue
Commit everything needed for software only tracking.
Remove native components.
Remove more native stuff.
Cleanup
Use a separate window for the background context, update opentk. (fixes linux)
Some experimental changes
Should get things working up to scratch - still need to try some things with flush/modification and res scale.
Include address with the region action.
Initial work to make range tracking work
Still a ton of bugs
Fix some issues with the new stuff.
* Fix texture flush instability
There's still some weird behaviour, but it's much improved without this. (textures with cpu modified data were flushing over it)
* Find the destination texture for Buffer->Texture full copy
Greatly improves performance for nvdec videos (with range tracking)
* Further improve texture tracking
* Disable Memory Tracking for view parents
This is a temporary approach to better match behaviour on master (where invalidations would be soaked up by views, rather than trigger twice)
The assumption is that when views are created to a texture, they will cover all of its data anyways. Of course, this can easily be improved in future.
* Introduce some tracking tests.
WIP
* Complete base tests.
* Add more tests for multiregion, fix existing test.
* Cleanup Part 1
* Remove unnecessary code from memory tracking
* Fix some inconsistencies with 3D texture rule.
* Add dispose tests.
* Use a background thread for the background context.
Rather than setting and unsetting a context as current, doing the work on a dedicated thread with signals seems to be a bit faster.
Also nerf the multithreading test a bit.
* Copy to texture with matching alignment
This extends the copy to work for some videos with unusual size, such as tutorial videos in SMO. It will only occur if the destination texture already exists at XCount size.
* Track reads for buffer copies. Synchronize new buffers before copying overlaps.
* Remove old texture flushing mechanisms.
Range tracking all the way, baby.
* Wake the background thread when disposing.
Avoids a deadlock when games are closed.
* Address Feedback 1
* Separate TextureCopy instance for background thread
Also `BackgroundContextWorker.InBackground` for a more sensible idenfifier for if we're in a background thread.
* Add missing XML docs.
* Address Feedback
* Maybe I should start drinking coffee.
* Some more feedback.
* Remove flush warning, Refocus window after making background context
2020-10-16 22:18:35 +02:00
|
|
|
|
{
|
|
|
|
|
action(); // We have a context already - use that (assuming it is the main one).
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_window.BackgroundContext.Invoke(action);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-14 12:28:43 +02:00
|
|
|
|
public void InitializeBackgroundContext(IOpenGLContext baseContext)
|
Memory Read/Write Tracking using Region Handles (#1272)
* WIP Range Tracking
- Texture invalidation seems to have large problems
- Buffer/Pool invalidation may have problems
- Mirror memory tracking puts an additional `add` in compiled code, we likely just want to make HLE access slower if this is the final solution.
- Native project is in the messiest possible location.
- [HACK] JIT memory access always uses native "fast" path
- [HACK] Trying some things with texture invalidation and views.
It works :)
Still a few hacks, messy things, slow things
More work in progress stuff (also move to memory project)
Quite a bit faster now.
- Unmapping GPU VA and CPU VA will now correctly update write tracking regions, and invalidate textures for the former.
- The Virtual range list is now non-overlapping like the physical one.
- Fixed some bugs where regions could leak.
- Introduced a weird bug that I still need to track down (consistent invalid buffer in MK8 ribbon road)
Move some stuff.
I think we'll eventually just put the dll and so for this in a nuget package.
Fix rebase.
[WIP] MultiRegionHandle variable size ranges
- Avoid reprotecting regions that change often (needs some tweaking)
- There's still a bug in buffers, somehow.
- Might want different api for minimum granularity
Fix rebase issue
Commit everything needed for software only tracking.
Remove native components.
Remove more native stuff.
Cleanup
Use a separate window for the background context, update opentk. (fixes linux)
Some experimental changes
Should get things working up to scratch - still need to try some things with flush/modification and res scale.
Include address with the region action.
Initial work to make range tracking work
Still a ton of bugs
Fix some issues with the new stuff.
* Fix texture flush instability
There's still some weird behaviour, but it's much improved without this. (textures with cpu modified data were flushing over it)
* Find the destination texture for Buffer->Texture full copy
Greatly improves performance for nvdec videos (with range tracking)
* Further improve texture tracking
* Disable Memory Tracking for view parents
This is a temporary approach to better match behaviour on master (where invalidations would be soaked up by views, rather than trigger twice)
The assumption is that when views are created to a texture, they will cover all of its data anyways. Of course, this can easily be improved in future.
* Introduce some tracking tests.
WIP
* Complete base tests.
* Add more tests for multiregion, fix existing test.
* Cleanup Part 1
* Remove unnecessary code from memory tracking
* Fix some inconsistencies with 3D texture rule.
* Add dispose tests.
* Use a background thread for the background context.
Rather than setting and unsetting a context as current, doing the work on a dedicated thread with signals seems to be a bit faster.
Also nerf the multithreading test a bit.
* Copy to texture with matching alignment
This extends the copy to work for some videos with unusual size, such as tutorial videos in SMO. It will only occur if the destination texture already exists at XCount size.
* Track reads for buffer copies. Synchronize new buffers before copying overlaps.
* Remove old texture flushing mechanisms.
Range tracking all the way, baby.
* Wake the background thread when disposing.
Avoids a deadlock when games are closed.
* Address Feedback 1
* Separate TextureCopy instance for background thread
Also `BackgroundContextWorker.InBackground` for a more sensible idenfifier for if we're in a background thread.
* Add missing XML docs.
* Address Feedback
* Maybe I should start drinking coffee.
* Some more feedback.
* Remove flush warning, Refocus window after making background context
2020-10-16 22:18:35 +02:00
|
|
|
|
{
|
|
|
|
|
_window.InitializeBackgroundContext(baseContext);
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-31 23:09:49 +01:00
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
Memory Read/Write Tracking using Region Handles (#1272)
* WIP Range Tracking
- Texture invalidation seems to have large problems
- Buffer/Pool invalidation may have problems
- Mirror memory tracking puts an additional `add` in compiled code, we likely just want to make HLE access slower if this is the final solution.
- Native project is in the messiest possible location.
- [HACK] JIT memory access always uses native "fast" path
- [HACK] Trying some things with texture invalidation and views.
It works :)
Still a few hacks, messy things, slow things
More work in progress stuff (also move to memory project)
Quite a bit faster now.
- Unmapping GPU VA and CPU VA will now correctly update write tracking regions, and invalidate textures for the former.
- The Virtual range list is now non-overlapping like the physical one.
- Fixed some bugs where regions could leak.
- Introduced a weird bug that I still need to track down (consistent invalid buffer in MK8 ribbon road)
Move some stuff.
I think we'll eventually just put the dll and so for this in a nuget package.
Fix rebase.
[WIP] MultiRegionHandle variable size ranges
- Avoid reprotecting regions that change often (needs some tweaking)
- There's still a bug in buffers, somehow.
- Might want different api for minimum granularity
Fix rebase issue
Commit everything needed for software only tracking.
Remove native components.
Remove more native stuff.
Cleanup
Use a separate window for the background context, update opentk. (fixes linux)
Some experimental changes
Should get things working up to scratch - still need to try some things with flush/modification and res scale.
Include address with the region action.
Initial work to make range tracking work
Still a ton of bugs
Fix some issues with the new stuff.
* Fix texture flush instability
There's still some weird behaviour, but it's much improved without this. (textures with cpu modified data were flushing over it)
* Find the destination texture for Buffer->Texture full copy
Greatly improves performance for nvdec videos (with range tracking)
* Further improve texture tracking
* Disable Memory Tracking for view parents
This is a temporary approach to better match behaviour on master (where invalidations would be soaked up by views, rather than trigger twice)
The assumption is that when views are created to a texture, they will cover all of its data anyways. Of course, this can easily be improved in future.
* Introduce some tracking tests.
WIP
* Complete base tests.
* Add more tests for multiregion, fix existing test.
* Cleanup Part 1
* Remove unnecessary code from memory tracking
* Fix some inconsistencies with 3D texture rule.
* Add dispose tests.
* Use a background thread for the background context.
Rather than setting and unsetting a context as current, doing the work on a dedicated thread with signals seems to be a bit faster.
Also nerf the multithreading test a bit.
* Copy to texture with matching alignment
This extends the copy to work for some videos with unusual size, such as tutorial videos in SMO. It will only occur if the destination texture already exists at XCount size.
* Track reads for buffer copies. Synchronize new buffers before copying overlaps.
* Remove old texture flushing mechanisms.
Range tracking all the way, baby.
* Wake the background thread when disposing.
Avoids a deadlock when games are closed.
* Address Feedback 1
* Separate TextureCopy instance for background thread
Also `BackgroundContextWorker.InBackground` for a more sensible idenfifier for if we're in a background thread.
* Add missing XML docs.
* Address Feedback
* Maybe I should start drinking coffee.
* Some more feedback.
* Remove flush warning, Refocus window after making background context
2020-10-16 22:18:35 +02:00
|
|
|
|
_textureCopy.Dispose();
|
|
|
|
|
_backgroundTextureCopy.Dispose();
|
2021-07-16 23:10:20 +02:00
|
|
|
|
PersistentBuffers.Dispose();
|
2020-09-10 21:44:04 +02:00
|
|
|
|
ResourcePool.Dispose();
|
2019-12-31 23:09:49 +01:00
|
|
|
|
_pipeline.Dispose();
|
|
|
|
|
_window.Dispose();
|
2020-05-04 04:24:59 +02:00
|
|
|
|
_counters.Dispose();
|
2021-01-17 21:08:06 +01:00
|
|
|
|
_sync.Dispose();
|
2019-12-31 23:09:49 +01:00
|
|
|
|
}
|
2020-11-13 00:15:34 +01:00
|
|
|
|
|
|
|
|
|
public IProgram LoadProgramBinary(byte[] programBinary)
|
|
|
|
|
{
|
2021-03-29 22:52:25 +02:00
|
|
|
|
return new Program(programBinary);
|
2020-11-13 00:15:34 +01:00
|
|
|
|
}
|
2021-01-17 21:08:06 +01:00
|
|
|
|
|
|
|
|
|
public void CreateSync(ulong id)
|
|
|
|
|
{
|
|
|
|
|
_sync.Create(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void WaitSync(ulong id)
|
|
|
|
|
{
|
|
|
|
|
_sync.Wait(id);
|
|
|
|
|
}
|
2021-06-28 22:09:43 +02:00
|
|
|
|
|
|
|
|
|
public void Screenshot()
|
|
|
|
|
{
|
|
|
|
|
_window.ScreenCaptureRequested = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnScreenCaptured(ScreenCaptureImageInfo bitmap)
|
|
|
|
|
{
|
|
|
|
|
ScreenCaptured?.Invoke(this, bitmap);
|
|
|
|
|
}
|
2019-10-13 08:02:07 +02:00
|
|
|
|
}
|
|
|
|
|
}
|