vulkan: Set up VkCmdBuffer dispatching
Change-Id: Ifb3cea05dab8828c2c00b8ed60c5ad991cdcbea7
(cherry picked from commit 10bf73e13b6904afa606fdcdc05bcc510c605180)
diff --git a/vulkan/nulldrv/null_driver.cpp b/vulkan/nulldrv/null_driver.cpp
index 281873d..ad7011f 100644
--- a/vulkan/nulldrv/null_driver.cpp
+++ b/vulkan/nulldrv/null_driver.cpp
@@ -48,36 +48,36 @@
// Using a namespace here instead of 'enum class' since we want scoped
// constants but also want implicit conversions to integral types.
namespace HandleType {
- enum Enum {
- kAttachmentView,
- kBufferView,
- kCmdPool,
- kDescriptorPool,
- kDescriptorSet,
- kDescriptorSetLayout,
- kDynamicColorBlendState,
- kDynamicDepthStencilState,
- kDynamicRasterState,
- kDynamicViewportState,
- kEvent,
- kFence,
- kFramebuffer,
- kImageView,
- kPipeline,
- kPipelineCache,
- kPipelineLayout,
- kQueryPool,
- kRenderPass,
- kSampler,
- kSemaphore,
- kShader,
- kShaderModule,
+enum Enum {
+ kAttachmentView,
+ kBufferView,
+ kCmdPool,
+ kDescriptorPool,
+ kDescriptorSet,
+ kDescriptorSetLayout,
+ kDynamicColorBlendState,
+ kDynamicDepthStencilState,
+ kDynamicRasterState,
+ kDynamicViewportState,
+ kEvent,
+ kFence,
+ kFramebuffer,
+ kImageView,
+ kPipeline,
+ kPipelineCache,
+ kPipelineLayout,
+ kQueryPool,
+ kRenderPass,
+ kSampler,
+ kSemaphore,
+ kShader,
+ kShaderModule,
- kNumTypes
- };
-} // namespace HandleType
+ kNumTypes
+};
+} // namespace HandleType
uint64_t AllocHandle(VkDevice device, HandleType::Enum type);
-} // anonymous namespace
+} // anonymous namespace
struct VkDevice_T {
hwvulkan_dispatch_t dispatch;
@@ -299,6 +299,29 @@
}
// -----------------------------------------------------------------------------
+// CmdBuffer
+
+VkResult CreateCommandBuffer(VkDevice device,
+ const VkCmdBufferCreateInfo*,
+ VkCmdBuffer* out_cmdbuf) {
+ const VkAllocCallbacks* alloc = device->instance->alloc;
+ VkCmdBuffer_T* cmdbuf = static_cast<VkCmdBuffer_T*>(alloc->pfnAlloc(
+ alloc->pUserData, sizeof(VkCmdBuffer_T), alignof(VkCmdBuffer_T),
+ VK_SYSTEM_ALLOC_TYPE_API_OBJECT));
+ if (!cmdbuf)
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
+ cmdbuf->dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
+ *out_cmdbuf = cmdbuf;
+ return VK_SUCCESS;
+}
+
+VkResult DestroyCommandBuffer(VkDevice device, VkCmdBuffer cmdbuf) {
+ const VkAllocCallbacks* alloc = device->instance->alloc;
+ alloc->pfnFree(alloc->pUserData, cmdbuf);
+ return VK_SUCCESS;
+}
+
+// -----------------------------------------------------------------------------
// DeviceMemory
struct DeviceMemory {
@@ -629,7 +652,6 @@
}
VkResult QueueSubmit(VkQueue queue, uint32_t cmdBufferCount, const VkCmdBuffer* pCmdBuffers, VkFence fence) {
- ALOGV("TODO: vk%s", __FUNCTION__);
return VK_SUCCESS;
}
@@ -706,7 +728,6 @@
}
VkResult ResetFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences) {
- ALOGV("TODO: vk%s", __FUNCTION__);
return VK_SUCCESS;
}
@@ -716,7 +737,6 @@
}
VkResult WaitForFences(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout) {
- ALOGV("TODO: vk%s", __FUNCTION__);
return VK_SUCCESS;
}
@@ -889,23 +909,11 @@
return VK_SUCCESS;
}
-VkResult CreateCommandBuffer(VkDevice device, const VkCmdBufferCreateInfo* pCreateInfo, VkCmdBuffer* pCmdBuffer) {
- ALOGV("TODO: vk%s", __FUNCTION__);
- return VK_SUCCESS;
-}
-
-VkResult DestroyCommandBuffer(VkDevice device, VkCmdBuffer commandBuffer) {
- ALOGV("TODO: vk%s", __FUNCTION__);
- return VK_SUCCESS;
-}
-
VkResult BeginCommandBuffer(VkCmdBuffer cmdBuffer, const VkCmdBufferBeginInfo* pBeginInfo) {
- ALOGV("TODO: vk%s", __FUNCTION__);
return VK_SUCCESS;
}
VkResult EndCommandBuffer(VkCmdBuffer cmdBuffer) {
- ALOGV("TODO: vk%s", __FUNCTION__);
return VK_SUCCESS;
}