anv: Use vk_foreach_struct for handling extension structs
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 14 Feb 2017 22:29:19 +0000 (14:29 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Wed, 15 Feb 2017 00:15:39 +0000 (16:15 -0800)
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_formats.c
src/intel/vulkan/anv_private.h

index 57d70b625c19b405f2690ac0af060284177c8093..d1a6cc8e9c0f0df6a7ff9bb9818086e179f309b2 100644 (file)
@@ -33,6 +33,7 @@
 #include "anv_private.h"
 #include "util/strtod.h"
 #include "util/debug.h"
+#include "util/vk_util.h"
 
 #include "genxml/gen7_pack.h"
 
@@ -511,10 +512,10 @@ void anv_GetPhysicalDeviceFeatures2KHR(
 {
    anv_GetPhysicalDeviceFeatures(physicalDevice, &pFeatures->features);
 
-   for (struct anv_common *c = pFeatures->pNext; c != NULL; c = c->pNext) {
-      switch (c->sType) {
+   vk_foreach_struct(ext, pFeatures->pNext) {
+      switch (ext->sType) {
       default:
-         anv_debug_ignored_stype(c->sType);
+         anv_debug_ignored_stype(ext->sType);
          break;
       }
    }
@@ -669,10 +670,10 @@ void anv_GetPhysicalDeviceProperties2KHR(
 {
    anv_GetPhysicalDeviceProperties(physicalDevice, &pProperties->properties);
 
-   for (struct anv_common *c = pProperties->pNext; c != NULL; c = c->pNext) {
-      switch (c->sType) {
+   vk_foreach_struct(ext, pProperties->pNext) {
+      switch (ext->sType) {
       default:
-         anv_debug_ignored_stype(c->sType);
+         anv_debug_ignored_stype(ext->sType);
          break;
       }
    }
@@ -746,11 +747,10 @@ void anv_GetPhysicalDeviceQueueFamilyProperties2KHR(
    anv_get_queue_family_properties(phys_dev,
          &pQueueFamilyProperties->queueFamilyProperties);
 
-   for (struct anv_common *c = pQueueFamilyProperties->pNext;
-        c != NULL; c = c->pNext) {
-      switch (c->sType) {
+   vk_foreach_struct(ext, pQueueFamilyProperties->pNext) {
+      switch (ext->sType) {
       default:
-         anv_debug_ignored_stype(c->sType);
+         anv_debug_ignored_stype(ext->sType);
          break;
       }
    }
@@ -815,11 +815,10 @@ void anv_GetPhysicalDeviceMemoryProperties2KHR(
    anv_GetPhysicalDeviceMemoryProperties(physicalDevice,
                                          &pMemoryProperties->memoryProperties);
 
-   for (struct anv_common *c = pMemoryProperties->pNext;
-        c != NULL; c = c->pNext) {
-      switch (c->sType) {
+   vk_foreach_struct(ext, pMemoryProperties->pNext) {
+      switch (ext->sType) {
       default:
-         anv_debug_ignored_stype(c->sType);
+         anv_debug_ignored_stype(ext->sType);
          break;
       }
    }
index 0e84960085a12c963c9668c4d79bfc23b779e2ac..6005791be5d24c8cb19b5f1609779a9a273484f9 100644 (file)
@@ -24,6 +24,8 @@
 #include "anv_private.h"
 #include "vk_format_info.h"
 
+#include "util/vk_util.h"
+
 /*
  * gcc-4 and earlier don't allow compound literals where a constant
  * is required in -std=c99/gnu99 mode, so we can't use ISL_SWIZZLE()
@@ -470,11 +472,10 @@ void anv_GetPhysicalDeviceFormatProperties2KHR(
    anv_GetPhysicalDeviceFormatProperties(physicalDevice, format,
                                          &pFormatProperties->formatProperties);
 
-   for (struct anv_common *c = pFormatProperties->pNext;
-        c != NULL; c = c->pNext) {
-      switch (c->sType) {
+   vk_foreach_struct(ext, pFormatProperties->pNext) {
+      switch (ext->sType) {
       default:
-         anv_debug_ignored_stype(c->sType);
+         anv_debug_ignored_stype(ext->sType);
          break;
       }
    }
@@ -668,11 +669,10 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties2KHR(
    if (result != VK_SUCCESS)
       return result;
 
-   for (struct anv_common *c = pImageFormatProperties->pNext;
-        c != NULL; c = c->pNext) {
-      switch (c->sType) {
+   vk_foreach_struct(ext, pImageFormatProperties->pNext) {
+      switch (ext->sType) {
       default:
-         anv_debug_ignored_stype(c->sType);
+         anv_debug_ignored_stype(ext->sType);
          break;
       }
    }
index b5c5b23f0fc7b46e92b019933e7bf21e1ecd0e06..da1ca29f64c3c38086ffa63d9e26d793b0a0a895 100644 (file)
@@ -1895,11 +1895,6 @@ void anv_dump_finish(void);
 void anv_dump_add_framebuffer(struct anv_cmd_buffer *cmd_buffer,
                               struct anv_framebuffer *fb);
 
-struct anv_common {
-    VkStructureType sType;
-    struct anv_common *pNext;
-};
-
 #define ANV_DEFINE_HANDLE_CASTS(__anv_type, __VkType)                      \
                                                                            \
    static inline struct __anv_type *                                       \