mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 10:35:43 -05:00
Added more info to fatal messages.
This commit is contained in:
parent
58a4549dce
commit
82335a6be1
3 changed files with 37 additions and 12 deletions
16
src/bgfx.cpp
16
src/bgfx.cpp
|
@ -47,6 +47,20 @@ namespace bgfx
|
|||
static BX_THREAD uint32_t s_threadIndex = 0;
|
||||
static Context s_ctx;
|
||||
|
||||
void fatal(bgfx::Fatal::Enum _code, const char* _format, ...)
|
||||
{
|
||||
char temp[8192];
|
||||
|
||||
va_list argList;
|
||||
va_start(argList, _format);
|
||||
vsnprintf(temp, sizeof(temp), _format, argList);
|
||||
va_end(argList);
|
||||
|
||||
temp[sizeof(temp)-1] = '\0';
|
||||
|
||||
g_fatal(_code, temp);
|
||||
}
|
||||
|
||||
inline void vec_mul_mtx(float* __restrict _result, const float* __restrict _vec, const float* __restrict _mat)
|
||||
{
|
||||
_result[0] = _vec[0] * _mat[ 0] + _vec[1] * _mat[4] + _vec[2] * _mat[ 8] + _vec[3] * _mat[12];
|
||||
|
@ -696,7 +710,7 @@ namespace bgfx
|
|||
return mem;
|
||||
}
|
||||
|
||||
void free(Memory* _mem)
|
||||
void release(Memory* _mem)
|
||||
{
|
||||
g_free(_mem);
|
||||
}
|
||||
|
|
19
src/bgfx_p.h
19
src/bgfx_p.h
|
@ -34,11 +34,11 @@ extern void dbgPrintfData(const void* _data, uint32_t _size, const char* _format
|
|||
} while(0)
|
||||
#endif // 0
|
||||
|
||||
#define BGFX_FATAL(_condition, _err, _str) \
|
||||
#define BGFX_FATAL(_condition, _err, _format, ...) \
|
||||
do { \
|
||||
if (!(_condition) ) \
|
||||
{ \
|
||||
g_fatal(_err, _str); \
|
||||
fatal(_err, _format, ##__VA_ARGS__); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
@ -204,7 +204,8 @@ namespace bgfx
|
|||
extern fatalFn g_fatal;
|
||||
extern reallocFn g_realloc;
|
||||
extern freeFn g_free;
|
||||
extern void free(Memory* _mem);
|
||||
extern void fatal(bgfx::Fatal::Enum _code, const char* _format, ...);
|
||||
extern void release(Memory* _mem);
|
||||
extern void saveTga(const char* _filePath, uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _data);
|
||||
extern const char* getAttribName(Attrib::Enum _attr);
|
||||
|
||||
|
@ -2065,7 +2066,7 @@ namespace bgfx
|
|||
|
||||
rendererCreateIndexBuffer(handle, mem);
|
||||
|
||||
free(mem);
|
||||
release(mem);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2133,7 +2134,7 @@ namespace bgfx
|
|||
|
||||
rendererCreateVertexBuffer(handle, mem, declHandle);
|
||||
|
||||
free(mem);
|
||||
release(mem);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2177,7 +2178,7 @@ namespace bgfx
|
|||
|
||||
rendererCreateVertexShader(handle, mem);
|
||||
|
||||
free(mem);
|
||||
release(mem);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2200,7 +2201,7 @@ namespace bgfx
|
|||
|
||||
rendererCreateFragmentShader(handle, mem);
|
||||
|
||||
free(mem);
|
||||
release(mem);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2250,7 +2251,7 @@ namespace bgfx
|
|||
|
||||
rendererCreateTexture(handle, mem, flags);
|
||||
|
||||
free(mem);
|
||||
release(mem);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -2328,7 +2329,7 @@ namespace bgfx
|
|||
|
||||
rendererSaveScreenShot(mem);
|
||||
|
||||
free(mem);
|
||||
release(mem);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -188,8 +188,18 @@ namespace bgfx
|
|||
BGFX_FATAL( (D3DPTEXTURECAPS_SQUAREONLY & m_caps.TextureCaps) == 0, bgfx::Fatal::MinimumRequiredSpecs, "D3DPTEXTURECAPS_SQUAREONLY");
|
||||
BGFX_FATAL( (D3DPTEXTURECAPS_MIPMAP & m_caps.TextureCaps) == D3DPTEXTURECAPS_MIPMAP, bgfx::Fatal::MinimumRequiredSpecs, "D3DPTEXTURECAPS_MIPMAP");
|
||||
BGFX_FATAL( (D3DPTEXTURECAPS_ALPHA & m_caps.TextureCaps) == D3DPTEXTURECAPS_ALPHA, bgfx::Fatal::MinimumRequiredSpecs, "D3DPTEXTURECAPS_ALPHA");
|
||||
BGFX_FATAL( (m_caps.VertexShaderVersion&0x300) == 0x300 && (m_caps.PixelShaderVersion&0x300) == 0x300, bgfx::Fatal::MinimumRequiredSpecs, "Shader Version is not 3.0.");
|
||||
BGFX_FATAL(m_caps.MaxTextureWidth >= 2048 && m_caps.MaxTextureHeight >= 2048, bgfx::Fatal::MinimumRequiredSpecs, "Maximum texture size is below 2048.");
|
||||
BGFX_FATAL(m_caps.VertexShaderVersion >= D3DVS_VERSION(3, 0) && m_caps.PixelShaderVersion >= D3DPS_VERSION(3, 0)
|
||||
, bgfx::Fatal::MinimumRequiredSpecs
|
||||
, "Shader Version is not 3.0 (vs: %x, ps: %x)."
|
||||
, m_caps.VertexShaderVersion
|
||||
, m_caps.PixelShaderVersion
|
||||
);
|
||||
BGFX_FATAL(m_caps.MaxTextureWidth >= 2048 && m_caps.MaxTextureHeight >= 2048
|
||||
, bgfx::Fatal::MinimumRequiredSpecs
|
||||
, "Maximum texture size is below 2048 (w: %d, h: %d)."
|
||||
, m_caps.MaxTextureWidth
|
||||
, m_caps.MaxTextureHeight
|
||||
);
|
||||
|
||||
m_fmtNULL = SUCCEEDED(m_d3d9->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_NULL) );
|
||||
m_fmtDF16 = SUCCEEDED(m_d3d9->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_TEXTURE, D3DFMT_DF16) );
|
||||
|
|
Loading…
Reference in a new issue