#include "tcuTestLog.hpp"
#include "vkPrograms.hpp"
#include "vkQueryUtil.hpp"
+#include "vkRefUtil.hpp"
#include "vktTestCase.hpp"
namespace vkt
{
const VkDevice vkDevice = m_context.getDevice();
const DeviceInterface& vk = m_context.getDeviceInterface();
- VkBuffer testBuffer;
+ Move<VkBuffer> testBuffer;
VkMemoryRequirements memReqs;
- VkDeviceMemory memory;
+ Move<VkDeviceMemory> memory;
const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
// Create buffer
&queueFamilyIndex,
};
- if (vk.createBuffer(vkDevice, &bufferParams, (const VkAllocationCallbacks*)DE_NULL, &testBuffer) != VK_SUCCESS)
- return tcu::TestStatus::fail("Buffer creation failed! (requested memory size: " + de::toString(size) + ")");
+ try
+ {
+ testBuffer = createBuffer(vk, vkDevice, &bufferParams, (const VkAllocationCallbacks*)DE_NULL);
+ }
+ catch (const vk::Error& error)
+ {
+ return tcu::TestStatus::fail("Buffer creation failed! (requested memory size: " + de::toString(size) + ", Error code: " + de::toString(error.getMessage()) + ")");
+ }
- vk.getBufferMemoryRequirements(vkDevice, testBuffer, &memReqs);
+ vk.getBufferMemoryRequirements(vkDevice, *testBuffer, &memReqs);
if (size > memReqs.size)
{
0 // deUint32 memoryTypeIndex
};
- if (vk.allocateMemory(vkDevice, &memAlloc, (const VkAllocationCallbacks*)DE_NULL, &memory) != VK_SUCCESS)
- return tcu::TestStatus::fail("Alloc memory failed! (requested memory size: " + de::toString(size) + ")");
-
+ try
+ {
+ memory = allocateMemory(vk, vkDevice, &memAlloc, (const VkAllocationCallbacks*)DE_NULL);
+ }
+ catch (const vk::Error& error)
+ {
+ return tcu::TestStatus::fail("Alloc memory failed! (requested memory size: " + de::toString(size) + ", Error code: " + de::toString(error.getMessage()) + ")");
+ }
if ((m_testCase.flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) ||
(m_testCase.flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) ||
{
0, // VkDeviceSize resourceOffset;
memReqs.size, // VkDeviceSize size;
- memory, // VkDeviceMemory memory;
+ *memory, // VkDeviceMemory memory;
0, // VkDeviceSize memoryOffset;
0 // VkSparseMemoryBindFlags flags;
};
const VkSparseBufferMemoryBindInfo sparseBufferMemoryBindInfo =
{
- testBuffer, // VkBuffer buffer;
+ *testBuffer, // VkBuffer buffer;
1u, // deUint32 bindCount;
&sparseMemoryBind // const VkSparseMemoryBind* pBinds;
};
if (vk.queueBindSparse(queue, 1, &bindSparseInfo, DE_NULL) != VK_SUCCESS)
return tcu::TestStatus::fail("Bind sparse buffer memory failed! (requested memory size: " + de::toString(size) + ")");
} else
- if (vk.bindBufferMemory(vkDevice, testBuffer, memory, 0) != VK_SUCCESS)
+ if (vk.bindBufferMemory(vkDevice, *testBuffer, *memory, 0) != VK_SUCCESS)
return tcu::TestStatus::fail("Bind buffer memory failed! (requested memory size: " + de::toString(size) + ")");
}
- vk.freeMemory(vkDevice, memory, (const VkAllocationCallbacks*)DE_NULL);
- vk.destroyBuffer(vkDevice, testBuffer, (const VkAllocationCallbacks*)DE_NULL);
-
return tcu::TestStatus::pass("Buffer test");
}
#include "gluVarType.hpp"
#include "tcuTestLog.hpp"
#include "vkPrograms.hpp"
+#include "vkRefUtil.hpp"
#include "vktTestCase.hpp"
namespace vkt
const DeviceInterface& vk = m_context.getDeviceInterface();
const deUint32 queueFamilyIndex = m_context.getUniversalQueueFamilyIndex();
const VkDeviceSize size = 3 * 5 * 7 * 64;
- VkBuffer testBuffer;
+ Move<VkBuffer> testBuffer;
VkMemoryRequirements memReqs;
VkFormatProperties properties;
const VkBufferCreateInfo bufferParams =
if (!(properties.bufferFeatures & m_testCase.features))
TCU_THROW(NotSupportedError, "Format not supported");
- if (vk.createBuffer(vkDevice, &bufferParams, (const VkAllocationCallbacks*)DE_NULL, &testBuffer) != VK_SUCCESS)
- return tcu::TestStatus::fail("Buffer creation failed!");
+ try
+ {
+ testBuffer = createBuffer(vk, vkDevice, &bufferParams, (const VkAllocationCallbacks*)DE_NULL);
+ }
+ catch (const vk::Error& error)
+ {
+ return tcu::TestStatus::fail("Buffer creation failed! (Error code: " + de::toString(error.getMessage()) + ")");
+ }
- vk.getBufferMemoryRequirements(vkDevice, testBuffer, &memReqs);
+ vk.getBufferMemoryRequirements(vkDevice, *testBuffer, &memReqs);
if (size > memReqs.size)
{
return tcu::TestStatus::fail(errorMsg.str());
}
- VkDeviceMemory memory;
+ Move<VkDeviceMemory> memory;
const VkMemoryAllocateInfo memAlloc =
{
VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, // VkStructureType sType
{
// Create buffer view.
- VkBufferView bufferView;
+ Move<VkBufferView> bufferView;
const VkBufferViewCreateInfo bufferViewCreateInfo =
{
VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO, // VkStructureType sType;
NULL, // const void* pNext;
(VkBufferViewCreateFlags)0,
- testBuffer, // VkBuffer buffer;
+ *testBuffer, // VkBuffer buffer;
m_testCase.format, // VkFormat format;
m_testCase.offset, // VkDeviceSize offset;
m_testCase.range, // VkDeviceSize range;
};
- if (vk.allocateMemory(vkDevice, &memAlloc, (const VkAllocationCallbacks*)DE_NULL, &memory) != VK_SUCCESS)
- return tcu::TestStatus::fail("Alloc memory failed!");
+ try
+ {
+ memory = allocateMemory(vk, vkDevice, &memAlloc, (const VkAllocationCallbacks*)DE_NULL);
+ }
+ catch (const vk::Error& error)
+ {
+ return tcu::TestStatus::fail("Alloc memory failed! (Error code: " + de::toString(error.getMessage()) + ")");
+ }
- if (vk.bindBufferMemory(vkDevice, testBuffer, memory, 0) != VK_SUCCESS)
+ if (vk.bindBufferMemory(vkDevice, *testBuffer, *memory, 0) != VK_SUCCESS)
return tcu::TestStatus::fail("Bind buffer memory failed!");
- if (vk.createBufferView(vkDevice, &bufferViewCreateInfo, (const VkAllocationCallbacks*)DE_NULL, &bufferView) != VK_SUCCESS)
- return tcu::TestStatus::fail("Buffer View creation failed!");
-
- vk.destroyBufferView(vkDevice, bufferView, (const VkAllocationCallbacks*)DE_NULL);
+ try
+ {
+ bufferView = createBufferView(vk, vkDevice, &bufferViewCreateInfo, (const VkAllocationCallbacks*)DE_NULL);
+ }
+ catch (const vk::Error& error)
+ {
+ return tcu::TestStatus::fail("Buffer View creation failed! (Error code: " + de::toString(error.getMessage()) + ")");
+ }
}
// Testing complete view size.
{
- VkBufferView completeBufferView;
+ Move<VkBufferView> completeBufferView;
VkBufferViewCreateInfo completeBufferViewCreateInfo =
{
VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO, // VkStructureType sType;
NULL, // const void* pNext;
(VkBufferViewCreateFlags)0,
- testBuffer, // VkBuffer buffer;
+ *testBuffer, // VkBuffer buffer;
m_testCase.format, // VkFormat format;
m_testCase.offset, // VkDeviceSize offset;
size, // VkDeviceSize range;
};
- if (vk.createBufferView(vkDevice, &completeBufferViewCreateInfo, (const VkAllocationCallbacks*)DE_NULL, &completeBufferView) != VK_SUCCESS)
- return tcu::TestStatus::fail("Buffer View creation failed!");
-
- vk.destroyBufferView(vkDevice, completeBufferView, (const VkAllocationCallbacks*)DE_NULL);
+ try
+ {
+ completeBufferView = createBufferView(vk, vkDevice, &completeBufferViewCreateInfo, (const VkAllocationCallbacks*)DE_NULL);
+ }
+ catch (const vk::Error& error)
+ {
+ return tcu::TestStatus::fail("Buffer View creation failed! (Error code: " + de::toString(error.getMessage()) + ")");
+ }
}
- vk.freeMemory(vkDevice, memory, (const VkAllocationCallbacks*)DE_NULL);
- vk.destroyBuffer(vkDevice, testBuffer, (const VkAllocationCallbacks*)DE_NULL);
-
return tcu::TestStatus::pass("BufferView test");
}