mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-10-01 12:30:00 +02:00
Support constant attributes (with a value of zero) (#1066)
* Support constant attributes (with a value of zero) * Remove extra line
This commit is contained in:
parent
8f21db810d
commit
9948a7be53
4 changed files with 26 additions and 4 deletions
|
@ -5,12 +5,15 @@ namespace Ryujinx.Graphics.GAL
|
||||||
public int BufferIndex { get; }
|
public int BufferIndex { get; }
|
||||||
public int Offset { get; }
|
public int Offset { get; }
|
||||||
|
|
||||||
|
public bool IsZero { get; }
|
||||||
|
|
||||||
public Format Format { get; }
|
public Format Format { get; }
|
||||||
|
|
||||||
public VertexAttribDescriptor(int bufferIndex, int offset, Format format)
|
public VertexAttribDescriptor(int bufferIndex, int offset, bool isZero, Format format)
|
||||||
{
|
{
|
||||||
BufferIndex = bufferIndex;
|
BufferIndex = bufferIndex;
|
||||||
Offset = offset;
|
Offset = offset;
|
||||||
|
IsZero = isZero;
|
||||||
Format = format;
|
Format = format;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -532,6 +532,7 @@ namespace Ryujinx.Graphics.Gpu.Engine
|
||||||
vertexAttribs[index] = new VertexAttribDescriptor(
|
vertexAttribs[index] = new VertexAttribDescriptor(
|
||||||
vertexAttrib.UnpackBufferIndex(),
|
vertexAttrib.UnpackBufferIndex(),
|
||||||
vertexAttrib.UnpackOffset(),
|
vertexAttrib.UnpackOffset(),
|
||||||
|
vertexAttrib.UnpackIsConstant(),
|
||||||
format);
|
format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,15 @@ namespace Ryujinx.Graphics.Gpu.State
|
||||||
return (int)(Attribute & 0x1f);
|
return (int)(Attribute & 0x1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unpacks the attribute constant flag.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True if the attribute is constant, false otherwise</returns>
|
||||||
|
public bool UnpackIsConstant()
|
||||||
|
{
|
||||||
|
return (Attribute & 0x40) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unpacks the offset, in bytes, of the attribute on the vertex buffer.
|
/// Unpacks the offset, in bytes, of the attribute on the vertex buffer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -58,7 +58,16 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
{
|
{
|
||||||
FormatInfo fmtInfo = FormatTable.GetFormatInfo(attrib.Format);
|
FormatInfo fmtInfo = FormatTable.GetFormatInfo(attrib.Format);
|
||||||
|
|
||||||
GL.EnableVertexAttribArray(attribIndex);
|
if (attrib.IsZero)
|
||||||
|
{
|
||||||
|
// Disabling the attribute causes the shader to read a constant value.
|
||||||
|
// The value is configurable, but by default is a vector of (0, 0, 0, 1).
|
||||||
|
GL.DisableVertexAttribArray(attribIndex);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GL.EnableVertexAttribArray(attribIndex);
|
||||||
|
}
|
||||||
|
|
||||||
int offset = attrib.Offset;
|
int offset = attrib.Offset;
|
||||||
int size = fmtInfo.Components;
|
int size = fmtInfo.Components;
|
||||||
|
@ -117,7 +126,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_needsAttribsUpdate)
|
if (_needsAttribsUpdate && !attrib.IsZero)
|
||||||
{
|
{
|
||||||
GL.EnableVertexAttribArray(attribIndex);
|
GL.EnableVertexAttribArray(attribIndex);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue