From 19356f9a280a121f24199afc371007208fe98a7f Mon Sep 17 00:00:00 2001 From: Artur Wasmut <awasmut@uni-koblenz.de> Date: Sat, 3 Jul 2021 15:27:29 +0200 Subject: [PATCH] [#87] Fetching the function pointer to relevant mesh shading draw commands now. Also, it compiles. GGWP vulkan.hpp for not being able to use extensions properly. --- include/vkcv/Context.hpp | 1 + include/vkcv/DrawcallRecording.hpp | 4 +++- src/vkcv/Context.cpp | 5 +++++ src/vkcv/DrawcallRecording.cpp | 18 +++++++++++++++++- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/vkcv/Context.hpp b/include/vkcv/Context.hpp index be693399..15e06316 100644 --- a/include/vkcv/Context.hpp +++ b/include/vkcv/Context.hpp @@ -3,6 +3,7 @@ #include <vulkan/vulkan.hpp> #include "QueueManager.hpp" +#include "DrawcallRecording.hpp" namespace vkcv { diff --git a/include/vkcv/DrawcallRecording.hpp b/include/vkcv/DrawcallRecording.hpp index e1526689..50fb0846 100644 --- a/include/vkcv/DrawcallRecording.hpp +++ b/include/vkcv/DrawcallRecording.hpp @@ -51,8 +51,10 @@ namespace vkcv { const PushConstantData &pushConstantData, const size_t drawcallIndex); + void InitMeshShaderDrawFunctions(vk::Device device); + struct MeshShaderDrawcall { - inline MeshShaderDrawcall(const std::vector<DescriptorSetUsage> descriptorSets, uint32_t taskCout) + inline MeshShaderDrawcall(const std::vector<DescriptorSetUsage> descriptorSets, uint32_t taskCount) : descriptorSets(descriptorSets), taskCount(taskCount) {} std::vector<DescriptorSetUsage> descriptorSets; diff --git a/src/vkcv/Context.cpp b/src/vkcv/Context.cpp index 49aea650..8f6efea2 100644 --- a/src/vkcv/Context.cpp +++ b/src/vkcv/Context.cpp @@ -307,6 +307,11 @@ namespace vkcv // jetzt koennen wir mit dem device die queues erstellen vk::Device device = physicalDevice.createDevice(deviceCreateInfo); + + if (usingMeshShaders) + { + InitMeshShaderDrawFunctions(device); + } QueueManager queueManager = QueueManager::create(device, queuePairsGraphics, queuePairsCompute, queuePairsTransfer); diff --git a/src/vkcv/DrawcallRecording.cpp b/src/vkcv/DrawcallRecording.cpp index 18eb896b..6ff3209b 100644 --- a/src/vkcv/DrawcallRecording.cpp +++ b/src/vkcv/DrawcallRecording.cpp @@ -43,6 +43,22 @@ namespace vkcv { } } + + + struct MeshShaderFunctions + { + PFN_vkCmdDrawMeshTasksNV cmdDrawMeshTasks = nullptr; + PFN_vkCmdDrawMeshTasksIndirectNV cmdDrawMeshTasksIndirect = nullptr; + PFN_vkCmdDrawMeshTasksIndirectCountNV cmdDrawMeshTasksIndirectCount = nullptr; + } MeshShaderFunctions; + + void InitMeshShaderDrawFunctions(vk::Device device) + { + MeshShaderFunctions.cmdDrawMeshTasks = reinterpret_cast<PFN_vkCmdDrawMeshTasksNV>(vkGetDeviceProcAddr(VkDevice(device), "vkCmdDrawMeshTasksNV")); + MeshShaderFunctions.cmdDrawMeshTasksIndirect = reinterpret_cast<PFN_vkCmdDrawMeshTasksIndirectNV>(vkGetDeviceProcAddr(VkDevice(device), "vkCmdDrawMeshTasksIndirectNV")); + MeshShaderFunctions.cmdDrawMeshTasksIndirectCount = reinterpret_cast<PFN_vkCmdDrawMeshTasksIndirectCountNV>(vkGetDeviceProcAddr(VkDevice(device), "vkCmdDrawMeshTasksIndirectCountNV")); + } + void recordMeshShaderDrawcall( vk::CommandBuffer cmdBuffer, vk::PipelineLayout pipelineLayout, @@ -71,6 +87,6 @@ namespace vkcv { pushConstantData.sizePerDrawcall, drawcallPushConstantData); - cmdBuffer.drawMeshTasksNV(drawcall.taskCount, firstTask); + MeshShaderFunctions.cmdDrawMeshTasks(cmdBuffer, drawcall.taskCount, firstTask); } } \ No newline at end of file -- GitLab