mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
Added ability to set offset in instance data buffer.
This commit is contained in:
@@ -284,7 +284,7 @@ public:
|
||||
}
|
||||
|
||||
// Set instance data buffer.
|
||||
bgfx::setInstanceDataBuffer(&idb, numInstances);
|
||||
bgfx::setInstanceDataBuffer(&idb, 0, numInstances);
|
||||
|
||||
// Set vertex and index buffer.
|
||||
bgfx::setVertexBuffer(0, m_vbh);
|
||||
|
||||
@@ -1164,13 +1164,23 @@ namespace bgfx
|
||||
/// Set instance data buffer for draw primitive.
|
||||
///
|
||||
/// @param[in] _idb Transient instance data buffer.
|
||||
///
|
||||
/// @attention C99 equivalent is `bgfx_set_instance_data_buffer`.
|
||||
///
|
||||
void setInstanceDataBuffer(const InstanceDataBuffer* _idb);
|
||||
|
||||
/// Set instance data buffer for draw primitive.
|
||||
///
|
||||
/// @param[in] _idb Transient instance data buffer.
|
||||
/// @param[in] _start First instance data.
|
||||
/// @param[in] _num Number of data instances.
|
||||
///
|
||||
/// @attention C99 equivalent is `bgfx_set_instance_data_buffer`.
|
||||
///
|
||||
void setInstanceDataBuffer(
|
||||
const InstanceDataBuffer* _idb
|
||||
, uint32_t _num = UINT32_MAX
|
||||
, uint32_t _start
|
||||
, uint32_t _num
|
||||
);
|
||||
|
||||
/// Set instance data buffer for draw primitive.
|
||||
@@ -3483,13 +3493,23 @@ namespace bgfx
|
||||
/// Set instance data buffer for draw primitive.
|
||||
///
|
||||
/// @param[in] _idb Transient instance data buffer.
|
||||
///
|
||||
/// @attention C99 equivalent is `bgfx_set_instance_data_buffer`.
|
||||
///
|
||||
void setInstanceDataBuffer(const InstanceDataBuffer* _idb);
|
||||
|
||||
/// Set instance data buffer for draw primitive.
|
||||
///
|
||||
/// @param[in] _idb Transient instance data buffer.
|
||||
/// @param[in] _start First instance data.
|
||||
/// @param[in] _num Number of data instances.
|
||||
///
|
||||
/// @attention C99 equivalent is `bgfx_set_instance_data_buffer`.
|
||||
///
|
||||
void setInstanceDataBuffer(
|
||||
const InstanceDataBuffer* _idb
|
||||
, uint32_t _num = UINT32_MAX
|
||||
, uint32_t _start
|
||||
, uint32_t _num
|
||||
);
|
||||
|
||||
/// Set instance data buffer for draw primitive.
|
||||
|
||||
@@ -930,7 +930,7 @@ BGFX_C_API void bgfx_set_dynamic_vertex_buffer(uint8_t _stream, bgfx_dynamic_ver
|
||||
BGFX_C_API void bgfx_set_transient_vertex_buffer(uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices);
|
||||
|
||||
/**/
|
||||
BGFX_C_API void bgfx_set_instance_data_buffer(const bgfx_instance_data_buffer_t* _idb, uint32_t _num);
|
||||
BGFX_C_API void bgfx_set_instance_data_buffer(const bgfx_instance_data_buffer_t* _idb, uint32_t _start, uint32_t _num);
|
||||
|
||||
/**/
|
||||
BGFX_C_API void bgfx_set_instance_data_from_vertex_buffer(bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
|
||||
@@ -1032,7 +1032,7 @@ BGFX_C_API void bgfx_encoder_set_dynamic_vertex_buffer(struct bgfx_encoder* _enc
|
||||
BGFX_C_API void bgfx_encoder_set_transient_vertex_buffer(struct bgfx_encoder* _encoder, uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices);
|
||||
|
||||
/**/
|
||||
BGFX_C_API void bgfx_encoder_set_instance_data_buffer(struct bgfx_encoder* _encoder, const bgfx_instance_data_buffer_t* _idb, uint32_t _num);
|
||||
BGFX_C_API void bgfx_encoder_set_instance_data_buffer(struct bgfx_encoder* _encoder, const bgfx_instance_data_buffer_t* _idb, uint32_t _start, uint32_t _num);
|
||||
|
||||
/**/
|
||||
BGFX_C_API void bgfx_encoder_set_instance_data_from_vertex_buffer(struct bgfx_encoder* _encoder, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
|
||||
|
||||
@@ -181,7 +181,7 @@ typedef struct bgfx_interface_vtbl
|
||||
void (*encoder_set_vertex_buffer)(struct bgfx_encoder* _encoder, uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
|
||||
void (*encoder_set_dynamic_vertex_buffer)(struct bgfx_encoder* _encoder, uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices);
|
||||
void (*encoder_set_transient_vertex_buffer)(struct bgfx_encoder* _encoder, uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices);
|
||||
void (*encoder_set_instance_data_buffer)(struct bgfx_encoder* _encoder, const bgfx_instance_data_buffer_t* _idb, uint32_t _num);
|
||||
void (*encoder_set_instance_data_buffer)(struct bgfx_encoder* _encoder, const bgfx_instance_data_buffer_t* _idb, uint32_t _start, uint32_t _num);
|
||||
void (*encoder_set_instance_data_from_vertex_buffer)(struct bgfx_encoder* _encoder, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
|
||||
void (*encoder_set_instance_data_from_dynamic_vertex_buffer)(struct bgfx_encoder* _encoder, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num);
|
||||
void (*encoder_set_texture)(struct bgfx_encoder* _encoder, uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint32_t _flags);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#ifndef BGFX_DEFINES_H_HEADER_GUARD
|
||||
#define BGFX_DEFINES_H_HEADER_GUARD
|
||||
|
||||
#define BGFX_API_VERSION UINT32_C(61)
|
||||
#define BGFX_API_VERSION UINT32_C(62)
|
||||
|
||||
/// Color RGB/alpha/depth write. When it's not specified write will be disabled.
|
||||
#define BGFX_STATE_RGB_WRITE UINT64_C(0x0000000000000001) //!< Enable RGB write.
|
||||
|
||||
27
src/bgfx.cpp
27
src/bgfx.cpp
@@ -3048,10 +3048,15 @@ error:
|
||||
setVertexBuffer(_stream, _tvb, 0, UINT32_MAX);
|
||||
}
|
||||
|
||||
void Encoder::setInstanceDataBuffer(const InstanceDataBuffer* _idb, uint32_t _num)
|
||||
void Encoder::setInstanceDataBuffer(const InstanceDataBuffer* _idb)
|
||||
{
|
||||
setInstanceDataBuffer(_idb, 0, UINT32_MAX);
|
||||
}
|
||||
|
||||
void Encoder::setInstanceDataBuffer(const InstanceDataBuffer* _idb, uint32_t _start, uint32_t _num)
|
||||
{
|
||||
BX_CHECK(NULL != _idb, "_idb can't be NULL");
|
||||
BGFX_ENCODER(setInstanceDataBuffer(_idb, _num) );
|
||||
BGFX_ENCODER(setInstanceDataBuffer(_idb, _start, _num) );
|
||||
}
|
||||
|
||||
void Encoder::setInstanceDataBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _num)
|
||||
@@ -4210,10 +4215,16 @@ error:
|
||||
setVertexBuffer(_stream, _tvb, 0, UINT32_MAX);
|
||||
}
|
||||
|
||||
void setInstanceDataBuffer(const InstanceDataBuffer* _idb, uint32_t _num)
|
||||
void setInstanceDataBuffer(const InstanceDataBuffer* _idb)
|
||||
{
|
||||
BGFX_CHECK_API_THREAD();
|
||||
s_ctx->m_encoder0->setInstanceDataBuffer(_idb, _num);
|
||||
s_ctx->m_encoder0->setInstanceDataBuffer(_idb);
|
||||
}
|
||||
|
||||
void setInstanceDataBuffer(const InstanceDataBuffer* _idb, uint32_t _start, uint32_t _num)
|
||||
{
|
||||
BGFX_CHECK_API_THREAD();
|
||||
s_ctx->m_encoder0->setInstanceDataBuffer(_idb, _start, _num);
|
||||
}
|
||||
|
||||
void setInstanceDataBuffer(VertexBufferHandle _handle, uint32_t _startVertex, uint32_t _num)
|
||||
@@ -5263,9 +5274,9 @@ BGFX_C_API void bgfx_set_transient_vertex_buffer(uint8_t _stream, const bgfx_tra
|
||||
bgfx::setVertexBuffer(_stream, (const bgfx::TransientVertexBuffer*)_tvb, _startVertex, _numVertices);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_set_instance_data_buffer(const bgfx_instance_data_buffer_t* _idb, uint32_t _num)
|
||||
BGFX_C_API void bgfx_set_instance_data_buffer(const bgfx_instance_data_buffer_t* _idb, uint32_t _start, uint32_t _num)
|
||||
{
|
||||
bgfx::setInstanceDataBuffer( (const bgfx::InstanceDataBuffer*)_idb, _num);
|
||||
bgfx::setInstanceDataBuffer( (const bgfx::InstanceDataBuffer*)_idb, _start, _num);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_set_instance_data_from_vertex_buffer(bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num)
|
||||
@@ -5461,9 +5472,9 @@ BGFX_C_API void bgfx_encoder_set_transient_vertex_buffer(bgfx_encoder* _encoder,
|
||||
BGFX_ENCODER(setVertexBuffer(_stream, (const bgfx::TransientVertexBuffer*)_tvb, _startVertex, _numVertices) );
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_encoder_set_instance_data_buffer(bgfx_encoder* _encoder, const bgfx_instance_data_buffer_t* _idb, uint32_t _num)
|
||||
BGFX_C_API void bgfx_encoder_set_instance_data_buffer(bgfx_encoder* _encoder, const bgfx_instance_data_buffer_t* _idb, uint32_t _start, uint32_t _num)
|
||||
{
|
||||
BGFX_ENCODER(setInstanceDataBuffer( (const bgfx::InstanceDataBuffer*)_idb, _num) );
|
||||
BGFX_ENCODER(setInstanceDataBuffer( (const bgfx::InstanceDataBuffer*)_idb, _start, _num) );
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_encoder_set_instance_data_from_vertex_buffer(bgfx_encoder* _encoder, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _num)
|
||||
|
||||
@@ -2177,11 +2177,13 @@ namespace bgfx
|
||||
}
|
||||
}
|
||||
|
||||
void setInstanceDataBuffer(const InstanceDataBuffer* _idb, uint32_t _num)
|
||||
void setInstanceDataBuffer(const InstanceDataBuffer* _idb, uint32_t _start, uint32_t _num)
|
||||
{
|
||||
m_draw.m_instanceDataOffset = _idb->offset;
|
||||
const uint32_t start = bx::min(_start, _idb->num);
|
||||
const uint32_t num = bx::min(_idb->num - start, _num);
|
||||
m_draw.m_instanceDataOffset = _idb->offset + start*_idb->stride;
|
||||
m_draw.m_instanceDataStride = _idb->stride;
|
||||
m_draw.m_numInstances = bx::uint32_min(_idb->num, _num);
|
||||
m_draw.m_numInstances = num;
|
||||
m_draw.m_instanceDataBuffer = _idb->handle;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user