templated pipeline
This commit is contained in:
parent
8275e01b6c
commit
74832c6824
8 changed files with 229 additions and 170 deletions
|
|
@ -9,30 +9,28 @@ import Crafter.Math;
|
|||
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;
|
||||
typedef VulkanShader<"closesthit.spv", "main", VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR, 0, {{}}> Closesthitspv;
|
||||
typedef VulkanShader<"miss.spv", "main", VK_SHADER_STAGE_MISS_BIT_KHR, 0, {{}}> Misspv;
|
||||
typedef std::tuple<Raygenspv, Misspv, Closesthitspv> AllShaders;
|
||||
typedef std::tuple<
|
||||
ShaderGroup<0, VK_SHADER_UNUSED_KHR, VK_SHADER_UNUSED_KHR, VK_SHADER_UNUSED_KHR>,
|
||||
ShaderGroup<1, VK_SHADER_UNUSED_KHR, VK_SHADER_UNUSED_KHR, VK_SHADER_UNUSED_KHR>,
|
||||
ShaderGroup<VK_SHADER_UNUSED_KHR, 2, VK_SHADER_UNUSED_KHR, VK_SHADER_UNUSED_KHR>
|
||||
> ShaderGroups;
|
||||
typedef PipelineRTVulkan<AllShaders, ShaderGroups> Pipeline;
|
||||
|
||||
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();
|
||||
WindowVulkan window(1280, 720, "HelloVulkan");
|
||||
VkCommandBuffer cmd = window.StartInit();
|
||||
|
||||
Raygenspv::CreateShader();
|
||||
Closesthitspv::CreateShader();
|
||||
Misspv::CreateShader();
|
||||
ShaderBindingTableVulkan<AllShaders>::Init();
|
||||
std::array<VkDescriptorSetLayout, 1> layouts {{Raygenspv::layout}};
|
||||
PipelineRTVulkan<Raygenspv, Closesthitspv, Misspv, Raygenspv, Closesthitspv, Misspv>::Init(layouts);
|
||||
Pipeline::Init(cmd, layouts);
|
||||
DescriptorPool pool;
|
||||
pool.sets.resize(1);
|
||||
pool.BuildPool(DescriptorPool::GetPoolSizes<Raygenspv, Closesthitspv, Misspv>(), layouts);
|
||||
|
||||
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();
|
||||
pool.BuildPool(DescriptorPool::GetPoolSizes<Raygenspv>(), layouts);
|
||||
|
||||
Mesh triangleMesh;
|
||||
std::array<Vertex, 3> verts {{{-150, -150, 100}, {0, 150, 100}, {150, -150, 100}}};
|
||||
|
|
@ -77,17 +75,10 @@ int main() {
|
|||
};
|
||||
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<Raygenspv, Closesthitspv, Misspv, Raygenspv, Closesthitspv, Misspv>();
|
||||
window.SetPipelineRT<Pipeline>();
|
||||
window.descriptorsRt = pool.sets;
|
||||
|
||||
|
||||
window.FinishInit();
|
||||
window.Render();
|
||||
window.StartSync();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue