RRenamed BX_CHECK to BX_ASSERT.

This commit is contained in:
Бранимир Караџић
2020-06-16 10:06:18 -07:00
parent ee78de075c
commit 2cbcb6ea90
42 changed files with 364 additions and 364 deletions

View File

@@ -25,10 +25,10 @@ namespace bgfx
#if BGFX_CONFIG_MULTITHREADED
# define BGFX_CHECK_API_THREAD() \
BX_CHECK(NULL != s_ctx, "Library is not initialized yet."); \
BX_CHECK(BGFX_API_THREAD_MAGIC == s_threadIndex, "Must be called from main thread.")
BX_ASSERT(NULL != s_ctx, "Library is not initialized yet."); \
BX_ASSERT(BGFX_API_THREAD_MAGIC == s_threadIndex, "Must be called from main thread.")
# define BGFX_CHECK_RENDER_THREAD() \
BX_CHECK( (NULL != s_ctx && s_ctx->m_singleThreaded) \
BX_ASSERT( (NULL != s_ctx && s_ctx->m_singleThreaded) \
|| ~BGFX_API_THREAD_MAGIC == s_threadIndex \
, "Must be called from render thread." \
)
@@ -38,7 +38,7 @@ namespace bgfx
#endif // BGFX_CONFIG_MULTITHREADED
#define BGFX_CHECK_CAPS(_caps, _msg) \
BX_CHECK(0 != (g_caps.supported & (_caps) ) \
BX_ASSERT(0 != (g_caps.supported & (_caps) ) \
, _msg " Use bgfx::getCaps to check " #_caps " backend renderer capabilities." \
);
@@ -181,7 +181,7 @@ namespace bgfx
#if BGFX_CONFIG_MEMORY_TRACKING
{
bx::MutexScope scope(m_mutex);
BX_CHECK(m_numBlocks > 0, "Number of blocks is 0. Possible alloc/free mismatch?");
BX_ASSERT(m_numBlocks > 0, "Number of blocks is 0. Possible alloc/free mismatch?");
--m_numBlocks;
}
#endif // BGFX_CONFIG_MEMORY_TRACKING
@@ -313,7 +313,7 @@ namespace bgfx
default: break;
}
BX_CHECK(false, "You should not be here.");
BX_ASSERT(false, "You should not be here.");
return "?";
}
@@ -685,7 +685,7 @@ namespace bgfx
ShaderHandle vsh = createEmbeddedShader(s_embeddedShaders, g_caps.rendererType, "vs_debugfont");
ShaderHandle fsh = createEmbeddedShader(s_embeddedShaders, g_caps.rendererType, "fs_debugfont");
BX_CHECK(isValid(vsh) && isValid(fsh), "Failed to create embedded blit shaders");
BX_ASSERT(isValid(vsh) && isValid(fsh), "Failed to create embedded blit shaders");
m_program = createProgram(vsh, fsh, true);
@@ -857,17 +857,17 @@ namespace bgfx
.end();
ShaderHandle vsh = createEmbeddedShader(s_embeddedShaders, g_caps.rendererType, "vs_clear");
BX_CHECK(isValid(vsh), "Failed to create clear quad embedded vertex shader \"vs_clear\"");
BX_ASSERT(isValid(vsh), "Failed to create clear quad embedded vertex shader \"vs_clear\"");
for (uint32_t ii = 0, num = g_caps.limits.maxFBAttachments; ii < num; ++ii)
{
char name[32];
bx::snprintf(name, BX_COUNTOF(name), "fs_clear%d", ii);
ShaderHandle fsh = createEmbeddedShader(s_embeddedShaders, g_caps.rendererType, name);
BX_CHECK(isValid(fsh), "Failed to create clear quad embedded fragment shader \"%s\"", name);
BX_ASSERT(isValid(fsh), "Failed to create clear quad embedded fragment shader \"%s\"", name);
m_program[ii] = createProgram(vsh, fsh);
BX_CHECK(isValid(m_program[ii]), "Failed to create clear quad program.");
BX_ASSERT(isValid(m_program[ii]), "Failed to create clear quad program.");
destroy(fsh);
}
@@ -882,7 +882,7 @@ namespace bgfx
const uint16_t stride = m_layout.m_stride;
const bgfx::Memory* mem = bgfx::alloc(4 * stride);
Vertex* vertex = (Vertex*)mem->data;
BX_CHECK(stride == sizeof(Vertex), "Stride/Vertex mismatch (stride %d, sizeof(Vertex) %d)", stride, sizeof(Vertex));
BX_ASSERT(stride == sizeof(Vertex), "Stride/Vertex mismatch (stride %d, sizeof(Vertex) %d)", stride, sizeof(Vertex));
vertex->m_x = -1.0f;
vertex->m_y = -1.0f;
@@ -931,7 +931,7 @@ namespace bgfx
const char* getUniformTypeName(UniformType::Enum _enum)
{
BX_CHECK(_enum < UniformType::Count, "%d < UniformType::Count %d", _enum, UniformType::Count);
BX_ASSERT(_enum < UniformType::Count, "%d < UniformType::Count %d", _enum, UniformType::Count);
return s_uniformTypeName[_enum];
}
@@ -1213,7 +1213,7 @@ namespace bgfx
if (BX_ENABLED(BGFX_CONFIG_DEBUG_OCCLUSION)
&& isValid(_occlusionQuery) )
{
BX_CHECK(m_occlusionQuerySet.end() == m_occlusionQuerySet.find(_occlusionQuery.idx)
BX_ASSERT(m_occlusionQuerySet.end() == m_occlusionQuerySet.find(_occlusionQuery.idx)
, "OcclusionQuery %d was already used for this frame."
, _occlusionQuery.idx
);
@@ -1449,7 +1449,7 @@ namespace bgfx
return result;
}
BX_CHECK(false, "This call only makes sense if used with multi-threaded renderer.");
BX_ASSERT(false, "This call only makes sense if used with multi-threaded renderer.");
return RenderFrame::NoContext;
}
@@ -1753,7 +1753,7 @@ namespace bgfx
return "Vertex";
}
BX_CHECK(false, "Invalid shader type!");
BX_ASSERT(false, "Invalid shader type!");
return NULL;
}
@@ -1790,7 +1790,7 @@ namespace bgfx
bool Context::init(const Init& _init)
{
BX_CHECK(!m_rendererInitialized, "Already initialized?");
BX_ASSERT(!m_rendererInitialized, "Already initialized?");
m_init = _init;
m_init.resolution.reset &= ~BGFX_RESET_INTERNAL_FORCE;
@@ -1877,7 +1877,7 @@ namespace bgfx
}
uint16_t idx = m_encoderHandle->alloc();
BX_CHECK(0 == idx, "Internal encoder handle is not 0 (idx %d).", idx); BX_UNUSED(idx);
BX_ASSERT(0 == idx, "Internal encoder handle is not 0 (idx %d).", idx); BX_UNUSED(idx);
m_encoder[0].begin(m_submit, 0);
m_encoder0 = reinterpret_cast<Encoder*>(&m_encoder[0]);
@@ -1981,7 +1981,7 @@ namespace bgfx
m_dynVertexBufferAllocator.compact();
m_dynIndexBufferAllocator.compact();
BX_CHECK(
BX_ASSERT(
m_layoutHandle.getNumHandles() == m_vertexLayoutRef.m_vertexLayoutMap.getNumElements()
, "VertexLayoutRef mismatch, num handles %d, handles in hash map %d."
, m_layoutHandle.getNumHandles()
@@ -2681,11 +2681,11 @@ namespace bgfx
default:
{
BX_CHECK(CommandBuffer::RendererInit == command
BX_ASSERT(CommandBuffer::RendererInit == command
, "RendererInit must be the first command in command buffer before initialization. Unexpected command %d?"
, command
);
BX_CHECK(!m_rendererInitialized, "This shouldn't happen! Bad synchronization?");
BX_ASSERT(!m_rendererInitialized, "This shouldn't happen! Bad synchronization?");
Init init;
_cmdbuf.read(init);
@@ -2697,7 +2697,7 @@ namespace bgfx
if (!m_rendererInitialized)
{
_cmdbuf.read(command);
BX_CHECK(CommandBuffer::End == command, "Unexpected command %d?"
BX_ASSERT(CommandBuffer::End == command, "Unexpected command %d?"
, command
);
return;
@@ -2716,14 +2716,14 @@ namespace bgfx
{
case CommandBuffer::RendererShutdownBegin:
{
BX_CHECK(m_rendererInitialized, "This shouldn't happen! Bad synchronization?");
BX_ASSERT(m_rendererInitialized, "This shouldn't happen! Bad synchronization?");
m_rendererInitialized = false;
}
break;
case CommandBuffer::RendererShutdownEnd:
{
BX_CHECK(!m_rendererInitialized && !m_exit, "This shouldn't happen! Bad synchronization?");
BX_ASSERT(!m_rendererInitialized && !m_exit, "This shouldn't happen! Bad synchronization?");
rendererDestroy(m_renderCtx);
m_renderCtx = NULL;
@@ -3253,7 +3253,7 @@ namespace bgfx
break;
default:
BX_CHECK(false, "Invalid command: %d", command);
BX_ASSERT(false, "Invalid command: %d", command);
break;
}
} while (!end);
@@ -3308,7 +3308,7 @@ namespace bgfx
const char* getRendererName(RendererType::Enum _type)
{
BX_CHECK(_type < RendererType::Count, "Invalid renderer type %d.", _type);
BX_ASSERT(_type < RendererType::Count, "Invalid renderer type %d.", _type);
return s_rendererCreator[_type].name;
}
@@ -3503,7 +3503,7 @@ namespace bgfx
BGFX_CHECK_API_THREAD();
Context* ctx = s_ctx; // it's going to be NULLd inside shutdown.
ctx->shutdown();
BX_CHECK(NULL == s_ctx, "bgfx is should be uninitialized here.");
BX_ASSERT(NULL == s_ctx, "bgfx is should be uninitialized here.");
BX_ALIGNED_DELETE(g_allocator, ctx, Context::kAlignment);
@@ -3535,7 +3535,7 @@ namespace bgfx
void reset(uint32_t _width, uint32_t _height, uint32_t _flags, TextureFormat::Enum _format)
{
BGFX_CHECK_API_THREAD();
BX_CHECK(0 == (_flags&BGFX_RESET_RESERVED_MASK), "Do not set reset reserved flags!");
BX_ASSERT(0 == (_flags&BGFX_RESET_RESERVED_MASK), "Do not set reset reserved flags!");
s_ctx->reset(_width, _height, _flags, _format);
}
@@ -3553,7 +3553,7 @@ namespace bgfx
void Encoder::setState(uint64_t _state, uint32_t _rgba)
{
BX_CHECK(0 == (_state&BGFX_STATE_RESERVED_MASK), "Do not set state reserved flags!");
BX_ASSERT(0 == (_state&BGFX_STATE_RESERVED_MASK), "Do not set state reserved flags!");
BGFX_ENCODER(setState(_state, _rgba) );
}
@@ -3597,8 +3597,8 @@ namespace bgfx
{
BGFX_CHECK_HANDLE("setUniform", s_ctx->m_uniformHandle, _handle);
const UniformRef& uniform = s_ctx->m_uniformRef[_handle.idx];
BX_CHECK(isValid(_handle) && 0 < uniform.m_refCount, "Setting invalid uniform (handle %3d)!", _handle.idx);
BX_CHECK(_num == UINT16_MAX || uniform.m_num >= _num, "Truncated uniform update. %d (max: %d)", _num, uniform.m_num);
BX_ASSERT(isValid(_handle) && 0 < uniform.m_refCount, "Setting invalid uniform (handle %3d)!", _handle.idx);
BX_ASSERT(_num == UINT16_MAX || uniform.m_num >= _num, "Truncated uniform update. %d (max: %d)", _num, uniform.m_num);
BGFX_ENCODER(setUniform(uniform.m_type, _handle, _value, UINT16_MAX != _num ? _num : uniform.m_num) );
}
@@ -3632,7 +3632,7 @@ namespace bgfx
void Encoder::setIndexBuffer(const TransientIndexBuffer* _tib, uint32_t _firstIndex, uint32_t _numIndices)
{
BX_CHECK(NULL != _tib, "_tib can't be NULL");
BX_ASSERT(NULL != _tib, "_tib can't be NULL");
BGFX_CHECK_HANDLE("setIndexBuffer", s_ctx->m_indexBufferHandle, _tib->handle);
BGFX_ENCODER(setIndexBuffer(_tib, _firstIndex, _numIndices) );
}
@@ -3682,7 +3682,7 @@ namespace bgfx
, VertexLayoutHandle _layoutHandle
)
{
BX_CHECK(NULL != _tvb, "_tvb can't be NULL");
BX_ASSERT(NULL != _tvb, "_tvb can't be NULL");
BGFX_CHECK_HANDLE("setVertexBuffer", s_ctx->m_vertexBufferHandle, _tvb->handle);
BGFX_CHECK_HANDLE_INVALID_OK("setVertexBuffer", s_ctx->m_layoutHandle, _layoutHandle);
BGFX_ENCODER(setVertexBuffer(_stream, _tvb, _startVertex, _numVertices, _layoutHandle) );
@@ -3706,7 +3706,7 @@ namespace bgfx
void Encoder::setInstanceDataBuffer(const InstanceDataBuffer* _idb, uint32_t _start, uint32_t _num)
{
BX_CHECK(NULL != _idb, "_idb can't be NULL");
BX_ASSERT(NULL != _idb, "_idb can't be NULL");
BGFX_ENCODER(setInstanceDataBuffer(_idb, _start, _num) );
}
@@ -3738,7 +3738,7 @@ namespace bgfx
{
BGFX_CHECK_HANDLE("setTexture/UniformHandle", s_ctx->m_uniformHandle, _sampler);
BGFX_CHECK_HANDLE_INVALID_OK("setTexture/TextureHandle", s_ctx->m_textureHandle, _handle);
BX_CHECK(_stage < g_caps.limits.maxTextureSamplers, "Invalid stage %d (max %d).", _stage, g_caps.limits.maxTextureSamplers);
BX_ASSERT(_stage < g_caps.limits.maxTextureSamplers, "Invalid stage %d (max %d).", _stage, g_caps.limits.maxTextureSamplers);
BGFX_ENCODER(setTexture(_stage, _sampler, _handle, _flags) );
}
@@ -3756,7 +3756,7 @@ namespace bgfx
void Encoder::submit(ViewId _id, ProgramHandle _program, OcclusionQueryHandle _occlusionQuery, uint32_t _depth, uint8_t _flags)
{
BX_CHECK(false
BX_ASSERT(false
|| !isValid(_occlusionQuery)
|| 0 != (g_caps.supported & BGFX_CAPS_OCCLUSION_QUERY)
, "Occlusion query is not supported! Use bgfx::getCaps to check BGFX_CAPS_OCCLUSION_QUERY backend renderer capabilities."
@@ -3776,21 +3776,21 @@ namespace bgfx
void Encoder::setBuffer(uint8_t _stage, IndexBufferHandle _handle, Access::Enum _access)
{
BX_CHECK(_stage < g_caps.limits.maxComputeBindings, "Invalid stage %d (max %d).", _stage, g_caps.limits.maxComputeBindings);
BX_ASSERT(_stage < g_caps.limits.maxComputeBindings, "Invalid stage %d (max %d).", _stage, g_caps.limits.maxComputeBindings);
BGFX_CHECK_HANDLE("setBuffer", s_ctx->m_indexBufferHandle, _handle);
BGFX_ENCODER(setBuffer(_stage, _handle, _access) );
}
void Encoder::setBuffer(uint8_t _stage, VertexBufferHandle _handle, Access::Enum _access)
{
BX_CHECK(_stage < g_caps.limits.maxComputeBindings, "Invalid stage %d (max %d).", _stage, g_caps.limits.maxComputeBindings);
BX_ASSERT(_stage < g_caps.limits.maxComputeBindings, "Invalid stage %d (max %d).", _stage, g_caps.limits.maxComputeBindings);
BGFX_CHECK_HANDLE("setBuffer", s_ctx->m_vertexBufferHandle, _handle);
BGFX_ENCODER(setBuffer(_stage, _handle, _access) );
}
void Encoder::setBuffer(uint8_t _stage, DynamicIndexBufferHandle _handle, Access::Enum _access)
{
BX_CHECK(_stage < g_caps.limits.maxComputeBindings, "Invalid stage %d (max %d).", _stage, g_caps.limits.maxComputeBindings);
BX_ASSERT(_stage < g_caps.limits.maxComputeBindings, "Invalid stage %d (max %d).", _stage, g_caps.limits.maxComputeBindings);
BGFX_CHECK_HANDLE("setBuffer", s_ctx->m_dynamicIndexBufferHandle, _handle);
const DynamicIndexBuffer& dib = s_ctx->m_dynamicIndexBuffers[_handle.idx];
BGFX_ENCODER(setBuffer(_stage, dib.m_handle, _access) );
@@ -3798,7 +3798,7 @@ namespace bgfx
void Encoder::setBuffer(uint8_t _stage, DynamicVertexBufferHandle _handle, Access::Enum _access)
{
BX_CHECK(_stage < g_caps.limits.maxComputeBindings, "Invalid stage %d (max %d).", _stage, g_caps.limits.maxComputeBindings);
BX_ASSERT(_stage < g_caps.limits.maxComputeBindings, "Invalid stage %d (max %d).", _stage, g_caps.limits.maxComputeBindings);
BGFX_CHECK_HANDLE("setBuffer", s_ctx->m_dynamicVertexBufferHandle, _handle);
const DynamicVertexBuffer& dvb = s_ctx->m_dynamicVertexBuffers[_handle.idx];
BGFX_ENCODER(setBuffer(_stage, dvb.m_handle, _access) );
@@ -3806,7 +3806,7 @@ namespace bgfx
void Encoder::setBuffer(uint8_t _stage, IndirectBufferHandle _handle, Access::Enum _access)
{
BX_CHECK(_stage < g_caps.limits.maxComputeBindings, "Invalid stage %d (max %d).", _stage, g_caps.limits.maxComputeBindings);
BX_ASSERT(_stage < g_caps.limits.maxComputeBindings, "Invalid stage %d (max %d).", _stage, g_caps.limits.maxComputeBindings);
BGFX_CHECK_HANDLE("setBuffer", s_ctx->m_vertexBufferHandle, _handle);
VertexBufferHandle handle = { _handle.idx };
BGFX_ENCODER(setBuffer(_stage, handle, _access) );
@@ -3814,13 +3814,13 @@ namespace bgfx
void Encoder::setImage(uint8_t _stage, TextureHandle _handle, uint8_t _mip, Access::Enum _access, TextureFormat::Enum _format)
{
BX_CHECK(_stage < g_caps.limits.maxComputeBindings, "Invalid stage %d (max %d).", _stage, g_caps.limits.maxComputeBindings);
BX_ASSERT(_stage < g_caps.limits.maxComputeBindings, "Invalid stage %d (max %d).", _stage, g_caps.limits.maxComputeBindings);
BGFX_CHECK_HANDLE_INVALID_OK("setImage/TextureHandle", s_ctx->m_textureHandle, _handle);
_format = TextureFormat::Count == _format
? TextureFormat::Enum(s_ctx->m_textureRef[_handle.idx].m_format)
: _format
;
BX_CHECK(_format != TextureFormat::BGRA8
BX_ASSERT(_format != TextureFormat::BGRA8
, "Can't use TextureFormat::BGRA8 with compute, use TextureFormat::RGBA8 instead."
);
BGFX_ENCODER(setImage(_stage, _handle, _mip, _access, _format) );
@@ -3859,7 +3859,7 @@ namespace bgfx
BGFX_CHECK_HANDLE("blit/dst TextureHandle", s_ctx->m_textureHandle, _dst);
const TextureRef& src = s_ctx->m_textureRef[_src.idx];
const TextureRef& dst = s_ctx->m_textureRef[_dst.idx];
BX_CHECK(src.m_format == dst.m_format
BX_ASSERT(src.m_format == dst.m_format
, "Texture format must match (src %s, dst %s)."
, bimg::getName(bimg::TextureFormat::Enum(src.m_format) )
, bimg::getName(bimg::TextureFormat::Enum(dst.m_format) )
@@ -3898,7 +3898,7 @@ namespace bgfx
const Memory* alloc(uint32_t _size)
{
BX_CHECK(0 < _size, "Invalid memory operation. _size is 0.");
BX_ASSERT(0 < _size, "Invalid memory operation. _size is 0.");
Memory* mem = (Memory*)BX_ALLOC(g_allocator, sizeof(Memory) + _size);
mem->size = _size;
mem->data = (uint8_t*)mem + sizeof(Memory);
@@ -3907,7 +3907,7 @@ namespace bgfx
const Memory* copy(const void* _data, uint32_t _size)
{
BX_CHECK(0 < _size, "Invalid memory operation. _size is 0.");
BX_ASSERT(0 < _size, "Invalid memory operation. _size is 0.");
const Memory* mem = alloc(_size);
bx::memCopy(mem->data, _data, _size);
return mem;
@@ -3937,7 +3937,7 @@ namespace bgfx
void release(const Memory* _mem)
{
BX_CHECK(NULL != _mem, "_mem can't be NULL");
BX_ASSERT(NULL != _mem, "_mem can't be NULL");
Memory* mem = const_cast<Memory*>(_mem);
if (isMemoryRef(mem) )
{
@@ -3984,7 +3984,7 @@ namespace bgfx
IndexBufferHandle createIndexBuffer(const Memory* _mem, uint16_t _flags)
{
BX_CHECK(NULL != _mem, "_mem can't be NULL");
BX_ASSERT(NULL != _mem, "_mem can't be NULL");
return s_ctx->createIndexBuffer(_mem, _flags);
}
@@ -4010,8 +4010,8 @@ namespace bgfx
VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexLayout& _layout, uint16_t _flags)
{
BX_CHECK(NULL != _mem, "_mem can't be NULL");
BX_CHECK(isValid(_layout), "Invalid VertexLayout.");
BX_ASSERT(NULL != _mem, "_mem can't be NULL");
BX_ASSERT(isValid(_layout), "Invalid VertexLayout.");
return s_ctx->createVertexBuffer(_mem, _layout, _flags);
}
@@ -4032,13 +4032,13 @@ namespace bgfx
DynamicIndexBufferHandle createDynamicIndexBuffer(const Memory* _mem, uint16_t _flags)
{
BX_CHECK(NULL != _mem, "_mem can't be NULL");
BX_ASSERT(NULL != _mem, "_mem can't be NULL");
return s_ctx->createDynamicIndexBuffer(_mem, _flags);
}
void update(DynamicIndexBufferHandle _handle, uint32_t _startIndex, const Memory* _mem)
{
BX_CHECK(NULL != _mem, "_mem can't be NULL");
BX_ASSERT(NULL != _mem, "_mem can't be NULL");
s_ctx->update(_handle, _startIndex, _mem);
}
@@ -4049,20 +4049,20 @@ namespace bgfx
DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexLayout& _layout, uint16_t _flags)
{
BX_CHECK(isValid(_layout), "Invalid VertexLayout.");
BX_ASSERT(isValid(_layout), "Invalid VertexLayout.");
return s_ctx->createDynamicVertexBuffer(_num, _layout, _flags);
}
DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexLayout& _layout, uint16_t _flags)
{
BX_CHECK(NULL != _mem, "_mem can't be NULL");
BX_CHECK(isValid(_layout), "Invalid VertexLayout.");
BX_ASSERT(NULL != _mem, "_mem can't be NULL");
BX_ASSERT(isValid(_layout), "Invalid VertexLayout.");
return s_ctx->createDynamicVertexBuffer(_mem, _layout, _flags);
}
void update(DynamicVertexBufferHandle _handle, uint32_t _startVertex, const Memory* _mem)
{
BX_CHECK(NULL != _mem, "_mem can't be NULL");
BX_ASSERT(NULL != _mem, "_mem can't be NULL");
s_ctx->update(_handle, _startVertex, _mem);
}
@@ -4073,29 +4073,29 @@ namespace bgfx
uint32_t getAvailTransientIndexBuffer(uint32_t _num)
{
BX_CHECK(0 < _num, "Requesting 0 indices.");
BX_ASSERT(0 < _num, "Requesting 0 indices.");
return s_ctx->getAvailTransientIndexBuffer(_num);
}
uint32_t getAvailTransientVertexBuffer(uint32_t _num, const VertexLayout& _layout)
{
BX_CHECK(0 < _num, "Requesting 0 vertices.");
BX_CHECK(isValid(_layout), "Invalid VertexLayout.");
BX_ASSERT(0 < _num, "Requesting 0 vertices.");
BX_ASSERT(isValid(_layout), "Invalid VertexLayout.");
return s_ctx->getAvailTransientVertexBuffer(_num, _layout.m_stride);
}
uint32_t getAvailInstanceDataBuffer(uint32_t _num, uint16_t _stride)
{
BX_CHECK(0 < _num, "Requesting 0 instances.");
BX_ASSERT(0 < _num, "Requesting 0 instances.");
return s_ctx->getAvailTransientVertexBuffer(_num, _stride);
}
void allocTransientIndexBuffer(TransientIndexBuffer* _tib, uint32_t _num)
{
BX_CHECK(NULL != _tib, "_tib can't be NULL");
BX_CHECK(0 < _num, "Requesting 0 indices.");
BX_ASSERT(NULL != _tib, "_tib can't be NULL");
BX_ASSERT(0 < _num, "Requesting 0 indices.");
s_ctx->allocTransientIndexBuffer(_tib, _num);
BX_CHECK(_num == _tib->size/2
BX_ASSERT(_num == _tib->size/2
, "Failed to allocate transient index buffer (requested %d, available %d). "
"Use bgfx::getAvailTransient* functions to ensure availability."
, _num
@@ -4105,11 +4105,11 @@ namespace bgfx
void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint32_t _num, const VertexLayout& _layout)
{
BX_CHECK(NULL != _tvb, "_tvb can't be NULL");
BX_CHECK(0 < _num, "Requesting 0 vertices.");
BX_CHECK(isValid(_layout), "Invalid VertexLayout.");
BX_ASSERT(NULL != _tvb, "_tvb can't be NULL");
BX_ASSERT(0 < _num, "Requesting 0 vertices.");
BX_ASSERT(isValid(_layout), "Invalid VertexLayout.");
s_ctx->allocTransientVertexBuffer(_tvb, _num, _layout);
BX_CHECK(_num == _tvb->size / _layout.m_stride
BX_ASSERT(_num == _tvb->size / _layout.m_stride
, "Failed to allocate transient vertex buffer (requested %d, available %d). "
"Use bgfx::getAvailTransient* functions to ensure availability."
, _num
@@ -4135,10 +4135,10 @@ namespace bgfx
void allocInstanceDataBuffer(InstanceDataBuffer* _idb, uint32_t _num, uint16_t _stride)
{
BGFX_CHECK_CAPS(BGFX_CAPS_INSTANCING, "Instancing is not supported!");
BX_CHECK(bx::isAligned(_stride, 16), "Stride must be multiple of 16.");
BX_CHECK(0 < _num, "Requesting 0 instanced data vertices.");
BX_ASSERT(bx::isAligned(_stride, 16), "Stride must be multiple of 16.");
BX_ASSERT(0 < _num, "Requesting 0 instanced data vertices.");
s_ctx->allocInstanceDataBuffer(_idb, _num, _stride);
BX_CHECK(_num == _idb->size / _stride
BX_ASSERT(_num == _idb->size / _stride
, "Failed to allocate instance data buffer (requested %d, available %d). "
"Use bgfx::getAvailTransient* functions to ensure availability."
, _num
@@ -4158,7 +4158,7 @@ namespace bgfx
ShaderHandle createShader(const Memory* _mem)
{
BX_CHECK(NULL != _mem, "_mem can't be NULL");
BX_ASSERT(NULL != _mem, "_mem can't be NULL");
return s_ctx->createShader(_mem);
}
@@ -4341,7 +4341,7 @@ namespace bgfx
TextureHandle createTexture(const Memory* _mem, uint64_t _flags, uint8_t _skip, TextureInfo* _info)
{
BX_CHECK(NULL != _mem, "_mem can't be NULL");
BX_ASSERT(NULL != _mem, "_mem can't be NULL");
return s_ctx->createTexture(_mem, _flags, _skip, _info, BackbufferRatio::Count, false);
}
@@ -4367,7 +4367,7 @@ namespace bgfx
{
bx::Error err;
isTextureValid(0, false, _numLayers, _format, _flags, &err);
BX_CHECK(err.isOk(), "%s (layers %d, format %s)"
BX_ASSERT(err.isOk(), "%s (layers %d, format %s)"
, err.getMessage().getPtr()
, _numLayers
, getName(_format)
@@ -4388,7 +4388,7 @@ namespace bgfx
{
TextureInfo ti;
calcTextureSize(ti, _width, _height, 1, false, _hasMips, _numLayers, _format);
BX_CHECK(ti.storageSize == _mem->size
BX_ASSERT(ti.storageSize == _mem->size
, "createTexture2D: Texture storage size doesn't match passed memory size (storage size: %d, memory size: %d)"
, ti.storageSize
, _mem->size
@@ -4418,13 +4418,13 @@ namespace bgfx
TextureHandle createTexture2D(uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, TextureFormat::Enum _format, uint64_t _flags, const Memory* _mem)
{
BX_CHECK(_width > 0 && _height > 0, "Invalid texture size (width %d, height %d).", _width, _height);
BX_ASSERT(_width > 0 && _height > 0, "Invalid texture size (width %d, height %d).", _width, _height);
return createTexture2D(BackbufferRatio::Count, _width, _height, _hasMips, _numLayers, _format, _flags, _mem);
}
TextureHandle createTexture2D(BackbufferRatio::Enum _ratio, bool _hasMips, uint16_t _numLayers, TextureFormat::Enum _format, uint64_t _flags)
{
BX_CHECK(_ratio < BackbufferRatio::Count, "Invalid back buffer ratio.");
BX_ASSERT(_ratio < BackbufferRatio::Count, "Invalid back buffer ratio.");
return createTexture2D(_ratio, 0, 0, _hasMips, _numLayers, _format, _flags, NULL);
}
@@ -4432,7 +4432,7 @@ namespace bgfx
{
bx::Error err;
isTextureValid(_depth, false, 1, _format, _flags, &err);
BX_CHECK(err.isOk(), "%s", err.getMessage().getPtr() );
BX_ASSERT(err.isOk(), "%s", err.getMessage().getPtr() );
const uint8_t numMips = calcNumMips(_hasMips, _width, _height, _depth);
@@ -4441,7 +4441,7 @@ namespace bgfx
{
TextureInfo ti;
calcTextureSize(ti, _width, _height, _depth, false, _hasMips, 1, _format);
BX_CHECK(ti.storageSize == _mem->size
BX_ASSERT(ti.storageSize == _mem->size
, "createTexture3D: Texture storage size doesn't match passed memory size (storage size: %d, memory size: %d)"
, ti.storageSize
, _mem->size
@@ -4473,7 +4473,7 @@ namespace bgfx
{
bx::Error err;
isTextureValid(0, true, _numLayers, _format, _flags, &err);
BX_CHECK(err.isOk(), "%s", err.getMessage().getPtr() );
BX_ASSERT(err.isOk(), "%s", err.getMessage().getPtr() );
const uint8_t numMips = calcNumMips(_hasMips, _size, _size);
_numLayers = bx::max<uint16_t>(_numLayers, 1);
@@ -4483,7 +4483,7 @@ namespace bgfx
{
TextureInfo ti;
calcTextureSize(ti, _size, _size, 1, true, _hasMips, _numLayers, _format);
BX_CHECK(ti.storageSize == _mem->size
BX_ASSERT(ti.storageSize == _mem->size
, "createTextureCube: Texture storage size doesn't match passed memory size (storage size: %d, memory size: %d)"
, ti.storageSize
, _mem->size
@@ -4528,7 +4528,7 @@ namespace bgfx
void updateTexture2D(TextureHandle _handle, uint16_t _layer, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const Memory* _mem, uint16_t _pitch)
{
BX_CHECK(NULL != _mem, "_mem can't be NULL");
BX_ASSERT(NULL != _mem, "_mem can't be NULL");
if (_width == 0
|| _height == 0)
{
@@ -4542,7 +4542,7 @@ namespace bgfx
void updateTexture3D(TextureHandle _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const Memory* _mem)
{
BX_CHECK(NULL != _mem, "_mem can't be NULL");
BX_ASSERT(NULL != _mem, "_mem can't be NULL");
BGFX_CHECK_CAPS(BGFX_CAPS_TEXTURE_3D, "Texture3D is not supported!");
if (0 == _width
@@ -4559,8 +4559,8 @@ namespace bgfx
void updateTextureCube(TextureHandle _handle, uint16_t _layer, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const Memory* _mem, uint16_t _pitch)
{
BX_CHECK(NULL != _mem, "_mem can't be NULL");
BX_CHECK(_side <= 5, "Invalid side %d.", _side);
BX_ASSERT(NULL != _mem, "_mem can't be NULL");
BX_ASSERT(_side <= 5, "Invalid side %d.", _side);
if (0 == _width
|| 0 == _height)
{
@@ -4574,7 +4574,7 @@ namespace bgfx
uint32_t readTexture(TextureHandle _handle, void* _data, uint8_t _mip)
{
BX_CHECK(NULL != _data, "_data can't be NULL");
BX_ASSERT(NULL != _data, "_data can't be NULL");
BGFX_CHECK_CAPS(BGFX_CAPS_TEXTURE_READ_BACK, "Texture read-back is not supported!");
return s_ctx->readTexture(_handle, _data, _mip);
}
@@ -4588,7 +4588,7 @@ namespace bgfx
FrameBufferHandle createFrameBuffer(BackbufferRatio::Enum _ratio, TextureFormat::Enum _format, uint64_t _textureFlags)
{
BX_CHECK(_ratio < BackbufferRatio::Count, "Invalid back buffer ratio.");
BX_ASSERT(_ratio < BackbufferRatio::Count, "Invalid back buffer ratio.");
_textureFlags |= _textureFlags&BGFX_TEXTURE_RT_MSAA_MASK ? 0 : BGFX_TEXTURE_RT;
TextureHandle th = createTexture2D(_ratio, false, 1, _format, _textureFlags);
return createFrameBuffer(1, &th, true);
@@ -4607,13 +4607,13 @@ namespace bgfx
FrameBufferHandle createFrameBuffer(uint8_t _num, const Attachment* _attachment, bool _destroyTextures)
{
BX_CHECK(_num != 0, "Number of frame buffer attachments can't be 0.");
BX_CHECK(_num <= BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS
BX_ASSERT(_num != 0, "Number of frame buffer attachments can't be 0.");
BX_ASSERT(_num <= BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS
, "Number of frame buffer attachments is larger than allowed %d (max: %d)."
, _num
, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS
);
BX_CHECK(NULL != _attachment, "_attachment can't be NULL");
BX_ASSERT(NULL != _attachment, "_attachment can't be NULL");
return s_ctx->createFrameBuffer(_num, _attachment, _destroyTextures);
}
@@ -4625,11 +4625,11 @@ namespace bgfx
, _width
, _height
);
BX_CHECK(_format == TextureFormat::Count || bimg::isColor(bimg::TextureFormat::Enum(_format) )
BX_ASSERT(_format == TextureFormat::Count || bimg::isColor(bimg::TextureFormat::Enum(_format) )
, "Invalid texture format for color (%s)."
, bimg::getName(bimg::TextureFormat::Enum(_format) )
);
BX_CHECK(_depthFormat == TextureFormat::Count || bimg::isDepth(bimg::TextureFormat::Enum(_depthFormat) )
BX_ASSERT(_depthFormat == TextureFormat::Count || bimg::isDepth(bimg::TextureFormat::Enum(_depthFormat) )
, "Invalid texture format for depth (%s)."
, bimg::getName(bimg::TextureFormat::Enum(_depthFormat) )
);
@@ -4728,19 +4728,19 @@ namespace bgfx
void setViewName(ViewId _id, const char* _name)
{
BX_CHECK(checkView(_id), "Invalid view id: %d", _id);
BX_ASSERT(checkView(_id), "Invalid view id: %d", _id);
s_ctx->setViewName(_id, _name);
}
void setViewRect(ViewId _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
{
BX_CHECK(checkView(_id), "Invalid view id: %d", _id);
BX_ASSERT(checkView(_id), "Invalid view id: %d", _id);
s_ctx->setViewRect(_id, _x, _y, _width, _height);
}
void setViewRect(ViewId _id, uint16_t _x, uint16_t _y, BackbufferRatio::Enum _ratio)
{
BX_CHECK(checkView(_id), "Invalid view id: %d", _id);
BX_ASSERT(checkView(_id), "Invalid view id: %d", _id);
uint16_t width = uint16_t(s_ctx->m_init.resolution.width);
uint16_t height = uint16_t(s_ctx->m_init.resolution.height);
@@ -4750,49 +4750,49 @@ namespace bgfx
void setViewScissor(ViewId _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
{
BX_CHECK(checkView(_id), "Invalid view id: %d", _id);
BX_ASSERT(checkView(_id), "Invalid view id: %d", _id);
s_ctx->setViewScissor(_id, _x, _y, _width, _height);
}
void setViewClear(ViewId _id, uint16_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil)
{
BX_CHECK(checkView(_id), "Invalid view id: %d", _id);
BX_ASSERT(checkView(_id), "Invalid view id: %d", _id);
s_ctx->setViewClear(_id, _flags, _rgba, _depth, _stencil);
}
void setViewClear(ViewId _id, uint16_t _flags, float _depth, uint8_t _stencil, uint8_t _0, uint8_t _1, uint8_t _2, uint8_t _3, uint8_t _4, uint8_t _5, uint8_t _6, uint8_t _7)
{
BX_CHECK(checkView(_id), "Invalid view id: %d", _id);
BX_ASSERT(checkView(_id), "Invalid view id: %d", _id);
s_ctx->setViewClear(_id, _flags, _depth, _stencil, _0, _1, _2, _3, _4, _5, _6, _7);
}
void setViewMode(ViewId _id, ViewMode::Enum _mode)
{
BX_CHECK(checkView(_id), "Invalid view id: %d", _id);
BX_ASSERT(checkView(_id), "Invalid view id: %d", _id);
s_ctx->setViewMode(_id, _mode);
}
void setViewFrameBuffer(ViewId _id, FrameBufferHandle _handle)
{
BX_CHECK(checkView(_id), "Invalid view id: %d", _id);
BX_ASSERT(checkView(_id), "Invalid view id: %d", _id);
s_ctx->setViewFrameBuffer(_id, _handle);
}
void setViewTransform(ViewId _id, const void* _view, const void* _proj)
{
BX_CHECK(checkView(_id), "Invalid view id: %d", _id);
BX_ASSERT(checkView(_id), "Invalid view id: %d", _id);
s_ctx->setViewTransform(_id, _view, _proj);
}
void setViewOrder(ViewId _id, uint16_t _num, const ViewId* _order)
{
BX_CHECK(checkView(_id), "Invalid view id: %d", _id);
BX_ASSERT(checkView(_id), "Invalid view id: %d", _id);
s_ctx->setViewOrder(_id, _num, _order);
}
void resetView(ViewId _id)
{
BX_CHECK(checkView(_id), "Invalid view id: %d", _id);
BX_ASSERT(checkView(_id), "Invalid view id: %d", _id);
s_ctx->resetView(_id);
}