Add implementation for libresoc_CreatePipelineCache().
[mesa.git] / src / libre-soc / vulkan / libresoc_util.c
1 /*
2 * Copyright © 2019 Raspberry Pi
3 *
4 * based in part on anv driver which is:
5 * Copyright © 2015 Intel Corporation
6 *
7 * based in part on radv driver which is:
8 * Copyright © 2016 Red Hat.
9 * Copyright © 2016 Bas Nieuwenhuizen
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice (including the next
19 * paragraph) shall be included in all copies or substantial portions of the
20 * Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
28 * IN THE SOFTWARE.
29 */
30
31 #include <stdarg.h>
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include <errno.h>
36 #include <assert.h>
37
38 #include "vk_enum_to_str.h"
39 #include "libresoc_private.h"
40
41 /** Log an error message. */
42 void libresoc_printflike(1, 2)
43 libresoc_loge(const char *format, ...)
44 {
45 va_list va;
46
47 va_start(va, format);
48 libresoc_loge_v(format, va);
49 va_end(va);
50 }
51
52 /** \see libresoc_loge() */
53 void
54 libresoc_loge_v(const char *format, va_list va)
55 {
56 fprintf(stderr, "vk: error: ");
57 vfprintf(stderr, format, va);
58 fprintf(stderr, "\n");
59 }
60
61 VkResult
62 __vk_errorf(struct libresoc_instance *instance, VkResult error, const char *file,
63 int line, const char *format, ...)
64 {
65 va_list ap;
66 char buffer[256];
67
68 const char *error_str = vk_Result_to_str(error);
69
70 #ifndef DEBUG
71 return error;
72 #endif
73
74 if (format) {
75 va_start(ap, format);
76 vsnprintf(buffer, sizeof(buffer), format, ap);
77 va_end(ap);
78
79 fprintf(stderr, "%s:%d: %s (%s)\n", file, line, buffer, error_str);
80 } else {
81 fprintf(stderr, "%s:%d: %s\n", file, line, error_str);
82 }
83
84 return error;
85 }