aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Image
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2020-11-08 08:10:00 -0300
committerGitHub <noreply@github.com>2020-11-08 12:10:00 +0100
commit8d168574eb04ae1e7026ac2b058e3b184f068fae (patch)
tree6e0f79447276619af980055419874f5e99595b58 /Ryujinx.Graphics.Gpu/Image
parent5561a3b95e9c980e3354366570e7896a213b95ae (diff)
Use explicit buffer and texture bindings on shaders (#1666)
* Use explicit buffer and texture bindings on shaders * More XML docs and other nits
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Image')
-rw-r--r--Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs28
-rw-r--r--Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs36
2 files changed, 37 insertions, 27 deletions
diff --git a/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs b/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs
index 422b66e2..a328fc2b 100644
--- a/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs
+++ b/Ryujinx.Graphics.Gpu/Image/TextureBindingInfo.cs
@@ -20,6 +20,11 @@ namespace Ryujinx.Graphics.Gpu.Image
public Format Format { get; }
/// <summary>
+ /// Shader texture host binding point.
+ /// </summary>
+ public int Binding { get; }
+
+ /// <summary>
/// Shader texture handle.
/// This is an index into the texture constant buffer.
/// </summary>
@@ -53,13 +58,15 @@ namespace Ryujinx.Graphics.Gpu.Image
/// </summary>
/// <param name="target">The shader sampler target type</param>
/// <param name="format">Format of the image as declared on the shader</param>
+ /// <param name="binding">The shader texture binding point</param>
/// <param name="handle">The shader texture handle (read index into the texture constant buffer)</param>
/// <param name="flags">The texture's usage flags, indicating how it is used in the shader</param>
- public TextureBindingInfo(Target target, Format format, int handle, TextureUsageFlags flags)
+ public TextureBindingInfo(Target target, Format format, int binding, int handle, TextureUsageFlags flags)
{
- Target = target;
- Format = format;
- Handle = handle;
+ Target = target;
+ Format = format;
+ Binding = binding;
+ Handle = handle;
IsBindless = false;
@@ -73,9 +80,10 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Constructs the texture binding information structure.
/// </summary>
/// <param name="target">The shader sampler target type</param>
+ /// <param name="binding">The shader texture binding point</param>
/// <param name="handle">The shader texture handle (read index into the texture constant buffer)</param>
/// <param name="flags">The texture's usage flags, indicating how it is used in the shader</param>
- public TextureBindingInfo(Target target, int handle, TextureUsageFlags flags) : this(target, (Format)0, handle, flags)
+ public TextureBindingInfo(Target target, int binding, int handle, TextureUsageFlags flags) : this(target, (Format)0, binding, handle, flags)
{
}
@@ -83,14 +91,16 @@ namespace Ryujinx.Graphics.Gpu.Image
/// Constructs the bindless texture binding information structure.
/// </summary>
/// <param name="target">The shader sampler target type</param>
+ /// <param name="binding">The shader texture binding point</param>
/// <param name="cbufSlot">Constant buffer slot where the bindless texture handle is located</param>
/// <param name="cbufOffset">Constant buffer offset of the bindless texture handle</param>
/// <param name="flags">The texture's usage flags, indicating how it is used in the shader</param>
- public TextureBindingInfo(Target target, int cbufSlot, int cbufOffset, TextureUsageFlags flags)
+ public TextureBindingInfo(Target target, int binding, int cbufSlot, int cbufOffset, TextureUsageFlags flags)
{
- Target = target;
- Format = 0;
- Handle = 0;
+ Target = target;
+ Format = 0;
+ Binding = binding;
+ Handle = 0;
IsBindless = true;
diff --git a/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs b/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs
index 08c4082e..bfb6da25 100644
--- a/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs
+++ b/Ryujinx.Graphics.Gpu/Image/TextureBindingsManager.cs
@@ -265,11 +265,11 @@ namespace Ryujinx.Graphics.Gpu.Image
for (int index = 0; index < _textureBindings[stageIndex].Length; index++)
{
- TextureBindingInfo binding = _textureBindings[stageIndex][index];
+ TextureBindingInfo bindingInfo = _textureBindings[stageIndex][index];
int packedId;
- if (binding.IsBindless)
+ if (bindingInfo.IsBindless)
{
ulong address;
@@ -277,18 +277,18 @@ namespace Ryujinx.Graphics.Gpu.Image
if (_isCompute)
{
- address = bufferManager.GetComputeUniformBufferAddress(binding.CbufSlot);
+ address = bufferManager.GetComputeUniformBufferAddress(bindingInfo.CbufSlot);
}
else
{
- address = bufferManager.GetGraphicsUniformBufferAddress(stageIndex, binding.CbufSlot);
+ address = bufferManager.GetGraphicsUniformBufferAddress(stageIndex, bindingInfo.CbufSlot);
}
- packedId = _context.PhysicalMemory.Read<int>(address + (ulong)binding.CbufOffset * 4);
+ packedId = _context.PhysicalMemory.Read<int>(address + (ulong)bindingInfo.CbufOffset * 4);
}
else
{
- packedId = ReadPackedId(stageIndex, binding.Handle, _textureBufferIndex);
+ packedId = ReadPackedId(stageIndex, bindingInfo.Handle, _textureBufferIndex);
}
int textureId = UnpackTextureId(packedId);
@@ -305,18 +305,18 @@ namespace Ryujinx.Graphics.Gpu.Image
Texture texture = pool.Get(textureId);
- ITexture hostTexture = texture?.GetTargetTexture(binding.Target);
+ ITexture hostTexture = texture?.GetTargetTexture(bindingInfo.Target);
if (_textureState[stageIndex][index].Texture != hostTexture || _rebind)
{
- if (UpdateScale(texture, binding, index, stage))
+ if (UpdateScale(texture, bindingInfo, index, stage))
{
- hostTexture = texture?.GetTargetTexture(binding.Target);
+ hostTexture = texture?.GetTargetTexture(bindingInfo.Target);
}
_textureState[stageIndex][index].Texture = hostTexture;
- _context.Renderer.Pipeline.SetTexture(index, stage, hostTexture);
+ _context.Renderer.Pipeline.SetTexture(bindingInfo.Binding, hostTexture);
}
if (hostTexture != null && texture.Info.Target == Target.TextureBuffer)
@@ -335,7 +335,7 @@ namespace Ryujinx.Graphics.Gpu.Image
{
_textureState[stageIndex][index].Sampler = hostSampler;
- _context.Renderer.Pipeline.SetSampler(index, stage, hostSampler);
+ _context.Renderer.Pipeline.SetSampler(bindingInfo.Binding, hostSampler);
}
}
}
@@ -359,14 +359,14 @@ namespace Ryujinx.Graphics.Gpu.Image
for (int index = 0; index < _imageBindings[stageIndex].Length; index++)
{
- TextureBindingInfo binding = _imageBindings[stageIndex][index];
+ TextureBindingInfo bindingInfo = _imageBindings[stageIndex][index];
- int packedId = ReadPackedId(stageIndex, binding.Handle, _textureBufferIndex);
+ int packedId = ReadPackedId(stageIndex, bindingInfo.Handle, _textureBufferIndex);
int textureId = UnpackTextureId(packedId);
Texture texture = pool.Get(textureId);
- ITexture hostTexture = texture?.GetTargetTexture(binding.Target);
+ ITexture hostTexture = texture?.GetTargetTexture(bindingInfo.Target);
if (hostTexture != null && texture.Info.Target == Target.TextureBuffer)
{
@@ -378,21 +378,21 @@ namespace Ryujinx.Graphics.Gpu.Image
if (_imageState[stageIndex][index].Texture != hostTexture || _rebind)
{
- if (UpdateScale(texture, binding, baseScaleIndex + index, stage))
+ if (UpdateScale(texture, bindingInfo, baseScaleIndex + index, stage))
{
- hostTexture = texture?.GetTargetTexture(binding.Target);
+ hostTexture = texture?.GetTargetTexture(bindingInfo.Target);
}
_imageState[stageIndex][index].Texture = hostTexture;
- Format format = binding.Format;
+ Format format = bindingInfo.Format;
if (format == 0 && texture != null)
{
format = texture.Format;
}
- _context.Renderer.Pipeline.SetImage(index, stage, hostTexture, format);
+ _context.Renderer.Pipeline.SetImage(bindingInfo.Binding, hostTexture, format);
}
}
}