blob: 748aa99d41af0d47046731e3a402e10257edb8e0 [file] [log] [blame]
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -07001/* Copyright (c) 2015-2016 The Khronos Group Inc.
2 * Copyright (c) 2015-2016 Valve Corporation
3 * Copyright (c) 2015-2016 LunarG, Inc.
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -06004 *
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -07005 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and/or associated documentation files (the "Materials"), to
7 * deal in the Materials without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Materials, and to permit persons to whom the Materials
10 * are furnished to do so, subject to the following conditions:
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060011 *
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -070012 * The above copyright notice(s) and this permission notice shall be included
13 * in all copies or substantial portions of the Materials.
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060014 *
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -070015 * The Materials are Confidential Information as defined by the Khronos
16 * Membership Agreement until designated non-confidential by Khronos, at which
17 * point this condition clause shall be removed.
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060018 *
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -070019 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060020 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -070021 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 *
23 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
24 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE
26 * USE OR OTHER DEALINGS IN THE MATERIALS
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060027 *
Courtney Goeltzenleuchter05559522015-10-30 11:14:30 -060028 * Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
29 *
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060030 */
31
32#include "string.h"
33#include "vk_layer_extension_utils.h"
34
Courtney Goeltzenleuchter58e1e3b2015-07-06 22:29:41 -060035#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
36
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060037/*
38 * This file contains utility functions for layers
39 */
40
41VkResult util_GetExtensionProperties(
42 const uint32_t count,
43 const VkExtensionProperties *layer_extensions,
44 uint32_t* pCount,
45 VkExtensionProperties* pProperties)
46{
47 uint32_t copy_size;
48
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060049 if (pProperties == NULL || layer_extensions == NULL) {
50 *pCount = count;
51 return VK_SUCCESS;
52 }
53
54 copy_size = *pCount < count ? *pCount : count;
55 memcpy(pProperties, layer_extensions, copy_size * sizeof(VkExtensionProperties));
56 *pCount = copy_size;
57 if (copy_size < count) {
58 return VK_INCOMPLETE;
59 }
60
61 return VK_SUCCESS;
62}
63
64VkResult util_GetLayerProperties(
65 const uint32_t count,
66 const VkLayerProperties *layer_properties,
67 uint32_t* pCount,
68 VkLayerProperties* pProperties)
69{
70 uint32_t copy_size;
71
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060072 if (pProperties == NULL || layer_properties == NULL) {
73 *pCount = count;
74 return VK_SUCCESS;
75 }
76
77 copy_size = *pCount < count ? *pCount : count;
78 memcpy(pProperties, layer_properties, copy_size * sizeof(VkLayerProperties));
79 *pCount = copy_size;
80 if (copy_size < count) {
81 return VK_INCOMPLETE;
82 }
83
84 return VK_SUCCESS;
85}