<commit_before>---
layout: post
title: A "Bind Once" Approach to Uniform Data
categories:
- blog
- tutorial
- vulkan
tags:
- <span style="background-color:#AA2222;"><font color="white">&nbsp;Vulkan</font></span>
---

After figuring out how to use a global [array of textures](http://127.0.0.1:4000/blog/tutorial/vulkan/2018/01/28/Textue-Arrays-Vulkan.html) to store all the textures that are in use for a frame in a single descriptor set, I returned to my [material system project](https://github.com/khalladay/VkMaterialSystem) and realized how much easier life would be if I could do all my descriptor set binding at the beginning of a frame, both because I'd avoid any performance overhead from doing lots of binding, and because it greatly simplifies anything related to descriptor set versioning (or dealing with updating buffers that are in flight).

As it turns out, this is totally possible and really easy to do, although I have no idea if it's a good idea in the grand scheme of things. Also, just like using an array of textures, I couldn't find anyone else writing about, so I guess that means it's on me to share.

<div align="center">
<img src="/images/post_images/2018-02-05/badideas.jpg" />
<br><br>
</div>
So with all that said, this post is going to show off how to use a single, globally bound descriptor set (and a single VkBuffer!) to store all the uniform data needed for multiple objects that are using different shaders.
<commit_msg>fixed link typo<commit_after>---
layout: post
title: A "Bind Once" Approach to Uniform Data
categories:
- blog
- tutorial
- vulkan
tags:
- <span style="background-color:#AA2222;"><font color="white">&nbsp;Vulkan</font></span>
---

After figuring out how to use a global [array of textures](http://kylehalladay.com/blog/tutorial/vulkan/2018/01/28/Textue-Arrays-Vulkan.html) to store all the textures that are in use for a frame in a single descriptor set, I returned to my [material system project](https://github.com/khalladay/VkMaterialSystem) and realized how much easier life would be if I could do all my descriptor set binding at the beginning of a frame, both because I'd avoid any performance overhead from doing lots of binding, and because it greatly simplifies anything related to descriptor set versioning (or dealing with updating buffers that are in flight).

As it turns out, this is totally possible and really easy to do, although I have no idea if it's a good idea in the grand scheme of things. Also, just like using an array of textures, I couldn't find anyone else writing about, so I guess that means it's on me to share.

<div align="center">
<img src="/images/post_images/2018-02-05/badideas.jpg" />
<br><br>
</div>
So with all that said, this post is going to show off how to use a single, globally bound descriptor set (and a single VkBuffer!) to store all the uniform data needed for multiple objects that are using different shaders.

{'fraction_non_alphanumeric': 0.08122001370801919, 'fraction_numerical': 0.017135023989033583, 'mean_word_length': 4.517958412098299, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3012136', 'n_tokens_mistral': 835, 'n_tokens_neox': 774, 'n_words': 420}