14 const VkPipelineLayoutCreateInfo * pPipelineLayoutCreateInfo,
15 const VkDescriptorSetLayoutCreateInfo * pDescriptorSetLayoutCreateInfo,
16 std::string shaderName,
17 const std::optional<const PipelineSpecializationData *> pSpecializationData
20 assert(pDescriptorSetLayoutCreateInfo !=
nullptr);
23 assert(pPipelineLayoutCreateInfo !=
nullptr);
26 if (device == VK_NULL_HANDLE) {
27 throw std::runtime_error(
"Invalid device handle in ComputePass::create");
30 throw std::runtime_error(
"Descriptor set layout creation failed in ComputePass::create");
34 VkPipelineLayoutCreateInfo localPipelineLayoutCreateInfo = *pPipelineLayoutCreateInfo;
35 localPipelineLayoutCreateInfo.setLayoutCount = 1;
38 PLOGD <<
"Creating pipeline layout for ComputePass: " <<
name;
43 throw std::runtime_error(
"Pipeline layout creation failed - returned null handle in ComputePass::create");
47 PLOGD <<
"Created pipeline layout with handle: 0x" << std::hex <<
pipelineLayout;
51 if (pSpecializationData)
54 PLOGI <<
"Created ComputePass " <<
name;
69 std::optional<const PipelineSpecializationData *> pSpecializationData
71 if (!pSpecializationData.has_value())
73 PLOGE <<
"Specialization Data is empty! This will cause the Dispatcher Compute Pass for " <<
getName() <<
" to have a thread count of 1. This applies for both this compute pass as well as for the assumed size of the next pass. Fix this as this will cause performance problems!";
100 .sType = VK_STRUCTURE_TYPE_PUSH_CONSTANTS_INFO,
103 .stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
111 assert(descriptorPool != VK_NULL_HANDLE);
112 VkDescriptorSetAllocateInfo descriptorSetAllocateInfo{
113 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
114 .descriptorPool = descriptorPool,
115 .descriptorSetCount = 1u,
134 vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE,
pipelineLayout, 0, 1u, &
descriptorSet[frameInFlightIndex], 0u,
nullptr);
140 PLOGW <<
"ComputePass::cleanup() called multiple times for " <<
name <<
". Ignoring subsequent calls.";
167 if ( !pSpecializationData.has_value() )
The application context is the core class which stores the basic openxr and vulkan objects.
const VkDevice getVkDevice() const
Gets the vulkan device.
std::array< VkDescriptorSet, MAX_FRAMES_IN_FLIGHT > descriptorSet
VkDescriptorSetLayout descriptorSetLayout
void createDescriptorSet(VkDevice device, uint32_t frameInFlightIndex, VkDescriptorPool descriptorPool)
Creates a vulkan descriptor set resource for a frame in flight into a specified descriptor pool.
DescriptorSetUpdater & updateDescriptorSet(uint32_t frameInFlightIndex)
Creates a descriptor set updater which is used to batch update descriptor set resources.
DescriptorSetUpdater descriptorSetBuilder
std::string getName() const
virtual void extractSpecializationData(std::optional< const PipelineSpecializationData * > pSpecializationData)
uint32_t getThreadCount() const
Gets the amount of threads this compute shader is running on on the GPU.
void bindDescriptorSets(VkCommandBuffer commandBuffer, uint32_t frameInFlightIndex)
Binds the descriptor set of a frame in flight.
void create(VkDevice device, const VkPipelineLayoutCreateInfo *pPipelineLayoutCreateInfo, const VkDescriptorSetLayoutCreateInfo *pDescriptorSetLayoutCreateInfo, std::string shaderName, std::optional< const PipelineSpecializationData * > pSpecializationData)
Creates a whole compute pass with a layout and everything. This is one of two steps needed to create ...
ComputePass(const std::string &name)
VkPipelineLayout & getPipelineLayout()
Gets the layout of this compute pipeline.
VkPipelineLayout pipelineLayout
VkPushConstantsInfo createPushConstantsInfo(uint32_t size, const void *pValues) const
Used to create preconfigured push constants where you only pass in the size of the push constant and ...
ComputePipeline * computePipeline
void cleanup(VkDevice device)
Cleanup of owned resources using direct VkDevice handle.
VkDescriptorSet getDescriptorSet(uint32_t frameInFlightIndex) const
Getter for the descriptor set of this pipeline.
VkDescriptorSetLayout & getDescriptorSetLayout()
Gets the descriptor set layout associated with this pipeline.
ComputePipeline * getComputePipeline()
Getter for the raw compute pipeline.
Wrapper for shader specialization data for compute pipelines. This usually only stores the thread cou...
A wrapper for vulkan pipeline resources. In this case a typesafe compute pipeline.
The Descriptor set updater is used to create a list of descriptor set writes which are executed with ...
void extractSpecializationData(std::optional< const PipelineSpecializationData * > pSpecializationData) override
DispatcherComputePass(const std::string &name)
uint32_t targetThreadCount
uint32_t getTargetThreadCount() const
static VkResult createPipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkPipelineLayout *pPipelineLayout, const std::string &name)
static std::string getDebugName(VulkanObjectType objectHandle)
static VkResult allocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, VkDescriptorSet *pDescriptorSets, const std::string &name)
static VkResult createDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout, const std::string &name)
Log category system implementation.