MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / Update

Method Update

GTE/Graphics/DX11/DX11Buffer.cpp:19–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19bool DX11Buffer::Update(ID3D11DeviceContext* context)
20{
21 Buffer* buffer = GetBuffer();
22 LogAssert(buffer->GetUsage() == Resource::Usage::DYNAMIC_UPDATE, "Buffer must be dynamic-update.");
23
24 UINT numActiveBytes = buffer->GetNumActiveBytes();
25 if (numActiveBytes > 0)
26 {
27 // Map the buffer.
28 ID3D11Buffer* dxBuffer = GetDXBuffer();
29 D3D11_MAPPED_SUBRESOURCE sub;
30 DX11Log(context->Map(dxBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &sub));
31
32 // Copy from CPU memory.
33 if (mUpdateMapMode != D3D11_MAP_WRITE_DISCARD)
34 {
35 uint32_t offsetInBytes = buffer->GetOffset() * buffer->GetElementSize();
36 char const* source = buffer->GetData() + offsetInBytes;
37 char* target = (char*)sub.pData + offsetInBytes;
38 std::memcpy(target, source, numActiveBytes);
39 }
40 else
41 {
42 std::memcpy(sub.pData, buffer->GetData(), buffer->GetNumBytes());
43 }
44 context->Unmap(dxBuffer, 0);
45 }
46 return true;
47}
48
49bool DX11Buffer::CopyCpuToGpu(ID3D11DeviceContext* context)
50{

Callers

nothing calls this directly

Calls 7

GetNumActiveBytesMethod · 0.80
GetElementSizeMethod · 0.80
GetUsageMethod · 0.45
GetOffsetMethod · 0.45
GetDataMethod · 0.45
GetNumBytesMethod · 0.45
UnmapMethod · 0.45

Tested by

no test coverage detected