nvk-struct-cache
🍣 A Rollup plugin for automated Structure caching for node-vulkan
Imagine the following situation:
let commandBuffers = ...Array8;for let ii = 0; ii < commandBufferslength; ++ii let commandBufferBeginInfo = ; ;;This results in 8 allocations of VkCommandBufferBeginInfo structures. When this code gets executed in frequently used code sections, the heap pressure will be high.
Now nvk has a mechanism to simulate stack allocation:
let commandBuffers = ...Array8;for let ii = 0; ii < commandBufferslength; ++ii let commandBufferBeginInfo = ; // 0x0 inserted by this package ;;On the first iteration of the loop, a VkCommandBufferBeginInfo structure is allocated on the heap but also gets cached internally. Whenever this code gets executed again, the cached structure will be used instead of a new one.
Install
Using npm:
npm install nvk-struct-cache --save-devUsage
Create a rollup.config.js configuration file and import the plugin:
; input: "src/index.mjs" output: file: "./bundle.js" format: "cjs" plugins: ;