mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-18 04:53:06 +01:00
RRenamed BX_CHECK to BX_ASSERT.
This commit is contained in:
202
src/bgfx.cpp
202
src/bgfx.cpp
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
116
src/bgfx_p.h
116
src/bgfx_p.h
@@ -15,7 +15,7 @@
|
||||
#if BGFX_CONFIG_DEBUG || BX_COMPILER_CLANG_ANALYZER
|
||||
# define BX_TRACE _BX_TRACE
|
||||
# define BX_WARN _BX_WARN
|
||||
# define BX_CHECK _BX_CHECK
|
||||
# define BX_ASSERT _BX_ASSERT
|
||||
# define BX_CONFIG_ALLOCATOR_DEBUG 1
|
||||
#endif // BGFX_CONFIG_DEBUG
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
// Check handle, cannot be bgfx::kInvalidHandle and must be valid.
|
||||
#define BGFX_CHECK_HANDLE(_desc, _handleAlloc, _handle) \
|
||||
BX_CHECK(isValid(_handle) \
|
||||
BX_ASSERT(isValid(_handle) \
|
||||
&& _handleAlloc.isValid(_handle.idx) \
|
||||
, "Invalid handle. %s handle: %d (max %d)" \
|
||||
, _desc \
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
// Check handle, it's ok to be bgfx::kInvalidHandle or must be valid.
|
||||
#define BGFX_CHECK_HANDLE_INVALID_OK(_desc, _handleAlloc, _handle) \
|
||||
BX_CHECK(!isValid(_handle) \
|
||||
BX_ASSERT(!isValid(_handle) \
|
||||
|| _handleAlloc.isValid(_handle.idx) \
|
||||
, "Invalid handle. %s handle: %d (max %d)" \
|
||||
, _desc \
|
||||
@@ -91,7 +91,7 @@ namespace bgfx
|
||||
} \
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
#define _BX_CHECK(_condition, _format, ...) \
|
||||
#define _BX_ASSERT(_condition, _format, ...) \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
if (!BX_IGNORE_C4127(_condition) ) \
|
||||
{ \
|
||||
@@ -836,7 +836,7 @@ namespace bgfx
|
||||
|
||||
void write(const void* _data, uint32_t _size)
|
||||
{
|
||||
BX_CHECK(m_size == 0, "Called write outside start/finish (m_size: %d)?", m_size);
|
||||
BX_ASSERT(m_size == 0, "Called write outside start/finish (m_size: %d)?", m_size);
|
||||
if (m_pos + _size > m_capacity)
|
||||
{
|
||||
resize(m_capacity + (16<<10) );
|
||||
@@ -855,7 +855,7 @@ namespace bgfx
|
||||
|
||||
void read(void* _data, uint32_t _size)
|
||||
{
|
||||
BX_CHECK(m_pos + _size <= m_size
|
||||
BX_ASSERT(m_pos + _size <= m_size
|
||||
, "CommandBuffer::read error (pos: %d-%d, size: %d)."
|
||||
, m_pos
|
||||
, m_pos + _size
|
||||
@@ -874,7 +874,7 @@ namespace bgfx
|
||||
|
||||
const uint8_t* skip(uint32_t _size)
|
||||
{
|
||||
BX_CHECK(m_pos + _size <= m_size
|
||||
BX_ASSERT(m_pos + _size <= m_size
|
||||
, "CommandBuffer::skip error (pos: %d-%d, size: %d)."
|
||||
, m_pos
|
||||
, m_pos + _size
|
||||
@@ -1123,7 +1123,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
const uint64_t view = (uint64_t(m_view ) << kSortKeyViewBitShift ) & kSortKeyViewMask;
|
||||
const uint64_t key = view|kSortKeyDrawBit|kSortKeyDrawTypeSequence|seq|blend|program;
|
||||
|
||||
BX_CHECK(seq == (uint64_t(m_seq) << kSortKeyDraw2SeqShift)
|
||||
BX_ASSERT(seq == (uint64_t(m_seq) << kSortKeyDraw2SeqShift)
|
||||
, "SortKey error, sequence is truncated (m_seq: %d)."
|
||||
, m_seq
|
||||
);
|
||||
@@ -1133,7 +1133,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
break;
|
||||
}
|
||||
|
||||
BX_CHECK(false, "You should not be here.");
|
||||
BX_ASSERT(false, "You should not be here.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1144,7 +1144,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
const uint64_t view = (uint64_t(m_view ) << kSortKeyViewBitShift ) & kSortKeyViewMask;
|
||||
const uint64_t key = program|seq|view;
|
||||
|
||||
BX_CHECK(seq == (uint64_t(m_seq) << kSortKeyComputeSeqShift)
|
||||
BX_ASSERT(seq == (uint64_t(m_seq) << kSortKeyComputeSeqShift)
|
||||
, "SortKey error, sequence is truncated (m_seq: %d)."
|
||||
, m_seq
|
||||
);
|
||||
@@ -1297,7 +1297,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
float* toPtr(uint32_t _cacheIdx)
|
||||
{
|
||||
BX_CHECK(_cacheIdx < BGFX_CONFIG_MAX_MATRIX_CACHE, "Matrix cache out of bounds index %d (max: %d)"
|
||||
BX_ASSERT(_cacheIdx < BGFX_CONFIG_MAX_MATRIX_CACHE, "Matrix cache out of bounds index %d (max: %d)"
|
||||
, _cacheIdx
|
||||
, BGFX_CONFIG_MAX_MATRIX_CACHE
|
||||
);
|
||||
@@ -1328,7 +1328,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
uint32_t add(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
|
||||
{
|
||||
const uint32_t first = bx::atomicFetchAndAddsat<uint32_t>(&m_num, 1, BGFX_CONFIG_MAX_RECT_CACHE-1);
|
||||
BX_CHECK(first+1 < BGFX_CONFIG_MAX_RECT_CACHE, "Rect cache overflow. %d (max: %d)", first, BGFX_CONFIG_MAX_RECT_CACHE);
|
||||
BX_ASSERT(first+1 < BGFX_CONFIG_MAX_RECT_CACHE, "Rect cache overflow. %d (max: %d)", first, BGFX_CONFIG_MAX_RECT_CACHE);
|
||||
|
||||
Rect& rect = m_cache[first];
|
||||
|
||||
@@ -1416,7 +1416,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
void write(const void* _data, uint32_t _size)
|
||||
{
|
||||
BX_CHECK(m_pos + _size < m_size, "Write would go out of bounds. pos %d + size %d > max size: %d).", m_pos, _size, m_size);
|
||||
BX_ASSERT(m_pos + _size < m_size, "Write would go out of bounds. pos %d + size %d > max size: %d).", m_pos, _size, m_size);
|
||||
|
||||
if (m_pos + _size < m_size)
|
||||
{
|
||||
@@ -1432,7 +1432,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
const char* read(uint32_t _size)
|
||||
{
|
||||
BX_CHECK(m_pos < m_size, "Out of bounds %d (size: %d).", m_pos, m_size);
|
||||
BX_ASSERT(m_pos < m_size, "Out of bounds %d (size: %d).", m_pos, m_size);
|
||||
const char* result = &m_buffer[m_pos];
|
||||
m_pos += _size;
|
||||
return result;
|
||||
@@ -1516,7 +1516,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
const UniformRegInfo& add(UniformHandle _handle, const char* _name)
|
||||
{
|
||||
BX_CHECK(isValid(_handle), "Uniform handle is invalid (name: %s)!", _name);
|
||||
BX_ASSERT(isValid(_handle), "Uniform handle is invalid (name: %s)!", _name);
|
||||
const uint32_t key = bx::hash<bx::HashMurmur2A>(_name);
|
||||
m_uniforms.removeByKey(key);
|
||||
m_uniforms.insert(key, _handle.idx);
|
||||
@@ -2299,7 +2299,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
{
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_UNIFORM) )
|
||||
{
|
||||
BX_CHECK(m_uniformSet.end() == m_uniformSet.find(_handle.idx)
|
||||
BX_ASSERT(m_uniformSet.end() == m_uniformSet.find(_handle.idx)
|
||||
, "Uniform %d (%s) was already set for this draw call."
|
||||
, _handle.idx
|
||||
, getName(_handle)
|
||||
@@ -2364,7 +2364,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
void setTransform(uint32_t _cache, uint16_t _num)
|
||||
{
|
||||
BX_CHECK(_cache < BGFX_CONFIG_MAX_MATRIX_CACHE, "Matrix cache out of bounds index %d (max: %d)"
|
||||
BX_ASSERT(_cache < BGFX_CONFIG_MAX_MATRIX_CACHE, "Matrix cache out of bounds index %d (max: %d)"
|
||||
, _cache
|
||||
, BGFX_CONFIG_MAX_MATRIX_CACHE
|
||||
);
|
||||
@@ -2374,7 +2374,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
void setIndexBuffer(IndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices)
|
||||
{
|
||||
BX_CHECK(UINT8_MAX != m_draw.m_streamMask, "");
|
||||
BX_ASSERT(UINT8_MAX != m_draw.m_streamMask, "");
|
||||
m_draw.m_startIndex = _firstIndex;
|
||||
m_draw.m_numIndices = _numIndices;
|
||||
m_draw.m_indexBuffer = _handle;
|
||||
@@ -2382,7 +2382,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
void setIndexBuffer(const DynamicIndexBuffer& _dib, uint32_t _firstIndex, uint32_t _numIndices)
|
||||
{
|
||||
BX_CHECK(UINT8_MAX != m_draw.m_streamMask, "");
|
||||
BX_ASSERT(UINT8_MAX != m_draw.m_streamMask, "");
|
||||
const uint32_t indexSize = 0 == (_dib.m_flags & BGFX_BUFFER_INDEX32) ? 2 : 4;
|
||||
m_draw.m_startIndex = _dib.m_startIndex + _firstIndex;
|
||||
m_draw.m_numIndices = bx::min(_numIndices, _dib.m_size/indexSize);
|
||||
@@ -2391,7 +2391,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
void setIndexBuffer(const TransientIndexBuffer* _tib, uint32_t _firstIndex, uint32_t _numIndices)
|
||||
{
|
||||
BX_CHECK(UINT8_MAX != m_draw.m_streamMask, "");
|
||||
BX_ASSERT(UINT8_MAX != m_draw.m_streamMask, "");
|
||||
const uint32_t numIndices = bx::min(_numIndices, _tib->size/2);
|
||||
m_draw.m_indexBuffer = _tib->handle;
|
||||
m_draw.m_startIndex = _tib->startIndex + _firstIndex;
|
||||
@@ -2407,8 +2407,8 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
, VertexLayoutHandle _layoutHandle
|
||||
)
|
||||
{
|
||||
BX_CHECK(UINT8_MAX != m_draw.m_streamMask, "");
|
||||
BX_CHECK(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
|
||||
BX_ASSERT(UINT8_MAX != m_draw.m_streamMask, "");
|
||||
BX_ASSERT(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
|
||||
if (m_draw.setStreamBit(_stream, _handle) )
|
||||
{
|
||||
Stream& stream = m_draw.m_stream[_stream];
|
||||
@@ -2427,8 +2427,8 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
, VertexLayoutHandle _layoutHandle
|
||||
)
|
||||
{
|
||||
BX_CHECK(UINT8_MAX != m_draw.m_streamMask, "");
|
||||
BX_CHECK(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
|
||||
BX_ASSERT(UINT8_MAX != m_draw.m_streamMask, "");
|
||||
BX_ASSERT(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
|
||||
if (m_draw.setStreamBit(_stream, _dvb.m_handle) )
|
||||
{
|
||||
Stream& stream = m_draw.m_stream[_stream];
|
||||
@@ -2449,8 +2449,8 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
, VertexLayoutHandle _layoutHandle
|
||||
)
|
||||
{
|
||||
BX_CHECK(UINT8_MAX != m_draw.m_streamMask, "");
|
||||
BX_CHECK(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
|
||||
BX_ASSERT(UINT8_MAX != m_draw.m_streamMask, "");
|
||||
BX_ASSERT(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
|
||||
if (m_draw.setStreamBit(_stream, _tvb->handle) )
|
||||
{
|
||||
Stream& stream = m_draw.m_stream[_stream];
|
||||
@@ -2463,7 +2463,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
void setVertexCount(uint32_t _numVertices)
|
||||
{
|
||||
BX_CHECK(0 == m_draw.m_streamMask, "Vertex buffer already set.");
|
||||
BX_ASSERT(0 == m_draw.m_streamMask, "Vertex buffer already set.");
|
||||
m_draw.m_streamMask = UINT8_MAX;
|
||||
Stream& stream = m_draw.m_stream[0];
|
||||
stream.m_startVertex = 0;
|
||||
@@ -2492,7 +2492,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
void setInstanceCount(uint32_t _numInstances)
|
||||
{
|
||||
BX_CHECK(!isValid(m_draw.m_instanceDataBuffer), "Instance buffer already set.");
|
||||
BX_ASSERT(!isValid(m_draw.m_instanceDataBuffer), "Instance buffer already set.");
|
||||
m_draw.m_numInstances = _numInstances;
|
||||
}
|
||||
|
||||
@@ -2645,7 +2645,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
void add(VertexBufferHandle _handle, VertexLayoutHandle _layoutHandle, uint32_t _hash)
|
||||
{
|
||||
BX_CHECK(m_vertexBufferRef[_handle.idx].idx == kInvalidHandle, "");
|
||||
BX_ASSERT(m_vertexBufferRef[_handle.idx].idx == kInvalidHandle, "");
|
||||
m_vertexBufferRef[_handle.idx] = _layoutHandle;
|
||||
m_vertexLayoutRef[_layoutHandle.idx]++;
|
||||
m_vertexLayoutMap.insert(_hash, _layoutHandle.idx);
|
||||
@@ -2653,7 +2653,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
void add(DynamicVertexBufferHandle _handle, VertexLayoutHandle _layoutHandle, uint32_t _hash)
|
||||
{
|
||||
BX_CHECK(m_dynamicVertexBufferRef[_handle.idx].idx == kInvalidHandle, "");
|
||||
BX_ASSERT(m_dynamicVertexBufferRef[_handle.idx].idx == kInvalidHandle, "");
|
||||
m_dynamicVertexBufferRef[_handle.idx] = _layoutHandle;
|
||||
m_vertexLayoutRef[_layoutHandle.idx]++;
|
||||
m_vertexLayoutMap.insert(_hash, _layoutHandle.idx);
|
||||
@@ -2728,7 +2728,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
uint64_t remove()
|
||||
{
|
||||
BX_CHECK(0 == m_used.size(), "");
|
||||
BX_ASSERT(0 == m_used.size(), "");
|
||||
|
||||
if (0 < m_free.size() )
|
||||
{
|
||||
@@ -3084,7 +3084,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
BGFX_CHECK_HANDLE("destroyIndexBuffer", m_indexBufferHandle, _handle);
|
||||
bool ok = m_submit->free(_handle); BX_UNUSED(ok);
|
||||
BX_CHECK(ok, "Index buffer handle %d is already destroyed!", _handle.idx);
|
||||
BX_ASSERT(ok, "Index buffer handle %d is already destroyed!", _handle.idx);
|
||||
|
||||
IndexBuffer& ref = m_indexBuffers[_handle.idx];
|
||||
ref.m_name.clear();
|
||||
@@ -3192,7 +3192,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
BGFX_CHECK_HANDLE("destroyVertexBuffer", m_vertexBufferHandle, _handle);
|
||||
bool ok = m_submit->free(_handle); BX_UNUSED(ok);
|
||||
BX_CHECK(ok, "Vertex buffer handle %d is already destroyed!", _handle.idx);
|
||||
BX_ASSERT(ok, "Vertex buffer handle %d is already destroyed!", _handle.idx);
|
||||
|
||||
VertexBuffer& ref = m_vertexBuffers[_handle.idx];
|
||||
ref.m_name.clear();
|
||||
@@ -3303,7 +3303,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
{
|
||||
BGFX_MUTEX_SCOPE(m_resourceApiLock);
|
||||
|
||||
BX_CHECK(0 == (_flags & BGFX_BUFFER_COMPUTE_READ_WRITE), "Cannot initialize compute buffer from CPU.");
|
||||
BX_ASSERT(0 == (_flags & BGFX_BUFFER_COMPUTE_READ_WRITE), "Cannot initialize compute buffer from CPU.");
|
||||
const uint32_t indexSize = 0 == (_flags & BGFX_BUFFER_INDEX32) ? 2 : 4;
|
||||
DynamicIndexBufferHandle handle = createDynamicIndexBuffer(_mem->size/indexSize, _flags);
|
||||
|
||||
@@ -3325,7 +3325,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
BGFX_CHECK_HANDLE("updateDynamicIndexBuffer", m_dynamicIndexBufferHandle, _handle);
|
||||
|
||||
DynamicIndexBuffer& dib = m_dynamicIndexBuffers[_handle.idx];
|
||||
BX_CHECK(0 == (dib.m_flags & BGFX_BUFFER_COMPUTE_WRITE), "Can't update GPU buffer from CPU.");
|
||||
BX_ASSERT(0 == (dib.m_flags & BGFX_BUFFER_COMPUTE_WRITE), "Can't update GPU buffer from CPU.");
|
||||
const uint32_t indexSize = 0 == (dib.m_flags & BGFX_BUFFER_INDEX32) ? 2 : 4;
|
||||
|
||||
if (dib.m_size < _mem->size
|
||||
@@ -3346,7 +3346,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
+ bx::min(bx::uint32_satsub(dib.m_size, _startIndex*indexSize), _mem->size)
|
||||
, m_indexBuffers[dib.m_handle.idx].m_size) - offset
|
||||
;
|
||||
BX_CHECK(_mem->size <= size, "Truncating dynamic index buffer update (size %d, mem size %d)."
|
||||
BX_ASSERT(_mem->size <= size, "Truncating dynamic index buffer update (size %d, mem size %d)."
|
||||
, size
|
||||
, _mem->size
|
||||
);
|
||||
@@ -3513,7 +3513,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
BGFX_CHECK_HANDLE("updateDynamicVertexBuffer", m_dynamicVertexBufferHandle, _handle);
|
||||
|
||||
DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[_handle.idx];
|
||||
BX_CHECK(0 == (dvb.m_flags & BGFX_BUFFER_COMPUTE_WRITE), "Can't update GPU write buffer from CPU.");
|
||||
BX_ASSERT(0 == (dvb.m_flags & BGFX_BUFFER_COMPUTE_WRITE), "Can't update GPU write buffer from CPU.");
|
||||
|
||||
if (dvb.m_size < _mem->size
|
||||
&& 0 != (dvb.m_flags & BGFX_BUFFER_ALLOW_RESIZE) )
|
||||
@@ -3536,7 +3536,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
+ bx::min(bx::uint32_satsub(dvb.m_size, _startVertex*dvb.m_stride), _mem->size)
|
||||
, m_vertexBuffers[dvb.m_handle.idx].m_size) - offset
|
||||
;
|
||||
BX_CHECK(_mem->size <= size, "Truncating dynamic vertex buffer update (size %d, mem size %d)."
|
||||
BX_ASSERT(_mem->size <= size, "Truncating dynamic vertex buffer update (size %d, mem size %d)."
|
||||
, size
|
||||
, _mem->size
|
||||
);
|
||||
@@ -3875,7 +3875,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
}
|
||||
|
||||
bool ok = m_shaderHashMap.insert(shaderHash, handle.idx);
|
||||
BX_CHECK(ok, "Shader already exists!"); BX_UNUSED(ok);
|
||||
BX_ASSERT(ok, "Shader already exists!"); BX_UNUSED(ok);
|
||||
|
||||
ShaderRef& sr = m_shaderRef[handle.idx];
|
||||
sr.m_refCount = 1;
|
||||
@@ -4021,7 +4021,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
if (0 == refs)
|
||||
{
|
||||
bool ok = m_submit->free(_handle); BX_UNUSED(ok);
|
||||
BX_CHECK(ok, "Shader handle %d is already destroyed!", _handle.idx);
|
||||
BX_ASSERT(ok, "Shader handle %d is already destroyed!", _handle.idx);
|
||||
|
||||
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyShader);
|
||||
cmdbuf.write(_handle);
|
||||
@@ -4085,7 +4085,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
const uint32_t key = uint32_t(_fsh.idx<<16)|_vsh.idx;
|
||||
bool ok = m_programHashMap.insert(key, handle.idx);
|
||||
BX_CHECK(ok, "Program already exists (key: %x, handle: %3d)!", key, handle.idx); BX_UNUSED(ok);
|
||||
BX_ASSERT(ok, "Program already exists (key: %x, handle: %3d)!", key, handle.idx); BX_UNUSED(ok);
|
||||
|
||||
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateProgram);
|
||||
cmdbuf.write(handle);
|
||||
@@ -4137,7 +4137,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
const uint32_t key = uint32_t(_vsh.idx);
|
||||
bool ok = m_programHashMap.insert(key, handle.idx);
|
||||
BX_CHECK(ok, "Program already exists (key: %x, handle: %3d)!", key, handle.idx); BX_UNUSED(ok);
|
||||
BX_ASSERT(ok, "Program already exists (key: %x, handle: %3d)!", key, handle.idx); BX_UNUSED(ok);
|
||||
|
||||
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateProgram);
|
||||
cmdbuf.write(handle);
|
||||
@@ -4172,7 +4172,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
if (0 == refs)
|
||||
{
|
||||
bool ok = m_submit->free(_handle); BX_UNUSED(ok);
|
||||
BX_CHECK(ok, "Program handle %d is already destroyed!", _handle.idx);
|
||||
BX_ASSERT(ok, "Program handle %d is already destroyed!", _handle.idx);
|
||||
|
||||
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyProgram);
|
||||
cmdbuf.write(_handle);
|
||||
@@ -4309,7 +4309,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
BGFX_CHECK_HANDLE("readTexture", m_textureHandle, _handle);
|
||||
|
||||
const TextureRef& ref = m_textureRef[_handle.idx];
|
||||
BX_CHECK(_mip < ref.m_numMips, "Invalid mip: %d num mips:", _mip, ref.m_numMips); BX_UNUSED(ref);
|
||||
BX_ASSERT(_mip < ref.m_numMips, "Invalid mip: %d num mips:", _mip, ref.m_numMips); BX_UNUSED(ref);
|
||||
|
||||
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::ReadTexture);
|
||||
cmdbuf.write(_handle);
|
||||
@@ -4321,7 +4321,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
void resizeTexture(TextureHandle _handle, uint16_t _width, uint16_t _height, uint8_t _numMips, uint16_t _numLayers)
|
||||
{
|
||||
const TextureRef& textureRef = m_textureRef[_handle.idx];
|
||||
BX_CHECK(BackbufferRatio::Count != textureRef.m_bbRatio, "");
|
||||
BX_ASSERT(BackbufferRatio::Count != textureRef.m_bbRatio, "");
|
||||
|
||||
getTextureSizeFromRatio(BackbufferRatio::Enum(textureRef.m_bbRatio), _width, _height);
|
||||
_numMips = calcNumMips(1 < _numMips, _width, _height);
|
||||
@@ -4375,7 +4375,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
}
|
||||
|
||||
bool ok = m_submit->free(_handle); BX_UNUSED(ok);
|
||||
BX_CHECK(ok, "Texture handle %d is already destroyed!", _handle.idx);
|
||||
BX_ASSERT(ok, "Texture handle %d is already destroyed!", _handle.idx);
|
||||
|
||||
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyTexture);
|
||||
cmdbuf.write(_handle);
|
||||
@@ -4449,7 +4449,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
{
|
||||
BGFX_MUTEX_SCOPE(m_resourceApiLock);
|
||||
|
||||
BX_CHECK(checkFrameBuffer(_num, _attachment)
|
||||
BX_ASSERT(checkFrameBuffer(_num, _attachment)
|
||||
, "Too many frame buffer attachments (num attachments: %d, max color attachments %d)!"
|
||||
, _num
|
||||
, g_caps.limits.maxFBAttachments
|
||||
@@ -4473,7 +4473,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
{
|
||||
TextureHandle texHandle = _attachment[ii].handle;
|
||||
BGFX_CHECK_HANDLE("createFrameBuffer texture", m_textureHandle, texHandle);
|
||||
BX_CHECK(bbRatio == m_textureRef[texHandle.idx].m_bbRatio, "Mismatch in texture back-buffer ratio.");
|
||||
BX_ASSERT(bbRatio == m_textureRef[texHandle.idx].m_bbRatio, "Mismatch in texture back-buffer ratio.");
|
||||
BX_UNUSED(bbRatio);
|
||||
|
||||
ref.un.m_th[ii] = texHandle;
|
||||
@@ -4554,7 +4554,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
BGFX_CHECK_HANDLE("destroyFrameBuffer", m_frameBufferHandle, _handle);
|
||||
bool ok = m_submit->free(_handle); BX_UNUSED(ok);
|
||||
BX_CHECK(ok, "Frame buffer handle %d is already destroyed!", _handle.idx);
|
||||
BX_ASSERT(ok, "Frame buffer handle %d is already destroyed!", _handle.idx);
|
||||
|
||||
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyFrameBuffer);
|
||||
cmdbuf.write(_handle);
|
||||
@@ -4592,7 +4592,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
{
|
||||
UniformHandle handle = { idx };
|
||||
UniformRef& uniform = m_uniformRef[handle.idx];
|
||||
BX_CHECK(uniform.m_type == _type
|
||||
BX_ASSERT(uniform.m_type == _type
|
||||
, "Uniform type mismatch (type: %d, expected %d)."
|
||||
, _type
|
||||
, uniform.m_type
|
||||
@@ -4637,7 +4637,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
uniform.m_num = _num;
|
||||
|
||||
bool ok = m_uniformHashMap.insert(bx::hash<bx::HashMurmur2A>(_name), handle.idx);
|
||||
BX_CHECK(ok, "Uniform already exists (name: %s)!", _name); BX_UNUSED(ok);
|
||||
BX_ASSERT(ok, "Uniform already exists (name: %s)!", _name); BX_UNUSED(ok);
|
||||
|
||||
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateUniform);
|
||||
cmdbuf.write(handle);
|
||||
@@ -4669,13 +4669,13 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
BGFX_CHECK_HANDLE("destroyUniform", m_uniformHandle, _handle);
|
||||
|
||||
UniformRef& uniform = m_uniformRef[_handle.idx];
|
||||
BX_CHECK(uniform.m_refCount > 0, "Destroying already destroyed uniform %d.", _handle.idx);
|
||||
BX_ASSERT(uniform.m_refCount > 0, "Destroying already destroyed uniform %d.", _handle.idx);
|
||||
int32_t refs = --uniform.m_refCount;
|
||||
|
||||
if (0 == refs)
|
||||
{
|
||||
bool ok = m_submit->free(_handle); BX_UNUSED(ok);
|
||||
BX_CHECK(ok, "Uniform handle %d is already destroyed!", _handle.idx);
|
||||
BX_ASSERT(ok, "Uniform handle %d is already destroyed!", _handle.idx);
|
||||
|
||||
uniform.m_name.clear();
|
||||
m_uniformHashMap.removeByHandle(_handle.idx);
|
||||
@@ -4758,7 +4758,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
{
|
||||
BGFX_MUTEX_SCOPE(m_resourceApiLock);
|
||||
|
||||
BX_CHECK(_index < BGFX_CONFIG_MAX_COLOR_PALETTE, "Color palette index out of bounds %d (max: %d)."
|
||||
BX_ASSERT(_index < BGFX_CONFIG_MAX_COLOR_PALETTE, "Color palette index out of bounds %d (max: %d)."
|
||||
, _index
|
||||
, BGFX_CONFIG_MAX_COLOR_PALETTE
|
||||
);
|
||||
@@ -4789,7 +4789,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
BGFX_API_FUNC(void setViewClear(ViewId _id, uint16_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil) )
|
||||
{
|
||||
BX_CHECK(bx::equal(_depth, bx::clamp(_depth, 0.0f, 1.0f), 0.0001f)
|
||||
BX_ASSERT(bx::equal(_depth, bx::clamp(_depth, 0.0f, 1.0f), 0.0001f)
|
||||
, "Clear depth value must be between 0.0 and 1.0 (_depth %f)."
|
||||
, _depth
|
||||
);
|
||||
@@ -4799,7 +4799,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
BGFX_API_FUNC(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(bx::equal(_depth, bx::clamp(_depth, 0.0f, 1.0f), 0.0001f)
|
||||
BX_ASSERT(bx::equal(_depth, bx::clamp(_depth, 0.0f, 1.0f), 0.0001f)
|
||||
, "Clear depth value must be between 0.0 and 1.0 (_depth %f)."
|
||||
, _depth
|
||||
);
|
||||
@@ -4912,7 +4912,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
BGFX_PROFILER_SCOPE("bgfx/Render thread wait", 0xff2040ff);
|
||||
int64_t start = bx::getHPCounter();
|
||||
bool ok = m_renderSem.wait();
|
||||
BX_CHECK(ok, "Semaphore wait failed."); BX_UNUSED(ok);
|
||||
BX_ASSERT(ok, "Semaphore wait failed."); BX_UNUSED(ok);
|
||||
m_submit->m_waitRender = bx::getHPCounter() - start;
|
||||
m_submit->m_perfStats.waitRender = m_submit->m_waitRender;
|
||||
}
|
||||
@@ -4938,7 +4938,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
m_encoderHandle->reset();
|
||||
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);
|
||||
}
|
||||
|
||||
bx::Semaphore m_renderSem;
|
||||
|
||||
@@ -113,7 +113,7 @@ EGL_IMPORT
|
||||
BGFX_FATAL(m_surface != EGL_NO_SURFACE, Fatal::UnableToInitialize, "Failed to create surface.");
|
||||
|
||||
m_context = eglCreateContext(m_display, _config, _context, s_contextAttrs);
|
||||
BX_CHECK(NULL != m_context, "Create swap chain failed: %x", eglGetError() );
|
||||
BX_ASSERT(NULL != m_context, "Create swap chain failed: %x", eglGetError() );
|
||||
|
||||
makeCurrent();
|
||||
GL_CHECK(glClearColor(0.0f, 0.0f, 0.0f, 0.0f) );
|
||||
@@ -374,7 +374,7 @@ EGL_IMPORT
|
||||
// will take the first canvas element found on the web page.
|
||||
#define HTML5_TARGET_CANVAS_SELECTOR "#canvas"
|
||||
|
||||
BX_CHECK(emscripten_set_canvas_element_size(HTML5_TARGET_CANVAS_SELECTOR, _width, _height) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_canvas_element_size() failed in GlContext::resize()!");
|
||||
BX_ASSERT(emscripten_set_canvas_element_size(HTML5_TARGET_CANVAS_SELECTOR, _width, _height) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_canvas_element_size() failed in GlContext::resize()!");
|
||||
# else
|
||||
BX_UNUSED(_width, _height);
|
||||
# endif // BX_PLATFORM_*
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace bgfx { namespace gl
|
||||
|
||||
void makeCurrent()
|
||||
{
|
||||
BX_CHECK(emscripten_webgl_make_context_current(m_context) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_webgl_make_context_current() failed!");
|
||||
BX_ASSERT(emscripten_webgl_make_context_current(m_context) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_webgl_make_context_current() failed!");
|
||||
}
|
||||
|
||||
void swapBuffers()
|
||||
@@ -75,7 +75,7 @@ namespace bgfx { namespace gl
|
||||
m_primary = createSwapChain((void*)canvas);
|
||||
|
||||
if (_width && _height)
|
||||
BX_CHECK(emscripten_set_canvas_element_size(canvas, (int)_width, (int)_height) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_canvas_element_size() failed in GlContext::create()!");
|
||||
BX_ASSERT(emscripten_set_canvas_element_size(canvas, (int)_width, (int)_height) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_canvas_element_size() failed in GlContext::create()!");
|
||||
|
||||
makeCurrent(m_primary);
|
||||
}
|
||||
@@ -101,7 +101,7 @@ namespace bgfx { namespace gl
|
||||
return;
|
||||
}
|
||||
|
||||
BX_CHECK(emscripten_set_canvas_element_size(m_primary->m_canvas, (int) _width, (int) _height) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_canvas_element_size() failed in GlContext::resize()!");
|
||||
BX_ASSERT(emscripten_set_canvas_element_size(m_primary->m_canvas, (int) _width, (int) _height) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_canvas_element_size() failed in GlContext::resize()!");
|
||||
}
|
||||
|
||||
SwapChainGL* GlContext::createSwapChain(void* _nwh)
|
||||
@@ -127,7 +127,7 @@ namespace bgfx { namespace gl
|
||||
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(canvas, &s_attrs);
|
||||
if (context > 0)
|
||||
{
|
||||
BX_CHECK(emscripten_webgl_make_context_current(context) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_webgl_make_context_current() failed in GlContext::createSwapChain()!");
|
||||
BX_ASSERT(emscripten_webgl_make_context_current(context) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_webgl_make_context_current() failed in GlContext::createSwapChain()!");
|
||||
|
||||
SwapChainGL* swapChain = BX_NEW(g_allocator, SwapChainGL)(context, canvas);
|
||||
|
||||
|
||||
@@ -316,7 +316,7 @@ namespace bgfx { namespace gl
|
||||
BX_WARN(result, "SetPixelFormat failed (last err: 0x%08x)!", GetLastError() ); BX_UNUSED(result);
|
||||
|
||||
swapChain->m_context = wglCreateContextAttribsARB(swapChain->m_hdc, m_context, m_contextAttrs);
|
||||
BX_CHECK(NULL != swapChain->m_context, "Create swap chain failed: %x", glGetError() );
|
||||
BX_ASSERT(NULL != swapChain->m_context, "Create swap chain failed: %x", glGetError() );
|
||||
return swapChain;
|
||||
}
|
||||
|
||||
|
||||
@@ -358,7 +358,7 @@ namespace bgfx
|
||||
#define NVA_CHECK(_call) \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
int32_t __result__ = _call; \
|
||||
BX_CHECK(1 == __result__, #_call " FAILED 0x%08x\n", __result__); \
|
||||
BX_ASSERT(1 == __result__, #_call " FAILED 0x%08x\n", __result__); \
|
||||
BX_UNUSED(__result__); \
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ namespace bgfx
|
||||
break;
|
||||
|
||||
default:
|
||||
BX_CHECK(false, "predefined %d not handled", predefined.m_type);
|
||||
BX_ASSERT(false, "predefined %d not handled", predefined.m_type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -304,7 +304,7 @@ namespace bgfx
|
||||
handle = m_alloc.alloc();
|
||||
}
|
||||
|
||||
BX_CHECK(UINT16_MAX != handle, "Failed to find handle.");
|
||||
BX_ASSERT(UINT16_MAX != handle, "Failed to find handle.");
|
||||
|
||||
Data& data = m_data[handle];
|
||||
data.m_hash = _key;
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace bgfx
|
||||
#define _DX_CHECK(_call) \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
HRESULT __hr__ = _call; \
|
||||
BX_CHECK(SUCCEEDED(__hr__), #_call " FAILED 0x%08x" DX_CHECK_EXTRA_F "\n" \
|
||||
BX_ASSERT(SUCCEEDED(__hr__), #_call " FAILED 0x%08x" DX_CHECK_EXTRA_F "\n" \
|
||||
, (uint32_t)__hr__ \
|
||||
DX_CHECK_EXTRA_ARGS \
|
||||
); \
|
||||
@@ -92,7 +92,7 @@ namespace bgfx
|
||||
#define _DX_CHECK_REFCOUNT(_ptr, _expected) \
|
||||
BX_MACRO_BLOCK_BEGIN \
|
||||
ULONG count = getRefCount(_ptr); \
|
||||
BX_CHECK(isGraphicsDebuggerPresent() || _expected == count, "%p RefCount is %d (expected %d).", _ptr, count, _expected); \
|
||||
BX_ASSERT(isGraphicsDebuggerPresent() || _expected == count, "%p RefCount is %d (expected %d).", _ptr, count, _expected); \
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
#define _DX_NAME(_ptr, _format, ...) setDebugObjectName(_ptr, _format, ##__VA_ARGS__)
|
||||
@@ -111,7 +111,7 @@ namespace bgfx
|
||||
# define DX_NAME(_ptr, _format, ...)
|
||||
#endif // BGFX_CONFIG_DEBUG_OBJECT_NAME
|
||||
|
||||
#define DX_RELEASE(_ptr, _expected) _DX_RELEASE(_ptr, _expected, BX_CHECK)
|
||||
#define DX_RELEASE(_ptr, _expected) _DX_RELEASE(_ptr, _expected, BX_ASSERT)
|
||||
#define DX_RELEASE_W(_ptr, _expected) _DX_RELEASE(_ptr, _expected, BX_WARN)
|
||||
#define DX_RELEASE_I(_ptr) _DX_RELEASE(_ptr, 0, BX_NOOP)
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace bgfx
|
||||
{
|
||||
invalidate(_key);
|
||||
m_hashMap.insert(stl::make_pair(_key, _value) );
|
||||
BX_CHECK(isGraphicsDebuggerPresent()
|
||||
BX_ASSERT(isGraphicsDebuggerPresent()
|
||||
|| 1 == getRefCount(_value), "Interface ref count %d, hash %" PRIx64 "."
|
||||
, getRefCount(_value)
|
||||
, _key
|
||||
|
||||
@@ -2051,7 +2051,7 @@ namespace bgfx { namespace d3d11
|
||||
break;
|
||||
|
||||
default:
|
||||
BX_CHECK(false, "Invalid handle type?! %d", _handle.type);
|
||||
BX_ASSERT(false, "Invalid handle type?! %d", _handle.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3753,7 +3753,7 @@ namespace bgfx { namespace d3d11
|
||||
void BufferD3D11::update(uint32_t _offset, uint32_t _size, void* _data, bool _discard)
|
||||
{
|
||||
ID3D11DeviceContext* deviceCtx = s_renderD3D11->m_deviceCtx;
|
||||
BX_CHECK(m_dynamic, "Must be dynamic!");
|
||||
BX_ASSERT(m_dynamic, "Must be dynamic!");
|
||||
|
||||
#if USE_D3D11_STAGING_BUFFER
|
||||
BX_UNUSED(_discard);
|
||||
@@ -4775,7 +4775,7 @@ namespace bgfx { namespace d3d11
|
||||
|
||||
if (bimg::isDepth(bimg::TextureFormat::Enum(texture.m_textureFormat) ) )
|
||||
{
|
||||
BX_CHECK(NULL == m_dsv, "Frame buffer already has depth-stencil attached.");
|
||||
BX_ASSERT(NULL == m_dsv, "Frame buffer already has depth-stencil attached.");
|
||||
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
|
||||
dsvDesc.Format = s_textureFormat[texture.m_textureFormat].m_fmtDsv;
|
||||
@@ -5278,7 +5278,7 @@ namespace bgfx { namespace d3d11
|
||||
else
|
||||
{
|
||||
bool depthStencil = bimg::isDepth(bimg::TextureFormat::Enum(src.m_textureFormat) );
|
||||
BX_CHECK(!depthStencil
|
||||
BX_ASSERT(!depthStencil
|
||||
|| (width == src.m_width && height == src.m_height)
|
||||
, "When blitting depthstencil surface, source resolution must match destination."
|
||||
);
|
||||
|
||||
@@ -204,14 +204,14 @@ namespace bgfx { namespace d3d11
|
||||
|
||||
void create(const ShaderD3D11* _vsh, const ShaderD3D11* _fsh)
|
||||
{
|
||||
BX_CHECK(NULL != _vsh->m_ptr, "Vertex shader doesn't exist.");
|
||||
BX_ASSERT(NULL != _vsh->m_ptr, "Vertex shader doesn't exist.");
|
||||
m_vsh = _vsh;
|
||||
bx::memCopy(&m_predefined[0], _vsh->m_predefined, _vsh->m_numPredefined*sizeof(PredefinedUniform) );
|
||||
m_numPredefined = _vsh->m_numPredefined;
|
||||
|
||||
if (NULL != _fsh)
|
||||
{
|
||||
BX_CHECK(NULL != _fsh->m_ptr, "Fragment shader doesn't exist.");
|
||||
BX_ASSERT(NULL != _fsh->m_ptr, "Fragment shader doesn't exist.");
|
||||
m_fsh = _fsh;
|
||||
bx::memCopy(&m_predefined[m_numPredefined], _fsh->m_predefined, _fsh->m_numPredefined*sizeof(PredefinedUniform) );
|
||||
m_numPredefined += _fsh->m_numPredefined;
|
||||
|
||||
@@ -1918,7 +1918,7 @@ namespace bgfx { namespace d3d12
|
||||
break;
|
||||
|
||||
default:
|
||||
BX_CHECK(false, "Invalid handle type?! %d", _handle.type);
|
||||
BX_ASSERT(false, "Invalid handle type?! %d", _handle.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2105,7 +2105,7 @@ namespace bgfx { namespace d3d12
|
||||
{
|
||||
ID3D12Resource* resource = m_backBufferColor[ii];
|
||||
|
||||
BX_CHECK(DXGI_FORMAT_R8G8B8A8_UNORM == m_scd.format, "");
|
||||
BX_ASSERT(DXGI_FORMAT_R8G8B8A8_UNORM == m_scd.format, "");
|
||||
const uint32_t size = m_scd.width*m_scd.height*4;
|
||||
|
||||
void* ptr;
|
||||
@@ -2912,7 +2912,7 @@ namespace bgfx { namespace d3d12
|
||||
dxbcHash(temp->data + 20, size - 20, temp->data + 4);
|
||||
|
||||
patchShader = 0 == bx::memCmp(program.m_fsh->m_code->data, temp->data, 16);
|
||||
BX_CHECK(patchShader, "DXBC fragment shader patching error (ShaderHandle: %d).", program.m_fsh - m_shaders);
|
||||
BX_ASSERT(patchShader, "DXBC fragment shader patching error (ShaderHandle: %d).", program.m_fsh - m_shaders);
|
||||
|
||||
if (!patchShader)
|
||||
{
|
||||
@@ -3818,7 +3818,7 @@ namespace bgfx { namespace d3d12
|
||||
}
|
||||
}
|
||||
|
||||
BX_CHECK(0 == m_control.available(), "");
|
||||
BX_ASSERT(0 == m_control.available(), "");
|
||||
}
|
||||
|
||||
bool CommandQueueD3D12::tryFinish(uint64_t _waitFence)
|
||||
@@ -3960,7 +3960,7 @@ namespace bgfx { namespace d3d12
|
||||
Ty& BatchD3D12::getCmd(Enum _type)
|
||||
{
|
||||
uint32_t index = m_num[_type];
|
||||
BX_CHECK(index < m_maxDrawPerBatch, "Memory corruption...");
|
||||
BX_ASSERT(index < m_maxDrawPerBatch, "Memory corruption...");
|
||||
m_num[_type]++;
|
||||
Ty* cmd = &reinterpret_cast<Ty*>(m_cmds[_type])[index];
|
||||
return *cmd;
|
||||
@@ -4953,7 +4953,7 @@ namespace bgfx { namespace d3d12
|
||||
, numSrd
|
||||
, srd
|
||||
);
|
||||
BX_CHECK(0 != result, "Invalid size"); BX_UNUSED(result);
|
||||
BX_ASSERT(0 != result, "Invalid size"); BX_UNUSED(result);
|
||||
BX_TRACE("Update subresource %" PRId64, result);
|
||||
|
||||
setState(commandList, state);
|
||||
@@ -5216,7 +5216,7 @@ namespace bgfx { namespace d3d12
|
||||
|
||||
if (bimg::isDepth(bimg::TextureFormat::Enum(texture.m_textureFormat) ) )
|
||||
{
|
||||
BX_CHECK(!isValid(m_depth), "");
|
||||
BX_ASSERT(!isValid(m_depth), "");
|
||||
m_depth = at.handle;
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE dsvDescriptor = getCPUHandleHeapStart(s_renderD3D12->m_dsvDescriptorHeap);
|
||||
uint32_t dsvDescriptorSize = device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_DSV);
|
||||
@@ -5367,7 +5367,7 @@ namespace bgfx { namespace d3d12
|
||||
}
|
||||
else
|
||||
{
|
||||
BX_CHECK(false, "");
|
||||
BX_ASSERT(false, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,14 +282,14 @@ namespace bgfx { namespace d3d12
|
||||
|
||||
void create(const ShaderD3D12* _vsh, const ShaderD3D12* _fsh)
|
||||
{
|
||||
BX_CHECK(NULL != _vsh->m_code, "Vertex shader doesn't exist.");
|
||||
BX_ASSERT(NULL != _vsh->m_code, "Vertex shader doesn't exist.");
|
||||
m_vsh = _vsh;
|
||||
bx::memCopy(&m_predefined[0], _vsh->m_predefined, _vsh->m_numPredefined*sizeof(PredefinedUniform));
|
||||
m_numPredefined = _vsh->m_numPredefined;
|
||||
|
||||
if (NULL != _fsh)
|
||||
{
|
||||
BX_CHECK(NULL != _fsh->m_code, "Fragment shader doesn't exist.");
|
||||
BX_ASSERT(NULL != _fsh->m_code, "Fragment shader doesn't exist.");
|
||||
m_fsh = _fsh;
|
||||
bx::memCopy(&m_predefined[m_numPredefined], _fsh->m_predefined, _fsh->m_numPredefined*sizeof(PredefinedUniform));
|
||||
m_numPredefined += _fsh->m_numPredefined;
|
||||
|
||||
@@ -1737,7 +1737,7 @@ namespace bgfx { namespace d3d9
|
||||
void setSamplerState(uint8_t _stage, uint64_t _flags, const float _rgba[4])
|
||||
{
|
||||
const uint64_t flags = _flags&( (~BGFX_SAMPLER_RESERVED_MASK) | BGFX_SAMPLER_BITS_MASK | BGFX_TEXTURE_SRGB);
|
||||
BX_CHECK(_stage < BX_COUNTOF(m_samplerFlags), "");
|
||||
BX_ASSERT(_stage < BX_COUNTOF(m_samplerFlags), "");
|
||||
if (m_samplerFlags[_stage] != flags)
|
||||
{
|
||||
m_samplerFlags[_stage] = flags;
|
||||
@@ -2809,7 +2809,7 @@ namespace bgfx { namespace d3d9
|
||||
}
|
||||
}
|
||||
|
||||
BX_CHECK(false, "You should not be here.");
|
||||
BX_ASSERT(false, "You should not be here.");
|
||||
_pitch = 0;
|
||||
_slicePitch = 0;
|
||||
return NULL;
|
||||
@@ -2843,7 +2843,7 @@ namespace bgfx { namespace d3d9
|
||||
return;
|
||||
}
|
||||
|
||||
BX_CHECK(false, "You should not be here.");
|
||||
BX_ASSERT(false, "You should not be here.");
|
||||
}
|
||||
|
||||
void TextureD3D9::dirty(uint8_t _side, const Rect& _rect, uint16_t _z, uint16_t _depth)
|
||||
@@ -2886,7 +2886,7 @@ namespace bgfx { namespace d3d9
|
||||
return;
|
||||
}
|
||||
|
||||
BX_CHECK(false, "You should not be here.");
|
||||
BX_ASSERT(false, "You should not be here.");
|
||||
}
|
||||
|
||||
IDirect3DSurface9* TextureD3D9::getSurface(uint8_t _side, uint8_t _mip) const
|
||||
@@ -2900,7 +2900,7 @@ namespace bgfx { namespace d3d9
|
||||
break;
|
||||
|
||||
case Texture3D:
|
||||
BX_CHECK(false, "");
|
||||
BX_ASSERT(false, "");
|
||||
break;
|
||||
|
||||
case TextureCube:
|
||||
@@ -3416,7 +3416,7 @@ namespace bgfx { namespace d3d9
|
||||
}
|
||||
else
|
||||
{
|
||||
BX_CHECK(false, "");
|
||||
BX_ASSERT(false, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3812,7 +3812,7 @@ namespace bgfx { namespace d3d9
|
||||
|
||||
if (isCompute)
|
||||
{
|
||||
BX_CHECK(false, "Compute is not supported on DirectX 9.");
|
||||
BX_ASSERT(false, "Compute is not supported on DirectX 9.");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1599,7 +1599,7 @@ namespace bgfx { namespace gl
|
||||
// Avoid creating test textures for WebGL, that causes error noise in the browser console; instead examine the supported texture formats from the spec.
|
||||
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_get_current_context();
|
||||
EmscriptenWebGLContextAttributes attrs;
|
||||
BX_CHECK(emscripten_webgl_get_context_attributes(ctx, &attrs) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_webgl_get_context_attributes() failed in isTextureFormatValidPerSpec()!");
|
||||
BX_ASSERT(emscripten_webgl_get_context_attributes(ctx, &attrs) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_webgl_get_context_attributes() failed in isTextureFormatValidPerSpec()!");
|
||||
int glesVersion = attrs.majorVersion + 1;
|
||||
switch(_format)
|
||||
{
|
||||
@@ -3400,7 +3400,7 @@ namespace bgfx { namespace gl
|
||||
break;
|
||||
|
||||
default:
|
||||
BX_CHECK(false, "Invalid handle type?! %d", _handle.type);
|
||||
BX_ASSERT(false, "Invalid handle type?! %d", _handle.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3658,7 +3658,7 @@ namespace bgfx { namespace gl
|
||||
;
|
||||
GL_CHECK(glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, m_msaaBackBufferRbos[1]) );
|
||||
|
||||
BX_CHECK(GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER)
|
||||
BX_ASSERT(GL_FRAMEBUFFER_COMPLETE == glCheckFramebufferStatus(GL_FRAMEBUFFER)
|
||||
, "glCheckFramebufferStatus failed 0x%08x"
|
||||
, glCheckFramebufferStatus(GL_FRAMEBUFFER)
|
||||
);
|
||||
@@ -4412,7 +4412,7 @@ namespace bgfx { namespace gl
|
||||
static void frameBufferValidate()
|
||||
{
|
||||
GLenum complete = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
BX_CHECK(GL_FRAMEBUFFER_COMPLETE == complete
|
||||
BX_ASSERT(GL_FRAMEBUFFER_COMPLETE == complete
|
||||
, "glCheckFramebufferStatus failed 0x%08x: %s"
|
||||
, complete
|
||||
, glEnumName(complete)
|
||||
@@ -4486,7 +4486,7 @@ namespace bgfx { namespace gl
|
||||
|
||||
#undef GLSL_TYPE
|
||||
|
||||
BX_CHECK(false, "Unknown GLSL type? %x", _type);
|
||||
BX_ASSERT(false, "Unknown GLSL type? %x", _type);
|
||||
return "UNKNOWN GLSL TYPE!";
|
||||
}
|
||||
|
||||
@@ -4583,7 +4583,7 @@ namespace bgfx { namespace gl
|
||||
return UniformType::Sampler;
|
||||
};
|
||||
|
||||
BX_CHECK(false, "Unrecognized GL type 0x%04x.", _type);
|
||||
BX_ASSERT(false, "Unrecognized GL type 0x%04x.", _type);
|
||||
return UniformType::End;
|
||||
}
|
||||
|
||||
@@ -4946,7 +4946,7 @@ namespace bgfx { namespace gl
|
||||
m_used[used++] = ii;
|
||||
}
|
||||
}
|
||||
BX_CHECK(used < BX_COUNTOF(m_used), "Out of bounds %d > array size %d.", used, Attrib::Count);
|
||||
BX_ASSERT(used < BX_COUNTOF(m_used), "Out of bounds %d > array size %d.", used, Attrib::Count);
|
||||
m_usedCount = (uint8_t)used;
|
||||
|
||||
used = 0;
|
||||
@@ -4959,7 +4959,7 @@ namespace bgfx { namespace gl
|
||||
m_instanceData[used++] = loc;
|
||||
}
|
||||
}
|
||||
BX_CHECK(used < BX_COUNTOF(m_instanceData), "Out of bounds %d > array size %d."
|
||||
BX_ASSERT(used < BX_COUNTOF(m_instanceData), "Out of bounds %d > array size %d."
|
||||
, used
|
||||
, BX_COUNTOF(m_instanceData)
|
||||
);
|
||||
@@ -5085,7 +5085,7 @@ namespace bgfx { namespace gl
|
||||
if (!writeOnly)
|
||||
{
|
||||
GL_CHECK(glGenTextures(1, &m_id) );
|
||||
BX_CHECK(0 != m_id, "Failed to generate texture id.");
|
||||
BX_ASSERT(0 != m_id, "Failed to generate texture id.");
|
||||
GL_CHECK(glBindTexture(_target, m_id) );
|
||||
GL_CHECK(glPixelStorei(GL_UNPACK_ALIGNMENT, 1) );
|
||||
|
||||
@@ -5180,7 +5180,7 @@ namespace bgfx { namespace gl
|
||||
&& (0 != msaaQuality || writeOnly) )
|
||||
{
|
||||
GL_CHECK(glGenRenderbuffers(1, &m_rbo) );
|
||||
BX_CHECK(0 != m_rbo, "Failed to generate renderbuffer id.");
|
||||
BX_ASSERT(0 != m_rbo, "Failed to generate renderbuffer id.");
|
||||
GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, m_rbo) );
|
||||
|
||||
if (0 == msaaQuality)
|
||||
|
||||
@@ -1119,7 +1119,7 @@ namespace bgfx { namespace gl
|
||||
#define IGNORE_GL_ERROR_CHECK(...) BX_NOOP()
|
||||
|
||||
#if BGFX_CONFIG_DEBUG
|
||||
# define GL_CHECK(_call) _GL_CHECK(BX_CHECK, _call)
|
||||
# define GL_CHECK(_call) _GL_CHECK(BX_ASSERT, _call)
|
||||
# define GL_CHECK_I(_call) _GL_CHECK(IGNORE_GL_ERROR_CHECK, _call)
|
||||
#else
|
||||
# define GL_CHECK(_call) _call
|
||||
@@ -1275,7 +1275,7 @@ namespace bgfx { namespace gl
|
||||
m_flags = _flags;
|
||||
|
||||
GL_CHECK(glGenBuffers(1, &m_id) );
|
||||
BX_CHECK(0 != m_id, "Failed to generate buffer id.");
|
||||
BX_ASSERT(0 != m_id, "Failed to generate buffer id.");
|
||||
GL_CHECK(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_id) );
|
||||
GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER
|
||||
, _size
|
||||
@@ -1287,7 +1287,7 @@ namespace bgfx { namespace gl
|
||||
|
||||
void update(uint32_t _offset, uint32_t _size, void* _data, bool _discard = false)
|
||||
{
|
||||
BX_CHECK(0 != m_id, "Updating invalid index buffer.");
|
||||
BX_ASSERT(0 != m_id, "Updating invalid index buffer.");
|
||||
|
||||
if (_discard)
|
||||
{
|
||||
@@ -1323,7 +1323,7 @@ namespace bgfx { namespace gl
|
||||
m_target = drawIndirect ? GL_DRAW_INDIRECT_BUFFER : GL_ARRAY_BUFFER;
|
||||
|
||||
GL_CHECK(glGenBuffers(1, &m_id) );
|
||||
BX_CHECK(0 != m_id, "Failed to generate buffer id.");
|
||||
BX_ASSERT(0 != m_id, "Failed to generate buffer id.");
|
||||
GL_CHECK(glBindBuffer(m_target, m_id) );
|
||||
GL_CHECK(glBufferData(m_target
|
||||
, _size
|
||||
@@ -1335,7 +1335,7 @@ namespace bgfx { namespace gl
|
||||
|
||||
void update(uint32_t _offset, uint32_t _size, void* _data, bool _discard = false)
|
||||
{
|
||||
BX_CHECK(0 != m_id, "Updating invalid vertex buffer.");
|
||||
BX_ASSERT(0 != m_id, "Updating invalid vertex buffer.");
|
||||
|
||||
if (_discard)
|
||||
{
|
||||
|
||||
@@ -819,7 +819,7 @@ VK_IMPORT_DEVICE
|
||||
|
||||
void setImageMemoryBarrier(VkCommandBuffer _commandBuffer, VkImage _image, VkImageAspectFlags _aspectMask, VkImageLayout _oldLayout, VkImageLayout _newLayout, uint32_t _levelCount, uint32_t _layerCount)
|
||||
{
|
||||
BX_CHECK(true
|
||||
BX_ASSERT(true
|
||||
&& _newLayout != VK_IMAGE_LAYOUT_UNDEFINED
|
||||
&& _newLayout != VK_IMAGE_LAYOUT_PREINITIALIZED
|
||||
, "_newLayout cannot use VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED."
|
||||
@@ -1968,7 +1968,7 @@ VK_IMPORT_DEVICE
|
||||
}
|
||||
}
|
||||
|
||||
BX_CHECK(surfaceFormatIdx < numSurfaceFormats, "Cannot find preferred surface format from supported surface formats");
|
||||
BX_ASSERT(surfaceFormatIdx < numSurfaceFormats, "Cannot find preferred surface format from supported surface formats");
|
||||
BX_WARN(surfaceFormatSrgbIdx < numSurfaceFormats, "Cannot find preferred sRGB surface format from supported surface formats");
|
||||
|
||||
m_backBufferColorFormat = surfaceFormats[surfaceFormatIdx];
|
||||
@@ -2681,7 +2681,7 @@ VK_IMPORT_DEVICE
|
||||
break;
|
||||
|
||||
default:
|
||||
BX_CHECK(false, "Invalid handle type?! %d", _handle.type);
|
||||
BX_ASSERT(false, "Invalid handle type?! %d", _handle.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -4849,7 +4849,7 @@ VK_DESTROY
|
||||
const uint16_t stage = regIndex - 16 - (fragment ? 48 : 0); // regIndex is used for image/sampler binding index
|
||||
|
||||
const UniformRegInfo* info = s_renderVK->m_uniformReg.find(name);
|
||||
BX_CHECK(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
|
||||
BX_ASSERT(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
|
||||
|
||||
m_bindInfo[stage].uniformHandle = info->m_handle;
|
||||
m_bindInfo[stage].type = BindType::Sampler;
|
||||
@@ -4861,7 +4861,7 @@ VK_DESTROY
|
||||
else
|
||||
{
|
||||
const UniformRegInfo* info = s_renderVK->m_uniformReg.find(name);
|
||||
BX_CHECK(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
|
||||
BX_ASSERT(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
|
||||
|
||||
if (NULL != info)
|
||||
{
|
||||
@@ -5036,7 +5036,7 @@ VK_DESTROY
|
||||
|
||||
void ProgramVK::create(const ShaderVK* _vsh, const ShaderVK* _fsh)
|
||||
{
|
||||
BX_CHECK(NULL != _vsh->m_code, "Vertex shader doesn't exist.");
|
||||
BX_ASSERT(NULL != _vsh->m_code, "Vertex shader doesn't exist.");
|
||||
m_vsh = _vsh;
|
||||
bx::memCopy(
|
||||
&m_predefined[0]
|
||||
@@ -5047,7 +5047,7 @@ VK_DESTROY
|
||||
|
||||
if (NULL != _fsh)
|
||||
{
|
||||
BX_CHECK(NULL != _fsh->m_code, "Fragment shader doesn't exist.");
|
||||
BX_ASSERT(NULL != _fsh->m_code, "Fragment shader doesn't exist.");
|
||||
m_fsh = _fsh;
|
||||
bx::memCopy(
|
||||
&m_predefined[m_numPredefined]
|
||||
|
||||
@@ -223,7 +223,7 @@
|
||||
BX_MACRO_BLOCK_END
|
||||
|
||||
#if BGFX_CONFIG_DEBUG
|
||||
# define VK_CHECK(_call) _VK_CHECK(BX_CHECK, _call)
|
||||
# define VK_CHECK(_call) _VK_CHECK(BX_ASSERT, _call)
|
||||
#else
|
||||
# define VK_CHECK(_call) _call
|
||||
#endif // BGFX_CONFIG_DEBUG
|
||||
|
||||
@@ -511,7 +511,7 @@ namespace bgfx { namespace webgpu
|
||||
}
|
||||
else
|
||||
{
|
||||
BX_CHECK(false, "Device error: %s", message);
|
||||
BX_ASSERT(false, "Device error: %s", message);
|
||||
}
|
||||
|
||||
s_ignoreError = false;
|
||||
@@ -828,7 +828,7 @@ namespace bgfx { namespace webgpu
|
||||
if (readback.m_mapped)
|
||||
return;
|
||||
|
||||
BX_CHECK(readback.m_mip<texture.m_numMips,"Invalid mip: %d num mips:", readback.m_mip,texture.m_numMips);
|
||||
BX_ASSERT(readback.m_mip<texture.m_numMips,"Invalid mip: %d num mips:", readback.m_mip,texture.m_numMips);
|
||||
|
||||
uint32_t srcWidth = bx::uint32_max(1, texture.m_width >> readback.m_mip);
|
||||
uint32_t srcHeight = bx::uint32_max(1, texture.m_height >> readback.m_mip);
|
||||
@@ -1064,7 +1064,7 @@ namespace bgfx { namespace webgpu
|
||||
break;
|
||||
|
||||
default:
|
||||
BX_CHECK(false, "Invalid handle type?! %d", _handle.type);
|
||||
BX_ASSERT(false, "Invalid handle type?! %d", _handle.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1152,11 +1152,11 @@ namespace bgfx { namespace webgpu
|
||||
uint8_t flags = predefined.m_type;
|
||||
setShaderUniform(flags, predefined.m_loc, proj, 4);
|
||||
|
||||
BX_CHECK(program.m_vsh->m_size > 0, "Not supposed to happen");
|
||||
BX_ASSERT(program.m_vsh->m_size > 0, "Not supposed to happen");
|
||||
const uint32_t voffset = scratchBuffer.write(m_vsScratch, program.m_vsh->m_gpuSize);
|
||||
|
||||
const uint32_t fsize = (NULL != program.m_fsh ? program.m_fsh->m_gpuSize : 0);
|
||||
BX_CHECK(fsize == 0, "Not supposed to happen");
|
||||
BX_ASSERT(fsize == 0, "Not supposed to happen");
|
||||
|
||||
TextureWgpu& texture = m_textures[_blitter.m_texture.idx];
|
||||
|
||||
@@ -1323,7 +1323,7 @@ namespace bgfx { namespace webgpu
|
||||
template <class Encoder>
|
||||
void bindProgram(Encoder& encoder, const ProgramWgpu& program, BindStateWgpu& bindState, uint32_t numOffset, uint32_t* offsets)
|
||||
{
|
||||
BX_CHECK(bindState.numOffset == numOffset, "We're obviously doing something wrong");
|
||||
BX_ASSERT(bindState.numOffset == numOffset, "We're obviously doing something wrong");
|
||||
encoder.SetBindGroup(0, bindState.m_bindGroup, numOffset, offsets);
|
||||
}
|
||||
|
||||
@@ -1340,7 +1340,7 @@ namespace bgfx { namespace webgpu
|
||||
|
||||
bool isUsed = isValid(program.m_bindInfo[stage].m_uniform);
|
||||
|
||||
BX_CHECK(!isUsed || kInvalidHandle != bind.m_idx, "All expected bindings must be bound with WebGPU");
|
||||
BX_ASSERT(!isUsed || kInvalidHandle != bind.m_idx, "All expected bindings must be bound with WebGPU");
|
||||
|
||||
if (kInvalidHandle != bind.m_idx)
|
||||
{
|
||||
@@ -2484,7 +2484,7 @@ namespace bgfx { namespace webgpu
|
||||
const bool fragment = isShaderType(magic, 'F');
|
||||
uint8_t fragmentBit = fragment ? BGFX_UNIFORM_FRAGMENTBIT : 0;
|
||||
|
||||
BX_CHECK(!isShaderVerLess(magic, 7), "WebGPU backend supports only shader binary version >= 7");
|
||||
BX_ASSERT(!isShaderVerLess(magic, 7), "WebGPU backend supports only shader binary version >= 7");
|
||||
|
||||
if (0 < count)
|
||||
{
|
||||
@@ -2562,7 +2562,7 @@ namespace bgfx { namespace webgpu
|
||||
else if (UniformType::Sampler == (~BGFX_UNIFORM_MASK & type))
|
||||
{
|
||||
const UniformRegInfo* info = s_renderWgpu->m_uniformReg.find(name);
|
||||
BX_CHECK(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
|
||||
BX_ASSERT(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
|
||||
|
||||
const uint8_t stage = regIndex - 16 - (fragment ? 48 : 0);
|
||||
|
||||
@@ -2593,7 +2593,7 @@ namespace bgfx { namespace webgpu
|
||||
else
|
||||
{
|
||||
const UniformRegInfo* info = s_renderWgpu->m_uniformReg.find(name);
|
||||
BX_CHECK(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
|
||||
BX_ASSERT(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name);
|
||||
|
||||
if(NULL == m_constantBuffer)
|
||||
{
|
||||
@@ -2722,19 +2722,19 @@ namespace bgfx { namespace webgpu
|
||||
|
||||
void ProgramWgpu::create(const ShaderWgpu* _vsh, const ShaderWgpu* _fsh)
|
||||
{
|
||||
BX_CHECK(_vsh->m_module, "Vertex shader doesn't exist.");
|
||||
BX_ASSERT(_vsh->m_module, "Vertex shader doesn't exist.");
|
||||
m_vsh = _vsh;
|
||||
m_fsh = _fsh;
|
||||
m_gpuSize = _vsh->m_gpuSize + (_fsh ? _fsh->m_gpuSize : 0);
|
||||
|
||||
//BX_CHECK(NULL != _vsh->m_code, "Vertex shader doesn't exist.");
|
||||
//BX_ASSERT(NULL != _vsh->m_code, "Vertex shader doesn't exist.");
|
||||
m_vsh = _vsh;
|
||||
bx::memCopy(&m_predefined[0], _vsh->m_predefined, _vsh->m_numPredefined * sizeof(PredefinedUniform));
|
||||
m_numPredefined = _vsh->m_numPredefined;
|
||||
|
||||
if(NULL != _fsh)
|
||||
{
|
||||
//BX_CHECK(NULL != _fsh->m_code, "Fragment shader doesn't exist.");
|
||||
//BX_ASSERT(NULL != _fsh->m_code, "Fragment shader doesn't exist.");
|
||||
m_fsh = _fsh;
|
||||
bx::memCopy(&m_predefined[m_numPredefined], _fsh->m_predefined, _fsh->m_numPredefined * sizeof(PredefinedUniform));
|
||||
m_numPredefined += _fsh->m_numPredefined;
|
||||
@@ -2810,7 +2810,7 @@ namespace bgfx { namespace webgpu
|
||||
|
||||
m_numBuffers = _vsh->m_numBuffers;
|
||||
|
||||
BX_CHECK(m_numUniforms + m_numSamplers * 2 + m_numBuffers == numBindings, "");
|
||||
BX_ASSERT(m_numUniforms + m_numSamplers * 2 + m_numBuffers == numBindings, "");
|
||||
|
||||
wgpu::BindGroupLayoutDescriptor bindGroupDesc;
|
||||
bindGroupDesc.entryCount = numBindings;
|
||||
@@ -3460,13 +3460,13 @@ namespace bgfx { namespace webgpu
|
||||
}
|
||||
}
|
||||
|
||||
BX_CHECK(NULL != m_staging, "No available mapped uniform buffer");
|
||||
BX_ASSERT(NULL != m_staging, "No available mapped uniform buffer");
|
||||
}
|
||||
|
||||
uint32_t ScratchBufferWgpu::write(void* data, uint64_t _size, uint64_t _offset)
|
||||
{
|
||||
BX_CHECK(nullptr != m_staging, "Cannot write uniforms outside of begin()/submit() calls");
|
||||
BX_CHECK(m_size > m_offset + _offset, "Out-of-bounds scratch buffer write");
|
||||
BX_ASSERT(nullptr != m_staging, "Cannot write uniforms outside of begin()/submit() calls");
|
||||
BX_ASSERT(m_size > m_offset + _offset, "Out-of-bounds scratch buffer write");
|
||||
uint32_t offset = m_offset;
|
||||
bx::memCopy((void*)((uint8_t*)m_staging->m_data + offset), data, _size);
|
||||
m_offset += _offset;
|
||||
@@ -3475,8 +3475,8 @@ namespace bgfx { namespace webgpu
|
||||
|
||||
uint32_t ScratchBufferWgpu::write(void* data, uint64_t _size)
|
||||
{
|
||||
BX_CHECK(nullptr != m_staging, "Cannot write uniforms outside of begin()/submit() calls");
|
||||
BX_CHECK(m_size > m_offset + _size, "Out-of-bounds scratch buffer write");
|
||||
BX_ASSERT(nullptr != m_staging, "Cannot write uniforms outside of begin()/submit() calls");
|
||||
BX_ASSERT(m_size > m_offset + _size, "Out-of-bounds scratch buffer write");
|
||||
uint32_t offset = m_offset;
|
||||
bx::memCopy((void*)((uint8_t*)m_staging->m_data + offset), data, _size);
|
||||
m_offset += _size;
|
||||
|
||||
@@ -225,7 +225,7 @@ namespace bgfx
|
||||
|
||||
const char* getName(Dx9bcOpcode::Enum _opcode)
|
||||
{
|
||||
BX_CHECK(_opcode < Dx9bcOpcode::Count, "Unknown opcode id %d (%x).", _opcode, _opcode);
|
||||
BX_ASSERT(_opcode < Dx9bcOpcode::Count, "Unknown opcode id %d (%x).", _opcode, _opcode);
|
||||
return s_dx9bcOpcode[_opcode];
|
||||
}
|
||||
|
||||
@@ -458,7 +458,7 @@ namespace bgfx
|
||||
break;
|
||||
|
||||
default:
|
||||
BX_CHECK(false, "Instruction %s with invalid number of operands %d (numValues %d)."
|
||||
BX_ASSERT(false, "Instruction %s with invalid number of operands %d (numValues %d)."
|
||||
, getName(_instruction.opcode)
|
||||
, _instruction.numOperands
|
||||
, info.numValues
|
||||
@@ -642,7 +642,7 @@ namespace bgfx
|
||||
char temp[512];
|
||||
toString(temp, 512, instruction);
|
||||
|
||||
BX_CHECK(length/4 == instruction.length
|
||||
BX_ASSERT(length/4 == instruction.length
|
||||
, "%s\nread %d, expected %d"
|
||||
, temp
|
||||
, length/4
|
||||
@@ -712,7 +712,7 @@ namespace bgfx
|
||||
{
|
||||
Dx9bcInstruction instruction;
|
||||
uint32_t size = read(&reader, instruction, _err);
|
||||
BX_CHECK(size/4 == instruction.length, "read %d, expected %d", size/4, instruction.length); BX_UNUSED(size);
|
||||
BX_ASSERT(size/4 == instruction.length, "read %d, expected %d", size/4, instruction.length); BX_UNUSED(size);
|
||||
|
||||
bool cont = _fn(token * sizeof(uint32_t), instruction, _userData);
|
||||
if (!cont)
|
||||
@@ -737,7 +737,7 @@ namespace bgfx
|
||||
{
|
||||
Dx9bcInstruction instruction;
|
||||
uint32_t size = read(&reader, instruction, _err);
|
||||
BX_CHECK(size/4 == instruction.length, "read %d, expected %d", size/4, instruction.length); BX_UNUSED(size);
|
||||
BX_ASSERT(size/4 == instruction.length, "read %d, expected %d", size/4, instruction.length); BX_UNUSED(size);
|
||||
|
||||
_fn(instruction, _userData);
|
||||
|
||||
|
||||
@@ -468,7 +468,7 @@ namespace bgfx
|
||||
|
||||
const char* getName(DxbcOpcode::Enum _opcode)
|
||||
{
|
||||
BX_CHECK(_opcode < DxbcOpcode::Count, "Unknown opcode id %d.", _opcode);
|
||||
BX_ASSERT(_opcode < DxbcOpcode::Count, "Unknown opcode id %d.", _opcode);
|
||||
return s_dxbcOpcode[_opcode];
|
||||
}
|
||||
|
||||
@@ -825,7 +825,7 @@ namespace bgfx
|
||||
break;
|
||||
|
||||
default:
|
||||
BX_CHECK(false, "sub operand addressing mode %d", _subOperand.addrMode);
|
||||
BX_ASSERT(false, "sub operand addressing mode %d", _subOperand.addrMode);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -878,7 +878,7 @@ namespace bgfx
|
||||
break;
|
||||
|
||||
default:
|
||||
BX_CHECK(false, "sub operand addressing mode %d", _subOperand.addrMode);
|
||||
BX_ASSERT(false, "sub operand addressing mode %d", _subOperand.addrMode);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -967,7 +967,7 @@ namespace bgfx
|
||||
break;
|
||||
|
||||
default:
|
||||
BX_CHECK(false, "operand %d addressing mode %d", ii, _operand.addrMode[ii]);
|
||||
BX_ASSERT(false, "operand %d addressing mode %d", ii, _operand.addrMode[ii]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1042,7 +1042,7 @@ namespace bgfx
|
||||
break;
|
||||
|
||||
default:
|
||||
BX_CHECK(false, "operand %d addressing mode %d", ii, _operand.addrMode[ii]);
|
||||
BX_ASSERT(false, "operand %d addressing mode %d", ii, _operand.addrMode[ii]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1065,7 +1065,7 @@ namespace bgfx
|
||||
// +-------------------------------- extended
|
||||
|
||||
_instruction.opcode = DxbcOpcode::Enum( (token & UINT32_C(0x000007ff) ) );
|
||||
BX_CHECK(_instruction.opcode < DxbcOpcode::Enum::Count, "unknown opcode");
|
||||
BX_ASSERT(_instruction.opcode < DxbcOpcode::Enum::Count, "unknown opcode");
|
||||
|
||||
_instruction.length = uint8_t( (token & UINT32_C(0x7f000000) ) >> 24);
|
||||
bool extended = 0 != (token & UINT32_C(0x80000000) );
|
||||
@@ -1299,7 +1299,7 @@ namespace bgfx
|
||||
uint32_t num;
|
||||
size += read(_reader, num, _err);
|
||||
|
||||
BX_CHECK(false, "not implemented.");
|
||||
BX_ASSERT(false, "not implemented.");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1327,7 +1327,7 @@ namespace bgfx
|
||||
break;
|
||||
|
||||
default:
|
||||
BX_CHECK(false, "Instruction %s with invalid number of operands %d (numValues %d)."
|
||||
BX_ASSERT(false, "Instruction %s with invalid number of operands %d (numValues %d)."
|
||||
, getName(_instruction.opcode)
|
||||
, info.numOperands
|
||||
, info.numValues
|
||||
@@ -1914,7 +1914,7 @@ namespace bgfx
|
||||
|
||||
default:
|
||||
size += chunkSize;
|
||||
BX_CHECK(false, "UNKNOWN FOURCC %c%c%c%c %d"
|
||||
BX_ASSERT(false, "UNKNOWN FOURCC %c%c%c%c %d"
|
||||
, ( (char*)&fourcc)[0]
|
||||
, ( (char*)&fourcc)[1]
|
||||
, ( (char*)&fourcc)[2]
|
||||
@@ -2001,7 +2001,7 @@ namespace bgfx
|
||||
{
|
||||
DxbcInstruction instruction;
|
||||
uint32_t size = read(&reader, instruction, _err);
|
||||
BX_CHECK(size/4 == instruction.length, "read %d, expected %d", size/4, instruction.length); BX_UNUSED(size);
|
||||
BX_ASSERT(size/4 == instruction.length, "read %d, expected %d", size/4, instruction.length); BX_UNUSED(size);
|
||||
|
||||
bool cont = _fn(token * sizeof(uint32_t), instruction, _userData);
|
||||
if (!cont)
|
||||
@@ -2028,7 +2028,7 @@ namespace bgfx
|
||||
{
|
||||
DxbcInstruction instruction;
|
||||
uint32_t size = read(&reader, instruction, _err);
|
||||
BX_CHECK(size/4 == instruction.length, "read %d, expected %d", size/4, instruction.length); BX_UNUSED(size);
|
||||
BX_ASSERT(size/4 == instruction.length, "read %d, expected %d", size/4, instruction.length); BX_UNUSED(size);
|
||||
|
||||
_fn(instruction, _userData);
|
||||
|
||||
|
||||
@@ -809,7 +809,7 @@ namespace bgfx
|
||||
const char* getName(SpvDecoration::Enum _enum)
|
||||
{
|
||||
BX_UNUSED(s_spvDecorationInfo);
|
||||
BX_CHECK(_enum <= SpvDecoration::Count, "Unknown decoration id %d.", _enum);
|
||||
BX_ASSERT(_enum <= SpvDecoration::Count, "Unknown decoration id %d.", _enum);
|
||||
return _enum <= SpvDecoration::Count
|
||||
? s_spvDecoration[_enum]
|
||||
: "?SpvDecoration?"
|
||||
@@ -839,7 +839,7 @@ namespace bgfx
|
||||
|
||||
const char* getName(SpvStorageClass::Enum _enum)
|
||||
{
|
||||
BX_CHECK(_enum <= SpvStorageClass::Count, "Unknown storage class id %d.", _enum);
|
||||
BX_ASSERT(_enum <= SpvStorageClass::Count, "Unknown storage class id %d.", _enum);
|
||||
return _enum <= SpvStorageClass::Count
|
||||
? s_spvStorageClass[_enum]
|
||||
: "?SpvStorageClass?"
|
||||
@@ -895,7 +895,7 @@ namespace bgfx
|
||||
|
||||
const char* getName(SpvBuiltin::Enum _enum)
|
||||
{
|
||||
BX_CHECK(_enum <= SpvBuiltin::Count, "Unknown builtin id %d.", _enum);
|
||||
BX_ASSERT(_enum <= SpvBuiltin::Count, "Unknown builtin id %d.", _enum);
|
||||
return _enum <= SpvBuiltin::Count
|
||||
? s_spvBuiltin[_enum]
|
||||
: "?SpvBuiltin?"
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace bgfx
|
||||
if (i0 > i1) { bx::swap(i0, i1); }
|
||||
if (i1 > i2) { bx::swap(i1, i2); }
|
||||
if (i0 > i1) { bx::swap(i0, i1); }
|
||||
BX_CHECK(i0 < i1 && i1 < i2, "");
|
||||
BX_ASSERT(i0 < i1 && i1 < i2, "");
|
||||
|
||||
dst[1] = i0; dst[0] = i1;
|
||||
dst[3] = i1; dst[2] = i2;
|
||||
|
||||
Reference in New Issue
Block a user