mojoshader_vulkan.c
changeset 1315 c54ad4b34c03
parent 1304 d68910d81b6e
--- a/mojoshader_vulkan.c	Thu Oct 15 01:17:45 2020 -0400
+++ b/mojoshader_vulkan.c	Thu Oct 22 10:57:02 2020 -0400
@@ -47,6 +47,7 @@
     VkDeviceSize bufferSize;
     VkDeviceSize dynamicOffset;
     VkDeviceSize currentBlockSize;
+    VkDeviceSize currentBlockIncrement;
     uint8_t *mapPointer;
 } MOJOSHADER_vkUniformBuffer;
 
@@ -217,6 +218,7 @@
 
     result->bufferSize = UBO_ACTUAL_SIZE;
     result->currentBlockSize = 0;
+    result->currentBlockIncrement = 0;
     result->dynamicOffset = 0;
 
     return result;
@@ -298,9 +300,10 @@
         ubo = ctx->fragUboBuffer;
     } // else
 
-    ubo->dynamicOffset += ubo->currentBlockSize;
+    ubo->dynamicOffset += ubo->currentBlockIncrement;
 
     ubo->currentBlockSize = next_highest_offset_alignment(uniform_data_size(shader));
+    ubo->currentBlockIncrement = ubo->currentBlockSize;
 
     if (ubo->dynamicOffset + ubo->currentBlockSize >= ubo->bufferSize * ctx->frameIndex)
     {
@@ -783,9 +786,9 @@
     // Reset counters
     // Offset by size of buffer to simulate "rotating" the buffers
     ctx->vertUboBuffer->dynamicOffset = UBO_BUFFER_SIZE * ctx->frameIndex;
-    ctx->vertUboBuffer->currentBlockSize = 0;
+    ctx->vertUboBuffer->currentBlockIncrement = 0;
     ctx->fragUboBuffer->dynamicOffset = UBO_BUFFER_SIZE * ctx->frameIndex;
-    ctx->fragUboBuffer->currentBlockSize = 0;
+    ctx->fragUboBuffer->currentBlockIncrement = 0;
 } // MOJOSHADER_VkEndFrame
 
 int MOJOSHADER_vkGetVertexAttribLocation(MOJOSHADER_vkShader *vert,