loader: Add support for AMD device extension
authorMark Lobodzinski <mark@lunarg.com>
Mon, 29 Aug 2016 20:54:34 +0000 (14:54 -0600)
committerMark Lobodzinski <mark@lunarg.com>
Wed, 31 Aug 2016 19:27:14 +0000 (13:27 -0600)
Added vkCmdDrawIndirectCountAMD and vkCmdDrawIndexedIndirectCountAMD
from the VK_AMD_draw_indirect_count extension to the loader.

Change-Id: I4e1810dd6efcc54291a35d1ce9a15e59830689f3

loader/extensions.c
loader/table_ops.h

index 47a3c12..3ba4b77 100644 (file)
@@ -75,16 +75,59 @@ terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV(
         externalHandleType, pExternalImageFormatProperties);
 }
 
+// Definitions for the VK_AMD_draw_indirect_count extension
+
+static const VkExtensionProperties amd_draw_indirect_count_extension_info = {
+    .extensionName = VK_AMD_EXTENSION_DRAW_INDIRECT_COUNT_EXTENSION_NAME,
+    .specVersion = VK_AMD_EXTENSION_DRAW_INDIRECT_COUNT_SPEC_VERSION,
+};
+
+VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectCountAMD(
+    VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
+    VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
+    uint32_t stride) {
+    const VkLayerDispatchTable *disp;
+
+    disp = loader_get_dispatch(commandBuffer);
+    disp->CmdDrawIndirectCountAMD(commandBuffer, buffer, offset, countBuffer,
+                                  countBufferOffset, maxDrawCount, stride);
+}
+
+VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCountAMD(
+    VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
+    VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
+    uint32_t stride) {
+    const VkLayerDispatchTable *disp;
+
+    disp = loader_get_dispatch(commandBuffer);
+    disp->CmdDrawIndexedIndirectCountAMD(commandBuffer, buffer, offset,
+                                         countBuffer, countBufferOffset,
+                                         maxDrawCount, stride);
+}
+
 bool extension_instance_gpa(struct loader_instance *ptr_instance,
                             const char *name, void **addr) {
     *addr = NULL;
 
     // Functions for the VK_NV_external_memory_capabilities extension
+
     if (!strcmp("vkGetPhysicalDeviceExternalImageFormatPropertiesNV", name)) {
         *addr = (void *)vkGetPhysicalDeviceExternalImageFormatPropertiesNV;
         return true;
     }
 
+    // Functions for the VK_AMD_draw_indirect_count extension
+
+    if (!strcmp("vkCmdDrawIndirectCountAMD", name)) {
+        *addr = (void *)vkCmdDrawIndirectCountAMD;
+        return true;
+    }
+
+    if (!strcmp("vkCmdDrawIndexedIndirectCountAMD", name)) {
+        *addr = (void *)vkCmdDrawIndexedIndirectCountAMD;
+        return true;
+    }
+
     return false;
 }
 
@@ -97,5 +140,11 @@ void extensions_create_instance(struct loader_instance *ptr_instance,
             // Nothing to do;
             return;
         }
+
+        if (strcmp(pCreateInfo->ppEnabledExtensionNames[i],
+                   VK_AMD_EXTENSION_DRAW_INDIRECT_COUNT_EXTENSION_NAME) == 0) {
+            // Nothing to do;
+            return;
+        }
     }
 }
index f527f6a..014607a 100644 (file)
@@ -267,6 +267,11 @@ static inline void loader_init_device_extension_dispatch_table(
         (PFN_vkGetSwapchainImagesKHR)gpa(dev, "vkGetSwapchainImagesKHR");
     table->QueuePresentKHR =
         (PFN_vkQueuePresentKHR)gpa(dev, "vkQueuePresentKHR");
+    table->CmdDrawIndirectCountAMD =
+        (PFN_vkCmdDrawIndirectCountAMD)gpa(dev, "vkCmdDrawIndirectCountAMD");
+    table->CmdDrawIndexedIndirectCountAMD =
+        (PFN_vkCmdDrawIndexedIndirectCountAMD)gpa(
+            dev, "vkCmdDrawIndexedIndirectCountAMD");
 }
 
 static inline void *