Debugging: Merge VkDebug into System/Debug
Delete Vulkan/VkDebug.hpp and Vulkan/VkDebug.cpp, use System/Debug.hpp from now on.
Also delete System/DebugAndroid.hpp and System/DebugAndroid.cpp.
These declared yet another version of the debug macros, along with the
AndroidEnterDebugger() function. None of this stuff is actually used
for the Android platform builds, and this change brings in logcat support
to the standard set of macros.
Bug: b/146051794
Change-Id: Ib52ec6af34cdf4ac390c73cb331239d81bed6e06
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/40968
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
diff --git a/src/Android.bp b/src/Android.bp
index e591ba4..f79220b 100644
--- a/src/Android.bp
+++ b/src/Android.bp
@@ -113,18 +113,18 @@
],
srcs: [
- "Common/CPUID.cpp",
"Common/Configurator.cpp",
+ "Common/CPUID.cpp",
"Common/DebugAndroid.cpp",
"Common/GrallocAndroid.cpp",
"Common/Half.cpp",
"Common/Math.cpp",
"Common/Memory.cpp",
"Common/Resource.cpp",
+ "Common/SharedLibrary.cpp",
"Common/Socket.cpp",
"Common/Thread.cpp",
"Common/Timer.cpp",
- "Common/SharedLibrary.cpp",
"Main/Config.cpp",
"Main/FrameBuffer.cpp",
"Main/FrameBufferAndroid.cpp",
@@ -177,6 +177,10 @@
defaults: [ "libswiftshader_common_defaults" ],
+ header_libs: [
+ "swiftshader_platform_headers",
+ ],
+
srcs: [
"Reactor/Reactor.cpp",
"Reactor/LLVMJIT.cpp",
@@ -194,11 +198,19 @@
static_libs: [
"libLLVM7_swiftshader",
],
+
+ shared_libs: [
+ "liblog",
+ ],
}
cc_defaults {
name: "libswiftshadervk_llvm_defaults",
+ header_libs: [
+ "swiftshader_platform_headers",
+ ],
+
srcs: [
"Reactor/Reactor.cpp",
"Reactor/LLVMJIT.cpp",
@@ -219,6 +231,7 @@
shared_libs: [
"libcutils",
+ "liblog",
],
}
@@ -578,16 +591,16 @@
srcs: [
"System/Build.cpp",
- "System/CPUID.cpp",
"System/Configurator.cpp",
+ "System/CPUID.cpp",
+ "System/Debug.cpp",
+ "System/GrallocAndroid.cpp",
"System/Half.cpp",
"System/Linux/MemFd.cpp",
"System/Math.cpp",
"System/Memory.cpp",
"System/Socket.cpp",
"System/Timer.cpp",
- "System/DebugAndroid.cpp",
- "System/GrallocAndroid.cpp",
"Device/*.cpp",
"Pipeline/*.cpp",
"Vulkan/*.cpp",
diff --git a/src/Device/Blitter.cpp b/src/Device/Blitter.cpp
index 611df31..f85c524 100644
--- a/src/Device/Blitter.cpp
+++ b/src/Device/Blitter.cpp
@@ -16,10 +16,10 @@
#include "Pipeline/ShaderCore.hpp"
#include "Reactor/Reactor.hpp"
+#include "System/Debug.hpp"
#include "System/Half.hpp"
#include "System/Memory.hpp"
#include "Vulkan/VkBuffer.hpp"
-#include "Vulkan/VkDebug.hpp"
#include "Vulkan/VkImage.hpp"
#include <utility>
diff --git a/src/Device/Context.cpp b/src/Device/Context.cpp
index 1303e4c..da0e2c4 100644
--- a/src/Device/Context.cpp
+++ b/src/Device/Context.cpp
@@ -16,8 +16,8 @@
#include "Primitive.hpp"
#include "Pipeline/SpirvShader.hpp"
+#include "System/Debug.hpp"
#include "System/Memory.hpp"
-#include "Vulkan/VkDebug.hpp"
#include "Vulkan/VkImageView.hpp"
#include <string.h>
diff --git a/src/Device/PixelProcessor.cpp b/src/Device/PixelProcessor.cpp
index d8d407d..b24d2d3 100644
--- a/src/Device/PixelProcessor.cpp
+++ b/src/Device/PixelProcessor.cpp
@@ -17,7 +17,7 @@
#include "Primitive.hpp"
#include "Pipeline/Constants.hpp"
#include "Pipeline/PixelProgram.hpp"
-#include "Vulkan/VkDebug.hpp"
+#include "System/Debug.hpp"
#include "Vulkan/VkImageView.hpp"
#include <cstring>
diff --git a/src/Device/QuadRasterizer.cpp b/src/Device/QuadRasterizer.cpp
index edda271..389b81a 100644
--- a/src/Device/QuadRasterizer.cpp
+++ b/src/Device/QuadRasterizer.cpp
@@ -17,8 +17,8 @@
#include "Primitive.hpp"
#include "Renderer.hpp"
#include "Pipeline/Constants.hpp"
+#include "System/Debug.hpp"
#include "System/Math.hpp"
-#include "Vulkan/VkDebug.hpp"
namespace sw {
diff --git a/src/Device/Renderer.cpp b/src/Device/Renderer.cpp
index a29e3ea..393f317 100644
--- a/src/Device/Renderer.cpp
+++ b/src/Device/Renderer.cpp
@@ -21,12 +21,12 @@
#include "Pipeline/Constants.hpp"
#include "Pipeline/SpirvShader.hpp"
#include "Reactor/Reactor.hpp"
+#include "System/Debug.hpp"
#include "System/Half.hpp"
#include "System/Math.hpp"
#include "System/Memory.hpp"
#include "System/Timer.hpp"
#include "Vulkan/VkConfig.h"
-#include "Vulkan/VkDebug.hpp"
#include "Vulkan/VkDevice.hpp"
#include "Vulkan/VkFence.hpp"
#include "Vulkan/VkImageView.hpp"
diff --git a/src/Device/SetupProcessor.cpp b/src/Device/SetupProcessor.cpp
index 030343d..9a9a15f 100644
--- a/src/Device/SetupProcessor.cpp
+++ b/src/Device/SetupProcessor.cpp
@@ -21,7 +21,7 @@
#include "Pipeline/Constants.hpp"
#include "Pipeline/SetupRoutine.hpp"
#include "Pipeline/SpirvShader.hpp"
-#include "Vulkan/VkDebug.hpp"
+#include "System/Debug.hpp"
#include <cstring>
diff --git a/src/Device/VertexProcessor.cpp b/src/Device/VertexProcessor.cpp
index 88359a2..c7f4d54 100644
--- a/src/Device/VertexProcessor.cpp
+++ b/src/Device/VertexProcessor.cpp
@@ -16,8 +16,8 @@
#include "Pipeline/Constants.hpp"
#include "Pipeline/VertexProgram.hpp"
+#include "System/Debug.hpp"
#include "System/Math.hpp"
-#include "Vulkan/VkDebug.hpp"
#include <cstring>
diff --git a/src/Pipeline/ComputeProgram.cpp b/src/Pipeline/ComputeProgram.cpp
index 26d42d5..2f58f0e 100644
--- a/src/Pipeline/ComputeProgram.cpp
+++ b/src/Pipeline/ComputeProgram.cpp
@@ -15,7 +15,7 @@
#include "ComputeProgram.hpp"
#include "Constants.hpp"
-#include "Vulkan/VkDebug.hpp"
+#include "System/Debug.hpp"
#include "Vulkan/VkPipelineLayout.hpp"
#include "marl/defer.h"
diff --git a/src/Pipeline/PixelRoutine.cpp b/src/Pipeline/PixelRoutine.cpp
index dc91691..6a46978 100644
--- a/src/Pipeline/PixelRoutine.cpp
+++ b/src/Pipeline/PixelRoutine.cpp
@@ -19,7 +19,7 @@
#include "Device/Primitive.hpp"
#include "Device/QuadRasterizer.hpp"
#include "Device/Renderer.hpp"
-#include "Vulkan/VkDebug.hpp"
+#include "System/Debug.hpp"
#include "Vulkan/VkPipelineLayout.hpp"
namespace sw {
diff --git a/src/Pipeline/SamplerCore.cpp b/src/Pipeline/SamplerCore.cpp
index ae8e787..dfffa87 100644
--- a/src/Pipeline/SamplerCore.cpp
+++ b/src/Pipeline/SamplerCore.cpp
@@ -16,7 +16,7 @@
#include "Constants.hpp"
#include "PixelRoutine.hpp"
-#include "Vulkan/VkDebug.hpp"
+#include "System/Debug.hpp"
#include "Vulkan/VkSampler.hpp"
#include <limits>
diff --git a/src/Pipeline/ShaderCore.cpp b/src/Pipeline/ShaderCore.cpp
index a13f0d3..2a1dc5b 100644
--- a/src/Pipeline/ShaderCore.cpp
+++ b/src/Pipeline/ShaderCore.cpp
@@ -15,7 +15,7 @@
#include "ShaderCore.hpp"
#include "Device/Renderer.hpp"
-#include "Vulkan/VkDebug.hpp"
+#include "System/Debug.hpp"
#include <limits.h>
diff --git a/src/Pipeline/ShaderCore.hpp b/src/Pipeline/ShaderCore.hpp
index 60a32b4..bbd4c2a 100644
--- a/src/Pipeline/ShaderCore.hpp
+++ b/src/Pipeline/ShaderCore.hpp
@@ -17,7 +17,7 @@
#include "Reactor/Print.hpp"
#include "Reactor/Reactor.hpp"
-#include "Vulkan/VkDebug.hpp"
+#include "System/Debug.hpp"
#include <array>
#include <atomic> // std::memory_order
diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp
index c505ad7..4246880 100644
--- a/src/Pipeline/SpirvShader.cpp
+++ b/src/Pipeline/SpirvShader.cpp
@@ -14,7 +14,7 @@
#include "SpirvShader.hpp"
-#include "Vulkan/VkDebug.hpp"
+#include "System/Debug.hpp"
#include "Vulkan/VkPipelineLayout.hpp"
#include "Vulkan/VkRenderPass.hpp"
diff --git a/src/Pipeline/SpirvShader.hpp b/src/Pipeline/SpirvShader.hpp
index f9c953b..fe8ce60 100644
--- a/src/Pipeline/SpirvShader.hpp
+++ b/src/Pipeline/SpirvShader.hpp
@@ -20,9 +20,9 @@
#include "SpirvID.hpp"
#include "Device/Config.hpp"
#include "Device/Sampler.hpp"
+#include "System/Debug.hpp"
#include "System/Types.hpp"
#include "Vulkan/VkConfig.h"
-#include "Vulkan/VkDebug.hpp"
#include "Vulkan/VkDescriptorSet.hpp"
#include <spirv/unified1/spirv.hpp>
diff --git a/src/Pipeline/SpirvShaderSampling.cpp b/src/Pipeline/SpirvShaderSampling.cpp
index e656a78..0de5059 100644
--- a/src/Pipeline/SpirvShaderSampling.cpp
+++ b/src/Pipeline/SpirvShaderSampling.cpp
@@ -16,8 +16,8 @@
#include "SamplerCore.hpp" // TODO: Figure out what's needed.
#include "Device/Config.hpp"
+#include "System/Debug.hpp"
#include "System/Math.hpp"
-#include "Vulkan/VkDebug.hpp"
#include "Vulkan/VkDescriptorSetLayout.hpp"
#include "Vulkan/VkDevice.hpp"
#include "Vulkan/VkImageView.hpp"
diff --git a/src/Pipeline/VertexProgram.cpp b/src/Pipeline/VertexProgram.cpp
index 4972ef2..f0d2979 100644
--- a/src/Pipeline/VertexProgram.cpp
+++ b/src/Pipeline/VertexProgram.cpp
@@ -17,8 +17,8 @@
#include "SamplerCore.hpp"
#include "Device/Renderer.hpp"
#include "Device/Vertex.hpp"
+#include "System/Debug.hpp"
#include "System/Half.hpp"
-#include "Vulkan/VkDebug.hpp"
#include "Vulkan/VkPipelineLayout.hpp"
diff --git a/src/Pipeline/VertexRoutine.cpp b/src/Pipeline/VertexRoutine.cpp
index 99cdbe3..1eebf57 100644
--- a/src/Pipeline/VertexRoutine.cpp
+++ b/src/Pipeline/VertexRoutine.cpp
@@ -18,8 +18,8 @@
#include "SpirvShader.hpp"
#include "Device/Renderer.hpp"
#include "Device/Vertex.hpp"
+#include "System/Debug.hpp"
#include "System/Half.hpp"
-#include "Vulkan/VkDebug.hpp"
namespace sw {
diff --git a/src/System/Debug.cpp b/src/System/Debug.cpp
index 5fafc90..f510200 100644
--- a/src/System/Debug.cpp
+++ b/src/System/Debug.cpp
@@ -1,4 +1,4 @@
-// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
+// Copyright 2018 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -14,26 +14,212 @@
#include "Debug.hpp"
-#include <stdarg.h>
-#include <stdio.h>
+#include <atomic>
+#include <cstdarg>
+#include <cstdio>
+#include <string>
+
+#if __ANDROID__
+# include <android/log.h>
+#endif
+
+#if defined(__unix__)
+# define PTRACE
+# include <sys/ptrace.h>
+# include <sys/types.h>
+#elif defined(_WIN32) || defined(_WIN64)
+# include <windows.h>
+#elif defined(__APPLE__) || defined(__MACH__)
+# include <sys/sysctl.h>
+# include <unistd.h>
+#endif
+
+#ifdef ERROR
+# undef ERROR // b/127920555
+#endif
+
+namespace {
+
+bool IsUnderDebugger()
+{
+#if defined(PTRACE) && !defined(__APPLE__) && !defined(__MACH__)
+ static bool checked = false;
+ static bool res = false;
+
+ if(!checked)
+ {
+ // If a debugger is attached then we're already being ptraced and ptrace
+ // will return a non-zero value.
+ checked = true;
+ if(ptrace(PTRACE_TRACEME, 0, 1, 0) != 0)
+ {
+ res = true;
+ }
+ else
+ {
+ ptrace(PTRACE_DETACH, 0, 1, 0);
+ }
+ }
+
+ return res;
+#elif defined(_WIN32) || defined(_WIN64)
+ return IsDebuggerPresent() != 0;
+#elif defined(__APPLE__) || defined(__MACH__)
+ // Code comes from the Apple Technical Q&A QA1361
+
+ // Tell sysctl what info we're requestion. Specifically we're asking for
+ // info about this our PID.
+ int res = 0;
+ int request[4] = {
+ CTL_KERN,
+ KERN_PROC,
+ KERN_PROC_PID,
+ getpid()
+ };
+ struct kinfo_proc info;
+ size_t size = sizeof(info);
+
+ info.kp_proc.p_flag = 0;
+
+ // Get the info we're requesting, if sysctl fails then info.kp_proc.p_flag will remain 0.
+ res = sysctl(request, sizeof(request) / sizeof(*request), &info, &size, NULL, 0);
+ ASSERT_MSG(res == 0, "syscl returned %d", res);
+
+ // We're being debugged if the P_TRACED flag is set
+ return ((info.kp_proc.p_flag & P_TRACED) != 0);
+#else
+ return false;
+#endif
+}
+
+enum class Level
+{
+ DEBUG,
+ INFO,
+ WARN,
+ ERROR,
+ FATAL,
+};
+
+#ifdef __ANDROID__
+void logv_android(Level level, const char *msg)
+{
+ switch(level)
+ {
+ case Level::DEBUG:
+ __android_log_write(ANDROID_LOG_DEBUG, "SwiftShader", msg);
+ break;
+ case Level::INFO:
+ __android_log_write(ANDROID_LOG_INFO, "SwiftShader", msg);
+ break;
+ case Level::WARN:
+ __android_log_write(ANDROID_LOG_WARN, "SwiftShader", msg);
+ break;
+ case Level::ERROR:
+ __android_log_write(ANDROID_LOG_ERROR, "SwiftShader", msg);
+ break;
+ case Level::FATAL:
+ __android_log_write(ANDROID_LOG_FATAL, "SwiftShader", msg);
+ break;
+ }
+}
+#else
+void logv_std(Level level, const char *msg)
+{
+ switch(level)
+ {
+ case Level::DEBUG:
+ case Level::INFO:
+ fprintf(stdout, "%s", msg);
+ break;
+ case Level::WARN:
+ case Level::ERROR:
+ case Level::FATAL:
+ fprintf(stderr, "%s", msg);
+ break;
+ }
+}
+#endif
+
+void logv(Level level, const char *format, va_list args)
+{
+#ifndef SWIFTSHADER_DISABLE_TRACE
+ char buffer[2048];
+ vsnprintf(buffer, sizeof(buffer), format, args);
+
+# if defined(__ANDROID__)
+ logv_android(level, buffer);
+# elif defined(_WIN32)
+ logv_std(level, buffer);
+ ::OutputDebugString(buffer);
+# else
+ logv_std(level, buffer);
+# endif
+
+ const bool traceToFile = false;
+ if(traceToFile)
+ {
+ FILE *file = fopen(TRACE_OUTPUT_FILE, "a");
+
+ if(file)
+ {
+ vfprintf(file, format, args);
+ fclose(file);
+ }
+ }
+#endif // SWIFTSHADER_DISABLE_TRACE
+}
+
+} // anonymous namespace
namespace sw {
void trace(const char *format, ...)
{
- if(false)
+ va_list vararg;
+ va_start(vararg, format);
+ logv(Level::DEBUG, format, vararg);
+ va_end(vararg);
+}
+
+void warn(const char *format, ...)
+{
+ va_list vararg;
+ va_start(vararg, format);
+ logv(Level::WARN, format, vararg);
+ va_end(vararg);
+}
+
+void abort(const char *format, ...)
+{
+ va_list vararg;
+
+ va_start(vararg, format);
+ logv(Level::FATAL, format, vararg);
+ va_end(vararg);
+
+ ::abort();
+}
+
+void trace_assert(const char *format, ...)
+{
+ static std::atomic<bool> asserted = { false };
+ if(IsUnderDebugger() && !asserted.exchange(true))
{
- FILE *file = fopen("debug.txt", "a");
+ // Abort after tracing and printing to stderr
+ va_list vararg;
+ va_start(vararg, format);
+ logv(Level::FATAL, format, vararg);
+ va_end(vararg);
- if(file)
- {
- va_list vararg;
- va_start(vararg, format);
- vfprintf(file, format, vararg);
- va_end(vararg);
-
- fclose(file);
- }
+ ::abort();
+ }
+ else if(!asserted)
+ {
+ va_list vararg;
+ va_start(vararg, format);
+ logv(Level::FATAL, format, vararg);
+ va_end(vararg);
}
}
diff --git a/src/System/Debug.hpp b/src/System/Debug.hpp
index 5c62d7b..85ea4a4 100644
--- a/src/System/Debug.hpp
+++ b/src/System/Debug.hpp
@@ -12,54 +12,140 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+// debug.h: Debugging utilities.
+
#ifndef Debug_hpp
#define Debug_hpp
-#if defined(__ANDROID__) && !defined(ANDROID_HOST_BUILD) && !defined(ANDROID_NDK_BUILD)
-# include "DebugAndroid.hpp"
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <cctype>
+#include <string>
+
+#if !defined(TRACE_OUTPUT_FILE)
+# define TRACE_OUTPUT_FILE "debug.txt"
+#endif
+
+#if defined(__GNUC__) || defined(__clang__)
+# define CHECK_PRINTF_ARGS __attribute__((format(printf, 1, 2)))
#else
-
-# include <assert.h>
-# include <stdio.h>
-
-# undef min
-# undef max
+# define CHECK_PRINTF_ARGS
+#endif
namespace sw {
-void trace(const char *format, ...);
+// Outputs text to the debugging log
+void trace(const char *format, ...) CHECK_PRINTF_ARGS;
inline void trace() {}
+// Outputs text to the debugging log and prints to stderr.
+void warn(const char *format, ...) CHECK_PRINTF_ARGS;
+inline void warn() {}
+
+// Outputs the message to the debugging log and stderr, and calls abort().
+void abort(const char *format, ...) CHECK_PRINTF_ARGS;
+
+// Outputs text to the debugging log, and asserts once if a debugger is attached.
+void trace_assert(const char *format, ...) CHECK_PRINTF_ARGS;
+
} // namespace sw
-# if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
-# define TRACE(format, ...) sw::trace("[0x%0.8X]%s(" format ")\n", this, __FUNCTION__, ##__VA_ARGS__)
-# else
-# define TRACE(...) ((void)0)
-# endif
+// A macro to output a trace of a function call and its arguments to the
+// debugging log. Disabled if SWIFTSHADER_DISABLE_TRACE is defined.
+#if defined(SWIFTSHADER_DISABLE_TRACE)
+# define TRACE(message, ...) (void(0))
+# define TRACE_ASSERT(message, ...) (void(0))
+#else
+# define TRACE(message, ...) sw::trace("%s:%d TRACE: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__)
+# define TRACE_ASSERT(message, ...) sw::trace_assert("%s:%d %s TRACE_ASSERT: " message "\n", __FILE__, __LINE__, __func__, ##__VA_ARGS__)
+#endif
-# if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
-# define UNIMPLEMENTED(...) \
- do \
- { \
- sw::trace("\t! Unimplemented: %s(%d): ", __FUNCTION__, __LINE__); \
- sw::trace(__VA_ARGS__); \
- sw::trace("\n"); \
- ASSERT(false); \
- } while(0)
-# else
-# define UNIMPLEMENTED(...) ((void)0)
-# endif
+// A macro to print a warning message to the debugging log and stderr to denote
+// an issue that needs fixing.
+#define FIXME(message, ...) sw::warn("%s:%d FIXME: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__);
-# if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
-# define ASSERT(expression) \
- { \
- if(!(expression)) sw::trace("\t! Assert failed in %s(%d): " #expression "\n", __FUNCTION__, __LINE__); \
- assert(expression); \
- }
-# else
-# define ASSERT assert
-# endif
+// A macro to print a warning message to the debugging log and stderr.
+#define WARN(message, ...) sw::warn("%s:%d WARNING: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__);
-#endif // !__ANDROID__
+// A macro that prints the message to the debugging log and stderr and
+// immediately aborts execution of the application.
+//
+// Note: This will terminate the application regardless of build flags!
+// Use with extreme caution!
+#undef ABORT
+#define ABORT(message, ...) sw::abort("%s:%d ABORT: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__)
+
+// A macro that delegates to:
+// ABORT() in debug builds (!NDEBUG || DCHECK_ALWAYS_ON)
+// or
+// WARN() in release builds (NDEBUG && !DCHECK_ALWAYS_ON)
+#undef DABORT
+#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
+# define DABORT(message, ...) ABORT(message, ##__VA_ARGS__)
+#else
+# define DABORT(message, ...) WARN(message, ##__VA_ARGS__)
+#endif
+
+// A macro asserting a condition.
+// If the condition fails, the condition and message is passed to DABORT().
+#undef ASSERT_MSG
+#define ASSERT_MSG(expression, format, ...) \
+ do \
+ { \
+ if(!(expression)) \
+ { \
+ DABORT("ASSERT(%s): " format "\n", #expression, ##__VA_ARGS__); \
+ } \
+ } while(0)
+
+// A macro asserting a condition.
+// If the condition fails, the condition is passed to DABORT().
+#undef ASSERT
+#define ASSERT(expression) \
+ do \
+ { \
+ if(!(expression)) \
+ { \
+ DABORT("ASSERT(%s)\n", #expression); \
+ } \
+ } while(0)
+
+// A macro to indicate functionality currently unimplemented, for a feature advertised
+// as supported. Since this is a bug, a bug ID must be provided, in b/### format.
+// For unimplemented functionality not advertised as supported, use UNSUPPORTED() instead.
+#undef UNIMPLEMENTED
+#define UNIMPLEMENTED(format, ...) \
+ DABORT("UNIMPLEMENTED: " format, ##__VA_ARGS__); \
+ static_assert(format[0] == 'b' && format[1] == '/' && format[2] >= '0' && format[2] <= '9', "explanation must start with bug reference in b/### format")
+
+// A macro to indicate unsupported functionality.
+// This should be called when a Vulkan / SPIR-V feature is attempted to be used,
+// but is not currently implemented by SwiftShader.
+// Note that in a well-behaved application these should not be reached as the
+// application should be respecting the advertised features / limits.
+#undef UNSUPPORTED
+#define UNSUPPORTED(format, ...) DABORT("UNSUPPORTED: " format, ##__VA_ARGS__)
+
+// A macro for code which should never be reached, even with misbehaving
+// applications.
+#undef UNREACHABLE
+#define UNREACHABLE(format, ...) DABORT("UNREACHABLE: " format, ##__VA_ARGS__)
+
+// A macro asserting a condition and performing a return.
+#undef ASSERT_OR_RETURN
+#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
+# define ASSERT_OR_RETURN(expression) ASSERT(expression)
+#else
+# define ASSERT_OR_RETURN(expression) \
+ do \
+ { \
+ if(!(expression)) \
+ { \
+ return; \
+ } \
+ } while(0)
+#endif
+
#endif // Debug_hpp
diff --git a/src/System/DebugAndroid.cpp b/src/System/DebugAndroid.cpp
deleted file mode 100644
index 5194cc3..0000000
--- a/src/System/DebugAndroid.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "DebugAndroid.hpp"
-
-#include <cutils/properties.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-void AndroidEnterDebugger()
-{
- ALOGE(__FUNCTION__);
-#ifndef NDEBUG
- static volatile int *const makefault = nullptr;
- char value[PROPERTY_VALUE_MAX];
- property_get("debug.db.uid", value, "-1");
- int debug_uid = atoi(value);
- if((debug_uid >= 0) && (geteuid() < static_cast<uid_t>(debug_uid)))
- {
- ALOGE("Waiting for debugger: gdbserver :${PORT} --attach %u. Look for thread %u", getpid(), gettid());
- volatile int waiting = 1;
- while(waiting)
- {
- sleep(1);
- }
- }
- else
- {
- ALOGE("No debugger");
- }
-#endif
-}
-
-void trace(const char *format, ...)
-{
-#ifndef NDEBUG
- va_list vararg;
- va_start(vararg, format);
- android_vprintLog(ANDROID_LOG_VERBOSE, NULL, LOG_TAG, format, vararg);
- va_end(vararg);
-#endif
-}
diff --git a/src/System/DebugAndroid.hpp b/src/System/DebugAndroid.hpp
deleted file mode 100644
index a8cbc9f..0000000
--- a/src/System/DebugAndroid.hpp
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#ifndef DebugAndroid_hpp
-#define DebugAndroid_hpp
-
-#if ANDROID_PLATFORM_SDK_VERSION < 27
-# include <cutils/log.h>
-#elif ANDROID_PLATFORM_SDK_VERSION >= 27
-# include <log/log.h>
-#else
-# error "ANDROID_PLATFORM_SDK_VERSION is not defined"
-#endif
-
-#include <cassert>
-
-// On Android Virtual Devices we heavily depend on logging, even in
-// production builds. We do this because AVDs are components of larger
-// systems, and may be configured in ways that are difficult to
-// reproduce locally. For example some system run tests against
-// third-party code that we cannot access. Aborting (cf. assert) on
-// unimplemented functionality creates two problems. First, it produces
-// a service failure where none is needed. Second, it puts the
-// customer on the critical path for notifying us of a problem.
-// The alternative, skipping unimplemented functionality silently, is
-// arguably worse: neither the service provider nor the customer will
-// learn that unimplemented functionality may have compromised the test
-// results.
-// Logging invocations of unimplemented functionality is useful to both
-// service provider and the customer. The service provider can learn
-// that the functionality is needed. The customer learns that the test
-// results may be compromised.
-
-/**
- * Enter the debugger with a memory fault iff debuggerd is set to capture this
- * process. Otherwise return.
- */
-void AndroidEnterDebugger();
-
-#define ASSERT(E) \
- do \
- { \
- if(!(E)) \
- { \
- ALOGE("badness: assertion_failed %s in %s at %s:%d", #E, \
- __FUNCTION__, __FILE__, __LINE__); \
- AndroidEnterDebugger(); \
- } \
- } while(0)
-
-#undef assert
-#define assert(E) ASSERT(E)
-
-#define ERR(format, ...) \
- do \
- { \
- ALOGE("badness: err %s %s:%d (" format ")", __FUNCTION__, __FILE__, \
- __LINE__, ##__VA_ARGS__); \
- AndroidEnterDebugger(); \
- } while(0)
-
-#define FIXME(format, ...) \
- do \
- { \
- ALOGE("badness: fixme %s %s:%d (" format ")", __FUNCTION__, __FILE__, \
- __LINE__, ##__VA_ARGS__); \
- AndroidEnterDebugger(); \
- } while(0)
-
-// TODO: Handle __VA_ARGS__ (can be empty)
-#define UNIMPLEMENTED(...) \
- do \
- { \
- ALOGE("badness: unimplemented: %s %s:%d", \
- __FUNCTION__, __FILE__, __LINE__); \
- AndroidEnterDebugger(); \
- } while(0)
-
-#define UNREACHABLE(value) \
- do \
- { \
- ALOGE("badness: unreachable case reached: %s %s:%d. %s: %d", \
- __FUNCTION__, __FILE__, __LINE__, #value, value); \
- AndroidEnterDebugger(); \
- } while(0)
-
-#ifndef NDEBUG
-# define TRACE(format, ...) \
- ALOGV("%s %s:%d (" format ")", __FUNCTION__, __FILE__, \
- __LINE__, ##__VA_ARGS__)
-#else
-# define TRACE(...) ((void)0)
-#endif
-
-void trace(const char *format, ...);
-
-#endif // DebugAndroid_hpp
diff --git a/src/System/Math.hpp b/src/System/Math.hpp
index 4071059..9004d9f 100644
--- a/src/System/Math.hpp
+++ b/src/System/Math.hpp
@@ -15,10 +15,9 @@
#ifndef sw_Math_hpp
#define sw_Math_hpp
+#include "Debug.hpp"
#include "Types.hpp"
-#include "Vulkan/VkDebug.hpp"
-
#include <cmath>
#if defined(_MSC_VER)
# include <intrin.h>
diff --git a/src/Vulkan/BUILD.gn b/src/Vulkan/BUILD.gn
index 613c1fb..ce7b87a 100644
--- a/src/Vulkan/BUILD.gn
+++ b/src/Vulkan/BUILD.gn
@@ -60,7 +60,6 @@
"VkCommandBuffer.hpp",
"VkCommandPool.hpp",
"VkConfig.h",
- "VkDebug.hpp",
"VkDescriptorPool.hpp",
"VkDescriptorSet.hpp",
"VkDescriptorSetLayout.hpp",
@@ -109,7 +108,6 @@
"VkBufferView.cpp",
"VkCommandBuffer.cpp",
"VkCommandPool.cpp",
- "VkDebug.cpp",
"VkDescriptorPool.cpp",
"VkDescriptorSetLayout.cpp",
"VkDescriptorUpdateTemplate.cpp",
diff --git a/src/Vulkan/VkDebug.cpp b/src/Vulkan/VkDebug.cpp
deleted file mode 100644
index 37a1ee8..0000000
--- a/src/Vulkan/VkDebug.cpp
+++ /dev/null
@@ -1,226 +0,0 @@
-// Copyright 2018 The SwiftShader Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-#include "VkDebug.hpp"
-
-#include <atomic>
-#include <cstdarg>
-#include <cstdio>
-#include <string>
-
-#if __ANDROID__
-# include <android/log.h>
-#endif
-
-#if defined(__unix__)
-# define PTRACE
-# include <sys/ptrace.h>
-# include <sys/types.h>
-#elif defined(_WIN32) || defined(_WIN64)
-# include <windows.h>
-#elif defined(__APPLE__) || defined(__MACH__)
-# include <sys/sysctl.h>
-# include <unistd.h>
-#endif
-
-#ifdef ERROR
-# undef ERROR // b/127920555
-#endif
-
-namespace {
-
-bool IsUnderDebugger()
-{
-#if defined(PTRACE) && !defined(__APPLE__) && !defined(__MACH__)
- static bool checked = false;
- static bool res = false;
-
- if(!checked)
- {
- // If a debugger is attached then we're already being ptraced and ptrace
- // will return a non-zero value.
- checked = true;
- if(ptrace(PTRACE_TRACEME, 0, 1, 0) != 0)
- {
- res = true;
- }
- else
- {
- ptrace(PTRACE_DETACH, 0, 1, 0);
- }
- }
-
- return res;
-#elif defined(_WIN32) || defined(_WIN64)
- return IsDebuggerPresent() != 0;
-#elif defined(__APPLE__) || defined(__MACH__)
- // Code comes from the Apple Technical Q&A QA1361
-
- // Tell sysctl what info we're requestion. Specifically we're asking for
- // info about this our PID.
- int res = 0;
- int request[4] = {
- CTL_KERN,
- KERN_PROC,
- KERN_PROC_PID,
- getpid()
- };
- struct kinfo_proc info;
- size_t size = sizeof(info);
-
- info.kp_proc.p_flag = 0;
-
- // Get the info we're requesting, if sysctl fails then info.kp_proc.p_flag will remain 0.
- res = sysctl(request, sizeof(request) / sizeof(*request), &info, &size, NULL, 0);
- ASSERT_MSG(res == 0, "syscl returned %d", res);
-
- // We're being debugged if the P_TRACED flag is set
- return ((info.kp_proc.p_flag & P_TRACED) != 0);
-#else
- return false;
-#endif
-}
-
-enum class Level
-{
- DEBUG,
- INFO,
- WARN,
- ERROR,
- FATAL,
-};
-
-#ifdef __ANDROID__
-void logv_android(Level level, const char *msg)
-{
- switch(level)
- {
- case Level::DEBUG:
- __android_log_write(ANDROID_LOG_DEBUG, "SwiftShader", msg);
- break;
- case Level::INFO:
- __android_log_write(ANDROID_LOG_INFO, "SwiftShader", msg);
- break;
- case Level::WARN:
- __android_log_write(ANDROID_LOG_WARN, "SwiftShader", msg);
- break;
- case Level::ERROR:
- __android_log_write(ANDROID_LOG_ERROR, "SwiftShader", msg);
- break;
- case Level::FATAL:
- __android_log_write(ANDROID_LOG_FATAL, "SwiftShader", msg);
- break;
- }
-}
-#else
-void logv_std(Level level, const char *msg)
-{
- switch(level)
- {
- case Level::DEBUG:
- case Level::INFO:
- fprintf(stdout, "%s", msg);
- break;
- case Level::WARN:
- case Level::ERROR:
- case Level::FATAL:
- fprintf(stderr, "%s", msg);
- break;
- }
-}
-#endif
-
-void logv(Level level, const char *format, va_list args)
-{
-#ifndef SWIFTSHADER_DISABLE_TRACE
- char buffer[2048];
- vsnprintf(buffer, sizeof(buffer), format, args);
-
-# if defined(__ANDROID__)
- logv_android(level, buffer);
-# elif defined(_WIN32)
- logv_std(level, buffer);
- ::OutputDebugString(buffer);
-# else
- logv_std(level, buffer);
-# endif
-
- const bool traceToFile = false;
- if(traceToFile)
- {
- FILE *file = fopen(TRACE_OUTPUT_FILE, "a");
-
- if(file)
- {
- vfprintf(file, format, args);
- fclose(file);
- }
- }
-#endif // SWIFTSHADER_DISABLE_TRACE
-}
-
-} // anonymous namespace
-
-namespace vk {
-
-void trace(const char *format, ...)
-{
- va_list vararg;
- va_start(vararg, format);
- logv(Level::DEBUG, format, vararg);
- va_end(vararg);
-}
-
-void warn(const char *format, ...)
-{
- va_list vararg;
- va_start(vararg, format);
- logv(Level::WARN, format, vararg);
- va_end(vararg);
-}
-
-void abort(const char *format, ...)
-{
- va_list vararg;
-
- va_start(vararg, format);
- logv(Level::FATAL, format, vararg);
- va_end(vararg);
-
- ::abort();
-}
-
-void trace_assert(const char *format, ...)
-{
- static std::atomic<bool> asserted = { false };
- if(IsUnderDebugger() && !asserted.exchange(true))
- {
- // Abort after tracing and printing to stderr
- va_list vararg;
- va_start(vararg, format);
- logv(Level::FATAL, format, vararg);
- va_end(vararg);
-
- ::abort();
- }
- else if(!asserted)
- {
- va_list vararg;
- va_start(vararg, format);
- logv(Level::FATAL, format, vararg);
- va_end(vararg);
- }
-}
-
-} // namespace vk
diff --git a/src/Vulkan/VkDebug.hpp b/src/Vulkan/VkDebug.hpp
deleted file mode 100644
index 801a9ad..0000000
--- a/src/Vulkan/VkDebug.hpp
+++ /dev/null
@@ -1,151 +0,0 @@
-// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// debug.h: Debugging utilities.
-
-#ifndef VK_DEBUG_H_
-#define VK_DEBUG_H_
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <cctype>
-#include <string>
-
-#if !defined(TRACE_OUTPUT_FILE)
-# define TRACE_OUTPUT_FILE "debug.txt"
-#endif
-
-#if defined(__GNUC__) || defined(__clang__)
-# define CHECK_PRINTF_ARGS __attribute__((format(printf, 1, 2)))
-#else
-# define CHECK_PRINTF_ARGS
-#endif
-
-namespace vk {
-
-// Outputs text to the debugging log
-void trace(const char *format, ...) CHECK_PRINTF_ARGS;
-inline void trace() {}
-
-// Outputs text to the debugging log and prints to stderr.
-void warn(const char *format, ...) CHECK_PRINTF_ARGS;
-inline void warn() {}
-
-// Outputs the message to the debugging log and stderr, and calls abort().
-void abort(const char *format, ...) CHECK_PRINTF_ARGS;
-
-// Outputs text to the debugging log, and asserts once if a debugger is attached.
-void trace_assert(const char *format, ...) CHECK_PRINTF_ARGS;
-
-} // namespace vk
-
-// A macro to output a trace of a function call and its arguments to the
-// debugging log. Disabled if SWIFTSHADER_DISABLE_TRACE is defined.
-#if defined(SWIFTSHADER_DISABLE_TRACE)
-# define TRACE(message, ...) (void(0))
-# define TRACE_ASSERT(message, ...) (void(0))
-#else
-# define TRACE(message, ...) vk::trace("%s:%d TRACE: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__)
-# define TRACE_ASSERT(message, ...) vk::trace_assert("%s:%d %s TRACE_ASSERT: " message "\n", __FILE__, __LINE__, __func__, ##__VA_ARGS__)
-#endif
-
-// A macro to print a warning message to the debugging log and stderr to denote
-// an issue that needs fixing.
-#define FIXME(message, ...) vk::warn("%s:%d FIXME: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__);
-
-// A macro to print a warning message to the debugging log and stderr.
-#define WARN(message, ...) vk::warn("%s:%d WARNING: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__);
-
-// A macro that prints the message to the debugging log and stderr and
-// immediately aborts execution of the application.
-//
-// Note: This will terminate the application regardless of build flags!
-// Use with extreme caution!
-#undef ABORT
-#define ABORT(message, ...) vk::abort("%s:%d ABORT: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__)
-
-// A macro that delegates to:
-// ABORT() in debug builds (!NDEBUG || DCHECK_ALWAYS_ON)
-// or
-// WARN() in release builds (NDEBUG && !DCHECK_ALWAYS_ON)
-#undef DABORT
-#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
-# define DABORT(message, ...) ABORT(message, ##__VA_ARGS__)
-#else
-# define DABORT(message, ...) WARN(message, ##__VA_ARGS__)
-#endif
-
-// A macro asserting a condition.
-// If the condition fails, the condition and message is passed to DABORT().
-#undef ASSERT_MSG
-#define ASSERT_MSG(expression, format, ...) \
- do \
- { \
- if(!(expression)) \
- { \
- DABORT("ASSERT(%s): " format "\n", #expression, ##__VA_ARGS__); \
- } \
- } while(0)
-
-// A macro asserting a condition.
-// If the condition fails, the condition is passed to DABORT().
-#undef ASSERT
-#define ASSERT(expression) \
- do \
- { \
- if(!(expression)) \
- { \
- DABORT("ASSERT(%s)\n", #expression); \
- } \
- } while(0)
-
-// A macro to indicate functionality currently unimplemented, for a feature advertised
-// as supported. Since this is a bug, a bug ID must be provided, in b/### format.
-// For unimplemented functionality not advertised as supported, use UNSUPPORTED() instead.
-#undef UNIMPLEMENTED
-#define UNIMPLEMENTED(format, ...) \
- DABORT("UNIMPLEMENTED: " format, ##__VA_ARGS__); \
- static_assert(format[0] == 'b' && format[1] == '/' && format[2] >= '0' && format[2] <= '9', "explanation must start with bug reference in b/### format")
-
-// A macro to indicate unsupported functionality.
-// This should be called when a Vulkan / SPIR-V feature is attempted to be used,
-// but is not currently implemented by SwiftShader.
-// Note that in a well-behaved application these should not be reached as the
-// application should be respecting the advertised features / limits.
-#undef UNSUPPORTED
-#define UNSUPPORTED(format, ...) DABORT("UNSUPPORTED: " format, ##__VA_ARGS__)
-
-// A macro for code which should never be reached, even with misbehaving
-// applications.
-#undef UNREACHABLE
-#define UNREACHABLE(format, ...) DABORT("UNREACHABLE: " format, ##__VA_ARGS__)
-
-// A macro asserting a condition and performing a return.
-#undef ASSERT_OR_RETURN
-#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
-# define ASSERT_OR_RETURN(expression) ASSERT(expression)
-#else
-# define ASSERT_OR_RETURN(expression) \
- do \
- { \
- if(!(expression)) \
- { \
- return; \
- } \
- } while(0)
-#endif
-
-#endif // VK_DEBUG_H_
diff --git a/src/Vulkan/VkDevice.cpp b/src/Vulkan/VkDevice.cpp
index c7af54c..7f9bcc0 100644
--- a/src/Vulkan/VkDevice.cpp
+++ b/src/Vulkan/VkDevice.cpp
@@ -15,13 +15,13 @@
#include "VkDevice.hpp"
#include "VkConfig.h"
-#include "VkDebug.hpp"
#include "VkDescriptorSetLayout.hpp"
#include "VkFence.hpp"
#include "VkQueue.hpp"
#include "Debug/Context.hpp"
#include "Debug/Server.hpp"
#include "Device/Blitter.hpp"
+#include "System/Debug.hpp"
#include <chrono>
#include <climits>
diff --git a/src/Vulkan/VkDeviceMemoryExternalAndroid.hpp b/src/Vulkan/VkDeviceMemoryExternalAndroid.hpp
index 853d144..9bfb381 100644
--- a/src/Vulkan/VkDeviceMemoryExternalAndroid.hpp
+++ b/src/Vulkan/VkDeviceMemoryExternalAndroid.hpp
@@ -12,9 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "VkDebug.hpp"
#include "VkStringify.hpp"
+#include "System/Debug.hpp"
+
#include <android/hardware_buffer.h>
#include <errno.h>
diff --git a/src/Vulkan/VkDeviceMemoryExternalLinux.hpp b/src/Vulkan/VkDeviceMemoryExternalLinux.hpp
index 3a9a768..77c7c80 100644
--- a/src/Vulkan/VkDeviceMemoryExternalLinux.hpp
+++ b/src/Vulkan/VkDeviceMemoryExternalLinux.hpp
@@ -12,8 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "VkDebug.hpp"
#include "VkStringify.hpp"
+
+#include "System/Debug.hpp"
#include "System/Linux/MemFd.hpp"
#include <errno.h>
diff --git a/src/Vulkan/VkFormat.cpp b/src/Vulkan/VkFormat.cpp
index 8eddb9c..837e8ca 100644
--- a/src/Vulkan/VkFormat.cpp
+++ b/src/Vulkan/VkFormat.cpp
@@ -13,7 +13,8 @@
// limitations under the License.
#include "VkFormat.h"
-#include "VkDebug.hpp"
+
+#include "System/Debug.hpp"
#include "System/Math.hpp"
namespace vk {
diff --git a/src/Vulkan/VkImageView.hpp b/src/Vulkan/VkImageView.hpp
index 20df400..65dca48 100644
--- a/src/Vulkan/VkImageView.hpp
+++ b/src/Vulkan/VkImageView.hpp
@@ -15,11 +15,12 @@
#ifndef VK_IMAGE_VIEW_HPP_
#define VK_IMAGE_VIEW_HPP_
-#include "VkDebug.hpp"
#include "VkFormat.h"
#include "VkImage.hpp"
#include "VkObject.hpp"
+#include "System/Debug.hpp"
+
#include <atomic>
namespace vk {
diff --git a/src/Vulkan/VkObject.hpp b/src/Vulkan/VkObject.hpp
index 0d7010f..d0fcba6 100644
--- a/src/Vulkan/VkObject.hpp
+++ b/src/Vulkan/VkObject.hpp
@@ -16,9 +16,10 @@
#define VK_OBJECT_HPP_
#include "VkConfig.h"
-#include "VkDebug.hpp"
#include "VkMemory.h"
+#include "System/Debug.hpp"
+
#include <Vulkan/VulkanPlatform.h>
#include <vulkan/vk_icd.h>
#include <new>
diff --git a/src/Vulkan/VkPipeline.cpp b/src/Vulkan/VkPipeline.cpp
index 9937dec..56786e8 100644
--- a/src/Vulkan/VkPipeline.cpp
+++ b/src/Vulkan/VkPipeline.cpp
@@ -42,13 +42,13 @@
opt.SetMessageConsumer([](spv_message_level_t level, const char *, const spv_position_t &p, const char *m) {
switch(level)
{
- case SPV_MSG_FATAL: vk::warn("SPIR-V FATAL: %d:%d %s\n", int(p.line), int(p.column), m);
- case SPV_MSG_INTERNAL_ERROR: vk::warn("SPIR-V INTERNAL_ERROR: %d:%d %s\n", int(p.line), int(p.column), m);
- case SPV_MSG_ERROR: vk::warn("SPIR-V ERROR: %d:%d %s\n", int(p.line), int(p.column), m);
- case SPV_MSG_WARNING: vk::warn("SPIR-V WARNING: %d:%d %s\n", int(p.line), int(p.column), m);
- case SPV_MSG_INFO: vk::trace("SPIR-V INFO: %d:%d %s\n", int(p.line), int(p.column), m);
- case SPV_MSG_DEBUG: vk::trace("SPIR-V DEBUG: %d:%d %s\n", int(p.line), int(p.column), m);
- default: vk::trace("SPIR-V MESSAGE: %d:%d %s\n", int(p.line), int(p.column), m);
+ case SPV_MSG_FATAL: sw::warn("SPIR-V FATAL: %d:%d %s\n", int(p.line), int(p.column), m);
+ case SPV_MSG_INTERNAL_ERROR: sw::warn("SPIR-V INTERNAL_ERROR: %d:%d %s\n", int(p.line), int(p.column), m);
+ case SPV_MSG_ERROR: sw::warn("SPIR-V ERROR: %d:%d %s\n", int(p.line), int(p.column), m);
+ case SPV_MSG_WARNING: sw::warn("SPIR-V WARNING: %d:%d %s\n", int(p.line), int(p.column), m);
+ case SPV_MSG_INFO: sw::trace("SPIR-V INFO: %d:%d %s\n", int(p.line), int(p.column), m);
+ case SPV_MSG_DEBUG: sw::trace("SPIR-V DEBUG: %d:%d %s\n", int(p.line), int(p.column), m);
+ default: sw::trace("SPIR-V MESSAGE: %d:%d %s\n", int(p.line), int(p.column), m);
}
});
diff --git a/src/Vulkan/VkSemaphoreExternalFuchsia.hpp b/src/Vulkan/VkSemaphoreExternalFuchsia.hpp
index 926687c..a45f0b8 100644
--- a/src/Vulkan/VkSemaphoreExternalFuchsia.hpp
+++ b/src/Vulkan/VkSemaphoreExternalFuchsia.hpp
@@ -15,7 +15,7 @@
#ifndef VK_SEMAPHORE_EXTERNAL_FUCHSIA_H_
#define VK_SEMAPHORE_EXTERNAL_FUCHSIA_H_
-#include "VkDebug.hpp"
+#include "System/Debug.hpp"
#include <zircon/syscalls.h>
diff --git a/src/Vulkan/VkStringify.cpp b/src/Vulkan/VkStringify.cpp
index f274724..9e660fd 100644
--- a/src/Vulkan/VkStringify.cpp
+++ b/src/Vulkan/VkStringify.cpp
@@ -11,8 +11,11 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
+
#include "VkStringify.hpp"
-#include "VkDebug.hpp"
+
+#include "System/Debug.hpp"
+
#include "vulkan/vk_ext_provoking_vertex.h"
#include <iostream>
diff --git a/src/Vulkan/libVulkan.cpp b/src/Vulkan/libVulkan.cpp
index f2146b1..1d93641 100644
--- a/src/Vulkan/libVulkan.cpp
+++ b/src/Vulkan/libVulkan.cpp
@@ -17,7 +17,6 @@
#include "VkCommandBuffer.hpp"
#include "VkCommandPool.hpp"
#include "VkConfig.h"
-#include "VkDebug.hpp"
#include "VkDescriptorPool.hpp"
#include "VkDescriptorSetLayout.hpp"
#include "VkDescriptorUpdateTemplate.hpp"
@@ -43,6 +42,8 @@
#include "VkShaderModule.hpp"
#include "VkStringify.hpp"
+#include "System/Debug.hpp"
+
#if defined(VK_USE_PLATFORM_METAL_EXT) || defined(VK_USE_PLATFORM_MACOS_MVK)
# include "WSI/MetalSurface.h"
#endif
diff --git a/src/WSI/Win32SurfaceKHR.cpp b/src/WSI/Win32SurfaceKHR.cpp
index ff13c26..c4c156b 100644
--- a/src/WSI/Win32SurfaceKHR.cpp
+++ b/src/WSI/Win32SurfaceKHR.cpp
@@ -14,7 +14,7 @@
#include "Win32SurfaceKHR.hpp"
-#include "Vulkan/VkDebug.hpp"
+#include "System/Debug.hpp"
#include "Vulkan/VkDeviceMemory.hpp"
#include <string.h>