-
Notifications
You must be signed in to change notification settings - Fork 191
Descriptor Heap alignment #378
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
Open
spencer-lunarg
wants to merge
1
commit into
KhronosGroup:main
Choose a base branch
from
spencer-lunarg:spencer-lunarg-heap-alignment
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+49
−2
Open
Changes from all commits
Commits
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
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -28,7 +28,7 @@ Here is a example of what a "descriptor" could look like: | |
|
|
||
| It is **not important** at all to the developer what the binary data of a descriptor means. | ||
|
|
||
| What **is important** is understanding that unlike Vulkan 1.0, the driver is now just handing you back an opaque, variable sized, internal data structure. | ||
| What **is important** is understanding that unlike Vulkan 1.0, the driver is now just handing you back an opaque, variable sized, internal data structure. | ||
|
|
||
| Instead of having a `VkDescriptorSet` object the driver controls, the application is now responsible to manage that this data is at the correct spot in memory for the GPU to read from. | ||
|
|
||
|
|
@@ -446,6 +446,41 @@ we would use that size as an array stride inside the heap. | |
|
|
||
| image::{images}descriptor_heap_untyped_stride.svg[descriptor_heap_untyped_stride.svg] | ||
|
|
||
| == Alignment | ||
|
|
||
| One of the hardest issues making an application portal across vendors is mastering the art of alignment. | ||
|
|
||
| === Binding the heap | ||
|
|
||
| If you want to bind somewhere inside your heap memory, you will want to be aware of the `resourceHeapAlignment` and `samplerHeapAlignment`. | ||
|
|
||
| image::{images}descriptor_heap_bind_alignment.svg[descriptor_heap_bind_alignment.svg] | ||
|
|
||
| [NOTE] | ||
| ==== | ||
| The spec allows these alignments to be as high as 64k, but currently seems to at most | ||
| link:https://vulkan.gpuinfo.org/displayextensionproperty.php?extensionname=VK_EXT_descriptor_heap&extensionproperty=resourceHeapAlignment&platform=all[64] | ||
| or | ||
| link:https://vulkan.gpuinfo.org/displayextensionproperty.php?extensionname=VK_EXT_descriptor_heap&extensionproperty=samplerHeapAlignment&platform=all[32] | ||
| on most devices. | ||
| ==== | ||
|
|
||
| === Descriptor alignment | ||
|
|
||
| For each descriptor accessed the `samplerDescriptorAlignment`, `imageDescriptorAlignment`, and `bufferDescriptorAlignment` are important. | ||
|
|
||
| The nice part is the spec requires that the `descriptorAlignment` is less than or equal to the `*descriptorSize`, so you are always able to tightly pack an array of descriptors together. | ||
|
|
||
| The two main times you can get in trouble with alignment. | ||
|
|
||
| First is when you set the offset to the descriptor wrong. | ||
|
|
||
| image::{images}descriptor_heap_offset_alignment.svg[descriptor_heap_offset_alignment.svg] | ||
|
|
||
| Second is when you do descriptor indexing that are non-packed (strided). | ||
|
|
||
| image::{images}descriptor_heap_stride_alignment.svg[descriptor_heap_stride_alignment.svg] | ||
|
Contributor
Author
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. .... ok, so I need to update this the issue I guess is really if the data from something PushData creates a bad address |
||
|
|
||
| == Combined Image Samplers | ||
|
|
||
| The `VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER` is a special descriptor and deserves it's own mention if you are planning to use it with `VK_EXT_descriptor_heap`. | ||
|
|
@@ -458,6 +493,6 @@ If you are using the binding mappings, you will see the `samplerHeapOffset` and | |
|
|
||
| [NOTE] | ||
| ==== | ||
| It is confusing at first that when using `VK_DESCRIPTOR_TYPE_SAMPLER` you use the `heapOffset` to set the offset in the Sampler heap. | ||
| It is confusing at first that when using `VK_DESCRIPTOR_TYPE_SAMPLER` you use the `heapOffset` to set the offset in the Sampler heap. | ||
| But when using `VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER` the `heapOffset` is for the Resource heap and the `samplerHeapOffset` is for the Sampler heap. | ||
| ==== | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
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.
portal=>portable?