aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2021-08-11 15:59:42 -0300
committerGitHub <noreply@github.com>2021-08-11 20:59:42 +0200
commitd9d18439f6900fd9f05bde41998526281f7638c5 (patch)
tree14e8cd74e10ca9c92d1b85ccf17cecad00e3a8f7 /Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
parent70f79e689bc947313aab11c41e59928ce43be517 (diff)
Use a new approach for shader BRX targets (#2532)
* Use a new approach for shader BRX targets * Make shader cache actually work * Improve the shader pattern matching a bit * Extend LDC search to predecessor blocks, catches more cases * Nit * Only save the amount of constant buffer data actually used. Avoids crashes on partially mapped buffers * Ignore Rd on predicate instructions, as they do not have a Rd register (catches more cases)
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs')
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs21
1 files changed, 21 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs b/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
index b7059b51..6254b1c2 100644
--- a/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/GpuAccessor.cs
@@ -20,6 +20,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
private readonly int _localMemorySize;
private readonly int _sharedMemorySize;
+ public int Cb1DataSize { get; private set; }
+
/// <summary>
/// Creates a new instance of the GPU state accessor for graphics shader translation.
/// </summary>
@@ -68,6 +70,25 @@ namespace Ryujinx.Graphics.Gpu.Shader
}
/// <summary>
+ /// Reads data from the constant buffer 1.
+ /// </summary>
+ /// <param name="offset">Offset in bytes to read from</param>
+ /// <returns>Value at the given offset</returns>
+ public uint ConstantBuffer1Read(int offset)
+ {
+ if (Cb1DataSize < offset + 4)
+ {
+ Cb1DataSize = offset + 4;
+ }
+
+ ulong baseAddress = _compute
+ ? _channel.BufferManager.GetComputeUniformBufferAddress(1)
+ : _channel.BufferManager.GetGraphicsUniformBufferAddress(_stageIndex, 1);
+
+ return _channel.MemoryManager.Physical.Read<uint>(baseAddress + (ulong)offset);
+ }
+
+ /// <summary>
/// Prints a log message.
/// </summary>
/// <param name="message">Message to print</param>