Commit 01c03fd5 by Ben Clayton

Revert "VkDebug: Update macros to address issues in b/127433389"

Breaks windows build. This reverts commit 36411219. Change-Id: I89286d25ed0e362f16e981d3c4d39a4661ee02c2 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/27329 Presubmit-Ready: Ben Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com>
parent acd87b70
...@@ -260,7 +260,7 @@ namespace sw ...@@ -260,7 +260,7 @@ namespace sw
mainBlockId = Block::ID(it.word(1)); mainBlockId = Block::ID(it.word(1));
break; break;
default: default:
WARN("Unexpected opcode '%s' following OpFunction", OpcodeName(it.opcode()).c_str()); ERR("Unexpected opcode '%s' following OpFunction", OpcodeName(it.opcode()).c_str());
} }
} }
ASSERT(mainBlockId.value() != 0); // Function's OpLabel not found ASSERT(mainBlockId.value() != 0); // Function's OpLabel not found
...@@ -402,7 +402,7 @@ namespace sw ...@@ -402,7 +402,7 @@ namespace sw
break; break;
default: default:
UNIMPLEMENTED("%s", OpcodeName(insn.opcode()).c_str()); UNIMPLEMENTED(OpcodeName(insn.opcode()).c_str());
} }
} }
} }
...@@ -1202,7 +1202,7 @@ namespace sw ...@@ -1202,7 +1202,7 @@ namespace sw
break; break;
default: default:
UNIMPLEMENTED("opcode: %s", OpcodeName(insn.opcode()).c_str()); UNIMPLEMENTED(OpcodeName(insn.opcode()).c_str());
break; break;
} }
} }
......
...@@ -392,14 +392,14 @@ namespace sw ...@@ -392,14 +392,14 @@ namespace sw
Type const &getType(Type::ID id) const Type const &getType(Type::ID id) const
{ {
auto it = types.find(id); auto it = types.find(id);
ASSERT_MSG(it != types.end(), "Unknown type %d", id.value()); ASSERT(it != types.end());
return it->second; return it->second;
} }
Object const &getObject(Object::ID id) const Object const &getObject(Object::ID id) const
{ {
auto it = defs.find(id); auto it = defs.find(id);
ASSERT_MSG(it != defs.end(), "Unknown object %d", id.value()); ASSERT(it != defs.end());
return it->second; return it->second;
} }
......
...@@ -14,61 +14,25 @@ ...@@ -14,61 +14,25 @@
#include "VkDebug.hpp" #include "VkDebug.hpp"
#include <string>
#include <stdarg.h> #include <stdarg.h>
namespace vk namespace vk
{ {
void trace(const char *format, ...)
void tracev(const char *format, va_list args)
{ {
#ifndef SWIFTSHADER_DISABLE_TRACE
if(false) if(false)
{ {
FILE *file = fopen(TRACE_OUTPUT_FILE, "a"); FILE *file = fopen("debug.txt", "a");
if(file) if(file)
{ {
vfprintf(file, format, args);
fclose(file);
}
}
#endif
}
void trace(const char *format, ...)
{
va_list vararg;
va_start(vararg, format);
tracev(format, vararg);
va_end(vararg);
}
void warn(const char *format, ...)
{
va_list vararg;
va_start(vararg, format);
tracev(format, vararg);
va_end(vararg);
va_start(vararg, format);
vfprintf(stderr, format, vararg);
va_end(vararg);
}
void abort(const char *format, ...)
{
va_list vararg; va_list vararg;
va_start(vararg, format);
tracev(format, vararg);
va_end(vararg);
va_start(vararg, format); va_start(vararg, format);
vfprintf(stderr, format, vararg); vfprintf(file, format, vararg);
va_end(vararg); va_end(vararg);
::abort(); fclose(file);
}
}
} }
} }
...@@ -27,85 +27,77 @@ ...@@ -27,85 +27,77 @@
namespace vk namespace vk
{ {
// Outputs text to the debugging log // Outputs text to the debugging log
void trace(const char *format, ...); void trace(const char *format, ...);
inline void trace() {} inline void trace() {}
// Outputs text to the debugging log and prints to stderr.
void warn(const char *format, ...);
inline void warn() {}
// Outputs the message to the debugging log and stderr, and calls abort().
void abort(const char *format, ...);
} }
// A macro to output a trace of a function call and its arguments to the // A macro to output a trace of a function call and its arguments to the debugging log
// debugging log. Disabled if SWIFTSHADER_DISABLE_TRACE is defined.
#if defined(SWIFTSHADER_DISABLE_TRACE) #if defined(SWIFTSHADER_DISABLE_TRACE)
#define TRACE(message, ...) (void(0)) #define TRACE(message, ...) (void(0))
#else #else
#define TRACE(message, ...) vk::trace("%s:%d TRACE: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__) #define TRACE(message, ...) vk::trace("trace: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
#endif #endif
// A macro to print a warning message to the debugging log and stderr to denote // A macro to output a function call and its arguments to the debugging log, to denote an item in need of fixing.
// an issue that needs fixing. #if defined(SWIFTSHADER_DISABLE_TRACE)
#define FIXME(message, ...) vk::warn("%s:%d FIXME: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__); #define FIXME(message, ...) (void(0))
// 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(...) ABORT(__VA_ARGS__)
#else #else
#define DABORT(...) WARN(__VA_ARGS__) #define FIXME(message, ...) do {vk::trace("fixme: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); assert(false); abort();} while(false)
#endif #endif
// A macro asserting a condition. // A macro to output a function call and its arguments to the debugging log, in case of error.
// If the condition fails, the condition and message is passed to DABORT(). #if defined(SWIFTSHADER_DISABLE_TRACE)
#undef ASSERT_MSG #define ERR(message, ...) (void(0))
#define ASSERT_MSG(expression, format, ...) do { \ #else
if(!(expression)) { \ #define ERR(message, ...) do {vk::trace("err: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); assert(false); abort();} while(false)
DABORT("ASSERT(%s): " format "\n", #expression, ##__VA_ARGS__); \ #endif
} } while(0)
// A macro asserting a condition. // A macro asserting a condition and outputting failures to the debug log
// If the condition fails, the condition is passed to DABORT().
#undef ASSERT #undef ASSERT
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#define ASSERT(expression) do { \ #define ASSERT(expression) do { \
if(!(expression)) { \ if(!(expression)) { \
DABORT("ASSERT(%s)\n", #expression); \ ERR("\t! Assert failed in %s(%d): "#expression"\n", __FUNCTION__, __LINE__); \
assert(expression); \
abort(); \
} } while(0) } } while(0)
#else
#define ASSERT(expression) (void(0))
#endif
// A macro to indicate unimplemented functionality. // A macro to indicate unimplemented functionality
#undef UNIMPLEMENTED #undef UNIMPLEMENTED
#define UNIMPLEMENTED(...) DABORT("UNIMPLEMENTED! " __VA_ARGS__) #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#define UNIMPLEMENTED(...) do { \
vk::trace("\t! Unimplemented: %s(%d): ", __FUNCTION__, __LINE__); \
vk::trace(__VA_ARGS__); \
vk::trace("\n"); \
assert(false); \
abort(); \
} while(0)
#else
#define UNIMPLEMENTED(...) FIXME("\t! Unimplemented: %s(%d)\n", __FUNCTION__, __LINE__)
#endif
// A macro for code which is not expected to be reached under valid assumptions. // A macro for code which is not expected to be reached under valid assumptions
#undef UNREACHABLE #undef UNREACHABLE
#define UNREACHABLE(...) DABORT("UNREACHABLE! " __VA_ARGS__)
// A macro asserting a condition and performing a return.
#undef ASSERT_OR_RETURN
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#define ASSERT_OR_RETURN(expression) ASSERT(expression) #define UNREACHABLE(value) do { \
ERR("\t! Unreachable case reached: %s(%d). %s: %d\n", __FUNCTION__, __LINE__, #value, value); \
assert(false); \
abort(); \
} while(0)
#else #else
#define UNREACHABLE(value) ERR("\t! Unreachable reached: %s(%d). %s: %d\n", __FUNCTION__, __LINE__, #value, value)
#endif
// A macro asserting a condition and outputting failures to the debug log, or return when in release mode.
#undef ASSERT_OR_RETURN
#define ASSERT_OR_RETURN(expression) do { \ #define ASSERT_OR_RETURN(expression) do { \
if(!(expression)) { \ if(!(expression)) { \
ASSERT(expression); \
return; \ return; \
} } while(0) } } while(0)
#endif
#endif // VK_DEBUG_H_ #endif // VK_DEBUG_H_
...@@ -655,7 +655,7 @@ void PhysicalDevice::getImageFormatProperties(VkFormat format, VkImageType type, ...@@ -655,7 +655,7 @@ void PhysicalDevice::getImageFormatProperties(VkFormat format, VkImageType type,
pImageFormatProperties->maxArrayLayers = 1; // no 3D + layers pImageFormatProperties->maxArrayLayers = 1; // no 3D + layers
break; break;
default: default:
UNREACHABLE("VkImageType: %d", int(type)); UNREACHABLE(type);
break; break;
} }
......
...@@ -192,17 +192,19 @@ std::vector<uint32_t> preprocessSpirv( ...@@ -192,17 +192,19 @@ std::vector<uint32_t> preprocessSpirv(
spvtools::Optimizer opt{SPV_ENV_VULKAN_1_1}; spvtools::Optimizer opt{SPV_ENV_VULKAN_1_1};
opt.SetMessageConsumer([](spv_message_level_t level, const char*, const spv_position_t& p, const char* m) { opt.SetMessageConsumer([](spv_message_level_t level, const char*, const spv_position_t& p, const char* m) {
const char* category = "";
switch (level) switch (level)
{ {
case SPV_MSG_FATAL: category = "FATAL"; break; case SPV_MSG_FATAL:
case SPV_MSG_INTERNAL_ERROR: category = "INTERNAL_ERROR"; break; case SPV_MSG_INTERNAL_ERROR:
case SPV_MSG_ERROR: category = "ERROR"; break; case SPV_MSG_ERROR:
case SPV_MSG_WARNING: category = "WARNING"; break; ERR("%d:%d %s", p.line, p.column, m);
case SPV_MSG_INFO: category = "INFO"; break; break;
case SPV_MSG_DEBUG: category = "DEBUG"; break; case SPV_MSG_WARNING:
case SPV_MSG_INFO:
case SPV_MSG_DEBUG:
TRACE("%d:%d %s", p.line, p.column, m);
break;
} }
vk::trace("%s: %d:%d %s", category, p.line, p.column, m);
}); });
opt.RegisterPass(spvtools::CreateInlineExhaustivePass()); opt.RegisterPass(spvtools::CreateInlineExhaustivePass());
......
...@@ -1737,7 +1737,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetDeviceGroupPeerMemoryFeatures(VkDevice device, u ...@@ -1737,7 +1737,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetDeviceGroupPeerMemoryFeatures(VkDevice device, u
device, heapIndex, localDeviceIndex, remoteDeviceIndex, pPeerMemoryFeatures); device, heapIndex, localDeviceIndex, remoteDeviceIndex, pPeerMemoryFeatures);
ASSERT(localDeviceIndex != remoteDeviceIndex); // "localDeviceIndex must not equal remoteDeviceIndex" ASSERT(localDeviceIndex != remoteDeviceIndex); // "localDeviceIndex must not equal remoteDeviceIndex"
UNREACHABLE("remoteDeviceIndex: %d", int(remoteDeviceIndex)); // Only one physical device is supported, and since the device indexes can't be equal, this should never be called. UNREACHABLE(remoteDeviceIndex); // Only one physical device is supported, and since the device indexes can't be equal, this should never be called.
} }
VKAPI_ATTR void VKAPI_CALL vkCmdSetDeviceMask(VkCommandBuffer commandBuffer, uint32_t deviceMask) VKAPI_ATTR void VKAPI_CALL vkCmdSetDeviceMask(VkCommandBuffer commandBuffer, uint32_t deviceMask)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment