From 53568d445bcb4d669873732bdcea63b90a5b0041 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Thu, 18 Jan 2018 03:12:52 +0100 Subject: [PATCH] gs-vertex: Hint VS2013/2015 at proper alignment The previous fix unfortunately didn't actually fix it and instead made the crash invisible at first and then corrupt the heap at a later point. With this, VS2013 and VS2015 create code identical to what VS2017 creates, and no longer seem to crash. Related: #9 --- source/gs-vertex.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/source/gs-vertex.h b/source/gs-vertex.h index 979f19e7..7c0d1720 100644 --- a/source/gs-vertex.h +++ b/source/gs-vertex.h @@ -19,6 +19,7 @@ #pragma once #include +#include extern "C" { #pragma warning( push ) #pragma warning( disable: 4201 ) @@ -30,10 +31,22 @@ namespace GS { const uint32_t MAXIMUM_UVW_LAYERS = 8u; // ToDo: Optimize for use with GS::VertexBuffer so that it doesn't require in-memory copy. __declspec(align(16)) struct Vertex { - vec3 position; - vec3 normal; - vec3 tangent; - vec4 uv[MAXIMUM_UVW_LAYERS]; + union { + __m128 _positionM; + vec3 position; + }; + union { + __m128 _normalM; + vec3 normal; + }; + union { + __m128 _tangentM; + vec3 tangent; + }; + union { + __m128 _uvM[MAXIMUM_UVW_LAYERS]; + vec4 uv[MAXIMUM_UVW_LAYERS]; + }; uint32_t color; // Operators