This commit is contained in:
Branimir Karadžić 2015-01-30 10:31:50 -08:00
parent a1d50d6ea4
commit 524b28a9f7
4 changed files with 9 additions and 11 deletions

View file

@ -692,7 +692,7 @@ namespace bgfx
/// @param _mem Vertex buffer data.
/// @param _decl Vertex declaration.
///
DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexDecl& _decl);
DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint8_t _flags = BGFX_BUFFER_NONE);
/// Update dynamic vertex buffer.
void updateDynamicVertexBuffer(DynamicVertexBufferHandle _handle, const Memory* _mem);

View file

@ -2144,19 +2144,19 @@ again:
s_ctx->destroyDynamicIndexBuffer(_handle);
}
DynamicVertexBufferHandle createDynamicVertexBuffer(uint16_t _num, const VertexDecl& _decl, uint8_t _compute)
DynamicVertexBufferHandle createDynamicVertexBuffer(uint16_t _num, const VertexDecl& _decl, uint8_t _flags)
{
BGFX_CHECK_MAIN_THREAD();
BX_CHECK(0 != _decl.m_stride, "Invalid VertexDecl.");
return s_ctx->createDynamicVertexBuffer(_num, _decl, _compute);
return s_ctx->createDynamicVertexBuffer(_num, _decl, _flags);
}
DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexDecl& _decl)
DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint8_t _flags)
{
BGFX_CHECK_MAIN_THREAD();
BX_CHECK(NULL != _mem, "_mem can't be NULL");
BX_CHECK(0 != _decl.m_stride, "Invalid VertexDecl.");
return s_ctx->createDynamicVertexBuffer(_mem, _decl);
return s_ctx->createDynamicVertexBuffer(_mem, _decl, _flags);
}
void updateDynamicVertexBuffer(DynamicVertexBufferHandle _handle, const Memory* _mem)

View file

@ -2222,11 +2222,11 @@ namespace bgfx
return handle;
}
BGFX_API_FUNC(DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexDecl& _decl) )
BGFX_API_FUNC(DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexDecl& _decl, uint8_t _flags) )
{
uint32_t numVertices = _mem->size/_decl.m_stride;
BX_CHECK(numVertices <= UINT16_MAX, "Num vertices exceeds maximum (num %d, max %d).", numVertices, UINT16_MAX);
DynamicVertexBufferHandle handle = createDynamicVertexBuffer(uint16_t(numVertices), _decl, BGFX_BUFFER_NONE);
DynamicVertexBufferHandle handle = createDynamicVertexBuffer(uint16_t(numVertices), _decl, _flags);
if (isValid(handle) )
{
updateDynamicVertexBuffer(handle, _mem);

View file

@ -2364,10 +2364,8 @@ namespace bgfx
BX_CHECK(m_dynamic, "Must be dynamic!");
D3D11_MAPPED_SUBRESOURCE mapped;
D3D11_MAP type = m_dynamic && ( (0 == _offset && m_size == _size) || _discard)
? D3D11_MAP_WRITE_DISCARD
: D3D11_MAP_WRITE_NO_OVERWRITE
;
BX_UNUSED(_discard);
D3D11_MAP type = D3D11_MAP_WRITE_DISCARD;
DX_CHECK(deviceCtx->Map(m_ptr, 0, type, 0, &mapped));
memcpy((uint8_t*)mapped.pData + _offset, _data, _size);
deviceCtx->Unmap(m_ptr, 0);