Ryujinx/Ryujinx.Graphics.Gpu/Engine/MethodUniformBufferBind.cs

83 lines
3.1 KiB
C#
Raw Normal View History

2019-10-13 08:02:07 +02:00
using Ryujinx.Graphics.Gpu.State;
namespace Ryujinx.Graphics.Gpu.Engine
{
partial class Methods
{
/// <summary>
/// Binds a uniform buffer for the vertex shader stage.
/// </summary>
/// <param name="state">Current GPU state</param>
/// <param name="argument">Method call argument</param>
2019-11-22 03:46:14 +01:00
private void UniformBufferBindVertex(GpuState state, int argument)
2019-10-13 08:02:07 +02:00
{
2019-11-22 03:46:14 +01:00
UniformBufferBind(state, argument, ShaderType.Vertex);
2019-10-13 08:02:07 +02:00
}
/// <summary>
/// Binds a uniform buffer for the tessellation control shader stage.
/// </summary>
/// <param name="state">Current GPU state</param>
/// <param name="argument">Method call argument</param>
2019-11-22 03:46:14 +01:00
private void UniformBufferBindTessControl(GpuState state, int argument)
2019-10-13 08:02:07 +02:00
{
2019-11-22 03:46:14 +01:00
UniformBufferBind(state, argument, ShaderType.TessellationControl);
2019-10-13 08:02:07 +02:00
}
/// <summary>
/// Binds a uniform buffer for the tessellation evaluation shader stage.
/// </summary>
/// <param name="state">Current GPU state</param>
/// <param name="argument">Method call argument</param>
2019-11-22 03:46:14 +01:00
private void UniformBufferBindTessEvaluation(GpuState state, int argument)
2019-10-13 08:02:07 +02:00
{
2019-11-22 03:46:14 +01:00
UniformBufferBind(state, argument, ShaderType.TessellationEvaluation);
2019-10-13 08:02:07 +02:00
}
/// <summary>
/// Binds a uniform buffer for the geometry shader stage.
/// </summary>
/// <param name="state">Current GPU state</param>
/// <param name="argument">Method call argument</param>
2019-11-22 03:46:14 +01:00
private void UniformBufferBindGeometry(GpuState state, int argument)
2019-10-13 08:02:07 +02:00
{
2019-11-22 03:46:14 +01:00
UniformBufferBind(state, argument, ShaderType.Geometry);
2019-10-13 08:02:07 +02:00
}
/// <summary>
/// Binds a uniform buffer for the fragment shader stage.
/// </summary>
/// <param name="state">Current GPU state</param>
/// <param name="argument">Method call argument</param>
2019-11-22 03:46:14 +01:00
private void UniformBufferBindFragment(GpuState state, int argument)
2019-10-13 08:02:07 +02:00
{
2019-11-22 03:46:14 +01:00
UniformBufferBind(state, argument, ShaderType.Fragment);
2019-10-13 08:02:07 +02:00
}
/// <summary>
///Binds a uniform buffer for the specified shader stage.
/// </summary>
/// <param name="state">Current GPU state</param>
/// <param name="argument">Method call argument</param>
/// <param name="type">Shader stage that will access the uniform buffer</param>
2019-11-22 03:46:14 +01:00
private void UniformBufferBind(GpuState state, int argument, ShaderType type)
2019-10-13 08:02:07 +02:00
{
bool enable = (argument & 1) != 0;
int index = (argument >> 4) & 0x1f;
if (enable)
{
2019-11-22 03:46:14 +01:00
var uniformBuffer = state.Get<UniformBufferState>(MethodOffset.UniformBufferState);
2019-10-13 08:02:07 +02:00
ulong address = uniformBuffer.Address.Pack();
2019-12-29 18:41:50 +01:00
BufferManager.SetGraphicsUniformBuffer((int)type, index, address, (uint)uniformBuffer.Size);
2019-10-13 08:02:07 +02:00
}
else
{
2019-12-29 18:41:50 +01:00
BufferManager.SetGraphicsUniformBuffer((int)type, index, 0, 0);
2019-10-13 08:02:07 +02:00
}
}
}
}