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
mainBlockId = Block::ID(it.word(1));
break;
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
......@@ -402,7 +402,7 @@ namespace sw
break;
default:
UNIMPLEMENTED("%s", OpcodeName(insn.opcode()).c_str());
UNIMPLEMENTED(OpcodeName(insn.opcode()).c_str());
}
}
}
......@@ -1202,7 +1202,7 @@ namespace sw
break;
default:
UNIMPLEMENTED("opcode: %s", OpcodeName(insn.opcode()).c_str());
UNIMPLEMENTED(OpcodeName(insn.opcode()).c_str());
break;
}
}
......
......@@ -392,14 +392,14 @@ namespace sw
Type const &getType(Type::ID id) const
{
auto it = types.find(id);
ASSERT_MSG(it != types.end(), "Unknown type %d", id.value());
ASSERT(it != types.end());
return it->second;
}
Object const &getObject(Object::ID id) const
{
auto it = defs.find(id);
ASSERT_MSG(it != defs.end(), "Unknown object %d", id.value());
ASSERT(it != defs.end());
return it->second;
}
......
......@@ -14,61 +14,25 @@
#include "VkDebug.hpp"
#include <string>
#include <stdarg.h>
namespace vk
{
void tracev(const char *format, va_list args)
void trace(const char *format, ...)
{
#ifndef SWIFTSHADER_DISABLE_TRACE
if(false)
{
FILE *file = fopen(TRACE_OUTPUT_FILE, "a");
FILE *file = fopen("debug.txt", "a");
if(file)
{
vfprintf(file, format, args);
va_list vararg;
va_start(vararg, format);
vfprintf(file, format, vararg);
va_end(vararg);
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_start(vararg, format);
tracev(format, vararg);
va_end(vararg);
va_start(vararg, format);
vfprintf(stderr, format, vararg);
va_end(vararg);
::abort();
}
}
......@@ -27,85 +27,77 @@
namespace vk
{
// Outputs text to the debugging log
void trace(const char *format, ...);
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, ...);
// Outputs text to the debugging log
void trace(const char *format, ...);
inline void trace() {}
}
// A macro to output a trace of a function call and its arguments to the
// debugging log. Disabled if SWIFTSHADER_DISABLE_TRACE is defined.
// A macro to output a trace of a function call and its arguments to the debugging log
#if defined(SWIFTSHADER_DISABLE_TRACE)
#define TRACE(message, ...) (void(0))
#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
// 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(...) ABORT(__VA_ARGS__)
// A macro to output a function call and its arguments to the debugging log, to denote an item in need of fixing.
#if defined(SWIFTSHADER_DISABLE_TRACE)
#define FIXME(message, ...) (void(0))
#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
// 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 to output a function call and its arguments to the debugging log, in case of error.
#if defined(SWIFTSHADER_DISABLE_TRACE)
#define ERR(message, ...) (void(0))
#else
#define ERR(message, ...) do {vk::trace("err: %s(%d): " message "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__); assert(false); abort();} while(false)
#endif
// A macro asserting a condition.
// If the condition fails, the condition is passed to DABORT().
// A macro asserting a condition and outputting failures to the debug log
#undef ASSERT
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
#define ASSERT(expression) do { \
if(!(expression)) { \
DABORT("ASSERT(%s)\n", #expression); \
ERR("\t! Assert failed in %s(%d): "#expression"\n", __FUNCTION__, __LINE__); \
assert(expression); \
abort(); \
} } while(0)
#else
#define ASSERT(expression) (void(0))
#endif
// A macro to indicate unimplemented functionality.
// A macro to indicate unimplemented functionality
#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
#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)
#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
#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 { \
if(!(expression)) { \
ASSERT(expression); \
return; \
} } while(0)
#endif
#endif // VK_DEBUG_H_
......@@ -655,7 +655,7 @@ void PhysicalDevice::getImageFormatProperties(VkFormat format, VkImageType type,
pImageFormatProperties->maxArrayLayers = 1; // no 3D + layers
break;
default:
UNREACHABLE("VkImageType: %d", int(type));
UNREACHABLE(type);
break;
}
......
......@@ -192,17 +192,19 @@ std::vector<uint32_t> preprocessSpirv(
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) {
const char* category = "";
switch (level)
{
case SPV_MSG_FATAL: category = "FATAL"; break;
case SPV_MSG_INTERNAL_ERROR: category = "INTERNAL_ERROR"; break;
case SPV_MSG_ERROR: category = "ERROR"; break;
case SPV_MSG_WARNING: category = "WARNING"; break;
case SPV_MSG_INFO: category = "INFO"; break;
case SPV_MSG_DEBUG: category = "DEBUG"; break;
case SPV_MSG_FATAL:
case SPV_MSG_INTERNAL_ERROR:
case SPV_MSG_ERROR:
ERR("%d:%d %s", p.line, p.column, m);
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());
......
......@@ -1737,7 +1737,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetDeviceGroupPeerMemoryFeatures(VkDevice device, u
device, heapIndex, localDeviceIndex, remoteDeviceIndex, pPeerMemoryFeatures);
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)
......
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