blob: 4c1e39636bea8df40a0534d7ba39b2328c94f709 [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 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -06005 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -06008 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -06009 * http://www.apache.org/licenses/LICENSE-2.0
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060010 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -060011 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060016 *
Courtney Goeltzenleuchter05559522015-10-30 11:14:30 -060017 * Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
18 *
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060019 */
20
21#include "string.h"
22#include "vk_layer_extension_utils.h"
23
Courtney Goeltzenleuchter58e1e3b2015-07-06 22:29:41 -060024#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
25
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060026/*
27 * This file contains utility functions for layers
28 */
29
Karl Schultz97dc68d2016-11-03 12:31:41 -060030VK_LAYER_EXPORT VkResult util_GetExtensionProperties(const uint32_t count, const VkExtensionProperties *layer_extensions,
31 uint32_t *pCount, VkExtensionProperties *pProperties) {
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060032 uint32_t copy_size;
33
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060034 if (pProperties == NULL || layer_extensions == NULL) {
35 *pCount = count;
36 return VK_SUCCESS;
37 }
38
39 copy_size = *pCount < count ? *pCount : count;
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -070040 memcpy(pProperties, layer_extensions, copy_size * sizeof(VkExtensionProperties));
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060041 *pCount = copy_size;
42 if (copy_size < count) {
43 return VK_INCOMPLETE;
44 }
45
46 return VK_SUCCESS;
47}
48
Karl Schultz97dc68d2016-11-03 12:31:41 -060049VK_LAYER_EXPORT VkResult util_GetLayerProperties(const uint32_t count, const VkLayerProperties *layer_properties, uint32_t *pCount,
50 VkLayerProperties *pProperties) {
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060051 uint32_t copy_size;
52
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060053 if (pProperties == NULL || layer_properties == NULL) {
54 *pCount = count;
55 return VK_SUCCESS;
56 }
57
58 copy_size = *pCount < count ? *pCount : count;
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -070059 memcpy(pProperties, layer_properties, copy_size * sizeof(VkLayerProperties));
Courtney Goeltzenleuchter110fdf92015-06-29 15:39:26 -060060 *pCount = copy_size;
61 if (copy_size < count) {
62 return VK_INCOMPLETE;
63 }
64
65 return VK_SUCCESS;
66}