This project demonstrates a basic raster rendering example in Vulkan, featuring:
- Camera manipulation
- Various geometric primitives
- Instance rendering
- Basic lighting model
The Simple Polygons sample showcases fundamental 3D graphics concepts using a modern Vulkan implementation. It serves as an educational tool for understanding basic rendering pipelines and scene management.
This sample is the repository's reference for VK_EXT_descriptor_heap used with a traditional graphics VkPipeline — no shader objects. The per-frame camera UBO is reached through a bound descriptor heap (nvvk::DescriptorHeap) instead of a descriptor set. Everything else about the pipeline is conventional, so this is a minimal "heaps without abandoning pipelines" example — the counterpart most PSO-based engines actually want.
Key points, visible in createPipeline() and onRender():
- The pipeline opts into the heap with
VK_PIPELINE_CREATE_2_DESCRIPTOR_HEAP_BIT_EXT(the pipeline-path counterpart of the shader-object flagVK_SHADER_CREATE_DESCRIPTOR_HEAP_BIT_EXT). - A descriptor-heap pipeline has no
VkPipelineLayout: the spec requireslayout == VK_NULL_HANDLE(VUID-VkGraphicsPipelineCreateInfo-flags-11311). Because there is no layout, per-draw data is sent withvkCmdPushDataEXT, notvkCmdPushConstants. m_heap.cmdBindHeaps(...)replacesvkCmdBindDescriptorSets;vkCmdBindPipelineand the rest of the raster setup are unchanged.- Only
VK_EXT_descriptor_heapandVK_KHR_shader_untyped_pointersare enabled — deliberately noVK_EXT_shader_object.
For the descriptor-heap concept in depth (mapping modes, sampler/resource heaps), see the descriptor_heap sample. For the same idea on a ray-tracing pipeline, see ray_trace.
The onAttach function sets up the rendering environment:
- Initializes the VMA (Vulkan Memory Allocator) for efficient memory management
- Constructs the scene graph, including:
- Primitive geometries
- Material definitions
- Instance references to meshes
- Creates Vulkan representations of the scene:
- Generates vertex and index buffers via
createVkBuffers - Establishes the rendering pipeline
- Generates vertex and index buffers via
The UI component provides:
- A camera widget in the settings window for view manipulation
- A viewport window displaying the rendered G-Buffer
The main rendering function iterates through all instance nodes in the scene, drawing each element.
Note: For performance optimization, especially with larger scenes, consider recording a command buffer instead of looping over rendering nodes in real-time.
