0
0
Fork 0

Reimplement limited bindless textures support

This commit is contained in:
gdkchan 2019-12-27 22:16:14 -03:00 committed by Thog
parent 647d0962df
commit 947e14d3be
6 changed files with 65 additions and 5 deletions

View file

@ -97,7 +97,14 @@ namespace Ryujinx.Graphics.Gpu.Engine
Target target = GetTarget(descriptor.Type);
textureBindings[index] = new TextureBindingInfo(target, descriptor.HandleIndex);
if (descriptor.IsBindless)
{
textureBindings[index] = new TextureBindingInfo(target, descriptor.CbufOffset, descriptor.CbufSlot);
}
else
{
textureBindings[index] = new TextureBindingInfo(target, descriptor.HandleIndex);
}
}
_textureManager.SetComputeTextures(textureBindings);

View file

@ -694,7 +694,14 @@ namespace Ryujinx.Graphics.Gpu.Engine
Target target = GetTarget(descriptor.Type);
textureBindings[index] = new TextureBindingInfo(target, descriptor.HandleIndex);
if (descriptor.IsBindless)
{
textureBindings[index] = new TextureBindingInfo(target, descriptor.CbufSlot, descriptor.CbufOffset);
}
else
{
textureBindings[index] = new TextureBindingInfo(target, descriptor.HandleIndex);
}
}
_textureManager.SetGraphicsTextures(stage, textureBindings);

View file

@ -8,10 +8,31 @@ namespace Ryujinx.Graphics.Gpu.Image
public int Handle { get; }
public bool IsBindless { get; }
public int CbufSlot { get; }
public int CbufOffset { get; }
public TextureBindingInfo(Target target, int handle)
{
Target = target;
Handle = handle;
IsBindless = false;
CbufSlot = 0;
CbufOffset = 0;
}
public TextureBindingInfo(Target target, int cbufSlot, int cbufOffset)
{
Target = target;
Handle = 0;
IsBindless = true;
CbufSlot = cbufSlot;
CbufOffset = cbufOffset;
}
}
}

View file

@ -2,6 +2,7 @@ using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Gpu.State;
using Ryujinx.Graphics.Shader;
using System;
using System.Runtime.InteropServices;
namespace Ryujinx.Graphics.Gpu.Image
{
@ -133,7 +134,29 @@ namespace Ryujinx.Graphics.Gpu.Image
{
TextureBindingInfo binding = _textureBindings[stageIndex][index];
int packedId = ReadPackedId(stageIndex, binding.Handle);
int packedId;
if (binding.IsBindless)
{
ulong address;
var bufferManager = _context.Methods.BufferManager;
if (_isCompute)
{
address = bufferManager.GetComputeUniformBufferAddress(binding.CbufSlot);
}
else
{
address = bufferManager.GetGraphicsUniformBufferAddress(stageIndex, binding.CbufSlot);
}
packedId = MemoryMarshal.Cast<byte, int>(_context.PhysicalMemory.Read(address + (ulong)binding.CbufOffset * 4, 4))[0];
}
else
{
packedId = ReadPackedId(stageIndex, binding.Handle);
}
int textureId = UnpackTextureId(packedId);
int samplerId;

View file

@ -272,6 +272,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
AstOperand operand = texOp.GetSource(0) as AstOperand;
desc = new TextureDescriptor(samplerName, texOp.Type, operand.CbufSlot, operand.CbufOffset);
context.TextureDescriptors.Add(desc);
}
else if ((texOp.Type & SamplerType.Indexed) != 0)
{

View file

@ -13,11 +13,11 @@ namespace Ryujinx.Graphics.Shader
public int CbufSlot { get; }
public int CbufOffset { get; }
public TextureDescriptor(string name, SamplerType type, int hIndex)
public TextureDescriptor(string name, SamplerType type, int handleIndex)
{
Name = name;
Type = type;
HandleIndex = hIndex;
HandleIndex = handleIndex;
IsBindless = false;