Sync document with code

This commit is contained in:
mklefrancois 2020-11-24 16:31:49 +01:00
parent 0bac428ad5
commit b26afc2832
2 changed files with 14 additions and 18 deletions

View file

@ -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()`

View file

@ -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<Stride, 4> 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: