mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-07 22:48:36 +00:00
Reimplement limited bindless textures support
This commit is contained in:
parent
647d0962df
commit
947e14d3be
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue