summaryrefslogtreecommitdiffstats
path: root/src/vulkan/anv_util.c
diff options
context:
space:
mode:
authorKristian Høgsberg Kristensen <[email protected]>2015-08-26 04:03:38 -0700
committerKristian Høgsberg Kristensen <[email protected]>2015-09-03 11:53:08 -0700
commitc4b30e7885f1d47e57753db49d232669d87a88e5 (patch)
treeda3699b7618cab688392ec8b4e194cf2ad6d14b0 /src/vulkan/anv_util.c
parent2e346c882ddbea68db6dc0b6a05a9e9186624c04 (diff)
vk: Add new vk_errorf that takes a format string
This allows us to annotate error cases in debug builds. Signed-off-by: Kristian Høgsberg Kristensen <[email protected]>
Diffstat (limited to 'src/vulkan/anv_util.c')
-rw-r--r--src/vulkan/anv_util.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/vulkan/anv_util.c b/src/vulkan/anv_util.c
index a78847acec6..94f14f98f8f 100644
--- a/src/vulkan/anv_util.c
+++ b/src/vulkan/anv_util.c
@@ -83,8 +83,11 @@ anv_abortfv(const char *format, va_list va)
}
VkResult
-__vk_error(VkResult error, const char *file, int line)
+__vk_errorf(VkResult error, const char *file, int line, const char *format, ...)
{
+ va_list ap;
+ char buffer[256];
+
static const char *error_names[] = {
"VK_ERROR_UNKNOWN",
"VK_ERROR_UNAVAILABLE",
@@ -120,11 +123,18 @@ __vk_error(VkResult error, const char *file, int line)
"VK_ERROR_INVALID_LAYER",
};
- if (error <= VK_ERROR_UNKNOWN && error >= VK_ERROR_INVALID_LAYER)
- fprintf(stderr, "%s:%d: %s\n",
- file, line, error_names[-error - VK_ERROR_UNKNOWN]);
- else
- fprintf(stderr, "%s:%d: vk error %d\n", file, line, error);
+ assert(error <= VK_ERROR_UNKNOWN && error >= VK_ERROR_INVALID_LAYER);
+
+ if (format) {
+ va_start(ap, format);
+ vsnprintf(buffer, sizeof(buffer), format, ap);
+ va_end(ap);
+
+ fprintf(stderr, "%s:%d: %s (%s)\n", file, line,
+ buffer, error_names[-error - 1]);
+ } else {
+ fprintf(stderr, "%s:%d: %s\n", file, line, error_names[-error - 1]);
+ }
return error;
}