vblanco20-1 / vulkan-guide

Introductory guide to vulkan.
https://vkguide.dev/
MIT License
940 stars 213 forks source link

fix incorrect way to calculate shader buffer size #44

Closed AnonN10 closed 3 years ago

AnonN10 commented 3 years ago

integer division rounds down, so it won't account for characters at the end of the file if they don't add up to a multiple of 4 bytes

charles-lunarg commented 3 years ago

If pCode is a pointer to SPIR-V code, codeSize must be a multiple of 4 https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkShaderModuleCreateInfo.html

There is no reason to worry about a buffer size not a multiple of 4, because Vulkan requires that the buffer is that way, otherwise its invalid spirv.

AnonN10 commented 3 years ago

it really isn't obvious from the specification that this is the case