Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2015-2016 The Khronos Group Inc. |
| 2 | * Copyright (c) 2015-2016 Valve Corporation |
| 3 | * Copyright (c) 2015-2016 LunarG, Inc. |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 4 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 5 | * 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 Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 8 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 10 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 11 | * 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 Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 16 | * |
Courtney Goeltzenleuchter | 0555952 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 17 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 18 | * |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #include "string.h" |
| 22 | #include "vk_layer_extension_utils.h" |
| 23 | |
Courtney Goeltzenleuchter | 58e1e3b | 2015-07-06 22:29:41 -0600 | [diff] [blame] | 24 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) |
| 25 | |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 26 | /* |
| 27 | * This file contains utility functions for layers |
| 28 | */ |
| 29 | |
Karl Schultz | 97dc68d | 2016-11-03 12:31:41 -0600 | [diff] [blame] | 30 | VK_LAYER_EXPORT VkResult util_GetExtensionProperties(const uint32_t count, const VkExtensionProperties *layer_extensions, |
| 31 | uint32_t *pCount, VkExtensionProperties *pProperties) { |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 32 | uint32_t copy_size; |
| 33 | |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 34 | if (pProperties == NULL || layer_extensions == NULL) { |
| 35 | *pCount = count; |
| 36 | return VK_SUCCESS; |
| 37 | } |
| 38 | |
| 39 | copy_size = *pCount < count ? *pCount : count; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 40 | memcpy(pProperties, layer_extensions, copy_size * sizeof(VkExtensionProperties)); |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 41 | *pCount = copy_size; |
| 42 | if (copy_size < count) { |
| 43 | return VK_INCOMPLETE; |
| 44 | } |
| 45 | |
| 46 | return VK_SUCCESS; |
| 47 | } |
| 48 | |
Karl Schultz | 97dc68d | 2016-11-03 12:31:41 -0600 | [diff] [blame] | 49 | VK_LAYER_EXPORT VkResult util_GetLayerProperties(const uint32_t count, const VkLayerProperties *layer_properties, uint32_t *pCount, |
| 50 | VkLayerProperties *pProperties) { |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 51 | uint32_t copy_size; |
| 52 | |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 53 | if (pProperties == NULL || layer_properties == NULL) { |
| 54 | *pCount = count; |
| 55 | return VK_SUCCESS; |
| 56 | } |
| 57 | |
| 58 | copy_size = *pCount < count ? *pCount : count; |
Mark Lobodzinski | 1ed594e | 2016-02-03 09:57:14 -0700 | [diff] [blame] | 59 | memcpy(pProperties, layer_properties, copy_size * sizeof(VkLayerProperties)); |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 60 | *pCount = copy_size; |
| 61 | if (copy_size < count) { |
| 62 | return VK_INCOMPLETE; |
| 63 | } |
| 64 | |
| 65 | return VK_SUCCESS; |
| 66 | } |