Workaround issue with partial dynamic buffer update.
This commit is contained in:
parent
a1289e9e82
commit
f74b350ab8
@ -4113,13 +4113,32 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
|||||||
}
|
}
|
||||||
else if (m_dynamic)
|
else if (m_dynamic)
|
||||||
{
|
{
|
||||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
#if USE_D3D11_STAGING_BUFFER
|
||||||
|
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||||
|
desc.CPUAccessFlags = 0;
|
||||||
|
|
||||||
|
DX_CHECK(device->CreateBuffer(&desc
|
||||||
|
, NULL
|
||||||
|
, &m_ptr
|
||||||
|
) );
|
||||||
|
|
||||||
|
desc.BindFlags = 0;
|
||||||
|
desc.Usage = D3D11_USAGE_STAGING;
|
||||||
|
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||||
|
|
||||||
|
DX_CHECK(device->CreateBuffer(&desc
|
||||||
|
, NULL
|
||||||
|
, &m_staging
|
||||||
|
) );
|
||||||
|
#else
|
||||||
|
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||||
|
|
||||||
DX_CHECK(device->CreateBuffer(&desc
|
DX_CHECK(device->CreateBuffer(&desc
|
||||||
, NULL
|
, NULL
|
||||||
, &m_ptr
|
, &m_ptr
|
||||||
) );
|
) );
|
||||||
|
#endif // USE_D3D11_STAGING_BUFFER
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -4151,54 +4170,79 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
|||||||
ID3D11DeviceContext* deviceCtx = s_renderD3D11->m_deviceCtx;
|
ID3D11DeviceContext* deviceCtx = s_renderD3D11->m_deviceCtx;
|
||||||
BX_CHECK(m_dynamic, "Must be dynamic!");
|
BX_CHECK(m_dynamic, "Must be dynamic!");
|
||||||
|
|
||||||
#if 0
|
#if USE_D3D11_STAGING_BUFFER
|
||||||
BX_UNUSED(_discard);
|
BX_UNUSED(_discard);
|
||||||
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;
|
D3D11_MAPPED_SUBRESOURCE mapped;
|
||||||
srd.pSysMem = _data;
|
DX_CHECK(deviceCtx->Map(m_staging, 0, D3D11_MAP_WRITE, 0, &mapped) );
|
||||||
srd.SysMemPitch = 0;
|
bx::memCopy( (uint8_t*)mapped.pData + _offset, _data, _size);
|
||||||
srd.SysMemSlicePitch = 0;
|
deviceCtx->Unmap(m_staging, 0);
|
||||||
|
|
||||||
D3D11_BOX srcBox;
|
D3D11_BOX box;
|
||||||
srcBox.left = 0;
|
box.left = _offset;
|
||||||
srcBox.top = 0;
|
box.top = 0;
|
||||||
srcBox.front = 0;
|
box.front = 0;
|
||||||
srcBox.right = _size;
|
box.right = _offset + _size;
|
||||||
srcBox.bottom = 1;
|
box.bottom = 1;
|
||||||
srcBox.back = 1;
|
box.back = 1;
|
||||||
|
|
||||||
ID3D11Device* device = s_renderD3D11->m_device;
|
|
||||||
|
|
||||||
ID3D11Buffer* ptr;
|
|
||||||
DX_CHECK(device->CreateBuffer(&desc, &srd, &ptr) );
|
|
||||||
|
|
||||||
deviceCtx->CopySubresourceRegion(m_ptr
|
deviceCtx->CopySubresourceRegion(m_ptr
|
||||||
, 0
|
, 0
|
||||||
, _offset
|
, _offset
|
||||||
, 0
|
, 0
|
||||||
, 0
|
, 0
|
||||||
, ptr
|
, m_staging
|
||||||
, 0
|
, 0
|
||||||
, &srcBox
|
, &box
|
||||||
);
|
);
|
||||||
|
|
||||||
DX_RELEASE(ptr, 0);
|
|
||||||
#else
|
#else
|
||||||
D3D11_MAPPED_SUBRESOURCE mapped;
|
if (_discard)
|
||||||
D3D11_MAP type = _discard
|
{
|
||||||
? D3D11_MAP_WRITE_DISCARD
|
D3D11_MAPPED_SUBRESOURCE mapped;
|
||||||
: D3D11_MAP_WRITE_NO_OVERWRITE
|
DX_CHECK(deviceCtx->Map(m_ptr, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped) );
|
||||||
;
|
bx::memCopy( (uint8_t*)mapped.pData + _offset, _data, _size);
|
||||||
DX_CHECK(deviceCtx->Map(m_ptr, 0, type, 0, &mapped) );
|
deviceCtx->Unmap(m_ptr, 0);
|
||||||
bx::memCopy( (uint8_t*)mapped.pData + _offset, _data, _size);
|
}
|
||||||
deviceCtx->Unmap(m_ptr, 0);
|
else
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
|
||||||
|
D3D11_BOX srcBox;
|
||||||
|
srcBox.left = 0;
|
||||||
|
srcBox.top = 0;
|
||||||
|
srcBox.front = 0;
|
||||||
|
srcBox.right = _size;
|
||||||
|
srcBox.bottom = 1;
|
||||||
|
srcBox.back = 1;
|
||||||
|
|
||||||
|
ID3D11Device* device = s_renderD3D11->m_device;
|
||||||
|
|
||||||
|
ID3D11Buffer* ptr;
|
||||||
|
DX_CHECK(device->CreateBuffer(&desc, &srd, &ptr) );
|
||||||
|
|
||||||
|
deviceCtx->CopySubresourceRegion(m_ptr
|
||||||
|
, 0
|
||||||
|
, _offset
|
||||||
|
, 0
|
||||||
|
, 0
|
||||||
|
, ptr
|
||||||
|
, 0
|
||||||
|
, &srcBox
|
||||||
|
);
|
||||||
|
|
||||||
|
DX_RELEASE(ptr, 0);
|
||||||
|
}
|
||||||
#endif // 0
|
#endif // 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
#ifndef BGFX_RENDERER_D3D11_H_HEADER_GUARD
|
#ifndef BGFX_RENDERER_D3D11_H_HEADER_GUARD
|
||||||
#define BGFX_RENDERER_D3D11_H_HEADER_GUARD
|
#define BGFX_RENDERER_D3D11_H_HEADER_GUARD
|
||||||
|
|
||||||
#define USE_D3D11_DYNAMIC_LIB BX_PLATFORM_WINDOWS
|
#define USE_D3D11_DYNAMIC_LIB BX_PLATFORM_WINDOWS
|
||||||
|
#define USE_D3D11_STAGING_BUFFER 0
|
||||||
|
|
||||||
#if !USE_D3D11_DYNAMIC_LIB
|
#if !USE_D3D11_DYNAMIC_LIB
|
||||||
# undef BGFX_CONFIG_DEBUG_PIX
|
# undef BGFX_CONFIG_DEBUG_PIX
|
||||||
@ -64,6 +65,9 @@ namespace bgfx { namespace d3d11
|
|||||||
{
|
{
|
||||||
BufferD3D11()
|
BufferD3D11()
|
||||||
: m_ptr(NULL)
|
: m_ptr(NULL)
|
||||||
|
#if USE_D3D11_STAGING_BUFFER
|
||||||
|
, m_staging(NULL)
|
||||||
|
#endif // USE_D3D11_STAGING_BUFFER
|
||||||
, m_srv(NULL)
|
, m_srv(NULL)
|
||||||
, m_uav(NULL)
|
, m_uav(NULL)
|
||||||
, m_flags(BGFX_BUFFER_NONE)
|
, m_flags(BGFX_BUFFER_NONE)
|
||||||
@ -82,11 +86,18 @@ namespace bgfx { namespace d3d11
|
|||||||
m_dynamic = false;
|
m_dynamic = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if USE_D3D11_STAGING_BUFFER
|
||||||
|
DX_RELEASE(m_staging, 0);
|
||||||
|
#endif // USE_D3D11_STAGING_BUFFER
|
||||||
|
|
||||||
DX_RELEASE(m_srv, 0);
|
DX_RELEASE(m_srv, 0);
|
||||||
DX_RELEASE(m_uav, 0);
|
DX_RELEASE(m_uav, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D11Buffer* m_ptr;
|
ID3D11Buffer* m_ptr;
|
||||||
|
#if USE_D3D11_STAGING_BUFFER
|
||||||
|
ID3D11Buffer* m_staging;
|
||||||
|
#endif // USE_D3D11_STAGING_BUFFER
|
||||||
ID3D11ShaderResourceView* m_srv;
|
ID3D11ShaderResourceView* m_srv;
|
||||||
ID3D11UnorderedAccessView* m_uav;
|
ID3D11UnorderedAccessView* m_uav;
|
||||||
uint32_t m_size;
|
uint32_t m_size;
|
||||||
|
Loading…
Reference in New Issue
Block a user