From 4c9418f59aea44fca4bc75732dd3cfcc41f35436 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 7 Aug 2020 21:18:08 -0400 Subject: [PATCH] Guarantees alignof(4) on all GPU-bound structures. Taken as given: Metal's requirement here is reasonable enough that it'll either be the same as other frameworks, or at least possibly help them down a fast path. --- Outputs/ScanTarget.hpp | 6 ++++-- Outputs/ScanTargets/BufferingScanTarget.hpp | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Outputs/ScanTarget.hpp b/Outputs/ScanTarget.hpp index 63be212d1..0765eef46 100644 --- a/Outputs/ScanTarget.hpp +++ b/Outputs/ScanTarget.hpp @@ -210,9 +210,11 @@ struct ScanTarget { /*! Defines a scan in terms of its two endpoints. + + Is guaranteed to be a multiple of four bytes in size. */ - struct Scan { - struct EndPoint { + struct alignas(4) Scan { + struct alignas(4) EndPoint { /// Provide the coordinate of this endpoint. These are fixed point, purely fractional /// numbers, relative to the scale provided in the Modals. uint16_t x, y; diff --git a/Outputs/ScanTargets/BufferingScanTarget.hpp b/Outputs/ScanTargets/BufferingScanTarget.hpp index 1f6b40ae0..503681aa3 100644 --- a/Outputs/ScanTargets/BufferingScanTarget.hpp +++ b/Outputs/ScanTargets/BufferingScanTarget.hpp @@ -51,7 +51,7 @@ class BufferingScanTarget: public Outputs::Display::ScanTarget { // Extends the definition of a Scan to include two extra fields, // completing this scan's source data and destination locations. - struct Scan { + struct alignas(4) Scan { Outputs::Display::ScanTarget::Scan scan; /// Stores the y coordinate for this scan's data within the write area texture. @@ -66,12 +66,13 @@ class BufferingScanTarget: public Outputs::Display::ScanTarget { /// Defines the boundaries of a complete line of video — a 2d start and end location, /// composite phase and amplitude (if relevant), the source line in the intermediate buffer /// plus the start and end offsets of the area that is visible from the intermediate buffer. - struct Line { - struct EndPoint { + struct alignas(4) Line { + struct alignas(4) EndPoint { uint16_t x, y; uint16_t cycles_since_end_of_horizontal_retrace; int16_t composite_angle; } end_points[2]; + uint16_t line; uint8_t composite_amplitude; };