diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2018-08-15 15:59:51 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-15 15:59:51 -0300 |
| commit | c393cdf8e3775bc95850e4d8c8e4c446b286d3b4 (patch) | |
| tree | 25035a244741d2daf3f7d6be8b23153ff061ea15 /Ryujinx.HLE/Gpu/Engines | |
| parent | 76d95dee05e3c51c18e1799f54cc407e0f633b4e (diff) | |
More flexible memory manager (#307)
* Keep track mapped buffers with fixed offsets
* Started rewriting the memory manager
* Initial support for MapPhysicalMemory and UnmapPhysicalMemory, other tweaks
* MapPhysicalMemory/UnmapPhysicalMemory support, other tweaks
* Rebased
* Optimize the map/unmap physical memory svcs
* Integrate shared font support
* Fix address space reserve alignment
* Some fixes related to gpu memory mapping
* Some cleanup
* Only try uploading const buffers that are really used
* Check if memory region is contiguous
* Rebased
* Add missing count increment on IsRegionModified
* Check for reads/writes outside of the address space, optimize translation with a tail call
Diffstat (limited to 'Ryujinx.HLE/Gpu/Engines')
| -rw-r--r-- | Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs index cb1514b5..6f601244 100644 --- a/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs +++ b/Ryujinx.HLE/Gpu/Engines/NvGpuEngine3d.cs @@ -109,7 +109,7 @@ namespace Ryujinx.HLE.Gpu.Engines Gpu.Renderer.Shader.BindProgram(); UploadTextures(Vmm, State, Keys); - UploadConstBuffers(Vmm, State); + UploadConstBuffers(Vmm, State, Keys); UploadVertexArrays(Vmm, State); DispatchRender(Vmm, State); @@ -426,6 +426,12 @@ namespace Ryujinx.HLE.Gpu.Engines Key = Vmm.GetPhysicalAddress(Key); + if (Key == -1) + { + //FIXME: Should'nt ignore invalid addresses. + return; + } + if (IsFrameBufferPosition(Key)) { //This texture is a frame buffer texture, @@ -465,24 +471,29 @@ namespace Ryujinx.HLE.Gpu.Engines Gpu.Renderer.Texture.SetSampler(Sampler); } - private void UploadConstBuffers(NvGpuVmm Vmm, GalPipelineState State) + private void UploadConstBuffers(NvGpuVmm Vmm, GalPipelineState State, long[] Keys) { - for (int Stage = 0; Stage < State.ConstBufferKeys.Length; Stage++) + for (int Stage = 0; Stage < Keys.Length; Stage++) { - for (int Index = 0; Index < State.ConstBufferKeys[Stage].Length; Index++) + foreach (ShaderDeclInfo DeclInfo in Gpu.Renderer.Shader.GetConstBufferUsage(Keys[Stage])) { - ConstBuffer Cb = ConstBuffers[Stage][Index]; + ConstBuffer Cb = ConstBuffers[Stage][DeclInfo.Cbuf]; - long Key = Cb.Position; + if (!Cb.Enabled) + { + continue; + } - if (Cb.Enabled && QueryKeyUpload(Vmm, Key, Cb.Size, NvGpuBufferType.ConstBuffer)) + long Key = Vmm.GetPhysicalAddress(Cb.Position); + + if (QueryKeyUpload(Vmm, Key, Cb.Size, NvGpuBufferType.ConstBuffer)) { - IntPtr Source = Vmm.GetHostAddress(Key, Cb.Size); + IntPtr Source = Vmm.GetHostAddress(Cb.Position, Cb.Size); Gpu.Renderer.Buffer.SetData(Key, Cb.Size, Source); } - State.ConstBufferKeys[Stage][Index] = Key; + State.ConstBufferKeys[Stage][DeclInfo.Cbuf] = Key; } } } @@ -668,11 +679,13 @@ namespace Ryujinx.HLE.Gpu.Engines long Position = MakeInt64From2xInt32(NvGpuEngine3dReg.ConstBufferAddress); + long CbKey = Vmm.GetPhysicalAddress(Position); + int Size = ReadRegister(NvGpuEngine3dReg.ConstBufferSize); - if (!Gpu.Renderer.Buffer.IsCached(Position, Size)) + if (!Gpu.Renderer.Buffer.IsCached(CbKey, Size)) { - Gpu.Renderer.Buffer.Create(Position, Size); + Gpu.Renderer.Buffer.Create(CbKey, Size); } ConstBuffer Cb = ConstBuffers[Stage][Index]; |
