From 0499dbd4cf7382c64e8bd50e4bbb99c0f382c529 Mon Sep 17 00:00:00 2001 From: Icecream95 Date: Mon, 29 Aug 2022 16:24:58 +1200 Subject: [PATCH] Align Scan to be a multiple of four bytes Some GPUs (e.g. r600) require the stride of vertex attributes to be a multiple of four bytes, add two bytes of padding to the Scan struct to meet this alignment requirement and reduce driver CPU overhead. --- Outputs/OpenGL/ScanTargetGLSLFragments.cpp | 5 +++++ Outputs/ScanTarget.hpp | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Outputs/OpenGL/ScanTargetGLSLFragments.cpp b/Outputs/OpenGL/ScanTargetGLSLFragments.cpp index 0404f95e8..bdfd5649a 100644 --- a/Outputs/OpenGL/ScanTargetGLSLFragments.cpp +++ b/Outputs/OpenGL/ScanTargetGLSLFragments.cpp @@ -84,6 +84,11 @@ void ScanTarget::enable_vertex_attributes(ShaderType type, Shader &target) { Scan test_scan; Line test_line; + // Some GPUs require alignment and will need to copy vertex data to a + // shadow buffer otherwise + static_assert(sizeof(Scan) % 4 == 0); + static_assert(sizeof(Line) % 4 == 0); + switch(type) { case ShaderType::Composition: for(int c = 0; c < 2; ++c) { diff --git a/Outputs/ScanTarget.hpp b/Outputs/ScanTarget.hpp index dc4074d95..0a32ac346 100644 --- a/Outputs/ScanTarget.hpp +++ b/Outputs/ScanTarget.hpp @@ -304,7 +304,11 @@ struct ScanTarget { /// For composite video, dictates the amplitude of the colour subcarrier as a proportion of /// the whole, as determined from the colour burst. Will be 0 if there was no colour burst. - uint8_t composite_amplitude; + union { + uint8_t composite_amplitude; + + uint32_t padding; + }; }; /// Requests a new scan to populate.