| 22 | } |
| 23 | |
| 24 | ALResult Tr2SuballocatedBuffer::Allocate( uint32_t stride, uint32_t count, void* data, Tr2RenderContextAL& renderContext, Allocation& result ) |
| 25 | { |
| 26 | if( !m_buffer.IsValid() ) |
| 27 | { |
| 28 | PrepareResources(); |
| 29 | if( !m_buffer.IsValid() ) |
| 30 | { |
| 31 | return E_FAIL; |
| 32 | } |
| 33 | } |
| 34 | size_t size = count * stride; |
| 35 | |
| 36 | Tr2VirtualAllocator::VirtualAllocation allocation = {}; |
| 37 | if( m_allocator.Allocate( size, stride, allocation ) ) |
| 38 | { |
| 39 | result.m_offset = static_cast<uint32_t>( allocation.offset ); |
| 40 | result.m_size = static_cast<uint32_t>( size ); |
| 41 | |
| 42 | result.m_stride = static_cast<uint32_t>( stride ); |
| 43 | |
| 44 | result.m_allocation = allocation; |
| 45 | result.m_parent = this; |
| 46 | m_allocations.push_back( &result ); |
| 47 | |
| 48 | CCP_ASSERT( result.m_offset % stride == 0 ); |
| 49 | |
| 50 | if( data != nullptr ) |
| 51 | { |
| 52 | result.Update( data, renderContext ); |
| 53 | } |
| 54 | |
| 55 | CCP_STATS_SET( suballocatedBufferAllocated, m_allocator.GetAllocatedMemory() ); |
| 56 | |
| 57 | return S_OK; |
| 58 | } |
| 59 | |
| 60 | FORWARD_HR( Expand() ); |
| 61 | |
| 62 | return Allocate( stride, count, data, renderContext, result ); |
| 63 | } |
| 64 | |
| 65 | void Tr2SuballocatedBuffer::Free( Allocation& allocation ) |
| 66 | { |
nothing calls this directly
no test coverage detected