From 8811506adf0829ca6c6b42d1dfef61c1897a6eb3 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 17 Aug 2020 22:10:02 -0400 Subject: [PATCH] Starts towards building a compound[/composition?] buffer. I now need to discover whether I can use natural integer texture coordinates. --- .../Clock Signal/ScanTarget/ScanTarget.metal | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/OSBindings/Mac/Clock Signal/ScanTarget/ScanTarget.metal b/OSBindings/Mac/Clock Signal/ScanTarget/ScanTarget.metal index 08d3ff2e9..4d69f3bc7 100644 --- a/OSBindings/Mac/Clock Signal/ScanTarget/ScanTarget.metal +++ b/OSBindings/Mac/Clock Signal/ScanTarget/ScanTarget.metal @@ -142,6 +142,9 @@ template 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 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.