mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
D3D11: Fixed buffer update. Issue #271.
This commit is contained in:
parent
93b5b0a20c
commit
ac34be556a
1 changed files with 34 additions and 1 deletions
|
@ -2372,12 +2372,45 @@ namespace bgfx
|
|||
ID3D11DeviceContext* deviceCtx = s_renderD3D11->m_deviceCtx;
|
||||
BX_CHECK(m_dynamic, "Must be dynamic!");
|
||||
|
||||
#if 1
|
||||
BX_UNUSED(_discard);
|
||||
ID3D11Device* device = s_renderD3D11->m_device;
|
||||
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = _size;
|
||||
desc.Usage = D3D11_USAGE_STAGING;
|
||||
desc.BindFlags = 0;
|
||||
desc.MiscFlags = 0;
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
desc.StructureByteStride = 0;
|
||||
|
||||
D3D11_SUBRESOURCE_DATA srd;
|
||||
srd.pSysMem = _data;
|
||||
srd.SysMemPitch = 0;
|
||||
srd.SysMemSlicePitch = 0;
|
||||
|
||||
ID3D11Buffer* ptr;
|
||||
DX_CHECK(device->CreateBuffer(&desc, &srd, &ptr) );
|
||||
|
||||
deviceCtx->CopySubresourceRegion(m_ptr
|
||||
, 0
|
||||
, _offset
|
||||
, 0
|
||||
, 0
|
||||
, ptr
|
||||
, 0
|
||||
, NULL
|
||||
);
|
||||
|
||||
DX_RELEASE(ptr, 0);
|
||||
#else
|
||||
D3D11_MAPPED_SUBRESOURCE mapped;
|
||||
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);
|
||||
memcpy( (uint8_t*)mapped.pData + _offset, _data, _size);
|
||||
deviceCtx->Unmap(m_ptr, 0);
|
||||
#endif // 0
|
||||
}
|
||||
|
||||
void VertexBufferD3D11::create(uint32_t _size, void* _data, VertexDeclHandle _declHandle, uint8_t _flags)
|
||||
|
|
Loading…
Reference in a new issue