| 108 | } |
| 109 | |
| 110 | bool DX11StructuredBuffer::GetNumActiveElements( |
| 111 | ID3D11DeviceContext* context) |
| 112 | { |
| 113 | // Copy the number of active elements from GPU to staging buffer. |
| 114 | context->CopyStructureCount(mCounterStaging, 0, mUAView); |
| 115 | |
| 116 | // Map the staging buffer. |
| 117 | D3D11_MAPPED_SUBRESOURCE sub; |
| 118 | DX11Log(context->Map(mCounterStaging, 0, D3D11_MAP_READ, 0, &sub)); |
| 119 | |
| 120 | // Get the number of active elements in the buffer. The internal counter |
| 121 | // appears to increment even when the buffer is full, so it needs to be |
| 122 | // clamped to the maximum value. The clamping occurs in the call to |
| 123 | // SetNumActiveElements(). |
| 124 | uint32_t numActive = *static_cast<uint32_t*>(sub.pData); |
| 125 | context->Unmap(mCounterStaging, 0); |
| 126 | |
| 127 | // Copy the number to the CPU. |
| 128 | GetStructuredBuffer()->SetNumActiveElements(numActive); |
| 129 | return true; |
| 130 | } |
| 131 | |
| 132 | void DX11StructuredBuffer::SetName(std::string const& name) |
| 133 | { |
nothing calls this directly
no test coverage detected