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