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);
|
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()
|
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
|
//@todo: WIP
|
||||||
VkDeviceSize imageMipTailSize = texture.sparseImageMemoryRequirements.imageMipTailSize;
|
VkDeviceSize imageMipTailSize = texture.sparseImageMemoryRequirements.imageMipTailSize;
|
||||||
VkDeviceSize imageMipTailOffset = texture.sparseImageMemoryRequirements.imageMipTailOffset;
|
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)
|
// 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;
|
VkDeviceSize imageMipTailStride = texture.sparseImageMemoryRequirements.imageMipTailStride;
|
||||||
|
|
||||||
VkSparseImageMemoryBind mipTailimageMemoryBind{};
|
|
||||||
|
|
||||||
VkMemoryAllocateInfo allocInfo = vks::initializers::memoryAllocateInfo();
|
VkMemoryAllocateInfo allocInfo = vks::initializers::memoryAllocateInfo();
|
||||||
allocInfo.allocationSize = imageMipTailSize;
|
allocInfo.allocationSize = imageMipTailSize;
|
||||||
allocInfo.memoryTypeIndex = texture.memoryTypeIndex;
|
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 mipLevel = texture.sparseImageMemoryRequirements.imageMipTailFirstLod;
|
||||||
uint32_t width = std::max(texture.width >> texture.sparseImageMemoryRequirements.imageMipTailFirstLod, 1u);
|
uint32_t width = std::max(texture.width >> texture.sparseImageMemoryRequirements.imageMipTailFirstLod, 1u);
|
||||||
|
|
|
||||||
|
|
@ -42,13 +42,15 @@ struct VirtualTexture
|
||||||
VkBindSparseInfo bindSparseInfo; // Sparse queue binding information
|
VkBindSparseInfo bindSparseInfo; // Sparse queue binding information
|
||||||
std::vector<VirtualTexturePage> pages; // Contains all virtual pages of the texture
|
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<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
|
VkSparseImageMemoryBindInfo imageMemoryBindInfo; // Sparse image memory bind info
|
||||||
VkSparseImageOpaqueMemoryBindInfo opaqueMemoryBindInfo; // Sparse image opaque memory bind info (mip tail)
|
VkSparseImageOpaqueMemoryBindInfo opaqueMemoryBindInfo; // Sparse image opaque memory bind info (mip tail)
|
||||||
uint32_t mipTailStart; // First mip level in mip tail
|
uint32_t mipTailStart; // First mip level in mip tail
|
||||||
VkSparseImageMemoryRequirements sparseImageMemoryRequirements; // @todo: Comment
|
VkSparseImageMemoryRequirements sparseImageMemoryRequirements; // @todo: Comment
|
||||||
uint32_t memoryTypeIndex; // @todo: Comment
|
uint32_t memoryTypeIndex; // @todo: Comment
|
||||||
|
|
||||||
|
VkSparseImageMemoryBind mipTailimageMemoryBind{};
|
||||||
|
|
||||||
// @todo: comment
|
// @todo: comment
|
||||||
struct MipTailInfo {
|
struct MipTailInfo {
|
||||||
bool singleMipTail;
|
bool singleMipTail;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue