Sodium

Sodium

44M Downloads

Provide a BufferBuilder interface that allows rewriting past vertex data

IMS212 opened this issue ยท 1 comments

commented

Iris uses a specialized system for writing extended vertex data. #2241 breaks this system.

The way this system works is by writing all the standard vertex data, skipping over bytes where the values aren't yet known. Once all 4 vertices in a quad are written, Iris goes back, gathering data about the quad, and writes new values for the normal, tangent, and average texture values.

In practice, it looks like this for one value (mid texture coordinates).

Sodium should provide a system to allow this without drastically reducing performance.

if (vertexCount == 4) {
	vertexCount = 0;
        float midU, midV;
        for (int i = 0; i < 4; i++) {
                midU += memGetFloat(bufferPointer + 12 - stride * i);
                midV += memGetFloat(bufferPointer + 16 - stride * i);
       }

        midU *= 0.25f;
        midV *= 0.25f;
      
        // This rewrites the past vertices to add the midU and midV values.
        for (int i = 0; i < 4; i++) {
                memPutFloat(bufferPointer + 38 - stride * i, midU);
                memPutFloat(bufferPointer + 42 - stride * i, midV);
        }
}
commented

Is this still necessary after IrisShaders/Iris@4d7abdd?