| 239 | } |
| 240 | |
| 241 | ALResult Tr2BufferAL::MapForReading( const void*& data, Tr2RenderContextAL& renderContext ) |
| 242 | { |
| 243 | if( !renderContext.IsValid() || !IsValid() ) |
| 244 | { |
| 245 | data = nullptr; |
| 246 | return E_INVALIDCALL; |
| 247 | } |
| 248 | if( !HasFlag( m_desc.cpuUsage, Tr2CpuUsage::READ ) ) |
| 249 | { |
| 250 | return E_INVALIDCALL; |
| 251 | } |
| 252 | CR_RETURN_HR( CreateStagingBuffer( m_desc.stride * m_desc.count, renderContext ) ); |
| 253 | |
| 254 | renderContext.m_context->CopyResource( m_staging, m_buffer ); |
| 255 | |
| 256 | D3D11_MAPPED_SUBRESOURCE ms = { nullptr, 0, 0 }; |
| 257 | auto hr = renderContext.m_context->Map( m_staging, 0, D3D11_MAP_READ, 0, &ms ); |
| 258 | if( !ms.pData ) |
| 259 | { |
| 260 | return E_FAIL; |
| 261 | } |
| 262 | data = ms.pData; |
| 263 | return hr; |
| 264 | } |
| 265 | |
| 266 | ALResult Tr2BufferAL::MapForReading( const void*& data, uint32_t offset, uint32_t size, Tr2RenderContextAL& renderContext ) |
| 267 | { |
nothing calls this directly
no test coverage detected