bug-14542: Remove VK_UNSUPPORTED from success return codes
authorCourtney Goeltzenleuchter <courtney@LunarG.com>
Thu, 22 Oct 2015 17:03:31 +0000 (11:03 -0600)
committerCourtney Goeltzenleuchter <courtney@LunarG.com>
Fri, 23 Oct 2015 23:32:04 +0000 (17:32 -0600)
demos/cube.c
demos/tri.c
demos/vulkaninfo.c
include/vulkan.h
layers/param_checker.cpp
layers/screenshot.cpp

index a74c909..7cb7057 100644 (file)
@@ -407,7 +407,7 @@ struct demo {
     uint32_t queue_count;
 };
 
-static VkResult memory_type_from_properties(struct demo *demo, uint32_t typeBits, VkFlags requirements_mask, uint32_t *typeIndex)
+static bool memory_type_from_properties(struct demo *demo, uint32_t typeBits, VkFlags requirements_mask, uint32_t *typeIndex)
 {
      // Search memtypes to find first index with those properties
      for (uint32_t i = 0; i < 32; i++) {
@@ -415,13 +415,13 @@ static VkResult memory_type_from_properties(struct demo *demo, uint32_t typeBits
              // Type is available, does it match user properties?
              if ((demo->memory_properties.memoryTypes[i].propertyFlags & requirements_mask) == requirements_mask) {
                  *typeIndex = i;
-                 return VK_SUCCESS;
+                 return true;
              }
          }
          typeBits >>= 1;
      }
      // No memory types matched, return failure
-     return VK_UNSUPPORTED;
+     return false;
 }
 
 static void demo_flush_init_cmd(struct demo *demo)
@@ -879,6 +879,7 @@ static void demo_prepare_depth(struct demo *demo)
 
     VkMemoryRequirements mem_reqs;
     VkResult U_ASSERT_ONLY err;
+    bool U_ASSERT_ONLY pass;
 
     demo->depth.format = depth_format;
 
@@ -896,11 +897,11 @@ static void demo_prepare_depth(struct demo *demo)
     demo->depth.mem_alloc.allocationSize = mem_reqs.size;
     demo->depth.mem_alloc.memoryTypeIndex = 0;
 
-    err = memory_type_from_properties(demo,
+    pass = memory_type_from_properties(demo,
                                       mem_reqs.memoryTypeBits,
                                       0, /* No requirements */
                                       &demo->depth.mem_alloc.memoryTypeIndex);
-    assert(!err);
+    assert(pass);
 
     /* allocate memory */
     err = vkAllocMemory(demo->device, &demo->depth.mem_alloc, &demo->depth.mem);
@@ -976,6 +977,7 @@ static void demo_prepare_texture_image(struct demo *demo,
     int32_t tex_width;
     int32_t tex_height;
     VkResult U_ASSERT_ONLY err;
+    bool U_ASSERT_ONLY pass;
 
     if (!loadTexture(filename, NULL, NULL, &tex_width, &tex_height))
     {
@@ -1014,8 +1016,8 @@ static void demo_prepare_texture_image(struct demo *demo,
     tex_obj->mem_alloc.allocationSize = mem_reqs.size;
     tex_obj->mem_alloc.memoryTypeIndex = 0;
 
-    err = memory_type_from_properties(demo, mem_reqs.memoryTypeBits, required_props, &tex_obj->mem_alloc.memoryTypeIndex);
-    assert(!err);
+    pass = memory_type_from_properties(demo, mem_reqs.memoryTypeBits, required_props, &tex_obj->mem_alloc.memoryTypeIndex);
+    assert(pass);
 
     /* allocate memory */
     err = vkAllocMemory(demo->device, &tex_obj->mem_alloc,
@@ -1179,6 +1181,7 @@ void demo_prepare_cube_data_buffer(struct demo *demo)
     int i;
     mat4x4 MVP, VP;
     VkResult U_ASSERT_ONLY err;
+    bool U_ASSERT_ONLY pass;
     struct vktexcube_vs_uniform data;
 
     mat4x4_mul(VP, demo->projection_matrix, demo->view_matrix);
@@ -1211,11 +1214,11 @@ void demo_prepare_cube_data_buffer(struct demo *demo)
     demo->uniform_data.mem_alloc.allocationSize = mem_reqs.size;
     demo->uniform_data.mem_alloc.memoryTypeIndex = 0;
 
-    err = memory_type_from_properties(demo,
+    pass = memory_type_from_properties(demo,
                                       mem_reqs.memoryTypeBits,
                                       VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                                       &demo->uniform_data.mem_alloc.memoryTypeIndex);
-    assert(!err);
+    assert(pass);
 
     err = vkAllocMemory(demo->device, &demo->uniform_data.mem_alloc, &(demo->uniform_data.mem));
     assert(!err);
index 4f21179..e21b0ad 100644 (file)
@@ -247,7 +247,7 @@ struct demo {
     uint32_t queue_count;
 };
 
-static VkResult memory_type_from_properties(struct demo *demo, uint32_t typeBits, VkFlags requirements_mask, uint32_t *typeIndex)
+static bool memory_type_from_properties(struct demo *demo, uint32_t typeBits, VkFlags requirements_mask, uint32_t *typeIndex)
 {
      // Search memtypes to find first index with those properties
      for (uint32_t i = 0; i < 32; i++) {
@@ -255,13 +255,13 @@ static VkResult memory_type_from_properties(struct demo *demo, uint32_t typeBits
              // Type is available, does it match user properties?
              if ((demo->memory_properties.memoryTypes[i].propertyFlags & requirements_mask) == requirements_mask) {
                  *typeIndex = i;
-                 return VK_SUCCESS;
+                 return true;
              }
          }
          typeBits >>= 1;
      }
      // No memory types matched, return failure
-     return VK_UNSUPPORTED;
+     return false;
 }
 
 static void demo_flush_init_cmd(struct demo *demo)
@@ -693,6 +693,7 @@ static void demo_prepare_depth(struct demo *demo)
 
     VkMemoryRequirements mem_reqs;
     VkResult U_ASSERT_ONLY err;
+    bool U_ASSERT_ONLY pass;
 
     demo->depth.format = depth_format;
 
@@ -707,11 +708,11 @@ static void demo_prepare_depth(struct demo *demo)
 
     /* select memory size and type */
     mem_alloc.allocationSize = mem_reqs.size;
-    err = memory_type_from_properties(demo,
+    pass = memory_type_from_properties(demo,
                                       mem_reqs.memoryTypeBits,
                                       0, /* No requirements */
                                       &mem_alloc.memoryTypeIndex);
-    assert(!err);
+    assert(pass);
 
     /* allocate memory */
     err = vkAllocMemory(demo->device, &mem_alloc, &demo->depth.mem);
@@ -744,6 +745,7 @@ static void demo_prepare_texture_image(struct demo *demo,
     const int32_t tex_width = 2;
     const int32_t tex_height = 2;
     VkResult U_ASSERT_ONLY err;
+    bool U_ASSERT_ONLY pass;
 
     tex_obj->tex_width = tex_width;
     tex_obj->tex_height = tex_height;
@@ -777,8 +779,8 @@ static void demo_prepare_texture_image(struct demo *demo,
     vkGetImageMemoryRequirements(demo->device, tex_obj->image, &mem_reqs);
 
     mem_alloc.allocationSize  = mem_reqs.size;
-    err = memory_type_from_properties(demo, mem_reqs.memoryTypeBits, required_props, &mem_alloc.memoryTypeIndex);
-    assert(!err);
+    pass = memory_type_from_properties(demo, mem_reqs.memoryTypeBits, required_props, &mem_alloc.memoryTypeIndex);
+    assert(pass);
 
     /* allocate memory */
     err = vkAllocMemory(demo->device, &mem_alloc, &tex_obj->mem);
@@ -960,6 +962,7 @@ static void demo_prepare_vertices(struct demo *demo)
     };
     VkMemoryRequirements mem_reqs;
     VkResult U_ASSERT_ONLY err;
+    bool U_ASSERT_ONLY pass;
     void *data;
 
     memset(&demo->vertices, 0, sizeof(demo->vertices));
@@ -972,11 +975,11 @@ static void demo_prepare_vertices(struct demo *demo)
     assert(!err);
 
     mem_alloc.allocationSize  = mem_reqs.size;
-    err = memory_type_from_properties(demo,
+    pass = memory_type_from_properties(demo,
                                       mem_reqs.memoryTypeBits,
                                       VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                                       &mem_alloc.memoryTypeIndex);
-    assert(!err);
+    assert(pass);
 
     err = vkAllocMemory(demo->device, &mem_alloc, &demo->vertices.mem);
     assert(!err);
index 5453c48..a1f1716 100644 (file)
@@ -132,7 +132,6 @@ static const char *vk_result_string(VkResult err)
     switch (err) {
 #define STR(r) case r: return #r
     STR(VK_SUCCESS);
-    STR(VK_UNSUPPORTED);
     STR(VK_NOT_READY);
     STR(VK_TIMEOUT);
     STR(VK_EVENT_SET);
index 5f9a8b9..6bc464e 100644 (file)
@@ -139,12 +139,11 @@ VK_DEFINE_NONDISP_HANDLE(VkCmdPool)
 
 typedef enum {
     VK_SUCCESS = 0,
-    VK_UNSUPPORTED = 1,
-    VK_NOT_READY = 2,
-    VK_TIMEOUT = 3,
-    VK_EVENT_SET = 4,
-    VK_EVENT_RESET = 5,
-    VK_INCOMPLETE = 6,
+    VK_NOT_READY = 1,
+    VK_TIMEOUT = 2,
+    VK_EVENT_SET = 3,
+    VK_EVENT_RESET = 4,
+    VK_INCOMPLETE = 5,
     VK_ERROR_OUT_OF_HOST_MEMORY = -1,
     VK_ERROR_OUT_OF_DEVICE_MEMORY = -2,
     VK_ERROR_INITIALIZATION_FAILED = -3,
index 8ea75ff..b42c013 100644 (file)
@@ -250,11 +250,6 @@ std::string EnumeratorString(VkResult const& enumerator)
             return "VK_EVENT_RESET";
             break;
         }
-        case VK_UNSUPPORTED:
-        {
-            return "VK_UNSUPPORTED";
-            break;
-        }
         case VK_SUCCESS:
         {
             return "VK_SUCCESS";
index ee39d0b..e9ec3eb 100644 (file)
@@ -96,7 +96,7 @@ static vector<int> screenshotFrames;
 // Flag indicating we have queried _VK_SCREENSHOT env var
 static bool screenshotEnvQueried = false;
 
-static VkResult memory_type_from_properties(
+static bool memory_type_from_properties(
     VkPhysicalDeviceMemoryProperties *memory_properties,
     uint32_t typeBits,
     VkFlags requirements_mask,
@@ -108,13 +108,13 @@ static VkResult memory_type_from_properties(
              // Type is available, does it match user properties?
              if ((memory_properties->memoryTypes[i].propertyFlags & requirements_mask) == requirements_mask) {
                  *typeIndex = i;
-                 return VK_SUCCESS;
+                 return true;
              }
          }
          typeBits >>= 1;
      }
      // No memory types matched, return failure
-     return VK_UNSUPPORTED;
+     return false;
 }
 
 static void init_screenshot()
@@ -135,6 +135,7 @@ static void writePPM( const char *filename, VkImage image1)
 {
     VkImage image2;
     VkResult err;
+    bool pass;
     int x, y;
     const char *ptr;
     VkDeviceMemory mem2;
@@ -216,11 +217,11 @@ static void writePPM( const char *filename, VkImage image1)
     pInstanceTable = instance_dispatch_table(instance);
     pInstanceTable->GetPhysicalDeviceMemoryProperties(physicalDevice, &memory_properties);
 
-    err = memory_type_from_properties(&memory_properties,
+    pass = memory_type_from_properties(&memory_properties,
                                 memRequirements.memoryTypeBits,
                                 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
                                 &memAllocInfo.memoryTypeIndex);
-       assert(!err);
+    assert(pass);
 
     err = pTableDevice->AllocMemory(device, &memAllocInfo, &mem2);
     assert(!err);