Skip to content

Commit

Permalink
merian: support push descriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
LDAP committed Aug 29, 2024
1 parent f285b66 commit 9009189
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
6 changes: 5 additions & 1 deletion include/merian/vk/descriptors/descriptor_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ class DescriptorSet : public std::enable_shared_from_this<DescriptorSet> {
}

operator const vk::DescriptorSetLayout&() const {
return *layout.get();
return *layout;
}

const vk::DescriptorSet& operator*() const {
return set;
}

const vk::DescriptorSet& get_descriptor_set() const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class DescriptorSetLayoutBuilder {

public:
DescriptorSetLayoutBuilder(std::vector<vk::DescriptorSetLayoutBinding> bindings = {}) {
add_binding(bindings);
add_binding(std::move(bindings));
}

// --------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -153,8 +153,8 @@ class DescriptorSetLayoutBuilder {
return *this;
}

DescriptorSetLayoutBuilder& add_binding(std::vector<vk::DescriptorSetLayoutBinding> bindings) {
for (auto& binding : bindings) {
DescriptorSetLayoutBuilder& add_binding(const std::vector<vk::DescriptorSetLayoutBinding>& bindings) {
for (const auto& binding : bindings) {
add_binding(binding);
}
return *this;
Expand Down
18 changes: 18 additions & 0 deletions include/merian/vk/extension/extension_vk_push_descriptor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include "merian/vk/extension/extension.hpp"

namespace merian {

class ExtensionVkPushDescriptor : public Extension {
public:
ExtensionVkPushDescriptor() : Extension("ExtensionVkPushDescriptor") {}
~ExtensionVkPushDescriptor() {}

std::vector<const char*>
required_device_extension_names(vk::PhysicalDevice) const override {
return {VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME};
}
};

} // namespace merian
10 changes: 8 additions & 2 deletions include/merian/vk/pipeline/pipeline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Pipeline : public std::enable_shared_from_this<Pipeline> {

// ---------------------------------------------------------------------------

operator const vk::Pipeline() const {
operator const vk::Pipeline&() const {
return pipeline;
}

Expand All @@ -38,7 +38,13 @@ class Pipeline : public std::enable_shared_from_this<Pipeline> {
const std::shared_ptr<DescriptorSet>& descriptor_set,
const uint32_t first_set = 0) {
cmd.bindDescriptorSets(get_pipeline_bind_point(), *pipeline_layout, first_set, 1,
&descriptor_set->get_descriptor_set(), 0, nullptr);
&**descriptor_set, 0, nullptr);
}

void push_descriptor_set(const vk::CommandBuffer& cmd,
const uint32_t set,
const std::vector<vk::WriteDescriptorSet>& writes) {
cmd.pushDescriptorSetKHR(get_pipeline_bind_point(), *pipeline_layout, set, writes);
}

// ---------------------------------------------------------------------------
Expand Down

0 comments on commit 9009189

Please sign in to comment.