|
|
@@ -1973,14 +1973,16 @@ namespace bgfx
|
|
|
|
|
|
void setIndexBuffer(const TransientIndexBuffer* _tib, uint32_t _firstIndex, uint32_t _numIndices)
|
|
|
{
|
|
|
+ const uint32_t numIndices = bx::uint32_min(_numIndices, _tib->size/2);
|
|
|
m_draw.m_indexBuffer = _tib->handle;
|
|
|
- m_draw.m_startIndex = _firstIndex;
|
|
|
- m_draw.m_numIndices = _numIndices;
|
|
|
- m_discard = 0 == _numIndices;
|
|
|
+ m_draw.m_startIndex = _tib->startIndex + _firstIndex;
|
|
|
+ m_draw.m_numIndices = numIndices;
|
|
|
+ m_discard = 0 == numIndices;
|
|
|
}
|
|
|
|
|
|
void setVertexBuffer(uint8_t _stream, VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices)
|
|
|
{
|
|
|
+ BX_CHECK(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
|
|
|
if (m_draw.setStreamBit(_stream, _handle) )
|
|
|
{
|
|
|
Stream& stream = m_draw.m_stream[_stream];
|
|
|
@@ -1993,6 +1995,7 @@ namespace bgfx
|
|
|
|
|
|
void setVertexBuffer(uint8_t _stream, const DynamicVertexBuffer& _dvb, uint32_t _startVertex, uint32_t _numVertices)
|
|
|
{
|
|
|
+ BX_CHECK(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
|
|
|
if (m_draw.setStreamBit(_stream, _dvb.m_handle) )
|
|
|
{
|
|
|
Stream& stream = m_draw.m_stream[_stream];
|
|
|
@@ -2007,6 +2010,7 @@ namespace bgfx
|
|
|
|
|
|
void setVertexBuffer(uint8_t _stream, const TransientVertexBuffer* _tvb, uint32_t _startVertex, uint32_t _numVertices)
|
|
|
{
|
|
|
+ BX_CHECK(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
|
|
|
if (m_draw.setStreamBit(_stream, _tvb->handle) )
|
|
|
{
|
|
|
Stream& stream = m_draw.m_stream[_stream];
|
|
|
@@ -4182,21 +4186,18 @@ namespace bgfx
|
|
|
BGFX_API_FUNC(void setVertexBuffer(uint8_t _stream, VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices) )
|
|
|
{
|
|
|
BGFX_CHECK_HANDLE("setVertexBuffer", m_vertexBufferHandle, _handle);
|
|
|
- BX_CHECK(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
|
|
|
m_encoder[0].setVertexBuffer(_stream, _handle, _startVertex, _numVertices);
|
|
|
}
|
|
|
|
|
|
BGFX_API_FUNC(void setVertexBuffer(uint8_t _stream, DynamicVertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices) )
|
|
|
{
|
|
|
BGFX_CHECK_HANDLE("setVertexBuffer", m_dynamicVertexBufferHandle, _handle);
|
|
|
- BX_CHECK(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
|
|
|
m_encoder[0].setVertexBuffer(_stream, m_dynamicVertexBuffers[_handle.idx], _startVertex, _numVertices);
|
|
|
}
|
|
|
|
|
|
BGFX_API_FUNC(void setVertexBuffer(uint8_t _stream, const TransientVertexBuffer* _tvb, uint32_t _startVertex, uint32_t _numVertices) )
|
|
|
{
|
|
|
BGFX_CHECK_HANDLE("setVertexBuffer", m_vertexBufferHandle, _tvb->handle);
|
|
|
- BX_CHECK(_stream < BGFX_CONFIG_MAX_VERTEX_STREAMS, "Invalid stream %d (max %d).", _stream, BGFX_CONFIG_MAX_VERTEX_STREAMS);
|
|
|
m_encoder[0].setVertexBuffer(_stream, _tvb, _startVertex, _numVertices);
|
|
|
}
|
|
|
|
|
|
@@ -4278,7 +4279,10 @@ namespace bgfx
|
|
|
|
|
|
BGFX_API_FUNC(void setImage(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint8_t _mip, Access::Enum _access, TextureFormat::Enum _format) )
|
|
|
{
|
|
|
- _format = TextureFormat::Count == _format ? TextureFormat::Enum(m_textureRef[_handle.idx].m_format) : _format;
|
|
|
+ _format = TextureFormat::Count == _format
|
|
|
+ ? TextureFormat::Enum(m_textureRef[_handle.idx].m_format)
|
|
|
+ : _format
|
|
|
+ ;
|
|
|
BX_CHECK(_format != TextureFormat::BGRA8
|
|
|
, "Can't use TextureFormat::BGRA8 with compute, use TextureFormat::RGBA8 instead."
|
|
|
);
|