using Ryujinx.Graphics.Gpu.State;
namespace Ryujinx.Graphics.Gpu.Engine
{
partial class Methods
{
///
/// Binds a uniform buffer for the vertex shader stage.
///
/// Current GPU state
/// Method call argument
private void UniformBufferBindVertex(GpuState state, int argument)
{
UniformBufferBind(state, argument, ShaderType.Vertex);
}
///
/// Binds a uniform buffer for the tessellation control shader stage.
///
/// Current GPU state
/// Method call argument
private void UniformBufferBindTessControl(GpuState state, int argument)
{
UniformBufferBind(state, argument, ShaderType.TessellationControl);
}
///
/// Binds a uniform buffer for the tessellation evaluation shader stage.
///
/// Current GPU state
/// Method call argument
private void UniformBufferBindTessEvaluation(GpuState state, int argument)
{
UniformBufferBind(state, argument, ShaderType.TessellationEvaluation);
}
///
/// Binds a uniform buffer for the geometry shader stage.
///
/// Current GPU state
/// Method call argument
private void UniformBufferBindGeometry(GpuState state, int argument)
{
UniformBufferBind(state, argument, ShaderType.Geometry);
}
///
/// Binds a uniform buffer for the fragment shader stage.
///
/// Current GPU state
/// Method call argument
private void UniformBufferBindFragment(GpuState state, int argument)
{
UniformBufferBind(state, argument, ShaderType.Fragment);
}
///
///Binds a uniform buffer for the specified shader stage.
///
/// Current GPU state
/// Method call argument
/// Shader stage that will access the uniform buffer
private void UniformBufferBind(GpuState state, int argument, ShaderType type)
{
bool enable = (argument & 1) != 0;
int index = (argument >> 4) & 0x1f;
FlushUboDirty();
if (enable)
{
var uniformBuffer = state.Get(MethodOffset.UniformBufferState);
ulong address = uniformBuffer.Address.Pack();
BufferManager.SetGraphicsUniformBuffer((int)type, index, address, (uint)uniformBuffer.Size);
}
else
{
BufferManager.SetGraphicsUniformBuffer((int)type, index, 0, 0);
}
}
}
}