diff --git a/tutorial02_prebuild_layers/app/src/main/jni/TutorialValLayer.cpp b/tutorial02_prebuild_layers/app/src/main/jni/TutorialValLayer.cpp index c4464a0..35902b0 100644 --- a/tutorial02_prebuild_layers/app/src/main/jni/TutorialValLayer.cpp +++ b/tutorial02_prebuild_layers/app/src/main/jni/TutorialValLayer.cpp @@ -63,23 +63,23 @@ static VkBool32 VKAPI_PTR vkDebugReportCallbackEX_impl( uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData) { if (flags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT) { - __android_log_print(ANDROID_LOG_INFO, "Vulkan Debug Message: ", "%s -- %s", + __android_log_print(ANDROID_LOG_INFO, "Vulkan-Debug-Message: ", "%s -- %s", pLayerPrefix, pMessage); } if (flags & VK_DEBUG_REPORT_WARNING_BIT_EXT) { - __android_log_print(ANDROID_LOG_WARN, "Vulkan Debug Message: ", "%s -- %s", + __android_log_print(ANDROID_LOG_WARN, "Vulkan-Debug-Message: ", "%s -- %s", pLayerPrefix, pMessage); } if (flags & VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT) { - __android_log_print(ANDROID_LOG_WARN, "Vulkan Debug Message (Perf): ", + __android_log_print(ANDROID_LOG_WARN, "Vulkan-Debug-Message-(Perf): ", "%s -- %s", pLayerPrefix, pMessage); } if (flags & VK_DEBUG_REPORT_ERROR_BIT_EXT) { - __android_log_print(ANDROID_LOG_ERROR, "Vulkan Debug Message: ", "%s -- %s", + __android_log_print(ANDROID_LOG_ERROR, "Vulkan-Debug-Message: ", "%s -- %s", pLayerPrefix, pMessage); } if (flags & VK_DEBUG_REPORT_DEBUG_BIT_EXT) { - __android_log_print(ANDROID_LOG_DEBUG, "Vulkan Debug Message: ", "%s -- %s", + __android_log_print(ANDROID_LOG_DEBUG, "Vulkan-Debug-Message: ", "%s -- %s", pLayerPrefix, pMessage); } diff --git a/tutorial03_traceable_layers/app/src/main/jni/TutorialValLayer.cpp b/tutorial03_traceable_layers/app/src/main/jni/TutorialValLayer.cpp index e02fe11..f1b9d07 100644 --- a/tutorial03_traceable_layers/app/src/main/jni/TutorialValLayer.cpp +++ b/tutorial03_traceable_layers/app/src/main/jni/TutorialValLayer.cpp @@ -64,23 +64,23 @@ static VkBool32 VKAPI_PTR vkDebugReportCallbackEX_impl( uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData) { if (flags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT) { - __android_log_print(ANDROID_LOG_INFO, "Vulkan Debug Message: ", "%s -- %s", + __android_log_print(ANDROID_LOG_INFO, "Vulkan-Debug-Message: ", "%s -- %s", pLayerPrefix, pMessage); } if (flags & VK_DEBUG_REPORT_WARNING_BIT_EXT) { - __android_log_print(ANDROID_LOG_WARN, "Vulkan Debug Message: ", "%s -- %s", + __android_log_print(ANDROID_LOG_WARN, "Vulkan-Debug-Message: ", "%s -- %s", pLayerPrefix, pMessage); } if (flags & VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT) { - __android_log_print(ANDROID_LOG_WARN, "Vulkan Debug Message (Perf): ", + __android_log_print(ANDROID_LOG_WARN, "Vulkan-Debug-Message-(Perf): ", "%s -- %s", pLayerPrefix, pMessage); } if (flags & VK_DEBUG_REPORT_ERROR_BIT_EXT) { - __android_log_print(ANDROID_LOG_ERROR, "Vulkan Debug Message: ", "%s -- %s", + __android_log_print(ANDROID_LOG_ERROR, "Vulkan-Debug-Message: ", "%s -- %s", pLayerPrefix, pMessage); } if (flags & VK_DEBUG_REPORT_DEBUG_BIT_EXT) { - __android_log_print(ANDROID_LOG_DEBUG, "Vulkan Debug Message: ", "%s -- %s", + __android_log_print(ANDROID_LOG_DEBUG, "Vulkan-Debug-Message: ", "%s -- %s", pLayerPrefix, pMessage); } diff --git a/tutorial05_triangle/app/src/main/jni/VulkanMain.cpp b/tutorial05_triangle/app/src/main/jni/VulkanMain.cpp index c1aa12a..8aa64f7 100644 --- a/tutorial05_triangle/app/src/main/jni/VulkanMain.cpp +++ b/tutorial05_triangle/app/src/main/jni/VulkanMain.cpp @@ -377,14 +377,14 @@ bool CreateBuffers(void) { VkMemoryAllocateInfo allocInfo{ .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .pNext = nullptr, - .allocationSize = sizeof(vertexData), + .allocationSize = memReq.size, .memoryTypeIndex = 0, // Memory type assigned in the next step }; // Assign the proper memory type for that buffer - allocInfo.allocationSize = memReq.size; MapMemoryTypeToIndex(memReq.memoryTypeBits, - VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, &allocInfo.memoryTypeIndex); // Allocate memory for the buffer @@ -392,8 +392,8 @@ bool CreateBuffers(void) { CALL_VK(vkAllocateMemory(device.device_, &allocInfo, nullptr, &deviceMemory)); void* data; - CALL_VK(vkMapMemory(device.device_, deviceMemory, 0, sizeof(vertexData), 0, - &data)); + CALL_VK(vkMapMemory(device.device_, deviceMemory, 0, allocInfo.allocationSize, + 0, &data)); memcpy(data, vertexData, sizeof(vertexData)); vkUnmapMemory(device.device_, deviceMemory); @@ -418,6 +418,7 @@ VkResult loadShaderFromFile(const char* filePath, VkShaderModule* shaderOut, char* fileContent = new char[fileLength]; AAsset_read(file, fileContent, fileLength); + AAsset_close(file); VkShaderModuleCreateInfo shaderModuleCreateInfo{ .sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, diff --git a/tutorial06_texture/app/src/main/cpp/VulkanMain.cpp b/tutorial06_texture/app/src/main/cpp/VulkanMain.cpp index d0197d6..20d6f52 100644 --- a/tutorial06_texture/app/src/main/cpp/VulkanMain.cpp +++ b/tutorial06_texture/app/src/main/cpp/VulkanMain.cpp @@ -401,6 +401,7 @@ VkResult LoadTextureFromFile(const char* filePath, size_t fileLength = AAsset_getLength(file); stbi_uc* fileContent = new unsigned char[fileLength]; AAsset_read(file, fileContent, fileLength); + AAsset_close(file); uint32_t imgWidth, imgHeight, n; unsigned char* imageData = stbi_load_from_memory( @@ -702,14 +703,14 @@ bool CreateBuffers(void) { VkMemoryAllocateInfo allocInfo{ .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .pNext = nullptr, - .allocationSize = sizeof(vertexData), + .allocationSize = memReq.size, .memoryTypeIndex = 0, // Memory type assigned in the next step }; // Assign the proper memory type for that buffer - allocInfo.allocationSize = memReq.size; MapMemoryTypeToIndex(memReq.memoryTypeBits, - VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, &allocInfo.memoryTypeIndex); // Allocate memory for the buffer @@ -717,8 +718,8 @@ bool CreateBuffers(void) { CALL_VK(vkAllocateMemory(device.device_, &allocInfo, nullptr, &deviceMemory)); void* data; - CALL_VK(vkMapMemory(device.device_, deviceMemory, 0, sizeof(vertexData), 0, - &data)); + CALL_VK(vkMapMemory(device.device_, deviceMemory, 0, allocInfo.allocationSize, + 0, &data)); memcpy(data, vertexData, sizeof(vertexData)); vkUnmapMemory(device.device_, deviceMemory);