Initial implementation of CommandPool

Basic shell class for CommandPool

Bug b/119827933

Change-Id: Ibbc8ac641b168a15974fd4ff1803b5aff51f48a3
Reviewed-on: https://swiftshader-review.googlesource.com/c/22730
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Vulkan/VkCommandPool.cpp b/src/Vulkan/VkCommandPool.cpp
new file mode 100644
index 0000000..155dfeb
--- /dev/null
+++ b/src/Vulkan/VkCommandPool.cpp
@@ -0,0 +1,33 @@
+// Copyright 2018 The SwiftShader Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "VkCommandPool.hpp"
+
+namespace vk
+{
+
+CommandPool::CommandPool(const VkCommandPoolCreateInfo* pCreateInfo, void* mem)
+{
+}
+
+void CommandPool::destroy(const VkAllocationCallbacks* pAllocator)
+{
+}
+
+size_t CommandPool::ComputeRequiredAllocationSize(const VkCommandPoolCreateInfo* pCreateInfo)
+{
+	return 0;
+}
+
+} // namespace vk
diff --git a/src/Vulkan/VkCommandPool.hpp b/src/Vulkan/VkCommandPool.hpp
new file mode 100644
index 0000000..46b1426
--- /dev/null
+++ b/src/Vulkan/VkCommandPool.hpp
@@ -0,0 +1,42 @@
+// Copyright 2018 The SwiftShader Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef VK_COMMAND_POOL_HPP_
+#define VK_COMMAND_POOL_HPP_
+
+#include "VkObject.hpp"
+
+namespace vk
+{
+
+class CommandPool : public Object<CommandPool, VkCommandPool>
+{
+public:
+	CommandPool(const VkCommandPoolCreateInfo* pCreateInfo, void* mem);
+	~CommandPool() = delete;
+	void destroy(const VkAllocationCallbacks* pAllocator);
+
+	static size_t ComputeRequiredAllocationSize(const VkCommandPoolCreateInfo* pCreateInfo);
+
+private:
+};
+
+static inline CommandPool* Cast(VkCommandPool object)
+{
+	return reinterpret_cast<CommandPool*>(object);
+}
+
+} // namespace vk
+
+#endif // VK_COMMAND_POOL_HPP_
diff --git a/src/Vulkan/VkDestroy.h b/src/Vulkan/VkDestroy.h
index cdc907f..b70a17f 100644
--- a/src/Vulkan/VkDestroy.h
+++ b/src/Vulkan/VkDestroy.h
@@ -15,6 +15,7 @@
 #include "VkBuffer.hpp"
 #include "VkBufferView.hpp"
 #include "VkCommandBuffer.hpp"
+#include "VkCommandPool.hpp"
 #include "VkDevice.hpp"
 #include "VkDeviceMemory.hpp"
 #include "VkEvent.hpp"
diff --git a/src/Vulkan/libVulkan.cpp b/src/Vulkan/libVulkan.cpp
index 0972c62..fe59570 100644
--- a/src/Vulkan/libVulkan.cpp
+++ b/src/Vulkan/libVulkan.cpp
@@ -15,6 +15,7 @@
 #include "VkBuffer.hpp"
 #include "VkBufferView.hpp"
 #include "VkCommandBuffer.hpp"
+#include "VkCommandPool.hpp"
 #include "VkConfig.h"
 #include "VkDebug.hpp"
 #include "VkDestroy.h"
@@ -1020,9 +1021,12 @@
 	TRACE("(VkDevice device = 0x%X, const VkCommandPoolCreateInfo* pCreateInfo = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X, VkCommandPool* pCommandPool = 0x%X)",
 		    device, pCreateInfo, pAllocator, pCommandPool);
 
-	UNIMPLEMENTED();
+	if(pCreateInfo->pNext)
+	{
+		UNIMPLEMENTED();
+	}
 
-	return VK_SUCCESS;
+	return vk::CommandPool::Create(pAllocator, pCreateInfo, pCommandPool);
 }
 
 VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks* pAllocator)
@@ -1030,7 +1034,7 @@
 	TRACE("(VkDevice device = 0x%X, VkCommandPool commandPool = 0x%X, const VkAllocationCallbacks* pAllocator = 0x%X)",
 		    device, commandPool, pAllocator);
 
-	UNIMPLEMENTED();
+	vk::destroy(commandPool, pAllocator);
 }
 
 VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandPool(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags)
diff --git a/src/Vulkan/vulkan.vcxproj b/src/Vulkan/vulkan.vcxproj
index a9a6383..124d5ed 100644
--- a/src/Vulkan/vulkan.vcxproj
+++ b/src/Vulkan/vulkan.vcxproj
@@ -102,6 +102,7 @@
     <ClCompile Include="main.cpp" />

     <ClCompile Include="VkBuffer.cpp" />

     <ClCompile Include="VkCommandBuffer.cpp" />

+    <ClCompile Include="VkCommandPool.cpp" />

     <ClCompile Include="VkDebug.cpp" />

     <ClCompile Include="VkDevice.cpp" />

     <ClCompile Include="VkDeviceMemory.cpp" />

@@ -191,6 +192,7 @@
     <ClInclude Include="VkBuffer.hpp" />

     <ClInclude Include="VkBufferView.hpp" />

     <ClInclude Include="VkCommandBuffer.hpp" />

+    <ClInclude Include="VkCommandPool.hpp" />

     <ClInclude Include="VkConfig.h" />

     <ClInclude Include="VkDebug.hpp" />

     <ClInclude Include="VkDestroy.h" />

diff --git a/src/Vulkan/vulkan.vcxproj.filters b/src/Vulkan/vulkan.vcxproj.filters
index 1d684b4..0f86ff6 100644
--- a/src/Vulkan/vulkan.vcxproj.filters
+++ b/src/Vulkan/vulkan.vcxproj.filters
@@ -204,6 +204,9 @@
     <ClCompile Include="VkCommandBuffer.cpp">

       <Filter>Source Files\Vulkan</Filter>

     </ClCompile>

+    <ClCompile Include="VkCommandPool.cpp">

+      <Filter>Source Files\Vulkan</Filter>

+    </ClCompile>

     <ClCompile Include="VkDebug.cpp">

       <Filter>Source Files\Vulkan</Filter>

     </ClCompile>

@@ -263,6 +266,9 @@
     <ClInclude Include="VkCommandBuffer.hpp">

       <Filter>Header Files\Vulkan</Filter>

     </ClInclude>

+    <ClInclude Include="VkCommandPool.hpp">

+      <Filter>Header Files\Vulkan</Filter>

+    </ClInclude>

     <ClInclude Include="VkConfig.h">

       <Filter>Header Files\Vulkan</Filter>

     </ClInclude>