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 | * |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 5 | * 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 Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 11 | * |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 12 | * The above copyright notice(s) and this permission notice shall be included |
| 13 | * in all copies or substantial portions of the Materials. |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 14 | * |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 15 | * 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 Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 18 | * |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 19 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
Mark Lobodzinski | 6eda00a | 2016-02-02 15:55:36 -0700 | [diff] [blame] | 21 | * 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 Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 27 | * |
Courtney Goeltzenleuchter | 0555952 | 2015-10-30 11:14:30 -0600 | [diff] [blame] | 28 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 29 | * |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 30 | */ |
| 31 | |
| 32 | #include "string.h" |
| 33 | #include "vk_layer_extension_utils.h" |
| 34 | |
Courtney Goeltzenleuchter | 58e1e3b | 2015-07-06 22:29:41 -0600 | [diff] [blame] | 35 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) |
| 36 | |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 37 | /* |
| 38 | * This file contains utility functions for layers |
| 39 | */ |
| 40 | |
| 41 | VkResult util_GetExtensionProperties( |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 42 | const uint32_t count, const VkExtensionProperties *layer_extensions, |
| 43 | uint32_t *pCount, VkExtensionProperties *pProperties) { |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 44 | uint32_t copy_size; |
| 45 | |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 46 | if (pProperties == NULL || layer_extensions == NULL) { |
| 47 | *pCount = count; |
| 48 | return VK_SUCCESS; |
| 49 | } |
| 50 | |
| 51 | copy_size = *pCount < count ? *pCount : count; |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 52 | memcpy(pProperties, layer_extensions, |
| 53 | copy_size * sizeof(VkExtensionProperties)); |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 54 | *pCount = copy_size; |
| 55 | if (copy_size < count) { |
| 56 | return VK_INCOMPLETE; |
| 57 | } |
| 58 | |
| 59 | return VK_SUCCESS; |
| 60 | } |
| 61 | |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 62 | VkResult util_GetLayerProperties(const uint32_t count, |
| 63 | const VkLayerProperties *layer_properties, |
| 64 | uint32_t *pCount, |
| 65 | VkLayerProperties *pProperties) { |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 66 | uint32_t copy_size; |
| 67 | |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 68 | if (pProperties == NULL || layer_properties == NULL) { |
| 69 | *pCount = count; |
| 70 | return VK_SUCCESS; |
| 71 | } |
| 72 | |
| 73 | copy_size = *pCount < count ? *pCount : count; |
Mark Lobodzinski | b39d9e6 | 2016-02-02 17:06:29 -0700 | [diff] [blame] | 74 | memcpy(pProperties, layer_properties, |
| 75 | copy_size * sizeof(VkLayerProperties)); |
Courtney Goeltzenleuchter | 110fdf9 | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 76 | *pCount = copy_size; |
| 77 | if (copy_size < count) { |
| 78 | return VK_INCOMPLETE; |
| 79 | } |
| 80 | |
| 81 | return VK_SUCCESS; |
| 82 | } |