Path: blob/21.2-virgl/src/broadcom/vulkan/v3dv_util.c
4560 views
/*1* Copyright © 2019 Raspberry Pi2*3* based in part on anv driver which is:4* Copyright © 2015 Intel Corporation5*6* based in part on radv driver which is:7* Copyright © 2016 Red Hat.8* Copyright © 2016 Bas Nieuwenhuizen9*10* Permission is hereby granted, free of charge, to any person obtaining a11* copy of this software and associated documentation files (the "Software"),12* to deal in the Software without restriction, including without limitation13* the rights to use, copy, modify, merge, publish, distribute, sublicense,14* and/or sell copies of the Software, and to permit persons to whom the15* Software is furnished to do so, subject to the following conditions:16*17* The above copyright notice and this permission notice (including the next18* paragraph) shall be included in all copies or substantial portions of the19* Software.20*21* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR22* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,23* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL24* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER25* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING26* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS27* IN THE SOFTWARE.28*/2930#include <stdarg.h>31#include <stdio.h>32#include <stdlib.h>33#include <string.h>34#include <errno.h>35#include <assert.h>3637#include "vk_enum_to_str.h"38#include "v3dv_private.h"3940VkResult41__vk_errorf(struct v3dv_instance *instance, VkResult error, const char *file,42int line, const char *format, ...)43{44va_list ap;45char buffer[256];4647#ifndef DEBUG48return error;49#endif5051const char *error_str = vk_Result_to_str(error);5253if (format) {54va_start(ap, format);55vsnprintf(buffer, sizeof(buffer), format, ap);56va_end(ap);5758fprintf(stderr, "%s:%d: %s (%s)\n", file, line, buffer, error_str);59} else {60fprintf(stderr, "%s:%d: %s\n", file, line, error_str);61}6263return error;64}656667