Support separate textures and samplers (#1216)
* Support separate textures and samplers * Add missing bindless flag, fix SNORM format on buffer textures * Add missing separation * Add comments about the new handles
This commit is contained in:
parent
0b6d206daa
commit
5795bb1528
17 changed files with 240 additions and 59 deletions
|
@ -1,8 +1,6 @@
|
|||
using Ryujinx.Graphics.GAL;
|
||||
using Ryujinx.Graphics.Gpu.State;
|
||||
using Ryujinx.Graphics.Shader;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.Graphics.Gpu.Image
|
||||
{
|
||||
|
@ -11,6 +9,9 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
/// </summary>
|
||||
class TextureBindingsManager
|
||||
{
|
||||
private const int HandleHigh = 16;
|
||||
private const int HandleMask = (1 << HandleHigh) - 1;
|
||||
|
||||
private GpuContext _context;
|
||||
|
||||
private bool _isCompute;
|
||||
|
@ -114,7 +115,6 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
}
|
||||
|
||||
_samplerPool = new SamplerPool(_context, address, maximumId);
|
||||
|
||||
_samplerIndex = samplerIndex;
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
address = bufferManager.GetGraphicsUniformBufferAddress(stageIndex, binding.CbufSlot);
|
||||
}
|
||||
|
||||
packedId = MemoryMarshal.Cast<byte, int>(_context.PhysicalMemory.GetSpan(address + (ulong)binding.CbufOffset * 4, 4))[0];
|
||||
packedId = _context.PhysicalMemory.Read<int>(address + (ulong)binding.CbufOffset * 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -324,9 +324,20 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||
address = bufferManager.GetGraphicsUniformBufferAddress(stageIndex, textureBufferIndex);
|
||||
}
|
||||
|
||||
address += (uint)wordOffset * 4;
|
||||
int handle = _context.PhysicalMemory.Read<int>(address + (ulong)(wordOffset & HandleMask) * 4);
|
||||
|
||||
return BitConverter.ToInt32(_context.PhysicalMemory.GetSpan(address, 4));
|
||||
// The "wordOffset" (which is really the immediate value used on texture instructions on the shader)
|
||||
// is a 13-bit value. However, in order to also support separate samplers and textures (which uses
|
||||
// bindless textures on the shader), we extend it with another value on the higher 16 bits with
|
||||
// another offset for the sampler.
|
||||
// The shader translator has code to detect separate texture and sampler uses with a bindless texture,
|
||||
// turn that into a regular texture access and produce those special handles with values on the higher 16 bits.
|
||||
if (wordOffset >> HandleHigh != 0)
|
||||
{
|
||||
handle |= _context.PhysicalMemory.Read<int>(address + (ulong)(wordOffset >> HandleHigh) * 4);
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue