tests:Fix memory allocation sizes
authorTobin Ehlis <tobine@google.com>
Wed, 15 Nov 2017 18:26:26 +0000 (11:26 -0700)
committerTobin Ehlis <tobine@google.com>
Fri, 17 Nov 2017 16:38:09 +0000 (09:38 -0700)
Update QueryAndCopySecondaryCommandBuffers and
QueryAndCopyMultipleCommandBuffers tests to allocate buffer with size
based on the returned size requirements instead of hard-coded value.

tests/layer_validation_tests.cpp

index b07905d..2a5a2e8 100644 (file)
@@ -22951,14 +22951,14 @@ TEST_F(VkPositiveLayerTest, QueryAndCopySecondaryCommandBuffers) {
     VkBuffer buffer;
     err = vkCreateBuffer(m_device->device(), &buff_create_info, NULL, &buffer);
     ASSERT_VK_SUCCESS(err);
+
+    VkMemoryRequirements memReqs;
+    vkGetBufferMemoryRequirements(m_device->device(), buffer, &memReqs);
     VkMemoryAllocateInfo mem_alloc = {};
     mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
     mem_alloc.pNext = NULL;
-    mem_alloc.allocationSize = 1024;
+    mem_alloc.allocationSize = memReqs.size;
     mem_alloc.memoryTypeIndex = 0;
-
-    VkMemoryRequirements memReqs;
-    vkGetBufferMemoryRequirements(m_device->device(), buffer, &memReqs);
     bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, 0);
     if (!pass) {
         vkDestroyBuffer(m_device->device(), buffer, NULL);
@@ -23051,14 +23051,14 @@ TEST_F(VkPositiveLayerTest, QueryAndCopyMultipleCommandBuffers) {
     VkBuffer buffer;
     err = vkCreateBuffer(m_device->device(), &buff_create_info, NULL, &buffer);
     ASSERT_VK_SUCCESS(err);
+
+    VkMemoryRequirements memReqs;
+    vkGetBufferMemoryRequirements(m_device->device(), buffer, &memReqs);
     VkMemoryAllocateInfo mem_alloc = {};
     mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
     mem_alloc.pNext = NULL;
-    mem_alloc.allocationSize = 1024;
+    mem_alloc.allocationSize = memReqs.size;
     mem_alloc.memoryTypeIndex = 0;
-
-    VkMemoryRequirements memReqs;
-    vkGetBufferMemoryRequirements(m_device->device(), buffer, &memReqs);
     bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, 0);
     if (!pass) {
         vkDestroyBuffer(m_device->device(), buffer, NULL);