15db71995Sopenharmony_ci/*
25db71995Sopenharmony_ci *
35db71995Sopenharmony_ci * Copyright (c) 2014-2021 The Khronos Group Inc.
45db71995Sopenharmony_ci * Copyright (c) 2014-2021 Valve Corporation
55db71995Sopenharmony_ci * Copyright (c) 2014-2021 LunarG, Inc.
65db71995Sopenharmony_ci *
75db71995Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
85db71995Sopenharmony_ci * you may not use this file except in compliance with the License.
95db71995Sopenharmony_ci * You may obtain a copy of the License at
105db71995Sopenharmony_ci *
115db71995Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
125db71995Sopenharmony_ci *
135db71995Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
145db71995Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
155db71995Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
165db71995Sopenharmony_ci * See the License for the specific language governing permissions and
175db71995Sopenharmony_ci * limitations under the License.
185db71995Sopenharmony_ci *
195db71995Sopenharmony_ci * Author: Jon Ashburn <jon@lunarg.com>
205db71995Sopenharmony_ci * Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
215db71995Sopenharmony_ci * Author: Chia-I Wu <olvaffe@gmail.com>
225db71995Sopenharmony_ci * Author: Chia-I Wu <olv@lunarg.com>
235db71995Sopenharmony_ci * Author: Mark Lobodzinski <mark@LunarG.com>
245db71995Sopenharmony_ci * Author: Lenny Komow <lenny@lunarg.com>
255db71995Sopenharmony_ci * Author: Charles Giessen <charles@lunarg.com>
265db71995Sopenharmony_ci *
275db71995Sopenharmony_ci */
285db71995Sopenharmony_ci
295db71995Sopenharmony_ci#pragma once
305db71995Sopenharmony_ci
315db71995Sopenharmony_ci#include <stdint.h>
325db71995Sopenharmony_ci#include <stdbool.h>
335db71995Sopenharmony_ci
345db71995Sopenharmony_ci#include "vulkan/vulkan_core.h"
355db71995Sopenharmony_ci
365db71995Sopenharmony_cistruct loader_instance;
375db71995Sopenharmony_ci
385db71995Sopenharmony_cienum vulkan_loader_debug_flags {
395db71995Sopenharmony_ci    VULKAN_LOADER_INFO_BIT = 0x01,
405db71995Sopenharmony_ci    VULKAN_LOADER_WARN_BIT = 0x02,
415db71995Sopenharmony_ci    VULKAN_LOADER_PERF_BIT = 0x04,
425db71995Sopenharmony_ci    VULKAN_LOADER_ERROR_BIT = 0x08,
435db71995Sopenharmony_ci    VULKAN_LOADER_DEBUG_BIT = 0x10,
445db71995Sopenharmony_ci    VULKAN_LOADER_LAYER_BIT = 0x20,
455db71995Sopenharmony_ci    VULKAN_LOADER_DRIVER_BIT = 0x40,
465db71995Sopenharmony_ci    VULKAN_LOADER_VALIDATION_BIT = 0x80,
475db71995Sopenharmony_ci    VULKAN_LOADER_FATAL_ERROR_BIT = 0x100,  // only forces the output to be printed to stderr, has no other effect
485db71995Sopenharmony_ci};
495db71995Sopenharmony_ci
505db71995Sopenharmony_ci// Checks for the environment variable VK_LOADER_DEBUG and sets up the current debug level accordingly
515db71995Sopenharmony_ci// This should be called before any Vulkan API calls, eg in the initialization of the .dll or .so
525db71995Sopenharmony_civoid loader_init_global_debug_level(void);
535db71995Sopenharmony_ci
545db71995Sopenharmony_ci// Sets the global debug level - used by global settings files
555db71995Sopenharmony_civoid loader_set_global_debug_level(uint32_t new_loader_debug);
565db71995Sopenharmony_ci
575db71995Sopenharmony_ci// The asm declaration prevents name mangling which is necessary for macOS
585db71995Sopenharmony_ci#if defined(MODIFY_UNKNOWN_FUNCTION_DECLS)
595db71995Sopenharmony_ci#define ASM_NAME(name) __asm(name)
605db71995Sopenharmony_ci#else
615db71995Sopenharmony_ci#define ASM_NAME(name)
625db71995Sopenharmony_ci#endif
635db71995Sopenharmony_ci
645db71995Sopenharmony_ci// Logs a message to stderr
655db71995Sopenharmony_ci// May output to DebugUtils if the instance isn't null and the extension is enabled.
665db71995Sopenharmony_civoid loader_log(const struct loader_instance *inst, VkFlags msg_type, int32_t msg_code, const char *format, ...)
675db71995Sopenharmony_ci    ASM_NAME("loader_log");
685db71995Sopenharmony_ci
695db71995Sopenharmony_ci// Used for the assembly code to emit an specific error message
705db71995Sopenharmony_ci// This is a work around for linux 32 bit error handling not passing relocatable strings correctly
715db71995Sopenharmony_civoid loader_log_asm_function_not_supported(const struct loader_instance *inst, VkFlags msg_type, int32_t msg_code,
725db71995Sopenharmony_ci                                           const char *func_name) ASM_NAME("loader_log_asm_function_not_supported");
735db71995Sopenharmony_ci
745db71995Sopenharmony_ci#undef ASM_NAME
75