mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-11-24 18:20:12 +01:00
99ffc061d3
* Changes 1 * Changes 2 * Better ModifiedSequence handling This should handle PreciseEvents properly, and simplifies a few things. * Minor changes, remove debug log * Handle stage.Info being null Hopefully fixes Catherine crash * Fix shader specialization fast texture lookup * Fix some things. * Address Feedback Part 1 * Make method static.
81 lines
2.7 KiB
C#
81 lines
2.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Ryujinx.Graphics.Gpu.Shader
|
|
{
|
|
/// <summary>
|
|
/// List of cached shader programs that differs only by specialization state.
|
|
/// </summary>
|
|
class ShaderSpecializationList : IEnumerable<CachedShaderProgram>
|
|
{
|
|
private readonly List<CachedShaderProgram> _entries = new List<CachedShaderProgram>();
|
|
|
|
/// <summary>
|
|
/// Adds a program to the list.
|
|
/// </summary>
|
|
/// <param name="program">Program to be added</param>
|
|
public void Add(CachedShaderProgram program)
|
|
{
|
|
_entries.Add(program);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tries to find an existing 3D program on the cache.
|
|
/// </summary>
|
|
/// <param name="channel">GPU channel</param>
|
|
/// <param name="poolState">Texture pool state</param>
|
|
/// <param name="graphicsState">Graphics state</param>
|
|
/// <param name="program">Cached program, if found</param>
|
|
/// <returns>True if a compatible program is found, false otherwise</returns>
|
|
public bool TryFindForGraphics(
|
|
GpuChannel channel,
|
|
GpuChannelPoolState poolState,
|
|
GpuChannelGraphicsState graphicsState,
|
|
out CachedShaderProgram program)
|
|
{
|
|
foreach (var entry in _entries)
|
|
{
|
|
if (entry.SpecializationState.MatchesGraphics(channel, poolState, graphicsState, true))
|
|
{
|
|
program = entry;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
program = default;
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tries to find an existing compute program on the cache.
|
|
/// </summary>
|
|
/// <param name="channel">GPU channel</param>
|
|
/// <param name="poolState">Texture pool state</param>
|
|
/// <param name="program">Cached program, if found</param>
|
|
/// <returns>True if a compatible program is found, false otherwise</returns>
|
|
public bool TryFindForCompute(GpuChannel channel, GpuChannelPoolState poolState, out CachedShaderProgram program)
|
|
{
|
|
foreach (var entry in _entries)
|
|
{
|
|
if (entry.SpecializationState.MatchesCompute(channel, poolState, true))
|
|
{
|
|
program = entry;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
program = default;
|
|
return false;
|
|
}
|
|
|
|
public IEnumerator<CachedShaderProgram> GetEnumerator()
|
|
{
|
|
return _entries.GetEnumerator();
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
{
|
|
return GetEnumerator();
|
|
}
|
|
}
|
|
} |