I'm following the online tutorial: vulkan-tutorial where the author is adding in the functionality for Descriptor Pools and Descriptor Sets.
I'm using Vulkan v1.2.135.0
and my Shader's are set to #version 450
I'm nearly finished this part of the tutorial and I'm able to render a spinning square and I'm getting no errors from Vulkan Layers when I compile and run in Debug mode.
I'm near the bottom of the page provided by the link above where he introduces a glm::vec2
within the UniformBufferOjbect
struct and a vec2
within the same corresponding struct within shader.vert
.
He changed these:
// Defined in C++ file
struct UniformBufferObject {
glm::mat4 model;
glm::mat4 view;
glm::mat4 proj;
};
// Defined in shader.vert
layout(binding = 0) uniform UniformBufferObject {
mat4 model;
mat4 view;
mat4 proj;
} ubo;
To the following:
// Defined in C++ file
struct UniformBufferObject {
glm::vec2 foo;
glm::mat4 model;
glm::mat4 view;
glm::mat4 proj;
};
// Defined in shader.vert
layout(binding = 0) uniform UniformBufferObject {
vec2 foo;
mat4 model;
mat4 view;
mat4 proj;
} ubo;
I followed the example and recompiled the shader using the provided tool to convert it to an SPV
binary. And as he suggests there is nothing rendered on the screen as this has to do with memory-alignment
that Vulkan requires...
He briefly explains the memory alignment issues by stating how to fix this issue. There were two things he suggests doing... The first is to use C++11's or greater alignas(16)
modifier.
He then states that if we are to change our UniformBufferObject
to the following:
// Defined in C++ file
struct UniformBufferObject {
glm::vec2 foo;
alignas(16) glm::mat4 model;
glm::mat4 view;
glm::mat4 proj;
};
Then compile and run the program again that it should render correctly, however, I'm still getting a black screen.
He also suggests using glm
's #define GLM_FORCE_DEFAULT_ALIGNED_GENTYPES
directive before including its header files in which I did. It is still not rendering anything to the screen...
I even modified the UniformBufferObject
to:
// Defined in C++ file
struct UniformBufferObject {
glm::vec2 foo;
alignas(16) glm::mat4 model;
alignas(16) glm::mat4 view;
alignas(16) glm::mat4 proj;
};
And still, nothing is rendering. I don't know why this isn't working as suggested by the tutorial.