Giter Site home page Giter Site logo

nvpro-samples / vk_raytracing_tutorial_khr Goto Github PK

View Code? Open in Web Editor NEW
1.3K 36.0 134.0 19.79 MB

Ray tracing examples and tutorials using VK_KHR_ray_tracing

License: Apache License 2.0

CMake 3.80% C++ 70.76% GLSL 21.65% C 3.78%
raytracing vulkan tutorial

vk_raytracing_tutorial_khr's Introduction

logo

NVIDIA Vulkan Ray Tracing Tutorials

resultRaytraceShadowMedieval

The focus of this repository and the provided code is to showcase a basic integration of ray tracing and ray traversal within an existing Vulkan sample, using the VK_KHR_acceleration_structure, VK_KHR_ray_tracing_pipeline and VK_KHR_ray_query extensions.

Setup

To be able to compile and run those examples, please follow the setup instructions. Find more over nvpro-samples setup at: https://github.com/nvpro-samples/build_all.

Tutorials

The first tutorial starts from a very simple Vulkan application. It loads a OBJ file and uses the rasterizer to render it. The tutorial then adds, step-by-step, all that is needed to be able to ray trace the scene.


Ray Tracing Tutorial: ▶️ Start Here ◀️


Extra Tutorials

All other tutorials start from the end of the first ray tracing tutorial and also provide step-by-step instructions to modify and add methods and functions for that extra section.

Tutorial Details
small Any Hit Shader
Implements transparent materials by adding a new shader to the Hit group and using the material information to discard hits over time. Adds an anyhit (.ahit) shader to the ray tracing pipeline. Creates simple transparency by randomly letting the ray hit or not.
small Jitter Camera
Anti-aliases the image by accumulating small variations of rays over time. Generates random ray directions. Read/write/accumulates the final image.
img Thousands of Objects
The current example allocates memory for each object, each of which has several buffers. This shows how to get around Vulkan's limits on the total number of memory allocations by using a memory allocator. Extends the limit of 4096 memory allocations. Uses these memory allocators: DMA, VMA.
img Reflections
Reflections can be implemented by shooting new rays from the closest hit shader, or by iteratively shooting them from the raygen shader. This example shows the limitations and differences of these implementations. Calls traceRayEXT() from the closest hit shader (recursive). Adds more data to the ray payload to continue the ray from the raygen shader.
img Multiple Closest Hits Shader and Shader Records
Explains how to add more closest hit shaders, choose which instance uses which shader, add data per SBT that can be retrieved in the shader, and more. One closest hit shader per object. Sharing closest hit shaders for some objects. Passing a shader record to the closest hit shader.
img Animation
This tutorial shows how animating the transformation matrices of the instances (TLAS) and animating the vertices of an object (BLAS) in a compute shader could be done. Refitting top level acceleration structures. Refitting bottom level acceleration structures.
img Intersection Shader
Adds thousands of implicit primitives and uses an intersection shader to render spheres and cubes. Explains what is needed to get procedural hit group working. Intersection Shaders. Sphere intersection. Axis aligned bounding box intersection.
img Callable Shader
Replacing if/else by callable shaders. The code to execute the lighting is done in separate callable shaders instead of being part of the main code. Adding multiple callable shaders. Calling ExecuteCallableEXT from the closest hit shader.
img Ray Query
Invokes ray intersection queries directly from the fragment shader to cast shadow rays. Ray tracing directly from the fragment shader.
img glTF Scene
Instead of loading separate OBJ objects, the example was modified to load glTF scene files containing multiple objects. This example is not about shading, but using more complex data than OBJ. However, it also shows a basic path tracer implementation.
img Advance
An example combining most of the above samples in a single application.
img Trace Rays Indirect
Teaches the use of vkCmdTraceRaysIndirectKHR, which sources width/height/depth from a buffer. As a use case, we add lanterns to the scene and use a compute shader to calculate scissor rectangles for each of them.
img AO Raytracing
This extension to the tutorial is showing how G-Buffers from the fragment shader, can be used in a compute shader to cast ambient occlusion rays using ray queries (GLSL_EXT_ray_query).
img Specialization Constants
Showing how to use specialization constant and using interactively different specialization.
img Advanced Compilation
Shows how to create reusable pipeline libraries and compile pipelines on multiple threads.
img Motion Blur
Using vertex motion and instance motion: matrix and SRT.

vk_raytracing_tutorial_khr's People

Contributors

fuxiii avatar k1ngst0m avatar kirill146 avatar konstantinseurer avatar mklefrancois avatar mousechannel avatar nbickford-nv avatar nvmheyer avatar pgautron avatar pixeljetstream avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vk_raytracing_tutorial_khr's Issues

Ask for a help!

I got a result like that:

[gfxrecon] ERROR - CmdBuildAccelerationStructureKHR encoding is not supported
ERROR: VUID-vkCmdBuildAccelerationStructureKHR-commandBuffer-parameter
 --> Validation Error: [ VUID-vkCmdBuildAccelerationStructureKHR-commandBuffer-parameter ] Object 0: handle = 0x1f733928b50, type = VK_OBJECT_TYPE_INSTANCE; | MessageID = 0x1922f32 | Invalid VkCommandBuffer Object 0x1f746a5be90. The Vulkan spec states: commandBuffer must be a valid VkCommandBuffer handle (https://vulkan.lunarg.com/doc/view/1.2.148.0/windows/1.2-extensions/vkspec.html#VUID-vkCmdBuildAccelerationStructureKHR-commandBuffer-parameter)
 Object[0] - Type Instance, Value 000001F733928B50, Name "(null)"
ERROR: VUID-VkAccelerationStructureBuildGeometryInfoKHR-dstAccelerationStructure-parameter
 --> Validation Error: [ VUID-VkAccelerationStructureBuildGeometryInfoKHR-dstAccelerationStructure-parameter ] Object 0: handle = 0x1f733928b50, type = VK_OBJECT_TYPE_INSTANCE; | MessageID = 0x45e8716f | Invalid VkAccelerationStructureKHR Object 0x1f744948b90. The Vulkan spec states: dstAccelerationStructure must be a valid VkAccelerationStructureKHR handle (https://vulkan.lunarg.com/doc/view/1.2.148.0/windows/1.2-extensions/vkspec.html#VUID-VkAccelerationStructureBuildGeometryInfoKHR-dstAccelerationStructure-parameter)
 Object[0] - Type Instance, Value 000001F733928B50, Name "(null)"

and what I have known is that the bug exists in the 228 lines of the "raytraceKHR_vk.hpp"! Could you provide some assistance to me?
Best regards!

Error in hello-vulkan during compilation

Dear All,
I am trying to compile Vulkan ray-tracing samples (vk_raytracing_tutorial_KHR) on Ubuntu and constantly receive an error like the below for ray_tracing__advance tutorial (gcc version 8.4):

[ 27%] Building CXX object ray_tracing__advance/CMakeFiles/vk_ray_tracing__advance_KHR.dir/hello_vulkan.cpp.o
In file included from ../vk_raytracing_tutorial_KHR/ray_tracing__advance/hello_vulkan.cpp:31:
.../vk_raytracing_tutorial_KHR/ray_tracing__advance/hello_vulkan.h:90:3: error: braces around scalar initializer for type ‘float’
};
^
make[2]: *** [ray_tracing__advance/CMakeFiles/vk_ray_tracing__advance_KHR.dir/build.make:138: ray_tracing__advance/CMakeFiles/vk_ray_tracing__advance_KHR.dir/hello_vulkan.cpp.o] Error 1

The problem seems to be in PushConstantRaster m_pcRaster (https://github.com/nvpro-samples/vk_raytracing_tutorial_KHR/issues/new?permalink=https%3A%2F%2Fgithub.com%2Fnvpro-samples%2Fvk_raytracing_tutorial_KHR%2Fblob%2F596b641a5687307ee9f58193472e8b620ce84189%2Fray_tracing__advance%2Fhello_vulkan.h%23L81), that is
// Push constant structure for the raster
struct PushConstantRaster
{
mat4 modelMatrix; // matrix of the instance
vec3 lightPosition;
uint objIndex;
vec3 lightDirection;
float lightSpotCutoff;
float lightSpotOuterCutoff;
float lightIntensity;
int lightType;
int frame;
};

Troubles combining intersection and gltf tutorials

Hi,

Starting somewhere around the end of the intersection tutorial, I had a go at switching to gltf support based on the related tutorial and while I got pretty close, have been stuck on a bug for a while now. I've tried just about everything I can think of so thought I'd ask for some suggestions, based on the symptoms. This is my test project.

Basically, the intersection shader's hit values now see completely off. You can see my issue in the following gifs:

vk_raytrace_bug

The following is a simplified scene, loading the Box.gltf file (red), and then an implicit object to the left and right:

vk_raytrace_bug_simplified

You can see where the implicit objects actually are if I modify the intersection shader to always call reportIntersectionEXT with some positive hit distance. Here it is with the bug (hit distance is going negative when it shouldn't):

image

And here it is when I hack it to use reportIntersectionEXT(abs(tHit), hitKind);:

image

Some notes:

  • there is one gltf file that is actually working fine (Suzanne.gltf), which I don't understand how that can be while all other gltf files I've tried throw things out of whack.
  • I thought my change in HelloVulkan::createTopLevelAS() to account for the gltf scene sometimes having a different number of nodes versus meshes might be the culprit, but I can't find any proof of this yet.
  • There's some nbObj + 1 business going on in the ray_tracing_intersection tutorial that completely went away in the ray_tracing_gltftutorial and as far as I can tell isn't accounted for, this was my best guess at what is going on wrong, although I opted to just remove the material buffers from my raytrace2.rchit and just create them on the fly to simplify things.

So, not sure what next to look at. All I know is that the tHit value in the intersection shader is reporting < 0 when it shouldn't. Does this ring any bells, or any ideas what I can try?

Thanks so much again for the awesome tutorial series!

ray_tracing_ao crashes when Nsight is used

I've tried to get a better understanding of the ray_tracing_ao example by examining the sample in Nsight (version 2022.4.1), however the application crashes on compute pipeline creation. I tried launching Nsight from VS 2022 as well as independently.

Minidump file 18c783f7-5489-4713-a27c-e26c5ef30ee7.zip

Reason: EXCEPTION_ACCESS_VIOLATION_READ
Address: 0xffffffffffffffff
Assertion: Unknown assertion type 0x00000000

Thread 0 (crashed)
[0] nvoglv64.dll + 0x8661e
[1] nvoglv64.dll + 0x142644d
[2] nvoglv64.dll + 0x14589c2
[3] nvoglv64.dll + 0x92aa2
[4] nvoglv64.dll + 0xa9430
[5] nvoglv64.dll + 0xa34f0
[6] nvoglv64.dll + 0x29d67a0
[7] nvoglv64.dll + 0xa2a86
[8] nvoglv64.dll + 0xe2d901
[9] nvoglv64.dll + 0x695aa
[10] nvoglv64.dll + 0x69383
[11] nvoglv64.dll + 0x11378f

Thread 1
[0] ntdll.dll + 0xa0994
[1] ntdll.dll + 0x52dc7

Thread 2
[0] ntdll.dll + 0xa0994
[1] ntdll.dll + 0x52dc7

Thread 3
[0] ntdll.dll + 0xa0994
[1] ntdll.dll + 0x52dc7

Thread 4
[0] ntdll.dll + 0x9d064
[1] KERNELBASE.dll + 0x61a7f
[2] ntdll.dll + 0x507b0
[3] Nvda.Graphics.Interception.dll + 0x3eb4e20
[4] ntdll.dll + 0x25ba1
[5] Nvda.Graphics.Interception.dll + 0x2a83400
[6] Nvda.Graphics.Interception.dll + 0x42e8100
[7] ntdll.dll + 0x247b1
[8] ucrtbase.dll + 0xf05b
[9] Nvda.Graphics.Interception.dll + 0x3002dd7
[10] Nvda.Graphics.Interception.dll + 0x42e8100
[11] Nvda.Graphics.Interception.dll + 0x30036fe
[12] Nvda.Graphics.Interception.dll + 0x3003c95
[13] ntdll.dll + 0x302c9
[14] Nvda.Graphics.Interception.dll + 0x3f01750
[15] Nvda.Graphics.Interception.dll + 0x3bd1d50
[16] Nvda.Graphics.Interception.dll + 0x300388a
[17] Nvda.Graphics.Interception.dll + 0x30030f3
[18] Nvda.Graphics.Interception.dll + 0x2bd1f20
[19] Nvda.Graphics.Interception.dll + 0x2bd1f2f
[20] Nvda.Graphics.Interception.dll + 0x2b02d18
[21] Nvda.Graphics.Interception.dll + 0x2bd1f05
[22] Nvda.Graphics.Interception.dll + 0x4abc668
[23] Nvda.Graphics.Interception.dll + 0x2bd1f20
[24] Nvda.Graphics.Interception.dll + 0x4abc668
[25] KERNELBASE.dll + 0x76601
[26] Nvda.Graphics.Interception.dll + 0x2bd2c0a
[27] ucrtbase.dll + 0x21bb2
[28] kernel32.dll + 0x17034
[29] ntdll.dll + 0x52651

Thread 5
[0] ntdll.dll + 0x9da94
[1] KERNELBASE.dll + 0x4cbc0
[2] ntdll.dll + 0x52630

Thread 6
[0] ntdll.dll + 0xa0994
[1] ntdll.dll + 0x52dc7

Thread 7
[0] ntdll.dll + 0xa0994
[1] ntdll.dll + 0x52dc7

Thread 8
[0] ntdll.dll + 0x9da94
[1] KERNELBASE.dll + 0x4cbc0
[2] ucrtbase.dll + 0x15efa
[3] CoreMessaging.dll + 0xa2461
[4] CoreMessaging.dll + 0xa2464
[5] inputhost.dll + 0x135b98
[6] inputhost.dll + 0xbb20
[7] inputhost.dll + 0xb3eb
[8] CoreMessaging.dll + 0xa246d
[9] CoreMessaging.dll + 0x18a78
[10] CoreMessaging.dll + 0x160f4
[11] inputhost.dll + 0x2f4e
[12] CoreMessaging.dll + 0xa7ff0
[13] inputhost.dll + 0xb3eb
[14] CoreMessaging.dll + 0x18a78
[15] CoreMessaging.dll + 0x160f4
[16] Nvda.Graphics.Interception.dll + 0x28f8db4
[17] Nvda.Graphics.Interception.dll + 0x2b78438
[18] CoreMessaging.dll + 0x3cd53
[19] CoreMessaging.dll + 0x17fff
[20] CoreMessaging.dll + 0x1f6b6
[21] CoreMessaging.dll + 0x14cf5
[22] CoreMessaging.dll + 0x17ce9
[23] CoreMessaging.dll + 0x17471
[24] CoreMessaging.dll + 0x58921
[25] CoreMessaging.dll + 0x1b35a
[26] CoreMessaging.dll + 0x3d0dd
[27] CoreMessaging.dll + 0x16744
[28] CoreMessaging.dll + 0x18100
[29] CoreMessaging.dll + 0x1c04a
[30] CoreMessaging.dll + 0xb28d8
[31] CoreMessaging.dll + 0x1996b
[32] CoreMessaging.dll + 0x111a8
[33] ntdll.dll + 0x247b1
[34] CoreMessaging.dll + 0x30312
[35] CoreMessaging.dll + 0x1ae80
[36] CoreMessaging.dll + 0x458af
[37] CoreMessaging.dll + 0x16c28
[38] CoreMessaging.dll + 0x587f3
[39] CoreMessaging.dll + 0x12198
[40] inputhost.dll + 0xebcc0
[41] CoreMessaging.dll + 0x4ebf5
[42] CoreMessaging.dll + 0x4da7b
[43] msvcp_win.dll + 0xf7e2
[44] inputhost.dll + 0x125aa
[45] inputhost.dll + 0x167f9
[46] kernel32.dll + 0x17034
[47] ntdll.dll + 0x52651

Thread 9
[0] ntdll.dll + 0x9da94
[1] KERNELBASE.dll + 0x4cbc0

Thread 10
[0] ntdll.dll + 0xa0994
[1] ntdll.dll + 0x52dc7

Thread 11
[0] ntdll.dll + 0x9cfc4
[1] KERNELBASE.dll + 0x21ace
[2] Nvda.Graphics.Interception.dll + 0x28f8db4
[3] ntdll.dll + 0x247b1
[4] Nvda.Graphics.Interception.dll + 0x2b785e2
[5] Nvda.Graphics.Interception.dll + 0x2b78508
[6] nvoglv64.dll + 0x125e57a
[7] nvoglv64.dll + 0xdc6e80
[8] nvoglv64.dll + 0xdc65ba
[9] nvoglv64.dll + 0x1212c52
[10] nvoglv64.dll + 0xdc7e78
[11] kernel32.dll + 0x17034
[12] ntdll.dll + 0x52651

Thread 12
[0] ntdll.dll + 0x9cfc4
[1] KERNELBASE.dll + 0x21ace
[2] Nvda.Graphics.Interception.dll + 0x28f8db4
[3] nvoglv64.dll + 0xe2d97e
[4] Nvda.Graphics.Interception.dll + 0x2b785e2
[5] nvoglv64.dll + 0xdc5514
[6] nvoglv64.dll + 0x122c1be
[7] Nvda.Graphics.Interception.dll + 0x2b78508
[8] nvoglv64.dll + 0x122ddd0
[9] nvoglv64.dll + 0xdc65ba
[10] nvoglv64.dll + 0x122f4e2
[11] nvoglv64.dll + 0xdc7e78
[12] kernel32.dll + 0x17034
[13] ntdll.dll + 0x52651

Thread 13
[0] ntdll.dll + 0x9cfc4
[1] KERNELBASE.dll + 0x21ace
[2] Nvda.Graphics.Interception.dll + 0x28f8db4
[3] nvoglv64.dll + 0xe2d97e
[4] Nvda.Graphics.Interception.dll + 0x2b785e2
[5] nvoglv64.dll + 0xdc5514
[6] nvoglv64.dll + 0xe6457b
[7] Nvda.Graphics.Interception.dll + 0x2b78508
[8] nvoglv64.dll + 0xe61f8a
[9] nvoglv64.dll + 0xdc65ba
[10] nvoglv64.dll + 0x121dca2
[11] nvoglv64.dll + 0xa59d6c
[12] nvoglv64.dll + 0xdc7e78
[13] kernel32.dll + 0x17034
[14] ntdll.dll + 0x52651

Thread 14
[0] ntdll.dll + 0x9da94
[1] KERNELBASE.dll + 0x4cbc0
[2] ntdll.dll + 0x19877
[3] nvrtum64.dll + 0x28685a
[4] nvrtum64.dll + 0x286e29
[5] ntdll.dll + 0x19aae
[6] ntdll.dll + 0x19a26
[7] ntdll.dll + 0x3e683
[8] nvrtum64.dll + 0x89450
[9] ntdll.dll + 0x5d964
[10] ntdll.dll + 0x16c4d0
[11] ntdll.dll + 0x51d9c
[12] nvrtum64.dll + 0x89450
[13] ntdll.dll + 0x17955
[14] ntdll.dll + 0x16c4d0
[15] ntdll.dll + 0x51748
[16] ntdll.dll + 0x1a8fc
[17] ntdll.dll + 0x172000
[18] ntdll.dll + 0x174a24
[19] ntdll.dll + 0x147648
[20] ntdll.dll + 0x69706
[21] Nvda.Graphics.Interception.dll + 0x28f8db4
[22] ntdll.dll + 0x69552
[23] ntdll.dll + 0x25ba1
[24] Nvda.Graphics.Interception.dll + 0x2b78438
[25] ntdll.dll + 0x515e2
[26] ntdll.dll + 0x32228
[27] Nvda.Graphics.Interception.dll + 0x28f8db4
[28] KERNELBASE.dll + 0x4cabe
[29] KERNELBASE.dll + 0x687fb
[30] Nvda.Graphics.Interception.dll + 0x2b7835d
[31] apphelp.dll + 0xe4ec
[32] ntdll.dll + 0x301a7
[33] nvcuda64.dll + 0x28ee83
[34] nvcuda64.dll + 0x1e4754
[35] kernel32.dll + 0x17034
[36] ntdll.dll + 0x52651
[37] ntdll.dll + 0x334f1
[38] nvcuda64.dll + 0x55a1b8
[39] ntdll.dll + 0x302c9
[40] kernel.appcore.dll + 0x3100
[41] nvcuda64.dll + 0x52bb4e
[42] ntdll.dll + 0x3e25f
[43] kernel.appcore.dll + 0x3100
[44] nvcuda64.dll + 0x52bb4e
[45] Nvda.Graphics.Interception.dll + 0x28f8de4
[46] nvcuda64.dll + 0x1f4086
[47] nvcuda64.dll + 0x79832
[48] nvcuda64.dll + 0x28f2dd
[49] nvcuda64.dll + 0x1e4123
[50] nvcuda64.dll + 0x520404
[51] kernel32.dll + 0x17034
[52] ntdll.dll + 0x52651

Thread 15
[0] win32u.dll + 0xa104
[1] user32.dll + 0x2078e
[2] Nvda.Graphics.Interception.dll + 0x2b77a78
[3] user32.dll + 0xe703
[4] Nvda.Graphics.Interception.dll + 0x2b77998
[5] user32.dll + 0x4f551
[6] nvoglv64.dll + 0xdbedcf
[7] kernel32.dll + 0x17034
[8] ntdll.dll + 0x52651

CMakeLists linker is missing libdl

cd vk_raytracing_tutorial_KHR
mkdir build
cd build
cmake ..
make -j 40

Compiles shared sources successfully, fails during the linking step:

[100%] Linking CXX executable /home/chris/ray-tracing/bin_x64/vk_ray_tracing__advance_NV.exe
/usr/bin/ld: CMakeFiles/vk_ray_tracing_anyhit_NV.dir/hello_vulkan.cpp.o: undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
/usr/bin/ld: /usr/lib64/libdl.so.2: error adding symbols: DSO missing from command line

libdl is installed via glibc-devel

Installed Packages
glibc-devel.x86_64  2.32-1.fc33

I think that the fix is going to be adding:

-ldl 

Somewhere in a CMakeLists target_link_library; I'll try that, and post the fix (if I get it working).

ray_tracing_ao crash

on my win7 x64 pc , with the Vulkan SDK 1.2.162.1 with Visual Studio 2019 Debug x64
when I run the ray_tracing_ao demo,
it crash at: void HelloVulkan::createCompPipelines()
VkResult res = vkCreateComputePipelines(m_device, {}, 1, &cpCreateInfo, nullptr, &m_compPipeline);

in this function ,it crashes.

VK_ERROR_LAYER_NOT_PRESENT on GTX1060

Hi, I tried all ray tracing samples, and vkCreateInstance always return error message "VK_ERROR_LAYER_NOT_PRESENT". Please help. Thanks in advance. Below is my environment:

  • GTX1060, driver 460.89
  • Vulkan SDK 1.2.162
  • Win10 pro 64
  • VS 2019

Build issue with VS2019

Using the vulkan driver, latest Vulkan-Headers and glslang, as the tutorial mentions, I am seeing the following errors in all projects:

1>------ Build started: Project: vk_ray_tracing__simple_KHR, Configuration: Debug x64 ------
1>hello_vulkan.cpp
1>D:\Programming\Vulkan\shared_sources\nvvkpp/pipeline_vkpp.hpp(91,1): error C2440: 'return': cannot convert from 'vk::ResultValuevk::Pipeline' to 'vk::Pipeline'
1>D:\Programming\Vulkan\shared_sources\nvvkpp/pipeline_vkpp.hpp(91,1): message : No constructor could take the source type, or constructor overload resolution was ambiguous

VK_BUFFER_USAGE_STORAGE_BUFFER_BIT for vertices and indices buffer

In 6.1 Additions to the Scene Descriptor Set :

Originally the buffers containing the vertices and indices were only used by the rasterization pipeline. The ray tracing will need to use those buffers as storage buffers, so we add VK_BUFFER_USAGE_STORAGE_BUFFER_BIT.

Why we need add VK_BUFFER_USAGE_STORAGE_BUFFER_BIT when create vertices buffer and indices buffer? In most cases, the vertices and indices data will not change. Use VK_BUFFER_USAGE_STORAGE_BUFFER_BIT usually want save data from device, which data should save from device into vertices buffer and indices buffer?

Couple minor issues / improvements possible

Hi, I noticed the command buffers are only enabled in debug builds, here:

#ifdef _DEBUG
for(size_t i = 0; i < m_commandBuffers.size(); i++)
{
std::string name = std::string("AppBase") + std::to_string(i);
m_device.setDebugUtilsObjectNameEXT(
{vk::ObjectType::eCommandBuffer, reinterpret_cast<const uint64_t&>(m_commandBuffers[i]), name.c_str()});
}
#endif // _DEBUG

whereas the rest of the code adds the names in Release too. I'd remove the #ifdef _DEBUG and use the appropriate DebugUtils function for command buffers, like this:

for(size_t i = 0; i < m_commandBuffers.size(); i++)
{
std::string name = std::string("AppBase") + std::to_string(i);
m_debug.setObjectName(m_commandBuffers[i], name);
}

This util function also checks s_enabled whereas the above code doesn't.

A couple other places I've noticed are redundant in the KHR basic sample, like one could call setViewport from AppBase (passing in the command buffer ref) instead of manually calling setViewPort/setScissors combo each time.

There are some other general things I could suggest, like renaming all the individual HelloVK classes to reflect the name of their respective samples, get rid of all the static variables, put the context struct as a member variable in the base class, with the derived class setting the required extensions during a virtual init method...this way you could build all the samples with unique class names and stuff them all in a single project, and even switch between them at runtime like the older DX11 samples do, so you can skim through all the samples individually in a single session. It would also make sure all the init / deinit stuff is done properly as you switch sessions, or even re-use the same base vulkan context and only init / reinit stuff for the derived classes, unless the required extensions are different.

I don't understand why both the Nvpro and Vulkan C samples use HelloVK as the class name for each sample. Call the sample's what it is and what it does explicitly (E.g. RayTracingBasic), and keep all their specific state / extensions in the class itself since that's the point of using classes, to encapsulate the requirements so it's self-contained. IMO it's not ideal to set the extensions externally the context prior to initializing it. I also prefer not duplicating raw pointers like m_device.setup(device) in various places, and instead pass references to what's needed in any member vars. Duplicating raw pointers to things can lead to double deinit errors, whereas if you pass a ref to a constructor in each member var that needs those things (like m_debug or m_device), you know they're all accessing the same base vulkan pointers everywhere and there's no chance of them being modified.

Just a few suggestions, take'em or leave'em! Btw great job on the VK debug functionality with NSight Graphics, super polished and easy to use.

Second rmiss shader defined too early in the tutorial

Second miss shader, which will later be used for shadows, is already declared in the step 7.1. I assume this is not intended as the number of miss shaders is set to 1 and its enum (eMiss2) is not defined at the time.

[question] why is the output of ray_tracing_gltf so noisy

Hi,
one quick questsion.
If I run the binary of the ray_tracing_gltf, I get a pretty noisy output.
If I understand it correctly it is normal to get a noisy Image with realtime raytracing. But why isn't the output of the other tutorials also noisy?

CMake can't find BASE_DIRECTORY

When I run CMake on the root folder of the repository, I get the following error:

CMake Error at CMakeLists.txt:27 (Message):
could not find base directory, please set BASE_DIRECTORY to folder
containing shared_sources

Spec says hitAttributeEXT should have two components, not three

https://github.com/KhronosGroup/GLSL/blob/master/extensions/ext/GLSL_EXT_ray_tracing.txt#L348

For the case of triangle geometry with no custom intersection shaders, any-hit and
closest-hit shaders can access barycentric weights of the point of intersection of
ray with triangle by declaring a hitAttributeEXT variable of two 32-bit floating
point elements

Incorrect srcStageMask in vkCmdPipelineBarrier in ray_tracing_ao

In ray_tracing_ao, g-buffer is drawn in fragment shader and sampled in compute shader. Between both shaders there is a pipeline barrier. According to vulkan specs, the srcStageMask should be VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT instead of VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT which may cause corruption sometimes.

VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT specifies the stage of the pipeline after blending where the final color values are output from the pipeline. This stage also includes subpass load and store operations, multisample resolve operations for framebuffer attachments with a color or depth/stencil format, and vkCmdClearAttachments.

vkCmdPipelineBarrier(cmdBuf, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,

The tutorial page is blank

When trying to "Start the tutorial" it takes you to a blank page with a "(insert vkrt_tutorial.md.html here)" message.
image

Fix raytrace.rgen in ray_tracing__advance

According to ray_tracing_jitter_cam, we should write directly to the image if the frame number is equal to 0 in "raytrace.rgen".
ray_tracing_jitter_cam_shaders_raytrace rgen
However, there is an equal sign in "raytrace.rgen" of ray_tracing__advance, which may cause corruption.
ray_tracing__advance_shaders_raytrace rgen

vk_raytracing_tutorial_KHR/docs/setup.md has wrong directory structure

Perhaps at some point shared_external and shared_sources were expected to be outside of vk_raytracing_tutorial_KHR but that is no longer the case.

They should be inside vk_raytracing_tutorial_KHR as cmake will otherwise fail.

Also cmake mandates that the arch be specified as 64-bit explicitly (i.e. cmake -G "Visual Studio 15 2017 Win64" in vk_raytracing_tutorial_KHR). Otherwise, it will fail.

I'm just asking that the documents be updated to reflect this as I had to go through all of this in order to produce the project files.

Thanks!

Fix your tutorial please

There are so many errors in you starter tutorial which link to the nv raytracing extension and not to the khr extension.
There are also steps missing which cause a lot of frustration (e.g. updating the descriptor sets when updating the camera struct or modifying the closetHit shader). Fortunately the ray_tracing__simple example works perfectly so you can just compare what's missing.

ray_tracing_motionblur: Validation error

Using Vulkan sdk 1.3.216, RTX 3070Ti (516.94) on windows 10, I am getting the following message:

ERROR: VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext
 --> Validation Error: [ VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext ] Object 0: handle = 0x27b882ea480, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xf69d66f5 | vkGetAccelerationStructureBuildSizesKHR: value of pInfos[0].pGeometries[0].geometry.triangles.pNext must be NULL. This error is based on the Valid Usage documentation for version 216 of the Vulkan header.  It is possible that you are using a struct from a private extension or an extension that was added to a later version of the Vulkan header, in which case the use of pInfos[0].pGeometries[0].geometry.triangles.pNext is undefined and may not work correctly with validation enabled The Vulkan spec states: pNext must be NULL or a pointer to a valid instance of VkAccelerationStructureGeometryMotionTrianglesDataNV (https://vulkan.lunarg.com/doc/view/1.3.216.0/windows/1.3-extensions/vkspec.html#VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext)
ERROR: VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext
 --> Validation Error: [ VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext ] Object 0: handle = 0x27b882ea480, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xf69d66f5 | vkCmdBuildAccelerationStructuresKHR: value of pInfos[0].pGeometries[0].geometry.triangles.pNext must be NULL. This error is based on the Valid Usage documentation for version 216 of the Vulkan header.  It is possible that you are using a struct from a private extension or an extension that was added to a later version of the Vulkan header, in which case the use of pInfos[0].pGeometries[0].geometry.triangles.pNext is undefined and may not work correctly with validation enabled The Vulkan spec states: pNext must be NULL or a pointer to a valid instance of VkAccelerationStructureGeometryMotionTrianglesDataNV (https://vulkan.lunarg.com/doc/view/1.3.216.0/windows/1.3-extensions/vkspec.html#VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext)
ERROR: VUID-VkShaderModuleCreateInfo-pCode-04146
 --> Validation Error: [ VUID-VkShaderModuleCreateInfo-pCode-04146 ] Object 0: handle = 0x27b882ea480, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xd80a42ae | vkCreateShaderModule(): A SPIR-V Extension (SPV_NV_ray_tracing_motion_blur) was declared that is not supported by Vulkan. The Vulkan spec states: pCode must not declare any SPIR-V extension that is not supported by the API, as described by the Extension section of the SPIR-V Environment appendix (https://vulkan.lunarg.com/doc/view/1.3.216.0/windows/1.3-extensions/vkspec.html#VUID-VkShaderModuleCreateInfo-pCode-04146)

Output seems ok:
image

Runtime error in creating swapchain on Tesla T4

When I try to run the samples in nsight sdk as well without nsight on cloud GPU (Tesla T4) with driver version 528.89 and Vulkan sdk version 1.3.250.1, I get following errors

Exception thrown at 0x00007FFD9C16D94F (nvoglv64.dll) in vk_ray_tracing__simple_KHR.exe: 0xC0000005: Access violation reading location 0x00007FFE01774300.

This exception comes while creating swapchain vkCreateSwapchainKHR

ray_tracing_intersection - says add hitAttributeEXT to raytrace.rint but it's not there

Hi,

I've been following these tutorials and first off wanted to say thanks so much! They are an excellent way to learn about this pretty sophisticated domain.

I wanted to point out something that has me scratching my head in the ray_tracing_intersection tutorial - it mentions the need for the following line in this section:

hitAttributeEXT vec3 HitAttribute;

However I don't see it in the intersection shader, hitAttributeEXT is only used within the closest hit shader. Is this an artifact of the previous version of the spec?

Thanks again for the great tutorials,
Rich

GLFW Not Found

I tried to build the binaries like described in the tutorial with cloning the repositories:

git clone https://github.com/nvpro-samples/shared_sources.git 
git clone https://github.com/nvpro-samples/shared_external.git 
git clone https://github.com/nvpro-samples/vk_raytracing_tutorial_KHR.git

and build with

cd vk_raytracing_tutorial_KHR
mkdir build
cd build
cmake ..

The Cmake configuration looks fine for me (if necessary I can add it)
However when cd'ing into build directory and building with make I always get the error:

make[2]: *** No rule to make target 'glfw-NOTFOUND', needed by '/home/.../code/nvray/build_all/bin_x64/Release/vk_ray_tracing__before_KHR.exe'.  Stop.

I'm not sure whats happening here, beside the GLFW lib/headers in shared_external, I also have a system wide install of libglfw3. System is Ubuntu 20.04. Not sure what I'm missing here, thank you for any suggestions...

Why did the QUADRO P620 support raytrace?

CUDA+OPTIX can support Quadro p620 to do raytracing with PBRT written by Matt Pharr. Maybe you do not belong to the same team
but why not ask Matt Pharr for a solution?

Could NOT find VulkanSDK (missing: VULKAN_LIB VULKANSDK_SHADERC_LIB)

Hi guys,

I am trying to get started with the raytracing tutorial. I cloned the repos and try to run cmake .. inside of the build dir. I get the following error:

C:\Users\olive\source\repos\vk_raytracing_tutorial_KHR\build>cmake ..
-- BASE_DIRECTORY = /cygdrive/c/Users/olive/source/repos
-- CMAKE_CURRENT_SOURCE_DIR = /cygdrive/c/Users/olive/source/repos/vk_raytracing_tutorial_KHR
-- Vulkan Library        : VULKAN_LIB-NOTFOUND
-- Vulkan ShaderC Library: VULKANSDK_SHADERC_LIB-NOTFOUND
-- VULKANSDK_ROOT_DIR = C:/VulkanSDK/1.3.250.0
CMake Error at /usr/share/cmake-3.23.2/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find VulkanSDK (missing: VULKAN_LIB VULKANSDK_SHADERC_LIB)
Call Stack (most recent call first):
  /usr/share/cmake-3.23.2/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /cygdrive/c/Users/olive/source/repos/nvpro_core/cmake/find/FindVulkanSDK.cmake:175 (find_package_handle_standard_args)
  /cygdrive/c/Users/olive/source/repos/nvpro_core/cmake/setup.cmake:375 (find_package)
  CMakeLists.txt:34 (_add_package_VulkanSDK)


-- Configuring incomplete, errors occurred!
See also "/cygdrive/c/Users/olive/source/repos/vk_raytracing_tutorial_KHR/build/CMakeFiles/CMakeOutput.log".
See also "/cygdrive/c/Users/olive/source/repos/vk_raytracing_tutorial_KHR/build/CMakeFiles/CMakeError.log".

Content of the Error Log:

Detecting C compiler ABI info failed to compile with the following output:
Change Dir: /cygdrive/c/Users/olive/source/repos/vk_raytracing_tutorial_KHR/build/CMakeFiles/CMakeTmp

Run Build Command(s):/cygdrive/c/ProgramData/chocolatey/bin/make.exe -f Makefile cmTC_be15f/fast && C:/ProgramData/chocolatey/lib/make/tools/install/bin/make.exe  -f CMakeFiles/cmTC_be15f.dir/build.make CMakeFiles/cmTC_be15f.dir/build
make[1]: Entering directory 'C:/Users/olive/source/repos/vk_raytracing_tutorial_KHR/build/CMakeFiles/CMakeTmp'
make[1]: *** No rule to make target '/usr/share/cmake-3.23.2/Modules/CMakeCCompilerABI.c', needed by 'CMakeFiles/cmTC_be15f.dir/CMakeCCompilerABI.c.o'.  Stop.
make[1]: Leaving directory 'C:/Users/olive/source/repos/vk_raytracing_tutorial_KHR/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:127: cmTC_be15f/fast] Error 2




Detecting CXX compiler ABI info failed to compile with the following output:
Change Dir: /cygdrive/c/Users/olive/source/repos/vk_raytracing_tutorial_KHR/build/CMakeFiles/CMakeTmp

Run Build Command(s):/cygdrive/c/ProgramData/chocolatey/bin/make.exe -f Makefile cmTC_df34b/fast && C:/ProgramData/chocolatey/lib/make/tools/install/bin/make.exe  -f CMakeFiles/cmTC_df34b.dir/build.make CMakeFiles/cmTC_df34b.dir/build
make[1]: Entering directory 'C:/Users/olive/source/repos/vk_raytracing_tutorial_KHR/build/CMakeFiles/CMakeTmp'
make[1]: *** No rule to make target '/usr/share/cmake-3.23.2/Modules/CMakeCXXCompilerABI.cpp', needed by 'CMakeFiles/cmTC_df34b.dir/CMakeCXXCompilerABI.cpp.o'.  Stop.
make[1]: Leaving directory 'C:/Users/olive/source/repos/vk_raytracing_tutorial_KHR/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:127: cmTC_df34b/fast] Error 2

I installed the latest VulkanSDK and also got it running with some simple triangle demo code.

Kind regards,
Oliver

Errata: NVIDIA Vulkan Ray Tracing Tutorial: 5 Acceleration Structure

Thank you for this thorough tutorial. I have found the following errors in the introductory section to chapter 5:

nvvk::RaytracingBuilder m_rtBuilder; -> nvvk::RaytracingBuilderKHR m_rtBuilder;

m_rtBuilder.setup(m_device, m_alloc, m_graphicsQueueIndex); -> m_rtBuilder.setup(m_device, &m_alloc, m_graphicsQueueIndex);

What does Nb mean?

When I read is tutorial some code, such like:

uint32_t maxPrimitiveCount = model.nbIndices / 3;
triangles.maxVertex = model.nbVertices;
uint32_t nbCompactions{0};   // Nb of BLAS requesting compaction

The nb in code nbIndices, nbVertices and nbCompactions.

What does nb mean?

issue on win10 when cmake

cmake ..
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
-- The C compiler identification is MSVC 19.38.33134.0
-- The CXX compiler identification is MSVC 19.38.33134.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done


-- Processing Project vk_ray_tracing__before_KHR:
CMake Error at CMakeLists.txt:20 (_add_project_definitions):
Unknown CMake command "_add_project_definitions".

-- Configuring incomplete, errors occurred!

Build Errors

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

Invalid trace opcode.

Driver wrongly uses SpvOpTraceNV opcode instead of SpvOpTraceRayKHR.

SpvOpTraceRayKHR opcode causes driver crash:
#0  0x00007ffff1f0bc08 in ?? () from /usr/lib/x86_64-linux-gnu/libnvidia-glvkspirv.so.455.46.02
#1  0x00007ffff1dc9600 in ?? () from /usr/lib/x86_64-linux-gnu/libnvidia-glvkspirv.so.455.46.02
#2  0x00007ffff1dcdac5 in ?? () from /usr/lib/x86_64-linux-gnu/libnvidia-glvkspirv.so.455.46.02

It looks like the SPIR-V compiler generates an invalid opcode for traceRayKHR().

Error with Validating layers

After following this link https://nvpro-samples.github.io/vk_raytracing_tutorial_KHR/ I get these errors:

Vulkan Version:
 - available:  1.2.141
 - requesting: 1.2.0
___________________________
Available Instance Layers :
VK_LAYER_NV_optimus (v. 1.2.142 1) : NVIDIA Optimus layer
VK_LAYER_VALVE_steam_overlay (v. 1.2.136 1) : Steam Overlay Layer
VK_LAYER_VALVE_steam_fossilize (v. 1.2.136 1) : Steam Pipeline Caching Layer
VK_LAYER_OBS_HOOK (v. 1.2.131 1) : Open Broadcaster Software hook
VK_LAYER_OBS_HOOK (v. 1.2.131 1) : Open Broadcaster Software hook
VK_LAYER_EOS_Overlay (v. 1.2.136 1) : Vulkan overlay layer for Epic Online Services
VK_LAYER_EOS_Overlay (v. 1.2.136 1) : Vulkan overlay layer for Epic Online Services
VK_LAYER_NV_nsight-sys (v. 1.1.97 2) : NVIDIA Nsight Systems profiler layer
VK_LAYER_LUNARG_gfxreconstruct (v. 1.2.162 9005) : GFXReconstruct Capture Layer Version 0.9.5

Available Instance Extensions :
VK_KHR_device_group_creation (v. 1)
VK_KHR_external_fence_capabilities (v. 1)
VK_KHR_external_memory_capabilities (v. 1)
VK_KHR_external_semaphore_capabilities (v. 1)
VK_KHR_get_physical_device_properties2 (v. 2)
VK_KHR_get_surface_capabilities2 (v. 1)
VK_KHR_surface (v. 25)
VK_KHR_surface_protected_capabilities (v. 1)
VK_KHR_win32_surface (v. 6)
VK_EXT_debug_report (v. 9)
VK_EXT_debug_utils (v. 2)
VK_EXT_swapchain_colorspace (v. 4)
VK_NV_external_memory_capabilities (v. 1)
______________________
Used Instance Layers :
VK_LAYER_KHRONOS_validation
VK_LAYER_LUNARG_monitor

Used Instance Extensions :
VK_EXT_debug_utils
VK_EXT_debug_utils
VK_KHR_surface
VK_KHR_win32_surface
VK_KHR_get_physical_device_properties2
C:\Users\Work\Documents\VulkanRTXTut\shared_sources\nvvk\context_vk.cpp(305): Vulkan Error : VK_ERROR_LAYER_NOT_PRESENT
Assertion failed: !"Critical Vulkan Error", file C:\Users\Work\Documents\VulkanRTXTut\shared_sources\nvvk\error_vk.cpp, line 119```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.