Move sRGB -> linear conversion for vertex color to vertex shader.

This took almost 2% of CPU time on release. Jeez.
This commit is contained in:
Pieter-Jan Briers
2022-05-28 23:17:37 +02:00
parent 47d7c7cf6c
commit 655b5974a3
2 changed files with 7 additions and 11 deletions

View File

@@ -541,14 +541,12 @@ namespace Robust.Client.Graphics.Clyde
tr = _currentMatrixModel.Transform(tr);
tl = _currentMatrixModel.Transform(tl);
var modulateLinear = Color.FromSrgb(modulate);
// TODO: split batch if necessary.
var vIdx = BatchVertexIndex;
BatchVertexData[vIdx + 0] = new Vertex2D(bl, texCoords.BottomLeft, modulateLinear);
BatchVertexData[vIdx + 1] = new Vertex2D(br, texCoords.BottomRight, modulateLinear);
BatchVertexData[vIdx + 2] = new Vertex2D(tr, texCoords.TopRight, modulateLinear);
BatchVertexData[vIdx + 3] = new Vertex2D(tl, texCoords.TopLeft, modulateLinear);
BatchVertexData[vIdx + 0] = new Vertex2D(bl, texCoords.BottomLeft, modulate);
BatchVertexData[vIdx + 1] = new Vertex2D(br, texCoords.BottomRight, modulate);
BatchVertexData[vIdx + 2] = new Vertex2D(tr, texCoords.TopRight, modulate);
BatchVertexData[vIdx + 3] = new Vertex2D(tl, texCoords.TopLeft, modulate);
BatchVertexIndex += 4;
QuadBatchIndexWrite(BatchIndexData, ref BatchIndexIndex, (ushort) vIdx);
@@ -645,12 +643,10 @@ namespace Robust.Client.Graphics.Clyde
a = _currentMatrixModel.Transform(a);
b = _currentMatrixModel.Transform(b);
var colorLinear = Color.FromSrgb(color);
// TODO: split batch if necessary.
var vIdx = BatchVertexIndex;
BatchVertexData[vIdx + 0] = new Vertex2D(a, Vector2.Zero, colorLinear);
BatchVertexData[vIdx + 1] = new Vertex2D(b, Vector2.Zero, colorLinear);
BatchVertexData[vIdx + 0] = new Vertex2D(a, Vector2.Zero, color);
BatchVertexData[vIdx + 1] = new Vertex2D(b, Vector2.Zero, color);
BatchVertexIndex += 2;
_debugStats.LastClydeDrawCalls += 1;

View File

@@ -36,5 +36,5 @@ void main()
gl_Position = vec4(VERTEX, 0.0, 1.0);
Pos = (VERTEX + 1.0) / 2.0;
UV = mix(modifyUV.xy, modifyUV.zw, tCoord);
VtxModulate = modulate;
VtxModulate = zFromSrgb(modulate);
}