diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2019-12-05 17:34:47 -0300 |
|---|---|---|
| committer | Thog <thog@protonmail.com> | 2020-01-09 02:13:00 +0100 |
| commit | e25b7c9848b6ec486eb513297b5c536857665c7f (patch) | |
| tree | c1ccb6c58bed0f7ece835359516330104feb8f4d /Ryujinx.Graphics.Gpu/Image | |
| parent | 6a98c643cabeea25dc42e19fe475a687a034a532 (diff) | |
Initial support for the guest OpenGL driver (NVIDIA and Nouveau)
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Image')
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Image/Texture.cs | 31 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs | 18 | ||||
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Image/TextureManager.cs | 21 |
3 files changed, 63 insertions, 7 deletions
diff --git a/Ryujinx.Graphics.Gpu/Image/Texture.cs b/Ryujinx.Graphics.Gpu/Image/Texture.cs index 120abe3f..5e057588 100644 --- a/Ryujinx.Graphics.Gpu/Image/Texture.cs +++ b/Ryujinx.Graphics.Gpu/Image/Texture.cs @@ -277,7 +277,36 @@ namespace Ryujinx.Graphics.Gpu.Image public void Flush() { - byte[] data = HostTexture.GetData(0); + Span<byte> data = HostTexture.GetData(); + + if (_info.IsLinear) + { + data = LayoutConverter.ConvertLinearToLinearStrided( + _info.Width, + _info.Height, + _info.FormatInfo.BlockWidth, + _info.FormatInfo.BlockHeight, + _info.Stride, + _info.FormatInfo.BytesPerPixel, + data); + } + else + { + data = LayoutConverter.ConvertLinearToBlockLinear( + _info.Width, + _info.Height, + _depth, + _info.Levels, + _layers, + _info.FormatInfo.BlockWidth, + _info.FormatInfo.BlockHeight, + _info.FormatInfo.BytesPerPixel, + _info.GobBlocksInY, + _info.GobBlocksInZ, + _info.GobBlocksInTileX, + _sizeInfo, + data); + } _context.PhysicalMemory.Write(Address, data); } diff --git a/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs b/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs index 74d7a76a..290bb665 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs @@ -1,4 +1,5 @@ using Ryujinx.Graphics.GAL; +using Ryujinx.Graphics.Gpu.State; using Ryujinx.Graphics.Shader; using System; @@ -12,6 +13,8 @@ namespace Ryujinx.Graphics.Gpu.Image private SamplerPool _samplerPool; + private SamplerIndex _samplerIndex; + private ulong _texturePoolAddress; private int _texturePoolMaximumId; @@ -67,7 +70,7 @@ namespace Ryujinx.Graphics.Gpu.Image _textureBufferIndex = index; } - public void SetSamplerPool(ulong gpuVa, int maximumId) + public void SetSamplerPool(ulong gpuVa, int maximumId, SamplerIndex samplerIndex) { ulong address = _context.MemoryManager.Translate(gpuVa); @@ -82,6 +85,8 @@ namespace Ryujinx.Graphics.Gpu.Image } _samplerPool = new SamplerPool(_context, address, maximumId); + + _samplerIndex = samplerIndex; } public void SetTexturePool(ulong gpuVa, int maximumId) @@ -131,7 +136,16 @@ namespace Ryujinx.Graphics.Gpu.Image int packedId = ReadPackedId(stageIndex, binding.Handle); int textureId = UnpackTextureId(packedId); - int samplerId = UnpackSamplerId(packedId); + int samplerId; + + if (_samplerIndex == SamplerIndex.ViaHeaderIndex) + { + samplerId = textureId; + } + else + { + samplerId = UnpackSamplerId(packedId); + } Texture texture = pool.Get(textureId); diff --git a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs index 5e5b1c97..ce0cc249 100644 --- a/Ryujinx.Graphics.Gpu/Image/TextureManager.cs +++ b/Ryujinx.Graphics.Gpu/Image/TextureManager.cs @@ -81,14 +81,14 @@ namespace Ryujinx.Graphics.Gpu.Image _gpBindingsManager.SetTextureBufferIndex(index); } - public void SetComputeSamplerPool(ulong gpuVa, int maximumId) + public void SetComputeSamplerPool(ulong gpuVa, int maximumId, SamplerIndex samplerIndex) { - _cpBindingsManager.SetSamplerPool(gpuVa, maximumId); + _cpBindingsManager.SetSamplerPool(gpuVa, maximumId, samplerIndex); } - public void SetGraphicsSamplerPool(ulong gpuVa, int maximumId) + public void SetGraphicsSamplerPool(ulong gpuVa, int maximumId, SamplerIndex samplerIndex) { - _gpBindingsManager.SetSamplerPool(gpuVa, maximumId); + _gpBindingsManager.SetSamplerPool(gpuVa, maximumId, samplerIndex); } public void SetComputeTexturePool(ulong gpuVa, int maximumId) @@ -599,6 +599,19 @@ namespace Ryujinx.Graphics.Gpu.Image } } + public void Flush(ulong address, ulong size) + { + foreach (Texture texture in _cache) + { + if (texture.OverlapsWith(address, size) && texture.Modified) + { + texture.Flush(); + + texture.Modified = false; + } + } + } + public void RemoveTextureFromCache(Texture texture) { _textures.Remove(texture); |
