mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-11 02:36:38 +00:00
f1d1670b0b
* Implement HLE macro for DrawElementsIndirect * Shader cache version bump * Use GL_ARB_shader_draw_parameters extension on OpenGL * Fix DrawIndexedIndirectCount on Vulkan when extension is not supported * Implement DrawIndex * Alignment * Fix some validation errors * Rename BaseIds to DrawParameters * Fix incorrect index buffer and vertex buffer size in some cases * Add HLE macros for DrawArraysInstanced and DrawElementsInstanced * Perform a regular draw when indirect data is not modified * Use non-indirect draw methods if indirect buffer was not GPU modified * Only check if draw parameters match if the shader actually uses them * Expose Macro HLE setting on GUI * Reset FirstVertex and FirstInstance after draw * Update shader cache version again since some people already tested this * PR feedback Co-authored-by: riperiperi <rhy3756547@hotmail.com>
83 lines
No EOL
2.8 KiB
C#
83 lines
No EOL
2.8 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)
|
|
{
|
|
bool usesDrawParameters = entry.Shaders[1]?.Info.UsesDrawParameters ?? false;
|
|
|
|
if (entry.SpecializationState.MatchesGraphics(channel, poolState, graphicsState, usesDrawParameters, 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();
|
|
}
|
|
}
|
|
} |