mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
RRenamed BX_CHECK to BX_ASSERT.
This commit is contained in:
@@ -153,9 +153,9 @@ bgfx::TextureHandle loadTextureWithUpdate(const char* _filePath, uint64_t _flags
|
|||||||
|
|
||||||
if (NULL != imageContainer)
|
if (NULL != imageContainer)
|
||||||
{
|
{
|
||||||
BX_CHECK(!imageContainer->m_cubeMap, "Cubemap Texture loading not supported");
|
BX_ASSERT(!imageContainer->m_cubeMap, "Cubemap Texture loading not supported");
|
||||||
BX_CHECK(1 >= imageContainer->m_depth, "3D Texture loading not supported");
|
BX_ASSERT(1 >= imageContainer->m_depth, "3D Texture loading not supported");
|
||||||
BX_CHECK(1 == imageContainer->m_numLayers, "Texture Layer loading not supported");
|
BX_ASSERT(1 == imageContainer->m_numLayers, "Texture Layer loading not supported");
|
||||||
|
|
||||||
if (!imageContainer->m_cubeMap
|
if (!imageContainer->m_cubeMap
|
||||||
&& 1 >= imageContainer->m_depth
|
&& 1 >= imageContainer->m_depth
|
||||||
|
|||||||
@@ -1067,7 +1067,7 @@ struct Model
|
|||||||
::setRenderState(_renderState);
|
::setRenderState(_renderState);
|
||||||
|
|
||||||
// Submit
|
// Submit
|
||||||
BX_CHECK(bgfx::kInvalidHandle != m_program, "Error, program is not set.");
|
BX_ASSERT(bgfx::kInvalidHandle != m_program, "Error, program is not set.");
|
||||||
::submit(_viewId, m_program);
|
::submit(_viewId, m_program);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1104,7 +1104,7 @@ struct Instance
|
|||||||
, m_pos[2]
|
, m_pos[2]
|
||||||
);
|
);
|
||||||
|
|
||||||
BX_CHECK(NULL != m_model, "Instance model cannot be NULL!");
|
BX_ASSERT(NULL != m_model, "Instance model cannot be NULL!");
|
||||||
m_model->submit(_viewId, mtx, _renderState);
|
m_model->submit(_viewId, mtx, _renderState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1140,7 +1140,7 @@ struct ShadowVolumeAllocator
|
|||||||
{
|
{
|
||||||
void* ret = (void*)m_ptr;
|
void* ret = (void*)m_ptr;
|
||||||
m_ptr += _size;
|
m_ptr += _size;
|
||||||
BX_CHECK(m_ptr - m_mem < (m_firstPage ? SV_PAGE_SIZE : 2 * SV_PAGE_SIZE), "Buffer overflow!");
|
BX_ASSERT(m_ptr - m_mem < (m_firstPage ? SV_PAGE_SIZE : 2 * SV_PAGE_SIZE), "Buffer overflow!");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2326,7 +2326,7 @@ public:
|
|||||||
|
|
||||||
// Compute split distances.
|
// Compute split distances.
|
||||||
const uint8_t maxNumSplits = 4;
|
const uint8_t maxNumSplits = 4;
|
||||||
BX_CHECK(maxNumSplits >= settings.m_numSplits, "Error! Max num splits.");
|
BX_ASSERT(maxNumSplits >= settings.m_numSplits, "Error! Max num splits.");
|
||||||
|
|
||||||
float splitSlices[maxNumSplits*2];
|
float splitSlices[maxNumSplits*2];
|
||||||
splitFrustum(splitSlices
|
splitFrustum(splitSlices
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ void VectorDisplay::endFrame()
|
|||||||
// advance step
|
// advance step
|
||||||
m_currentDrawStep = (m_currentDrawStep + 1) % m_numberDecaySteps;
|
m_currentDrawStep = (m_currentDrawStep + 1) % m_numberDecaySteps;
|
||||||
|
|
||||||
BX_CHECK(m_points.size() < MAX_NUMBER_VERTICES, "");
|
BX_ASSERT(m_points.size() < MAX_NUMBER_VERTICES, "");
|
||||||
|
|
||||||
bgfx::update(
|
bgfx::update(
|
||||||
m_vertexBuffers[m_currentDrawStep]
|
m_vertexBuffers[m_currentDrawStep]
|
||||||
@@ -315,7 +315,7 @@ void VectorDisplay::endFrame()
|
|||||||
|
|
||||||
void VectorDisplay::beginDraw(float _x, float _y)
|
void VectorDisplay::beginDraw(float _x, float _y)
|
||||||
{
|
{
|
||||||
BX_CHECK(0 == m_pendingPoints.size(), "Begin draw on already filled buffer!");
|
BX_ASSERT(0 == m_pendingPoints.size(), "Begin draw on already filled buffer!");
|
||||||
|
|
||||||
PendingPoint point;
|
PendingPoint point;
|
||||||
point.x = _x * m_drawScale + m_drawOffsetX;
|
point.x = _x * m_drawScale + m_drawOffsetX;
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ static bgfx::ShaderHandle loadShader(bx::FileReaderI* _reader, const char* _name
|
|||||||
case bgfx::RendererType::WebGPU: shaderPath = "shaders/spirv/"; break;
|
case bgfx::RendererType::WebGPU: shaderPath = "shaders/spirv/"; break;
|
||||||
|
|
||||||
case bgfx::RendererType::Count:
|
case bgfx::RendererType::Count:
|
||||||
BX_CHECK(false, "You should not be here!");
|
BX_ASSERT(false, "You should not be here!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,8 +85,8 @@ RectanglePacker::RectanglePacker(uint32_t _width, uint32_t _height)
|
|||||||
|
|
||||||
void RectanglePacker::init(uint32_t _width, uint32_t _height)
|
void RectanglePacker::init(uint32_t _width, uint32_t _height)
|
||||||
{
|
{
|
||||||
BX_CHECK(_width > 2, "_width must be > 2");
|
BX_ASSERT(_width > 2, "_width must be > 2");
|
||||||
BX_CHECK(_height > 2, "_height must be > 2");
|
BX_ASSERT(_height > 2, "_height must be > 2");
|
||||||
m_width = _width;
|
m_width = _width;
|
||||||
m_height = _height;
|
m_height = _height;
|
||||||
m_usedSpace = 0;
|
m_usedSpace = 0;
|
||||||
@@ -256,8 +256,8 @@ Atlas::Atlas(uint16_t _textureSize, uint16_t _maxRegionsCount)
|
|||||||
, m_regionCount(0)
|
, m_regionCount(0)
|
||||||
, m_maxRegionCount(_maxRegionsCount)
|
, m_maxRegionCount(_maxRegionsCount)
|
||||||
{
|
{
|
||||||
BX_CHECK(_textureSize >= 64 && _textureSize <= 4096, "Invalid _textureSize %d.", _textureSize);
|
BX_ASSERT(_textureSize >= 64 && _textureSize <= 4096, "Invalid _textureSize %d.", _textureSize);
|
||||||
BX_CHECK(_maxRegionsCount >= 64 && _maxRegionsCount <= 32000, "Invalid _maxRegionsCount %d.", _maxRegionsCount);
|
BX_ASSERT(_maxRegionsCount >= 64 && _maxRegionsCount <= 32000, "Invalid _maxRegionsCount %d.", _maxRegionsCount);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
@@ -285,7 +285,7 @@ Atlas::Atlas(uint16_t _textureSize, const uint8_t* _textureBuffer, uint16_t _reg
|
|||||||
, m_regionCount(_regionCount)
|
, m_regionCount(_regionCount)
|
||||||
, m_maxRegionCount(_regionCount < _maxRegionsCount ? _regionCount : _maxRegionsCount)
|
, m_maxRegionCount(_regionCount < _maxRegionsCount ? _regionCount : _maxRegionsCount)
|
||||||
{
|
{
|
||||||
BX_CHECK(_regionCount <= 64 && _maxRegionsCount <= 4096, "_regionCount %d, _maxRegionsCount %d", _regionCount, _maxRegionsCount);
|
BX_ASSERT(_regionCount <= 64 && _maxRegionsCount <= 4096, "_regionCount %d, _maxRegionsCount %d", _regionCount, _maxRegionsCount);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
|||||||
@@ -1050,7 +1050,7 @@ struct DebugDrawEncoderImpl
|
|||||||
|
|
||||||
void begin(bgfx::ViewId _viewId, bool _depthTestLess, bgfx::Encoder* _encoder)
|
void begin(bgfx::ViewId _viewId, bool _depthTestLess, bgfx::Encoder* _encoder)
|
||||||
{
|
{
|
||||||
BX_CHECK(State::Count == m_state);
|
BX_ASSERT(State::Count == m_state);
|
||||||
|
|
||||||
m_viewId = _viewId;
|
m_viewId = _viewId;
|
||||||
m_encoder = _encoder == NULL ? m_defaultEncoder : _encoder;
|
m_encoder = _encoder == NULL ? m_defaultEncoder : _encoder;
|
||||||
@@ -1084,7 +1084,7 @@ struct DebugDrawEncoderImpl
|
|||||||
|
|
||||||
void end()
|
void end()
|
||||||
{
|
{
|
||||||
BX_CHECK(0 == m_stack, "Invalid stack %d.", m_stack);
|
BX_ASSERT(0 == m_stack, "Invalid stack %d.", m_stack);
|
||||||
|
|
||||||
flushQuad();
|
flushQuad();
|
||||||
flush();
|
flush();
|
||||||
@@ -1095,14 +1095,14 @@ struct DebugDrawEncoderImpl
|
|||||||
|
|
||||||
void push()
|
void push()
|
||||||
{
|
{
|
||||||
BX_CHECK(State::Count != m_state);
|
BX_ASSERT(State::Count != m_state);
|
||||||
++m_stack;
|
++m_stack;
|
||||||
m_attrib[m_stack] = m_attrib[m_stack-1];
|
m_attrib[m_stack] = m_attrib[m_stack-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
void pop()
|
void pop()
|
||||||
{
|
{
|
||||||
BX_CHECK(State::Count != m_state);
|
BX_ASSERT(State::Count != m_state);
|
||||||
const Attrib& curr = m_attrib[m_stack];
|
const Attrib& curr = m_attrib[m_stack];
|
||||||
const Attrib& prev = m_attrib[m_stack-1];
|
const Attrib& prev = m_attrib[m_stack-1];
|
||||||
if (curr.m_stipple != prev.m_stipple
|
if (curr.m_stipple != prev.m_stipple
|
||||||
@@ -1115,7 +1115,7 @@ struct DebugDrawEncoderImpl
|
|||||||
|
|
||||||
void setDepthTestLess(bool _depthTestLess)
|
void setDepthTestLess(bool _depthTestLess)
|
||||||
{
|
{
|
||||||
BX_CHECK(State::Count != m_state);
|
BX_ASSERT(State::Count != m_state);
|
||||||
if (m_depthTestLess != _depthTestLess)
|
if (m_depthTestLess != _depthTestLess)
|
||||||
{
|
{
|
||||||
m_depthTestLess = _depthTestLess;
|
m_depthTestLess = _depthTestLess;
|
||||||
@@ -1131,7 +1131,7 @@ struct DebugDrawEncoderImpl
|
|||||||
|
|
||||||
void setTransform(const void* _mtx, uint16_t _num = 1, bool _flush = true)
|
void setTransform(const void* _mtx, uint16_t _num = 1, bool _flush = true)
|
||||||
{
|
{
|
||||||
BX_CHECK(State::Count != m_state);
|
BX_ASSERT(State::Count != m_state);
|
||||||
if (_flush)
|
if (_flush)
|
||||||
{
|
{
|
||||||
flush();
|
flush();
|
||||||
@@ -1166,8 +1166,8 @@ struct DebugDrawEncoderImpl
|
|||||||
|
|
||||||
void pushTransform(const void* _mtx, uint16_t _num, bool _flush = true)
|
void pushTransform(const void* _mtx, uint16_t _num, bool _flush = true)
|
||||||
{
|
{
|
||||||
BX_CHECK(m_mtxStackCurrent < BX_COUNTOF(m_mtxStack), "Out of matrix stack!");
|
BX_ASSERT(m_mtxStackCurrent < BX_COUNTOF(m_mtxStack), "Out of matrix stack!");
|
||||||
BX_CHECK(State::Count != m_state);
|
BX_ASSERT(State::Count != m_state);
|
||||||
if (_flush)
|
if (_flush)
|
||||||
{
|
{
|
||||||
flush();
|
flush();
|
||||||
@@ -1197,7 +1197,7 @@ struct DebugDrawEncoderImpl
|
|||||||
|
|
||||||
void popTransform(bool _flush = true)
|
void popTransform(bool _flush = true)
|
||||||
{
|
{
|
||||||
BX_CHECK(State::Count != m_state);
|
BX_ASSERT(State::Count != m_state);
|
||||||
if (_flush)
|
if (_flush)
|
||||||
{
|
{
|
||||||
flush();
|
flush();
|
||||||
@@ -1257,25 +1257,25 @@ struct DebugDrawEncoderImpl
|
|||||||
|
|
||||||
void setColor(uint32_t _abgr)
|
void setColor(uint32_t _abgr)
|
||||||
{
|
{
|
||||||
BX_CHECK(State::Count != m_state);
|
BX_ASSERT(State::Count != m_state);
|
||||||
m_attrib[m_stack].m_abgr = _abgr;
|
m_attrib[m_stack].m_abgr = _abgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLod(uint8_t _lod)
|
void setLod(uint8_t _lod)
|
||||||
{
|
{
|
||||||
BX_CHECK(State::Count != m_state);
|
BX_ASSERT(State::Count != m_state);
|
||||||
m_attrib[m_stack].m_lod = _lod;
|
m_attrib[m_stack].m_lod = _lod;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setWireframe(bool _wireframe)
|
void setWireframe(bool _wireframe)
|
||||||
{
|
{
|
||||||
BX_CHECK(State::Count != m_state);
|
BX_ASSERT(State::Count != m_state);
|
||||||
m_attrib[m_stack].m_wireframe = _wireframe;
|
m_attrib[m_stack].m_wireframe = _wireframe;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStipple(bool _stipple, float _scale = 1.0f, float _offset = 0.0f)
|
void setStipple(bool _stipple, float _scale = 1.0f, float _offset = 0.0f)
|
||||||
{
|
{
|
||||||
BX_CHECK(State::Count != m_state);
|
BX_ASSERT(State::Count != m_state);
|
||||||
|
|
||||||
Attrib& attrib = m_attrib[m_stack];
|
Attrib& attrib = m_attrib[m_stack];
|
||||||
|
|
||||||
@@ -1297,7 +1297,7 @@ struct DebugDrawEncoderImpl
|
|||||||
|
|
||||||
void moveTo(float _x, float _y, float _z = 0.0f)
|
void moveTo(float _x, float _y, float _z = 0.0f)
|
||||||
{
|
{
|
||||||
BX_CHECK(State::Count != m_state);
|
BX_ASSERT(State::Count != m_state);
|
||||||
|
|
||||||
softFlush();
|
softFlush();
|
||||||
|
|
||||||
@@ -1317,7 +1317,7 @@ struct DebugDrawEncoderImpl
|
|||||||
|
|
||||||
void moveTo(const bx::Vec3& _pos)
|
void moveTo(const bx::Vec3& _pos)
|
||||||
{
|
{
|
||||||
BX_CHECK(State::Count != m_state);
|
BX_ASSERT(State::Count != m_state);
|
||||||
moveTo(_pos.x, _pos.y, _pos.z);
|
moveTo(_pos.x, _pos.y, _pos.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1328,7 +1328,7 @@ struct DebugDrawEncoderImpl
|
|||||||
|
|
||||||
void lineTo(float _x, float _y, float _z = 0.0f)
|
void lineTo(float _x, float _y, float _z = 0.0f)
|
||||||
{
|
{
|
||||||
BX_CHECK(State::Count != m_state);
|
BX_ASSERT(State::Count != m_state);
|
||||||
if (State::None == m_state)
|
if (State::None == m_state)
|
||||||
{
|
{
|
||||||
moveTo(_x, _y, _z);
|
moveTo(_x, _y, _z);
|
||||||
@@ -1381,7 +1381,7 @@ struct DebugDrawEncoderImpl
|
|||||||
|
|
||||||
void lineTo(const bx::Vec3& _pos)
|
void lineTo(const bx::Vec3& _pos)
|
||||||
{
|
{
|
||||||
BX_CHECK(State::Count != m_state);
|
BX_ASSERT(State::Count != m_state);
|
||||||
lineTo(_pos.x, _pos.y, _pos.z);
|
lineTo(_pos.x, _pos.y, _pos.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1392,7 +1392,7 @@ struct DebugDrawEncoderImpl
|
|||||||
|
|
||||||
void close()
|
void close()
|
||||||
{
|
{
|
||||||
BX_CHECK(State::Count != m_state);
|
BX_ASSERT(State::Count != m_state);
|
||||||
DebugVertex& vertex = m_cache[m_vertexPos];
|
DebugVertex& vertex = m_cache[m_vertexPos];
|
||||||
lineTo(vertex.m_x, vertex.m_y, vertex.m_z);
|
lineTo(vertex.m_x, vertex.m_y, vertex.m_z);
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ struct CmdContext
|
|||||||
void add(const char* _name, ConsoleFn _fn, void* _userData)
|
void add(const char* _name, ConsoleFn _fn, void* _userData)
|
||||||
{
|
{
|
||||||
uint32_t cmd = bx::hash<bx::HashMurmur2A>(_name, (uint32_t)bx::strLen(_name) );
|
uint32_t cmd = bx::hash<bx::HashMurmur2A>(_name, (uint32_t)bx::strLen(_name) );
|
||||||
BX_CHECK(m_lookup.end() == m_lookup.find(cmd), "Command \"%s\" already exist.", _name);
|
BX_ASSERT(m_lookup.end() == m_lookup.find(cmd), "Command \"%s\" already exist.", _name);
|
||||||
Func fn = { _fn, _userData };
|
Func fn = { _fn, _userData };
|
||||||
m_lookup.insert(stl::make_pair(cmd, fn) );
|
m_lookup.insert(stl::make_pair(cmd, fn) );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
|||||||
|
|
||||||
const char* getName(Key::Enum _key)
|
const char* getName(Key::Enum _key)
|
||||||
{
|
{
|
||||||
BX_CHECK(_key < Key::Count, "Invalid key %d.", _key);
|
BX_ASSERT(_key < Key::Count, "Invalid key %d.", _key);
|
||||||
return s_keyName[_key];
|
return s_keyName[_key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ namespace entry
|
|||||||
|
|
||||||
virtual bool open(const bx::FilePath& _filePath, bx::Error* _err) override
|
virtual bool open(const bx::FilePath& _filePath, bx::Error* _err) override
|
||||||
{
|
{
|
||||||
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
|
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
|
||||||
|
|
||||||
if (NULL != m_file)
|
if (NULL != m_file)
|
||||||
{
|
{
|
||||||
@@ -139,15 +139,15 @@ namespace entry
|
|||||||
|
|
||||||
virtual int64_t seek(int64_t _offset, bx::Whence::Enum _whence) override
|
virtual int64_t seek(int64_t _offset, bx::Whence::Enum _whence) override
|
||||||
{
|
{
|
||||||
BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
|
BX_ASSERT(NULL != m_file, "Reader/Writer file is not open.");
|
||||||
return AAsset_seek64(m_file, _offset, _whence);
|
return AAsset_seek64(m_file, _offset, _whence);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int32_t read(void* _data, int32_t _size, bx::Error* _err) override
|
virtual int32_t read(void* _data, int32_t _size, bx::Error* _err) override
|
||||||
{
|
{
|
||||||
BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
|
BX_ASSERT(NULL != m_file, "Reader/Writer file is not open.");
|
||||||
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
|
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
|
||||||
|
|
||||||
int32_t size = (int32_t)AAsset_read(m_file, _data, _size);
|
int32_t size = (int32_t)AAsset_read(m_file, _data, _size);
|
||||||
if (size != _size)
|
if (size != _size)
|
||||||
@@ -555,7 +555,7 @@ namespace entry
|
|||||||
BX_UNUSED(_thread);
|
BX_UNUSED(_thread);
|
||||||
|
|
||||||
int32_t result = chdir("/sdcard/bgfx/examples/runtime");
|
int32_t result = chdir("/sdcard/bgfx/examples/runtime");
|
||||||
BX_CHECK(0 == result, "Failed to chdir to dir. android.permission.WRITE_EXTERNAL_STORAGE?", errno);
|
BX_ASSERT(0 == result, "Failed to chdir to dir. android.permission.WRITE_EXTERNAL_STORAGE?", errno);
|
||||||
|
|
||||||
MainThreadEntry* self = (MainThreadEntry*)_userData;
|
MainThreadEntry* self = (MainThreadEntry*)_userData;
|
||||||
result = main(self->m_argc, self->m_argv);
|
result = main(self->m_argc, self->m_argv);
|
||||||
|
|||||||
@@ -94,17 +94,17 @@ namespace entry
|
|||||||
// will take the first canvas element found on the web page.
|
// will take the first canvas element found on the web page.
|
||||||
#define HTML5_TARGET_CANVAS_SELECTOR "#canvas"
|
#define HTML5_TARGET_CANVAS_SELECTOR "#canvas"
|
||||||
|
|
||||||
BX_CHECK(emscripten_set_mousedown_callback(HTML5_TARGET_CANVAS_SELECTOR, this, true, mouseCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_mousedown_callback() failed!");
|
BX_ASSERT(emscripten_set_mousedown_callback(HTML5_TARGET_CANVAS_SELECTOR, this, true, mouseCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_mousedown_callback() failed!");
|
||||||
BX_CHECK(emscripten_set_mouseup_callback(HTML5_TARGET_CANVAS_SELECTOR, this, true, mouseCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_mouseup_callback() failed!");
|
BX_ASSERT(emscripten_set_mouseup_callback(HTML5_TARGET_CANVAS_SELECTOR, this, true, mouseCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_mouseup_callback() failed!");
|
||||||
BX_CHECK(emscripten_set_mousemove_callback(HTML5_TARGET_CANVAS_SELECTOR, this, true, mouseCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_mousemove_callback() failed!");
|
BX_ASSERT(emscripten_set_mousemove_callback(HTML5_TARGET_CANVAS_SELECTOR, this, true, mouseCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_mousemove_callback() failed!");
|
||||||
|
|
||||||
BX_CHECK(emscripten_set_wheel_callback(HTML5_TARGET_CANVAS_SELECTOR, this, true, wheelCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_wheel_callback() failed!");
|
BX_ASSERT(emscripten_set_wheel_callback(HTML5_TARGET_CANVAS_SELECTOR, this, true, wheelCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_wheel_callback() failed!");
|
||||||
|
|
||||||
BX_CHECK(emscripten_set_keypress_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, this, true, keyCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_keypress_callback() failed!");
|
BX_ASSERT(emscripten_set_keypress_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, this, true, keyCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_keypress_callback() failed!");
|
||||||
BX_CHECK(emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, this, true, keyCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_keydown_callback() failed!");
|
BX_ASSERT(emscripten_set_keydown_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, this, true, keyCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_keydown_callback() failed!");
|
||||||
BX_CHECK(emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, this, true, keyCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_keyup_callback() failed!");
|
BX_ASSERT(emscripten_set_keyup_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, this, true, keyCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_keyup_callback() failed!");
|
||||||
|
|
||||||
BX_CHECK(emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, this, true, resizeCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_resize_callback() failed!");
|
BX_ASSERT(emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, this, true, resizeCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_resize_callback() failed!");
|
||||||
|
|
||||||
EmscriptenFullscreenStrategy fullscreenStrategy = {};
|
EmscriptenFullscreenStrategy fullscreenStrategy = {};
|
||||||
fullscreenStrategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_DEFAULT;
|
fullscreenStrategy.scaleMode = EMSCRIPTEN_FULLSCREEN_SCALE_DEFAULT;
|
||||||
@@ -115,9 +115,9 @@ namespace entry
|
|||||||
|
|
||||||
emscripten_request_fullscreen_strategy(HTML5_TARGET_CANVAS_SELECTOR, false, &fullscreenStrategy);
|
emscripten_request_fullscreen_strategy(HTML5_TARGET_CANVAS_SELECTOR, false, &fullscreenStrategy);
|
||||||
|
|
||||||
BX_CHECK(emscripten_set_focus_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, this, true, focusCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_focus_callback() failed!");
|
BX_ASSERT(emscripten_set_focus_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, this, true, focusCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_focus_callback() failed!");
|
||||||
BX_CHECK(emscripten_set_focusin_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, this, true, focusCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_focusin_callback() failed!");
|
BX_ASSERT(emscripten_set_focusin_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, this, true, focusCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_focusin_callback() failed!");
|
||||||
BX_CHECK(emscripten_set_focusout_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, this, true, focusCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_focusout_callback() failed!");
|
BX_ASSERT(emscripten_set_focusout_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, this, true, focusCb) == EMSCRIPTEN_RESULT_SUCCESS, "emscripten_set_focusout_callback() failed!");
|
||||||
|
|
||||||
bgfx::PlatformData pd;
|
bgfx::PlatformData pd;
|
||||||
bx::memSet(&pd, 0, sizeof(pd) );
|
bx::memSet(&pd, 0, sizeof(pd) );
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ namespace entry
|
|||||||
|
|
||||||
static void initTranslateKey(uint16_t _sdl, Key::Enum _key)
|
static void initTranslateKey(uint16_t _sdl, Key::Enum _key)
|
||||||
{
|
{
|
||||||
BX_CHECK(_sdl < BX_COUNTOF(s_translateKey), "Out of bounds %d.", _sdl);
|
BX_ASSERT(_sdl < BX_COUNTOF(s_translateKey), "Out of bounds %d.", _sdl);
|
||||||
s_translateKey[_sdl&0xff] = (uint8_t)_key;
|
s_translateKey[_sdl&0xff] = (uint8_t)_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ namespace entry
|
|||||||
static void initTranslateKey(uint16_t _xk, Key::Enum _key)
|
static void initTranslateKey(uint16_t _xk, Key::Enum _key)
|
||||||
{
|
{
|
||||||
_xk += 256;
|
_xk += 256;
|
||||||
BX_CHECK(_xk < BX_COUNTOF(s_translateKey), "Out of bounds %d.", _xk);
|
BX_ASSERT(_xk < BX_COUNTOF(s_translateKey), "Out of bounds %d.", _xk);
|
||||||
s_translateKey[_xk&0x1ff] = (uint8_t)_key;
|
s_translateKey[_xk&0x1ff] = (uint8_t)_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,9 +63,9 @@ TrueTypeFont::~TrueTypeFont()
|
|||||||
|
|
||||||
bool TrueTypeFont::init(const uint8_t* _buffer, uint32_t _bufferSize, int32_t _fontIndex, uint32_t _pixelHeight)
|
bool TrueTypeFont::init(const uint8_t* _buffer, uint32_t _bufferSize, int32_t _fontIndex, uint32_t _pixelHeight)
|
||||||
{
|
{
|
||||||
BX_CHECK(m_font == NULL, "TrueTypeFont already initialized");
|
BX_ASSERT(m_font == NULL, "TrueTypeFont already initialized");
|
||||||
BX_CHECK( (_bufferSize > 256 && _bufferSize < 100000000), "TrueType buffer size is suspicious");
|
BX_ASSERT( (_bufferSize > 256 && _bufferSize < 100000000), "TrueType buffer size is suspicious");
|
||||||
BX_CHECK( (_pixelHeight > 4 && _pixelHeight < 128), "TrueType buffer size is suspicious");
|
BX_ASSERT( (_pixelHeight > 4 && _pixelHeight < 128), "TrueType buffer size is suspicious");
|
||||||
BX_UNUSED(_bufferSize);
|
BX_UNUSED(_bufferSize);
|
||||||
|
|
||||||
int offset = stbtt_GetFontOffsetForIndex(_buffer, _fontIndex);
|
int offset = stbtt_GetFontOffsetForIndex(_buffer, _fontIndex);
|
||||||
@@ -79,7 +79,7 @@ bool TrueTypeFont::init(const uint8_t* _buffer, uint32_t _bufferSize, int32_t _f
|
|||||||
|
|
||||||
FontInfo TrueTypeFont::getFontInfo()
|
FontInfo TrueTypeFont::getFontInfo()
|
||||||
{
|
{
|
||||||
BX_CHECK(m_font != NULL, "TrueTypeFont not initialized");
|
BX_ASSERT(m_font != NULL, "TrueTypeFont not initialized");
|
||||||
|
|
||||||
int ascent;
|
int ascent;
|
||||||
int descent;
|
int descent;
|
||||||
@@ -105,7 +105,7 @@ FontInfo TrueTypeFont::getFontInfo()
|
|||||||
|
|
||||||
bool TrueTypeFont::bakeGlyphAlpha(CodePoint _codePoint, GlyphInfo& _glyphInfo, uint8_t* _outBuffer)
|
bool TrueTypeFont::bakeGlyphAlpha(CodePoint _codePoint, GlyphInfo& _glyphInfo, uint8_t* _outBuffer)
|
||||||
{
|
{
|
||||||
BX_CHECK(m_font != NULL, "TrueTypeFont not initialized");
|
BX_ASSERT(m_font != NULL, "TrueTypeFont not initialized");
|
||||||
|
|
||||||
int xx;
|
int xx;
|
||||||
int yy;
|
int yy;
|
||||||
@@ -140,7 +140,7 @@ bool TrueTypeFont::bakeGlyphAlpha(CodePoint _codePoint, GlyphInfo& _glyphInfo, u
|
|||||||
|
|
||||||
bool TrueTypeFont::bakeGlyphDistance(CodePoint _codePoint, GlyphInfo& _glyphInfo, uint8_t* _outBuffer)
|
bool TrueTypeFont::bakeGlyphDistance(CodePoint _codePoint, GlyphInfo& _glyphInfo, uint8_t* _outBuffer)
|
||||||
{
|
{
|
||||||
BX_CHECK(m_font != NULL, "TrueTypeFont not initialized");
|
BX_ASSERT(m_font != NULL, "TrueTypeFont not initialized");
|
||||||
|
|
||||||
int32_t xx;
|
int32_t xx;
|
||||||
int32_t yy;
|
int32_t yy;
|
||||||
@@ -177,7 +177,7 @@ bool TrueTypeFont::bakeGlyphDistance(CodePoint _codePoint, GlyphInfo& _glyphInfo
|
|||||||
|
|
||||||
uint32_t nw = ww + dw * 2;
|
uint32_t nw = ww + dw * 2;
|
||||||
uint32_t nh = hh + dh * 2;
|
uint32_t nh = hh + dh * 2;
|
||||||
BX_CHECK(nw * nh < 128 * 128, "Buffer overflow (size %d)", nw * nh);
|
BX_ASSERT(nw * nh < 128 * 128, "Buffer overflow (size %d)", nw * nh);
|
||||||
|
|
||||||
uint32_t buffSize = nw * nh * sizeof(uint8_t);
|
uint32_t buffSize = nw * nh * sizeof(uint8_t);
|
||||||
|
|
||||||
@@ -258,10 +258,10 @@ void FontManager::init()
|
|||||||
|
|
||||||
FontManager::~FontManager()
|
FontManager::~FontManager()
|
||||||
{
|
{
|
||||||
BX_CHECK(m_fontHandles.getNumHandles() == 0, "All the fonts must be destroyed before destroying the manager");
|
BX_ASSERT(m_fontHandles.getNumHandles() == 0, "All the fonts must be destroyed before destroying the manager");
|
||||||
delete [] m_cachedFonts;
|
delete [] m_cachedFonts;
|
||||||
|
|
||||||
BX_CHECK(m_filesHandles.getNumHandles() == 0, "All the font files must be destroyed before destroying the manager");
|
BX_ASSERT(m_filesHandles.getNumHandles() == 0, "All the font files must be destroyed before destroying the manager");
|
||||||
delete [] m_cachedFiles;
|
delete [] m_cachedFiles;
|
||||||
|
|
||||||
delete [] m_buffer;
|
delete [] m_buffer;
|
||||||
@@ -275,7 +275,7 @@ FontManager::~FontManager()
|
|||||||
TrueTypeHandle FontManager::createTtf(const uint8_t* _buffer, uint32_t _size)
|
TrueTypeHandle FontManager::createTtf(const uint8_t* _buffer, uint32_t _size)
|
||||||
{
|
{
|
||||||
uint16_t id = m_filesHandles.alloc();
|
uint16_t id = m_filesHandles.alloc();
|
||||||
BX_CHECK(id != bx::kInvalidHandle, "Invalid handle used");
|
BX_ASSERT(id != bx::kInvalidHandle, "Invalid handle used");
|
||||||
m_cachedFiles[id].buffer = new uint8_t[_size];
|
m_cachedFiles[id].buffer = new uint8_t[_size];
|
||||||
m_cachedFiles[id].bufferSize = _size;
|
m_cachedFiles[id].bufferSize = _size;
|
||||||
bx::memCopy(m_cachedFiles[id].buffer, _buffer, _size);
|
bx::memCopy(m_cachedFiles[id].buffer, _buffer, _size);
|
||||||
@@ -286,7 +286,7 @@ TrueTypeHandle FontManager::createTtf(const uint8_t* _buffer, uint32_t _size)
|
|||||||
|
|
||||||
void FontManager::destroyTtf(TrueTypeHandle _handle)
|
void FontManager::destroyTtf(TrueTypeHandle _handle)
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_handle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_handle), "Invalid handle used");
|
||||||
delete m_cachedFiles[_handle.idx].buffer;
|
delete m_cachedFiles[_handle.idx].buffer;
|
||||||
m_cachedFiles[_handle.idx].bufferSize = 0;
|
m_cachedFiles[_handle.idx].bufferSize = 0;
|
||||||
m_cachedFiles[_handle.idx].buffer = NULL;
|
m_cachedFiles[_handle.idx].buffer = NULL;
|
||||||
@@ -295,7 +295,7 @@ void FontManager::destroyTtf(TrueTypeHandle _handle)
|
|||||||
|
|
||||||
FontHandle FontManager::createFontByPixelSize(TrueTypeHandle _ttfHandle, uint32_t _typefaceIndex, uint32_t _pixelSize, uint32_t _fontType)
|
FontHandle FontManager::createFontByPixelSize(TrueTypeHandle _ttfHandle, uint32_t _typefaceIndex, uint32_t _pixelSize, uint32_t _fontType)
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_ttfHandle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_ttfHandle), "Invalid handle used");
|
||||||
|
|
||||||
TrueTypeFont* ttf = new TrueTypeFont();
|
TrueTypeFont* ttf = new TrueTypeFont();
|
||||||
if (!ttf->init(m_cachedFiles[_ttfHandle.idx].buffer, m_cachedFiles[_ttfHandle.idx].bufferSize, _typefaceIndex, _pixelSize) )
|
if (!ttf->init(m_cachedFiles[_ttfHandle.idx].buffer, m_cachedFiles[_ttfHandle.idx].bufferSize, _typefaceIndex, _pixelSize) )
|
||||||
@@ -306,7 +306,7 @@ FontHandle FontManager::createFontByPixelSize(TrueTypeHandle _ttfHandle, uint32_
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint16_t fontIdx = m_fontHandles.alloc();
|
uint16_t fontIdx = m_fontHandles.alloc();
|
||||||
BX_CHECK(fontIdx != bx::kInvalidHandle, "Invalid handle used");
|
BX_ASSERT(fontIdx != bx::kInvalidHandle, "Invalid handle used");
|
||||||
|
|
||||||
CachedFont& font = m_cachedFonts[fontIdx];
|
CachedFont& font = m_cachedFonts[fontIdx];
|
||||||
font.trueTypeFont = ttf;
|
font.trueTypeFont = ttf;
|
||||||
@@ -322,7 +322,7 @@ FontHandle FontManager::createFontByPixelSize(TrueTypeHandle _ttfHandle, uint32_
|
|||||||
|
|
||||||
FontHandle FontManager::createScaledFontToPixelSize(FontHandle _baseFontHandle, uint32_t _pixelSize)
|
FontHandle FontManager::createScaledFontToPixelSize(FontHandle _baseFontHandle, uint32_t _pixelSize)
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_baseFontHandle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_baseFontHandle), "Invalid handle used");
|
||||||
CachedFont& baseFont = m_cachedFonts[_baseFontHandle.idx];
|
CachedFont& baseFont = m_cachedFonts[_baseFontHandle.idx];
|
||||||
FontInfo& fontInfo = baseFont.fontInfo;
|
FontInfo& fontInfo = baseFont.fontInfo;
|
||||||
|
|
||||||
@@ -337,7 +337,7 @@ FontHandle FontManager::createScaledFontToPixelSize(FontHandle _baseFontHandle,
|
|||||||
newFontInfo.underlinePosition = (newFontInfo.underlinePosition * newFontInfo.scale);
|
newFontInfo.underlinePosition = (newFontInfo.underlinePosition * newFontInfo.scale);
|
||||||
|
|
||||||
uint16_t fontIdx = m_fontHandles.alloc();
|
uint16_t fontIdx = m_fontHandles.alloc();
|
||||||
BX_CHECK(fontIdx != bx::kInvalidHandle, "Invalid handle used");
|
BX_ASSERT(fontIdx != bx::kInvalidHandle, "Invalid handle used");
|
||||||
|
|
||||||
CachedFont& font = m_cachedFonts[fontIdx];
|
CachedFont& font = m_cachedFonts[fontIdx];
|
||||||
font.cachedGlyphs.clear();
|
font.cachedGlyphs.clear();
|
||||||
@@ -351,7 +351,7 @@ FontHandle FontManager::createScaledFontToPixelSize(FontHandle _baseFontHandle,
|
|||||||
|
|
||||||
void FontManager::destroyFont(FontHandle _handle)
|
void FontManager::destroyFont(FontHandle _handle)
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_handle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_handle), "Invalid handle used");
|
||||||
|
|
||||||
CachedFont& font = m_cachedFonts[_handle.idx];
|
CachedFont& font = m_cachedFonts[_handle.idx];
|
||||||
|
|
||||||
@@ -367,7 +367,7 @@ void FontManager::destroyFont(FontHandle _handle)
|
|||||||
|
|
||||||
bool FontManager::preloadGlyph(FontHandle _handle, const wchar_t* _string)
|
bool FontManager::preloadGlyph(FontHandle _handle, const wchar_t* _string)
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_handle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_handle), "Invalid handle used");
|
||||||
CachedFont& font = m_cachedFonts[_handle.idx];
|
CachedFont& font = m_cachedFonts[_handle.idx];
|
||||||
|
|
||||||
if (NULL == font.trueTypeFont)
|
if (NULL == font.trueTypeFont)
|
||||||
@@ -389,7 +389,7 @@ bool FontManager::preloadGlyph(FontHandle _handle, const wchar_t* _string)
|
|||||||
|
|
||||||
bool FontManager::preloadGlyph(FontHandle _handle, CodePoint _codePoint)
|
bool FontManager::preloadGlyph(FontHandle _handle, CodePoint _codePoint)
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_handle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_handle), "Invalid handle used");
|
||||||
CachedFont& font = m_cachedFonts[_handle.idx];
|
CachedFont& font = m_cachedFonts[_handle.idx];
|
||||||
FontInfo& fontInfo = font.fontInfo;
|
FontInfo& fontInfo = font.fontInfo;
|
||||||
|
|
||||||
@@ -418,7 +418,7 @@ bool FontManager::preloadGlyph(FontHandle _handle, CodePoint _codePoint)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BX_CHECK(false, "TextureType not supported yet");
|
BX_ASSERT(false, "TextureType not supported yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!addBitmap(glyphInfo, m_buffer) )
|
if (!addBitmap(glyphInfo, m_buffer) )
|
||||||
@@ -459,7 +459,7 @@ bool FontManager::preloadGlyph(FontHandle _handle, CodePoint _codePoint)
|
|||||||
|
|
||||||
const FontInfo& FontManager::getFontInfo(FontHandle _handle) const
|
const FontInfo& FontManager::getFontInfo(FontHandle _handle) const
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_handle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_handle), "Invalid handle used");
|
||||||
return m_cachedFonts[_handle.idx].fontInfo;
|
return m_cachedFonts[_handle.idx].fontInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -478,7 +478,7 @@ const GlyphInfo* FontManager::getGlyphInfo(FontHandle _handle, CodePoint _codePo
|
|||||||
it = cachedGlyphs.find(_codePoint);
|
it = cachedGlyphs.find(_codePoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
BX_CHECK(it != cachedGlyphs.end(), "Failed to preload glyph.");
|
BX_ASSERT(it != cachedGlyphs.end(), "Failed to preload glyph.");
|
||||||
return &it->second;
|
return &it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ void TextBuffer::appendText(FontHandle _fontHandle, const char* _string, const c
|
|||||||
{
|
{
|
||||||
_end = _string + bx::strLen(_string);
|
_end = _string + bx::strLen(_string);
|
||||||
}
|
}
|
||||||
BX_CHECK(_end >= _string);
|
BX_ASSERT(_end >= _string);
|
||||||
|
|
||||||
for (; *_string && _string < _end ; ++_string)
|
for (; *_string && _string < _end ; ++_string)
|
||||||
{
|
{
|
||||||
@@ -263,7 +263,7 @@ void TextBuffer::appendText(FontHandle _fontHandle, const char* _string, const c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BX_CHECK(state == UTF8_ACCEPT, "The string is not well-formed");
|
BX_ASSERT(state == UTF8_ACCEPT, "The string is not well-formed");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBuffer::appendText(FontHandle _fontHandle, const wchar_t* _string, const wchar_t* _end)
|
void TextBuffer::appendText(FontHandle _fontHandle, const wchar_t* _string, const wchar_t* _end)
|
||||||
@@ -281,7 +281,7 @@ void TextBuffer::appendText(FontHandle _fontHandle, const wchar_t* _string, cons
|
|||||||
{
|
{
|
||||||
_end = _string + wcslen(_string);
|
_end = _string + wcslen(_string);
|
||||||
}
|
}
|
||||||
BX_CHECK(_end >= _string);
|
BX_ASSERT(_end >= _string);
|
||||||
|
|
||||||
for (const wchar_t* _current = _string; _current < _end; ++_current)
|
for (const wchar_t* _current = _string; _current < _end; ++_current)
|
||||||
{
|
{
|
||||||
@@ -610,7 +610,7 @@ TextBufferManager::TextBufferManager(FontManager* _fontManager)
|
|||||||
|
|
||||||
TextBufferManager::~TextBufferManager()
|
TextBufferManager::~TextBufferManager()
|
||||||
{
|
{
|
||||||
BX_CHECK(m_textBufferHandles.getNumHandles() == 0, "All the text buffers must be destroyed before destroying the manager");
|
BX_ASSERT(m_textBufferHandles.getNumHandles() == 0, "All the text buffers must be destroyed before destroying the manager");
|
||||||
delete [] m_textBuffers;
|
delete [] m_textBuffers;
|
||||||
|
|
||||||
bgfx::destroy(s_texColor);
|
bgfx::destroy(s_texColor);
|
||||||
@@ -637,7 +637,7 @@ TextBufferHandle TextBufferManager::createTextBuffer(uint32_t _type, BufferType:
|
|||||||
|
|
||||||
void TextBufferManager::destroyTextBuffer(TextBufferHandle _handle)
|
void TextBufferManager::destroyTextBuffer(TextBufferHandle _handle)
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_handle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_handle), "Invalid handle used");
|
||||||
|
|
||||||
BufferCache& bc = m_textBuffers[_handle.idx];
|
BufferCache& bc = m_textBuffers[_handle.idx];
|
||||||
m_textBufferHandles.free(_handle.idx);
|
m_textBufferHandles.free(_handle.idx);
|
||||||
@@ -680,7 +680,7 @@ void TextBufferManager::destroyTextBuffer(TextBufferHandle _handle)
|
|||||||
|
|
||||||
void TextBufferManager::submitTextBuffer(TextBufferHandle _handle, bgfx::ViewId _id, int32_t _depth)
|
void TextBufferManager::submitTextBuffer(TextBufferHandle _handle, bgfx::ViewId _id, int32_t _depth)
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_handle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_handle), "Invalid handle used");
|
||||||
|
|
||||||
BufferCache& bc = m_textBuffers[_handle.idx];
|
BufferCache& bc = m_textBuffers[_handle.idx];
|
||||||
|
|
||||||
@@ -816,84 +816,84 @@ void TextBufferManager::submitTextBuffer(TextBufferHandle _handle, bgfx::ViewId
|
|||||||
|
|
||||||
void TextBufferManager::setStyle(TextBufferHandle _handle, uint32_t _flags)
|
void TextBufferManager::setStyle(TextBufferHandle _handle, uint32_t _flags)
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_handle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_handle), "Invalid handle used");
|
||||||
BufferCache& bc = m_textBuffers[_handle.idx];
|
BufferCache& bc = m_textBuffers[_handle.idx];
|
||||||
bc.textBuffer->setStyle(_flags);
|
bc.textBuffer->setStyle(_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBufferManager::setTextColor(TextBufferHandle _handle, uint32_t _rgba)
|
void TextBufferManager::setTextColor(TextBufferHandle _handle, uint32_t _rgba)
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_handle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_handle), "Invalid handle used");
|
||||||
BufferCache& bc = m_textBuffers[_handle.idx];
|
BufferCache& bc = m_textBuffers[_handle.idx];
|
||||||
bc.textBuffer->setTextColor(_rgba);
|
bc.textBuffer->setTextColor(_rgba);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBufferManager::setBackgroundColor(TextBufferHandle _handle, uint32_t _rgba)
|
void TextBufferManager::setBackgroundColor(TextBufferHandle _handle, uint32_t _rgba)
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_handle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_handle), "Invalid handle used");
|
||||||
BufferCache& bc = m_textBuffers[_handle.idx];
|
BufferCache& bc = m_textBuffers[_handle.idx];
|
||||||
bc.textBuffer->setBackgroundColor(_rgba);
|
bc.textBuffer->setBackgroundColor(_rgba);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBufferManager::setOverlineColor(TextBufferHandle _handle, uint32_t _rgba)
|
void TextBufferManager::setOverlineColor(TextBufferHandle _handle, uint32_t _rgba)
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_handle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_handle), "Invalid handle used");
|
||||||
BufferCache& bc = m_textBuffers[_handle.idx];
|
BufferCache& bc = m_textBuffers[_handle.idx];
|
||||||
bc.textBuffer->setOverlineColor(_rgba);
|
bc.textBuffer->setOverlineColor(_rgba);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBufferManager::setUnderlineColor(TextBufferHandle _handle, uint32_t _rgba)
|
void TextBufferManager::setUnderlineColor(TextBufferHandle _handle, uint32_t _rgba)
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_handle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_handle), "Invalid handle used");
|
||||||
BufferCache& bc = m_textBuffers[_handle.idx];
|
BufferCache& bc = m_textBuffers[_handle.idx];
|
||||||
bc.textBuffer->setUnderlineColor(_rgba);
|
bc.textBuffer->setUnderlineColor(_rgba);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBufferManager::setStrikeThroughColor(TextBufferHandle _handle, uint32_t _rgba)
|
void TextBufferManager::setStrikeThroughColor(TextBufferHandle _handle, uint32_t _rgba)
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_handle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_handle), "Invalid handle used");
|
||||||
BufferCache& bc = m_textBuffers[_handle.idx];
|
BufferCache& bc = m_textBuffers[_handle.idx];
|
||||||
bc.textBuffer->setStrikeThroughColor(_rgba);
|
bc.textBuffer->setStrikeThroughColor(_rgba);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBufferManager::setPenPosition(TextBufferHandle _handle, float _x, float _y)
|
void TextBufferManager::setPenPosition(TextBufferHandle _handle, float _x, float _y)
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_handle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_handle), "Invalid handle used");
|
||||||
BufferCache& bc = m_textBuffers[_handle.idx];
|
BufferCache& bc = m_textBuffers[_handle.idx];
|
||||||
bc.textBuffer->setPenPosition(_x, _y);
|
bc.textBuffer->setPenPosition(_x, _y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBufferManager::appendText(TextBufferHandle _handle, FontHandle _fontHandle, const char* _string, const char* _end)
|
void TextBufferManager::appendText(TextBufferHandle _handle, FontHandle _fontHandle, const char* _string, const char* _end)
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_handle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_handle), "Invalid handle used");
|
||||||
BufferCache& bc = m_textBuffers[_handle.idx];
|
BufferCache& bc = m_textBuffers[_handle.idx];
|
||||||
bc.textBuffer->appendText(_fontHandle, _string, _end);
|
bc.textBuffer->appendText(_fontHandle, _string, _end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBufferManager::appendText(TextBufferHandle _handle, FontHandle _fontHandle, const wchar_t* _string, const wchar_t* _end)
|
void TextBufferManager::appendText(TextBufferHandle _handle, FontHandle _fontHandle, const wchar_t* _string, const wchar_t* _end)
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_handle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_handle), "Invalid handle used");
|
||||||
BufferCache& bc = m_textBuffers[_handle.idx];
|
BufferCache& bc = m_textBuffers[_handle.idx];
|
||||||
bc.textBuffer->appendText(_fontHandle, _string, _end);
|
bc.textBuffer->appendText(_fontHandle, _string, _end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBufferManager::appendAtlasFace(TextBufferHandle _handle, uint16_t _faceIndex)
|
void TextBufferManager::appendAtlasFace(TextBufferHandle _handle, uint16_t _faceIndex)
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_handle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_handle), "Invalid handle used");
|
||||||
BufferCache& bc = m_textBuffers[_handle.idx];
|
BufferCache& bc = m_textBuffers[_handle.idx];
|
||||||
bc.textBuffer->appendAtlasFace(_faceIndex);
|
bc.textBuffer->appendAtlasFace(_faceIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBufferManager::clearTextBuffer(TextBufferHandle _handle)
|
void TextBufferManager::clearTextBuffer(TextBufferHandle _handle)
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_handle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_handle), "Invalid handle used");
|
||||||
BufferCache& bc = m_textBuffers[_handle.idx];
|
BufferCache& bc = m_textBuffers[_handle.idx];
|
||||||
bc.textBuffer->clearTextBuffer();
|
bc.textBuffer->clearTextBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
TextRectangle TextBufferManager::getRectangle(TextBufferHandle _handle) const
|
TextRectangle TextBufferManager::getRectangle(TextBufferHandle _handle) const
|
||||||
{
|
{
|
||||||
BX_CHECK(bgfx::isValid(_handle), "Invalid handle used");
|
BX_ASSERT(bgfx::isValid(_handle), "Invalid handle used");
|
||||||
BufferCache& bc = m_textBuffers[_handle.idx];
|
BufferCache& bc = m_textBuffers[_handle.idx];
|
||||||
return bc.textBuffer->getRectangle();
|
return bc.textBuffer->getRectangle();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,12 +59,12 @@ void TextMetrics::appendText(FontHandle _fontHandle, const char* _string)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BX_CHECK(false, "Glyph not found");
|
BX_ASSERT(false, "Glyph not found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BX_CHECK(state == UTF8_ACCEPT, "The string is not well-formed");
|
BX_ASSERT(state == UTF8_ACCEPT, "The string is not well-formed");
|
||||||
}
|
}
|
||||||
|
|
||||||
TextLineMetrics::TextLineMetrics(const FontInfo& _fontInfo)
|
TextLineMetrics::TextLineMetrics(const FontInfo& _fontInfo)
|
||||||
@@ -88,7 +88,7 @@ uint32_t TextLineMetrics::getLineCount(const bx::StringView& _str) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BX_CHECK(state == UTF8_ACCEPT, "The string is not well-formed");
|
BX_ASSERT(state == UTF8_ACCEPT, "The string is not well-formed");
|
||||||
return lineCount;
|
return lineCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ void TextLineMetrics::getSubText(const bx::StringView& _str, uint32_t _firstLine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BX_CHECK(state == UTF8_ACCEPT, "The string is not well-formed");
|
BX_ASSERT(state == UTF8_ACCEPT, "The string is not well-formed");
|
||||||
_begin = ptr;
|
_begin = ptr;
|
||||||
|
|
||||||
while (ptr != _str.getTerm()
|
while (ptr != _str.getTerm()
|
||||||
@@ -138,6 +138,6 @@ void TextLineMetrics::getSubText(const bx::StringView& _str, uint32_t _firstLine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BX_CHECK(state == UTF8_ACCEPT, "The string is not well-formed");
|
BX_ASSERT(state == UTF8_ACCEPT, "The string is not well-formed");
|
||||||
_end = ptr;
|
_end = ptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ namespace ps
|
|||||||
|
|
||||||
void updateEmitter(EmitterHandle _handle, const EmitterUniforms* _uniforms)
|
void updateEmitter(EmitterHandle _handle, const EmitterUniforms* _uniforms)
|
||||||
{
|
{
|
||||||
BX_CHECK(m_emitterAlloc.isValid(_handle.idx)
|
BX_ASSERT(m_emitterAlloc.isValid(_handle.idx)
|
||||||
, "destroyEmitter handle %d is not valid."
|
, "destroyEmitter handle %d is not valid."
|
||||||
, _handle.idx
|
, _handle.idx
|
||||||
);
|
);
|
||||||
@@ -645,7 +645,7 @@ namespace ps
|
|||||||
|
|
||||||
void getAabb(EmitterHandle _handle, Aabb& _outAabb)
|
void getAabb(EmitterHandle _handle, Aabb& _outAabb)
|
||||||
{
|
{
|
||||||
BX_CHECK(m_emitterAlloc.isValid(_handle.idx)
|
BX_ASSERT(m_emitterAlloc.isValid(_handle.idx)
|
||||||
, "getAabb handle %d is not valid."
|
, "getAabb handle %d is not valid."
|
||||||
, _handle.idx
|
, _handle.idx
|
||||||
);
|
);
|
||||||
@@ -654,7 +654,7 @@ namespace ps
|
|||||||
|
|
||||||
void destroyEmitter(EmitterHandle _handle)
|
void destroyEmitter(EmitterHandle _handle)
|
||||||
{
|
{
|
||||||
BX_CHECK(m_emitterAlloc.isValid(_handle.idx)
|
BX_ASSERT(m_emitterAlloc.isValid(_handle.idx)
|
||||||
, "destroyEmitter handle %d is not valid."
|
, "destroyEmitter handle %d is not valid."
|
||||||
, _handle.idx
|
, _handle.idx
|
||||||
);
|
);
|
||||||
|
|||||||
202
src/bgfx.cpp
202
src/bgfx.cpp
@@ -25,10 +25,10 @@ namespace bgfx
|
|||||||
|
|
||||||
#if BGFX_CONFIG_MULTITHREADED
|
#if BGFX_CONFIG_MULTITHREADED
|
||||||
# define BGFX_CHECK_API_THREAD() \
|
# define BGFX_CHECK_API_THREAD() \
|
||||||
BX_CHECK(NULL != s_ctx, "Library is not initialized yet."); \
|
BX_ASSERT(NULL != s_ctx, "Library is not initialized yet."); \
|
||||||
BX_CHECK(BGFX_API_THREAD_MAGIC == s_threadIndex, "Must be called from main thread.")
|
BX_ASSERT(BGFX_API_THREAD_MAGIC == s_threadIndex, "Must be called from main thread.")
|
||||||
# define BGFX_CHECK_RENDER_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 \
|
|| ~BGFX_API_THREAD_MAGIC == s_threadIndex \
|
||||||
, "Must be called from render thread." \
|
, "Must be called from render thread." \
|
||||||
)
|
)
|
||||||
@@ -38,7 +38,7 @@ namespace bgfx
|
|||||||
#endif // BGFX_CONFIG_MULTITHREADED
|
#endif // BGFX_CONFIG_MULTITHREADED
|
||||||
|
|
||||||
#define BGFX_CHECK_CAPS(_caps, _msg) \
|
#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." \
|
, _msg " Use bgfx::getCaps to check " #_caps " backend renderer capabilities." \
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ namespace bgfx
|
|||||||
#if BGFX_CONFIG_MEMORY_TRACKING
|
#if BGFX_CONFIG_MEMORY_TRACKING
|
||||||
{
|
{
|
||||||
bx::MutexScope scope(m_mutex);
|
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;
|
--m_numBlocks;
|
||||||
}
|
}
|
||||||
#endif // BGFX_CONFIG_MEMORY_TRACKING
|
#endif // BGFX_CONFIG_MEMORY_TRACKING
|
||||||
@@ -313,7 +313,7 @@ namespace bgfx
|
|||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
BX_CHECK(false, "You should not be here.");
|
BX_ASSERT(false, "You should not be here.");
|
||||||
return "?";
|
return "?";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -685,7 +685,7 @@ namespace bgfx
|
|||||||
ShaderHandle vsh = createEmbeddedShader(s_embeddedShaders, g_caps.rendererType, "vs_debugfont");
|
ShaderHandle vsh = createEmbeddedShader(s_embeddedShaders, g_caps.rendererType, "vs_debugfont");
|
||||||
ShaderHandle fsh = createEmbeddedShader(s_embeddedShaders, g_caps.rendererType, "fs_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);
|
m_program = createProgram(vsh, fsh, true);
|
||||||
|
|
||||||
@@ -857,17 +857,17 @@ namespace bgfx
|
|||||||
.end();
|
.end();
|
||||||
|
|
||||||
ShaderHandle vsh = createEmbeddedShader(s_embeddedShaders, g_caps.rendererType, "vs_clear");
|
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)
|
for (uint32_t ii = 0, num = g_caps.limits.maxFBAttachments; ii < num; ++ii)
|
||||||
{
|
{
|
||||||
char name[32];
|
char name[32];
|
||||||
bx::snprintf(name, BX_COUNTOF(name), "fs_clear%d", ii);
|
bx::snprintf(name, BX_COUNTOF(name), "fs_clear%d", ii);
|
||||||
ShaderHandle fsh = createEmbeddedShader(s_embeddedShaders, g_caps.rendererType, name);
|
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);
|
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);
|
destroy(fsh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -882,7 +882,7 @@ namespace bgfx
|
|||||||
const uint16_t stride = m_layout.m_stride;
|
const uint16_t stride = m_layout.m_stride;
|
||||||
const bgfx::Memory* mem = bgfx::alloc(4 * stride);
|
const bgfx::Memory* mem = bgfx::alloc(4 * stride);
|
||||||
Vertex* vertex = (Vertex*)mem->data;
|
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_x = -1.0f;
|
||||||
vertex->m_y = -1.0f;
|
vertex->m_y = -1.0f;
|
||||||
@@ -931,7 +931,7 @@ namespace bgfx
|
|||||||
|
|
||||||
const char* getUniformTypeName(UniformType::Enum _enum)
|
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];
|
return s_uniformTypeName[_enum];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1213,7 +1213,7 @@ namespace bgfx
|
|||||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG_OCCLUSION)
|
if (BX_ENABLED(BGFX_CONFIG_DEBUG_OCCLUSION)
|
||||||
&& isValid(_occlusionQuery) )
|
&& 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 %d was already used for this frame."
|
||||||
, _occlusionQuery.idx
|
, _occlusionQuery.idx
|
||||||
);
|
);
|
||||||
@@ -1449,7 +1449,7 @@ namespace bgfx
|
|||||||
return result;
|
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;
|
return RenderFrame::NoContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1753,7 +1753,7 @@ namespace bgfx
|
|||||||
return "Vertex";
|
return "Vertex";
|
||||||
}
|
}
|
||||||
|
|
||||||
BX_CHECK(false, "Invalid shader type!");
|
BX_ASSERT(false, "Invalid shader type!");
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -1790,7 +1790,7 @@ namespace bgfx
|
|||||||
|
|
||||||
bool Context::init(const Init& _init)
|
bool Context::init(const Init& _init)
|
||||||
{
|
{
|
||||||
BX_CHECK(!m_rendererInitialized, "Already initialized?");
|
BX_ASSERT(!m_rendererInitialized, "Already initialized?");
|
||||||
|
|
||||||
m_init = _init;
|
m_init = _init;
|
||||||
m_init.resolution.reset &= ~BGFX_RESET_INTERNAL_FORCE;
|
m_init.resolution.reset &= ~BGFX_RESET_INTERNAL_FORCE;
|
||||||
@@ -1877,7 +1877,7 @@ namespace bgfx
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint16_t idx = m_encoderHandle->alloc();
|
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_encoder[0].begin(m_submit, 0);
|
||||||
m_encoder0 = reinterpret_cast<Encoder*>(&m_encoder[0]);
|
m_encoder0 = reinterpret_cast<Encoder*>(&m_encoder[0]);
|
||||||
|
|
||||||
@@ -1981,7 +1981,7 @@ namespace bgfx
|
|||||||
m_dynVertexBufferAllocator.compact();
|
m_dynVertexBufferAllocator.compact();
|
||||||
m_dynIndexBufferAllocator.compact();
|
m_dynIndexBufferAllocator.compact();
|
||||||
|
|
||||||
BX_CHECK(
|
BX_ASSERT(
|
||||||
m_layoutHandle.getNumHandles() == m_vertexLayoutRef.m_vertexLayoutMap.getNumElements()
|
m_layoutHandle.getNumHandles() == m_vertexLayoutRef.m_vertexLayoutMap.getNumElements()
|
||||||
, "VertexLayoutRef mismatch, num handles %d, handles in hash map %d."
|
, "VertexLayoutRef mismatch, num handles %d, handles in hash map %d."
|
||||||
, m_layoutHandle.getNumHandles()
|
, m_layoutHandle.getNumHandles()
|
||||||
@@ -2681,11 +2681,11 @@ namespace bgfx
|
|||||||
|
|
||||||
default:
|
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?"
|
, "RendererInit must be the first command in command buffer before initialization. Unexpected command %d?"
|
||||||
, command
|
, command
|
||||||
);
|
);
|
||||||
BX_CHECK(!m_rendererInitialized, "This shouldn't happen! Bad synchronization?");
|
BX_ASSERT(!m_rendererInitialized, "This shouldn't happen! Bad synchronization?");
|
||||||
|
|
||||||
Init init;
|
Init init;
|
||||||
_cmdbuf.read(init);
|
_cmdbuf.read(init);
|
||||||
@@ -2697,7 +2697,7 @@ namespace bgfx
|
|||||||
if (!m_rendererInitialized)
|
if (!m_rendererInitialized)
|
||||||
{
|
{
|
||||||
_cmdbuf.read(command);
|
_cmdbuf.read(command);
|
||||||
BX_CHECK(CommandBuffer::End == command, "Unexpected command %d?"
|
BX_ASSERT(CommandBuffer::End == command, "Unexpected command %d?"
|
||||||
, command
|
, command
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@@ -2716,14 +2716,14 @@ namespace bgfx
|
|||||||
{
|
{
|
||||||
case CommandBuffer::RendererShutdownBegin:
|
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;
|
m_rendererInitialized = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CommandBuffer::RendererShutdownEnd:
|
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);
|
rendererDestroy(m_renderCtx);
|
||||||
m_renderCtx = NULL;
|
m_renderCtx = NULL;
|
||||||
@@ -3253,7 +3253,7 @@ namespace bgfx
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BX_CHECK(false, "Invalid command: %d", command);
|
BX_ASSERT(false, "Invalid command: %d", command);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (!end);
|
} while (!end);
|
||||||
@@ -3308,7 +3308,7 @@ namespace bgfx
|
|||||||
|
|
||||||
const char* getRendererName(RendererType::Enum _type)
|
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;
|
return s_rendererCreator[_type].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3503,7 +3503,7 @@ namespace bgfx
|
|||||||
BGFX_CHECK_API_THREAD();
|
BGFX_CHECK_API_THREAD();
|
||||||
Context* ctx = s_ctx; // it's going to be NULLd inside shutdown.
|
Context* ctx = s_ctx; // it's going to be NULLd inside shutdown.
|
||||||
ctx->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);
|
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)
|
void reset(uint32_t _width, uint32_t _height, uint32_t _flags, TextureFormat::Enum _format)
|
||||||
{
|
{
|
||||||
BGFX_CHECK_API_THREAD();
|
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);
|
s_ctx->reset(_width, _height, _flags, _format);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3553,7 +3553,7 @@ namespace bgfx
|
|||||||
|
|
||||||
void Encoder::setState(uint64_t _state, uint32_t _rgba)
|
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) );
|
BGFX_ENCODER(setState(_state, _rgba) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3597,8 +3597,8 @@ namespace bgfx
|
|||||||
{
|
{
|
||||||
BGFX_CHECK_HANDLE("setUniform", s_ctx->m_uniformHandle, _handle);
|
BGFX_CHECK_HANDLE("setUniform", s_ctx->m_uniformHandle, _handle);
|
||||||
const UniformRef& uniform = s_ctx->m_uniformRef[_handle.idx];
|
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_ASSERT(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(_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) );
|
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)
|
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_CHECK_HANDLE("setIndexBuffer", s_ctx->m_indexBufferHandle, _tib->handle);
|
||||||
BGFX_ENCODER(setIndexBuffer(_tib, _firstIndex, _numIndices) );
|
BGFX_ENCODER(setIndexBuffer(_tib, _firstIndex, _numIndices) );
|
||||||
}
|
}
|
||||||
@@ -3682,7 +3682,7 @@ namespace bgfx
|
|||||||
, VertexLayoutHandle _layoutHandle
|
, 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("setVertexBuffer", s_ctx->m_vertexBufferHandle, _tvb->handle);
|
||||||
BGFX_CHECK_HANDLE_INVALID_OK("setVertexBuffer", s_ctx->m_layoutHandle, _layoutHandle);
|
BGFX_CHECK_HANDLE_INVALID_OK("setVertexBuffer", s_ctx->m_layoutHandle, _layoutHandle);
|
||||||
BGFX_ENCODER(setVertexBuffer(_stream, _tvb, _startVertex, _numVertices, _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)
|
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) );
|
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("setTexture/UniformHandle", s_ctx->m_uniformHandle, _sampler);
|
||||||
BGFX_CHECK_HANDLE_INVALID_OK("setTexture/TextureHandle", s_ctx->m_textureHandle, _handle);
|
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) );
|
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)
|
void Encoder::submit(ViewId _id, ProgramHandle _program, OcclusionQueryHandle _occlusionQuery, uint32_t _depth, uint8_t _flags)
|
||||||
{
|
{
|
||||||
BX_CHECK(false
|
BX_ASSERT(false
|
||||||
|| !isValid(_occlusionQuery)
|
|| !isValid(_occlusionQuery)
|
||||||
|| 0 != (g_caps.supported & BGFX_CAPS_OCCLUSION_QUERY)
|
|| 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."
|
, "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)
|
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_CHECK_HANDLE("setBuffer", s_ctx->m_indexBufferHandle, _handle);
|
||||||
BGFX_ENCODER(setBuffer(_stage, _handle, _access) );
|
BGFX_ENCODER(setBuffer(_stage, _handle, _access) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Encoder::setBuffer(uint8_t _stage, VertexBufferHandle _handle, Access::Enum _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_CHECK_HANDLE("setBuffer", s_ctx->m_vertexBufferHandle, _handle);
|
||||||
BGFX_ENCODER(setBuffer(_stage, _handle, _access) );
|
BGFX_ENCODER(setBuffer(_stage, _handle, _access) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Encoder::setBuffer(uint8_t _stage, DynamicIndexBufferHandle _handle, Access::Enum _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);
|
BGFX_CHECK_HANDLE("setBuffer", s_ctx->m_dynamicIndexBufferHandle, _handle);
|
||||||
const DynamicIndexBuffer& dib = s_ctx->m_dynamicIndexBuffers[_handle.idx];
|
const DynamicIndexBuffer& dib = s_ctx->m_dynamicIndexBuffers[_handle.idx];
|
||||||
BGFX_ENCODER(setBuffer(_stage, dib.m_handle, _access) );
|
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)
|
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);
|
BGFX_CHECK_HANDLE("setBuffer", s_ctx->m_dynamicVertexBufferHandle, _handle);
|
||||||
const DynamicVertexBuffer& dvb = s_ctx->m_dynamicVertexBuffers[_handle.idx];
|
const DynamicVertexBuffer& dvb = s_ctx->m_dynamicVertexBuffers[_handle.idx];
|
||||||
BGFX_ENCODER(setBuffer(_stage, dvb.m_handle, _access) );
|
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)
|
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);
|
BGFX_CHECK_HANDLE("setBuffer", s_ctx->m_vertexBufferHandle, _handle);
|
||||||
VertexBufferHandle handle = { _handle.idx };
|
VertexBufferHandle handle = { _handle.idx };
|
||||||
BGFX_ENCODER(setBuffer(_stage, handle, _access) );
|
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)
|
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);
|
BGFX_CHECK_HANDLE_INVALID_OK("setImage/TextureHandle", s_ctx->m_textureHandle, _handle);
|
||||||
_format = TextureFormat::Count == _format
|
_format = TextureFormat::Count == _format
|
||||||
? TextureFormat::Enum(s_ctx->m_textureRef[_handle.idx].m_format)
|
? TextureFormat::Enum(s_ctx->m_textureRef[_handle.idx].m_format)
|
||||||
: _format
|
: _format
|
||||||
;
|
;
|
||||||
BX_CHECK(_format != TextureFormat::BGRA8
|
BX_ASSERT(_format != TextureFormat::BGRA8
|
||||||
, "Can't use TextureFormat::BGRA8 with compute, use TextureFormat::RGBA8 instead."
|
, "Can't use TextureFormat::BGRA8 with compute, use TextureFormat::RGBA8 instead."
|
||||||
);
|
);
|
||||||
BGFX_ENCODER(setImage(_stage, _handle, _mip, _access, _format) );
|
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);
|
BGFX_CHECK_HANDLE("blit/dst TextureHandle", s_ctx->m_textureHandle, _dst);
|
||||||
const TextureRef& src = s_ctx->m_textureRef[_src.idx];
|
const TextureRef& src = s_ctx->m_textureRef[_src.idx];
|
||||||
const TextureRef& dst = s_ctx->m_textureRef[_dst.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)."
|
, "Texture format must match (src %s, dst %s)."
|
||||||
, bimg::getName(bimg::TextureFormat::Enum(src.m_format) )
|
, bimg::getName(bimg::TextureFormat::Enum(src.m_format) )
|
||||||
, bimg::getName(bimg::TextureFormat::Enum(dst.m_format) )
|
, bimg::getName(bimg::TextureFormat::Enum(dst.m_format) )
|
||||||
@@ -3898,7 +3898,7 @@ namespace bgfx
|
|||||||
|
|
||||||
const Memory* alloc(uint32_t _size)
|
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);
|
Memory* mem = (Memory*)BX_ALLOC(g_allocator, sizeof(Memory) + _size);
|
||||||
mem->size = _size;
|
mem->size = _size;
|
||||||
mem->data = (uint8_t*)mem + sizeof(Memory);
|
mem->data = (uint8_t*)mem + sizeof(Memory);
|
||||||
@@ -3907,7 +3907,7 @@ namespace bgfx
|
|||||||
|
|
||||||
const Memory* copy(const void* _data, uint32_t _size)
|
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);
|
const Memory* mem = alloc(_size);
|
||||||
bx::memCopy(mem->data, _data, _size);
|
bx::memCopy(mem->data, _data, _size);
|
||||||
return mem;
|
return mem;
|
||||||
@@ -3937,7 +3937,7 @@ namespace bgfx
|
|||||||
|
|
||||||
void release(const Memory* _mem)
|
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);
|
Memory* mem = const_cast<Memory*>(_mem);
|
||||||
if (isMemoryRef(mem) )
|
if (isMemoryRef(mem) )
|
||||||
{
|
{
|
||||||
@@ -3984,7 +3984,7 @@ namespace bgfx
|
|||||||
|
|
||||||
IndexBufferHandle createIndexBuffer(const Memory* _mem, uint16_t _flags)
|
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);
|
return s_ctx->createIndexBuffer(_mem, _flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4010,8 +4010,8 @@ namespace bgfx
|
|||||||
|
|
||||||
VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexLayout& _layout, uint16_t _flags)
|
VertexBufferHandle createVertexBuffer(const Memory* _mem, const VertexLayout& _layout, uint16_t _flags)
|
||||||
{
|
{
|
||||||
BX_CHECK(NULL != _mem, "_mem can't be NULL");
|
BX_ASSERT(NULL != _mem, "_mem can't be NULL");
|
||||||
BX_CHECK(isValid(_layout), "Invalid VertexLayout.");
|
BX_ASSERT(isValid(_layout), "Invalid VertexLayout.");
|
||||||
return s_ctx->createVertexBuffer(_mem, _layout, _flags);
|
return s_ctx->createVertexBuffer(_mem, _layout, _flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4032,13 +4032,13 @@ namespace bgfx
|
|||||||
|
|
||||||
DynamicIndexBufferHandle createDynamicIndexBuffer(const Memory* _mem, uint16_t _flags)
|
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);
|
return s_ctx->createDynamicIndexBuffer(_mem, _flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(DynamicIndexBufferHandle _handle, uint32_t _startIndex, const Memory* _mem)
|
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);
|
s_ctx->update(_handle, _startIndex, _mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4049,20 +4049,20 @@ namespace bgfx
|
|||||||
|
|
||||||
DynamicVertexBufferHandle createDynamicVertexBuffer(uint32_t _num, const VertexLayout& _layout, uint16_t _flags)
|
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);
|
return s_ctx->createDynamicVertexBuffer(_num, _layout, _flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexLayout& _layout, uint16_t _flags)
|
DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexLayout& _layout, uint16_t _flags)
|
||||||
{
|
{
|
||||||
BX_CHECK(NULL != _mem, "_mem can't be NULL");
|
BX_ASSERT(NULL != _mem, "_mem can't be NULL");
|
||||||
BX_CHECK(isValid(_layout), "Invalid VertexLayout.");
|
BX_ASSERT(isValid(_layout), "Invalid VertexLayout.");
|
||||||
return s_ctx->createDynamicVertexBuffer(_mem, _layout, _flags);
|
return s_ctx->createDynamicVertexBuffer(_mem, _layout, _flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(DynamicVertexBufferHandle _handle, uint32_t _startVertex, const Memory* _mem)
|
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);
|
s_ctx->update(_handle, _startVertex, _mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4073,29 +4073,29 @@ namespace bgfx
|
|||||||
|
|
||||||
uint32_t getAvailTransientIndexBuffer(uint32_t _num)
|
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);
|
return s_ctx->getAvailTransientIndexBuffer(_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getAvailTransientVertexBuffer(uint32_t _num, const VertexLayout& _layout)
|
uint32_t getAvailTransientVertexBuffer(uint32_t _num, const VertexLayout& _layout)
|
||||||
{
|
{
|
||||||
BX_CHECK(0 < _num, "Requesting 0 vertices.");
|
BX_ASSERT(0 < _num, "Requesting 0 vertices.");
|
||||||
BX_CHECK(isValid(_layout), "Invalid VertexLayout.");
|
BX_ASSERT(isValid(_layout), "Invalid VertexLayout.");
|
||||||
return s_ctx->getAvailTransientVertexBuffer(_num, _layout.m_stride);
|
return s_ctx->getAvailTransientVertexBuffer(_num, _layout.m_stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getAvailInstanceDataBuffer(uint32_t _num, uint16_t _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);
|
return s_ctx->getAvailTransientVertexBuffer(_num, _stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
void allocTransientIndexBuffer(TransientIndexBuffer* _tib, uint32_t _num)
|
void allocTransientIndexBuffer(TransientIndexBuffer* _tib, uint32_t _num)
|
||||||
{
|
{
|
||||||
BX_CHECK(NULL != _tib, "_tib can't be NULL");
|
BX_ASSERT(NULL != _tib, "_tib can't be NULL");
|
||||||
BX_CHECK(0 < _num, "Requesting 0 indices.");
|
BX_ASSERT(0 < _num, "Requesting 0 indices.");
|
||||||
s_ctx->allocTransientIndexBuffer(_tib, _num);
|
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). "
|
, "Failed to allocate transient index buffer (requested %d, available %d). "
|
||||||
"Use bgfx::getAvailTransient* functions to ensure availability."
|
"Use bgfx::getAvailTransient* functions to ensure availability."
|
||||||
, _num
|
, _num
|
||||||
@@ -4105,11 +4105,11 @@ namespace bgfx
|
|||||||
|
|
||||||
void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint32_t _num, const VertexLayout& _layout)
|
void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint32_t _num, const VertexLayout& _layout)
|
||||||
{
|
{
|
||||||
BX_CHECK(NULL != _tvb, "_tvb can't be NULL");
|
BX_ASSERT(NULL != _tvb, "_tvb can't be NULL");
|
||||||
BX_CHECK(0 < _num, "Requesting 0 vertices.");
|
BX_ASSERT(0 < _num, "Requesting 0 vertices.");
|
||||||
BX_CHECK(isValid(_layout), "Invalid VertexLayout.");
|
BX_ASSERT(isValid(_layout), "Invalid VertexLayout.");
|
||||||
s_ctx->allocTransientVertexBuffer(_tvb, _num, _layout);
|
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). "
|
, "Failed to allocate transient vertex buffer (requested %d, available %d). "
|
||||||
"Use bgfx::getAvailTransient* functions to ensure availability."
|
"Use bgfx::getAvailTransient* functions to ensure availability."
|
||||||
, _num
|
, _num
|
||||||
@@ -4135,10 +4135,10 @@ namespace bgfx
|
|||||||
void allocInstanceDataBuffer(InstanceDataBuffer* _idb, uint32_t _num, uint16_t _stride)
|
void allocInstanceDataBuffer(InstanceDataBuffer* _idb, uint32_t _num, uint16_t _stride)
|
||||||
{
|
{
|
||||||
BGFX_CHECK_CAPS(BGFX_CAPS_INSTANCING, "Instancing is not supported!");
|
BGFX_CHECK_CAPS(BGFX_CAPS_INSTANCING, "Instancing is not supported!");
|
||||||
BX_CHECK(bx::isAligned(_stride, 16), "Stride must be multiple of 16.");
|
BX_ASSERT(bx::isAligned(_stride, 16), "Stride must be multiple of 16.");
|
||||||
BX_CHECK(0 < _num, "Requesting 0 instanced data vertices.");
|
BX_ASSERT(0 < _num, "Requesting 0 instanced data vertices.");
|
||||||
s_ctx->allocInstanceDataBuffer(_idb, _num, _stride);
|
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). "
|
, "Failed to allocate instance data buffer (requested %d, available %d). "
|
||||||
"Use bgfx::getAvailTransient* functions to ensure availability."
|
"Use bgfx::getAvailTransient* functions to ensure availability."
|
||||||
, _num
|
, _num
|
||||||
@@ -4158,7 +4158,7 @@ namespace bgfx
|
|||||||
|
|
||||||
ShaderHandle createShader(const Memory* _mem)
|
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);
|
return s_ctx->createShader(_mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4341,7 +4341,7 @@ namespace bgfx
|
|||||||
|
|
||||||
TextureHandle createTexture(const Memory* _mem, uint64_t _flags, uint8_t _skip, TextureInfo* _info)
|
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);
|
return s_ctx->createTexture(_mem, _flags, _skip, _info, BackbufferRatio::Count, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4367,7 +4367,7 @@ namespace bgfx
|
|||||||
{
|
{
|
||||||
bx::Error err;
|
bx::Error err;
|
||||||
isTextureValid(0, false, _numLayers, _format, _flags, &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()
|
, err.getMessage().getPtr()
|
||||||
, _numLayers
|
, _numLayers
|
||||||
, getName(_format)
|
, getName(_format)
|
||||||
@@ -4388,7 +4388,7 @@ namespace bgfx
|
|||||||
{
|
{
|
||||||
TextureInfo ti;
|
TextureInfo ti;
|
||||||
calcTextureSize(ti, _width, _height, 1, false, _hasMips, _numLayers, _format);
|
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)"
|
, "createTexture2D: Texture storage size doesn't match passed memory size (storage size: %d, memory size: %d)"
|
||||||
, ti.storageSize
|
, ti.storageSize
|
||||||
, _mem->size
|
, _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)
|
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);
|
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)
|
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);
|
return createTexture2D(_ratio, 0, 0, _hasMips, _numLayers, _format, _flags, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4432,7 +4432,7 @@ namespace bgfx
|
|||||||
{
|
{
|
||||||
bx::Error err;
|
bx::Error err;
|
||||||
isTextureValid(_depth, false, 1, _format, _flags, &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);
|
const uint8_t numMips = calcNumMips(_hasMips, _width, _height, _depth);
|
||||||
|
|
||||||
@@ -4441,7 +4441,7 @@ namespace bgfx
|
|||||||
{
|
{
|
||||||
TextureInfo ti;
|
TextureInfo ti;
|
||||||
calcTextureSize(ti, _width, _height, _depth, false, _hasMips, 1, _format);
|
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)"
|
, "createTexture3D: Texture storage size doesn't match passed memory size (storage size: %d, memory size: %d)"
|
||||||
, ti.storageSize
|
, ti.storageSize
|
||||||
, _mem->size
|
, _mem->size
|
||||||
@@ -4473,7 +4473,7 @@ namespace bgfx
|
|||||||
{
|
{
|
||||||
bx::Error err;
|
bx::Error err;
|
||||||
isTextureValid(0, true, _numLayers, _format, _flags, &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);
|
const uint8_t numMips = calcNumMips(_hasMips, _size, _size);
|
||||||
_numLayers = bx::max<uint16_t>(_numLayers, 1);
|
_numLayers = bx::max<uint16_t>(_numLayers, 1);
|
||||||
@@ -4483,7 +4483,7 @@ namespace bgfx
|
|||||||
{
|
{
|
||||||
TextureInfo ti;
|
TextureInfo ti;
|
||||||
calcTextureSize(ti, _size, _size, 1, true, _hasMips, _numLayers, _format);
|
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)"
|
, "createTextureCube: Texture storage size doesn't match passed memory size (storage size: %d, memory size: %d)"
|
||||||
, ti.storageSize
|
, ti.storageSize
|
||||||
, _mem->size
|
, _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)
|
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
|
if (_width == 0
|
||||||
|| _height == 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)
|
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!");
|
BGFX_CHECK_CAPS(BGFX_CAPS_TEXTURE_3D, "Texture3D is not supported!");
|
||||||
|
|
||||||
if (0 == _width
|
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)
|
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_ASSERT(NULL != _mem, "_mem can't be NULL");
|
||||||
BX_CHECK(_side <= 5, "Invalid side %d.", _side);
|
BX_ASSERT(_side <= 5, "Invalid side %d.", _side);
|
||||||
if (0 == _width
|
if (0 == _width
|
||||||
|| 0 == _height)
|
|| 0 == _height)
|
||||||
{
|
{
|
||||||
@@ -4574,7 +4574,7 @@ namespace bgfx
|
|||||||
|
|
||||||
uint32_t readTexture(TextureHandle _handle, void* _data, uint8_t _mip)
|
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!");
|
BGFX_CHECK_CAPS(BGFX_CAPS_TEXTURE_READ_BACK, "Texture read-back is not supported!");
|
||||||
return s_ctx->readTexture(_handle, _data, _mip);
|
return s_ctx->readTexture(_handle, _data, _mip);
|
||||||
}
|
}
|
||||||
@@ -4588,7 +4588,7 @@ namespace bgfx
|
|||||||
|
|
||||||
FrameBufferHandle createFrameBuffer(BackbufferRatio::Enum _ratio, TextureFormat::Enum _format, uint64_t _textureFlags)
|
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;
|
_textureFlags |= _textureFlags&BGFX_TEXTURE_RT_MSAA_MASK ? 0 : BGFX_TEXTURE_RT;
|
||||||
TextureHandle th = createTexture2D(_ratio, false, 1, _format, _textureFlags);
|
TextureHandle th = createTexture2D(_ratio, false, 1, _format, _textureFlags);
|
||||||
return createFrameBuffer(1, &th, true);
|
return createFrameBuffer(1, &th, true);
|
||||||
@@ -4607,13 +4607,13 @@ namespace bgfx
|
|||||||
|
|
||||||
FrameBufferHandle createFrameBuffer(uint8_t _num, const Attachment* _attachment, bool _destroyTextures)
|
FrameBufferHandle createFrameBuffer(uint8_t _num, const Attachment* _attachment, bool _destroyTextures)
|
||||||
{
|
{
|
||||||
BX_CHECK(_num != 0, "Number of frame buffer attachments can't be 0.");
|
BX_ASSERT(_num != 0, "Number of frame buffer attachments can't be 0.");
|
||||||
BX_CHECK(_num <= BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS
|
BX_ASSERT(_num <= BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS
|
||||||
, "Number of frame buffer attachments is larger than allowed %d (max: %d)."
|
, "Number of frame buffer attachments is larger than allowed %d (max: %d)."
|
||||||
, _num
|
, _num
|
||||||
, BGFX_CONFIG_MAX_FRAME_BUFFER_ATTACHMENTS
|
, 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);
|
return s_ctx->createFrameBuffer(_num, _attachment, _destroyTextures);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4625,11 +4625,11 @@ namespace bgfx
|
|||||||
, _width
|
, _width
|
||||||
, _height
|
, _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)."
|
, "Invalid texture format for color (%s)."
|
||||||
, bimg::getName(bimg::TextureFormat::Enum(_format) )
|
, 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)."
|
, "Invalid texture format for depth (%s)."
|
||||||
, bimg::getName(bimg::TextureFormat::Enum(_depthFormat) )
|
, bimg::getName(bimg::TextureFormat::Enum(_depthFormat) )
|
||||||
);
|
);
|
||||||
@@ -4728,19 +4728,19 @@ namespace bgfx
|
|||||||
|
|
||||||
void setViewName(ViewId _id, const char* _name)
|
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);
|
s_ctx->setViewName(_id, _name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setViewRect(ViewId _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
|
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);
|
s_ctx->setViewRect(_id, _x, _y, _width, _height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setViewRect(ViewId _id, uint16_t _x, uint16_t _y, BackbufferRatio::Enum _ratio)
|
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 width = uint16_t(s_ctx->m_init.resolution.width);
|
||||||
uint16_t height = uint16_t(s_ctx->m_init.resolution.height);
|
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)
|
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);
|
s_ctx->setViewScissor(_id, _x, _y, _width, _height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setViewClear(ViewId _id, uint16_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil)
|
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);
|
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)
|
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);
|
s_ctx->setViewClear(_id, _flags, _depth, _stencil, _0, _1, _2, _3, _4, _5, _6, _7);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setViewMode(ViewId _id, ViewMode::Enum _mode)
|
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);
|
s_ctx->setViewMode(_id, _mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setViewFrameBuffer(ViewId _id, FrameBufferHandle _handle)
|
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);
|
s_ctx->setViewFrameBuffer(_id, _handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setViewTransform(ViewId _id, const void* _view, const void* _proj)
|
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);
|
s_ctx->setViewTransform(_id, _view, _proj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setViewOrder(ViewId _id, uint16_t _num, const ViewId* _order)
|
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);
|
s_ctx->setViewOrder(_id, _num, _order);
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetView(ViewId _id)
|
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);
|
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
|
#if BGFX_CONFIG_DEBUG || BX_COMPILER_CLANG_ANALYZER
|
||||||
# define BX_TRACE _BX_TRACE
|
# define BX_TRACE _BX_TRACE
|
||||||
# define BX_WARN _BX_WARN
|
# define BX_WARN _BX_WARN
|
||||||
# define BX_CHECK _BX_CHECK
|
# define BX_ASSERT _BX_ASSERT
|
||||||
# define BX_CONFIG_ALLOCATOR_DEBUG 1
|
# define BX_CONFIG_ALLOCATOR_DEBUG 1
|
||||||
#endif // BGFX_CONFIG_DEBUG
|
#endif // BGFX_CONFIG_DEBUG
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
// Check handle, cannot be bgfx::kInvalidHandle and must be valid.
|
// Check handle, cannot be bgfx::kInvalidHandle and must be valid.
|
||||||
#define BGFX_CHECK_HANDLE(_desc, _handleAlloc, _handle) \
|
#define BGFX_CHECK_HANDLE(_desc, _handleAlloc, _handle) \
|
||||||
BX_CHECK(isValid(_handle) \
|
BX_ASSERT(isValid(_handle) \
|
||||||
&& _handleAlloc.isValid(_handle.idx) \
|
&& _handleAlloc.isValid(_handle.idx) \
|
||||||
, "Invalid handle. %s handle: %d (max %d)" \
|
, "Invalid handle. %s handle: %d (max %d)" \
|
||||||
, _desc \
|
, _desc \
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
// Check handle, it's ok to be bgfx::kInvalidHandle or must be valid.
|
// Check handle, it's ok to be bgfx::kInvalidHandle or must be valid.
|
||||||
#define BGFX_CHECK_HANDLE_INVALID_OK(_desc, _handleAlloc, _handle) \
|
#define BGFX_CHECK_HANDLE_INVALID_OK(_desc, _handleAlloc, _handle) \
|
||||||
BX_CHECK(!isValid(_handle) \
|
BX_ASSERT(!isValid(_handle) \
|
||||||
|| _handleAlloc.isValid(_handle.idx) \
|
|| _handleAlloc.isValid(_handle.idx) \
|
||||||
, "Invalid handle. %s handle: %d (max %d)" \
|
, "Invalid handle. %s handle: %d (max %d)" \
|
||||||
, _desc \
|
, _desc \
|
||||||
@@ -91,7 +91,7 @@ namespace bgfx
|
|||||||
} \
|
} \
|
||||||
BX_MACRO_BLOCK_END
|
BX_MACRO_BLOCK_END
|
||||||
|
|
||||||
#define _BX_CHECK(_condition, _format, ...) \
|
#define _BX_ASSERT(_condition, _format, ...) \
|
||||||
BX_MACRO_BLOCK_BEGIN \
|
BX_MACRO_BLOCK_BEGIN \
|
||||||
if (!BX_IGNORE_C4127(_condition) ) \
|
if (!BX_IGNORE_C4127(_condition) ) \
|
||||||
{ \
|
{ \
|
||||||
@@ -836,7 +836,7 @@ namespace bgfx
|
|||||||
|
|
||||||
void write(const void* _data, uint32_t _size)
|
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)
|
if (m_pos + _size > m_capacity)
|
||||||
{
|
{
|
||||||
resize(m_capacity + (16<<10) );
|
resize(m_capacity + (16<<10) );
|
||||||
@@ -855,7 +855,7 @@ namespace bgfx
|
|||||||
|
|
||||||
void read(void* _data, uint32_t _size)
|
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)."
|
, "CommandBuffer::read error (pos: %d-%d, size: %d)."
|
||||||
, m_pos
|
, m_pos
|
||||||
, m_pos + _size
|
, m_pos + _size
|
||||||
@@ -874,7 +874,7 @@ namespace bgfx
|
|||||||
|
|
||||||
const uint8_t* skip(uint32_t _size)
|
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)."
|
, "CommandBuffer::skip error (pos: %d-%d, size: %d)."
|
||||||
, m_pos
|
, m_pos
|
||||||
, m_pos + _size
|
, 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 view = (uint64_t(m_view ) << kSortKeyViewBitShift ) & kSortKeyViewMask;
|
||||||
const uint64_t key = view|kSortKeyDrawBit|kSortKeyDrawTypeSequence|seq|blend|program;
|
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)."
|
, "SortKey error, sequence is truncated (m_seq: %d)."
|
||||||
, m_seq
|
, m_seq
|
||||||
);
|
);
|
||||||
@@ -1133,7 +1133,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
BX_CHECK(false, "You should not be here.");
|
BX_ASSERT(false, "You should not be here.");
|
||||||
return 0;
|
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 view = (uint64_t(m_view ) << kSortKeyViewBitShift ) & kSortKeyViewMask;
|
||||||
const uint64_t key = program|seq|view;
|
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)."
|
, "SortKey error, sequence is truncated (m_seq: %d)."
|
||||||
, m_seq
|
, m_seq
|
||||||
);
|
);
|
||||||
@@ -1297,7 +1297,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
|
|
||||||
float* toPtr(uint32_t _cacheIdx)
|
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
|
, _cacheIdx
|
||||||
, BGFX_CONFIG_MAX_MATRIX_CACHE
|
, 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)
|
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);
|
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];
|
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)
|
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)
|
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)
|
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];
|
const char* result = &m_buffer[m_pos];
|
||||||
m_pos += _size;
|
m_pos += _size;
|
||||||
return result;
|
return result;
|
||||||
@@ -1516,7 +1516,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
|
|
||||||
const UniformRegInfo& add(UniformHandle _handle, const char* _name)
|
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);
|
const uint32_t key = bx::hash<bx::HashMurmur2A>(_name);
|
||||||
m_uniforms.removeByKey(key);
|
m_uniforms.removeByKey(key);
|
||||||
m_uniforms.insert(key, _handle.idx);
|
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) )
|
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."
|
, "Uniform %d (%s) was already set for this draw call."
|
||||||
, _handle.idx
|
, _handle.idx
|
||||||
, getName(_handle)
|
, getName(_handle)
|
||||||
@@ -2364,7 +2364,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
|
|
||||||
void setTransform(uint32_t _cache, uint16_t _num)
|
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
|
, _cache
|
||||||
, BGFX_CONFIG_MAX_MATRIX_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)
|
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_startIndex = _firstIndex;
|
||||||
m_draw.m_numIndices = _numIndices;
|
m_draw.m_numIndices = _numIndices;
|
||||||
m_draw.m_indexBuffer = _handle;
|
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)
|
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;
|
const uint32_t indexSize = 0 == (_dib.m_flags & BGFX_BUFFER_INDEX32) ? 2 : 4;
|
||||||
m_draw.m_startIndex = _dib.m_startIndex + _firstIndex;
|
m_draw.m_startIndex = _dib.m_startIndex + _firstIndex;
|
||||||
m_draw.m_numIndices = bx::min(_numIndices, _dib.m_size/indexSize);
|
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)
|
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);
|
const uint32_t numIndices = bx::min(_numIndices, _tib->size/2);
|
||||||
m_draw.m_indexBuffer = _tib->handle;
|
m_draw.m_indexBuffer = _tib->handle;
|
||||||
m_draw.m_startIndex = _tib->startIndex + _firstIndex;
|
m_draw.m_startIndex = _tib->startIndex + _firstIndex;
|
||||||
@@ -2407,8 +2407,8 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
, VertexLayoutHandle _layoutHandle
|
, VertexLayoutHandle _layoutHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
BX_CHECK(UINT8_MAX != m_draw.m_streamMask, "");
|
BX_ASSERT(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(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
|
||||||
if (m_draw.setStreamBit(_stream, _handle) )
|
if (m_draw.setStreamBit(_stream, _handle) )
|
||||||
{
|
{
|
||||||
Stream& stream = m_draw.m_stream[_stream];
|
Stream& stream = m_draw.m_stream[_stream];
|
||||||
@@ -2427,8 +2427,8 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
, VertexLayoutHandle _layoutHandle
|
, VertexLayoutHandle _layoutHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
BX_CHECK(UINT8_MAX != m_draw.m_streamMask, "");
|
BX_ASSERT(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(_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) )
|
if (m_draw.setStreamBit(_stream, _dvb.m_handle) )
|
||||||
{
|
{
|
||||||
Stream& stream = m_draw.m_stream[_stream];
|
Stream& stream = m_draw.m_stream[_stream];
|
||||||
@@ -2449,8 +2449,8 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
, VertexLayoutHandle _layoutHandle
|
, VertexLayoutHandle _layoutHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
BX_CHECK(UINT8_MAX != m_draw.m_streamMask, "");
|
BX_ASSERT(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(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
|
||||||
if (m_draw.setStreamBit(_stream, _tvb->handle) )
|
if (m_draw.setStreamBit(_stream, _tvb->handle) )
|
||||||
{
|
{
|
||||||
Stream& stream = m_draw.m_stream[_stream];
|
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)
|
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;
|
m_draw.m_streamMask = UINT8_MAX;
|
||||||
Stream& stream = m_draw.m_stream[0];
|
Stream& stream = m_draw.m_stream[0];
|
||||||
stream.m_startVertex = 0;
|
stream.m_startVertex = 0;
|
||||||
@@ -2492,7 +2492,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
|
|
||||||
void setInstanceCount(uint32_t _numInstances)
|
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;
|
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)
|
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_vertexBufferRef[_handle.idx] = _layoutHandle;
|
||||||
m_vertexLayoutRef[_layoutHandle.idx]++;
|
m_vertexLayoutRef[_layoutHandle.idx]++;
|
||||||
m_vertexLayoutMap.insert(_hash, _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)
|
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_dynamicVertexBufferRef[_handle.idx] = _layoutHandle;
|
||||||
m_vertexLayoutRef[_layoutHandle.idx]++;
|
m_vertexLayoutRef[_layoutHandle.idx]++;
|
||||||
m_vertexLayoutMap.insert(_hash, _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()
|
uint64_t remove()
|
||||||
{
|
{
|
||||||
BX_CHECK(0 == m_used.size(), "");
|
BX_ASSERT(0 == m_used.size(), "");
|
||||||
|
|
||||||
if (0 < m_free.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);
|
BGFX_CHECK_HANDLE("destroyIndexBuffer", m_indexBufferHandle, _handle);
|
||||||
bool ok = m_submit->free(_handle); BX_UNUSED(ok);
|
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];
|
IndexBuffer& ref = m_indexBuffers[_handle.idx];
|
||||||
ref.m_name.clear();
|
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);
|
BGFX_CHECK_HANDLE("destroyVertexBuffer", m_vertexBufferHandle, _handle);
|
||||||
bool ok = m_submit->free(_handle); BX_UNUSED(ok);
|
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];
|
VertexBuffer& ref = m_vertexBuffers[_handle.idx];
|
||||||
ref.m_name.clear();
|
ref.m_name.clear();
|
||||||
@@ -3303,7 +3303,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
{
|
{
|
||||||
BGFX_MUTEX_SCOPE(m_resourceApiLock);
|
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;
|
const uint32_t indexSize = 0 == (_flags & BGFX_BUFFER_INDEX32) ? 2 : 4;
|
||||||
DynamicIndexBufferHandle handle = createDynamicIndexBuffer(_mem->size/indexSize, _flags);
|
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);
|
BGFX_CHECK_HANDLE("updateDynamicIndexBuffer", m_dynamicIndexBufferHandle, _handle);
|
||||||
|
|
||||||
DynamicIndexBuffer& dib = m_dynamicIndexBuffers[_handle.idx];
|
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;
|
const uint32_t indexSize = 0 == (dib.m_flags & BGFX_BUFFER_INDEX32) ? 2 : 4;
|
||||||
|
|
||||||
if (dib.m_size < _mem->size
|
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)
|
+ bx::min(bx::uint32_satsub(dib.m_size, _startIndex*indexSize), _mem->size)
|
||||||
, m_indexBuffers[dib.m_handle.idx].m_size) - offset
|
, 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
|
, size
|
||||||
, _mem->size
|
, _mem->size
|
||||||
);
|
);
|
||||||
@@ -3513,7 +3513,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
BGFX_CHECK_HANDLE("updateDynamicVertexBuffer", m_dynamicVertexBufferHandle, _handle);
|
BGFX_CHECK_HANDLE("updateDynamicVertexBuffer", m_dynamicVertexBufferHandle, _handle);
|
||||||
|
|
||||||
DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[_handle.idx];
|
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
|
if (dvb.m_size < _mem->size
|
||||||
&& 0 != (dvb.m_flags & BGFX_BUFFER_ALLOW_RESIZE) )
|
&& 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)
|
+ bx::min(bx::uint32_satsub(dvb.m_size, _startVertex*dvb.m_stride), _mem->size)
|
||||||
, m_vertexBuffers[dvb.m_handle.idx].m_size) - offset
|
, 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
|
, size
|
||||||
, _mem->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);
|
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];
|
ShaderRef& sr = m_shaderRef[handle.idx];
|
||||||
sr.m_refCount = 1;
|
sr.m_refCount = 1;
|
||||||
@@ -4021,7 +4021,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
if (0 == refs)
|
if (0 == refs)
|
||||||
{
|
{
|
||||||
bool ok = m_submit->free(_handle); BX_UNUSED(ok);
|
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);
|
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyShader);
|
||||||
cmdbuf.write(_handle);
|
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;
|
const uint32_t key = uint32_t(_fsh.idx<<16)|_vsh.idx;
|
||||||
bool ok = m_programHashMap.insert(key, handle.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);
|
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateProgram);
|
||||||
cmdbuf.write(handle);
|
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);
|
const uint32_t key = uint32_t(_vsh.idx);
|
||||||
bool ok = m_programHashMap.insert(key, handle.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);
|
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateProgram);
|
||||||
cmdbuf.write(handle);
|
cmdbuf.write(handle);
|
||||||
@@ -4172,7 +4172,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
if (0 == refs)
|
if (0 == refs)
|
||||||
{
|
{
|
||||||
bool ok = m_submit->free(_handle); BX_UNUSED(ok);
|
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);
|
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyProgram);
|
||||||
cmdbuf.write(_handle);
|
cmdbuf.write(_handle);
|
||||||
@@ -4309,7 +4309,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
BGFX_CHECK_HANDLE("readTexture", m_textureHandle, _handle);
|
BGFX_CHECK_HANDLE("readTexture", m_textureHandle, _handle);
|
||||||
|
|
||||||
const TextureRef& ref = m_textureRef[_handle.idx];
|
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);
|
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::ReadTexture);
|
||||||
cmdbuf.write(_handle);
|
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)
|
void resizeTexture(TextureHandle _handle, uint16_t _width, uint16_t _height, uint8_t _numMips, uint16_t _numLayers)
|
||||||
{
|
{
|
||||||
const TextureRef& textureRef = m_textureRef[_handle.idx];
|
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);
|
getTextureSizeFromRatio(BackbufferRatio::Enum(textureRef.m_bbRatio), _width, _height);
|
||||||
_numMips = calcNumMips(1 < _numMips, _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);
|
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);
|
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyTexture);
|
||||||
cmdbuf.write(_handle);
|
cmdbuf.write(_handle);
|
||||||
@@ -4449,7 +4449,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
{
|
{
|
||||||
BGFX_MUTEX_SCOPE(m_resourceApiLock);
|
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)!"
|
, "Too many frame buffer attachments (num attachments: %d, max color attachments %d)!"
|
||||||
, _num
|
, _num
|
||||||
, g_caps.limits.maxFBAttachments
|
, g_caps.limits.maxFBAttachments
|
||||||
@@ -4473,7 +4473,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
{
|
{
|
||||||
TextureHandle texHandle = _attachment[ii].handle;
|
TextureHandle texHandle = _attachment[ii].handle;
|
||||||
BGFX_CHECK_HANDLE("createFrameBuffer texture", m_textureHandle, texHandle);
|
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);
|
BX_UNUSED(bbRatio);
|
||||||
|
|
||||||
ref.un.m_th[ii] = texHandle;
|
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);
|
BGFX_CHECK_HANDLE("destroyFrameBuffer", m_frameBufferHandle, _handle);
|
||||||
bool ok = m_submit->free(_handle); BX_UNUSED(ok);
|
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);
|
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::DestroyFrameBuffer);
|
||||||
cmdbuf.write(_handle);
|
cmdbuf.write(_handle);
|
||||||
@@ -4592,7 +4592,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
{
|
{
|
||||||
UniformHandle handle = { idx };
|
UniformHandle handle = { idx };
|
||||||
UniformRef& uniform = m_uniformRef[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)."
|
, "Uniform type mismatch (type: %d, expected %d)."
|
||||||
, _type
|
, _type
|
||||||
, uniform.m_type
|
, uniform.m_type
|
||||||
@@ -4637,7 +4637,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
uniform.m_num = _num;
|
uniform.m_num = _num;
|
||||||
|
|
||||||
bool ok = m_uniformHashMap.insert(bx::hash<bx::HashMurmur2A>(_name), handle.idx);
|
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);
|
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateUniform);
|
||||||
cmdbuf.write(handle);
|
cmdbuf.write(handle);
|
||||||
@@ -4669,13 +4669,13 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
BGFX_CHECK_HANDLE("destroyUniform", m_uniformHandle, _handle);
|
BGFX_CHECK_HANDLE("destroyUniform", m_uniformHandle, _handle);
|
||||||
|
|
||||||
UniformRef& uniform = m_uniformRef[_handle.idx];
|
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;
|
int32_t refs = --uniform.m_refCount;
|
||||||
|
|
||||||
if (0 == refs)
|
if (0 == refs)
|
||||||
{
|
{
|
||||||
bool ok = m_submit->free(_handle); BX_UNUSED(ok);
|
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();
|
uniform.m_name.clear();
|
||||||
m_uniformHashMap.removeByHandle(_handle.idx);
|
m_uniformHashMap.removeByHandle(_handle.idx);
|
||||||
@@ -4758,7 +4758,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
{
|
{
|
||||||
BGFX_MUTEX_SCOPE(m_resourceApiLock);
|
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
|
, _index
|
||||||
, BGFX_CONFIG_MAX_COLOR_PALETTE
|
, 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) )
|
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)."
|
, "Clear depth value must be between 0.0 and 1.0 (_depth %f)."
|
||||||
, _depth
|
, _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) )
|
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)."
|
, "Clear depth value must be between 0.0 and 1.0 (_depth %f)."
|
||||||
, _depth
|
, _depth
|
||||||
);
|
);
|
||||||
@@ -4912,7 +4912,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
|||||||
BGFX_PROFILER_SCOPE("bgfx/Render thread wait", 0xff2040ff);
|
BGFX_PROFILER_SCOPE("bgfx/Render thread wait", 0xff2040ff);
|
||||||
int64_t start = bx::getHPCounter();
|
int64_t start = bx::getHPCounter();
|
||||||
bool ok = m_renderSem.wait();
|
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_waitRender = bx::getHPCounter() - start;
|
||||||
m_submit->m_perfStats.waitRender = m_submit->m_waitRender;
|
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();
|
m_encoderHandle->reset();
|
||||||
uint16_t idx = m_encoderHandle->alloc();
|
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;
|
bx::Semaphore m_renderSem;
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ EGL_IMPORT
|
|||||||
BGFX_FATAL(m_surface != EGL_NO_SURFACE, Fatal::UnableToInitialize, "Failed to create surface.");
|
BGFX_FATAL(m_surface != EGL_NO_SURFACE, Fatal::UnableToInitialize, "Failed to create surface.");
|
||||||
|
|
||||||
m_context = eglCreateContext(m_display, _config, _context, s_contextAttrs);
|
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();
|
makeCurrent();
|
||||||
GL_CHECK(glClearColor(0.0f, 0.0f, 0.0f, 0.0f) );
|
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.
|
// will take the first canvas element found on the web page.
|
||||||
#define HTML5_TARGET_CANVAS_SELECTOR "#canvas"
|
#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
|
# else
|
||||||
BX_UNUSED(_width, _height);
|
BX_UNUSED(_width, _height);
|
||||||
# endif // BX_PLATFORM_*
|
# endif // BX_PLATFORM_*
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace bgfx { namespace gl
|
|||||||
|
|
||||||
void makeCurrent()
|
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()
|
void swapBuffers()
|
||||||
@@ -75,7 +75,7 @@ namespace bgfx { namespace gl
|
|||||||
m_primary = createSwapChain((void*)canvas);
|
m_primary = createSwapChain((void*)canvas);
|
||||||
|
|
||||||
if (_width && _height)
|
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);
|
makeCurrent(m_primary);
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ namespace bgfx { namespace gl
|
|||||||
return;
|
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)
|
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);
|
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = emscripten_webgl_create_context(canvas, &s_attrs);
|
||||||
if (context > 0)
|
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);
|
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);
|
BX_WARN(result, "SetPixelFormat failed (last err: 0x%08x)!", GetLastError() ); BX_UNUSED(result);
|
||||||
|
|
||||||
swapChain->m_context = wglCreateContextAttribsARB(swapChain->m_hdc, m_context, m_contextAttrs);
|
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;
|
return swapChain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -358,7 +358,7 @@ namespace bgfx
|
|||||||
#define NVA_CHECK(_call) \
|
#define NVA_CHECK(_call) \
|
||||||
BX_MACRO_BLOCK_BEGIN \
|
BX_MACRO_BLOCK_BEGIN \
|
||||||
int32_t __result__ = _call; \
|
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_UNUSED(__result__); \
|
||||||
BX_MACRO_BLOCK_END
|
BX_MACRO_BLOCK_END
|
||||||
|
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ namespace bgfx
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BX_CHECK(false, "predefined %d not handled", predefined.m_type);
|
BX_ASSERT(false, "predefined %d not handled", predefined.m_type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -304,7 +304,7 @@ namespace bgfx
|
|||||||
handle = m_alloc.alloc();
|
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& data = m_data[handle];
|
||||||
data.m_hash = _key;
|
data.m_hash = _key;
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ namespace bgfx
|
|||||||
#define _DX_CHECK(_call) \
|
#define _DX_CHECK(_call) \
|
||||||
BX_MACRO_BLOCK_BEGIN \
|
BX_MACRO_BLOCK_BEGIN \
|
||||||
HRESULT __hr__ = _call; \
|
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__ \
|
, (uint32_t)__hr__ \
|
||||||
DX_CHECK_EXTRA_ARGS \
|
DX_CHECK_EXTRA_ARGS \
|
||||||
); \
|
); \
|
||||||
@@ -92,7 +92,7 @@ namespace bgfx
|
|||||||
#define _DX_CHECK_REFCOUNT(_ptr, _expected) \
|
#define _DX_CHECK_REFCOUNT(_ptr, _expected) \
|
||||||
BX_MACRO_BLOCK_BEGIN \
|
BX_MACRO_BLOCK_BEGIN \
|
||||||
ULONG count = getRefCount(_ptr); \
|
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
|
BX_MACRO_BLOCK_END
|
||||||
|
|
||||||
#define _DX_NAME(_ptr, _format, ...) setDebugObjectName(_ptr, _format, ##__VA_ARGS__)
|
#define _DX_NAME(_ptr, _format, ...) setDebugObjectName(_ptr, _format, ##__VA_ARGS__)
|
||||||
@@ -111,7 +111,7 @@ namespace bgfx
|
|||||||
# define DX_NAME(_ptr, _format, ...)
|
# define DX_NAME(_ptr, _format, ...)
|
||||||
#endif // BGFX_CONFIG_DEBUG_OBJECT_NAME
|
#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_W(_ptr, _expected) _DX_RELEASE(_ptr, _expected, BX_WARN)
|
||||||
#define DX_RELEASE_I(_ptr) _DX_RELEASE(_ptr, 0, BX_NOOP)
|
#define DX_RELEASE_I(_ptr) _DX_RELEASE(_ptr, 0, BX_NOOP)
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ namespace bgfx
|
|||||||
{
|
{
|
||||||
invalidate(_key);
|
invalidate(_key);
|
||||||
m_hashMap.insert(stl::make_pair(_key, _value) );
|
m_hashMap.insert(stl::make_pair(_key, _value) );
|
||||||
BX_CHECK(isGraphicsDebuggerPresent()
|
BX_ASSERT(isGraphicsDebuggerPresent()
|
||||||
|| 1 == getRefCount(_value), "Interface ref count %d, hash %" PRIx64 "."
|
|| 1 == getRefCount(_value), "Interface ref count %d, hash %" PRIx64 "."
|
||||||
, getRefCount(_value)
|
, getRefCount(_value)
|
||||||
, _key
|
, _key
|
||||||
|
|||||||
@@ -2051,7 +2051,7 @@ namespace bgfx { namespace d3d11
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BX_CHECK(false, "Invalid handle type?! %d", _handle.type);
|
BX_ASSERT(false, "Invalid handle type?! %d", _handle.type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3753,7 +3753,7 @@ namespace bgfx { namespace d3d11
|
|||||||
void BufferD3D11::update(uint32_t _offset, uint32_t _size, void* _data, bool _discard)
|
void BufferD3D11::update(uint32_t _offset, uint32_t _size, void* _data, bool _discard)
|
||||||
{
|
{
|
||||||
ID3D11DeviceContext* deviceCtx = s_renderD3D11->m_deviceCtx;
|
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
|
#if USE_D3D11_STAGING_BUFFER
|
||||||
BX_UNUSED(_discard);
|
BX_UNUSED(_discard);
|
||||||
@@ -4775,7 +4775,7 @@ namespace bgfx { namespace d3d11
|
|||||||
|
|
||||||
if (bimg::isDepth(bimg::TextureFormat::Enum(texture.m_textureFormat) ) )
|
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;
|
D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc;
|
||||||
dsvDesc.Format = s_textureFormat[texture.m_textureFormat].m_fmtDsv;
|
dsvDesc.Format = s_textureFormat[texture.m_textureFormat].m_fmtDsv;
|
||||||
@@ -5278,7 +5278,7 @@ namespace bgfx { namespace d3d11
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool depthStencil = bimg::isDepth(bimg::TextureFormat::Enum(src.m_textureFormat) );
|
bool depthStencil = bimg::isDepth(bimg::TextureFormat::Enum(src.m_textureFormat) );
|
||||||
BX_CHECK(!depthStencil
|
BX_ASSERT(!depthStencil
|
||||||
|| (width == src.m_width && height == src.m_height)
|
|| (width == src.m_width && height == src.m_height)
|
||||||
, "When blitting depthstencil surface, source resolution must match destination."
|
, "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)
|
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;
|
m_vsh = _vsh;
|
||||||
bx::memCopy(&m_predefined[0], _vsh->m_predefined, _vsh->m_numPredefined*sizeof(PredefinedUniform) );
|
bx::memCopy(&m_predefined[0], _vsh->m_predefined, _vsh->m_numPredefined*sizeof(PredefinedUniform) );
|
||||||
m_numPredefined = _vsh->m_numPredefined;
|
m_numPredefined = _vsh->m_numPredefined;
|
||||||
|
|
||||||
if (NULL != _fsh)
|
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;
|
m_fsh = _fsh;
|
||||||
bx::memCopy(&m_predefined[m_numPredefined], _fsh->m_predefined, _fsh->m_numPredefined*sizeof(PredefinedUniform) );
|
bx::memCopy(&m_predefined[m_numPredefined], _fsh->m_predefined, _fsh->m_numPredefined*sizeof(PredefinedUniform) );
|
||||||
m_numPredefined += _fsh->m_numPredefined;
|
m_numPredefined += _fsh->m_numPredefined;
|
||||||
|
|||||||
@@ -1918,7 +1918,7 @@ namespace bgfx { namespace d3d12
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BX_CHECK(false, "Invalid handle type?! %d", _handle.type);
|
BX_ASSERT(false, "Invalid handle type?! %d", _handle.type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2105,7 +2105,7 @@ namespace bgfx { namespace d3d12
|
|||||||
{
|
{
|
||||||
ID3D12Resource* resource = m_backBufferColor[ii];
|
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;
|
const uint32_t size = m_scd.width*m_scd.height*4;
|
||||||
|
|
||||||
void* ptr;
|
void* ptr;
|
||||||
@@ -2912,7 +2912,7 @@ namespace bgfx { namespace d3d12
|
|||||||
dxbcHash(temp->data + 20, size - 20, temp->data + 4);
|
dxbcHash(temp->data + 20, size - 20, temp->data + 4);
|
||||||
|
|
||||||
patchShader = 0 == bx::memCmp(program.m_fsh->m_code->data, temp->data, 16);
|
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)
|
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)
|
bool CommandQueueD3D12::tryFinish(uint64_t _waitFence)
|
||||||
@@ -3960,7 +3960,7 @@ namespace bgfx { namespace d3d12
|
|||||||
Ty& BatchD3D12::getCmd(Enum _type)
|
Ty& BatchD3D12::getCmd(Enum _type)
|
||||||
{
|
{
|
||||||
uint32_t index = m_num[_type];
|
uint32_t index = m_num[_type];
|
||||||
BX_CHECK(index < m_maxDrawPerBatch, "Memory corruption...");
|
BX_ASSERT(index < m_maxDrawPerBatch, "Memory corruption...");
|
||||||
m_num[_type]++;
|
m_num[_type]++;
|
||||||
Ty* cmd = &reinterpret_cast<Ty*>(m_cmds[_type])[index];
|
Ty* cmd = &reinterpret_cast<Ty*>(m_cmds[_type])[index];
|
||||||
return *cmd;
|
return *cmd;
|
||||||
@@ -4953,7 +4953,7 @@ namespace bgfx { namespace d3d12
|
|||||||
, numSrd
|
, numSrd
|
||||||
, srd
|
, 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);
|
BX_TRACE("Update subresource %" PRId64, result);
|
||||||
|
|
||||||
setState(commandList, state);
|
setState(commandList, state);
|
||||||
@@ -5216,7 +5216,7 @@ namespace bgfx { namespace d3d12
|
|||||||
|
|
||||||
if (bimg::isDepth(bimg::TextureFormat::Enum(texture.m_textureFormat) ) )
|
if (bimg::isDepth(bimg::TextureFormat::Enum(texture.m_textureFormat) ) )
|
||||||
{
|
{
|
||||||
BX_CHECK(!isValid(m_depth), "");
|
BX_ASSERT(!isValid(m_depth), "");
|
||||||
m_depth = at.handle;
|
m_depth = at.handle;
|
||||||
D3D12_CPU_DESCRIPTOR_HANDLE dsvDescriptor = getCPUHandleHeapStart(s_renderD3D12->m_dsvDescriptorHeap);
|
D3D12_CPU_DESCRIPTOR_HANDLE dsvDescriptor = getCPUHandleHeapStart(s_renderD3D12->m_dsvDescriptorHeap);
|
||||||
uint32_t dsvDescriptorSize = device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_DSV);
|
uint32_t dsvDescriptorSize = device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_DSV);
|
||||||
@@ -5367,7 +5367,7 @@ namespace bgfx { namespace d3d12
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BX_CHECK(false, "");
|
BX_ASSERT(false, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -282,14 +282,14 @@ namespace bgfx { namespace d3d12
|
|||||||
|
|
||||||
void create(const ShaderD3D12* _vsh, const ShaderD3D12* _fsh)
|
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;
|
m_vsh = _vsh;
|
||||||
bx::memCopy(&m_predefined[0], _vsh->m_predefined, _vsh->m_numPredefined*sizeof(PredefinedUniform));
|
bx::memCopy(&m_predefined[0], _vsh->m_predefined, _vsh->m_numPredefined*sizeof(PredefinedUniform));
|
||||||
m_numPredefined = _vsh->m_numPredefined;
|
m_numPredefined = _vsh->m_numPredefined;
|
||||||
|
|
||||||
if (NULL != _fsh)
|
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;
|
m_fsh = _fsh;
|
||||||
bx::memCopy(&m_predefined[m_numPredefined], _fsh->m_predefined, _fsh->m_numPredefined*sizeof(PredefinedUniform));
|
bx::memCopy(&m_predefined[m_numPredefined], _fsh->m_predefined, _fsh->m_numPredefined*sizeof(PredefinedUniform));
|
||||||
m_numPredefined += _fsh->m_numPredefined;
|
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])
|
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);
|
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)
|
if (m_samplerFlags[_stage] != flags)
|
||||||
{
|
{
|
||||||
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;
|
_pitch = 0;
|
||||||
_slicePitch = 0;
|
_slicePitch = 0;
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -2843,7 +2843,7 @@ namespace bgfx { namespace d3d9
|
|||||||
return;
|
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)
|
void TextureD3D9::dirty(uint8_t _side, const Rect& _rect, uint16_t _z, uint16_t _depth)
|
||||||
@@ -2886,7 +2886,7 @@ namespace bgfx { namespace d3d9
|
|||||||
return;
|
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
|
IDirect3DSurface9* TextureD3D9::getSurface(uint8_t _side, uint8_t _mip) const
|
||||||
@@ -2900,7 +2900,7 @@ namespace bgfx { namespace d3d9
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Texture3D:
|
case Texture3D:
|
||||||
BX_CHECK(false, "");
|
BX_ASSERT(false, "");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TextureCube:
|
case TextureCube:
|
||||||
@@ -3416,7 +3416,7 @@ namespace bgfx { namespace d3d9
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BX_CHECK(false, "");
|
BX_ASSERT(false, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3812,7 +3812,7 @@ namespace bgfx { namespace d3d9
|
|||||||
|
|
||||||
if (isCompute)
|
if (isCompute)
|
||||||
{
|
{
|
||||||
BX_CHECK(false, "Compute is not supported on DirectX 9.");
|
BX_ASSERT(false, "Compute is not supported on DirectX 9.");
|
||||||
continue;
|
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.
|
// 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();
|
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_get_current_context();
|
||||||
EmscriptenWebGLContextAttributes attrs;
|
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;
|
int glesVersion = attrs.majorVersion + 1;
|
||||||
switch(_format)
|
switch(_format)
|
||||||
{
|
{
|
||||||
@@ -3400,7 +3400,7 @@ namespace bgfx { namespace gl
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BX_CHECK(false, "Invalid handle type?! %d", _handle.type);
|
BX_ASSERT(false, "Invalid handle type?! %d", _handle.type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3658,7 +3658,7 @@ namespace bgfx { namespace gl
|
|||||||
;
|
;
|
||||||
GL_CHECK(glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, m_msaaBackBufferRbos[1]) );
|
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 failed 0x%08x"
|
||||||
, glCheckFramebufferStatus(GL_FRAMEBUFFER)
|
, glCheckFramebufferStatus(GL_FRAMEBUFFER)
|
||||||
);
|
);
|
||||||
@@ -4412,7 +4412,7 @@ namespace bgfx { namespace gl
|
|||||||
static void frameBufferValidate()
|
static void frameBufferValidate()
|
||||||
{
|
{
|
||||||
GLenum complete = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
GLenum complete = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||||
BX_CHECK(GL_FRAMEBUFFER_COMPLETE == complete
|
BX_ASSERT(GL_FRAMEBUFFER_COMPLETE == complete
|
||||||
, "glCheckFramebufferStatus failed 0x%08x: %s"
|
, "glCheckFramebufferStatus failed 0x%08x: %s"
|
||||||
, complete
|
, complete
|
||||||
, glEnumName(complete)
|
, glEnumName(complete)
|
||||||
@@ -4486,7 +4486,7 @@ namespace bgfx { namespace gl
|
|||||||
|
|
||||||
#undef GLSL_TYPE
|
#undef GLSL_TYPE
|
||||||
|
|
||||||
BX_CHECK(false, "Unknown GLSL type? %x", _type);
|
BX_ASSERT(false, "Unknown GLSL type? %x", _type);
|
||||||
return "UNKNOWN GLSL TYPE!";
|
return "UNKNOWN GLSL TYPE!";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4583,7 +4583,7 @@ namespace bgfx { namespace gl
|
|||||||
return UniformType::Sampler;
|
return UniformType::Sampler;
|
||||||
};
|
};
|
||||||
|
|
||||||
BX_CHECK(false, "Unrecognized GL type 0x%04x.", _type);
|
BX_ASSERT(false, "Unrecognized GL type 0x%04x.", _type);
|
||||||
return UniformType::End;
|
return UniformType::End;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4946,7 +4946,7 @@ namespace bgfx { namespace gl
|
|||||||
m_used[used++] = ii;
|
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;
|
m_usedCount = (uint8_t)used;
|
||||||
|
|
||||||
used = 0;
|
used = 0;
|
||||||
@@ -4959,7 +4959,7 @@ namespace bgfx { namespace gl
|
|||||||
m_instanceData[used++] = loc;
|
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
|
, used
|
||||||
, BX_COUNTOF(m_instanceData)
|
, BX_COUNTOF(m_instanceData)
|
||||||
);
|
);
|
||||||
@@ -5085,7 +5085,7 @@ namespace bgfx { namespace gl
|
|||||||
if (!writeOnly)
|
if (!writeOnly)
|
||||||
{
|
{
|
||||||
GL_CHECK(glGenTextures(1, &m_id) );
|
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(glBindTexture(_target, m_id) );
|
||||||
GL_CHECK(glPixelStorei(GL_UNPACK_ALIGNMENT, 1) );
|
GL_CHECK(glPixelStorei(GL_UNPACK_ALIGNMENT, 1) );
|
||||||
|
|
||||||
@@ -5180,7 +5180,7 @@ namespace bgfx { namespace gl
|
|||||||
&& (0 != msaaQuality || writeOnly) )
|
&& (0 != msaaQuality || writeOnly) )
|
||||||
{
|
{
|
||||||
GL_CHECK(glGenRenderbuffers(1, &m_rbo) );
|
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) );
|
GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, m_rbo) );
|
||||||
|
|
||||||
if (0 == msaaQuality)
|
if (0 == msaaQuality)
|
||||||
|
|||||||
@@ -1119,7 +1119,7 @@ namespace bgfx { namespace gl
|
|||||||
#define IGNORE_GL_ERROR_CHECK(...) BX_NOOP()
|
#define IGNORE_GL_ERROR_CHECK(...) BX_NOOP()
|
||||||
|
|
||||||
#if BGFX_CONFIG_DEBUG
|
#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)
|
# define GL_CHECK_I(_call) _GL_CHECK(IGNORE_GL_ERROR_CHECK, _call)
|
||||||
#else
|
#else
|
||||||
# define GL_CHECK(_call) _call
|
# define GL_CHECK(_call) _call
|
||||||
@@ -1275,7 +1275,7 @@ namespace bgfx { namespace gl
|
|||||||
m_flags = _flags;
|
m_flags = _flags;
|
||||||
|
|
||||||
GL_CHECK(glGenBuffers(1, &m_id) );
|
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(glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_id) );
|
||||||
GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER
|
GL_CHECK(glBufferData(GL_ELEMENT_ARRAY_BUFFER
|
||||||
, _size
|
, _size
|
||||||
@@ -1287,7 +1287,7 @@ namespace bgfx { namespace gl
|
|||||||
|
|
||||||
void update(uint32_t _offset, uint32_t _size, void* _data, bool _discard = false)
|
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)
|
if (_discard)
|
||||||
{
|
{
|
||||||
@@ -1323,7 +1323,7 @@ namespace bgfx { namespace gl
|
|||||||
m_target = drawIndirect ? GL_DRAW_INDIRECT_BUFFER : GL_ARRAY_BUFFER;
|
m_target = drawIndirect ? GL_DRAW_INDIRECT_BUFFER : GL_ARRAY_BUFFER;
|
||||||
|
|
||||||
GL_CHECK(glGenBuffers(1, &m_id) );
|
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(glBindBuffer(m_target, m_id) );
|
||||||
GL_CHECK(glBufferData(m_target
|
GL_CHECK(glBufferData(m_target
|
||||||
, _size
|
, _size
|
||||||
@@ -1335,7 +1335,7 @@ namespace bgfx { namespace gl
|
|||||||
|
|
||||||
void update(uint32_t _offset, uint32_t _size, void* _data, bool _discard = false)
|
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)
|
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)
|
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_UNDEFINED
|
||||||
&& _newLayout != VK_IMAGE_LAYOUT_PREINITIALIZED
|
&& _newLayout != VK_IMAGE_LAYOUT_PREINITIALIZED
|
||||||
, "_newLayout cannot use VK_IMAGE_LAYOUT_UNDEFINED or 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");
|
BX_WARN(surfaceFormatSrgbIdx < numSurfaceFormats, "Cannot find preferred sRGB surface format from supported surface formats");
|
||||||
|
|
||||||
m_backBufferColorFormat = surfaceFormats[surfaceFormatIdx];
|
m_backBufferColorFormat = surfaceFormats[surfaceFormatIdx];
|
||||||
@@ -2681,7 +2681,7 @@ VK_IMPORT_DEVICE
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BX_CHECK(false, "Invalid handle type?! %d", _handle.type);
|
BX_ASSERT(false, "Invalid handle type?! %d", _handle.type);
|
||||||
break;
|
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 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);
|
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].uniformHandle = info->m_handle;
|
||||||
m_bindInfo[stage].type = BindType::Sampler;
|
m_bindInfo[stage].type = BindType::Sampler;
|
||||||
@@ -4861,7 +4861,7 @@ VK_DESTROY
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
const UniformRegInfo* info = s_renderVK->m_uniformReg.find(name);
|
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)
|
if (NULL != info)
|
||||||
{
|
{
|
||||||
@@ -5036,7 +5036,7 @@ VK_DESTROY
|
|||||||
|
|
||||||
void ProgramVK::create(const ShaderVK* _vsh, const ShaderVK* _fsh)
|
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;
|
m_vsh = _vsh;
|
||||||
bx::memCopy(
|
bx::memCopy(
|
||||||
&m_predefined[0]
|
&m_predefined[0]
|
||||||
@@ -5047,7 +5047,7 @@ VK_DESTROY
|
|||||||
|
|
||||||
if (NULL != _fsh)
|
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;
|
m_fsh = _fsh;
|
||||||
bx::memCopy(
|
bx::memCopy(
|
||||||
&m_predefined[m_numPredefined]
|
&m_predefined[m_numPredefined]
|
||||||
|
|||||||
@@ -223,7 +223,7 @@
|
|||||||
BX_MACRO_BLOCK_END
|
BX_MACRO_BLOCK_END
|
||||||
|
|
||||||
#if BGFX_CONFIG_DEBUG
|
#if BGFX_CONFIG_DEBUG
|
||||||
# define VK_CHECK(_call) _VK_CHECK(BX_CHECK, _call)
|
# define VK_CHECK(_call) _VK_CHECK(BX_ASSERT, _call)
|
||||||
#else
|
#else
|
||||||
# define VK_CHECK(_call) _call
|
# define VK_CHECK(_call) _call
|
||||||
#endif // BGFX_CONFIG_DEBUG
|
#endif // BGFX_CONFIG_DEBUG
|
||||||
|
|||||||
@@ -511,7 +511,7 @@ namespace bgfx { namespace webgpu
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BX_CHECK(false, "Device error: %s", message);
|
BX_ASSERT(false, "Device error: %s", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
s_ignoreError = false;
|
s_ignoreError = false;
|
||||||
@@ -828,7 +828,7 @@ namespace bgfx { namespace webgpu
|
|||||||
if (readback.m_mapped)
|
if (readback.m_mapped)
|
||||||
return;
|
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 srcWidth = bx::uint32_max(1, texture.m_width >> readback.m_mip);
|
||||||
uint32_t srcHeight = bx::uint32_max(1, texture.m_height >> 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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BX_CHECK(false, "Invalid handle type?! %d", _handle.type);
|
BX_ASSERT(false, "Invalid handle type?! %d", _handle.type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1152,11 +1152,11 @@ namespace bgfx { namespace webgpu
|
|||||||
uint8_t flags = predefined.m_type;
|
uint8_t flags = predefined.m_type;
|
||||||
setShaderUniform(flags, predefined.m_loc, proj, 4);
|
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 voffset = scratchBuffer.write(m_vsScratch, program.m_vsh->m_gpuSize);
|
||||||
|
|
||||||
const uint32_t fsize = (NULL != program.m_fsh ? program.m_fsh->m_gpuSize : 0);
|
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];
|
TextureWgpu& texture = m_textures[_blitter.m_texture.idx];
|
||||||
|
|
||||||
@@ -1323,7 +1323,7 @@ namespace bgfx { namespace webgpu
|
|||||||
template <class Encoder>
|
template <class Encoder>
|
||||||
void bindProgram(Encoder& encoder, const ProgramWgpu& program, BindStateWgpu& bindState, uint32_t numOffset, uint32_t* offsets)
|
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);
|
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);
|
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)
|
if (kInvalidHandle != bind.m_idx)
|
||||||
{
|
{
|
||||||
@@ -2484,7 +2484,7 @@ namespace bgfx { namespace webgpu
|
|||||||
const bool fragment = isShaderType(magic, 'F');
|
const bool fragment = isShaderType(magic, 'F');
|
||||||
uint8_t fragmentBit = fragment ? BGFX_UNIFORM_FRAGMENTBIT : 0;
|
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)
|
if (0 < count)
|
||||||
{
|
{
|
||||||
@@ -2562,7 +2562,7 @@ namespace bgfx { namespace webgpu
|
|||||||
else if (UniformType::Sampler == (~BGFX_UNIFORM_MASK & type))
|
else if (UniformType::Sampler == (~BGFX_UNIFORM_MASK & type))
|
||||||
{
|
{
|
||||||
const UniformRegInfo* info = s_renderWgpu->m_uniformReg.find(name);
|
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);
|
const uint8_t stage = regIndex - 16 - (fragment ? 48 : 0);
|
||||||
|
|
||||||
@@ -2593,7 +2593,7 @@ namespace bgfx { namespace webgpu
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
const UniformRegInfo* info = s_renderWgpu->m_uniformReg.find(name);
|
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)
|
if(NULL == m_constantBuffer)
|
||||||
{
|
{
|
||||||
@@ -2722,19 +2722,19 @@ namespace bgfx { namespace webgpu
|
|||||||
|
|
||||||
void ProgramWgpu::create(const ShaderWgpu* _vsh, const ShaderWgpu* _fsh)
|
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_vsh = _vsh;
|
||||||
m_fsh = _fsh;
|
m_fsh = _fsh;
|
||||||
m_gpuSize = _vsh->m_gpuSize + (_fsh ? _fsh->m_gpuSize : 0);
|
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;
|
m_vsh = _vsh;
|
||||||
bx::memCopy(&m_predefined[0], _vsh->m_predefined, _vsh->m_numPredefined * sizeof(PredefinedUniform));
|
bx::memCopy(&m_predefined[0], _vsh->m_predefined, _vsh->m_numPredefined * sizeof(PredefinedUniform));
|
||||||
m_numPredefined = _vsh->m_numPredefined;
|
m_numPredefined = _vsh->m_numPredefined;
|
||||||
|
|
||||||
if(NULL != _fsh)
|
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;
|
m_fsh = _fsh;
|
||||||
bx::memCopy(&m_predefined[m_numPredefined], _fsh->m_predefined, _fsh->m_numPredefined * sizeof(PredefinedUniform));
|
bx::memCopy(&m_predefined[m_numPredefined], _fsh->m_predefined, _fsh->m_numPredefined * sizeof(PredefinedUniform));
|
||||||
m_numPredefined += _fsh->m_numPredefined;
|
m_numPredefined += _fsh->m_numPredefined;
|
||||||
@@ -2810,7 +2810,7 @@ namespace bgfx { namespace webgpu
|
|||||||
|
|
||||||
m_numBuffers = _vsh->m_numBuffers;
|
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;
|
wgpu::BindGroupLayoutDescriptor bindGroupDesc;
|
||||||
bindGroupDesc.entryCount = numBindings;
|
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)
|
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_ASSERT(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(m_size > m_offset + _offset, "Out-of-bounds scratch buffer write");
|
||||||
uint32_t offset = m_offset;
|
uint32_t offset = m_offset;
|
||||||
bx::memCopy((void*)((uint8_t*)m_staging->m_data + offset), data, _size);
|
bx::memCopy((void*)((uint8_t*)m_staging->m_data + offset), data, _size);
|
||||||
m_offset += _offset;
|
m_offset += _offset;
|
||||||
@@ -3475,8 +3475,8 @@ namespace bgfx { namespace webgpu
|
|||||||
|
|
||||||
uint32_t ScratchBufferWgpu::write(void* data, uint64_t _size)
|
uint32_t ScratchBufferWgpu::write(void* data, uint64_t _size)
|
||||||
{
|
{
|
||||||
BX_CHECK(nullptr != m_staging, "Cannot write uniforms outside of begin()/submit() calls");
|
BX_ASSERT(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(m_size > m_offset + _size, "Out-of-bounds scratch buffer write");
|
||||||
uint32_t offset = m_offset;
|
uint32_t offset = m_offset;
|
||||||
bx::memCopy((void*)((uint8_t*)m_staging->m_data + offset), data, _size);
|
bx::memCopy((void*)((uint8_t*)m_staging->m_data + offset), data, _size);
|
||||||
m_offset += _size;
|
m_offset += _size;
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ namespace bgfx
|
|||||||
|
|
||||||
const char* getName(Dx9bcOpcode::Enum _opcode)
|
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];
|
return s_dx9bcOpcode[_opcode];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -458,7 +458,7 @@ namespace bgfx
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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)
|
, getName(_instruction.opcode)
|
||||||
, _instruction.numOperands
|
, _instruction.numOperands
|
||||||
, info.numValues
|
, info.numValues
|
||||||
@@ -642,7 +642,7 @@ namespace bgfx
|
|||||||
char temp[512];
|
char temp[512];
|
||||||
toString(temp, 512, instruction);
|
toString(temp, 512, instruction);
|
||||||
|
|
||||||
BX_CHECK(length/4 == instruction.length
|
BX_ASSERT(length/4 == instruction.length
|
||||||
, "%s\nread %d, expected %d"
|
, "%s\nread %d, expected %d"
|
||||||
, temp
|
, temp
|
||||||
, length/4
|
, length/4
|
||||||
@@ -712,7 +712,7 @@ namespace bgfx
|
|||||||
{
|
{
|
||||||
Dx9bcInstruction instruction;
|
Dx9bcInstruction instruction;
|
||||||
uint32_t size = read(&reader, instruction, _err);
|
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);
|
bool cont = _fn(token * sizeof(uint32_t), instruction, _userData);
|
||||||
if (!cont)
|
if (!cont)
|
||||||
@@ -737,7 +737,7 @@ namespace bgfx
|
|||||||
{
|
{
|
||||||
Dx9bcInstruction instruction;
|
Dx9bcInstruction instruction;
|
||||||
uint32_t size = read(&reader, instruction, _err);
|
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);
|
_fn(instruction, _userData);
|
||||||
|
|
||||||
|
|||||||
@@ -468,7 +468,7 @@ namespace bgfx
|
|||||||
|
|
||||||
const char* getName(DxbcOpcode::Enum _opcode)
|
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];
|
return s_dxbcOpcode[_opcode];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -825,7 +825,7 @@ namespace bgfx
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BX_CHECK(false, "sub operand addressing mode %d", _subOperand.addrMode);
|
BX_ASSERT(false, "sub operand addressing mode %d", _subOperand.addrMode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -878,7 +878,7 @@ namespace bgfx
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BX_CHECK(false, "sub operand addressing mode %d", _subOperand.addrMode);
|
BX_ASSERT(false, "sub operand addressing mode %d", _subOperand.addrMode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -967,7 +967,7 @@ namespace bgfx
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1042,7 +1042,7 @@ namespace bgfx
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1065,7 +1065,7 @@ namespace bgfx
|
|||||||
// +-------------------------------- extended
|
// +-------------------------------- extended
|
||||||
|
|
||||||
_instruction.opcode = DxbcOpcode::Enum( (token & UINT32_C(0x000007ff) ) );
|
_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);
|
_instruction.length = uint8_t( (token & UINT32_C(0x7f000000) ) >> 24);
|
||||||
bool extended = 0 != (token & UINT32_C(0x80000000) );
|
bool extended = 0 != (token & UINT32_C(0x80000000) );
|
||||||
@@ -1299,7 +1299,7 @@ namespace bgfx
|
|||||||
uint32_t num;
|
uint32_t num;
|
||||||
size += read(_reader, num, _err);
|
size += read(_reader, num, _err);
|
||||||
|
|
||||||
BX_CHECK(false, "not implemented.");
|
BX_ASSERT(false, "not implemented.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1327,7 +1327,7 @@ namespace bgfx
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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)
|
, getName(_instruction.opcode)
|
||||||
, info.numOperands
|
, info.numOperands
|
||||||
, info.numValues
|
, info.numValues
|
||||||
@@ -1914,7 +1914,7 @@ namespace bgfx
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
size += chunkSize;
|
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)[0]
|
||||||
, ( (char*)&fourcc)[1]
|
, ( (char*)&fourcc)[1]
|
||||||
, ( (char*)&fourcc)[2]
|
, ( (char*)&fourcc)[2]
|
||||||
@@ -2001,7 +2001,7 @@ namespace bgfx
|
|||||||
{
|
{
|
||||||
DxbcInstruction instruction;
|
DxbcInstruction instruction;
|
||||||
uint32_t size = read(&reader, instruction, _err);
|
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);
|
bool cont = _fn(token * sizeof(uint32_t), instruction, _userData);
|
||||||
if (!cont)
|
if (!cont)
|
||||||
@@ -2028,7 +2028,7 @@ namespace bgfx
|
|||||||
{
|
{
|
||||||
DxbcInstruction instruction;
|
DxbcInstruction instruction;
|
||||||
uint32_t size = read(&reader, instruction, _err);
|
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);
|
_fn(instruction, _userData);
|
||||||
|
|
||||||
|
|||||||
@@ -809,7 +809,7 @@ namespace bgfx
|
|||||||
const char* getName(SpvDecoration::Enum _enum)
|
const char* getName(SpvDecoration::Enum _enum)
|
||||||
{
|
{
|
||||||
BX_UNUSED(s_spvDecorationInfo);
|
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
|
return _enum <= SpvDecoration::Count
|
||||||
? s_spvDecoration[_enum]
|
? s_spvDecoration[_enum]
|
||||||
: "?SpvDecoration?"
|
: "?SpvDecoration?"
|
||||||
@@ -839,7 +839,7 @@ namespace bgfx
|
|||||||
|
|
||||||
const char* getName(SpvStorageClass::Enum _enum)
|
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
|
return _enum <= SpvStorageClass::Count
|
||||||
? s_spvStorageClass[_enum]
|
? s_spvStorageClass[_enum]
|
||||||
: "?SpvStorageClass?"
|
: "?SpvStorageClass?"
|
||||||
@@ -895,7 +895,7 @@ namespace bgfx
|
|||||||
|
|
||||||
const char* getName(SpvBuiltin::Enum _enum)
|
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
|
return _enum <= SpvBuiltin::Count
|
||||||
? s_spvBuiltin[_enum]
|
? s_spvBuiltin[_enum]
|
||||||
: "?SpvBuiltin?"
|
: "?SpvBuiltin?"
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ namespace bgfx
|
|||||||
if (i0 > i1) { bx::swap(i0, i1); }
|
if (i0 > i1) { bx::swap(i0, i1); }
|
||||||
if (i1 > i2) { bx::swap(i1, i2); }
|
if (i1 > i2) { bx::swap(i1, i2); }
|
||||||
if (i0 > i1) { bx::swap(i0, i1); }
|
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[1] = i0; dst[0] = i1;
|
||||||
dst[3] = i1; dst[2] = i2;
|
dst[3] = i1; dst[2] = i2;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace stl = tinystl;
|
|||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
# define BX_CHECK(_condition, _format, ...) \
|
# define BX_ASSERT(_condition, _format, ...) \
|
||||||
do { \
|
do { \
|
||||||
if (!(_condition) ) \
|
if (!(_condition) ) \
|
||||||
{ \
|
{ \
|
||||||
@@ -741,7 +741,7 @@ void processGltfNode(cgltf_node* _node, Mesh* _mesh, Group* _group, bool _hasBc)
|
|||||||
cgltf_accessor* accessor = attribute->data;
|
cgltf_accessor* accessor = attribute->data;
|
||||||
cgltf_size accessorCount = accessor->count;
|
cgltf_size accessorCount = accessor->count;
|
||||||
|
|
||||||
BX_CHECK(numVertex == accessorCount, "Invalid attribute count");
|
BX_ASSERT(numVertex == accessorCount, "Invalid attribute count");
|
||||||
|
|
||||||
cgltf_size floatCount = cgltf_accessor_unpack_floats(accessor, NULL, 0);
|
cgltf_size floatCount = cgltf_accessor_unpack_floats(accessor, NULL, 0);
|
||||||
float* accessorData = (float*)malloc(floatCount * sizeof(float));
|
float* accessorData = (float*)malloc(floatCount * sizeof(float));
|
||||||
@@ -1395,7 +1395,7 @@ int main(int _argc, const char* _argv[])
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
BX_CHECK(0 == primitives.size(), "Not all primitives are written");
|
BX_ASSERT(0 == primitives.size(), "Not all primitives are written");
|
||||||
|
|
||||||
bx::printf("size: %d\n", uint32_t(bx::seek(&writer) ) );
|
bx::printf("size: %d\n", uint32_t(bx::seek(&writer) ) );
|
||||||
bx::close(&writer);
|
bx::close(&writer);
|
||||||
|
|||||||
@@ -509,7 +509,7 @@ namespace bgfx
|
|||||||
}
|
}
|
||||||
replace[len] = '\0';
|
replace[len] = '\0';
|
||||||
|
|
||||||
BX_CHECK(len >= bx::strLen(_replace), "");
|
BX_ASSERT(len >= bx::strLen(_replace), "");
|
||||||
for (bx::StringView ptr = bx::strFind(_str, _find)
|
for (bx::StringView ptr = bx::strFind(_str, _find)
|
||||||
; !ptr.isEmpty()
|
; !ptr.isEmpty()
|
||||||
; ptr = bx::strFind(ptr.getPtr() + len, _find)
|
; ptr = bx::strFind(ptr.getPtr() + len, _find)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace bgfx
|
|||||||
} \
|
} \
|
||||||
BX_MACRO_BLOCK_END
|
BX_MACRO_BLOCK_END
|
||||||
|
|
||||||
#define _BX_CHECK(_condition, _format, ...) \
|
#define _BX_ASSERT(_condition, _format, ...) \
|
||||||
BX_MACRO_BLOCK_BEGIN \
|
BX_MACRO_BLOCK_BEGIN \
|
||||||
if (!(_condition) ) \
|
if (!(_condition) ) \
|
||||||
{ \
|
{ \
|
||||||
@@ -38,7 +38,7 @@ namespace bgfx
|
|||||||
|
|
||||||
#define BX_TRACE _BX_TRACE
|
#define BX_TRACE _BX_TRACE
|
||||||
#define BX_WARN _BX_WARN
|
#define BX_WARN _BX_WARN
|
||||||
#define BX_CHECK _BX_CHECK
|
#define BX_ASSERT _BX_ASSERT
|
||||||
|
|
||||||
#ifndef SHADERC_CONFIG_HLSL
|
#ifndef SHADERC_CONFIG_HLSL
|
||||||
# define SHADERC_CONFIG_HLSL BX_PLATFORM_WINDOWS
|
# define SHADERC_CONFIG_HLSL BX_PLATFORM_WINDOWS
|
||||||
|
|||||||
Reference in New Issue
Block a user