-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
VulkanDeviceAlloc: Memorytype per slab #11744
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev
Previous commit
Additional logging
- Loading branch information
commit 46585a5da9a276499e78afdcf5d6ced311eef86d
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,7 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, int w, int h, int numMips, | |
VkResult res = vkCreateImage(vulkan_->GetDevice(), &image_create_info, NULL, &image_); | ||
if (res != VK_SUCCESS) { | ||
_assert_(res == VK_ERROR_OUT_OF_HOST_MEMORY || res == VK_ERROR_OUT_OF_DEVICE_MEMORY || res == VK_ERROR_TOO_MANY_OBJECTS); | ||
ELOG("vkCreateImage failed: %s", VulkanResultToString(res)); | ||
return false; | ||
} | ||
|
||
|
@@ -76,6 +77,8 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, int w, int h, int numMips, | |
if (allocator_) { | ||
offset_ = allocator_->Allocate(mem_reqs, &mem_, Tag()); | ||
if (offset_ == VulkanDeviceAllocator::ALLOCATE_FAILED) { | ||
vkDestroyImage(vulkan_->GetDevice(), image_, nullptr); | ||
ELOG("Image memory allocation failed (mem_reqs.size = %d)", (int)mem_reqs.size); | ||
return false; | ||
} | ||
} else { | ||
|
@@ -89,6 +92,7 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, int w, int h, int numMips, | |
|
||
res = vkAllocateMemory(vulkan_->GetDevice(), &mem_alloc, NULL, &mem_); | ||
if (res != VK_SUCCESS) { | ||
ELOG("vkAllocateMemory failed: %s", VulkanResultToString(res)); | ||
_assert_msg_(G3D, res != VK_ERROR_TOO_MANY_OBJECTS, "Too many Vulkan memory objects!"); | ||
_assert_(res == VK_ERROR_OUT_OF_HOST_MEMORY || res == VK_ERROR_OUT_OF_DEVICE_MEMORY || res == VK_ERROR_TOO_MANY_OBJECTS); | ||
vkDestroyImage(vulkan_->GetDevice(), image_, nullptr); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW, this one is also not necessary but at least clears |
||
|
@@ -101,6 +105,7 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, int w, int h, int numMips, | |
|
||
res = vkBindImageMemory(vulkan_->GetDevice(), image_, mem_, offset_); | ||
if (res != VK_SUCCESS) { | ||
ELOG("vkBindImageMemory failed: %s", VulkanResultToString(res)); | ||
// This leaks the image and memory. Should not really happen though... | ||
_assert_(res == VK_ERROR_OUT_OF_HOST_MEMORY || res == VK_ERROR_OUT_OF_DEVICE_MEMORY || res == VK_ERROR_TOO_MANY_OBJECTS); | ||
return false; | ||
|
@@ -144,6 +149,7 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, int w, int h, int numMips, | |
|
||
res = vkCreateImageView(vulkan_->GetDevice(), &view_info, NULL, &view_); | ||
if (res != VK_SUCCESS) { | ||
ELOG("vkCreateImageView failed: %s", VulkanResultToString(res)); | ||
// This leaks the image. | ||
_assert_(res == VK_ERROR_OUT_OF_HOST_MEMORY || res == VK_ERROR_OUT_OF_DEVICE_MEMORY || res == VK_ERROR_TOO_MANY_OBJECTS); | ||
return false; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Destroy is called in the destructor which already does this. We should at least clear
image_
, but I'm personally not a big fan of repeating WET cleanup code in every error case, so I try to design things so they auto-cleanup and the code is easier to read.-[Unknown]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WET? Yeah I see your point, I'll clean it up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We Enjoy Typing. The opposite of DRY.
-[Unknown]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah :)