Initial support for the guest OpenGL driver (NVIDIA and Nouveau)
This commit is contained in:
parent
6a98c643ca
commit
e25b7c9848
25 changed files with 581 additions and 102 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue