blob: a6fd8695f7e0feb79d85dfede6349534a67bda14 [file] [log] [blame]
Mike Stroyan3712d5c2015-04-02 11:59:05 -06001/*
Mike Stroyan3712d5c2015-04-02 11:59:05 -06002 *
Courtney Goeltzenleuchterfcbe16f2015-10-29 13:50:34 -06003 * Copyright (C) 2015 Valve Corporation
Mike Stroyan3712d5c2015-04-02 11:59:05 -06004 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
Courtney Goeltzenleuchter05559522015-10-30 11:14:30 -060022 *
23 * Author: Cody Northrop <cody@lunarg.com>
24 * Author: Mike Stroyan <mike@LunarG.com>
Mike Stroyan3712d5c2015-04-02 11:59:05 -060025 */
Mike Stroyan313f7e62015-08-10 16:42:53 -060026#ifndef THREADING_H
27#define THREADING_H
28#include "vk_layer_config.h"
29#include "vk_layer_logging.h"
Mike Stroyan3712d5c2015-04-02 11:59:05 -060030
31// Draw State ERROR codes
32typedef enum _THREADING_CHECKER_ERROR
33{
34 THREADING_CHECKER_NONE, // Used for INFO & other non-error messages
35 THREADING_CHECKER_MULTIPLE_THREADS, // Object used simultaneously by multiple threads
36 THREADING_CHECKER_SINGLE_THREAD_REUSE, // Object used simultaneously by recursion in single thread
37} THREADING_CHECKER_ERROR;
38
Cody Northrop55443ef2015-09-28 15:09:32 -060039struct layer_data {
Mike Stroyan313f7e62015-08-10 16:42:53 -060040 debug_report_data *report_data;
41 VkDbgMsgCallback logging_callback;
Cody Northrop55443ef2015-09-28 15:09:32 -060042
43 layer_data() :
44 report_data(nullptr),
45 logging_callback(nullptr)
46 {};
47};
Mike Stroyan313f7e62015-08-10 16:42:53 -060048
49static std::unordered_map<void*, layer_data *> layer_data_map;
50static device_table_map Threading_device_table_map;
51static instance_table_map Threading_instance_table_map;
52
53static inline debug_report_data *mdd(const void* object)
54{
55 dispatch_key key = get_dispatch_key(object);
56 layer_data *my_data = get_my_data_ptr(key, layer_data_map);
57 return my_data->report_data;
58}
59#endif // THREADING_H