UBO bindings in GLSL now search for free spaces
This commit is contained in:
parent
cc298c676a
commit
5cd6ce87b7
1 changed files with 37 additions and 24 deletions
|
@ -157,8 +157,6 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
|
||||||
public void Prepare(bool TrySPIRV)
|
public void Prepare(bool TrySPIRV)
|
||||||
{
|
{
|
||||||
Console.WriteLine(GL.GetInteger(GetPName.MaxUniformBufferBindings));
|
|
||||||
|
|
||||||
for (int Stage = 0; Stage < 5; Stage++)
|
for (int Stage = 0; Stage < 5; Stage++)
|
||||||
{
|
{
|
||||||
for (int Cbuf = 0; Cbuf < BuffersPerStage; Cbuf++)
|
for (int Cbuf = 0; Cbuf < BuffersPerStage; Cbuf++)
|
||||||
|
@ -405,21 +403,22 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
|
|
||||||
CheckProgramLink(Handle);
|
CheckProgramLink(Handle);
|
||||||
|
|
||||||
if (Language == ShadingLanguage.GLSL)
|
switch (Language)
|
||||||
{
|
{
|
||||||
BindUniformBlocksIfNotNull(Handle, Current.Vertex);
|
case ShadingLanguage.GLSL:
|
||||||
BindUniformBlocksIfNotNull(Handle, Current.TessControl);
|
{
|
||||||
BindUniformBlocksIfNotNull(Handle, Current.TessEvaluation);
|
int FreeBinding = 0;
|
||||||
BindUniformBlocksIfNotNull(Handle, Current.Geometry);
|
|
||||||
BindUniformBlocksIfNotNull(Handle, Current.Fragment);
|
FreeBinding = BindUniformBlocksIfNotNull(Handle, FreeBinding, Current.Vertex);
|
||||||
|
FreeBinding = BindUniformBlocksIfNotNull(Handle, FreeBinding, Current.TessControl);
|
||||||
|
FreeBinding = BindUniformBlocksIfNotNull(Handle, FreeBinding, Current.TessEvaluation);
|
||||||
|
FreeBinding = BindUniformBlocksIfNotNull(Handle, FreeBinding, Current.Geometry);
|
||||||
|
FreeBinding = BindUniformBlocksIfNotNull(Handle, FreeBinding, Current.Fragment);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Programs.Add(Current, Handle);
|
case ShadingLanguage.SPIRV:
|
||||||
}
|
{
|
||||||
|
|
||||||
GL.UseProgram(Handle);
|
|
||||||
|
|
||||||
//TODO: This could be done once, right?
|
|
||||||
for (int Stage = 0; Stage < 5; Stage++)
|
for (int Stage = 0; Stage < 5; Stage++)
|
||||||
{
|
{
|
||||||
for (int Cbuf = 0; Cbuf < BuffersPerStage; Cbuf++)
|
for (int Cbuf = 0; Cbuf < BuffersPerStage; Cbuf++)
|
||||||
|
@ -431,6 +430,14 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
GL.BindBufferBase(BufferRangeTarget.UniformBuffer, Binding, Buffer.Handle);
|
GL.BindBufferBase(BufferRangeTarget.UniformBuffer, Binding, Buffer.Handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Programs.Add(Current, Handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
GL.UseProgram(Handle);
|
||||||
|
|
||||||
CurrentProgramHandle = Handle;
|
CurrentProgramHandle = Handle;
|
||||||
}
|
}
|
||||||
|
@ -445,7 +452,7 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BindUniformBlocksIfNotNull(int ProgramHandle, ShaderStage Stage)
|
private int BindUniformBlocksIfNotNull(int ProgramHandle, int FreeBinding, ShaderStage Stage)
|
||||||
{
|
{
|
||||||
if (Stage != null)
|
if (Stage != null)
|
||||||
{
|
{
|
||||||
|
@ -458,11 +465,17 @@ namespace Ryujinx.Graphics.Gal.OpenGL
|
||||||
throw new InvalidOperationException();
|
throw new InvalidOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Binding = Shader.UniformBinding.Get(Stage.Type, DeclInfo.Cbuf);
|
GL.UniformBlockBinding(ProgramHandle, BlockIndex, FreeBinding);
|
||||||
|
|
||||||
GL.UniformBlockBinding(ProgramHandle, BlockIndex, Binding);
|
OGLStreamBuffer Buffer = Buffers[(int)Stage.Type][DeclInfo.Cbuf];
|
||||||
|
|
||||||
|
GL.BindBufferBase(BufferRangeTarget.UniformBuffer, FreeBinding, Buffer.Handle);
|
||||||
|
|
||||||
|
FreeBinding++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return FreeBinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CheckCompilation(int Handle)
|
private static void CheckCompilation(int Handle)
|
||||||
|
|
Loading…
Reference in a new issue