Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
Vulkan render to OpenGL texture
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Antonio Ospite
Vulkan render to OpenGL texture
Commits
adb05281
Commit
adb05281
authored
3 years ago
by
Sascha Willems
Browse files
Options
Downloads
Patches
Plain Diff
Proper mip tail memory cleanup
Refs #882
parent
a5c2a8e7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/texturesparseresidency/texturesparseresidency.cpp
+10
-3
10 additions, 3 deletions
examples/texturesparseresidency/texturesparseresidency.cpp
examples/texturesparseresidency/texturesparseresidency.h
+3
-1
3 additions, 1 deletion
examples/texturesparseresidency/texturesparseresidency.h
with
13 additions
and
4 deletions
examples/texturesparseresidency/texturesparseresidency.cpp
+
10
−
3
View file @
adb05281
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
examples/texturesparseresidency/texturesparseresidency.h
+
3
−
1
View file @
adb05281
...
...
@@ -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
o
paque 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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment