mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-12-23 12:45:48 +00:00
Reimplement limited bindless textures support
This commit is contained in:
parent
647d0962df
commit
947e14d3be
6 changed files with 65 additions and 5 deletions
|
@ -97,8 +97,15 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
|
|
||||||
Target target = GetTarget(descriptor.Type);
|
Target target = GetTarget(descriptor.Type);
|
||||||
|
|
||||||
|
if (descriptor.IsBindless)
|
||||||
|
{
|
||||||
|
textureBindings[index] = new TextureBindingInfo(target, descriptor.CbufOffset, descriptor.CbufSlot);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
textureBindings[index] = new TextureBindingInfo(target, descriptor.HandleIndex);
|
textureBindings[index] = new TextureBindingInfo(target, descriptor.HandleIndex);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_textureManager.SetComputeTextures(textureBindings);
|
_textureManager.SetComputeTextures(textureBindings);
|
||||||
|
|
||||||
|
|
|
@ -694,8 +694,15 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
|
|
||||||
Target target = GetTarget(descriptor.Type);
|
Target target = GetTarget(descriptor.Type);
|
||||||
|
|
||||||
|
if (descriptor.IsBindless)
|
||||||
|
{
|
||||||
|
textureBindings[index] = new TextureBindingInfo(target, descriptor.CbufSlot, descriptor.CbufOffset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
textureBindings[index] = new TextureBindingInfo(target, descriptor.HandleIndex);
|
textureBindings[index] = new TextureBindingInfo(target, descriptor.HandleIndex);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_textureManager.SetGraphicsTextures(stage, textureBindings);
|
_textureManager.SetGraphicsTextures(stage, textureBindings);
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,31 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
|
|
||||||
public int Handle { get; }
|
public int Handle { get; }
|
||||||
|
|
||||||
|
public bool IsBindless { get; }
|
||||||
|
|
||||||
|
public int CbufSlot { get; }
|
||||||
|
public int CbufOffset { get; }
|
||||||
|
|
||||||
public TextureBindingInfo(Target target, int handle)
|
public TextureBindingInfo(Target target, int handle)
|
||||||
{
|
{
|
||||||
Target = target;
|
Target = target;
|
||||||
Handle = handle;
|
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.Gpu.State;
|
||||||
using Ryujinx.Graphics.Shader;
|
using Ryujinx.Graphics.Shader;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.Graphics.Gpu.Image
|
namespace Ryujinx.Graphics.Gpu.Image
|
||||||
{
|
{
|
||||||
|
@ -133,7 +134,29 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||||
{
|
{
|
||||||
TextureBindingInfo binding = _textureBindings[stageIndex][index];
|
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 textureId = UnpackTextureId(packedId);
|
||||||
int samplerId;
|
int samplerId;
|
||||||
|
|
|
@ -272,6 +272,8 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||||
AstOperand operand = texOp.GetSource(0) as AstOperand;
|
AstOperand operand = texOp.GetSource(0) as AstOperand;
|
||||||
|
|
||||||
desc = new TextureDescriptor(samplerName, texOp.Type, operand.CbufSlot, operand.CbufOffset);
|
desc = new TextureDescriptor(samplerName, texOp.Type, operand.CbufSlot, operand.CbufOffset);
|
||||||
|
|
||||||
|
context.TextureDescriptors.Add(desc);
|
||||||
}
|
}
|
||||||
else if ((texOp.Type & SamplerType.Indexed) != 0)
|
else if ((texOp.Type & SamplerType.Indexed) != 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,11 +13,11 @@ namespace Ryujinx.Graphics.Shader
|
||||||
public int CbufSlot { get; }
|
public int CbufSlot { get; }
|
||||||
public int CbufOffset { get; }
|
public int CbufOffset { get; }
|
||||||
|
|
||||||
public TextureDescriptor(string name, SamplerType type, int hIndex)
|
public TextureDescriptor(string name, SamplerType type, int handleIndex)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
Type = type;
|
Type = type;
|
||||||
HandleIndex = hIndex;
|
HandleIndex = handleIndex;
|
||||||
|
|
||||||
IsBindless = false;
|
IsBindless = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue