Huge thanks for posting the code for each episode. After 10th episode I realized that its better to copy-paste code and understand it / refactor after.
01:06 That string parameter will be a copy. You generally want to avoid passing strings as copies. Same goes for the "readFile()" as well, pass them by "const&". That way you're passing 8 bytes (which is the size of a pointer or reference in a 64-bit program) instead of 40 bytes (size of the "std::string" class in the C++ implementation from msvc), or 32 bytes (in clang).
02:41 The "{}" does indeed "zero it out", but you're using the .hpp header, which if you look at the struct, it comes pre-zeroed out. So you don't really need to do that. But since you wrote: _vk::ShaderModuleCreateInfo moduleInfo = {};_ Now you really should initialize the 'sType' member variable of the struct. It needs value "16", not 0.
12:25 It was crashing because the 'filesize' variable in the "readFile()" function says it has the value "18446744073709551615". Because you're continuing running code past "!file.is_open()" - which fails. Which you really shouldn't be. What happens if it fails to open that file? 🤔 GOOD QUESTION. I chose to return a blank vector right then and there (and not under the 'debug' bool!). That way you at least get a Vulkan validation error saying that the shader source code shouldn't be zero, which is a bit more "sane" (I think) than some seemingly random crash in Microsoft's implementation of std::vector.
This series is quite inspiring !! Thank you so much, Andrew, for this deep dive into Vulkan API. Great job !!!
Huge thanks for posting the code for each episode. After 10th episode I realized that its better to copy-paste code and understand it / refactor after.
Thanks! I'd love to see what you come up with!
01:06 That string parameter will be a copy. You generally want to avoid passing strings as copies. Same goes for the "readFile()" as well, pass them by "const&". That way you're passing 8 bytes (which is the size of a pointer or reference in a 64-bit program) instead of 40 bytes (size of the "std::string" class in the C++ implementation from msvc), or 32 bytes (in clang).
02:41 The "{}" does indeed "zero it out", but you're using the .hpp header, which if you look at the struct, it comes pre-zeroed out. So you don't really need to do that.
But since you wrote: _vk::ShaderModuleCreateInfo moduleInfo = {};_
Now you really should initialize the 'sType' member variable of the struct. It needs value "16", not 0.
12:25 It was crashing because the 'filesize' variable in the "readFile()" function says it has the value "18446744073709551615".
Because you're continuing running code past "!file.is_open()" - which fails.
Which you really shouldn't be.
What happens if it fails to open that file? 🤔 GOOD QUESTION. I chose to return a blank vector right then and there (and not under the 'debug' bool!). That way you at least get a Vulkan validation error saying that the shader source code shouldn't be zero, which is a bit more "sane" (I think) than some seemingly random crash in Microsoft's implementation of std::vector.
awesome
🎉