Fix alignment issues in uploading image data in ShaderExecutor
authorPyry Haulos <phaulos@google.com>
Tue, 27 Sep 2016 22:49:46 +0000 (15:49 -0700)
committerPyry Haulos <phaulos@google.com>
Thu, 29 Sep 2016 19:18:00 +0000 (15:18 -0400)
Fixes #485

Change-Id: If04aebab19fb25ef26b51b4af86e718004438d82

external/vulkancts/modules/vulkan/shaderexecutor/vktShaderExecutor.cpp

index 1f09cbd..977ba41 100644 (file)
@@ -3149,7 +3149,8 @@ void ShaderExecutor::uploadImage (const VkDevice&                         vkDevice,
                                                                  const VkImageAspectFlags              aspectMask,
                                                                  VkImage                                               destImage)
 {
-       deUint32                                                textureSize                     = texSize.x() * texSize.y() * texSize.z() * texFormat.getPixelSize();
+       const deUint32                                  unalignedTextureSize            = texSize.x() * texSize.y() * texSize.z() * texFormat.getPixelSize();
+       const deUint32                                  alignedTextureSize                      = deAlign32(unalignedTextureSize, 4u);
        deUint32                                                bufferSize;
        Move<VkBuffer>                                  buffer;
        de::MovePtr<Allocation>                 bufferAlloc;
@@ -3159,7 +3160,7 @@ void ShaderExecutor::uploadImage (const VkDevice&                         vkDevice,
        std::vector<deUint32>                   levelDataSizes;
 
        // Calculate buffer size
-       bufferSize = arraySize * textureSize;
+       bufferSize = arraySize * alignedTextureSize;
 
        // Create source buffer
        {
@@ -3305,7 +3306,7 @@ void ShaderExecutor::uploadImage (const VkDevice&                         vkDevice,
                        };
 
                        copyRegions.push_back(layerRegion);
-                       layerDataOffset += textureSize;
+                       layerDataOffset += alignedTextureSize;
                }
        }
 
@@ -3320,7 +3321,7 @@ void ShaderExecutor::uploadImage (const VkDevice&                         vkDevice,
                        tcu::PixelBufferAccess                  destAccess      (texFormat, texSize, destPtr + levelOffset);
 
                        tcu::copy(destAccess, access);
-                       levelOffset += textureSize;
+                       levelOffset += alignedTextureSize;
                }
        }