if (!display)
return VK_ERROR_OUT_OF_HOST_MEMORY;
- uint32_t count = u_vector_length(&display->formats);
-
if (pSurfaceFormats == NULL) {
- *pSurfaceFormatCount = count;
+ *pSurfaceFormatCount = u_vector_length(&display->formats);
return VK_SUCCESS;
}
- assert(*pSurfaceFormatCount >= count);
- *pSurfaceFormatCount = count;
-
+ uint32_t count = 0;
VkFormat *f;
u_vector_foreach(f, &display->formats) {
- *(pSurfaceFormats++) = (VkSurfaceFormatKHR) {
+ if (count == *pSurfaceFormatCount)
+ return VK_INCOMPLETE;
+
+ pSurfaceFormats[count++] = (VkSurfaceFormatKHR) {
.format = *f,
/* TODO: We should get this from the compositor somehow */
.colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR,
};
}
+ assert(*pSurfaceFormatCount <= count);
+ *pSurfaceFormatCount = count;
+
return VK_SUCCESS;
}