blob: 71c3cba07aab714a2361232c1e045a78597704ee [file] [log] [blame]
Courtney Goeltzenleuchter18061cd2015-06-29 15:39:26 -06001/*
2 * Vulkan
3 *
4 * Copyright (C) 2015 LunarG, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Courtney Goeltzenleuchter <courtney@lunarg.com>
26 */
27
28#include "string.h"
29#include "vk_layer_extension_utils.h"
30
31/*
32 * This file contains utility functions for layers
33 */
34
35VkResult util_GetExtensionProperties(
36 const uint32_t count,
37 const VkExtensionProperties *layer_extensions,
38 uint32_t* pCount,
39 VkExtensionProperties* pProperties)
40{
41 uint32_t copy_size;
42
43 if (pCount == NULL) {
44 return VK_ERROR_INVALID_POINTER;
45 }
46
47 if (pProperties == NULL || layer_extensions == NULL) {
48 *pCount = count;
49 return VK_SUCCESS;
50 }
51
52 copy_size = *pCount < count ? *pCount : count;
53 memcpy(pProperties, layer_extensions, copy_size * sizeof(VkExtensionProperties));
54 *pCount = copy_size;
55 if (copy_size < count) {
56 return VK_INCOMPLETE;
57 }
58
59 return VK_SUCCESS;
60}
61
62VkResult util_GetLayerProperties(
63 const uint32_t count,
64 const VkLayerProperties *layer_properties,
65 uint32_t* pCount,
66 VkLayerProperties* pProperties)
67{
68 uint32_t copy_size;
69
70 if (pCount == NULL) {
71 return VK_ERROR_INVALID_POINTER;
72 }
73
74 if (pProperties == NULL || layer_properties == NULL) {
75 *pCount = count;
76 return VK_SUCCESS;
77 }
78
79 copy_size = *pCount < count ? *pCount : count;
80 memcpy(pProperties, layer_properties, copy_size * sizeof(VkLayerProperties));
81 *pCount = copy_size;
82 if (copy_size < count) {
83 return VK_INCOMPLETE;
84 }
85
86 return VK_SUCCESS;
87}