aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs')
-rw-r--r--src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs b/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs
index 52193940..9d030cd6 100644
--- a/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs
+++ b/src/Ryujinx.Graphics.Gpu/Shader/GpuAccessorBase.cs
@@ -15,8 +15,10 @@ namespace Ryujinx.Graphics.Gpu.Shader
private readonly ResourceCounts _resourceCounts;
private readonly int _stageIndex;
- private readonly int _reservedConstantBuffers;
- private readonly int _reservedStorageBuffers;
+ private int _reservedConstantBuffers;
+ private int _reservedStorageBuffers;
+ private int _reservedTextures;
+ private int _reservedImages;
/// <summary>
/// Creates a new GPU accessor.
@@ -24,15 +26,26 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <param name="context">GPU context</param>
/// <param name="resourceCounts">Counter of GPU resources used by the shader</param>
/// <param name="stageIndex">Index of the shader stage, 0 for compute</param>
- /// <param name="tfEnabled">Indicates if the current graphics shader is used with transform feedback enabled</param>
- public GpuAccessorBase(GpuContext context, ResourceCounts resourceCounts, int stageIndex, bool tfEnabled)
+ public GpuAccessorBase(GpuContext context, ResourceCounts resourceCounts, int stageIndex)
{
_context = context;
_resourceCounts = resourceCounts;
_stageIndex = stageIndex;
+ }
+
+ /// <summary>
+ /// Initializes counts for bindings that will be reserved for emulator use.
+ /// </summary>
+ /// <param name="tfEnabled">Indicates if the current graphics shader is used with transform feedback enabled</param>
+ /// <param name="vertexAsCompute">Indicates that the vertex shader will be emulated on a compute shader</param>
+ public void InitializeReservedCounts(bool tfEnabled, bool vertexAsCompute)
+ {
+ ResourceReservationCounts rrc = new(!_context.Capabilities.SupportsTransformFeedback && tfEnabled, vertexAsCompute);
- _reservedConstantBuffers = 1; // For the support buffer.
- _reservedStorageBuffers = !context.Capabilities.SupportsTransformFeedback && tfEnabled ? 5 : 0;
+ _reservedConstantBuffers = rrc.ReservedConstantBuffers;
+ _reservedStorageBuffers = rrc.ReservedStorageBuffers;
+ _reservedTextures = rrc.ReservedTextures;
+ _reservedImages = rrc.ReservedImages;
}
public int QueryBindingConstantBuffer(int index)
@@ -69,6 +82,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
public int QueryBindingTexture(int index, bool isBuffer)
{
+ int binding;
+
if (_context.Capabilities.Api == TargetApi.Vulkan)
{
if (isBuffer)
@@ -76,16 +91,20 @@ namespace Ryujinx.Graphics.Gpu.Shader
index += (int)_context.Capabilities.MaximumTexturesPerStage;
}
- return GetBindingFromIndex(index, _context.Capabilities.MaximumTexturesPerStage * 2, "Texture");
+ binding = GetBindingFromIndex(index, _context.Capabilities.MaximumTexturesPerStage * 2, "Texture");
}
else
{
- return _resourceCounts.TexturesCount++;
+ binding = _resourceCounts.TexturesCount++;
}
+
+ return binding + _reservedTextures;
}
public int QueryBindingImage(int index, bool isBuffer)
{
+ int binding;
+
if (_context.Capabilities.Api == TargetApi.Vulkan)
{
if (isBuffer)
@@ -93,12 +112,14 @@ namespace Ryujinx.Graphics.Gpu.Shader
index += (int)_context.Capabilities.MaximumImagesPerStage;
}
- return GetBindingFromIndex(index, _context.Capabilities.MaximumImagesPerStage * 2, "Image");
+ binding = GetBindingFromIndex(index, _context.Capabilities.MaximumImagesPerStage * 2, "Image");
}
else
{
- return _resourceCounts.ImagesCount++;
+ binding = _resourceCounts.ImagesCount++;
}
+
+ return binding + _reservedImages;
}
private int GetBindingFromIndex(int index, uint maxPerStage, string resourceName)