Added function to check both vertex and index transient buffers.

This commit is contained in:
bkaradzic 2013-05-01 20:35:43 -07:00
parent b15dcfd66a
commit b7c4630ee3
2 changed files with 47 additions and 11 deletions

View file

@ -351,6 +351,7 @@ namespace bgfx
/// NOTE:
/// 'fatal' callback can be called from any thread. Other callbacks
/// are called from the render thread.
///
struct CallbackI
{
virtual ~CallbackI() = 0;
@ -456,6 +457,7 @@ namespace bgfx
///
/// NOTE:
/// Must be called between begin/end.
///
void add(Attrib::Enum _attrib, uint8_t _num, AttribType::Enum _type, bool _normalized = false, bool _asInt = false);
/// Decode attribute.
@ -581,28 +583,46 @@ namespace bgfx
/// Update dynamic vertex buffer.
void updateDynamicVertexBuffer(DynamicVertexBufferHandle _handle, const Memory* _mem);
/// Destory dynamic vertex buffer.
/// Destroy dynamic vertex buffer.
void destroyDynamicVertexBuffer(DynamicVertexBufferHandle _handle);
/// Returns true if internal transient index buffer has enough space.
///
/// @param _num Number of indices.
///
bool checkAvailTransientIndexBuffer(uint16_t _num);
/// Returns true if internal transient vertex buffer has enough space.
///
/// @param _num Number of vertices.
/// @param _decl Vertex declaration.
///
bool checkAvailTransientVertexBuffer(uint16_t _num, const VertexDecl& _decl);
/// Returns true if both internal transient index and vertex buffer have
/// enough space.
///
/// @param _numVertices Number of vertices.
/// @param _decl Vertex declaration.
/// @param _numIndices Number of indices.
///
bool checkAvailTransientBuffers(uint16_t _numVertices, const VertexDecl& _decl, uint16_t _numIndices);
/// Allocate transient index buffer.
///
/// @param[out] _tib is valid for the duration of frame, and it can be
/// reused for multiple draw calls.
/// @param _num number of indices to allocate.
///
void allocTransientIndexBuffer(TransientIndexBuffer* _tib, uint16_t _num);
/// Returns true if internal transient vertex buffer has enough space.
bool checkAvailTransientVertexBuffer(uint16_t _num, const VertexDecl& _decl);
/// Allocate transient vertex buffer.
///
/// @param[out] _tvb is valid for the duration of frame, and it can be
/// reused for multiple draw calls.
/// @param _num number of vertices to allocate.
/// @param _decl vertex declaration.
///
void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint16_t _num, const VertexDecl& _decl);
/// Allocate instance data buffer.
@ -628,6 +648,7 @@ namespace bgfx
/// @param _fsh fragment shader.
/// @returns Program handle if vertex shader output and fragment shader
/// input are matching, otherwise returns invalid program handle.
///
ProgramHandle createProgram(VertexShaderHandle _vsh, FragmentShaderHandle _fsh);
/// Destroy program.
@ -652,6 +673,7 @@ namespace bgfx
///
/// @param _info Returns parsed DDS texture information.
/// @returns Texture handle.
///
TextureHandle createTexture(const Memory* _mem, uint32_t _flags = BGFX_TEXTURE_NONE, TextureInfo* _info = NULL);
/// Create 2D texture.
@ -702,6 +724,7 @@ namespace bgfx
/// @param _rgba color clear value.
/// @param _depth depth clear value.
/// @param _stencil stencil clear value.
///
void setViewClear(uint8_t _id, uint8_t _flags, uint32_t _rgba = 0x000000ff, float _depth = 1.0f, uint8_t _stencil = 0);
/// Set view clear flags for multiple views.
@ -749,6 +772,7 @@ namespace bgfx
/// NOTE:
/// Use BGFX_STATE_ALPHA_REF, BGFX_STATE_POINT_SIZE and
/// BGFX_STATE_BLEND_FUNC macros to setup more complex states.
///
void setState(uint64_t _state, uint32_t _rgba = UINT32_MAX);
/// Set stencil test state.
@ -756,6 +780,7 @@ namespace bgfx
/// @param _fstencil Front stencil state.
/// @param _bstencil Back stencil state. If back is set to BGFX_STENCIL_NONE
/// _fstencil is applied to both front and back facing primitives.
///
void setStencil(uint32_t _fstencil, uint32_t _bstencil = BGFX_STENCIL_NONE);
/// Set model matrix for draw primitive. If it is not called model will
@ -765,12 +790,14 @@ namespace bgfx
/// @param _num number of matrices in array.
/// @returns index into matrix cache in case the same model matrix has
/// to be used for other draw primitive call.
///
uint32_t setTransform(const void* _mtx, uint16_t _num = 1);
/// Set model matrix from matrix cache for draw primitive.
///
/// @param _cache index in matrix cache.
/// @param _num number of matrices from cache.
///
void setTransform(uint32_t _cache, uint16_t _num = 1);
/// Set shader uniform parameter for draw primitive.
@ -810,12 +837,14 @@ namespace bgfx
///
/// @param _id View id.
/// @param _depth depth for sorting.
///
void submit(uint8_t _id, int32_t _depth = 0);
/// Submit primitive for rendering into multiple views.
///
/// @param _viewMask mask to which views to submit draw primitive calls.
/// @param _depth depth for sorting.
///
void submitMask(uint32_t _viewMask, int32_t _depth = 0);
/// Request screen shot.

View file

@ -931,6 +931,20 @@ namespace bgfx
return s_ctx.m_submit->checkAvailTransientIndexBuffer(_num);
}
bool checkAvailTransientVertexBuffer(uint16_t _num, const VertexDecl& _decl)
{
BGFX_CHECK_MAIN_THREAD();
BX_CHECK(0 < _num, "Requesting 0 vertices.");
return s_ctx.m_submit->checkAvailTransientVertexBuffer(_num, _decl.m_stride);
}
bool checkAvailTransientBuffers(uint16_t _numVertices, const VertexDecl& _decl, uint16_t _numIndices)
{
return checkAvailTransientVertexBuffer(_numVertices, _decl)
&& checkAvailTransientIndexBuffer(_numIndices)
;
}
void allocTransientIndexBuffer(TransientIndexBuffer* _tib, uint16_t _num)
{
BGFX_CHECK_MAIN_THREAD();
@ -939,13 +953,6 @@ namespace bgfx
return s_ctx.allocTransientIndexBuffer(_tib, _num);
}
bool checkAvailTransientVertexBuffer(uint16_t _num, const VertexDecl& _decl)
{
BGFX_CHECK_MAIN_THREAD();
BX_CHECK(0 < _num, "Requesting 0 vertices.");
return s_ctx.m_submit->checkAvailTransientVertexBuffer(_num, _decl.m_stride);
}
void allocTransientVertexBuffer(TransientVertexBuffer* _tvb, uint16_t _num, const VertexDecl& _decl)
{
BGFX_CHECK_MAIN_THREAD();