1*b7893ccfSSadaf Ebrahimi /* Copyright (c) 2015-2016 The Khronos Group Inc.
2*b7893ccfSSadaf Ebrahimi * Copyright (c) 2015-2016 Valve Corporation
3*b7893ccfSSadaf Ebrahimi * Copyright (c) 2015-2016 LunarG, Inc.
4*b7893ccfSSadaf Ebrahimi *
5*b7893ccfSSadaf Ebrahimi * Licensed under the Apache License, Version 2.0 (the "License");
6*b7893ccfSSadaf Ebrahimi * you may not use this file except in compliance with the License.
7*b7893ccfSSadaf Ebrahimi * You may obtain a copy of the License at
8*b7893ccfSSadaf Ebrahimi *
9*b7893ccfSSadaf Ebrahimi * http://www.apache.org/licenses/LICENSE-2.0
10*b7893ccfSSadaf Ebrahimi *
11*b7893ccfSSadaf Ebrahimi * Unless required by applicable law or agreed to in writing, software
12*b7893ccfSSadaf Ebrahimi * distributed under the License is distributed on an "AS IS" BASIS,
13*b7893ccfSSadaf Ebrahimi * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*b7893ccfSSadaf Ebrahimi * See the License for the specific language governing permissions and
15*b7893ccfSSadaf Ebrahimi * limitations under the License.
16*b7893ccfSSadaf Ebrahimi *
17*b7893ccfSSadaf Ebrahimi * Author: Courtney Goeltzenleuchter <[email protected]>
18*b7893ccfSSadaf Ebrahimi *
19*b7893ccfSSadaf Ebrahimi */
20*b7893ccfSSadaf Ebrahimi
21*b7893ccfSSadaf Ebrahimi #include "string.h"
22*b7893ccfSSadaf Ebrahimi #include "vk_layer_extension_utils.h"
23*b7893ccfSSadaf Ebrahimi
24*b7893ccfSSadaf Ebrahimi #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
25*b7893ccfSSadaf Ebrahimi
26*b7893ccfSSadaf Ebrahimi /*
27*b7893ccfSSadaf Ebrahimi * This file contains utility functions for layers
28*b7893ccfSSadaf Ebrahimi */
29*b7893ccfSSadaf Ebrahimi
util_GetExtensionProperties(const uint32_t count,const VkExtensionProperties * layer_extensions,uint32_t * pCount,VkExtensionProperties * pProperties)30*b7893ccfSSadaf Ebrahimi VK_LAYER_EXPORT VkResult util_GetExtensionProperties(const uint32_t count, const VkExtensionProperties *layer_extensions,
31*b7893ccfSSadaf Ebrahimi uint32_t *pCount, VkExtensionProperties *pProperties) {
32*b7893ccfSSadaf Ebrahimi uint32_t copy_size;
33*b7893ccfSSadaf Ebrahimi
34*b7893ccfSSadaf Ebrahimi if (pProperties == NULL || layer_extensions == NULL) {
35*b7893ccfSSadaf Ebrahimi *pCount = count;
36*b7893ccfSSadaf Ebrahimi return VK_SUCCESS;
37*b7893ccfSSadaf Ebrahimi }
38*b7893ccfSSadaf Ebrahimi
39*b7893ccfSSadaf Ebrahimi copy_size = *pCount < count ? *pCount : count;
40*b7893ccfSSadaf Ebrahimi memcpy(pProperties, layer_extensions, copy_size * sizeof(VkExtensionProperties));
41*b7893ccfSSadaf Ebrahimi *pCount = copy_size;
42*b7893ccfSSadaf Ebrahimi if (copy_size < count) {
43*b7893ccfSSadaf Ebrahimi return VK_INCOMPLETE;
44*b7893ccfSSadaf Ebrahimi }
45*b7893ccfSSadaf Ebrahimi
46*b7893ccfSSadaf Ebrahimi return VK_SUCCESS;
47*b7893ccfSSadaf Ebrahimi }
48*b7893ccfSSadaf Ebrahimi
util_GetLayerProperties(const uint32_t count,const VkLayerProperties * layer_properties,uint32_t * pCount,VkLayerProperties * pProperties)49*b7893ccfSSadaf Ebrahimi VK_LAYER_EXPORT VkResult util_GetLayerProperties(const uint32_t count, const VkLayerProperties *layer_properties, uint32_t *pCount,
50*b7893ccfSSadaf Ebrahimi VkLayerProperties *pProperties) {
51*b7893ccfSSadaf Ebrahimi uint32_t copy_size;
52*b7893ccfSSadaf Ebrahimi
53*b7893ccfSSadaf Ebrahimi if (pProperties == NULL || layer_properties == NULL) {
54*b7893ccfSSadaf Ebrahimi *pCount = count;
55*b7893ccfSSadaf Ebrahimi return VK_SUCCESS;
56*b7893ccfSSadaf Ebrahimi }
57*b7893ccfSSadaf Ebrahimi
58*b7893ccfSSadaf Ebrahimi copy_size = *pCount < count ? *pCount : count;
59*b7893ccfSSadaf Ebrahimi memcpy(pProperties, layer_properties, copy_size * sizeof(VkLayerProperties));
60*b7893ccfSSadaf Ebrahimi *pCount = copy_size;
61*b7893ccfSSadaf Ebrahimi if (copy_size < count) {
62*b7893ccfSSadaf Ebrahimi return VK_INCOMPLETE;
63*b7893ccfSSadaf Ebrahimi }
64*b7893ccfSSadaf Ebrahimi
65*b7893ccfSSadaf Ebrahimi return VK_SUCCESS;
66*b7893ccfSSadaf Ebrahimi }
67