forked from Mirror/Ryujinx
Pass all inputs when geometry shader passthrough is enabled (#2362)
* Pass all inputs when geometry shader passthrough is enabled * Shader cache version bump
This commit is contained in:
parent
eb23933331
commit
49edf14a3e
2 changed files with 48 additions and 29 deletions
|
@ -36,7 +36,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Version of the codegen (to be changed when codegen or guest format change).
|
/// Version of the codegen (to be changed when codegen or guest format change).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private const ulong ShaderCodeGenVersion = 2367;
|
private const ulong ShaderCodeGenVersion = 2362;
|
||||||
|
|
||||||
// Progress reporting helpers
|
// Progress reporting helpers
|
||||||
private volatile int _shaderCount;
|
private volatile int _shaderCount;
|
||||||
|
|
|
@ -131,7 +131,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||||
context.AppendLine();
|
context.AppendLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.IAttributes.Count != 0)
|
if (info.IAttributes.Count != 0 || context.Config.GpPassthrough)
|
||||||
{
|
{
|
||||||
DeclareInputAttributes(context, info);
|
DeclareInputAttributes(context, info);
|
||||||
|
|
||||||
|
@ -371,10 +371,30 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||||
|
|
||||||
private static void DeclareInputAttributes(CodeGenContext context, StructuredProgramInfo info)
|
private static void DeclareInputAttributes(CodeGenContext context, StructuredProgramInfo info)
|
||||||
{
|
{
|
||||||
string suffix = context.Config.Stage == ShaderStage.Geometry ? "[]" : string.Empty;
|
if (context.Config.GpPassthrough)
|
||||||
|
{
|
||||||
|
for (int attr = 0; attr < MaxAttributes; attr++)
|
||||||
|
{
|
||||||
|
DeclareInputAttribute(context, info, attr);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (int attr in info.IAttributes.OrderBy(x => x).Where(x => x >= MaxAttributes))
|
||||||
|
{
|
||||||
|
DeclareInputAttribute(context, info, attr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
foreach (int attr in info.IAttributes.OrderBy(x => x))
|
foreach (int attr in info.IAttributes.OrderBy(x => x))
|
||||||
{
|
{
|
||||||
|
DeclareInputAttribute(context, info, attr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void DeclareInputAttribute(CodeGenContext context, StructuredProgramInfo info, int attr)
|
||||||
|
{
|
||||||
|
string suffix = context.Config.Stage == ShaderStage.Geometry ? "[]" : string.Empty;
|
||||||
string iq = string.Empty;
|
string iq = string.Empty;
|
||||||
|
|
||||||
if (context.Config.Stage == ShaderStage.Fragment)
|
if (context.Config.Stage == ShaderStage.Fragment)
|
||||||
|
@ -387,7 +407,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
string pass = context.Config.GpPassthrough ? "passthrough, " : string.Empty;
|
string pass = context.Config.GpPassthrough && !info.OAttributes.Contains(attr) ? "passthrough, " : string.Empty;
|
||||||
|
|
||||||
string name = $"{DefaultNames.IAttributePrefix}{attr}";
|
string name = $"{DefaultNames.IAttributePrefix}{attr}";
|
||||||
|
|
||||||
|
@ -405,11 +425,10 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||||
context.AppendLine($"layout ({pass}location = {attr}) {iq}in vec4 {name}{suffix};");
|
context.AppendLine($"layout ({pass}location = {attr}) {iq}in vec4 {name}{suffix};");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static void DeclareOutputAttributes(CodeGenContext context, StructuredProgramInfo info)
|
private static void DeclareOutputAttributes(CodeGenContext context, StructuredProgramInfo info)
|
||||||
{
|
{
|
||||||
if (context.Config.Stage == ShaderStage.Fragment)
|
if (context.Config.Stage == ShaderStage.Fragment || context.Config.GpPassthrough)
|
||||||
{
|
{
|
||||||
DeclareUsedOutputAttributes(context, info);
|
DeclareUsedOutputAttributes(context, info);
|
||||||
}
|
}
|
||||||
|
@ -423,7 +442,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl
|
||||||
{
|
{
|
||||||
foreach (int attr in info.OAttributes.OrderBy(x => x))
|
foreach (int attr in info.OAttributes.OrderBy(x => x))
|
||||||
{
|
{
|
||||||
context.AppendLine($"layout (location = {attr}) out vec4 {DefaultNames.OAttributePrefix}{attr};");
|
DeclareOutputAttribute(context, attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue