Implement gl_ViewportIndex Vertex Attribute

This commit is contained in:
jduncanator 2018-12-07 00:43:07 +11:00
commit 407c893e0f
2 changed files with 20 additions and 4 deletions

View file

@ -6,6 +6,7 @@ namespace Ryujinx.Graphics.Gal.Shader
class GlslDecl class GlslDecl
{ {
public const int LayerAttr = 0x064; public const int LayerAttr = 0x064;
public const int ViewportIdxAttr = 0x068;
public const int PointSizeAttr = 0x06c; public const int PointSizeAttr = 0x06c;
public const int PointCoordAttrX = 0x2e0; public const int PointCoordAttrX = 0x2e0;
public const int PointCoordAttrY = 0x2e4; public const int PointCoordAttrY = 0x2e4;

View file

@ -190,7 +190,13 @@ namespace Ryujinx.Graphics.Gal.Shader
private void PrintDeclHeader() private void PrintDeclHeader()
{ {
if (Decl.ShaderType == GalShaderType.Geometry) if(Decl.ShaderType == GalShaderType.Vertex)
{
SB.AppendLine("#extension GL_AMD_vertex_shader_viewport_index : require");
SB.AppendLine();
}
else if (Decl.ShaderType == GalShaderType.Geometry)
{ {
int MaxVertices = Header.MaxOutputVertexCount; int MaxVertices = Header.MaxOutputVertexCount;
@ -872,10 +878,18 @@ namespace Ryujinx.Graphics.Gal.Shader
return Name + Swizzle; return Name + Swizzle;
} }
else if (Abuf.Offs == GlslDecl.ViewportIdxAttr)
{
return "gl_ViewportIndex";
}
else if (Abuf.Offs == GlslDecl.PointSizeAttr) else if (Abuf.Offs == GlslDecl.PointSizeAttr)
{ {
return "gl_PointSize"; return "gl_PointSize";
} }
else
{
throw new NotImplementedException($"Attribute with offset 0x{Abuf.Offs:x2} is not implemented.");
}
} }
if (DeclInfo.Index >= 32) if (DeclInfo.Index >= 32)
@ -1346,9 +1360,10 @@ namespace Ryujinx.Graphics.Gal.Shader
switch (Node) switch (Node)
{ {
case ShaderIrOperAbuf Abuf: case ShaderIrOperAbuf Abuf:
return Abuf.Offs == GlslDecl.LayerAttr || return Abuf.Offs == GlslDecl.LayerAttr ||
Abuf.Offs == GlslDecl.InstanceIdAttr || Abuf.Offs == GlslDecl.ViewportIdxAttr ||
Abuf.Offs == GlslDecl.VertexIdAttr || Abuf.Offs == GlslDecl.InstanceIdAttr ||
Abuf.Offs == GlslDecl.VertexIdAttr ||
Abuf.Offs == GlslDecl.FaceAttr Abuf.Offs == GlslDecl.FaceAttr
? OperType.I32 ? OperType.I32
: OperType.F32; : OperType.F32;