Skip to content

General improvements #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tutorial02_prebuild_layers/app/src/main/jni/TutorialValLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
11 changes: 6 additions & 5 deletions tutorial05_triangle/app/src/main/jni/VulkanMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,23 +377,23 @@ 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
VkDeviceMemory deviceMemory;
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);

Expand All @@ -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,
Expand Down
11 changes: 6 additions & 5 deletions tutorial06_texture/app/src/main/cpp/VulkanMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -702,23 +703,23 @@ 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
VkDeviceMemory deviceMemory;
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);

Expand Down