Add default allocator to vulkan context.
authorJarkko Pöyry <jpoyry@google.com>
Sat, 25 Jul 2015 00:21:56 +0000 (17:21 -0700)
committerJarkko Pöyry <jpoyry@google.com>
Tue, 28 Jul 2015 20:05:25 +0000 (13:05 -0700)
Change-Id: Icad711b3e6071174c0307d4c34742d2fd2f73846

external/vulkancts/modules/vulkan/vktTestCase.cpp
external/vulkancts/modules/vulkan/vktTestCase.hpp

index b9d5a8e..f3a69aa 100644 (file)
@@ -37,6 +37,7 @@
 #include "vkRef.hpp"
 #include "vkQueryUtil.hpp"
 #include "vkDeviceUtil.hpp"
+#include "vkMemUtil.hpp"
 #include "vkPlatform.hpp"
 
 #include "deMemory.h"
@@ -144,6 +145,16 @@ VkQueue DefaultDevice::getUniversalQueue (void) const
        return queue;
 }
 
+// Allocator utilities
+
+vk::Allocator* createAllocator (DefaultDevice* device)
+{
+       const VkPhysicalDeviceMemoryProperties memoryProperties = vk::getPhysicalDeviceMemoryProperties(device->getInstanceInterface(), device->getPhysicalDevice());
+
+       // \todo [2015-07-24 jarkko] support allocator selection/configuration from command line (or compile time)
+       return new SimpleAllocator(device->getDeviceInterface(), device->getDevice(), memoryProperties);
+}
+
 // Context
 
 Context::Context (tcu::TestContext&                                                    testCtx,
@@ -153,12 +164,12 @@ Context::Context (tcu::TestContext&                                                       testCtx,
        , m_platformInterface   (platformInterface)
        , m_progCollection              (progCollection)
        , m_device                              (new DefaultDevice(m_platformInterface, testCtx.getCommandLine()))
+       , m_allocator                   (createAllocator(m_device.get()))
 {
 }
 
 Context::~Context (void)
 {
-       delete m_device;
 }
 
 vk::VkInstance                                 Context::getInstance                                    (void) const { return m_device->getInstance();                                  }
@@ -168,6 +179,7 @@ vk::VkDevice                                        Context::getDevice                                              (void) const { return m_device->getDevi
 const vk::DeviceInterface&             Context::getDeviceInterface                             (void) const { return m_device->getDeviceInterface();                   }
 deUint32                                               Context::getUniversalQueueFamilyIndex   (void) const { return m_device->getUniversalQueueFamilyIndex(); }
 vk::VkQueue                                            Context::getUniversalQueue                              (void) const { return m_device->getUniversalQueue();                    }
+vk::Allocator&                                 Context::getDefaultAllocator                    (void) const { return *m_allocator;                                                     }
 
 // TestCase
 
index 937c3d2..c7d61b6 100644 (file)
@@ -37,6 +37,7 @@
 #include "tcuDefs.hpp"
 #include "tcuTestCase.hpp"
 #include "vkDefs.hpp"
+#include "deUniquePtr.hpp"
 
 namespace glu
 {
@@ -48,6 +49,7 @@ namespace vk
 class PlatformInterface;
 class ProgramBinary;
 template<typename Program> class ProgramCollection;
+class Allocator;
 }
 
 namespace vkt
@@ -76,12 +78,15 @@ public:
        deUint32                                                                        getUniversalQueueFamilyIndex    (void) const;
        vk::VkQueue                                                                     getUniversalQueue                               (void) const;
 
+       vk::Allocator&                                                          getDefaultAllocator                             (void) const;
+
 protected:
        tcu::TestContext&                                                       m_testCtx;
        const vk::PlatformInterface&                            m_platformInterface;
        vk::ProgramCollection<vk::ProgramBinary>&       m_progCollection;
 
-       DefaultDevice* const                                            m_device;
+       const de::UniquePtr<DefaultDevice>                      m_device;
+       const de::UniquePtr<vk::Allocator>                      m_allocator;
 
 private:
                                                                                                Context                                                 (const Context&); // Not allowed