Path: blob/21.2-virgl/src/panfrost/vulkan/panvk_util.c
4560 views
/*1* Copyright © 2015 Collabora Ltd.2*3* Derived from tu_util.c which is:4* Copyright © 2015 Intel Corporation5*6* Permission is hereby granted, free of charge, to any person obtaining a7* copy of this software and associated documentation files (the "Software"),8* to deal in the Software without restriction, including without limitation9* the rights to use, copy, modify, merge, publish, distribute, sublicense,10* and/or sell copies of the Software, and to permit persons to whom the11* Software is furnished to do so, subject to the following conditions:12*13* The above copyright notice and this permission notice (including the next14* paragraph) shall be included in all copies or substantial portions of the15* Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR18* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,19* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL20* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER21* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING22* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER23* DEALINGS IN THE SOFTWARE.24*/2526#include "panvk_private.h"2728#include <assert.h>29#include <errno.h>30#include <stdarg.h>31#include <stdio.h>32#include <stdlib.h>33#include <string.h>3435#include "util/u_math.h"36#include "vk_enum_to_str.h"3738/** Log an error message. */39void panvk_printflike(1, 2)40panvk_logi(const char *format, ...)41{42va_list va;4344va_start(va, format);45panvk_logi_v(format, va);46va_end(va);47}4849/** \see panvk_logi() */50void51panvk_logi_v(const char *format, va_list va)52{53fprintf(stderr, "tu: info: ");54vfprintf(stderr, format, va);55fprintf(stderr, "\n");56}5758VkResult59__vk_errorf(struct panvk_instance *instance,60VkResult error,61const char *file,62int line,63const char *format,64...)65{66va_list ap;67char buffer[256];6869const char *error_str = vk_Result_to_str(error);7071#ifndef DEBUG72return error;73#endif7475if (format) {76va_start(ap, format);77vsnprintf(buffer, sizeof(buffer), format, ap);78va_end(ap);7980fprintf(stderr, "%s:%d: %s (%s)\n", file, line, buffer, error_str);81} else {82fprintf(stderr, "%s:%d: %s\n", file, line, error_str);83}8485return error;86}878889