blob: 32d2a9ac83a632053101a2c794f1d2ba15cf291b [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.
Mike Stroyan3712d5c2015-04-02 11:59:05 -06004 *
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -07005 * 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:
Mike Stroyan3712d5c2015-04-02 11:59:05 -060011 *
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -070012 * The above copyright notice(s) and this permission notice shall be included
13 * in all copies or substantial portions of the Materials.
Mike Stroyan3712d5c2015-04-02 11:59:05 -060014 *
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -070015 * 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.
Mike Stroyan3712d5c2015-04-02 11:59:05 -060018 *
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -070019 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Mike Stroyan3712d5c2015-04-02 11:59:05 -060020 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -070021 * 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 Goeltzenleuchter05559522015-10-30 11:14:30 -060027 *
28 * Author: Cody Northrop <cody@lunarg.com>
29 * Author: Mike Stroyan <mike@LunarG.com>
Mike Stroyan3712d5c2015-04-02 11:59:05 -060030 */
Mark Lobodzinski6eda00a2016-02-02 15:55:36 -070031
Mike Stroyan313f7e62015-08-10 16:42:53 -060032#ifndef THREADING_H
33#define THREADING_H
34#include "vk_layer_config.h"
35#include "vk_layer_logging.h"
Mike Stroyan3712d5c2015-04-02 11:59:05 -060036
37// Draw State ERROR codes
38typedef enum _THREADING_CHECKER_ERROR
39{
40 THREADING_CHECKER_NONE, // Used for INFO & other non-error messages
41 THREADING_CHECKER_MULTIPLE_THREADS, // Object used simultaneously by multiple threads
42 THREADING_CHECKER_SINGLE_THREAD_REUSE, // Object used simultaneously by recursion in single thread
43} THREADING_CHECKER_ERROR;
44
Cody Northrop55443ef2015-09-28 15:09:32 -060045struct layer_data {
Mike Stroyan313f7e62015-08-10 16:42:53 -060046 debug_report_data *report_data;
Courtney Goeltzenleuchter7415d5a2015-12-09 15:48:16 -070047 VkDebugReportCallbackEXT logging_callback;
Cody Northrop55443ef2015-09-28 15:09:32 -060048
49 layer_data() :
50 report_data(nullptr),
Michael Lentine13803dc2015-11-04 14:35:12 -080051 logging_callback(VK_NULL_HANDLE)
Cody Northrop55443ef2015-09-28 15:09:32 -060052 {};
53};
Mike Stroyan313f7e62015-08-10 16:42:53 -060054
55static std::unordered_map<void*, layer_data *> layer_data_map;
Mark Lobodzinski0d054fe2015-12-30 08:16:12 -070056static device_table_map threading_device_table_map;
57static instance_table_map threading_instance_table_map;
Mike Stroyan313f7e62015-08-10 16:42:53 -060058
59static inline debug_report_data *mdd(const void* object)
60{
61 dispatch_key key = get_dispatch_key(object);
62 layer_data *my_data = get_my_data_ptr(key, layer_data_map);
63 return my_data->report_data;
64}
65#endif // THREADING_H