1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +00:00

Starts towards building a compound[/composition?] buffer.

I now need to discover whether I can use natural integer texture coordinates.
This commit is contained in:
Thomas Harte 2020-08-17 22:10:02 -04:00
parent 11dec6fc0f
commit 8811506adf

View File

@ -142,6 +142,9 @@ template <typename Input> SourceInterpolator toDisplay(
return output;
}
// These next two assume the incoming geometry to be a four-vertex triangle strip; each instance will therefore
// produce a quad.
vertex SourceInterpolator scanToDisplay( constant Uniforms &uniforms [[buffer(1)]],
constant Scan *scans [[buffer(0)]],
uint instanceID [[instance_id]],
@ -156,6 +159,26 @@ vertex SourceInterpolator lineToDisplay( constant Uniforms &uniforms [[buffer(1)
return toDisplay(uniforms, lines, instanceID, vertexID);
}
// This assumes that it needs to generate endpoints for a line segment.
vertex SourceInterpolator scanToCompound( constant Uniforms &uniforms [[buffer(1)]],
constant Scan *scans [[buffer(0)]],
uint instanceID [[instance_id]],
uint vertexID [[vertex_id]],
texture2d<float> texture [[texture(0)]]) {
SourceInterpolator result;
// Populate result as if direct texture access were available.
result.position.x = mix(scans[instanceID].endPoints[0].cyclesSinceRetrace, scans[instanceID].endPoints[1].cyclesSinceRetrace, float(vertexID));
result.position.y = scans[instanceID].line;
result.textureCoordinates.x = mix(scans[instanceID].endPoints[0].dataOffset, scans[instanceID].endPoints[1].dataOffset, float(vertexID));
result.textureCoordinates.y = scans[instanceID].dataY;
// TODO: map position into eye space, allowing for target texture dimensions.
return result;
}
// MARK: - Various input format conversion samplers.