#include import Crafter.Graphics; using namespace Crafter; import std; typedef VulkanShader<"raygen.spv", "main", VK_SHADER_STAGE_RAYGEN_BIT_KHR, 2, {{{VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, 0}, {VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1}}}> Raygenspv; int main() { /* This sets up all necessary things and creates the vulkan device. This must be called before any vulkan related things. Things like VkDevice are static members of the VulkanDevice class. */ VulkanDevice::CreateDevice(); Raygenspv::CreateShader(); DescriptorLayoutVulkan::Init(); PipelineRTVulkan::Init(); DescriptorPool<1, Raygenspv> pool; pool.setsCount = 1; pool.BuildPool(0); WindowVulkan window(1280, 720, "HelloVulkan"); /* StartInit gives you a VkCommandBuffer to use before the event loop starts Use this for inititializing things like textures. */ VkCommandBuffer cmd = window.StartInit(); Mesh triangleMesh; std::array verts {{{-0.1, 0, 0}, {0, 0.1, 0}, {0.1, 0, 0}}}; std::array index {{0,1,2}}; triangleMesh.Build(verts, index, cmd); RenderingElement3DVulkan::elements.emplace_back(triangleMesh); RenderingElement3DVulkan::BuildTLAS(cmd); VkDescriptorImageInfo imageInfo = { .imageView = window.imageViews[0], .imageLayout = VK_IMAGE_LAYOUT_GENERAL }; std::cout << pool.sets.size() << std::endl; VkWriteDescriptorSetAccelerationStructureKHR writeDescriptorSetAccelerationStructure { .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR, .accelerationStructureCount = 1, .pAccelerationStructures = &RenderingElement3DVulkan::accelerationStructure }; VkWriteDescriptorSet write[2] = { { .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .pNext = &writeDescriptorSetAccelerationStructure, .dstSet = pool.sets[0], .dstBinding = 0, .descriptorCount = 1, .descriptorType = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, .pBufferInfo = &RenderingElement3DVulkan::tlasBuffer.descriptor }, { .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstSet = pool.sets[0], .dstBinding = 1, .descriptorCount = 1, .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, .pImageInfo = &imageInfo } }; vkUpdateDescriptorSets(VulkanDevice::device, 2, write, 0, nullptr); /* FinishInit executes all commands recorded to StartInit. This must be called before the the event loops starts if you called StartInit before. */ window.FinishInit(); window.SetPipelineRT(); window.descriptorsRt = pool.sets; window.Render(); window.StartSync(); }