nvpro-samples / vk_raytracing_tutorial_KHR

Ray tracing examples and tutorials using VK_KHR_ray_tracing
Apache License 2.0
1.34k stars 142 forks source link

Build Errors #30

Closed jruebsam closed 3 years ago

jruebsam commented 3 years ago

Hi, when using the latest master commit, I get a lot of the following build errors during compilation, e.g.:

/vk_raytracing_tutorial_KHR/ray_tracing__advance/main.cpp:344:45: error: cannot bind non-const lvalue reference of type ‘VkExtent2D&’ to an rvalue of type ‘VkExtent2D’ 344 | offscreen.draw(cmdBuf, helloVk.getSize());

Basically its always of the type `cannot bind non-const lvalue reference of type ... to an rvalue of type ... Any Idea how to fix this ? could this be linked to a different compiler setup or similar? (I don't know maybe my compiler does some kind of move semantics optimization.. )

Cheers

mklefrancois commented 3 years ago

This can actually be an error. A temporary can not bind to a non-const reference, therefore the signature of Offscreen.draw should be: void draw(VkCommandBuffer cmdBuf, const VkExtent2D& size);

Can you please verify that this change fixes it?

jruebsam commented 3 years ago

This indeed fixes it... there are a couple of more errors related to this. I would not mind to create a pull request which fixes this, just tell me what you would prefer.

Just keep in mind this also affects the nvpro-core/nvvk library in particular sbtwrapper_vk.hpp/cpp also need to be changed (since this is a different repository im not sure if this could break something anywhere else)

The function defintion in the header/src has to be changed from

std::array<VkStridedDeviceAddressRegionKHR, 4> getRegions(); to const std::array<VkStridedDeviceAddressRegionKHR, 4> getRegions();

Cheers

mklefrancois commented 3 years ago

Thanks @jruebsam for reporting this. I will also apply the fix for getRegion() in sbtWrapper. We do not develop in Github, therefore it would still be preferable if you list the errors here.

Could you please tell me which compiler you are using?

jruebsam commented 3 years ago

Sure no problem, this is g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

I also attached some of the linking options maybe it helps

cd /home/jonas/code/nvpro/vk_raytracing_tutorial_KHR/build/ray_tracing_gltf && /usr/bin/c++ -DLINUX -DNVP_SUPPORTS_VULKANSDK -DPROJECT_DOWNLOAD_RELDIRECTORY=\"../../downloaded_resources/\" -DPROJECT_NAME=\"vk_ray_tracing_gltf_KHR\" -DPROJECT_RELDIRECTORY=\"../../vk_raytracing_tutorial_KHR/ray_tracing_gltf/\" -DRESOURCE_DIRECTORY=\"/home/jonas/code/nvpro/nvpro_core/resources/\" -DVK_ENABLE_BETA_EXTENSIONS -DVK_USE_PLATFORM_XCB_KHR -DVK_USE_PLATFORM_XLIB_KHR -DVULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1 -I/home/jonas/code/nvpro/vk_raytracing_tutorial_KHR/build/ray_tracing_gltf -I/home/jonas/code/nvpro/vk_raytracing_tutorial_KHR/ray_tracing_gltf -I/home/jonas/code/nvpro/nvpro_core -I/home/jonas/code/nvpro/nvpro_core/imgui -I/home/jonas/code/nvpro/vk_raytracing_tutorial_KHR/common -I/home/jonas/code/nvpro/nvpro_core/third_party/cgltf -I/home/jonas/code/nvpro/nvpro_core/third_party/glfw/include -I/home/jonas/code/nvpro/nvpro_core/third_party/imgui -I/home/jonas/code/nvpro/nvpro_core/third_party/stb -I/home/jonas/code/nvpro/nvpro_core/third_party/tinygltf -I/home/jonas/code/nvpro/nvpro_core/third_party/tinyobjloader -I/home/jonas/code/nvpro/nvpro_core/third_party/vma/include -I/home/jonas/code/nvpro/nvpro_core/third_party/NVTX/c/include -O3 -DNDEBUG -fpermissive -std=gnu++17 -o CMakeFiles/vk_ray_tracing_gltf_KHR.dir/hello_vulkan.cpp.o -c /home/jonas/code/nvpro/vk_raytracing_tutorial_KHR/ray_tracing_gltf/hello_vulkan.cpp

jruebsam commented 3 years ago

Also this is the last error I get which is a little bit different:

vk_raytracing_tutorial_KHR/ray_tracing_advanced_compilation/hello_vulkan.cpp:1013:75: error: no matching function for call to ‘nvvk::SBTWrapper::create(VkPipeline_T*&, VkRayTracingPipelineCreateInfoKHR&, )’ 1013 | m_sbtWrapper.create(m_rtPipeline, rayPipelineInfo, {pipelineLibraryInfo});

mklefrancois commented 3 years ago

Hi @jruebsam, we have updated this repository as well as nvpro_core. Can you please confirm that the issues are gone?

Thanks

mklefrancois commented 3 years ago

We have tested on Ubuntu and it compiles. Closing.