parent
a5c2a8e757
commit
adb0528184
2 changed files with 13 additions and 4 deletions
|
|
@ -137,6 +137,10 @@ void VirtualTexture::destroy()
|
|||
{
|
||||
vkFreeMemory(device, bind.memory, nullptr);
|
||||
}
|
||||
// Clean up mip tail
|
||||
if (mipTailimageMemoryBind.memory != VK_NULL_HANDLE) {
|
||||
vkFreeMemory(device, mipTailimageMemoryBind.memory, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -791,18 +795,21 @@ void VulkanExample::fillRandomPages()
|
|||
|
||||
void VulkanExample::fillMipTail()
|
||||
{
|
||||
// Clean up previous mip tail memory allocation
|
||||
if (texture.mipTailimageMemoryBind.memory != VK_NULL_HANDLE) {
|
||||
vkFreeMemory(device, texture.mipTailimageMemoryBind.memory, nullptr);
|
||||
}
|
||||
|
||||
//@todo: WIP
|
||||
VkDeviceSize imageMipTailSize = texture.sparseImageMemoryRequirements.imageMipTailSize;
|
||||
VkDeviceSize imageMipTailOffset = texture.sparseImageMemoryRequirements.imageMipTailOffset;
|
||||
// Stride between memory bindings for each mip level if not single mip tail (VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT not set)
|
||||
VkDeviceSize imageMipTailStride = texture.sparseImageMemoryRequirements.imageMipTailStride;
|
||||
|
||||
VkSparseImageMemoryBind mipTailimageMemoryBind{};
|
||||
|
||||
VkMemoryAllocateInfo allocInfo = vks::initializers::memoryAllocateInfo();
|
||||
allocInfo.allocationSize = imageMipTailSize;
|
||||
allocInfo.memoryTypeIndex = texture.memoryTypeIndex;
|
||||
VK_CHECK_RESULT(vkAllocateMemory(device, &allocInfo, nullptr, &mipTailimageMemoryBind.memory));
|
||||
VK_CHECK_RESULT(vkAllocateMemory(device, &allocInfo, nullptr, &texture.mipTailimageMemoryBind.memory));
|
||||
|
||||
uint32_t mipLevel = texture.sparseImageMemoryRequirements.imageMipTailFirstLod;
|
||||
uint32_t width = std::max(texture.width >> texture.sparseImageMemoryRequirements.imageMipTailFirstLod, 1u);
|
||||
|
|
|
|||
|
|
@ -42,13 +42,15 @@ struct VirtualTexture
|
|||
VkBindSparseInfo bindSparseInfo; // Sparse queue binding information
|
||||
std::vector<VirtualTexturePage> pages; // Contains all virtual pages of the texture
|
||||
std::vector<VkSparseImageMemoryBind> sparseImageMemoryBinds; // Sparse image memory bindings of all memory-backed virtual tables
|
||||
std::vector<VkSparseMemoryBind> opaqueMemoryBinds; // Sparse ópaque memory bindings for the mip tail (if present)
|
||||
std::vector<VkSparseMemoryBind> opaqueMemoryBinds; // Sparse opaque memory bindings for the mip tail (if present)
|
||||
VkSparseImageMemoryBindInfo imageMemoryBindInfo; // Sparse image memory bind info
|
||||
VkSparseImageOpaqueMemoryBindInfo opaqueMemoryBindInfo; // Sparse image opaque memory bind info (mip tail)
|
||||
uint32_t mipTailStart; // First mip level in mip tail
|
||||
VkSparseImageMemoryRequirements sparseImageMemoryRequirements; // @todo: Comment
|
||||
uint32_t memoryTypeIndex; // @todo: Comment
|
||||
|
||||
VkSparseImageMemoryBind mipTailimageMemoryBind{};
|
||||
|
||||
// @todo: comment
|
||||
struct MipTailInfo {
|
||||
bool singleMipTail;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue