VulkanTracer (rayx)

The VulkanTracer is a ray tracing module using VULKAN by KHRONOS GROUP to efficiently trace rays with hardware acceleration.

In the current version the Vulkan Engine is a Compute Class that runs as much parallel as possible on the GPU.

Current procedure:

  • generate rays
  • create input and output buffers
  • initialize Vulkan
  • run the main loop
  • clean up

initVulkan():

  • create a Vulkan instance
  • set up the debug messenger
  • pick the physical device and create a logical device to access it
  • create the input and output buffers
  • create the descriptors to connect the buffers to the shader
  • create a compute pipeline and a command buffer for the shader

mainLoop():

  • run the command buffer
  • read the data from the output buffer

How the VulkanTracer works

vulkan_flow

Buffer types used:

A uniform buffer (VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) is a descriptor type associated with a buffer resource directly, described in a shader as a structure with various members that load operations can be performed on. More here

A storage buffer (VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) is a descriptor type associated with a buffer resource directly, described in a shader as a structure with various members that load, store, and atomic operations can be performed on.


Buffers:

BuffersSize ( vkDeviceSize)UsageName
0NumverOfRays*RAY_DOUBLE_AMOUNTTransfer_DST|STORAGE_BUFFERRay Buffer
1NumberOfRays*RAY_DOUBLE_AMOUNTTransfer_SRC|STORAGE_BUFFEROutput Buffer
2Quadric_parm+beamlineSizeSTORAGE_BUFFERQuadric Buffer
3100STORAGE_BUFFERBuffer for xyznull
4xxxxxxxxxxxxxxxSTORAGE_BUFFERmaterialIndexBuf
5xxxxxxxxxxxxxxxSTORAGE_BUFFERmaterialBuf
6xxxxxxxxxxxxxxxSTORAGE_BUFFERdebugBuffer
Xmin(GPU_MAX_STAGING,numberOfRays)STORAGE|DST|SRCStaging Buffer

Buffer Usages:

VK_BUFFER_USAGE_TRANSFER_SRC_BIT specifies that the buffer can be used as the source of a transfer command (see the definition of VK_PIPELINE_STAGE_TRANSFER_BIT).

VK_BUFFER_USAGE_TRANSFER_DST_BIT specifies that the buffer can be used as the destination of a transfer command.