Open utterances-bot opened 9 months ago
This is the feedback comment channel for Vk guide 2 Early Beta. The comments here will be removed once full release is done. If you find issues with the current version or typos, post here to report them.
Do you have any idea how i could set up this project for CLion?
The hyperlink "Initializing Vulkan" on Chapter0: Code Walkthrough leads to the old version.
1) I don't know if I did something wrong using the starting point or I missed some configuration that had to be done, but my engine project wasn't linked to "vkboostrap" so I coulnd't include the header or link with the .lib. I had to do it manually and the "project dependencies" thing didn't help either.
2) Something I never understood is this:
"By doing that = {}
thing, we are letting the compiler initialize the entire struct to zero. This is critical, as in general Vulkan structs will have their defaults set in a way that 0 is relatively safe. By doing that, we make sure we don’t leave uninitialized data in the struct."
If so, then that doesn't also mean that .pNext is already set to either 0 or nullptr, so it's pointless to set it?
3)Typos:
``" Extra "
"4) Initialization steps lack the hyperlink to the next step
I think it's a me problem :/
Or even better, "#include "fmt/printf.h"" and use "fmt::print("Error when building the compute shader\n");" instead of std::cout 8) "We are now ready to draw with it" needs a dot. 9) "Go back to the draw() function, we will replace the vkCmdClear with a compute shader invocation.": I guess you mean "draw_main()". 10) I got a linking error because "allocate" from DescriptorAllocator wasn't defined, I guess it's missing from 4). 11) I got an error when I tried to load a shader, because apparently it wasn't compiled. Even when I added "Shaders" to the project dependencies of "engine", it still didn't build. You have to go to "Configuration Manager" when you click "Debug/Release" and then tick "build" on the Shader project. Could be useful for other VS users. 12) I got a validation error about push constants because I was loading the wrong shader. " if (!vkutil::load_shader_module("../../shaders/gradient_color.comp.spv", _device, &computeDrawShader)) ": it's "gradient.comp.spv" not "gradient_color.comp.spv" 13) The validation error in the previous chapter about VkClear and draw Image is gone, but so far in this chapter the descriptor set/pool/set_layout are not deleted properly.
maybe?
Push Constants and new shaders: Two minor nitpicks: 1) In order to demostrate the awesomeness of imgui and the newest shader, I suggest this instead: "if (ImGui::Begin("Background")) { ComputeEffect& selected = backgroundEffects[currentBackgroundEffect];
ImGui::Text("Selected effect: ", selected.name);
ImGui::SliderInt("Effect Index", ¤tBackgroundEffect, 0, backgroundEffects.size() - 1); ImGui::ColorEdit4("Data1", reinterpret_cast<float>(&selected.data.data1)); ImGui::ColorEdit4("Data2", reinterpret_cast<float>(&selected.data.data2));
ImGui::End(); }"
2) I have a doubt, VS reports me that I'm using 275 MB whether I'm in release or debug mode. Is it normal? I'm not even loading meshes or textures :/
@MasterDrake, thanks for the reports, ill begin fixing all of those.
@MasterDrake, thanks for the reports, ill begin fixing all of those.
Have fun 😊 I'll continue tomorrow and see how it goes Thanks you so much for this, btw!!
@MasterDrake Ive tested it, my debug ram cost is also at 200+ MBs. seems like the cost just comes by initializing vulkan and its validation layers.
2) "fmt::print("Loading GLTF: {}.", filePath);"
3) "std::optional<std::vector<std::shared_ptr
4) "#include <fastgltf/parser.hpp>
Also "//needed for the fastgltf variants
template
5) Since we're using c++20, I'm not asking to use ranges for stuff like: " constexpr bool OverrideColors = false; if (OverrideColors) std::ranges::for_each(vertices, [](Vertex& vtx) { vtx.color = glm::vec4(vtx.normal, 1.f); });" But it would be cool to use if stataments with initializer like this: "if (auto normals = p.findAttribute("NORMAL"); normals != p.attributes.end()) if (auto uv = p.findAttribute("TEXCOORD_0"); uv != p.attributes.end()) if (auto colors = p.findAttribute("COLOR_0"); colors != p.attributes.end())" Reducing the scope isn't vital here, but it's a c++17-ism that's pretty neat IMO.
6) #include <glm/gtx/transform.hpp> when fixing the camera Y axis.
7) "Now we need to change the render pass begin info to use this depth attachment and clear it correctly.": specify that is in the draw_geometry() function.
8) "We made the depth option when the pipelinebuilder was made, buit left it dsiabled": "dsiabled" -> "disabled"
9) " std::vector
I wish you can name vulkan objects so the validation errors would be useful or should I say precise -.-
3) Mea culpa, I previously suggested to "poolSizes.resize(poolRatios.size());" in the DescriptorAllocatorGrowable::create_pool, but I obviously meant ".reserve" -.- I keep making this mistake even when I'm aware of this pitfall, grr
1) Scene node classes go into "vk_types.h".
2) Not sure whether you're supposed to use "auto& c : children" or "auto c : children" when using shared_ptrs, but you're using both approaches and it's confusing.
3) "MaterialInstance material;": "MaterialData has become MaterialInstance*.
4) "void MeshNode::Draw(const glm::mat4& topMatrix, DrawContext& ctx)" goes into "vk_engine.cpp"
5) So far, GeoSurface doesn't have a material, so "def.material = &s.material->data;" is an error.
6) "We are binding the data every draw which is inneficient but we will fix that later.": "inneficient"->"inefficient"
7) "std::unordered_map<std::string, shared_ptr<Node*>> loadedNodes;": should be std::shared_ptr
8) "loadedNodes[m.name] = std::move(newNode);": should be m->name.
9) "newNode->mesh = std::make_shared
10) For some messy reason, I didn't have "Cube" loaded so I crashed. I used a mesh I knew I had in my unordered_map(ehi, can we change it to martinus one and see how much is better) and it's huge so I'm not sure I'm doing ok :D Hopefully with the free camera... .Mantaining a project like this with so many refactors can become a pain in the ass. IMO, some of the deprecated stuff should be resolved before jumping to the next stage.
Before we begin loading everything, We are going to create some arrays to hold the structures. In GLTF files, everything works through indices, so we need a way to handle that . For example a mesh node will give the mesh index, not name or anything similar.
4) " loadedScenes["structure"]->Draw(glm::mat4{ 1.f }, drawCommands);": "drawCommands" should be "mainDrawContext".
5) I already said that but it needs a clean up since test meshes are still loaded and rendered.
6) It's needed "#include "vk_descriptors.h" in "vk_loaders.h" because of DescriptorAllocatorGrowable we just added.
7) "if (node->parent.get() == nullptr)": gives me an error that I can't understand and the source code is this: "if (node->parent.lock() == nullptr)"
8) Not gonna lie, this is a pretty big function we've got here and it's not over yet
Thank you so much!!
"We set queueFamilyIndex to the _graphicsQueueFamily that we grabbed before. This means that the command pool will create commands that are compatible with any queue of that “graphics” family."
Both the code in the lesson and the function and the function in vk_initializers.cpp don't actually set the queueFamilyIndex field.
VkCommandPoolCreateFlags flags /*= 0*/)
{
VkCommandPoolCreateInfo info = {};
info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
info.pNext = nullptr;
info.queueFamilyIndex = queueFamilyIndex;
info.flags = flags;
return info;
}```
By the way, thanks a ton for this updated guide! :)
1) My "LoadedGLTF::clearAll" is different from the one in your source code. Not to mention the pointless "samplersToDestroy" variable after the samplers are destroyed. Unless I'm missing something.
2) Apparently I don't have a "GPUGLTFMaterial" for the uniform buffer :/
3) I don't have an "AllocatedBuffer cameraBuffer" in FrameData
4) I don't have "EngineStats" as well, but that's not surprising.
5) I don't have " // the format for the draw image
VkFormat _drawFormat;"
6) you added "init_renderables" and got rid of "init_triangle_pipeline" and "init_mesh_pipeline"
7) there's not render_nodes() for me.
8) I don't have "std::vector
12) In the end I had to got rid of: " VkPipelineLayout _trianglePipelineLayout; VkPipeline _trianglePipeline; VkDescriptorSetLayout _singleImageDescriptorLayout;
MaterialData defaultData;
VkPipelineLayout _meshPipelineLayout; VkPipeline _meshPipeline;
std::vector<std::shared_ptr
I'm not ready for vk_engine.cpp :(
@MasterDrake most of those you have mentioned are never used, and its just dead code i havent fixed yet. you dont have to worry. Chapter 5 in particular is prone to that dead code because its the "original" code for the tutorial chapters, chapters 2 to 4 were made after it.
Yeah, I know nothing too fancy, but at least I'm done :D
I figure out why I coulnd't load the textures
It was missing this and apparently my vk_loader code is broken but I still missed the bug while file-diffing :( "#define STB_IMAGE_IMPLEMENTATION
in "vk_images.cpp" I hate these headers implementation
Finally!
Completely stuck at the Textures lesson, as soon as I set the _singleImageDescriptorSet to the _meshPipelineLayout.pSetLayouts field, the validation layer vomits this error and nothing renders
Validation Error: [ VUID-vkCmdDrawIndexed-None-02697 ] Object 0: handle = 0x3fbcd60000000028, type = VK_OBJECT_TYPE_PIPELINE; Object 1: VK_NULL_HANDLE, type = VK_OBJECT_TYPE_PIPELINE_LAYOUT; | MessageID = 0x9888fef3 | vkCmdDrawIndexed(): The VkPipeline 0x3fbcd60000000028[] (created with VkPipelineLayout 0xb097c90000000027[]) statically uses descriptor set (index #0) which is not compatible with the currently bound descriptor set's pipeline layout (VkPipelineLayout 0x0[]) The Vulkan spec states: For each set n that is statically used by the VkPipeline bound to the pipeline bind point used by this command, a descriptor set must have been bound to n at the same pipeline bind point, with a VkPipelineLayout that is compatible for set n, with the VkPipelineLayout used to create the current VkPipeline, as described in Pipeline Layout Compatibility (https://vulkan.lunarg.com/doc/view/1.3.239.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDrawIndexed-None-02697)
@mattwhitson The texture chapter had an error on the code snippets where the init_mesh_pipeline() is updated with the new descriptor set layout and new shaders. Check that chapter again as i just fixed it
If someone else also have problems with buffer device address (in my case vertices have wrong positions) try using alignas() for the vertex struct
@aer-i Did you modify the vertex struct? With the exact code shown in the guide, it should align exactly to what the GPU wants in the shader with std430 rules. If you didnt, what gpu did you use?
@vblanco20-1 Sorry, I should have mentioned that I have different vertex struct. Everything is fine, with alignment in the tutorial. I just tried moving to device address vertex buffer from normal vertex buffer, but then vertices broke in my game engine. I was a bit confused so I wanted to inform people with similar problem.
"void VulkanEngine::init_descriptors() { // other code
^code init_desc_2 chapter-2/vk_engine.cpp }"
Error on init_descriptors() fixed
follow "2 Drawing with Compute / Setting up IMGUI" of Vkguide2, the visual studio catch one error below, any advice can fix it? VulkanEngine initialized Assertion failed: GImGui != 0 && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?", file D:\vulkan-guide\third_party\imgui\imgui.cpp, line 4239
D:\vulkan-guide\bin\Debug\engine.exe (process 40164) exited with code 3.
@YanTree make sure you call init_imgui() from the main init() function of the engine, you likely missed it.
@vblanco20-1 oh! Right here, i missed call it, thx your advice.
For a Mac user, Vulkan is supported by the MoltenVK, which only support api_version 1.2;
Although the required extension dynamic rendering
and synchronization
is supported, but as KHR extensions.
In order to do that, use latest Volk is not that hard
add_subdirectory(volk) # complete repo of Volk, not existing one under third_party
#define VK_KHR_synchronization2
#define VK_NO_PROTOTYPES
3. add KHR suffix in all synchronization2 functions, structures.... eg:
VkImageMemoryBarrier2 imageBarrier{};
-------> VkImageMemoryBarrier2KHR imageBarrier{};
Emmmmm, could be a advice or a note for Mac users.
I followed the tutorial in the IMGUI chapter and found an error indicating that the setLayout was not closed after closing the program
Found a few issues so far in Section 2:
_mainDeletionQueue.push_function([&]() { vkDestroyDescriptorSetLayout(_device, _drawImageDescriptorLayout, nullptr); globalDescriptorAllocator.destroy_pool(_device); });
I got it to not complain with this code at the end of init_background_pipelines():
_mainDeletionQueue.push_function([&]() { vkDestroyPipelineLayout(_device, _gradientPipelineLayout, nullptr);
for (auto&& effect : backgroundEffects)
{
vkDestroyPipeline(_device, effect.pipeline, nullptr);
}
});
I modified the sky.comp compute shader by adding the constants:
layout (local_size_x = 16, local_size_y = 16) in; layout(rgba8,set = 0, binding = 0) uniform image2D image;
//push constants block layout( push_constant ) uniform constants { vec4 data1; vec4 data2; vec4 data3; vec4 data4; } PushConstants;
Then I changed the mainImage a little to make the sky change color + change the star density
void mainImage( out vec4 fragColor, in vec2 fragCoord ) { vec4 pushedData = PushConstants.data1; //new
vec2 iResolution = imageSize(image);
// Sky Background Color
vec3 vColor = pushedData.xyz * fragCoord.y / iResolution.y; //use the push constants
// Note: Choose fThreshhold in the range [0.99, 0.9999].
// Higher values (i.e., closer to one) yield a sparser starfield.
float StarFieldThreshhold = pushedData.w; //use the push constants
// Stars with a slow crawl.
float xRate = 0.2;
float yRate = -0.06;
vec2 vSamplePos = fragCoord.xy + vec2( xRate * float( 1 ), yRate * float( 1 ) );
float StarVal = StableStarField( vSamplePos, StarFieldThreshhold );
vColor += vec3( StarVal );
fragColor = vec4(vColor, 1.0);
}
Enjoying the tutorial so far!
To avoid crash when closing app (after Mesh Buffers section):
destroy_buffer(rectangle.indexBuffer);
destroy_buffer(rectangle.vertexBuffer);
});```
To avoid crash when closing app (after Mesh Buffers section):
_mainDeletionQueue.push_function([&]() {
destroy_buffer(rectangle.indexBuffer);
destroy_buffer(rectangle.vertexBuffer);
});```
Likewise, need to add delete stuff after Mesh Loading section:
_mainDeletionQueue.push_function([&]() {
for( auto&& meshAsset : testMeshes)
{
destroy_buffer(meshAsset->meshBuffers.indexBuffer);
destroy_buffer(meshAsset->meshBuffers.vertexBuffer);
}
});
One more minor cleanup tip - when exiting there is a high chance the current in flight frame will not have the _deletionQueue called. Added to cleanup():
//Make sure to flush all possible in flight frames
for (FrameData framedata : _frames)
{
framedata._deletionQueue.flush();
}
If you're trying to follow along on macOS then you've likely run into linker issues. Inserting this after the filrst call to target_link_libraries(vkbootstrap,...)
helped me:
target_link_libraries(vkbootstrap PUBLIC "iconv -framework AudioToolbox -framework Carbon -framework Cocoa -framework CoreFoundation -framework CoreGraphics -framework CoreHaptics -framework CoreAudio -framework CoreVideo -framework ForceFeedback -framework GameController -framework IOKit -framework Metal")
If I understand correctly, some vma memory usage flags, such as VMA_MEMORY_USAGE_GPU_ONLY, are deprecated. This link contains more info: https://gpuopen-librariesandsdks.github.io/VulkanMemoryAllocator/html/deprecated.html
I just finished chapter 2
I don't know what causes it or if it is reproducible for anyone else. I noticed this in my own version of the code (starting from the starting point project an adding stuff as I go) and then I built the chapter-2 code in the all-chapters project and the same thing happens
If anyone has the time can you check if you get the same issue from RenderDoc? I've spent the whole day trying to debug it and didn't get anywhere
- Vulkan Guide
Practical guide to vulkan graphics programming
https://www.vkguide.dev/docs/new_vkguide/chapter_1/vulkan_mainloop/