| 29 | } |
| 30 | |
| 31 | void * VulkanGPUBuffer::Map(ref_ptr<VulkanBaseContext> context, uint32_t elementOffset, uint32_t elementCount) |
| 32 | { |
| 33 | CHECK(m_objectManager != nullptr, ()); |
| 34 | |
| 35 | uint32_t const elementSize = GetElementSize(); |
| 36 | uint32_t const mappingSizeInBytes = elementCount * elementSize; |
| 37 | m_mappingByteOffset = elementOffset * elementSize; |
| 38 | m_mappingByteOffsetMin = std::numeric_limits<uint32_t>::max(); |
| 39 | m_mappingByteOffsetMax = std::numeric_limits<uint32_t>::min(); |
| 40 | |
| 41 | VkCommandBuffer commandBuffer = context->GetCurrentMemoryCommandBuffer(); |
| 42 | CHECK(commandBuffer != nullptr, ()); |
| 43 | |
| 44 | // Copy to default or temporary staging buffer. |
| 45 | m_stagingBufferRef = context->GetDefaultStagingBuffer(); |
| 46 | if (!m_stagingBufferRef->HasEnoughSpace(mappingSizeInBytes)) |
| 47 | { |
| 48 | m_ownStagingBuffer = make_unique_dp<VulkanStagingBuffer>(m_objectManager, mappingSizeInBytes); |
| 49 | ASSERT(m_ownStagingBuffer->HasEnoughSpace(mappingSizeInBytes), ()); |
| 50 | m_stagingBufferRef = make_ref(m_ownStagingBuffer); |
| 51 | } |
| 52 | |
| 53 | VulkanStagingBuffer::StagingData data; |
| 54 | m_reservationId = m_stagingBufferRef->ReserveWithId(mappingSizeInBytes, data); |
| 55 | return data.m_pointer; |
| 56 | } |
| 57 | |
| 58 | void VulkanGPUBuffer::UpdateData(void * gpuPtr, void const * data, uint32_t elementOffset, uint32_t elementCount) |
| 59 | { |
nothing calls this directly
no test coverage detected