Make asserts more robust.
Add SWR_INVALID(...) as a replacement for SWR_ASSERT(0, ...)
Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
return pManager;
}
- SWR_ASSERT(0, "Failed to register thread.");
+ SWR_INVALID("Failed to register thread.");
return nullptr;
}
private:
// Handlers stay registered for life
- void Detach(EventHandler* pHandler) { SWR_ASSERT(0); }
+ void Detach(EventHandler* pHandler) { SWR_INVALID("Should not be called"); }
std::vector<EventHandler*> mHandlers;
};
#pragma comment(lib, "user32.lib")
#endif // _WIN32
-enum TextColor
-{
- TEXT_BLACK = 0,
- TEXT_RED = 1,
- TEXT_GREEN = 2,
- TEXT_BLUE = 4,
- TEXT_PURPLE = TEXT_RED | TEXT_BLUE,
- TEXT_CYAN = TEXT_GREEN | TEXT_BLUE,
- TEXT_YELLOW = TEXT_RED | TEXT_GREEN,
- TEXT_WHITE = TEXT_RED | TEXT_GREEN | TEXT_BLUE,
-};
-
-enum TextStyle
-{
- TEXT_NORMAL = 0,
- TEXT_INTENSITY = 1,
-};
-
-void SetTextColor(FILE* stream, TextColor color = TEXT_WHITE, TextStyle style = TEXT_NORMAL)
+namespace ConsoleUtils
{
+ enum class TextColor
+ {
+ BLACK = 0,
#if defined(_WIN32)
+ RED = 4,
+ GREEN = 2,
+ BLUE = 1,
+#else
+ RED = 1,
+ GREEN = 2,
+ BLUE = 4,
+#endif // _WIN32
+ PURPLE = static_cast<uint32_t>(RED) | static_cast<uint32_t>(BLUE),
+ CYAN = static_cast<uint32_t>(GREEN) | static_cast<uint32_t>(BLUE),
+ YELLOW = static_cast<uint32_t>(RED) | static_cast<uint32_t>(GREEN),
+ WHITE = static_cast<uint32_t>(RED) | static_cast<uint32_t>(GREEN) | static_cast<uint32_t>(BLUE),
+ };
- HANDLE hConsoleHandle = nullptr;
- if (stream == stderr)
- {
- hConsoleHandle = GetStdHandle(STD_ERROR_HANDLE);
- }
- else if (stream == stdout)
- {
- hConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
- }
- else
+ enum class TextStyle
{
- // Not a console stream, do nothing
- return;
- }
+ NORMAL = 0,
+ INTENSITY = 1,
+ };
- WORD textAttributes = 0;
- if (color & TEXT_RED)
- {
- textAttributes |= FOREGROUND_RED;
- }
- if (color & TEXT_GREEN)
- {
- textAttributes |= FOREGROUND_GREEN;
- }
- if (color & TEXT_BLUE)
- {
- textAttributes |= FOREGROUND_BLUE;
- }
- if (style & TEXT_INTENSITY)
+ void SetTextColor(FILE* stream, TextColor color = TextColor::WHITE, TextStyle style = TextStyle::NORMAL)
{
- textAttributes |= FOREGROUND_INTENSITY;
- }
- SetConsoleTextAttribute(hConsoleHandle, textAttributes);
+#if defined(_WIN32)
+
+ HANDLE hConsoleHandle = nullptr;
+ if (stream == stderr)
+ {
+ hConsoleHandle = GetStdHandle(STD_ERROR_HANDLE);
+ }
+ else if (stream == stdout)
+ {
+ hConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
+ }
+ else
+ {
+ // Not a console stream, do nothing
+ return;
+ }
+
+ WORD textAttributes = static_cast<WORD>(color);
+ if (style == TextStyle::INTENSITY)
+ {
+ textAttributes |= FOREGROUND_INTENSITY;
+ }
+ SetConsoleTextAttribute(hConsoleHandle, textAttributes);
#else // !_WIN32
- // Print ANSI codes
- uint32_t cc = 30 + (style ? 60 : 0) + color;
- fprintf(stream, "\033[0m\033[%d;%dm", style, cc);
+ // Print ANSI codes
+ uint32_t cc = 30 + ((style == TextStyle::INTENSITY) ? 60 : 0) + static_cast<uint32_t>(color);
+ fprintf(stream, "\033[0m\033[%d;%dm", static_cast<uint32_t>(style), cc);
#endif
-}
+ }
-void ResetTextColor(FILE* stream)
-{
+ void ResetTextColor(FILE* stream)
+ {
#if defined(_WIN32)
- SetTextColor(stream);
+ SetTextColor(stream);
#else // !_WIN32
- // Print ANSI codes
- fprintf(stream, "\033[0m");
+ // Print ANSI codes
+ fprintf(stream, "\033[0m");
#endif
-}
+ }
-static std::mutex g_stderrMutex;
+ static std::mutex g_stderrMutex;
+} // ns ConsoleUtils
-void SwrTrace(
- const char* pFileName,
- uint32_t lineNum,
- const char* function,
- const char* pFmtString,
- ...)
+bool SwrAssert(
+ bool chkDebugger,
+ bool& enabled,
+ const char* pExpression,
+ const char* pFileName,
+ uint32_t lineNum,
+ const char* pFunction,
+ const char* pFmtString,
+ ...)
{
+ using namespace ConsoleUtils;
std::lock_guard<std::mutex> l(g_stderrMutex);
- SetTextColor(stderr, TEXT_CYAN, TEXT_NORMAL);
+ SetTextColor(stderr, TextColor::CYAN, TextStyle::NORMAL);
+
+ fprintf(stderr, "%s(%d): ", pFileName, lineNum);
+
+ SetTextColor(stderr, TextColor::RED, TextStyle::INTENSITY);
+
+ fprintf(stderr, "ASSERT: %s\n", pExpression);
- fprintf(stderr, "%s(%d): TRACE in %s:\n", pFileName, lineNum, function);
+ SetTextColor(stderr, TextColor::CYAN, TextStyle::INTENSITY);
+ fprintf(stderr, "\t%s\n", pFunction);
if (pFmtString)
{
- SetTextColor(stderr, TEXT_PURPLE, TEXT_INTENSITY);
+ SetTextColor(stderr, TextColor::YELLOW, TextStyle::INTENSITY);
fprintf(stderr, "\t");
va_list args;
va_start(args, pFmtString);
ResetTextColor(stderr);
fflush(stderr);
-#if defined(_WIN32)
- static const int MAX_MESSAGE_LEN = 2048;
- char msgBuf[MAX_MESSAGE_LEN];
-
- sprintf_s(msgBuf, "%s(%d): TRACE in %s\n", pFileName, lineNum, function);
- msgBuf[MAX_MESSAGE_LEN - 2] = '\n';
- msgBuf[MAX_MESSAGE_LEN - 1] = 0;
- OutputDebugStringA(msgBuf);
-
- int offset = 0;
-
- if (pFmtString)
- {
- va_list args;
- va_start(args, pFmtString);
- offset = _vsnprintf_s(
- msgBuf,
- sizeof(msgBuf),
- sizeof(msgBuf),
- pFmtString,
- args);
- va_end(args);
-
- if (offset < 0) { return; }
-
- OutputDebugStringA("\t");
- OutputDebugStringA(msgBuf);
- OutputDebugStringA("\n");
- }
-#endif // _WIN32
-}
-
-bool SwrAssert(
- bool chkDebugger,
- bool& enabled,
- const char* pExpression,
- const char* pFileName,
- uint32_t lineNum,
- const char* pFunction,
- const char* pFmtString /* = nullptr */,
- ...)
-{
- {
- std::lock_guard<std::mutex> l(g_stderrMutex);
-
- SetTextColor(stderr, TEXT_CYAN, TEXT_NORMAL);
-
- fprintf(stderr, "%s(%d): ", pFileName, lineNum);
-
- SetTextColor(stderr, TEXT_RED, TEXT_INTENSITY);
-
- fprintf(stderr, "ASSERT: %s\n", pExpression);
-
- SetTextColor(stderr, TEXT_CYAN, TEXT_INTENSITY);
- fprintf(stderr, "\t%s\n", pFunction);
-
- if (pFmtString)
- {
- SetTextColor(stderr, TEXT_YELLOW, TEXT_INTENSITY);
- fprintf(stderr, "\t");
- va_list args;
- va_start(args, pFmtString);
- vfprintf(stderr, pFmtString, args);
- va_end(args);
- fprintf(stderr, "\n");
- }
- ResetTextColor(stderr);
- fflush(stderr);
- }
-
#if defined(_WIN32)
static const int MAX_MESSAGE_LEN = 2048;
char msgBuf[MAX_MESSAGE_LEN];
va_list args;
va_start(args, pFmtString);
offset = _vsnprintf_s(
- msgBuf,
- sizeof(msgBuf),
- sizeof(msgBuf),
- pFmtString,
- args);
+ msgBuf,
+ sizeof(msgBuf),
+ sizeof(msgBuf),
+ pFmtString,
+ args);
va_end(args);
if (offset < 0) { return true; }
if (enabled && KNOB_ENABLE_ASSERT_DIALOGS)
{
int retval = sprintf_s(
- &msgBuf[offset],
- MAX_MESSAGE_LEN - offset,
- "\n\n"
- "File: %s\n"
- "Line: %d\n"
- "\n"
- "Expression: %s\n\n"
- "Cancel: Disable this assert for the remainder of the process\n"
- "Try Again: Break into the debugger\n"
- "Continue: Continue execution (but leave assert enabled)",
- pFileName,
- lineNum,
- pExpression);
+ &msgBuf[offset],
+ MAX_MESSAGE_LEN - offset,
+ "\n\n"
+ "File: %s\n"
+ "Line: %d\n"
+ "\n"
+ "Expression: %s\n\n"
+ "Cancel: Disable this assert for the remainder of the process\n"
+ "Try Again: Break into the debugger\n"
+ "Continue: Continue execution (but leave assert enabled)",
+ pFileName,
+ lineNum,
+ pExpression);
if (retval < 0) { return true; }
if (!IsDebuggerPresent())
{
sprintf_s(
- &msgBuf[offset],
- MAX_MESSAGE_LEN - offset,
- "\n\n*** NO DEBUGGER DETECTED ***\n\nPressing \"Try Again\" will cause a program crash!");
+ &msgBuf[offset],
+ MAX_MESSAGE_LEN - offset,
+ "\n\n*** NO DEBUGGER DETECTED ***\n\nPressing \"Try Again\" will cause a program crash!");
}
retval = MessageBoxA(nullptr, msgBuf, "Assert Failed", MB_CANCELTRYCONTINUE | MB_ICONEXCLAMATION | MB_SETFOREGROUND);
switch (retval)
{
- case IDCANCEL:
- enabled = false;
- return false;
+ case IDCANCEL:
+ enabled = false;
+ return false;
- case IDTRYAGAIN:
- return true;
+ case IDTRYAGAIN:
+ return true;
- case IDCONTINUE:
- return false;
+ case IDCONTINUE:
+ return false;
}
}
else
return enabled;
}
+void SwrTrace(
+ const char* pFileName,
+ uint32_t lineNum,
+ const char* pFunction,
+ const char* pFmtString,
+ ...)
+{
+ using namespace ConsoleUtils;
+ std::lock_guard<std::mutex> l(g_stderrMutex);
+
+ SetTextColor(stderr, TextColor::CYAN, TextStyle::NORMAL);
+
+ fprintf(stderr, "%s(%d): TRACE in %s:\n", pFileName, lineNum, pFunction);
+
+ if (pFmtString)
+ {
+ SetTextColor(stderr, TextColor::PURPLE, TextStyle::INTENSITY);
+ fprintf(stderr, "\t");
+ va_list args;
+ va_start(args, pFmtString);
+ vfprintf(stderr, pFmtString, args);
+ va_end(args);
+ fprintf(stderr, "\n");
+ }
+ ResetTextColor(stderr);
+ fflush(stderr);
+
+#if defined(_WIN32)
+ static const int MAX_MESSAGE_LEN = 2048;
+ char msgBuf[MAX_MESSAGE_LEN];
+
+ sprintf_s(msgBuf, "%s(%d): TRACE in %s\n", pFileName, lineNum, pFunction);
+ msgBuf[MAX_MESSAGE_LEN - 2] = '\n';
+ msgBuf[MAX_MESSAGE_LEN - 1] = 0;
+ OutputDebugStringA(msgBuf);
+
+ int offset = 0;
+
+ if (pFmtString)
+ {
+ va_list args;
+ va_start(args, pFmtString);
+ offset = _vsnprintf_s(
+ msgBuf,
+ sizeof(msgBuf),
+ sizeof(msgBuf),
+ pFmtString,
+ args);
+ va_end(args);
+
+ if (offset < 0) { return; }
+
+ OutputDebugStringA("\t");
+ OutputDebugStringA(msgBuf);
+ OutputDebugStringA("\n");
+ }
+#endif // _WIN32
+}
+
#endif // SWR_ENABLE_ASSERTS
//
//=============================================================================
+// Stupid preprocessor tricks to avoid -Wall / -W4 warnings
+#if defined(_MSC_VER)
+#define _SWR_WARN_DISABLE __pragma(warning(push)) __pragma(warning(disable:4127))
+#define _SWR_WARN_RESTORE __pragma(warning(pop))
+#else // ! MSVC compiler
+#define _SWR_WARN_DISABLE
+#define _SWR_WARN_RESTORE
+#endif
+
+#define _SWR_MACRO_START do {
+#define _SWR_MACRO_END \
+ _SWR_WARN_DISABLE \
+ } while(0) \
+ _SWR_WARN_RESTORE
+
+
#if defined(_WIN32)
-#define SWR_ASSUME(e, ...) __assume(e)
+#define SWR_ASSUME(e, ...) _SWR_MACRO_START __assume(e); _SWR_MACRO_END
#elif defined(__clang__)
-#define SWR_ASSUME(e, ...) __builtin_assume(e)
+#define SWR_ASSUME(e, ...) _SWR_MACRO_START __builtin_assume(e); _SWR_MACRO_END
#elif defined(__GNUC__)
-#define SWR_ASSUME(e, ...) ((e) ? ((void)0) : __builtin_unreachable())
+#define SWR_ASSUME(e, ...) _SWR_MACRO_START ((e) ? ((void)0) : __builtin_unreachable()); _SWR_MACRO_END
#else
-#define SWR_ASSUME(e, ...) ASSUME(e)
+#define SWR_ASSUME(e, ...) _SWR_MACRO_START ASSUME(e); _SWR_MACRO_END
#endif
#if !defined(SWR_ENABLE_ASSERTS)
const char* pFmtString,
...);
-#define _SWR_ASSERT(chkDebugger, e, ...) {\
+#define _SWR_ASSERT(chkDebugger, e, ...) \
+ _SWR_MACRO_START \
bool expFailed = !(e);\
if (expFailed) {\
static bool swrAssertEnabled = true;\
expFailed = SwrAssert(chkDebugger, swrAssertEnabled, #e, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);\
if (expFailed) { DEBUGBREAK; }\
}\
-}
+ _SWR_MACRO_END
+
+#define _SWR_INVALID(chkDebugger, ...) \
+ _SWR_MACRO_START \
+ static bool swrAssertEnabled = true;\
+ bool expFailed = SwrAssert(chkDebugger, swrAssertEnabled, "", __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);\
+ if (expFailed) { DEBUGBREAK; }\
+ _SWR_MACRO_END
#define _SWR_TRACE(_fmtstr, ...) \
SwrTrace(__FILE__, __LINE__, __FUNCTION__, _fmtstr, ##__VA_ARGS__);
#define SWR_REL_ASSERT(e, ...) _SWR_ASSERT(false, e, ##__VA_ARGS__)
#define SWR_REL_ASSUME_ASSERT(e, ...) SWR_REL_ASSERT(e, ##__VA_ARGS__)
#define SWR_REL_TRACE(_fmtstr, ...) _SWR_TRACE(_fmtstr, ##__VA_ARGS__)
+
+// SWR_INVALID is always enabled
+#define SWR_INVALID(fmtStr, ...) _SWR_INVALID(false, fmtStr, ##__VA_ARGS__)
#endif
#endif // C++
#endif // SWR_ENABLE_ASSERTS || SWR_ENABLE_REL_ASSERTS
+// Needed to allow passing bitfield members to sizeof() in disabled asserts
+template<typename T>
+static bool SwrSizeofWorkaround(T) {return false;}
+
#if !SWR_ENABLE_ASSERTS
-#define SWR_ASSERT(e, ...) (void)(0)
+#define SWR_ASSERT(e, ...) _SWR_MACRO_START (void)sizeof(SwrSizeofWorkaround(e)); _SWR_MACRO_END
#define SWR_ASSUME_ASSERT(e, ...) SWR_ASSUME(e, ##__VA_ARGS__)
-#define SWR_TRACE(_fmtstr, ...) (void)(0)
+#define SWR_TRACE(_fmtstr, ...) _SWR_MACRO_START (void)(0); _SWR_MACRO_END
#endif
#if !SWR_ENABLE_REL_ASSERTS
-#define SWR_REL_ASSERT(e, ...) (void)(0)
+#define SWR_REL_ASSERT(e, ...) _SWR_MACRO_START (void)sizeof(SwrSizeofWorkaround(e)); _SWR_MACRO_END
+#define SWR_INVALID(...) _SWR_MACRO_START (void)(0); _SWR_MACRO_END
#define SWR_REL_ASSUME_ASSERT(e, ...) SWR_ASSUME(e, ##__VA_ARGS__)
-#define SWR_REL_TRACE(_fmtstr, ...) (void)(0)
+#define SWR_REL_TRACE(_fmtstr, ...) _SWR_MACRO_START (void)(0); _SWR_MACRO_END
+#endif
+
+#if defined(_MSC_VER)
+#define SWR_FUNCTION_DECL __FUNCSIG__
+#elif (defined(__GNUC__) || defined(__clang__))
+#define SWR_FUNCTION_DECL __PRETTY_FUNCTION__
+#else
+#define SWR_FUNCTION_DECL __FUNCTION__
#endif
-#define SWR_NOT_IMPL SWR_ASSERT(0, "%s not implemented", __FUNCTION__)
+#define SWR_NOT_IMPL SWR_INVALID("%s not implemented", SWR_FUNCTION_DECL)
#endif//__SWR_ASSERT_H__
case R16_UINT: indexSize = sizeof(uint16_t); break;
case R8_UINT: indexSize = sizeof(uint8_t); break;
default:
- SWR_ASSERT(0);
+ SWR_INVALID("Invalid index buffer format: %d", pState->indexBuffer.format);
}
int draw = 0;
simdscalari &scisXmin, simdscalari &scisYmin,
simdscalari &scisXmax, simdscalari &scisYmax)
{
- SWR_ASSERT(0, "Unhandled Simd Width in Scissor Rect Gather");
+ SWR_INVALID("Unhandled Simd Width in Scissor Rect Gather");
}
};
{
#if KNOB_SIMD_WIDTH == 8
#if KNOB_ARCH==KNOB_ARCH_AVX
- SWR_ASSERT(0); // I think this may be incorrect.
+ SWR_INVALID("I think this may be incorrect.");
__m128i src = _mm_castps_si128(_mm256_castps256_ps128(in));
__m128i resLo = _mm_cvtepi8_epi32(src);
__m128i resHi = _mm_shuffle_epi8(src,
{
#if KNOB_SIMD_WIDTH == 8
#if KNOB_ARCH==KNOB_ARCH_AVX
- SWR_ASSERT(0); // I think this is incorrectly implemented
+ SWR_INVALID("I think this may be incorrect.");
__m128i src = _mm_castps_si128(_mm256_castps256_ps128(in));
__m128i resLo = _mm_cvtepi16_epi32(src);
__m128i resHi = _mm_shuffle_epi8(src,
{
static const SWR_TYPE MyType = type;
static float toFloat() { return 0.0; }
- static float fromFloat() { SWR_ASSERT(0); return 0.0; }
- static simdscalar convertSrgb(simdscalar &in) { SWR_ASSERT(0); return _simd_setzero_ps(); }
+ static float fromFloat() { SWR_NOT_IMPL; return 0.0; }
+ static simdscalar convertSrgb(simdscalar &in) { SWR_NOT_IMPL; return _simd_setzero_ps(); }
};
//////////////////////////////////////////////////////////////////////////
{
static const SWR_TYPE MyType = SWR_TYPE_UINT;
static float toFloat() { return 0.0; }
- static float fromFloat() { SWR_ASSERT(0); return 0.0; }
- static simdscalar convertSrgb(simdscalar &in) { SWR_ASSERT(0); return _simd_setzero_ps(); }
+ static float fromFloat() { SWR_NOT_IMPL; return 0.0; }
+ static simdscalar convertSrgb(simdscalar &in) { SWR_NOT_IMPL; return _simd_setzero_ps(); }
};
//////////////////////////////////////////////////////////////////////////
{
static const SWR_TYPE MyType = SWR_TYPE_SINT;
static float toFloat() { return 0.0; }
- static float fromFloat() { SWR_ASSERT(0); return 0.0; }
- static simdscalar convertSrgb(simdscalar &in) { SWR_ASSERT(0); return _simd_setzero_ps(); }
+ static float fromFloat() { SWR_NOT_IMPL; return 0.0; }
+ static simdscalar convertSrgb(simdscalar &in) { SWR_NOT_IMPL; return _simd_setzero_ps(); }
};
//////////////////////////////////////////////////////////////////////////
{
static const SWR_TYPE MyType = SWR_TYPE_UINT;
static float toFloat() { return 0.0; }
- static float fromFloat() { SWR_ASSERT(0); return 0.0; }
- static simdscalar convertSrgb(simdscalar &in) { SWR_ASSERT(0); return _simd_setzero_ps(); }
+ static float fromFloat() { SWR_NOT_IMPL; return 0.0; }
+ static simdscalar convertSrgb(simdscalar &in) { SWR_NOT_IMPL; return _simd_setzero_ps(); }
};
//////////////////////////////////////////////////////////////////////////
{
static const SWR_TYPE MyType = SWR_TYPE_SINT;
static float toFloat() { return 0.0; }
- static float fromFloat() { SWR_ASSERT(0); return 0.0; }
- static simdscalar convertSrgb(simdscalar &in) { SWR_ASSERT(0); return _simd_setzero_ps(); }
+ static float fromFloat() { SWR_NOT_IMPL; return 0.0; }
+ static simdscalar convertSrgb(simdscalar &in) { SWR_NOT_IMPL; return _simd_setzero_ps(); }
};
//////////////////////////////////////////////////////////////////////////
{
static const SWR_TYPE MyType = SWR_TYPE_UINT;
static float toFloat() { return 0.0; }
- static float fromFloat() { SWR_ASSERT(0); return 0.0; }
- static simdscalar convertSrgb(simdscalar &in) { SWR_ASSERT(0); return _simd_setzero_ps(); }
+ static float fromFloat() { SWR_NOT_IMPL; return 0.0; }
+ static simdscalar convertSrgb(simdscalar &in) { SWR_NOT_IMPL; return _simd_setzero_ps(); }
};
//////////////////////////////////////////////////////////////////////////
{
static const SWR_TYPE MyType = SWR_TYPE_SINT;
static float toFloat() { return 0.0; }
- static float fromFloat() { SWR_ASSERT(0); return 0.0; }
- static simdscalar convertSrgb(simdscalar &in) { SWR_ASSERT(0); return _simd_setzero_ps(); }
+ static float fromFloat() { SWR_NOT_IMPL; return 0.0; }
+ static simdscalar convertSrgb(simdscalar &in) { SWR_NOT_IMPL; return _simd_setzero_ps(); }
};
//////////////////////////////////////////////////////////////////////////
static const SWR_TYPE MyType = SWR_TYPE_UNORM;
static float toFloat() { return 1.0f / 31.0f; }
static float fromFloat() { return 31.0f; }
- static simdscalar convertSrgb(simdscalar &in) { SWR_ASSERT(0); return _simd_setzero_ps(); }
+ static simdscalar convertSrgb(simdscalar &in) { SWR_NOT_IMPL; return _simd_setzero_ps(); }
};
//////////////////////////////////////////////////////////////////////////
static const SWR_TYPE MyType = SWR_TYPE_UNORM;
static float toFloat() { return 1.0f / 63.0f; }
static float fromFloat() { return 63.0f; }
- static simdscalar convertSrgb(simdscalar &in) { SWR_ASSERT(0); return _simd_setzero_ps(); }
+ static simdscalar convertSrgb(simdscalar &in) { SWR_NOT_IMPL; return _simd_setzero_ps(); }
};
//////////////////////////////////////////////////////////////////////////
static const SWR_TYPE MyType = SWR_TYPE_UNORM;
static float toFloat() { return 1.0f / 255.0f; }
static float fromFloat() { return 255.0f; }
- static simdscalar convertSrgb(simdscalar &in) { SWR_ASSERT(0); return _simd_setzero_ps(); }
+ static simdscalar convertSrgb(simdscalar &in) { SWR_NOT_IMPL; return _simd_setzero_ps(); }
};
//////////////////////////////////////////////////////////////////////////
static const SWR_TYPE MyType = SWR_TYPE_SNORM;
static float toFloat() { return 1.0f / 127.0f; }
static float fromFloat() { return 127.0f; }
- static simdscalar convertSrgb(simdscalar &in) { SWR_ASSERT(0); return _simd_setzero_ps(); }
+ static simdscalar convertSrgb(simdscalar &in) { SWR_NOT_IMPL; return _simd_setzero_ps(); }
};
//////////////////////////////////////////////////////////////////////////
static const SWR_TYPE MyType = SWR_TYPE_UNORM;
static float toFloat() { return 1.0f / 65535.0f; }
static float fromFloat() { return 65535.0f; }
- static simdscalar convertSrgb(simdscalar &in) { SWR_ASSERT(0); return _simd_setzero_ps(); }
+ static simdscalar convertSrgb(simdscalar &in) { SWR_NOT_IMPL; return _simd_setzero_ps(); }
};
//////////////////////////////////////////////////////////////////////////
static const SWR_TYPE MyType = SWR_TYPE_UNORM;
static float toFloat() { return 1.0f / 32767.0f; }
static float fromFloat() { return 32767.0f; }
- static simdscalar convertSrgb(simdscalar &in) { SWR_ASSERT(0); return _simd_setzero_ps(); }
+ static simdscalar convertSrgb(simdscalar &in) { SWR_NOT_IMPL; return _simd_setzero_ps(); }
};
//////////////////////////////////////////////////////////////////////////
static const SWR_TYPE MyType = SWR_TYPE_UNORM;
static float toFloat() { return 1.0f / 16777215.0f; }
static float fromFloat() { return 16777215.0f; }
- static simdscalar convertSrgb(simdscalar &in) { SWR_ASSERT(0); return _simd_setzero_ps(); }
+ static simdscalar convertSrgb(simdscalar &in) { SWR_NOT_IMPL; return _simd_setzero_ps(); }
};
//////////////////////////////////////////////////////////////////////////
static const SWR_TYPE MyType = SWR_TYPE_FLOAT;
static float toFloat() { return 1.0f; }
static float fromFloat() { return 1.0f; }
- static simdscalar convertSrgb(simdscalar &in) { SWR_ASSERT(0); return _simd_setzero_ps(); }
+ static simdscalar convertSrgb(simdscalar &in) { SWR_NOT_IMPL; return _simd_setzero_ps(); }
static simdscalar pack(const simdscalar &in)
{
static simdscalar unpack(const simdscalar &in)
{
// input is 8 packed float16, output is 8 packed float32
- SWR_ASSERT(0); // @todo
+ SWR_NOT_IMPL; // @todo
return _simd_setzero_ps();
}
#if ENABLE_AVX512_SIMD16
static simd16scalar unpack(const simd16scalar &in)
{
// input is 16 packed float16, output is 16 packed float32
- SWR_ASSERT(0); // @todo
+ SWR_NOT_IMPL; // @todo
return _simd16_setzero_ps();
}
#endif
case 3:
return (W == SWR_TYPE_UNORM || W == SWR_TYPE_SNORM) ? true : false;
}
- SWR_ASSERT(0);
+ SWR_INVALID("Invalid component: %d", comp);
return false;
}
case 3:
return TypeTraits<W, NumBitsW>::toFloat();
}
- SWR_ASSERT(0);
+ SWR_INVALID("Invalid component: %d", comp);
return TypeTraits<X, NumBitsX>::toFloat();
}
case 3:
return TypeTraits<W, NumBitsW>::fromFloat();
}
- SWR_ASSERT(0);
+ SWR_INVALID("Invalid component: %d", comp);
return TypeTraits<X, NumBitsX>::fromFloat();
}
case 3:
return TypeTraits<W, NumBitsW>::loadSOA(pSrc);
}
- SWR_ASSERT(0);
+ SWR_INVALID("Invalid component: %d", comp);
return TypeTraits<X, NumBitsX>::loadSOA(pSrc);
}
TypeTraits<W, NumBitsW>::storeSOA(pDst, src);
return;
}
- SWR_ASSERT(0);
+ SWR_INVALID("Invalid component: %d", comp);
TypeTraits<X, NumBitsX>::storeSOA(pDst, src);
}
case 3:
return TypeTraits<W, NumBitsW>::unpack(in);
}
- SWR_ASSERT(0);
+ SWR_INVALID("Invalid component: %d", comp);
return TypeTraits<X, NumBitsX>::unpack(in);
}
case 3:
return TypeTraits<W, NumBitsW>::pack(in);
}
- SWR_ASSERT(0);
+ SWR_INVALID("Invalid component: %d", comp);
return TypeTraits<X, NumBitsX>::pack(in);
}
case 3:
return TypeTraits<W, NumBitsW>::convertSrgb(in);
}
- SWR_ASSERT(0);
+ SWR_INVALID("Invalid component: %d", comp);
return TypeTraits<X, NumBitsX>::convertSrgb(in);
}
#if ENABLE_AVX512_SIMD16
case 3:
return TypeTraits<W, NumBitsW>::loadSOA_16(pSrc);
}
- SWR_ASSERT(0);
+ SWR_INVALID("Invalid component: %d", comp);
return TypeTraits<X, NumBitsX>::loadSOA_16(pSrc);
}
TypeTraits<W, NumBitsW>::storeSOA(pDst, src);
return;
}
- SWR_ASSERT(0);
+ SWR_INVALID("Invalid component: %d", comp);
TypeTraits<X, NumBitsX>::storeSOA(pDst, src);
}
case 3:
return TypeTraits<W, NumBitsW>::unpack(in);
}
- SWR_ASSERT(0);
+ SWR_INVALID("Invalid component: %d", comp);
return TypeTraits<X, NumBitsX>::unpack(in);
}
case 3:
return TypeTraits<W, NumBitsW>::pack(in);
}
- SWR_ASSERT(0);
+ SWR_INVALID("Invalid component: %d", comp);
return TypeTraits<X, NumBitsX>::pack(in);
}
case 3:
return TypeTraits<W, NumBitsW>::convertSrgb(in);
}
- SWR_ASSERT(0);
+ SWR_INVALID("Invalid component: %d", comp);
return TypeTraits<X, NumBitsX>::convertSrgb(in);
}
#endif
simd16vector prim_simd16[3];
#endif
AR_BEGIN(FEPAAssemble, pDC->drawId);
-#if SWR_ENABLE_ASSERTS
bool assemble =
-#endif
#if USE_SIMD16_FRONTEND
tessPa.Assemble_simd16(VERTEX_POSITION_SLOT, prim_simd16);
#else
pLastRequestedIndex = (int32_t*)(&(((uint8_t*)work.pIB)[endVertex]));
break;
default:
- SWR_ASSERT(0);
+ SWR_INVALID("Invalid work.type: %d", work.type);
}
}
else
break;
default:
- SWR_ASSERT(0, "Invalid binTopology (%d) for %s", binTopology, __FUNCTION__);
+ SWR_INVALID("Invalid binTopology (%d) for %s", binTopology, __FUNCTION__);
break;
}
}
simdvector& GetSimdVector(uint32_t index, uint32_t slot)
{
- SWR_ASSERT(0, "%s NOT IMPLEMENTED", __FUNCTION__);
+ SWR_INVALID("%s NOT IMPLEMENTED", __FUNCTION__);
static simdvector junk;
return junk;
}
#if ENABLE_AVX512_SIMD16
simd16vector& GetSimdVector_simd16(uint32_t index, uint32_t slot)
{
- SWR_ASSERT(0, "%s NOT IMPLEMENTED", __FUNCTION__);
+ SWR_INVALID("%s NOT IMPLEMENTED", __FUNCTION__);
static simd16vector junk;
return junk;
}
SIMDVERTEX& GetNextVsOutput()
{
- SWR_ASSERT(0, "%s", __FUNCTION__);
+ SWR_NOT_IMPL;
static SIMDVERTEX junk;
return junk;
}
bool GetNextStreamOutput()
{
- SWR_ASSERT(0, "%s", __FUNCTION__);
+ SWR_NOT_IMPL;
return false;
}
SIMDMASK& GetNextVsIndices()
{
- SWR_ASSERT(0, "%s", __FUNCTION__);
+ SWR_NOT_IMPL;
static SIMDMASK junk;
return junk;
}
return std::min<uint32_t>(m_numPrims, SIMD_WIDTH);
}
- void Reset() { SWR_ASSERT(0); };
+ void Reset()
+ {
+ SWR_NOT_IMPL;
+ }
SIMDSCALARI GetPrimID(uint32_t startID)
{
uint32_t slot,
simdvector verts[])
{
- SWR_ASSERT(0); // Is rect list used for anything other then clears?
+ SWR_INVALID("Is rect list used for anything other then clears?");
SetNextPaState(pa, PaRectList0, PaRectListSingle0, 0, KNOB_SIMD_WIDTH, true);
return true;
}
uint32_t slot,
simd16vector verts[])
{
- SWR_ASSERT(0); // Is rect list used for anything other then clears?
+ SWR_INVALID("Is rect list used for anything other then clears?")
SetNextPaState_simd16(pa, PaRectList0_simd16, PaRectListSingle0, 0, KNOB_SIMD16_WIDTH, true);
return true;
}
case 5:
case 6:
case 7:
- SWR_ASSERT(0);
+ SWR_INVALID("Invalid primIndex: %d", primIndex);
break;
};
}
break;
default:
- SWR_ASSERT(0);
+ SWR_INVALID("Invalid topology: %d", this->binTopology);
break;
};
break;
default:
- SWR_ASSERT(0);
+ SWR_INVALID("Invalid topology: %d", this->binTopology);
break;
};
template <typename ValidEdgeMaskT>
INLINE bool TrivialRejectTest(const int, const int, const int)
{
- SWR_ASSERT(0, "Primary templated function should never be called");
+ SWR_INVALID("Primary templated function should never be called");
return false;
};
void* pContextMem,
size_t& memSize)
{
- SWR_ASSERT(0, "%s: Not Implemented", __FUNCTION__);
+ SWR_NOT_IMPL;
return NULL;
}
INLINE void SWR_API TSDestroyCtx(HANDLE tsCtx)
{
- SWR_ASSERT(0, "%s: Not Implemented", __FUNCTION__);
+ SWR_NOT_IMPL;
}
const SWR_TESSELLATION_FACTORS& tsTessFactors,
SWR_TS_TESSELLATED_DATA& tsTessellatedData)
{
- SWR_ASSERT(0, "%s: Not Implemented", __FUNCTION__);
+ SWR_NOT_IMPL;
}
#define INTEL_OUTPUT_DIR "c:\\Intel"
#define SWR_OUTPUT_DIR INTEL_OUTPUT_DIR "\\SWR"
#define JITTER_OUTPUT_DIR SWR_OUTPUT_DIR "\\Jitter"
-#endif
+#endif // _WIN32
+
using namespace llvm;
using namespace SwrJit;
SMDiagnostic Err;
std::unique_ptr<Module> newModule = parseIR(pMem.get()->getMemBufferRef(), Err, mContext);
+
SWR_REL_ASSERT(
!(newModule == nullptr),
"Parse failed!\n"
switch (info.type[i]) {
default:
- SWR_ASSERT(0, "Unsupported type for logic op\n");
+ SWR_INVALID("Unsupported type for logic op\n");
/* fallthrough */
case SWR_TYPE_UINT:
case SWR_TYPE_SINT:
switch (info.type[i]) {
default:
- SWR_ASSERT(0, "Unsupported type for logic op\n");
+ SWR_INVALID("Unsupported type for logic op\n");
/* fallthrough */
case SWR_TYPE_UINT:
case SWR_TYPE_SINT:
}
break;
default:
- SWR_ASSERT(0, "Invalid float format");
+ SWR_INVALID("Invalid float format");
break;
}
}
}
break;
default:
- SWR_ASSERT(0, "unsupported format");
+ SWR_INVALID("unsupported format");
break;
}
}
(fetchState.bDisableIndexOOBCheck) ? vIndices = LOAD(BITCAST(indices, PointerType::get(mSimdInt32Ty,0)),{(uint32_t)0})
: vIndices = GetSimdValid32bitIndices(indices, pLastIndex);
break; // incoming type is already 32bit int
- default: SWR_ASSERT(0, "Unsupported index type"); vIndices = nullptr; break;
+ default: SWR_INVALID("Unsupported index type"); vIndices = nullptr; break;
}
Value* vVertexId = vIndices;
case 16: pLoadTy = Type::getInt16PtrTy(JM()->mContext); break;
case 24:
case 32: pLoadTy = Type::getInt32PtrTy(JM()->mContext); break;
- default: SWR_ASSERT(0);
+ default: SWR_INVALID("Invalid bpp: %d", info.bpp);
}
// allocate temporary memory for masked off lanes
}
break;
default:
- SWR_ASSERT(0, "Tried to fetch invalid FP format");
+ SWR_INVALID("Tried to fetch invalid FP format");
break;
}
}
conversionFactor = VIMMED1((float)(1.0));
break;
case CONVERT_USCALED:
- SWR_ASSERT(0, "Type should not be sign extended!");
+ SWR_INVALID("Type should not be sign extended!");
conversionFactor = nullptr;
break;
default:
conversionFactor = VIMMED1((float)(1.0));
break;
case CONVERT_SSCALED:
- SWR_ASSERT(0, "Type should not be zero extended!");
+ SWR_INVALID("Type should not be zero extended!");
conversionFactor = nullptr;
break;
default:
}
else
{
- SWR_ASSERT(0, "Unsupported conversion type");
+ SWR_INVALID("Unsupported conversion type");
}
}
conversionFactor = VIMMED1((float)(1.0));
break;
case CONVERT_USCALED:
- SWR_ASSERT(0, "Type should not be sign extended!");
+ SWR_INVALID("Type should not be sign extended!");
conversionFactor = nullptr;
break;
default:
conversionFactor = VIMMED1((float)(1.0f));
break;
case CONVERT_SSCALED:
- SWR_ASSERT(0, "Type should not be zero extended!");
+ SWR_INVALID("Type should not be zero extended!");
conversionFactor = nullptr;
break;
default:
}
else
{
- SWR_ASSERT(0, "Unsupported conversion type");
+ SWR_INVALID("Unsupported conversion type");
}
}
return VBROADCAST(pId);
}
case StoreSrc:
- default: SWR_ASSERT(0, "Invalid component control"); return VUNDEF_I();
+ default: SWR_INVALID("Invalid component control"); return VUNDEF_I();
}
}
if (!file.is_open())
{
- SWR_ASSERT(0, "ArchRast: Could not open event file!");
+ SWR_INVALID("ArchRast: Could not open event file!");
return false;
}