@@ -6161,7 +6161,7 @@ static void TestDataUploadingWithStagingBuffer()
6161
6161
const VkDeviceSize bufferSize = 65536 ;
6162
6162
std::vector<std::uint8_t > bufferData (bufferSize);
6163
6163
for (auto & bufferByte : bufferData) {
6164
- bufferByte = static_cast <std::uint8_t >(rand () % 256 );
6164
+ bufferByte = static_cast <std::uint8_t >(rand ());
6165
6165
}
6166
6166
6167
6167
VkBufferCreateInfo uniformBufferCI = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
@@ -6170,20 +6170,14 @@ static void TestDataUploadingWithStagingBuffer()
6170
6170
6171
6171
VmaAllocationCreateInfo uniformBufferAllocCI = {};
6172
6172
uniformBufferAllocCI.usage = VMA_MEMORY_USAGE_AUTO;
6173
- uniformBufferAllocCI.flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
6174
6173
6175
6174
VkBuffer uniformBuffer = VK_NULL_HANDLE;
6176
- VmaAllocation uniformBufferAlloc = {} ;
6175
+ VmaAllocation uniformBufferAlloc = VK_NULL_HANDLE ;
6177
6176
VmaAllocationInfo uniformBufferAllocInfo = {};
6178
6177
6179
6178
VkResult result = vmaCreateBuffer (g_hAllocator, &uniformBufferCI, &uniformBufferAllocCI, &uniformBuffer, &uniformBufferAlloc, &uniformBufferAllocInfo);
6180
6179
TEST (result == VK_SUCCESS);
6181
6180
6182
- // We need to check if the uniform buffer really ended NOT up in mappable memory.
6183
- VkMemoryPropertyFlags memPropFlags;
6184
- vmaGetAllocationMemoryProperties (g_hAllocator, uniformBufferAlloc, &memPropFlags);
6185
- TEST (!(memPropFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT));
6186
-
6187
6181
VkBufferCreateInfo stagingBufferCI = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO };
6188
6182
stagingBufferCI.size = bufferSize;
6189
6183
stagingBufferCI.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
@@ -6200,10 +6194,7 @@ static void TestDataUploadingWithStagingBuffer()
6200
6194
TEST (result == VK_SUCCESS);
6201
6195
6202
6196
TEST (stagingBufferAllocInfo.pMappedData != nullptr );
6203
- std::memcpy (stagingBufferAllocInfo.pMappedData , bufferData.data (), bufferData.size ());
6204
-
6205
- result = vmaFlushAllocation (g_hAllocator, uniformBufferAlloc, 0 , VK_WHOLE_SIZE);
6206
- TEST (result == VK_SUCCESS);
6197
+ vmaCopyMemoryToAllocation (g_hAllocator, bufferData.data (), stagingBufferAlloc, 0 , bufferData.size ());
6207
6198
6208
6199
BeginSingleTimeCommands ();
6209
6200
@@ -6243,7 +6234,7 @@ static void TestDataUploadingWithStagingBuffer()
6243
6234
}
6244
6235
6245
6236
static void TestDataUploadingWithMappedMemory () {
6246
- wprintf (L" Testing data uploading with mapped memory and memcpy ...\n " );
6237
+ wprintf (L" Testing data uploading with mapped memory...\n " );
6247
6238
6248
6239
// Generate some random data to fill the uniform buffer with.
6249
6240
const VkDeviceSize bufferSize = 65536 ;
@@ -6258,10 +6249,10 @@ static void TestDataUploadingWithMappedMemory() {
6258
6249
6259
6250
VmaAllocationCreateInfo uniformBufferAllocCI = {};
6260
6251
uniformBufferAllocCI.usage = VMA_MEMORY_USAGE_AUTO;
6261
- uniformBufferAllocCI.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT; // We want memory to be mapped so we can use memcpy to update it
6252
+ uniformBufferAllocCI.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT; // We want memory to be mapped.
6262
6253
6263
6254
VkBuffer uniformBuffer = VK_NULL_HANDLE;
6264
- VmaAllocation uniformBufferAlloc = {} ;
6255
+ VmaAllocation uniformBufferAlloc = VK_NULL_HANDLE ;
6265
6256
VmaAllocationInfo uniformBufferAllocInfo = {};
6266
6257
6267
6258
VkResult result = vmaCreateBuffer (g_hAllocator, &uniformBufferCI, &uniformBufferAllocCI, &uniformBuffer, &uniformBufferAlloc, &uniformBufferAllocInfo);
@@ -6273,11 +6264,7 @@ static void TestDataUploadingWithMappedMemory() {
6273
6264
TEST (memPropFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
6274
6265
6275
6266
TEST (uniformBufferAllocInfo.pMappedData != nullptr );
6276
- std::memcpy (uniformBufferAllocInfo.pMappedData , bufferData.data (), bufferData.size ());
6277
-
6278
- // We don't need to check for VK_MEMORY_PROPERTY_HOST_COHERENT_BIT because both vmaFlushAllocation and vmaInvalidateAllocation check for this internally.
6279
- result = vmaFlushAllocation (g_hAllocator, uniformBufferAlloc, 0 , VK_WHOLE_SIZE);
6280
- TEST (result == VK_SUCCESS);
6267
+ vmaCopyMemoryToAllocation (g_hAllocator, bufferData.data (), uniformBufferAlloc, 0 , bufferData.size ());
6281
6268
6282
6269
BeginSingleTimeCommands ();
6283
6270
@@ -6313,7 +6300,8 @@ static void TestAdvancedDataUploading() {
6313
6300
6314
6301
VmaAllocationCreateInfo uniformBufferAllocCI = {};
6315
6302
uniformBufferAllocCI.usage = VMA_MEMORY_USAGE_AUTO;
6316
- uniformBufferAllocCI.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_ALLOW_TRANSFER_INSTEAD_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT;
6303
+ uniformBufferAllocCI.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_ALLOW_TRANSFER_INSTEAD_BIT
6304
+ | VMA_ALLOCATION_CREATE_MAPPED_BIT;
6317
6305
6318
6306
VkBuffer uniformBuffer = VK_NULL_HANDLE;
6319
6307
VmaAllocation uniformBufferAlloc = {};
@@ -6326,13 +6314,9 @@ static void TestAdvancedDataUploading() {
6326
6314
vmaGetAllocationMemoryProperties (g_hAllocator, uniformBufferAlloc, &memPropFlags);
6327
6315
6328
6316
if (memPropFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) {
6329
- // The allocation ended up as mapped memory, meaning we can update it simply by using std::memcpy .
6317
+ // The allocation ended up as mapped memory.
6330
6318
TEST (uniformBufferAllocInfo.pMappedData != nullptr );
6331
- std::memcpy (uniformBufferAllocInfo.pMappedData , bufferData.data (), bufferData.size ());
6332
-
6333
- // We don't need to check for VK_MEMORY_PROPERTY_HOST_COHERENT_BIT because both vmaFlushAllocation and vmaInvalidateAllocation check for this internally.
6334
- result = vmaFlushAllocation (g_hAllocator, uniformBufferAlloc, 0 , VK_WHOLE_SIZE);
6335
- TEST (result == VK_SUCCESS);
6319
+ vmaCopyMemoryToAllocation (g_hAllocator, bufferData.data (), uniformBufferAlloc, 0 , bufferData.size ());
6336
6320
6337
6321
BeginSingleTimeCommands ();
6338
6322
@@ -6367,7 +6351,7 @@ static void TestAdvancedDataUploading() {
6367
6351
TEST (result == VK_SUCCESS);
6368
6352
6369
6353
TEST (stagingBufferAllocInfo.pMappedData != nullptr );
6370
- std::memcpy (stagingBufferAllocInfo. pMappedData , bufferData.data (), bufferData.size ());
6354
+ vmaCopyMemoryToAllocation (g_hAllocator , bufferData.data (), stagingBufferAlloc, 0 , bufferData.size ());
6371
6355
6372
6356
result = vmaFlushAllocation (g_hAllocator, uniformBufferAlloc, 0 , VK_WHOLE_SIZE);
6373
6357
TEST (result == VK_SUCCESS);
0 commit comments