blob: 888983a01b8237d03ce5e2c1589841ee9a87ddbe [file] [log] [blame]
Dave Houlton59a20702017-02-02 17:26:23 -07001/* Copyright (c) 2015-2017 The Khronos Group Inc.
2 * Copyright (c) 2015-2017 Valve Corporation
3 * Copyright (c) 2015-2017 LunarG, Inc.
Mark Lobodzinski6f2274e2015-09-22 09:33:21 -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
Mark Lobodzinski6f2274e2015-09-22 09:33:21 -06008 *
Jon Ashburn3ebf1252016-04-19 11:30:31 -06009 * http://www.apache.org/licenses/LICENSE-2.0
Mark Lobodzinski6f2274e2015-09-22 09:33:21 -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.
Mark Lobodzinski6f2274e2015-09-22 09:33:21 -060016 *
Jon Ashburne922f712015-11-03 13:41:23 -070017 * Author: Mark Lobodzinski <mark@lunarg.com>
18 * Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
Dave Houlton59a20702017-02-02 17:26:23 -070019 * Author: Dave Houlton <daveh@lunarg.com>
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -070020 */
21
Mark Lobodzinski6f2274e2015-09-22 09:33:21 -060022#pragma once
23#include <stdbool.h>
Mark Lobodzinski1079e1b2016-03-15 14:21:59 -060024#include <vector>
Dave Houlton3c9fca72017-03-27 17:25:54 -060025#include "vk_format_utils.h"
Mark Lobodzinski1079e1b2016-03-15 14:21:59 -060026#include "vk_layer_logging.h"
27
Courtney Goeltzenleuchterd2635502015-10-21 17:08:06 -060028#ifndef WIN32
Mark Lobodzinski64318ba2017-01-26 13:34:13 -070029#include <strings.h> // For ffs()
Courtney Goeltzenleuchter3698c622015-10-27 11:23:21 -060030#else
Mark Lobodzinski64318ba2017-01-26 13:34:13 -070031#include <intrin.h> // For __lzcnt()
Courtney Goeltzenleuchterd2635502015-10-21 17:08:06 -060032#endif
Mark Lobodzinski6f2274e2015-09-22 09:33:21 -060033
34#ifdef __cplusplus
35extern "C" {
36#endif
37
Jon Ashburnd883d812016-03-24 08:32:09 -060038#define VK_LAYER_API_VERSION VK_MAKE_VERSION(1, 0, VK_HEADER_VERSION)
Mark Lobodzinskiadaac9d2016-01-08 11:07:56 -070039
Mark Lobodzinskia9f33492016-01-11 14:17:05 -070040typedef enum VkStringErrorFlagBits {
Jon Ashburn5484e0c2016-03-08 17:48:44 -070041 VK_STRING_ERROR_NONE = 0x00000000,
42 VK_STRING_ERROR_LENGTH = 0x00000001,
43 VK_STRING_ERROR_BAD_DATA = 0x00000002,
Mark Lobodzinskia9f33492016-01-11 14:17:05 -070044} VkStringErrorFlagBits;
45typedef VkFlags VkStringErrorFlags;
Mark Lobodzinski1ed594e2016-02-03 09:57:14 -070046
Mike Stroyana551bc02016-09-28 09:42:28 -060047VK_LAYER_EXPORT void layer_debug_actions(debug_report_data *report_data, std::vector<VkDebugReportCallbackEXT> &logging_callback,
48 const VkAllocationCallbacks *pAllocator, const char *layer_identifier);
Mark Lobodzinski1079e1b2016-03-15 14:21:59 -060049
Mike Stroyana551bc02016-09-28 09:42:28 -060050VK_LAYER_EXPORT VkStringErrorFlags vk_string_validate(const int max_length, const char *char_array);
51VK_LAYER_EXPORT bool white_list(const char *item, const char *whitelist);
Mark Lobodzinski6f2274e2015-09-22 09:33:21 -060052
Jon Ashburn5484e0c2016-03-08 17:48:44 -070053static inline int u_ffs(int val) {
Courtney Goeltzenleuchterd2635502015-10-21 17:08:06 -060054#ifdef WIN32
Mark Lobodzinski5ddf6c32015-12-16 17:47:28 -070055 unsigned long bit_pos = 0;
Mike Stroyandebb9842016-01-07 10:05:21 -070056 if (_BitScanForward(&bit_pos, val) != 0) {
Mark Lobodzinski5ddf6c32015-12-16 17:47:28 -070057 bit_pos += 1;
58 }
59 return bit_pos;
Courtney Goeltzenleuchterd2635502015-10-21 17:08:06 -060060#else
Mark Lobodzinski5ddf6c32015-12-16 17:47:28 -070061 return ffs(val);
Courtney Goeltzenleuchterd2635502015-10-21 17:08:06 -060062#endif
63}
Mark Lobodzinski6f2274e2015-09-22 09:33:21 -060064
65#ifdef __cplusplus
66}
67#endif