Use memcpy to copy floats for vertex input
authorMark Adams <marka@nvidia.com>
Sat, 16 Jan 2016 16:37:31 +0000 (11:37 -0500)
committerMark Adams <marka@nvidia.com>
Sat, 16 Jan 2016 16:37:31 +0000 (11:37 -0500)
The destination buffer may not be aligned as required to
cast as a float* or deFloat16*. This was causing crashes
due to bus errors on 32-bit ARM systems in several of the
dEQP-VK.pipeline.vertex_input.multiple_attributes.* tests.

external/vulkancts/modules/vulkan/pipeline/vktPipelineVertexInputTests.cpp

index 6af31c8..c136913 100644 (file)
@@ -1175,12 +1175,14 @@ void writeVertexInputValueSfloat (deUint8* destPtr, VkFormat format, int compone
 
        switch (componentSize)
        {
-               case 2:
-                       *((deFloat16*)destFormatPtr) = deFloat32To16(value);
+               case 2: {
+                       deFloat16 f16 = deFloat32To16(value);
+                       memcpy(destFormatPtr, &f16, sizeof(f16));
                        break;
+               }
 
                case 4:
-                       *((float*)destFormatPtr) = value;
+                       memcpy(destFormatPtr, &value, sizeof(value));
                        break;
 
                default: