/* Copyright (c) 2015-2024 The Khronos Group Inc. * Copyright (c) 2015-2024 Valve Corporation * Copyright (c) 2015-2024 LunarG, Inc. * Copyright (c) 2015-2024 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <atomic> #include <chrono> #include <mutex> #include <string> #include <thread> #include <vector> #include "utils/vk_layer_utils.h" VK_DEFINE_NON_DISPATCHABLE_HANDLE(…) … // The following line must match the vulkan_core.h condition guarding VK_DEFINE_NON_DISPATCHABLE_HANDLE #if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__)) || defined(_M_X64) || defined(__ia64) || \ defined(_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) // If pointers are 64-bit, then there can be separate counters for each // NONDISPATCHABLE_HANDLE type. Otherwise they are all typedef uint64_t. #define DISTINCT_NONDISPATCHABLE_HANDLES // Make sure we catch any disagreement between us and the vulkan definition static_assert …; #else // Make sure we catch any disagreement between us and the vulkan definition static_assert(std::is_same<uint64_t, DISTINCT_NONDISPATCHABLE_PHONY_HANDLE>::value, "Mismatched non-dispatchable handle handle, expected uint64_t."); #endif // Modern CPUs have 64 or 128-byte cache line sizes (Apple M1 has 128-byte cache line size). // Use alignment of 64 bytes (instead of 128) to prioritize using less memory and decrease // cache pressure. inline constexpr size_t kObjectUserDataAlignment = …; static_assert …; // sanity check on the build machine class alignas(kObjectUserDataAlignment) ObjectUseData { … }; template <typename T> class counter { … }; class ThreadSafety : public ValidationObject { … };