From b26afc2832fa9cebd49a2b93ca454a995db5a9a7 Mon Sep 17 00:00:00 2001 From: mklefrancois <38076163+mklefrancois@users.noreply.github.com> Date: Tue, 24 Nov 2020 16:31:49 +0100 Subject: [PATCH] Sync document with code --- ray_tracing_instances/README.md | 9 --------- ray_tracing_manyhits/README.md | 23 ++++++++++++++--------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/ray_tracing_instances/README.md b/ray_tracing_instances/README.md index 95f586f..84f17bb 100644 --- a/ray_tracing_instances/README.md +++ b/ray_tracing_instances/README.md @@ -152,15 +152,6 @@ DMA needs to be initialized, which will be done in the `setup()` function: #endif ~~~~ -When using DMA, memory buffer mapping is done through the DMA interface (instead of the VKDevice). -Therefore, change the lines at the end of `updateUniformBuffer()` to use the common allocator interface. - -~~~~ C++ -void* data = m_alloc.map(m_cameraMat); -memcpy(data, &ubo, sizeof(ubo)); -m_alloc.unmap(m_cameraMat); -~~~~ - The RaytracerBuilder was made to allow various allocators, therefore nothing to change in the call to `m_rtBuilder.setup()` diff --git a/ray_tracing_manyhits/README.md b/ray_tracing_manyhits/README.md index e677161..12cc095 100644 --- a/ray_tracing_manyhits/README.md +++ b/ray_tracing_manyhits/README.md @@ -257,21 +257,26 @@ Then change the call to `m_alloc.createBuffer` to create the SBT buffer from `sb m_rtSBTBuffer = m_alloc.createBuffer(cmdBuf, sbtBuffer, vk::BufferUsageFlagBits::eRayTracingKHR); ~~~~ -Note: we are using this `define` for rounding up to the correct alignment -~~~~ C++ -#ifndef ROUND_UP -#define ROUND_UP(v, powerOf2Alignment) (((v) + (powerOf2Alignment)-1) & ~((powerOf2Alignment)-1)) -#endif -~~~~ - ### `raytrace` Finally, since the size of the hit group is now larger than just the handle, we need to set the new value of the hit group stride in `HelloVulkan::raytrace`. ~~~~ C++ -vk::DeviceSize hitGroupStride = -ROUND_UP(m_rtProperties.shaderGroupHandleSize + sizeof(HitRecordBuffer), progOffset); + vk::DeviceSize hitGroupSize = + nvh::align_up(m_rtProperties.shaderGroupHandleSize + sizeof(HitRecordBuffer), + m_rtProperties.shaderGroupBaseAlignment); +~~~~ + +The stride device address will be modified like this: + +~~~~ C++ + using Stride = vk::StridedDeviceAddressRegionKHR; + std::array strideAddresses{ + Stride{sbtAddress + 0u * groupSize, groupStride, groupSize * 1}, // raygen + Stride{sbtAddress + 1u * groupSize, groupStride, groupSize * 2}, // miss + Stride{sbtAddress + 3u * groupSize, hitGroupSize, hitGroupSize * 3}, // hit + Stride{0u, 0u, 0u}}; // callable ~~~~ !!! Note: